/* ===== ScenarioX WhatsApp light-mode theme ===== */

:root {
    --wa-header: #075e54;
    --wa-header-dark: #054d44;
    --wa-chat-bg: #efeae2;
    --wa-bot-bubble: #ffffff;
    --wa-user-bubble: #d9fdd3;
    --wa-accent: #25d366;
    --wa-text: #111b21;
    --wa-muted: #667781;
    --wa-tag: #ffeeced1;
    --score-green: #1fa855;
    --score-yellow: #d9a300;
    /* Warm terracotta for "review this": encouraging, not alarming. */
    --score-red: #d0704f;
    --score-red-text: #b3552f;
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: var(--wa-text);
    background: #d6d0c8;
}

/* ---------- Phone frame ---------- */

.wa-app {
    min-height: 100vh;
    min-height: 100dvh; /* dynamic viewport: excludes the mobile address bar */
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.wa-phone {
    width: 100%;
    max-width: 460px;
    height: min(92vh, 820px);
    height: min(92dvh, 820px); /* keeps the input bar fully on screen on mobile */
    display: flex;
    flex-direction: column;
    background: var(--wa-chat-bg);
    border-radius: 14px;
    overflow: hidden;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
}

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

.wa-header {
    background: var(--wa-header);
    color: #fff;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    flex: 0 0 auto;
}

.wa-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--wa-header-dark);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 15px;
    letter-spacing: 0.5px;
}

.wa-title { line-height: 1.25; }
.wa-name { font-weight: 600; font-size: 16px; }
.wa-status { font-size: 12px; opacity: 0.85; }

/* Home link, pinned to the right of the header like a WhatsApp action */
.wa-drops-link {
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: #fff;
    text-decoration: none;
    font-size: 12px;
    font-weight: 600;
    background: rgba(255, 255, 255, 0.16);
    padding: 6px 12px;
    border-radius: 14px;
    white-space: nowrap;
}
.wa-drops-link:hover { background: rgba(255, 255, 255, 0.28); }

/* ---------- Progress bar ---------- */

.wa-progress {
    background: var(--wa-header-dark);
    color: #eafff2;
    padding: 6px 16px 10px;
    flex: 0 0 auto;
}

.wa-progress-label {
    font-size: 11px;
    letter-spacing: 0.3px;
    display: block;
    margin-bottom: 5px;
    opacity: 0.9;
}

.wa-progress-track {
    height: 5px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.22);
    overflow: hidden;
}

.wa-progress-fill {
    height: 100%;
    width: 0;
    border-radius: 999px;
    background: var(--wa-accent);
    transition: width 0.5s ease;
}

/* ---------- Chat area ---------- */

.wa-chat {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 16px 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    background-color: var(--wa-chat-bg);
    background-image: radial-gradient(rgba(0, 0, 0, 0.035) 1px, transparent 1px);
    background-size: 22px 22px;
    scroll-behavior: smooth;
}

/* Drop label chip (centered, WhatsApp date-pill style, top of the chat) */
.wa-datechip {
    align-self: center;
    background: #d9ecf4;
    color: #54656f;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    padding: 5px 12px;
    border-radius: 8px;
    box-shadow: 0 1px 1px rgba(0, 0, 0, 0.08);
    margin: 8px 0 4px;
    text-align: center;
}

/* Scenario tag pill (centered, above a question) */
.wa-tag {
    align-self: center;
    background: #d8f0d0;
    color: #3a5f2f;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.3px;
    padding: 4px 12px;
    border-radius: 999px;
    box-shadow: 0 1px 1px rgba(0, 0, 0, 0.08);
    margin: 6px 0 2px;
    text-align: center;
}

/* Bubbles */
.wa-msg {
    max-width: 82%;
    padding: 8px 11px 9px;
    border-radius: 10px;
    font-size: 14.5px;
    line-height: 1.42;
    position: relative;
    box-shadow: 0 1px 0.5px rgba(0, 0, 0, 0.13);
    white-space: pre-wrap;
    word-wrap: break-word;
    animation: pop 0.18s ease-out;
}

/* Programmatic focus (moving to a new question) shows no box; keyboard users still get one. */
.wa-msg:focus { outline: none; }
.wa-msg:focus-visible { outline: 2px solid var(--wa-header); outline-offset: 2px; }

.wa-msg.bot {
    align-self: flex-start;
    background: var(--wa-bot-bubble);
    border-top-left-radius: 2px;
}

.wa-msg.user {
    align-self: flex-end;
    background: var(--wa-user-bubble);
    border-top-right-radius: 2px;
}

/* Question bubbles carry a green accent so they stand apart from chatter */
.wa-msg.wa-question {
    border-left: 3px solid var(--score-green);
}

.wa-msg .wa-time {
    display: block;
    text-align: right;
    font-size: 10px;
    color: var(--wa-muted);
    margin-top: 3px;
}

/* Labeled feedback bubble */
.wa-msg.fb { max-width: 90%; }

.fb-verdict {
    font-weight: 800;
    font-size: 14px;
    margin-bottom: 6px;
}
.fb-verdict.fb-green  { color: var(--score-green); }
.fb-verdict.fb-yellow { color: #b07d00; }
.fb-verdict.fb-red    { color: var(--score-red-text); }

.fb-body { font-size: 14.5px; line-height: 1.42; }

.fb-best-label {
    margin-top: 11px;
    padding-top: 9px;
    border-top: 1px solid #eceff1;
    font-size: 11.5px;
    font-weight: 800;
    letter-spacing: 0.4px;
    text-transform: uppercase;
    color: var(--score-green);
}
.fb-best-text {
    font-weight: 600;
    font-size: 14px;
    line-height: 1.4;
    margin-top: 4px;
}
.fb-why-label {
    margin-top: 8px;
    font-size: 11.5px;
    font-weight: 800;
    letter-spacing: 0.4px;
    text-transform: uppercase;
    color: var(--wa-muted);
}
.fb-best-why {
    font-size: 13.5px;
    line-height: 1.42;
    color: #33414a;
    margin-top: 3px;
}

/* Collapsed "right call" block inside a wrong-answer feedback bubble */
.fb-reveal-btn {
    display: block;
    width: 100%;
    margin-top: 11px;
    padding: 9px 0 0;
    border: none;
    border-top: 1px solid #eceff1;
    background: none;
    text-align: left;
    font-size: 12.5px;
    font-weight: 700;
    color: var(--wa-header);
    cursor: pointer;
}
.fb-reveal-btn:hover { text-decoration: underline; }
.fb-reveal .fb-best-label {
    border-top: none;
    margin-top: 6px;
    padding-top: 0;
}

/* Score chip inside feedback bubble */
.wa-scorechip {
    display: inline-block;
    margin-top: 8px;
    font-size: 12px;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: 999px;
    color: #fff;
}
.wa-scorechip.green { background: var(--score-green); }
.wa-scorechip.yellow { background: var(--score-yellow); }
.wa-scorechip.red { background: var(--score-red); }

@keyframes pop {
    from { transform: translateY(6px) scale(0.98); opacity: 0; }
    to   { transform: translateY(0) scale(1); opacity: 1; }
}

/* Typing indicator */
.wa-typing {
    align-self: flex-start;
    background: var(--wa-bot-bubble);
    padding: 12px 14px;
    border-radius: 10px;
    border-top-left-radius: 2px;
    box-shadow: 0 1px 0.5px rgba(0, 0, 0, 0.13);
    display: inline-flex;
    gap: 4px;
}
.wa-typing span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #9aa6ac;
    animation: blink 1.2s infinite ease-in-out both;
}
.wa-typing span:nth-child(2) { animation-delay: 0.2s; }
.wa-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes blink {
    0%, 80%, 100% { transform: scale(0.7); opacity: 0.4; }
    40% { transform: scale(1); opacity: 1; }
}

/* ---------- Input bar (start button / options) ---------- */

.wa-inputbar {
    flex: 0 0 auto;
    background: #f0f2f5;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    border-top: 1px solid #e2e2e2;
    max-height: 48%;
    overflow-y: auto;
}

.wa-option {
    text-align: left;
    background: #fff;
    border: 1px solid #d6dde0;
    border-radius: 10px;
    padding: 11px 13px;
    font-size: 14px;
    line-height: 1.35;
    color: var(--wa-text);
    cursor: pointer;
    transition: background 0.12s ease, border-color 0.12s ease, transform 0.05s ease;
}
.wa-option:hover { background: #f2fbef; border-color: var(--wa-accent); }
.wa-option:active { transform: scale(0.995); }
.wa-option:disabled { opacity: 0.55; cursor: default; }

.wa-option-num {
    display: inline-block;
    min-width: 20px;
    font-weight: 700;
    color: var(--wa-header);
}

.wa-cta {
    background: var(--wa-header);
    color: #fff;
    border: none;
    border-radius: 999px;
    padding: 13px 20px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease, transform 0.05s ease;
}
.wa-cta:hover { background: #0a6d60; }
.wa-cta:active { transform: scale(0.99); }

/* Secondary CTA (e.g. "Start over" under the resume prompt) */
.wa-cta.wa-cta-secondary {
    background: none;
    color: var(--wa-header);
    border: 1.5px solid var(--wa-header);
}
.wa-cta.wa-cta-secondary:hover { background: #e9f3f1; }

.wa-intro {
    text-align: center;
    color: var(--wa-muted);
    font-size: 13px;
    line-height: 1.5;
    padding: 4px 6px 0;
}

/* ============================================================
   RESULTS PAGE
   ============================================================ */

.results-page {
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 28px 16px 60px;
}

.results-card {
    position: relative;
    width: 100%;
    max-width: 560px;
    background: #fff;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
}

/* Back-to-home pill, same idea as the chat page's header link, positioned
   over the top-left corner of the Drops/Concepts cards (Results has its own
   "Home" button in the action row instead, so the hero stays uncluttered). */
.back-home-link {
    position: absolute; top: 16px; left: 16px; z-index: 4;
    display: inline-flex; align-items: center; gap: 6px;
    text-decoration: none; font-size: 12px; font-weight: 600;
    padding: 6px 12px; border-radius: 14px; white-space: nowrap;
    background: #eef1f4; color: var(--wa-header);
}
.back-home-link:hover { background: #e2e7ea; }

.results-hero {
    position: relative;
    text-align: center;
    padding: 30px 20px 0;
    color: #fff;
    overflow: hidden;
}
.results-hero.score-green {
    background:
        radial-gradient(120% 90% at 50% 0%, rgba(37, 211, 102, 0.35), rgba(37, 211, 102, 0) 60%),
        linear-gradient(165deg, #0d6b52, #054d44 70%, #04382f);
}
.results-hero.score-yellow {
    background:
        radial-gradient(120% 90% at 50% 0%, rgba(233, 196, 100, 0.35), rgba(233, 196, 100, 0) 60%),
        linear-gradient(165deg, #6e5314, #4a3b10 70%, #2f2609);
}
.results-hero.score-red {
    background:
        radial-gradient(120% 90% at 50% 0%, rgba(208, 112, 79, 0.32), rgba(208, 112, 79, 0) 60%),
        linear-gradient(165deg, #6b3f2c, #4a2c1f 70%, #301c14);
}

.results-eyebrow {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 2.2px;
    opacity: 0.85;
    margin-bottom: 16px;
}

/* ---- progress ring ---- */
.score-ring-wrap {
    position: relative;
    width: 172px;
    height: 172px;
    margin: 0 auto;
    cursor: pointer;
    border-radius: 50%;
}
.score-ring-wrap svg { transform: rotate(-90deg); display: block; }
.ring-bg { fill: none; stroke: rgba(255, 255, 255, 0.14); stroke-width: 9; }
.ring-fg {
    fill: none; stroke-width: 9; stroke-linecap: round;
    transition: stroke-dashoffset 1.6s cubic-bezier(0.22, 1, 0.36, 1);
}
.score-green  .ring-fg, .results-hero.score-green  .ring-fg { stroke: #25d366; filter: drop-shadow(0 0 6px rgba(37, 211, 102, 0.55)); }
.results-hero.score-yellow .ring-fg { stroke: #e9c464; filter: drop-shadow(0 0 6px rgba(233, 196, 100, 0.5)); }
.results-hero.score-red    .ring-fg { stroke: #e79a72; filter: drop-shadow(0 0 6px rgba(231, 154, 114, 0.5)); }
.ring-center {
    position: absolute; inset: 0; display: flex; flex-direction: column;
    align-items: center; justify-content: center;
}
.results-score { font-size: 56px; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.results-score-max { font-size: 15px; font-weight: 600; opacity: 0.75; margin-top: 2px; }

/* ---- tier badge ---- */
.results-tier {
    display: inline-flex; align-items: center; gap: 8px;
    margin: 16px auto 8px;
    padding: 7px 18px; border-radius: 999px;
    border: 1px solid rgba(233, 196, 100, 0.65);
    background: linear-gradient(180deg, rgba(233, 196, 100, 0.16), rgba(233, 196, 100, 0.05));
    color: #e9c464;
    font-size: 14px; font-weight: 800; letter-spacing: 1.6px; text-transform: uppercase;
}
.results-tier svg { display: block; }
.results-correct { font-size: 13px; opacity: 0.85; margin: 2px 0 18px; }

/* ---- attribution strip (inside the hero, above the crop line) ---- */
.results-attribution {
    display: flex; justify-content: center; gap: 6px; flex-wrap: wrap;
    border-top: 1px solid rgba(255, 255, 255, 0.16);
    margin: 0; padding: 10px 14px 12px;
    font-size: 11.5px; letter-spacing: 0.3px; color: rgba(255, 255, 255, 0.92);
}
.results-attribution b { font-weight: 700; color: #fff; }
.results-attribution .dot { opacity: 0.5; }
/* Each part stays whole; narrow screens wrap between parts, not mid-phrase */
.results-attribution .attr-part { white-space: nowrap; }
@media (max-width: 480px) {
    .results-attribution .attr-sep { display: none; }
}

/* confetti canvas overlays the hero */
#confetti-canvas {
    position: absolute; inset: 0; pointer-events: none; z-index: 3;
    width: 100%; height: 100%;
}

@media (prefers-reduced-motion: reduce) {
    .ring-fg { transition: none; }
}

.results-section { padding: 22px 24px 4px; }
.results-h2 {
    font-size: 19px;
    font-weight: 700;
    color: #111b21;
    margin: 0 0 12px;
}
.results-h2::after {
    content: "";
    display: block;
    width: 44px;
    height: 3px;
    margin-top: 6px;
    border-radius: 2px;
    background: var(--score-green);
}
.results-message { margin: 0 0 14px; color: #33414a; font-size: 14.5px; line-height: 1.55; }

/* Collapsible history */
.history {
    border-top: 1px solid #eceff1;
    padding: 16px 24px 20px;
}
.history-summary {
    list-style: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 14px 16px;
    border-radius: 12px;
    background: #eaf7f1;
    border: 1px solid #d3ebe1;
    font-size: 14.5px;
    font-weight: 700;
    color: var(--wa-header);
    user-select: none;
    transition: background 0.15s ease, border-color 0.15s ease;
}
.history-summary:hover { background: #dcf3e9; border-color: var(--wa-accent); }
.history-summary::-webkit-details-marker { display: none; }
.history-chevron { transition: transform 0.2s ease; font-size: 13px; opacity: 0.8; }
.history[open] .history-chevron { transform: rotate(180deg); }
.history[open] .history-summary { border-radius: 12px 12px 0 0; }
.history .breakdown-list { padding: 12px 2px 8px; }

/* Breakdown */
.breakdown-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.breakdown-item {
    border: 1px solid #eceff1;
    border-left-width: 5px;
    border-radius: 10px;
    padding: 11px 13px;
    background: #fbfdfc;
}
.breakdown-item.bd-green  { border-left-color: var(--score-green); }
.breakdown-item.bd-yellow { border-left-color: var(--score-yellow); }
.breakdown-item.bd-red    { border-left-color: var(--score-red); }

.breakdown-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 5px; }
.breakdown-qnum { font-size: 12px; font-weight: 700; color: var(--wa-header); letter-spacing: 0.3px; }
.breakdown-question { font-size: 13.5px; color: var(--wa-text); line-height: 1.45; margin-bottom: 6px; }
.breakdown-meta { display: inline-flex; align-items: center; gap: 7px; flex: 0 0 auto; }
.breakdown-verdict {
    font-size: 11px; font-weight: 800; letter-spacing: 0.3px; text-transform: uppercase;
    padding: 2px 8px; border-radius: 999px;
}
.bd-green .breakdown-verdict  { color: var(--score-green);  background: #e4f6ea; }
.bd-yellow .breakdown-verdict { color: #a37700;             background: #fbf1d6; }
.bd-red .breakdown-verdict    { color: var(--score-red-text); background: #fbeae1; }
.breakdown-score {
    font-size: 13px; font-weight: 800; color: #fff;
    padding: 2px 9px; border-radius: 999px; background: var(--wa-muted);
}
.bd-green .breakdown-score  { background: var(--score-green); }
.bd-yellow .breakdown-score { background: var(--score-yellow); }
.bd-red .breakdown-score    { background: var(--score-red); }
.breakdown-choice { font-size: 13.5px; color: #33414a; line-height: 1.45; }
.breakdown-best {
    margin-top: 7px; padding-top: 7px; border-top: 1px dashed #e0e5e8;
    font-size: 13px; color: #33414a; line-height: 1.45;
}
.breakdown-best-label { font-weight: 700; color: var(--score-green); }

/* Study topics: whole-row tappable cards so links read as links on mobile */
.topic-hint { margin: 0 0 10px; color: var(--wa-muted); font-size: 12.5px; }
.topic-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.topic-item { display: block; }
.topic-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    background: #f6faf8;
    border: 1px solid #d9e7e0;
    border-radius: 10px;
    padding: 12px 14px;
    font-size: 14.5px;
    font-weight: 600;
    line-height: 1.4;
    color: var(--wa-header);
    text-decoration: none;
}
.topic-link::after {
    content: "\2197"; /* ↗ signals it opens a page */
    flex-shrink: 0;
    font-size: 15px;
    font-weight: 700;
    color: #8696a0;
}
.topic-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.topic-name { font-weight: 600; }
.topic-anchor { font-size: 12.5px; font-weight: 400; color: var(--wa-muted); }
.topic-link:hover { border-color: var(--wa-header); background: #eff7f3; }
.topic-link:active { background: #e7f2ec; }

/* ---- share + retake row ---- */
.results-actions-share {
    display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; padding: 20px 24px 6px;
}
/* In-page pointer to the study list further down */
.btn-learn-next {
    background: none; border: 1.5px solid var(--score-green); color: #189a4d; cursor: pointer;
    padding: 13px 20px; border-radius: 999px; font-weight: 600; font-size: 14px; font-family: inherit;
    text-decoration: none; display: inline-flex; align-items: center;
    transition: background 0.15s ease;
}
.btn-learn-next:hover { background: #eefaf3; }
/* Narrow screens: Share + Retake share the first row, the study pointer gets
   its own full-width row instead of wrapping raggedly */
@media (max-width: 480px) {
    .btn-learn-next { flex-basis: 100%; justify-content: center; }
    /* Without this, "Share your score" wraps to 3 lines and, because flex
       items stretch to match the tallest sibling on their line by default,
       drags Retake/Home into tall squished pills instead of clean rows. */
    .btn-share { flex-basis: 100%; max-width: none; }
}
@media (prefers-reduced-motion: no-preference) {
    html { scroll-behavior: smooth; }
}
.btn-share {
    flex: 1; max-width: 220px;
    background: var(--score-green); color: #fff; border: none; cursor: pointer;
    padding: 13px 18px; border-radius: 999px; font-weight: 700; font-size: 15px;
    font-family: inherit;
    box-shadow: 0 4px 14px rgba(31, 168, 85, 0.35);
    transition: background 0.15s ease;
}
.btn-share:hover { background: #189a4d; }
.btn-retake-outline {
    background: none; border: 1.5px solid #cfd8d3; color: var(--wa-header); cursor: pointer;
    padding: 13px 20px; border-radius: 999px; font-weight: 600; font-size: 14px; font-family: inherit;
    text-decoration: none; display: inline-flex; align-items: center;
    transition: border-color 0.15s ease;
}
.btn-retake-outline:hover { border-color: var(--wa-header); }

/* ---- credit link ---- */
.credit-slim { margin: 16px 24px 0; display: flex; justify-content: center; }
.credit-li-btn {
    background: #0a66c2; color: #fff; text-decoration: none;
    font-size: 12px; font-weight: 700; padding: 6px 13px; border-radius: 999px;
    white-space: nowrap;
}

/* ---- share dialog ---- */
dialog {
    border: none; border-radius: 16px; padding: 0;
    max-width: 380px; width: calc(100vw - 40px);
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.4);
}
dialog::backdrop { background: rgba(10, 20, 16, 0.55); }
.modal-inner { background: #fff; color: var(--wa-text); padding: 24px 24px 20px; }
.modal-head { display: flex; align-items: center; gap: 12px; margin-bottom: 6px; }
.modal-title { font-size: 17px; font-weight: 800; }
.modal-close {
    margin-left: auto; background: none; border: none; cursor: pointer;
    font-size: 20px; color: var(--wa-muted); line-height: 1; padding: 4px;
}

.sheet-text {
    background: #f0f5f3; border-radius: 10px; padding: 12px 14px;
    font-size: 13.5px; line-height: 1.5; color: var(--wa-text); margin: 0 0 14px;
}
.sheet-btns { display: flex; gap: 8px; }
.sheet-btn {
    flex: 1; border: none; cursor: pointer; font-family: inherit;
    padding: 11px 0; border-radius: 999px; font-weight: 700; font-size: 13.5px;
    text-decoration: none; text-align: center; color: #fff;
}
.sheet-wa { background: #25d366; }
.sheet-li { background: #0a66c2; }
.sheet-copy { background: #e8edeb; color: var(--wa-text); }
