:root {
  --bg: #1f2419;
  --bg-deep: #171b13;
  --paper: #f5f1e3;
  --paper-shadow: #d8d0b8;
  --ink: #2b2b24;
  --ink-soft: #55503f;
  --amber: #d9a441;
  --rust: #a8432f;
  --sage: #7c8b6f;
  --line: rgba(245, 241, 227, 0.14);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    radial-gradient(ellipse at top, rgba(124, 139, 111, 0.08), transparent 60%),
    var(--bg);
  color: var(--paper);
  font-family: "Source Serif 4", serif;
  min-height: 100vh;
  padding: 0 0 6rem;
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    transition: none !important;
  }
}

/* ---------- Header ---------- */

header {
  padding: 3.5rem 1.5rem 2.5rem;
  text-align: center;
  border-bottom: 1px dashed var(--line);
  position: relative;
}

.eyebrow {
  font-family: "IBM Plex Mono", monospace;
  letter-spacing: 0.35em;
  text-transform: uppercase;
  font-size: 0.68rem;
  color: var(--sage);
  margin: 0 0 0.9rem;
}

h1 {
  font-family: "Special Elite", monospace;
  font-size: clamp(2.2rem, 6vw, 3.6rem);
  margin: 0;
  color: var(--paper);
  letter-spacing: 0.02em;
  text-shadow: 2px 2px 0 rgba(0, 0, 0, 0.25);
}

.subhead {
  max-width: 34rem;
  margin: 1rem auto 0;
  color: rgba(245, 241, 227, 0.72);
  font-size: 1.02rem;
  line-height: 1.6;
}

.subhead em {
  color: var(--amber);
  font-style: normal;
}

/* ---------- Main capture area ---------- */

main {
  max-width: 880px;
  margin: 0 auto;
  padding: 3rem 1.5rem 0;
}

.capture {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
}

.plate {
  width: 100%;
  max-width: 420px;
  background: var(--paper);
  padding: 1rem 1rem 3rem;
  box-shadow:
    0 18px 40px rgba(0, 0, 0, 0.45),
    0 2px 0 rgba(0, 0, 0, 0.2);
  transform: rotate(-1.2deg);
  position: relative;
}

.plate::before {
  content: "";
  position: absolute;
  top: -10px;
  left: 50%;
  transform: translateX(-50%) rotate(3deg);
  width: 70px;
  height: 24px;
  background: rgba(217, 164, 65, 0.55);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.frame {
  width: 100%;
  aspect-ratio: 1 / 1;
  background: var(--bg-deep) center/cover no-repeat;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-soft);
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.85rem;
  overflow: hidden;
}

.frame img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.caption-line {
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.78rem;
  color: var(--ink-soft);
  text-align: center;
  margin-top: 0.9rem;
  letter-spacing: 0.03em;
}

.caption-line strong {
  color: var(--ink);
  text-transform: capitalize;
}

/* ADDED FEATURE: Simple small font styling for the dog fact */
.fact-line {
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.7rem;
  color: var(--ink-soft);
  text-align: center;
  margin-top: 0.4rem;
  line-height: 1.35;
  padding: 0 0.5rem;
}

.fact-label {
  color: var(--rust);
  font-weight: 600;
  text-transform: uppercase;
}

.controls {
  display: flex;
  gap: 0.85rem;
  flex-wrap: wrap;
  justify-content: center;
}

button {
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.82rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 0.85rem 1.4rem;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--paper);
  cursor: pointer;
  transition:
    background 0.15s ease,
    color 0.15s ease,
    border-color 0.15s ease,
    transform 0.1s ease;
}

button:hover {
  border-color: var(--amber);
  color: var(--amber);
}

button:active {
  transform: scale(0.97);
}

button:focus-visible {
  outline: 2px solid var(--amber);
  outline-offset: 3px;
}

button.primary {
  background: var(--amber);
  border-color: var(--amber);
  color: var(--bg-deep);
  font-weight: 600;
}

button.primary:hover {
  background: #e8b455;
  color: var(--bg-deep);
}

button.save {
  background: var(--sage);
  border-color: var(--sage);
  color: var(--bg-deep);
  font-weight: 600;
}

button.save:hover {
  background: #8fa082;
  color: var(--bg-deep);
}

button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ---------- Catalog section ---------- */

.catalog-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin: 4.5rem 0 1.5rem;
  padding-bottom: 0.6rem;
  border-bottom: 1px dashed var(--line);
}

.catalog-head h2 {
  font-family: "Special Elite", monospace;
  font-size: 1.25rem;
  margin: 0;
  color: var(--amber);
  letter-spacing: 0.02em;
}

.catalog-count {
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.75rem;
  color: rgba(245, 241, 227, 0.55);
}

.empty-state {
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.85rem;
  color: rgba(245, 241, 227, 0.45);
  padding: 2.5rem 1rem;
  text-align: center;
  border: 1px dashed var(--line);
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 1.6rem;
}

.card {
  background: var(--paper);
  padding: 0.7rem 0.7rem 1rem;
  position: relative;
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.35);
  animation: settle 0.35s ease both;
}

@keyframes settle {
  from {
    opacity: 0;
    transform: translateY(10px) rotate(0deg);
  }
  to {
    opacity: 1;
    transform: translateY(0) rotate(var(--tilt, 0deg));
  }
}

.card img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  display: block;
  filter: sepia(0.06) contrast(1.02);
}

/* ADDED FEATURE: Fact line on saved cards inside catalog grid */
.card-fact {
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.62rem;
  color: var(--ink-soft);
  margin-top: 0.4rem;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-meta {
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.68rem;
  color: var(--ink-soft);
  margin-top: 0.55rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.4rem;
}

.card-meta .num {
  color: var(--rust);
  font-weight: 600;
}

.card-meta .breed {
  text-transform: capitalize;
  color: var(--ink);
  text-align: right;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stamp {
  position: absolute;
  top: 0.4rem;
  right: 0.4rem;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 2px solid var(--rust);
  color: var(--rust);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: "Special Elite", monospace;
  font-size: 0.9rem;
  transform: rotate(-14deg);
  background: rgba(245, 241, 227, 0.85);
  opacity: 0.9;
}

.remove-btn {
  position: absolute;
  bottom: 0.5rem;
  right: 0.5rem;
  background: var(--bg-deep);
  color: var(--paper);
  border: none;
  width: 22px;
  height: 22px;
  line-height: 22px;
  text-align: center;
  padding: 0;
  font-size: 0.75rem;
  border-radius: 50%;
  opacity: 0.75;
}

.remove-btn:hover {
  opacity: 1;
  color: var(--rust);
  border-color: transparent;
}

/* ADDED FEATURE: Share / Download button for single cards */
.share-btn {
  position: absolute;
  bottom: 0.5rem;
  right: 2.1rem;
  background: var(--bg-deep);
  color: var(--paper);
  border: none;
  width: 22px;
  height: 22px;
  line-height: 22px;
  text-align: center;
  padding: 0;
  font-size: 0.75rem;
  border-radius: 50%;
  opacity: 0.75;
}

.share-btn:hover {
  opacity: 1;
  color: var(--amber);
  border-color: transparent;
}

footer {
  text-align: center;
  margin-top: 4rem;
  padding: 1.5rem;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.7rem;
  color: rgba(245, 241, 227, 0.35);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}
