/* ==========================================================================
   Hidden Workings — "Guess First" Signature Feature Styles
   Field-guide Owner's Manual aesthetic, tactile flip animation, AA contrast
   ========================================================================== */

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Page container & Hero */
.guess-page {
  padding-bottom: 24px;
}

.guess-hero {
  padding: 56px 0 36px;
}

.guess-hero h1 {
  font-size: clamp(52px, 5.8vw, 88px);
  line-height: 0.98;
  letter-spacing: -3px;
  margin: 24px 0 20px;
}

.guess-hero h1 em {
  color: var(--orange);
}

.guess-intro {
  max-width: 580px;
  font-size: 16px;
  line-height: 1.75;
  color: var(--ink);
}

/* Dashboard / Live Tally Tracker */
.guess-dashboard {
  margin: 32px 0 40px;
  background: #eae5d9;
  border: 1px solid var(--ink);
  padding: 24px 28px;
}

.dashboard-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
}

.tally-box {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.dashboard-label {
  color: var(--orange);
  font-size: 10px;
  letter-spacing: 1px;
  text-transform: uppercase;
  font-weight: 700;
}

.tally-headline {
  font-size: 17px;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -0.2px;
}

.tally-count,
.final-usual-text {
  color: var(--orange);
  font-size: 22px;
  font-family: var(--serif);
  font-style: italic;
  font-weight: 600;
}

.tally-subtext {
  font-size: 11px;
  color: #4a4e52;
}

/* Pips row for the 11 cards */
.tally-pips {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.pip {
  width: 22px;
  height: 22px;
  border: 1.5px solid var(--ink);
  background: var(--paper);
  border-radius: 0;
  padding: 0;
  display: inline-grid;
  place-items: center;
  cursor: pointer;
  transition: transform 0.15s ease, background-color 0.15s ease, border-color 0.15s ease;
  position: relative;
}

.pip:hover {
  transform: scale(1.15);
  border-color: var(--blue);
}

.pip:focus-visible {
  outline: 3px solid var(--blue);
  outline-offset: 3px;
}

.pip.is-usual {
  background: var(--ink);
  border-color: var(--ink);
}

.pip.is-usual::after {
  content: '';
  width: 6px;
  height: 6px;
  background: var(--paper);
}

.pip.is-doubted {
  background: var(--orange);
  border-color: var(--orange);
}

.pip.is-doubted::after {
  content: '';
  width: 6px;
  height: 6px;
  background: #ffffff;
}

.pip.is-peeked {
  background: var(--line);
  border-color: var(--ink);
}

/* Dashboard Quick Actions */
.dashboard-actions {
  display: flex;
  gap: 12px;
  align-items: center;
}

.ctrl-btn {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--ink);
  border-radius: 0;
  padding: 8px 14px;
  font-size: 11px;
  font-family: 'Courier New', monospace;
  text-transform: uppercase;
  letter-spacing: 1px;
  cursor: pointer;
  font-weight: 700;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.ctrl-btn:hover {
  background: var(--ink);
  color: var(--paper);
}

.ctrl-btn:focus-visible {
  outline: 3px solid var(--blue);
  outline-offset: 2px;
}

/* 11 Cards Grid */
.guess-section {
  padding: 24px 0 64px;
}

.guess-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 28px;
}

/* ==========================================================================
   PROGRESSIVE ENHANCEMENT: Non-JS Base Layout (Readable List)
   ========================================================================== */
.guess-card {
  border: 1px solid var(--ink);
  background: var(--ground, var(--paper));
  color: var(--card-text, var(--ink));
  display: flex;
  flex-direction: column;
}

.guess-card-inner {
  display: flex;
  flex-direction: column;
  width: 100%;
}

.card-face {
  position: static;
  width: 100%;
  display: flex;
  flex-direction: column;
}

.card-front {
  padding: 24px;
  flex-grow: 1;
}

.card-back {
  padding: 24px;
  background: #fbf8f2;
  color: var(--ink);
  border-top: 2px solid var(--ink);
}

/* Progressive Enhancement No-JS Rules */
.guess-page:not(.is-interactive) .btn-direct-flip,
.guess-page:not(.is-interactive) .btn-flip-back,
.guess-page:not(.is-interactive) .dashboard-actions {
  display: none !important;
}

.guess-page:not(.is-interactive) .card-foot .flip-prompt-text {
  display: none;
}

.guess-page:not(.is-interactive) .card-foot::before {
  content: 'Mechanism explained below ↓';
  font-weight: 700;
  letter-spacing: 0.5px;
}

/* ==========================================================================
   INTERACTIVE MODE (when assets/js/guess.js initializes)
   3D tactile flip card mechanics & smooth perspective
   Resolved DESIGN #20: overflow: hidden eliminates internal scrollbars!
   ========================================================================== */
.is-interactive .guess-card {
  perspective: 1200px;
  height: auto;
  border: none;
  background: transparent;
}

.is-interactive .guess-card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform 0.6s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.is-interactive .card-face {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border: 1px solid var(--ink);
  border-radius: 0;
  overflow: hidden; /* Fix DESIGN #20: no internal scrollbar */
}

.is-interactive .card-front {
  background-color: var(--ground);
  color: var(--card-text);
  padding: 20px 20px 16px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.is-interactive .card-back {
  background-color: #fbf8f2;
  color: var(--ink);
  transform: rotateY(180deg);
  border-top: 1px solid var(--ink);
  padding: 18px 20px 18px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.is-interactive .guess-card.is-flipped .guess-card-inner {
  transform: rotateY(180deg);
}

.is-interactive .btn-direct-flip,
.is-interactive .btn-flip-back {
  display: inline-flex;
}

/* ==========================================================================
   CARD FRONT: Header, Observation, Question, Teaser Plate, Choices
   ========================================================================== */
.card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 10px;
  letter-spacing: 1.2px;
  padding-bottom: 10px;
  border-bottom: 1px solid currentColor;
}

.card-plate {
  font-weight: 700;
}

.card-object {
  text-transform: uppercase;
  font-weight: 600;
}

.card-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 8px 0;
  flex-grow: 1;
}

/* Observation Banner */
.noticed-banner {
  background: #fdfaf4;
  color: var(--ink);
  border: 1px solid var(--ink);
  padding: 7px 10px;
}

.noticed-label {
  color: #1e2226;
  font-size: 9px;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 3px;
}

.noticed-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--blue);
  display: inline-block;
}

.noticed-text {
  font-size: 11.5px;
  line-height: 1.45;
  margin: 0;
  font-weight: 500;
  color: #1e2226;
}

.card-question {
  font-size: clamp(18px, 1.45vw, 22px);
  line-height: 1.2;
  letter-spacing: -0.3px;
  margin: 0;
  color: inherit;
}

/* Popular explanation callout */
.popular-box {
  background: #fdfaf4;
  color: var(--ink);
  border: 1px solid var(--ink);
  padding: 7px 10px;
}

.popular-label {
  font-size: 9px;
  letter-spacing: 1.1px;
  text-transform: uppercase;
  color: #4a4e52;
  display: block;
  margin-bottom: 2px;
  font-weight: 700;
}

.popular-text {
  font-size: 12px;
  line-height: 1.4;
  margin: 0;
  font-weight: 600;
  color: #1e2226;
}

/* Choices group: tactile self-check buttons */
.choices-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: auto;
}

.choice-btn {
  background: #ffffff;
  color: var(--ink);
  border: 2px solid var(--ink);
  border-radius: 0;
  padding: 9px 12px;
  text-align: left;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 3px;
  box-shadow: 2px 2px 0 var(--ink);
  transition: transform 0.12s ease, box-shadow 0.12s ease, background-color 0.15s ease, border-color 0.15s ease;
  position: relative;
}

.choice-btn:hover {
  background: #faf6ed;
  transform: translate(-1px, -1px);
  box-shadow: 3px 3px 0 var(--ink);
}

.choice-btn:active,
.choice-btn.is-pressing {
  transform: translate(2px, 2px);
  box-shadow: 0 0 0 var(--ink);
}

.choice-btn:focus-visible {
  outline: 3px solid var(--blue);
  outline-offset: 3px;
}

.choice-btn.is-selected {
  border-color: var(--orange);
  background: #fffaf7;
  box-shadow: 2px 2px 0 var(--orange);
}

.choice-meta {
  font-size: 9px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: #4a4e52;
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 700;
}

.choice-btn.is-selected .choice-meta {
  color: var(--orange);
}

.choice-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #6f6a62;
}

.choice-btn.is-selected .choice-dot {
  background: var(--orange);
}

.choice-text {
  font-size: 13px;
  font-weight: 700;
  line-height: 1.35;
  color: var(--ink);
}

.card-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 10px;
  padding-top: 8px;
  border-top: 1px solid currentColor;
}

.flip-prompt-text {
  letter-spacing: 0.5px;
  font-weight: 600;
  white-space: nowrap;
}

.btn-direct-flip {
  background: #fdfaf4;
  border: 1px solid var(--ink);
  border-radius: 0;
  color: var(--ink);
  padding: 4px 8px;
  font-size: 9.5px;
  font-family: 'Courier New', monospace;
  text-transform: uppercase;
  letter-spacing: 1px;
  cursor: pointer;
  font-weight: 700;
  white-space: nowrap;
  box-shadow: 1px 1px 0 var(--ink);
  transition: background-color 0.15s ease, transform 0.12s ease;
}

.btn-direct-flip:hover {
  background: var(--ink);
  color: var(--paper);
}

.btn-direct-flip:focus-visible {
  outline: 3px solid var(--blue);
  outline-offset: 2px;
}

/* ==========================================================================
   CARD BACK: Reveal, Silent Loop Diagram, Verdict, Teaser & Actions
   ========================================================================== */
.card-back-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}

.btn-flip-back {
  background: transparent;
  border: 1px solid var(--ink);
  border-radius: 0;
  color: var(--ink);
  padding: 4px 10px;
  font-size: 10px;
  font-family: 'Courier New', monospace;
  text-transform: uppercase;
  letter-spacing: 1px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  font-weight: 700;
  white-space: nowrap;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.btn-flip-back:hover {
  background: var(--ink);
  color: var(--paper);
}

.btn-flip-back:focus-visible {
  outline: 3px solid var(--blue);
  outline-offset: 2px;
}

.back-plate-pill {
  font-size: 10px;
  color: #4a4e52;
  font-weight: 600;
  white-space: nowrap;
  border-radius: 0;
}

/* Living looping diagram frame */
.card-diagram-frame {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--ink);
  border-radius: 0;
  aspect-ratio: 960 / 416;
  background: var(--ink);
  margin: 8px 0 10px;
}

.loop-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.loop-poster-fallback {
  display: none;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.loop-caption {
  position: absolute;
  bottom: 8px;
  left: 8px;
  background: var(--paper);
  color: var(--ink);
  padding: 3px 8px;
  font-size: 9.5px;
  border: 1px solid var(--ink);
  border-radius: 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 700;
  letter-spacing: 0.8px;
  text-transform: uppercase;
}

.loop-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #238636;
  display: inline-block;
}

.card-back-content {
  display: flex;
  flex-direction: column;
  flex-grow: 1;
}

.choice-feedback-badge {
  font-size: 9.5px;
  letter-spacing: 1px;
  text-transform: uppercase;
  padding: 3px 8px;
  border: 1px solid var(--line);
  border-radius: 0;
  margin-bottom: 6px;
  align-self: start;
  background: #ffffff;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 700;
  color: var(--ink);
}

.choice-feedback-badge .feedback-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #4a4e52;
  display: inline-block;
}

.choice-feedback-badge.is-usual {
  border-color: var(--ink);
  background: #f4f0e6;
  color: var(--ink);
}

.choice-feedback-badge.is-usual .feedback-dot {
  background: var(--ink);
}

.choice-feedback-badge.is-doubted {
  border-color: var(--orange);
  color: var(--orange);
  background: #fff5f0;
}

.choice-feedback-badge.is-doubted .feedback-dot {
  background: var(--orange);
}

.choice-feedback-badge.is-peeked {
  border-color: var(--line);
  color: #4a4e52;
  background: #ffffff;
}

.back-verdict {
  font-size: 16px;
  line-height: 1.25;
  margin: 0 0 5px;
  color: var(--ink);
  font-weight: 600;
}

.back-teaser {
  font-size: 11.5px;
  line-height: 1.5;
  color: #2b2e32;
  margin: 0 0 8px;
}

/* Sourced Field Mechanism Note */
.back-fact {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 0;
  padding: 7px 9px;
  margin-bottom: 8px;
  font-size: 11px;
  line-height: 1.45;
}

.back-fact-label {
  font-size: 8.5px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: #4a4e52;
  display: block;
  margin-bottom: 2px;
  font-weight: 700;
}

.back-fact-text {
  margin: 0;
  color: var(--ink);
  font-weight: 500;
}

.card-back-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-top: auto;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

.btn-watch-exp {
  flex: 1;
  background: var(--ink);
  color: var(--paper);
  border-radius: 0;
  padding: 9px 12px;
  font-size: 11px;
  display: inline-flex;
  justify-content: space-between;
  align-items: center;
  border: 1px solid var(--ink);
  font-weight: 700;
  transition: background-color 0.2s ease, border-color 0.2s ease;
}

.btn-watch-exp:hover {
  background: var(--blue);
  border-color: var(--blue);
}

.btn-watch-exp:focus-visible {
  outline: 3px solid var(--blue);
  outline-offset: 2px;
}

.btn-yt-link {
  background: transparent;
  color: var(--ink);
  border-radius: 0;
  padding: 8px 10px;
  font-size: 11px;
  border: 1px solid var(--ink);
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
  font-weight: 600;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.btn-yt-link:hover {
  background: var(--ink);
  color: var(--paper);
}

.btn-yt-link:focus-visible {
  outline: 3px solid var(--blue);
  outline-offset: 2px;
}

/* ==========================================================================
   END SCREEN: Score verdict, Mascot Cat & Subscribe Action
   Warmed ground: #ebe5d8 warm drafting stock (DESIGN #6 / DECISIONS #15)
   ========================================================================== */
.guess-end-screen {
  padding: 48px 0 32px;
  border-top: 1px solid var(--ink);
}

.end-card {
  background: #ebe5d8;
  border: 1px solid var(--ink);
  padding: 44px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24'%3E%3Cpath d='M24 0H0V24' fill='none' stroke='%239b9383' stroke-opacity='.18'/%3E%3C/svg%3E");
  background-size: 24px 24px;
}

.end-card h2 {
  font-size: clamp(32px, 3.8vw, 52px);
  line-height: 1.08;
  letter-spacing: -1.4px;
  margin: 18px 0 14px;
}

.end-verdict-summary {
  font-size: 15px;
  line-height: 1.75;
  max-width: 640px;
  color: #2b2e32;
  margin-bottom: 20px;
}

.end-screen-actions {
  margin: 20px 0 28px;
}

.end-screen-actions .button {
  background: var(--orange);
  border-color: var(--orange);
  color: #ffffff;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 16px;
  padding: 12px 18px;
}

.end-screen-actions .button:hover {
  background: var(--ink);
  border-color: var(--ink);
}

.end-cat-note {
  display: flex;
  align-items: center;
  gap: 24px;
  border-top: 1px solid var(--line);
  padding-top: 24px;
}

.end-cat-note .cat {
  width: 90px;
  flex-shrink: 0;
}

.end-cat-copy {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.end-cat-quote {
  font-family: var(--serif);
  font-style: italic;
  font-size: 21px;
  line-height: 1.25;
  color: var(--blue);
  margin: 0;
}

/* ==========================================================================
   REDUCED MOTION SUPPORT
   Respect reduced motion — show poster only, instant transitions
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
  .guess-card-inner,
  .choice-btn,
  .pip,
  .ctrl-btn,
  .btn-watch-exp,
  .btn-yt-link,
  .btn-direct-flip,
  .btn-flip-back {
    transition: none !important;
    animation: none !important;
  }

  /* Show poster only in reduced motion */
  .card-diagram-frame .loop-video {
    display: none !important;
  }

  .card-diagram-frame .loop-poster-fallback {
    display: block !important;
  }

  .loop-dot {
    background: #6f6a62;
  }
}

/* ==========================================================================
   RESPONSIVE DESIGN (360px to 1600px)
   ========================================================================== */
@media (max-width: 1120px) {
  .guess-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 24px;
  }
}

@media (max-width: 720px) {
  .guess-hero {
    padding: 32px 0 24px;
  }

  .guess-hero h1 {
    font-size: clamp(40px, 11vw, 54px);
    letter-spacing: -1.8px;
    margin: 18px 0 16px;
  }

  .guess-dashboard {
    padding: 18px 16px;
    margin: 24px 0 32px;
  }

  .dashboard-inner {
    flex-direction: column;
    align-items: stretch;
    gap: 16px;
  }

  .tally-pips {
    gap: 6px;
    justify-content: flex-start;
  }

  .pip {
    width: 20px;
    height: 20px;
  }

  .dashboard-actions {
    justify-content: flex-start;
  }

  .guess-grid {
    grid-template-columns: 1fr;
    gap: 24px;
  }

  .is-interactive .guess-card {
    height: auto;
  }

  .is-interactive .card-front {
    padding: 18px 16px 14px;
  }

  .is-interactive .card-back {
    padding: 16px 16px 16px;
  }

  .card-body {
    gap: 6px;
    margin: 6px 0;
  }

  .card-teaser-plate {
    height: 76px;
  }

  .noticed-banner {
    padding: 6px 9px;
  }

  .noticed-text {
    font-size: 11px;
    line-height: 1.4;
  }

  .popular-box {
    padding: 6px 9px;
  }

  .popular-text {
    font-size: 11.5px;
    line-height: 1.35;
  }

  .choice-btn {
    padding: 8px 10px;
  }

  .end-card {
    padding: 24px;
  }

  .end-cat-note {
    flex-direction: column;
    align-items: flex-start;
    gap: 16px;
  }

  .card-back-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .btn-watch-exp,
  .btn-yt-link {
    justify-content: center;
    width: 100%;
  }
}

/* Cards follow their content; the choices stay next to the claim. */
.guess-grid { align-items: start; }
.is-interactive .guess-card { height: auto; perspective: none; }
.is-interactive .guess-card-inner { height: auto; transform: none !important; transition: none; }
.is-interactive .card-face { position: relative; inset: auto; height: auto; overflow: visible; transform: none; backface-visibility: visible; }
.is-interactive .card-back { display: none; }
.is-interactive .guess-card.is-flipped .card-front { display: none; }
.is-interactive .guess-card.is-flipped .card-back { display: flex; }
.card-body { flex-grow: 0; gap: 16px; margin: 16px 0; }
.choices-group { margin-top: 0; gap: 10px; }
.noticed-text,.popular-text,.back-teaser,.back-fact { font-size: 16px; line-height: 1.6; font-weight: 400; }
.card-question { font-size: 27px; line-height: 1.15; }
.choice-text { font-size: 15px; font-weight: 600; }
.choice-btn { padding: 12px; }
.card-head { gap: 12px; flex-wrap: wrap; }
.back-verdict { font-size: 26px; margin: 16px 0 12px; }
.back-fact { padding: 14px; margin: 18px 0; }
.back-fact-text { font-weight: 400; }
.card-back-actions { flex-wrap: wrap; gap: 10px; }
.btn-watch-exp,.btn-yt-link,.btn-direct-flip,.btn-flip-back,.ctrl-btn { min-height: 44px; }
.choice-feedback-badge { white-space: normal; line-height: 1.6; }
@media(min-width:1121px) { .guess-grid { grid-template-columns: repeat(6,minmax(0,1fr)); } .guess-card { grid-column: span 2; } .guess-card:nth-last-child(-n+2) { grid-column: span 3; } }
@media(min-width:721px) and (max-width:1120px) { .guess-card:last-child { grid-column: 1 / -1; } }
@media(max-width:720px) { .card-body { gap: 14px; margin: 16px 0; } .noticed-text,.popular-text { font-size: 16px; line-height: 1.6; } .card-head { font-size: 9px; letter-spacing: .6px; } }

.guess-page:not(.is-interactive) .choices-group { display: none; }

.is-interactive .guess-card-inner { transform-style: flat; }
.pip { width: 24px; height: 24px; }
.tally-pips { gap: 4px; }
@media(max-width:720px) { .pip { width: 24px; height: 24px; } .guess-dashboard { margin-bottom: 20px; } .guess-section { padding-top: 12px; } }

.diagram-controls { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; border-bottom: 1px solid var(--line); }
.diagram-controls > span { font-size: 10px; color: var(--muted); }
.btn-loop-toggle { min-height: 44px; padding: 8px 0 8px 12px; border: 0; background: transparent; color: var(--ink); font-size: 12px; text-decoration: underline; text-underline-offset: 3px; }
.guess-page:not(.is-interactive) .btn-loop-toggle { display: none; }
@media(prefers-reduced-motion:reduce) { .diagram-controls { display: none; } }
