/* =====================================================================
   With Practice — Shared Design System
   ---------------------------------------------------------------------
   One stylesheet, used across the landing site, the payment flow and the
   lesson-review pages, so every surface shares the same look and a change
   made here lands everywhere.

   Load it from any page with a same-origin link (works with CSP 'self'):
       <link rel="stylesheet" href="/assets/wp-system.css">

   Structure
     1. Design tokens        (:root custom properties)
     2. Base / reset         (body, links, headings)
     3. Utilities            (.wp-wrap, .muted, .eyebrow, visually-hidden)
     4. Buttons              (.button + variants)
     5. Brand lockup         (.wp-brand)
     6. Cards & panels       (.card, .panel, .summary)
     7. Forms                (.field, .check, .radio-*)
     8. Feedback             (.flash, .note, .pill, .badge, .count-badge)
     9. Payment shells       (.pay-shell, .pay-card, .pay-head, .pay-glyph)
    10. Dashboard shell      (.dash-shell, .dash-side, .dash-table, .dash-tabs)
    11. Review pages         (.pages nav, .page, .chat bubbles, quiz .q)

   Naming: shared building blocks are unprefixed (.button, .card, .field).
   Area-specific shells keep their historical prefixes (.pay-*, .dash-*) so
   existing markup keeps working without edits.
   ===================================================================== */

/* ---------------------------------------------------------------------
   1. Design tokens
   --------------------------------------------------------------------- */
:root {
    /* Brand palette */
    --ink: #1e293b;
    --ink-soft: #52607a;
    --paper: #fbf5e9;
    --teal: #238b7e;
    --teal-deep: #146458;
    --sun: #f8c94e;
    --coral: #ed7665;
    --coral-deep: #a23b2c;
    --line: #ddcfbd;
    --card: #fffdf8;
    --muted: #a99f8c;

    /* Translucent brand tints (reused by pills, alerts, quiz states) */
    --teal-tint: rgba(35, 139, 126, 0.12);
    --teal-tint-strong: rgba(35, 139, 126, 0.18);
    --coral-tint: rgba(237, 118, 101, 0.14);
    --coral-tint-strong: rgba(237, 118, 101, 0.18);
    --ink-tint: rgba(30, 41, 59, 0.06);

    /* Typography */
    --font-sans: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
    --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

    /* Radius scale */
    --radius-sm: 12px;
    --radius-md: 16px;
    --radius-lg: 22px;
    --radius-xl: 26px;
    --radius-pill: 999px;

    /* Shadows */
    --shadow-card: 0 24px 60px -34px rgba(30, 41, 59, 0.55);
    --shadow-pop: 4px 4px 0 var(--ink);
    --shadow-pop-lg: 6px 6px 0 var(--ink);

    /* Motion */
    --ease: cubic-bezier(0.4, 0, 0.2, 1);
    --speed: 0.18s;
}

/* ---------------------------------------------------------------------
   2. Base / reset
   --------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }

body {
    margin: 0;
    min-width: 320px;
    background: var(--paper);
    color: var(--ink);
    font-family: var(--font-sans);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a { color: inherit; }

/* ---------------------------------------------------------------------
   3. Utilities
   --------------------------------------------------------------------- */
.wp-wrap { max-width: 820px; margin: 0 auto; padding: 28px 20px 80px; }

.muted { color: var(--muted); }

.eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 0.74rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.16em;
    color: var(--teal-deep);
    margin-bottom: 10px;
}

.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;
}

/* ---------------------------------------------------------------------
   4. Buttons
   --------------------------------------------------------------------- */
.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 22px;
    border-radius: var(--radius-pill);
    font-weight: 600;
    font-size: 0.95rem;
    text-decoration: none;
    border: 2px solid var(--ink);
    cursor: pointer;
    transition: transform var(--speed) var(--ease),
                box-shadow var(--speed) var(--ease),
                background var(--speed) var(--ease);
    line-height: 1;
    font-family: inherit;
}
.button:hover { transform: translateY(-2px); }
.button-sun { background: var(--sun); color: var(--ink); box-shadow: var(--shadow-pop); }
.button-sun:hover { box-shadow: var(--shadow-pop-lg); }
.button-ink { background: var(--ink); color: var(--paper); }
.button-ghost { background: transparent; color: var(--ink); }
.button-ghost:hover { background: var(--ink-tint); }
.button-block { width: 100%; }
.button-sm { padding: 7px 14px; font-size: 0.82rem; }

.btn-row {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: center;
    margin-top: 8px;
}

/* ---------------------------------------------------------------------
   5. Brand lockup
   --------------------------------------------------------------------- */
.wp-brand {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: var(--ink);
    font-weight: 700;
    letter-spacing: -0.01em;
}
.wp-brand .brand-mark {
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    background: var(--sun);
    border: 2px solid var(--ink);
    font-weight: 800;
    font-size: 1.1rem;
}
.wp-brand small {
    display: block;
    font-weight: 500;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    opacity: 0.6;
}

/* ---------------------------------------------------------------------
   6. Cards & panels
   --------------------------------------------------------------------- */
.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    padding: 26px 30px;
    margin-bottom: 22px;
}
.card > h2 { margin: 0 0 4px; font-size: 1.3rem; letter-spacing: -0.01em; }
.card > .sub { margin: 0 0 16px; color: var(--ink-soft); font-size: 0.88rem; }

/* Section divider used inside cards */
.section { padding: 16px 0; border-top: 1px solid var(--line); }
.section:first-of-type { border-top: none; }
.section .path {
    display: inline-flex;
    align-items: center;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--teal-deep);
    margin-bottom: 4px;
}
.section h3 { margin: 0 0 8px; font-size: 1.05rem; }
.section .body { color: var(--ink-soft); }

/* Panel (dashboard-style header + body) */
.panel {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    margin-bottom: 24px;
    overflow: hidden;
}
.panel-head { padding: 18px 24px; border-bottom: 1px solid var(--line); font-weight: 700; }
.panel-body { padding: 24px; }

/* Summary / detail list */
.summary {
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    padding: 20px 22px;
    margin-bottom: 24px;
}
.summary h3 {
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    opacity: 0.65;
    margin: 0 0 14px;
}
.summary-row {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    padding: 8px 0;
    border-bottom: 1px solid var(--line);
}
.summary-row:last-child { border-bottom: none; }
.summary-row .label { opacity: 0.7; }
.summary-row .value { font-weight: 600; text-align: right; }
.summary-row .value.amount { color: var(--teal-deep); }

.muted-note { text-align: center; opacity: 0.7; font-size: 0.9rem; margin-top: 22px; }

/* ---------------------------------------------------------------------
   7. Forms
   --------------------------------------------------------------------- */
.field { margin-bottom: 18px; }
.field label {
    display: block;
    font-size: 0.82rem;
    font-weight: 600;
    margin-bottom: 6px;
    letter-spacing: 0.01em;
}
.field input[type="text"],
.field input[type="email"],
.field input[type="tel"],
.field input[type="password"],
.field input[type="number"],
.field select,
.field textarea {
    width: 100%;
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    border: 1.5px solid var(--line);
    background: #fff;
    color: var(--ink);
    font: inherit;
    transition: border-color var(--speed) var(--ease), box-shadow var(--speed) var(--ease);
}
.field input:focus,
.field select:focus,
.field textarea:focus {
    outline: none;
    border-color: var(--teal);
    box-shadow: 0 0 0 3px var(--teal-tint-strong);
}
.field input.has-error { border-color: var(--coral); }
.field-error { margin-top: 6px; font-size: 0.8rem; color: var(--coral-deep); }

.check {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    margin-bottom: 18px;
}
.check input { width: 16px; height: 16px; accent-color: var(--teal); }

.radio-group { display: grid; gap: 10px; }
.radio-tile {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    border: 1.5px solid var(--line);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: border-color var(--speed) var(--ease), background var(--speed) var(--ease);
}
.radio-tile:hover { border-color: var(--teal); }
.radio-tile input { accent-color: var(--teal); }

/* ---------------------------------------------------------------------
   8. Feedback: alerts, pills, badges
   --------------------------------------------------------------------- */
.flash {
    border-radius: var(--radius-sm);
    padding: 13px 16px;
    margin-bottom: 20px;
    border: 1px solid var(--line);
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 10px;
    text-align: left;
}
.flash-success { background: var(--teal-tint); border-color: rgba(35, 139, 126, 0.4); color: var(--teal-deep); }
.flash-error { background: var(--coral-tint); border-color: rgba(237, 118, 101, 0.45); color: var(--coral-deep); }

.note {
    border-radius: var(--radius-sm);
    padding: 14px 18px;
    border: 1px solid var(--line);
    background: var(--paper);
    display: flex;
    align-items: center;
    gap: 10px;
}

.pill {
    display: inline-block;
    padding: 4px 12px;
    border-radius: var(--radius-pill);
    font-weight: 700;
    font-size: 0.72rem;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    border: 1.5px solid var(--ink);
}
.pill-paid, .pill-success { background: var(--teal-tint-strong); color: var(--teal-deep); }
.pill-pending { background: var(--sun); color: var(--ink); }
.pill-overdue, .pill-failed { background: var(--coral-tint-strong); color: var(--coral-deep); }

.badge {
    display: inline-block;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    background: var(--sun);
    color: var(--ink);
    padding: 3px 10px;
    border-radius: var(--radius-pill);
    margin-left: 8px;
    vertical-align: middle;
}

.count-badge {
    background: var(--sun);
    color: var(--ink);
    border-radius: var(--radius-pill);
    padding: 1px 9px;
    font-size: 0.75rem;
    font-weight: 700;
}

/* ---------------------------------------------------------------------
   9. Payment shells (centered single-card pages)
   --------------------------------------------------------------------- */
.pay-shell {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px 20px;
}

.pay-brand {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: var(--ink);
    font-weight: 700;
    letter-spacing: -0.01em;
    margin-bottom: 28px;
}
.pay-brand .brand-mark {
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    background: var(--sun);
    border: 2px solid var(--ink);
    font-weight: 800;
    font-size: 1.1rem;
}
.pay-brand small {
    display: block;
    font-weight: 500;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    opacity: 0.6;
}

.pay-card {
    width: 100%;
    max-width: 560px;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius-xl);
    padding: 40px;
    box-shadow: var(--shadow-card);
}
.pay-card.is-narrow { max-width: 480px; }

.pay-head { text-align: center; margin-bottom: 28px; }
.pay-head h1 {
    font-size: clamp(1.6rem, 3.4vw, 2.1rem);
    line-height: 1.1;
    letter-spacing: -0.02em;
    margin: 0 0 8px;
}
.pay-head p { margin: 0; opacity: 0.72; }

.pay-glyph {
    width: 84px;
    height: 84px;
    margin: 0 auto 20px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    font-size: 2.2rem;
    border: 2px solid var(--ink);
}
.pay-glyph.is-success { background: var(--teal-tint-strong); color: var(--teal-deep); }
.pay-glyph.is-failed { background: var(--coral-tint-strong); color: var(--coral-deep); }

/* ---------------------------------------------------------------------
   10. Dashboard shell (sidebar + main, tables, tabs)
   --------------------------------------------------------------------- */
.dash-shell {
    max-width: 1200px;
    margin: 0 auto;
    padding: 32px 24px 64px;
    display: grid;
    grid-template-columns: 260px 1fr;
    gap: 28px;
    align-items: start;
}

.dash-side { position: sticky; top: 24px; }
.side-brand {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: var(--ink);
    font-weight: 700;
    letter-spacing: -0.01em;
    margin-bottom: 24px;
}
.side-brand .brand-mark {
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    background: var(--sun);
    border: 2px solid var(--ink);
    font-weight: 800;
    font-size: 1.1rem;
}
.side-brand small {
    display: block;
    font-weight: 500;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    opacity: 0.6;
}

.side-user {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 18px;
    padding: 18px;
    margin-bottom: 18px;
    display: flex;
    align-items: center;
    gap: 12px;
}
.side-user .avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: var(--teal);
    color: var(--paper);
    display: grid;
    place-items: center;
    font-weight: 700;
    font-size: 1.05rem;
    flex-shrink: 0;
}
.side-user .name { font-weight: 700; line-height: 1.2; }
.side-user .role { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.1em; opacity: 0.6; }

.side-nav { display: grid; gap: 4px; margin-bottom: 18px; }
.side-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 14px;
    border-radius: var(--radius-sm);
    text-decoration: none;
    color: var(--ink);
    font-weight: 600;
    font-size: 0.94rem;
    transition: background 0.16s var(--ease), color 0.16s var(--ease);
}
.side-link i { width: 20px; text-align: center; opacity: 0.8; }
.side-link:hover { background: var(--ink-tint); }
.side-link.active { background: var(--ink); color: var(--paper); }
.side-link.active i { opacity: 1; }

.side-logout {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 14px;
    border-radius: var(--radius-pill);
    border: 2px solid var(--coral);
    color: var(--coral-deep);
    background: transparent;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9rem;
    justify-content: center;
    transition: background 0.16s var(--ease);
}
.side-logout:hover { background: var(--coral-tint); }

.dash-main { min-width: 0; }

.welcome-header {
    background: var(--ink);
    color: var(--paper);
    border-radius: 24px;
    padding: 28px 30px;
    margin-bottom: 26px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 18px;
}
.welcome-header h2 { margin: 0 0 4px; font-size: 1.6rem; letter-spacing: -0.01em; }
.welcome-header p { margin: 0; opacity: 0.75; }

.dash-table { width: 100%; border-collapse: collapse; }
.dash-table th, .dash-table td {
    padding: 12px 14px;
    text-align: left;
    border-bottom: 1px solid var(--line);
}
.dash-table thead th {
    font-size: 0.74rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 700;
    color: var(--teal-deep);
    background: var(--paper);
}
.dash-table tbody tr:hover { background: rgba(30, 41, 59, 0.03); }
.dash-table tbody tr:last-child td { border-bottom: none; }

.dash-tabs {
    display: flex;
    gap: 8px;
    list-style: none;
    margin: 0;
    padding: 0;
    border: none;
}
.dash-tab {
    border: none;
    background: transparent;
    font: inherit;
    font-weight: 600;
    color: var(--ink);
    opacity: 0.6;
    padding: 8px 4px;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}
.dash-tab.active { opacity: 1; border-bottom-color: var(--sun); }

@media (max-width: 860px) {
    .dash-shell { grid-template-columns: 1fr; }
    .dash-side { position: static; }
    .side-nav { grid-template-columns: repeat(2, 1fr); }
}

/* ---------------------------------------------------------------------
   11. Review pages (lesson notes / student view)
   --------------------------------------------------------------------- */
h1.lesson-title { font-size: 1.8rem; margin: 0 0 18px; letter-spacing: -0.01em; }

/* Sticky pill navigation between lesson pages */
nav.pages {
    position: sticky;
    top: 0;
    z-index: 5;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    padding: 14px 0;
    margin-bottom: 24px;
    background: var(--paper);
    border-bottom: 1px solid var(--line);
}
nav.pages a {
    display: inline-block;
    padding: 8px 16px;
    border-radius: var(--radius-pill);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 600;
    background: var(--card);
    color: var(--ink);
    border: 1.5px solid var(--line);
    transition: transform 0.16s var(--ease), box-shadow 0.16s var(--ease),
                background 0.16s var(--ease), color 0.16s var(--ease),
                border-color 0.16s var(--ease);
}
nav.pages a:hover { border-color: var(--ink); background: rgba(30, 41, 59, 0.04); }
nav.pages a.active { background: var(--sun); color: var(--ink); border-color: var(--ink); box-shadow: 3px 3px 0 var(--ink); }

.page { display: none; }
.page.active { display: block; }
.page-nav-btns { display: flex; justify-content: space-between; margin-top: 8px; gap: 10px; }
.page-nav-btns button {
    padding: 10px 18px;
    border-radius: var(--radius-pill);
    border: 2px solid var(--ink);
    cursor: pointer;
    background: transparent;
    color: var(--ink);
    font-size: 0.9rem;
    font-weight: 600;
    font-family: inherit;
    transition: transform 0.16s var(--ease), background 0.16s var(--ease);
}
.page-nav-btns button:hover { background: var(--ink-tint); transform: translateY(-2px); }
.page-nav-btns button[disabled] { opacity: 0.35; cursor: default; transform: none; }

/* Conversation chat bubbles */
.chat { display: flex; flex-direction: column; gap: 10px; }
.bubble-row { display: flex; }
.bubble-row.left { justify-content: flex-start; }
.bubble-row.right { justify-content: flex-end; }
.bubble { max-width: 78%; padding: 11px 15px; border-radius: 18px; border: 1px solid var(--line); }
.bubble-row.left .bubble { border-bottom-left-radius: 5px; }
.bubble-row.right .bubble { border-bottom-right-radius: 5px; }
.bubble-speaker { font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--teal-deep); margin-bottom: 3px; }
.bubble-body { color: var(--ink); }
.chat-note { text-align: center; color: var(--muted); font-size: 0.85rem; font-style: italic; padding: 4px 0; }
/* Speaker colour palette (assigned in first-seen order) */
.bubble.c1 { background: #fff6df; }
.bubble.c2 { background: #e4f3f0; }
.bubble.c3 { background: #fdeee4; }
.bubble.c4 { background: #fbf2e3; }
.bubble.c5 { background: #eef4e9; }
.bubble.c6 { background: #e7f1f5; }

/* Quiz questions & options.
   Two contracts share this block:
     - Interactive (student view): plain `ul.options`. JS adds .answered on the
       <ul> and .chosen/.correct/.wrong on <li>. Explanations start hidden and
       are revealed with .show after grading.
     - Read-only answer key (teacher notes): `ul.options.answer-key`. The
       correct option is pre-marked with .correct and labelled inline; the
       explanation is always visible (no toggle). */
.q { padding: 16px 0; border-top: 1px solid var(--line); }
.q:first-of-type { border-top: none; }
.q .prompt { font-weight: 600; margin-bottom: 10px; }
ul.options { list-style: none; margin: 0 0 10px; padding: 0; }
ul.options li {
    padding: 11px 15px;
    border: 1.5px solid var(--line);
    border-radius: var(--radius-sm);
    margin-bottom: 7px;
    transition: background 0.14s var(--ease), border-color 0.14s var(--ease);
}

/* Interactive affordances (default). The read-only key opts out. */
ul.options:not(.answer-key) li { cursor: pointer; }
ul.options:not(.answer-key) li:hover { border-color: var(--ink); background: rgba(30, 41, 59, 0.03); }
ul.options li.chosen { border-color: var(--ink); }
ul.options.answered li { cursor: default; }
ul.options li.correct { border-color: var(--teal); background: var(--teal-tint); }
ul.options.answered li.correct::after { content: " \2713"; color: var(--teal-deep); font-weight: 700; }
ul.options.answered li.wrong { border-color: var(--coral); background: var(--coral-tint); }
ul.options.answered li.wrong::after { content: " \2717"; color: var(--coral-deep); font-weight: 700; }

/* Read-only answer key: mark the correct option immediately. */
ul.options.answer-key li.correct::after { content: " \2713 correct"; color: var(--teal-deep); font-size: 0.8rem; font-weight: 700; }

.explanation {
    font-size: 0.9rem;
    color: var(--ink-soft);
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    padding: 11px 14px;
}
/* Interactive explanations stay hidden until the question is graded.
   The read-only key shows them straight away via .explanation.static. */
.explanation:not(.static) { display: none; margin-top: 4px; }
.explanation.show,
.explanation.static { display: block; }
.score { font-weight: 700; color: var(--teal-deep); margin-top: 12px; }

/* Collapsible raw block (grammar diff dump, etc.) */
details.raw { margin-top: 12px; }
details.raw summary { cursor: pointer; color: var(--ink-soft); font-size: 0.85rem; font-weight: 600; }
details.raw pre {
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    padding: 14px;
    overflow-x: auto;
    font-size: 0.82rem;
    white-space: pre-wrap;
    word-break: break-word;
}

.audio-note { font-size: 0.82rem; color: var(--ink-soft); margin-top: 8px; }
