/*!
 * TGC Gut Check Quiz — App Layer v1.2 (2026-10-05)
 * Every rule is scoped to html.tgc-mq, which gut-check-mobile.js sets once the
 * quiz layer is enabled. Applies at ALL widths: phones get the full-bleed app,
 * tablets/desktops get the same focused flow in a centered column.
 * No-JS visitors see the current page unchanged.
 * Palette and type follow the TGC design system (sage / terracotta / gold,
 * Cormorant Garamond + Inter, 50px pills, 44px+ tap targets).
 */
.mq-back, .mq-count, .mq-next, .mq-analyzing { display: none; }

@media all {

  html.tgc-mq body.quiz-mode { -webkit-tap-highlight-color: transparent; }

  /* ── Top bar: back · wordmark · save, then step label + progress ─────── */
  html.tgc-mq #progressStrip { padding-top: env(safe-area-inset-top); }
  html.tgc-mq #progressStrip .progress-inner {
    display: grid;
    grid-template-columns: 48px minmax(0, 1fr) 46px;
    grid-template-areas: "back logo exit" "bar bar bar";
    align-items: center;
    gap: 4px 6px;
    padding: 6px 12px 12px 6px;
  }
  html.tgc-mq .mq-back {
    grid-area: back;
    display: flex; align-items: center; justify-content: center;
    width: 48px; height: 48px;
    border: 0; border-radius: 50%; background: transparent;
    color: var(--sage-dark); font-size: 24px; cursor: pointer;
  }
  html.tgc-mq .mq-back:active { background: var(--stone); }
  html.tgc-mq .mq-back:focus-visible { outline: 3px solid var(--terracotta); outline-offset: 3px; }
  html.tgc-mq .progress-logo { grid-area: logo; font-size: 16px; overflow: hidden; text-overflow: ellipsis; }
  html.tgc-mq .quiz-exit-btn {
    grid-area: exit;
    width: 46px; height: 46px; padding: 0;
    justify-content: center; border-radius: 50%;
    color: var(--sage-dark); background: #fff;
  }
  html.tgc-mq .quiz-exit-btn i { font-size: 20px; }
  html.tgc-mq .quiz-exit-btn .quiz-exit-text { display: none; }
  html.tgc-mq .progress-center {
    grid-area: bar;
    display: grid; grid-template-columns: 1fr auto;
    gap: 8px 10px; padding-left: 12px;
  }
  html.tgc-mq #progressLabel { font-size: 14px; font-weight: 600; color: var(--sage-rich); }
  html.tgc-mq .mq-count {
    display: block; font-size: 14px; font-weight: 600;
    color: var(--text-secondary); font-variant-numeric: tabular-nums;
  }
  html.tgc-mq .progress-bar-track { grid-column: 1 / -1; height: 6px; }
  html.tgc-mq .progress-bar-fill { transition: width 0.45s cubic-bezier(0.23, 1, 0.32, 1); }

  /* ── One card per screen ─────────────────────────────────────────────── */
  html.tgc-mq .quiz-section-wrap { min-height: calc(100vh - 120px); padding: 24px 20px 132px; }
  /* dvh tracks the viewport the keyboard leaves behind; vh above is the
     fallback for browsers that do not know the unit. */
  html.tgc-mq .quiz-section-wrap { min-height: calc(100dvh - 120px); }

  /* ── Soft keyboard ─────────────────────────────────────────────────────
     Both iOS Safari and Chrome on Android resize only the VISUAL viewport
     when the keyboard opens: the layout viewport, and so 100vh, keeps its
     full height, and the contact fields end up under the keyboard with a
     screenful of reserved space below them. body.mq-kb is set from the
     visualViewport API in the JS, and gives that room back. ────────────── */
  html.tgc-mq body.mq-kb .quiz-section-wrap { min-height: 0; padding-bottom: 92px; }
  html.tgc-mq body.mq-kb .step-header { display: none; }
  html.tgc-mq body.mq-kb .contact-step { padding: 14px 16px; }
  html.tgc-mq body.mq-kb .form-group { margin-bottom: 12px; }
  /* Focusing a field must not tuck it under the sticky top bar or the
     action bar -- the browser honours these when it scrolls it into view. */
  html.tgc-mq .form-group input,
  html.tgc-mq .form-group textarea { scroll-margin-top: 130px; scroll-margin-bottom: 104px; }
  /* The optional phone/note block is opened by the JS. Tighten it so the
     extra two fields cost as little height as possible. */
  html.tgc-mq .contact-more { margin-top: 14px; padding-top: 12px; }
  html.tgc-mq body.mq-kb .contact-more { margin-top: 10px; padding-top: 10px; }
  html.tgc-mq .step-preview { display: none; }
  html.tgc-mq .quiz-step[data-step="1"] .step-header,
  html.tgc-mq .quiz-step[data-step="2"] .step-header { display: none; }
  html.tgc-mq .quiz-step:not(.mq-first) .step2-callout { display: none; }
  html.tgc-mq .step-header { margin-bottom: 20px; }
  html.tgc-mq .step-header h2 { font-size: 30px; line-height: 1.12; }
  html.tgc-mq .step-header p { font-size: 16px; line-height: 1.5; }
  html.tgc-mq .step2-callout { font-size: 16px; margin-bottom: 22px; }

  html.tgc-mq .mq-card { display: none; }
  html.tgc-mq .mq-card.mq-on { display: block; }
  html.tgc-mq .quiz-step[data-step="1"] .section-group:not(.mq-group-on),
  html.tgc-mq .quiz-step[data-step="2"] .section-group:not(.mq-group-on) { display: none; }
  html.tgc-mq .section-group { background: transparent; border: 0; padding: 0; margin: 0; }
  html.tgc-mq .section-group-title {
    border: 0; padding: 0; margin: 0 0 10px;
    font-size: 13px; font-weight: 700; color: var(--terracotta);
  }
  html.tgc-mq .question-radio,
  html.tgc-mq .yesno-question { margin: 0; padding: 0; background: transparent; border: 0; }
  html.tgc-mq .question-radio .question-label,
  html.tgc-mq .yesno-question .question-label {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-size: 29px; font-weight: 700; line-height: 1.15;
    color: var(--sage-dark); margin-bottom: 22px;
  }

  /* Never / Sometimes / Often — stacked, full-width tap targets */
  html.tgc-mq .radio-group { flex-direction: column; gap: 10px; }
  html.tgc-mq .radio-option { min-width: 0; }
  html.tgc-mq .radio-option span {
    justify-content: flex-start; gap: 14px;
    min-height: 60px; padding: 14px 18px;
    border-radius: 16px; border: 2px solid var(--border-light);
    background: #fff; color: var(--text-primary);
    font-size: 17px; white-space: normal;
    box-shadow: 0 2px 8px rgba(45, 68, 56, 0.05);
  }
  html.tgc-mq .radio-option span::before {
    content: ''; flex: none;
    width: 24px; height: 24px; border-radius: 50%;
    border: 2px solid var(--sage-light);
    background: #fff no-repeat center / 12px;
    transition: all 0.15s;
  }
  html.tgc-mq .radio-option input[type="radio"]:checked + span {
    background: #e8f0e7; border-color: var(--sage-rich); color: var(--text-primary);
  }
  html.tgc-mq .radio-option input[type="radio"]:checked + span::before {
    background-color: var(--sage-rich); border-color: var(--sage-rich);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M2 6l3 3 5-5' stroke='white' stroke-width='2' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  }

  /* Yes / No — two big cards */
  html.tgc-mq .yesno-group { gap: 12px; }
  html.tgc-mq .yesno-option span {
    min-height: 104px; border-radius: 18px; border-width: 2px;
    background: #fff; font-size: 19px; font-weight: 700; color: var(--sage-dark);
    box-shadow: 0 2px 8px rgba(45, 68, 56, 0.05);
  }

  /* Conditions checklists */
  html.tgc-mq .checkbox-group { grid-template-columns: 1fr; gap: 10px; }
  html.tgc-mq .checkbox-option span {
    min-height: 56px; padding: 12px 16px;
    border-radius: 14px; border-width: 2px;
    background: #fff; font-size: 16px; color: var(--text-primary);
  }
  html.tgc-mq .checkbox-option span::before { width: 22px; height: 22px; border-radius: 6px; border-width: 2px; border-color: var(--sage-light); }

  html.tgc-mq .radio-option input:focus-visible + span,
  html.tgc-mq .yesno-option input:focus-visible + span,
  html.tgc-mq .checkbox-option input:focus-visible + span { outline: 3px solid var(--terracotta); outline-offset: 3px; }

  /* Contact */
  html.tgc-mq .contact-step { padding: 20px 18px; border-radius: 18px; }
  html.tgc-mq .contact-step .form-row { grid-template-columns: 1fr 1fr; gap: 12px; }
  html.tgc-mq .form-group { margin-bottom: 16px; }
  html.tgc-mq .form-group input,
  html.tgc-mq .form-group textarea { font-size: 17px; min-height: 54px; border-radius: 14px; border-width: 2px; }

  /* Bottom action bar — steps 3–4 only (steps 1–2 advance on tap) */
  html.tgc-mq .quiz-step[data-step="1"] .step-navigation,
  html.tgc-mq .quiz-step[data-step="2"] .step-navigation { display: none; }
  html.tgc-mq .quiz-step .step-navigation {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 90;
    justify-content: center;
    margin: 0; padding: 12px 20px calc(14px + env(safe-area-inset-bottom));
    background: var(--stone); border-top: 1px solid var(--border-light);
  }
  html.tgc-mq .step-navigation .btn-secondary { display: none; }
  html.tgc-mq .step-navigation .btn-primary { width: 100%; justify-content: center; min-height: 56px; }

  /* Screen transitions — one direction, no bounce */
  @keyframes mqInF { from { opacity: 0; transform: translateX(26px); } to { opacity: 1; transform: none; } }
  @keyframes mqInB { from { opacity: 0; transform: translateX(-26px); } to { opacity: 1; transform: none; } }
  html.tgc-mq .mq-in-f { animation: mqInF 0.32s cubic-bezier(0.23, 1, 0.32, 1) both; }
  html.tgc-mq .mq-in-b { animation: mqInB 0.32s cubic-bezier(0.23, 1, 0.32, 1) both; }

  /* ── Analyzing screen (between submit and results) ───────────────────── */
  html.tgc-mq .mq-analyzing {
    display: flex; position: fixed; inset: 0; z-index: 300;
    align-items: center; padding: 40px 26px;
    background: linear-gradient(135deg, var(--sage-dark) 0%, #1e3025 100%);
    color: #fff; transition: opacity 0.4s ease;
  }
  html.tgc-mq .mq-analyzing::before {
    content: ''; position: absolute; inset: 0; pointer-events: none;
    background: radial-gradient(circle at 80% 15%, rgba(201,169,97,0.16), transparent 55%),
                radial-gradient(circle at 10% 95%, rgba(255,255,255,0.05), transparent 50%);
  }
  html.tgc-mq .mq-analyzing.mq-out { opacity: 0; }
  html.tgc-mq .mq-an-inner { position: relative; width: 100%; }
  html.tgc-mq .mq-an-eyebrow { margin: 0 0 12px; font-size: 14px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--gold); }
  html.tgc-mq .mq-an-title { margin: 0 0 28px; font-family: 'Cormorant Garamond', Georgia, serif; font-size: 38px; font-weight: 700; line-height: 1.08; color: #fff; }
  html.tgc-mq .mq-an-title em { font-weight: 600; color: var(--gold); }
  html.tgc-mq .mq-an-list { list-style: none; margin: 0; padding: 0; }
  html.tgc-mq .mq-an-list li {
    display: flex; align-items: center; gap: 14px; min-height: 56px;
    border-bottom: 1px solid rgba(255,255,255,0.12);
    font-size: 17px; color: #fff; opacity: 0.35; transition: opacity 0.4s ease;
  }
  html.tgc-mq .mq-an-list li.mq-now,
  html.tgc-mq .mq-an-list li.mq-done { opacity: 1; }
  html.tgc-mq .mq-an-dot {
    flex: none; width: 30px; height: 30px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    border: 2px solid rgba(255,255,255,0.35); color: transparent; font-size: 16px;
    transition: all 0.3s ease;
  }
  html.tgc-mq .mq-an-list li.mq-done .mq-an-dot { background: var(--gold); border-color: var(--gold); color: #1e3025; }

  /* ── Results: sticky "Your next step" bar ────────────────────────────── */
  html.tgc-mq .mq-next {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 90;
    align-items: center; justify-content: space-between; gap: 12px;
    padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
    background: var(--sage-dark); color: #fff;
    box-shadow: 0 -6px 20px rgba(31,42,39,0.15);
    transform: translateY(110%); transition: transform 0.4s cubic-bezier(0.23, 1, 0.32, 1);
  }
  html.tgc-mq .mq-next.mq-show { transform: none; }
  html.tgc-mq .mq-next.mq-show.mq-hide { transform: translateY(110%); }
  html.tgc-mq .mq-next-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
  html.tgc-mq .mq-next-eyebrow { font-size: 12px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--gold); }
  html.tgc-mq .mq-next-name { font-size: 16px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  html.tgc-mq .mq-next-btn {
    flex: none; min-height: 48px; padding: 0 22px;
    border: 0; border-radius: 50px; cursor: pointer;
    background: linear-gradient(180deg, var(--gold), #a8873e); color: #1e3025;
    font-family: 'Inter', sans-serif; font-size: 15px; font-weight: 700;
    letter-spacing: 0.1em; text-transform: uppercase;
    display: flex; align-items: center; gap: 6px;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.22);
  }
  html.tgc-mq .mq-next-btn:focus-visible { outline: 3px solid var(--terracotta); outline-offset: 3px; }
  html.tgc-mq body:has(.mq-next.mq-show) .results-section { padding-bottom: 110px; }
}

/* ── Tablet (768–1023): still the full app, a little roomier ────────────── */
@media (min-width: 768px) and (max-width: 1023px) {
  html.tgc-mq .quiz-section-wrap { padding: 40px 40px 150px; }
  html.tgc-mq .quiz-step { max-width: 600px; margin-left: auto; margin-right: auto; }
  html.tgc-mq .question-radio .question-label,
  html.tgc-mq .yesno-question .question-label { font-size: 34px; }
  html.tgc-mq .radio-option span { min-height: 64px; font-size: 18px; }
  html.tgc-mq .yesno-option span { min-height: 120px; }
  html.tgc-mq .checkbox-group { grid-template-columns: 1fr 1fr; }
}

/* ── Desktop (1024+): the quiz is the whole screen, centered in the viewport ─ */
@media (min-width: 1024px) {
  /* Only lay out (and show) the quiz once it's open. Without .active this
     display:flex overrode the base `display:none` and left an empty, full-
     height quiz wrapper sitting below the landing on desktop. */
  html.tgc-mq .quiz-section-wrap.active {
    min-height: calc(100vh - 100px);
    display: flex; flex-direction: column; justify-content: center;
  }
  html.tgc-mq #progressStrip .progress-inner {
    max-width: 760px; margin: 0 auto;
    grid-template-columns: 52px minmax(0, 1fr) auto;
    padding: 10px 24px 14px 12px;
  }
  html.tgc-mq .progress-logo { font-size: 18px; }
  html.tgc-mq .quiz-exit-btn { width: auto; height: 46px; padding: 0 20px; border-radius: 50px; gap: 8px; }
  html.tgc-mq .quiz-exit-btn .quiz-exit-text { display: inline; font-size: 15px; font-weight: 600; }
  html.tgc-mq .progress-center { padding-left: 16px; }

  html.tgc-mq .quiz-section-wrap { padding: clamp(40px, 9vh, 104px) 32px 170px; }
  html.tgc-mq .quiz-step { max-width: 640px; margin-left: auto; margin-right: auto; }
  html.tgc-mq .step-header h2 { font-size: 40px; }
  html.tgc-mq .step-header p { font-size: 18px; }
  html.tgc-mq .question-radio .question-label,
  html.tgc-mq .yesno-question .question-label { font-size: 40px; line-height: 1.12; margin-bottom: 30px; }
  html.tgc-mq .section-group-title { font-size: 14px; }
  html.tgc-mq .radio-group { gap: 12px; }
  html.tgc-mq .radio-option span { min-height: 64px; padding: 16px 22px; font-size: 18px; }
  html.tgc-mq .yesno-option span { min-height: 128px; font-size: 21px; }
  html.tgc-mq .checkbox-group { grid-template-columns: 1fr 1fr; }
  html.tgc-mq .contact-step { padding: 32px; border-radius: 22px; }

  html.tgc-mq .quiz-step .step-navigation { padding: 16px 24px calc(18px + env(safe-area-inset-bottom)); }
  html.tgc-mq .step-navigation .btn-primary { width: 100%; max-width: 440px; min-height: 60px; }

  html.tgc-mq .mq-an-inner { max-width: 560px; margin: 0 auto; }
  html.tgc-mq .mq-an-title { font-size: 52px; }
  html.tgc-mq .mq-next { padding-left: max(24px, calc(50% - 380px)); padding-right: max(24px, calc(50% - 380px)); }
  html.tgc-mq .mq-next-name { font-size: 18px; }
}

/* ── Keyboard hints — only for mouse/trackpad devices, any width ────────── */
@media (hover: hover) and (pointer: fine) {
  html.tgc-mq .radio-option span[data-key]::after,
  html.tgc-mq .yesno-option span[data-key]::after {
    content: attr(data-key);
    margin-left: auto; flex: none;
    min-width: 28px; height: 28px; padding: 0 6px; border-radius: 8px;
    display: inline-flex; align-items: center; justify-content: center;
    border: 1px solid var(--border-light); background: var(--stone);
    font: 600 14px/1 'Inter', sans-serif; color: var(--text-secondary);
  }
  html.tgc-mq .yesno-option span[data-key] { position: relative; }
  html.tgc-mq .yesno-option span[data-key]::after { position: absolute; top: 12px; right: 12px; margin: 0; }
  html.tgc-mq .radio-option:hover span,
  html.tgc-mq .yesno-option:hover span,
  html.tgc-mq .checkbox-option:hover span { border-color: var(--sage-light); transform: translateY(-2px); box-shadow: 0 8px 20px rgba(45, 68, 56, 0.10); }
  html.tgc-mq .radio-option span, html.tgc-mq .yesno-option span, html.tgc-mq .checkbox-option span { transition: border-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease; }
  html.tgc-mq .mq-keys {
    display: block; margin-top: 22px; text-align: center;
    font-size: 14px; color: var(--text-secondary);
  }
}
html.tgc-mq .mq-keys { display: none; }
@media (hover: hover) and (pointer: fine) { html.tgc-mq .mq-keys { display: block; } }

@media (prefers-reduced-motion: reduce) {
  html.tgc-mq .mq-in-f, html.tgc-mq .mq-in-b { animation: none; }
  html.tgc-mq .progress-bar-fill, html.tgc-mq .mq-next { transition: none; }
}

/* ── Focus mode: site header + footer stay hidden from Start through Results.
   They come back only on Save & Exit (page's exitQuiz) or Retake/Restart. ── */
html.tgc-mq body.mq-focus header,
html.tgc-mq body.mq-focus footer,
html.tgc-mq body.mq-focus #megaMenu,
html.tgc-mq body.mq-focus #mobileMenuOverlay { display: none !important; }

html.tgc-mq .mq-rbar { display: none; }
html.tgc-mq body.mq-results .mq-rbar {
  display: flex; position: sticky; top: 0; z-index: 100;
  align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(8px + env(safe-area-inset-top)) 12px 8px 20px;
  background: var(--stone); border-bottom: 1px solid var(--border-light);
}
.mq-rbar { display: none; }
html.tgc-mq .mq-rbar-logo {
  font-family: 'Cormorant Garamond', Georgia, serif; font-size: 16px; font-weight: 700;
  letter-spacing: 0.08em; color: var(--sage-dark); text-decoration: none;
}
html.tgc-mq .mq-rbar-btn {
  display: inline-flex; align-items: center; gap: 8px;
  min-height: 46px; padding: 0 18px; border-radius: 50px;
  border: 1px solid var(--border-light); background: #fff; cursor: pointer;
  font: 600 15px/1 'Inter', sans-serif; color: var(--sage-dark);
}
html.tgc-mq .mq-rbar-btn i { font-size: 18px; }
html.tgc-mq .mq-rbar-btn:focus-visible,
html.tgc-mq .mq-rbar-logo:focus-visible { outline: 3px solid var(--terracotta); outline-offset: 3px; }
@media (min-width: 1024px) {
  html.tgc-mq .mq-rbar { padding-left: max(24px, calc(50% - 380px)); padding-right: max(24px, calc(50% - 380px)); }
  html.tgc-mq .mq-rbar-logo { font-size: 18px; }
}
