:root {
  --bg: #EDF1E9;
  --ink: #1F2A24;
  --ink-soft: #4B584F;
  --amber: #E8A33D;
  --amber-deep: #C9821F;
  --coral: #E2665B;
  --card: #FFFFFF;
  --line: rgba(31, 42, 36, 0.14);
  --radius: 10px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: 'Inter', system-ui, sans-serif;
  line-height: 1.5;
}

.wrap {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 24px;
}

a { color: inherit; }

/* Header */
.site-header {
  border-bottom: 1px solid var(--line);
  padding: 20px 0;
}
.header-inner {
  display: flex;
  align-items: baseline;
  gap: 16px;
  flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 8px; }
.brand-mark { font-size: 1.2rem; }
.brand-name {
  font-family: 'Fraunces', serif;
  font-weight: 600;
  font-size: 1.15rem;
  letter-spacing: -0.01em;
}
.brand-tag {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.9rem;
}
.site-nav {
  margin-left: auto;
  display: flex;
  gap: 20px;
}
.site-nav a {
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--ink-soft);
  border-bottom: 2px solid transparent;
  padding-bottom: 2px;
}
.site-nav a:hover { color: var(--ink); border-bottom-color: var(--amber); }

.demo-banner {
  background: rgba(232, 163, 61, 0.16);
  border-bottom: 1px solid var(--line);
  font-size: 0.85rem;
  color: var(--ink);
  padding: 10px 0;
}

/* Simple content pages (privacy, contact) */
.page-content {
  padding: 48px 0 60px;
  max-width: 720px;
}
.page-content h1 {
  font-family: 'Fraunces', serif;
  font-weight: 600;
  font-size: 2.1rem;
  margin: 0 0 8px;
}
.page-content .page-updated {
  color: var(--ink-soft);
  font-size: 0.85rem;
  margin: 0 0 32px;
}
.page-content h2 {
  font-family: 'Fraunces', serif;
  font-weight: 600;
  font-size: 1.25rem;
  margin: 32px 0 10px;
}
.page-content p, .page-content li {
  font-size: 0.97rem;
  color: var(--ink);
}
.page-content ul { padding-left: 20px; }

/* Contact form */
.contact-form {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 480px;
}
.contact-form label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-soft);
  font-weight: 500;
  display: block;
  margin-bottom: 6px;
}
.contact-form input, .contact-form textarea {
  width: 100%;
  font-family: 'Inter', sans-serif;
  font-size: 0.95rem;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg);
  color: var(--ink);
  resize: vertical;
}
.contact-form textarea { min-height: 120px; }
.contact-form button {
  align-self: flex-start;
  font-family: 'Inter', sans-serif;
  font-weight: 600;
  font-size: 0.95rem;
  background: var(--ink);
  color: var(--bg);
  border: none;
  border-radius: 6px;
  padding: 11px 22px;
  cursor: pointer;
}
.contact-form button:hover { background: #34423A; }

.flash {
  padding: 12px 16px;
  border-radius: 6px;
  margin-bottom: 20px;
  font-size: 0.9rem;
  max-width: 480px;
}
.flash-success { background: rgba(232,163,61,0.18); color: var(--ink); }
.flash-error { background: rgba(226,102,91,0.15); color: var(--coral); }

/* Pet profile page */
.profile-layout {
  display: grid;
  grid-template-columns: minmax(280px, 420px) 1fr;
  gap: 40px;
  padding: 40px 0 60px;
  align-items: start;
}
.profile-photo {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--bg);
}
.profile-photo img {
  width: 100%;
  display: block;
  aspect-ratio: 4 / 3;
  /* contain, not cover: pet photos are often portrait, and cover was
     cropping heads off. Letterbox on the page background instead. */
  object-fit: contain;
  background: var(--bg);
}
.back-link {
  display: inline-block;
  font-size: 0.85rem;
  color: var(--ink-soft);
  text-decoration: none;
  margin-bottom: 18px;
}
.back-link:hover { color: var(--ink); }
.profile-name-row {
  display: flex;
  align-items: baseline;
  gap: 14px;
  flex-wrap: wrap;
}
.profile-name-row h1 {
  font-family: 'Fraunces', serif;
  font-weight: 600;
  font-size: 2.4rem;
  margin: 0;
}
.profile-tag {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.85rem;
  color: var(--ink-soft);
  margin: 8px 0 24px;
}
.profile-facts {
  display: flex;
  gap: 32px;
  padding: 16px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  margin-bottom: 24px;
}
.profile-facts span {
  display: block;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-soft);
  margin-bottom: 4px;
}
.profile-facts strong {
  font-size: 0.95rem;
  font-weight: 600;
}
.profile-body h2 {
  font-family: 'Fraunces', serif;
  font-weight: 600;
  font-size: 1.2rem;
  margin: 0 0 10px;
}
.profile-bio {
  font-size: 0.98rem;
  line-height: 1.6;
  color: var(--ink);
  max-width: 60ch;
}
.profile-cta { margin-top: 28px; }
.profile-cta .btn-search {
  display: inline-block;
  text-decoration: none;
}

@media (max-width: 720px) {
  .profile-layout { grid-template-columns: 1fr; }
}

/* Pet detail modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(31, 42, 36, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 100;
}
/* The hidden attribute's default display:none loses to the explicit
   display:flex above -- restore it with higher specificity. */
.modal-overlay[hidden] {
  display: none;
}
.modal {
  background: var(--card);
  border-radius: var(--radius);
  max-width: 560px;
  width: 100%;
  max-height: 88vh;
  overflow-y: auto;
  position: relative;
  box-shadow: 0 20px 60px rgba(31,42,36,0.3);
}
.modal-close {
  position: absolute;
  top: 10px; right: 12px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 50%;
  width: 34px; height: 34px;
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
  color: var(--ink);
  z-index: 2;
}
.modal-close:hover { background: var(--bg); }
.modal-photo img {
  width: 100%;
  max-height: 46vh;
  /* contain, like the details page: portrait pet photos were getting
     absurd crops in a fixed landscape box. Show the whole photo. */
  object-fit: contain;
  background: var(--bg);
  display: block;
  border-radius: var(--radius) var(--radius) 0 0;
}
.modal-body {
  padding: 20px 22px 26px;
}
.modal-name-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}
.modal-name-row h2 {
  font-family: 'Fraunces', serif;
  font-weight: 600;
  font-size: 1.6rem;
  margin: 0;
}
.modal-tag { margin: 6px 0 12px; }
.modal-traits {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}
.modal-traits:empty { display: none; }
.trait-badge {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--ink);
  padding: 4px 9px;
  border-radius: 4px;
}
.modal-description {
  font-size: 0.95rem;
  line-height: 1.6;
  color: var(--ink);
  margin: 0 0 14px;
}
.modal-org {
  font-size: 0.82rem;
  color: var(--ink-soft);
  margin: 0 0 18px;
}
.modal-cta {
  display: inline-block;
  text-decoration: none;
}

/* Live profile photo gallery */
.profile-gallery { display: flex; flex-direction: column; gap: 12px; }
.gallery-thumbs {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
  gap: 10px;
}
.gallery-thumb {
  padding: 0;
  border: 2px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  background: var(--bg);
  aspect-ratio: 1 / 1;
}
.gallery-thumb img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}
.gallery-thumb.active { border-color: var(--amber-deep); }
.gallery-thumb:hover { border-color: var(--ink-soft); }

/* Hero */
.hero { padding: 56px 0 40px; }
.hero h1 {
  font-family: 'Fraunces', serif;
  font-weight: 600;
  font-size: clamp(2rem, 5vw, 3.1rem);
  line-height: 1.08;
  letter-spacing: -0.01em;
  margin: 0 0 32px;
  max-width: 14ch;
}
.hero h1 em {
  font-style: italic;
  color: var(--amber-deep);
}

.search-form {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  display: grid;
  grid-template-columns: 2fr 1fr 1fr auto;
  gap: 14px;
  align-items: end;
  position: relative;
  box-shadow: 0 1px 0 rgba(31,42,36,0.03);
}
/* index-card notch, referencing the physical kennel card this whole design borrows from */
.search-form::before {
  content: "";
  position: absolute;
  top: -1px; left: 24px;
  width: 40px; height: 6px;
  background: var(--amber);
  border-radius: 0 0 4px 4px;
}

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-soft);
  font-weight: 500;
}
.field input, .field select {
  font-family: 'Inter', sans-serif;
  font-size: 0.95rem;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg);
  color: var(--ink);
}
.field input:focus, .field select:focus, .btn-search:focus {
  outline: 2px solid var(--amber-deep);
  outline-offset: 1px;
}

.btn-search {
  font-family: 'Inter', sans-serif;
  font-weight: 600;
  font-size: 0.95rem;
  background: var(--ink);
  color: var(--bg);
  border: none;
  border-radius: 6px;
  padding: 11px 22px;
  cursor: pointer;
  transition: background 0.15s ease;
}
.btn-search:hover { background: #34423A; }

@media (max-width: 720px) {
  .search-form { grid-template-columns: 1fr 1fr; }
  .btn-search { grid-column: 1 / -1; }
}

/* Status / empty states */
.status {
  min-height: 1.4em;
  margin: 8px 0 24px;
  font-size: 0.95rem;
  color: var(--ink-soft);
}
.status.error { color: var(--coral); font-weight: 500; }

/* Results grid */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 22px;
  padding-bottom: 40px;
}

.kcard {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  position: relative;
  display: flex;
  flex-direction: column;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.kcard:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(31,42,36,0.10);
}
.kcard-punch {
  position: absolute;
  top: 10px; right: 10px;
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--bg);
  border: 1px solid var(--line);
  z-index: 2;
}
.kcard-photo {
  aspect-ratio: 4 / 3;
  background: var(--bg);
  position: relative;
}
.kcard-photo img {
  width: 100%; height: 100%;
  object-fit: cover;
  object-position: center top; /* keep heads in frame on portrait photos */
  display: block;
}
.kcard-photo-fallback {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  color: var(--ink-soft);
  font-size: 0.85rem;
  font-family: 'IBM Plex Mono', monospace;
}
.kcard-photo:has(img[src]) .kcard-photo-fallback { display: none; }

.kcard-body {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}
.kcard-name-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}
.kcard-name {
  font-family: 'Fraunces', serif;
  font-weight: 600;
  font-size: 1.15rem;
  margin: 0;
}
.kcard-status {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--amber-deep);
  background: rgba(232,163,61,0.15);
  padding: 3px 7px;
  border-radius: 4px;
  white-space: nowrap;
}
.kcard-tag {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.72rem;
  color: var(--ink-soft);
  margin: 0;
  letter-spacing: 0.01em;
}
.kcard-blurb {
  font-size: 0.85rem;
  color: var(--ink);
  margin: 0;
  line-height: 1.45;
}
.kcard-loc {
  font-size: 0.85rem;
  color: var(--ink-soft);
  margin: 0;
}
.kcard-link {
  margin-top: auto;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink);
  text-decoration: none;
  border-top: 1px solid var(--line);
  padding-top: 10px;
}
.kcard-link:hover { color: var(--amber-deep); }

/* Pager */
.pager {
  display: flex;
  justify-content: center;
  gap: 10px;
  padding-bottom: 60px;
}
.pager button {
  font-family: 'Inter', sans-serif;
  font-size: 0.9rem;
  font-weight: 500;
  padding: 9px 18px;
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 6px;
  cursor: pointer;
}
.pager button:disabled { opacity: 0.4; cursor: not-allowed; }
.pager button:not(:disabled):hover { border-color: var(--amber-deep); }

/* Footer */
.site-footer {
  border-top: 1px solid var(--line);
  padding: 24px 0 40px;
  color: var(--ink-soft);
  font-size: 0.82rem;
}

@media (prefers-reduced-motion: reduce) {
  .kcard, html { transition: none; scroll-behavior: auto; }
}
