/* ==========================================================================
   Doguesser — visual system
   Palette named after dog-coat vocabulary: sable, fawn, liver, golden.
   ========================================================================== */

:root {
  --sable: #1b1614;
  --kennel: #251e1a;
  --kennel-2: #2f2620;
  --rope: #3d322b;
  --fawn: #f4eae0;
  --taupe: #a99485;
  --golden: #e8a33d;
  --golden-deep: #b4783c;
  --clay: #c9553b;

  --display: 'Fraunces', Georgia, 'Times New Roman', serif;
  --ui: 'Figtree', system-ui, -apple-system, 'Segoe UI', sans-serif;

  --radius: 14px;
  --radius-sm: 8px;
  --shell: 34rem;
  --read: 40rem;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--sable);
  color: var(--fawn);
  font-family: var(--ui);
  font-size: 17px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; display: block; }

a { color: var(--golden); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--fawn); }

:focus-visible {
  outline: 2px solid var(--golden);
  outline-offset: 3px;
  border-radius: 4px;
}

.skip-link {
  position: absolute;
  left: -9999px;
  background: var(--golden);
  color: var(--sable);
  padding: 0.6rem 1rem;
  font-weight: 600;
  z-index: 100;
}
.skip-link:focus { left: 1rem; top: 1rem; }

.is-hidden { visibility: hidden; }

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

.topbar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--rope);
  position: sticky;
  top: 0;
  background: rgba(27, 22, 20, 0.92);
  backdrop-filter: blur(8px);
  z-index: 20;
}

.wordmark {
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.45rem;
  letter-spacing: -0.02em;
  color: var(--fawn);
  text-decoration: none;
  margin-right: auto;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.wordmark img { height: 30px; width: auto; }
.wordmark:hover { color: var(--golden); }

.icon-btn {
  background: none;
  border: 1px solid var(--rope);
  color: var(--taupe);
  width: 38px;
  height: 38px;
  border-radius: 50%;
  font-size: 1rem;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: color 0.15s, border-color 0.15s;
}
.icon-btn:hover { color: var(--golden); border-color: var(--golden-deep); }

/* --- Stage ---------------------------------------------------------------- */

.stage {
  max-width: var(--shell);
  margin: 0 auto;
  padding: 1.25rem 1rem 2rem;
}

.mode {
  display: flex;
  gap: 0.35rem;
  background: var(--kennel);
  border: 1px solid var(--rope);
  border-radius: 999px;
  padding: 0.25rem;
  width: fit-content;
  margin: 0 auto 0.9rem;
}
.mode button {
  background: none;
  border: 0;
  color: var(--taupe);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  padding: 0.35rem 1.1rem;
  border-radius: 999px;
  cursor: pointer;
}
.mode button[aria-pressed='true'] { background: var(--golden); color: #241a10; }

.stage-heading {
  font-family: var(--display);
  font-size: 1.6rem;
  font-weight: 600;
  line-height: 1.2;
  text-align: center;
  margin: 0 0 0.15rem;
  letter-spacing: -0.02em;
}
.stage-sub {
  text-align: center;
  color: var(--taupe);
  font-size: 0.92rem;
  margin: 0 0 1.1rem;
}

/* --- Photo, the hero of the page ------------------------------------------ */

.photo-frame {
  position: relative;
  aspect-ratio: 5 / 4;
  max-height: 320px;
  margin: 0 auto;
  background: var(--kennel);
  border: 1px solid var(--rope);
  border-radius: var(--radius);
  overflow: hidden;
  display: grid;
  place-items: center;
}
.photo-frame img { width: 100%; height: 100%; object-fit: cover; }

.photo-frame.is-loading::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(100deg, var(--kennel) 30%, var(--kennel-2) 50%, var(--kennel) 70%);
  background-size: 220% 100%;
  animation: sweep 1.3s infinite linear;
}
@keyframes sweep { to { background-position: -220% 0; } }

.photo-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin: 0.5rem 0 1.2rem;
  font-size: 0.85rem;
  color: var(--taupe);
}
.ghost-btn {
  background: none;
  border: 1px solid var(--rope);
  color: var(--fawn);
  font: inherit;
  font-size: 0.85rem;
  padding: 0.3rem 0.8rem;
  border-radius: 999px;
  cursor: pointer;
}
.ghost-btn:hover { border-color: var(--golden-deep); color: var(--golden); }

/* --- Breed board ---------------------------------------------------------- */

.breed-board {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.4rem 0.75rem;
  margin-bottom: 1.4rem;
}
.word { display: flex; gap: 0.25rem; }
.slot {
  width: 26px;
  height: 32px;
  display: grid;
  place-items: center;
  font-family: var(--display);
  font-size: 1.05rem;
  font-weight: 600;
  border-bottom: 3px solid var(--rope);
  color: var(--fawn);
}
.slot.is-revealed {
  color: var(--golden);
  border-bottom-color: var(--golden);
  animation: rise 0.45s backwards;
}
.slot.is-missed { color: var(--taupe); border-bottom-color: var(--taupe); }
@keyframes rise {
  from { transform: translateY(6px) scale(0.85); opacity: 0; }
  to { transform: none; opacity: 1; }
}

/* --- Guess grid ----------------------------------------------------------- */

.grid { display: grid; gap: 5px; justify-content: center; margin-bottom: 0.6rem; }
.row { display: grid; grid-template-columns: repeat(5, 46px); gap: 5px; }
.tile {
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border: 2px solid var(--rope);
  border-radius: var(--radius-sm);
  font-size: 1.4rem;
  font-weight: 800;
  background: transparent;
}
.tile.is-typed { border-color: var(--taupe); animation: pop 0.1s; }
.tile.found { background: var(--golden); border-color: var(--golden); color: #241a10; }
.tile.miss { background: var(--kennel-2); border-color: var(--kennel-2); color: var(--taupe); }
.tile.flip { animation: flip 0.5s; }

@keyframes pop { 50% { transform: scale(1.08); } }
@keyframes flip { 0% { transform: rotateX(0); } 50% { transform: rotateX(90deg); } 100% { transform: rotateX(0); } }
.shake { animation: shake 0.45s; }
@keyframes shake {
  10%, 90% { transform: translateX(-2px); }
  30%, 70% { transform: translateX(4px); }
  50% { transform: translateX(-4px); }
}

.tries { text-align: center; color: var(--taupe); font-size: 0.85rem; margin: 0 0 1rem; }

/* --- Keyboard ------------------------------------------------------------- */

.keyboard { display: grid; gap: 6px; }
.key-row { display: flex; gap: 5px; justify-content: center; }
.key {
  flex: 1 1 auto;
  min-width: 0;
  padding: 0.9rem 0.2rem;
  background: var(--kennel-2);
  border: 0;
  border-radius: var(--radius-sm);
  color: var(--fawn);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}
.key:hover { background: var(--rope); }
.key.wide { flex: 1.6 1 auto; font-size: 0.78rem; }
.key.found { background: var(--golden); color: #241a10; }
.key.miss { background: #201a17; color: #6d5f56; }

/* --- Toast & modals ------------------------------------------------------- */

.toast {
  position: fixed;
  left: 50%;
  top: 5.5rem;
  transform: translate(-50%, -8px);
  background: var(--fawn);
  color: var(--sable);
  font-weight: 600;
  font-size: 0.9rem;
  padding: 0.55rem 1rem;
  border-radius: 999px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 60;
}
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

.modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 11, 10, 0.86);
  display: grid;
  place-items: center;
  padding: 1rem;
  z-index: 80;
}
.modal[hidden] { display: none; }
.modal-card {
  background: var(--kennel);
  border: 1px solid var(--rope);
  border-radius: var(--radius);
  padding: 1.75rem 1.5rem 1.5rem;
  width: 100%;
  max-width: 25rem;
  max-height: 90vh;
  overflow-y: auto;
  text-align: center;
  position: relative;
  animation: lift 0.25s;
}
@keyframes lift { from { transform: translateY(10px); opacity: 0; } }

.modal-close {
  position: absolute;
  top: 0.6rem;
  right: 0.8rem;
  background: none;
  border: 0;
  color: var(--taupe);
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
}
.modal-close:hover { color: var(--fawn); }

.result-title {
  font-family: var(--display);
  font-size: 1.7rem;
  font-weight: 600;
  margin: 0 0 0.2rem;
  color: var(--golden);
}
.result-title.is-loss { color: var(--clay); }
.result-breed { font-size: 1.15rem; font-weight: 700; margin: 0 0 0.35rem; }
.result-note { color: var(--taupe); font-size: 0.9rem; margin: 0 0 1rem; }
.result-photo img {
  width: 160px;
  height: 160px;
  object-fit: cover;
  border-radius: var(--radius);
  margin: 0 auto 1rem;
}

.btn {
  display: block;
  width: 100%;
  padding: 0.85rem 1rem;
  border: 0;
  border-radius: var(--radius-sm);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  margin-top: 0.5rem;
  background: var(--golden);
  color: #241a10;
}
.btn:hover { background: #f0b155; }
.btn.secondary { background: none; border: 1px solid var(--rope); color: var(--fawn); }
.btn.secondary:hover { border-color: var(--golden-deep); color: var(--golden); }

.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.5rem; margin: 1rem 0; }
.stat b { display: block; font-size: 1.5rem; font-family: var(--display); font-weight: 600; }
.stat span { font-size: 0.72rem; color: var(--taupe); }

.distro { display: grid; gap: 4px; text-align: left; }
.bar-row { display: flex; align-items: center; gap: 0.5rem; font-size: 0.8rem; color: var(--taupe); }
.bar {
  background: var(--rope);
  color: var(--fawn);
  padding: 0.1rem 0.4rem;
  border-radius: 3px;
  font-size: 0.75rem;
  text-align: right;
  font-weight: 700;
}

/* --- Editorial content ---------------------------------------------------- */

.content { max-width: var(--read); margin: 0 auto; padding: 0 1.15rem 3rem; }
.content section { padding-top: 2.5rem; }

h1, h2, h3 { font-family: var(--display); font-weight: 600; letter-spacing: -0.02em; line-height: 1.2; }
h1 { font-size: 2rem; margin: 0 0 0.6rem; }
h2 { font-size: 1.4rem; margin: 0 0 0.7rem; }
h3 { font-size: 1.08rem; margin: 1.6rem 0 0.3rem; }
p { margin: 0 0 1rem; }
.lede { color: var(--taupe); font-size: 1.05rem; }

.steps { list-style: none; counter-reset: step; padding: 0; margin: 0; }
.steps li {
  counter-increment: step;
  display: grid;
  grid-template-columns: 2rem 1fr;
  gap: 0.85rem;
  padding: 0.9rem 0;
  border-top: 1px solid var(--rope);
}
.steps li::before {
  content: counter(step);
  font-family: var(--display);
  font-size: 1.2rem;
  color: var(--golden);
  align-self: start;
  padding-top: 0.1em;
}
.steps .step-text { display: block; }
.steps b { display: inline; }
.steps b::after { content: ' — '; color: var(--taupe); font-weight: 400; }
.steps span { color: var(--taupe); font-size: 0.95rem; display: inline; }

.faq { border-top: 1px solid var(--rope); }
.faq details { border-bottom: 1px solid var(--rope); }
.faq summary {
  cursor: pointer;
  padding: 0.9rem 0;
  font-weight: 600;
  list-style: none;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: '+'; color: var(--golden); font-size: 1.2rem; line-height: 1; }
.faq details[open] summary::after { content: '–'; }
.faq details p { color: var(--taupe); font-size: 0.95rem; padding-bottom: 0.4rem; }

.tag-list { display: flex; flex-wrap: wrap; gap: 0.4rem; padding: 0; margin: 0 0 1rem; list-style: none; }
.tag-list li {
  border: 1px solid var(--rope);
  border-radius: 999px;
  padding: 0.2rem 0.7rem;
  font-size: 0.85rem;
  color: var(--taupe);
}

.callout {
  border-left: 3px solid var(--golden);
  background: var(--kennel);
  padding: 1rem 1.15rem;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 0.95rem;
}
.callout p:last-child { margin-bottom: 0; }

.example-row { display: flex; gap: 5px; margin: 0.8rem 0; }
.example-row .tile { width: 44px; }

/* --- Footer --------------------------------------------------------------- */

.site-footer {
  border-top: 1px solid var(--rope);
  padding: 2rem 1.15rem 3rem;
  text-align: center;
  color: var(--taupe);
  font-size: 0.9rem;
}
.site-footer nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.35rem 1.1rem;
  margin-bottom: 0.9rem;
}
.site-footer a { color: var(--fawn); text-decoration: none; }
.site-footer a:hover { color: var(--golden); text-decoration: underline; }

/* --- Larger screens ------------------------------------------------------- */

@media (min-width: 720px) {
  body { font-size: 18px; }
  .stage-heading { font-size: 1.9rem; }
  h1 { font-size: 2.6rem; }
  h2 { font-size: 1.7rem; }
  .slot { width: 30px; height: 36px; font-size: 1.2rem; }
  .photo-frame { max-height: 360px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* --- Sub-page adjustments -------------------------------------------------- */

a.ghost-btn { text-decoration: none; display: inline-flex; align-items: center; }
main.content { padding-top: 2rem; }
main.content > p:first-of-type { margin-bottom: 1.5rem; }
.content ul:not(.tag-list):not(.steps) { padding-left: 1.1rem; margin: 0 0 1rem; }
.content ul:not(.tag-list):not(.steps) li { margin-bottom: 0.4rem; }

/* --- Dogdex ---------------------------------------------------------------- */

.dex-page { max-width: 52rem; }

.dex-progress {
  background: var(--kennel);
  border: 1px solid var(--rope);
  border-radius: var(--radius);
  padding: 1.1rem 1.2rem;
  margin-bottom: 1.4rem;
}
.dex-progress-head { display: flex; justify-content: space-between; align-items: baseline; }
.dex-progress-head b { font-family: var(--display); font-size: 1.5rem; font-weight: 600; }
.dex-progress-head span { color: var(--golden); font-weight: 700; }
.dex-bar { height: 8px; background: var(--sable); border-radius: 999px; overflow: hidden; margin: 0.6rem 0 0.5rem; }
.dex-bar span { display: block; height: 100%; width: 0; background: var(--golden); border-radius: 999px; transition: width 0.5s ease; }
.dex-blurb { color: var(--taupe); font-size: 0.9rem; margin: 0; }

.dex-controls { display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: center; margin-bottom: 1.2rem; }
.dex-controls .mode { margin: 0; }
.dex-search {
  flex: 1 1 12rem;
  background: var(--kennel);
  border: 1px solid var(--rope);
  border-radius: 999px;
  color: var(--fawn);
  font: inherit;
  font-size: 0.9rem;
  padding: 0.45rem 1rem;
}
.dex-search::placeholder { color: var(--taupe); }

.dex-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 0.6rem; }
.dex-empty { color: var(--taupe); grid-column: 1 / -1; }

.dex-card {
  position: relative;
  background: var(--kennel);
  border: 1px solid var(--rope);
  border-radius: var(--radius-sm);
  padding: 0.55rem 0.5rem 0.7rem;
  color: var(--fawn);
  font: inherit;
  text-align: center;
  cursor: pointer;
  display: grid;
  gap: 0.3rem;
  transition: border-color 0.15s;
}
.dex-card:hover { border-color: var(--golden-deep); }
.dex-thumb {
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  background: var(--sable);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.dex-thumb img { width: 100%; height: 100%; object-fit: cover; }
.dex-name { font-size: 0.82rem; font-weight: 700; line-height: 1.25; }
.dex-meta { font-size: 0.7rem; color: var(--taupe); }

.dex-card.is-locked { cursor: pointer; }
.dex-card.is-locked .dex-name { color: var(--rope); letter-spacing: 0.08em; }
.dex-card.is-missed .dex-thumb img { filter: grayscale(1) brightness(0.7); }
.dex-card.is-missed .dex-name { color: var(--taupe); }
.dex-flag {
  position: absolute;
  top: 0.4rem;
  right: 0.4rem;
  background: var(--clay);
  color: #fff;
  font-size: 0.6rem;
  font-weight: 700;
  padding: 0.05rem 0.35rem;
  border-radius: 3px;
}

.dex-paw { width: 42%; fill: var(--rope); }
.dex-spinner {
  width: 18px; height: 18px;
  border: 2px solid var(--rope);
  border-top-color: var(--golden);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.dex-card-modal { max-width: 27rem; text-align: center; }
.dex-photo { aspect-ratio: 4 / 3; background: var(--sable); border-radius: var(--radius); overflow: hidden; display: grid; place-items: center; margin-bottom: 0.9rem; }
.dex-photo img { width: 100%; height: 100%; object-fit: cover; }
.dex-status { font-size: 0.7rem; font-weight: 700; padding: 0.15rem 0.55rem; border-radius: 999px; }
.dex-status.is-found { background: var(--golden); color: #241a10; }
.dex-status.is-missed { background: var(--rope); color: var(--fawn); }
.dex-note { color: var(--taupe); font-size: 0.92rem; margin: 0.4rem 0 1rem; }

.dex-facts { display: grid; gap: 1px; background: var(--rope); border: 1px solid var(--rope); border-radius: var(--radius-sm); overflow: hidden; margin: 0 0 1rem; text-align: left; }
.dex-facts .fact { display: grid; grid-template-columns: 8.5rem 1fr; gap: 0.5rem; background: var(--kennel); padding: 0.5rem 0.7rem; }
.dex-facts dt { color: var(--taupe); font-size: 0.82rem; }
.dex-facts dd { margin: 0; font-size: 0.88rem; font-weight: 600; }
.dex-facts dd i { color: var(--taupe); font-weight: 400; font-style: normal; }

.dex-locked-art { display: grid; place-items: center; padding: 1.5rem 0 0.5rem; }
.dex-locked-art .dex-paw { width: 84px; }
#dexModal[data-view='detail'] .locked-only { display: none; }
#dexModal[data-view='locked'] .detail-only { display: none; }
#dexModal a.btn { text-decoration: none; }

.dex-about { padding-top: 2.5rem; }
.dex-new { font-size: 0.85rem; color: var(--golden); margin: 0 0 0.6rem; }


/* --- Cookie consent -------------------------------------------------------- */

.consent {
  position: fixed;
  left: 1rem;
  right: 1rem;
  bottom: 1rem;
  z-index: 90;
  max-width: 30rem;
  margin: 0 auto;
  background: var(--kennel);
  border: 1px solid var(--rope);
  border-radius: var(--radius);
  padding: 1.1rem 1.2rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.55);
  animation: lift 0.3s;
}
.consent[hidden] { display: none; }
.consent-text { font-size: 0.88rem; color: var(--taupe); margin: 0 0 0.9rem; }
.consent-text a { color: var(--golden); }
.consent-actions { display: flex; gap: 0.5rem; }
.consent-actions .btn { margin-top: 0; flex: 1; }

.link-btn {
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  color: var(--fawn);
  cursor: pointer;
  text-decoration: none;
}
.link-btn:hover { color: var(--golden); text-decoration: underline; }
.content .link-btn { color: var(--golden); text-decoration: underline; }
.content .link-btn:hover { color: var(--fawn); }