/* =========================================================================
   DESIGN SYSTEM LAYER

   Four things live here, all of them cross-cutting:
     1. Typography  — one family (Inter) instead of Segoe UI / Google Sans /
                      Roboto picked per file.
     2. Spacing     — a 4px scale replacing the ad-hoc 5/10/11/13/15/22/25px.
     3. Colour      — the app grew five competing accents (#03dac6 teal,
                      #2196f3 blue, #9c27b0 purple, #ffca28 amber, #ff5252 red)
                      all used as "the" highlight. They collapse to one primary
                      + one accent, with the rest demoted to semantic status
                      colours that only appear when they mean something.
     4. Components  — the mobile tab bar and skeleton loaders.

   Loaded after light-theme.css. Test mode, the video player and the notes
   surfaces keep their own identity and are excluded throughout.
   ========================================================================= */

:root {
    /* 4px spacing scale */
    --sp-1: 4px;
    --sp-2: 8px;
    --sp-3: 12px;
    --sp-4: 16px;
    --sp-5: 20px;
    --sp-6: 24px;
    --sp-8: 32px;

    /* Semantic colour roles. --brand / --brand-2 stay as the source of truth
       so both themes keep flowing through the existing token switch. */
    --primary: var(--brand);
    --primary-soft: var(--brand-soft);
    --accent: var(--brand-2);

    --tabbar-h: 58px;
}

/* ── 1. TYPOGRAPHY ──────────────────────────────────────────────────────── */

body,
button,
input,
textarea,
select,
.set-btn,
.sub-btn {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

body {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    letter-spacing: -0.006em;
}

/* Handwritten notes (Kalam) and AI smart notes (Outfit) opt out on purpose —
   their own rules are more specific and still win. Monospace timers too. */

/* ── 2. SPACING NORMALISATION ───────────────────────────────────────────── */

.scroll-content {
    padding: var(--sp-4);
}

.stats-grid,
.action-grid {
    gap: var(--sp-4);
}

.dash-hero.hero-panel {
    margin-bottom: var(--sp-6);
}

/* ── 3. COLOUR CONSOLIDATION ────────────────────────────────────────────── */

/* Legacy teal was used as the primary highlight in ~40 places. It becomes the
   single accent, so it now reads as one deliberate colour rather than a second
   brand competing with the blue. */
body:not(.test-taking-mode) #full-res-title,
body:not(.test-taking-mode) .res-segments-card-container > h3,
body:not(.test-taking-mode) .rev-hub-intro + * h5,
body:not(.test-taking-mode) .chart-container-box h5 {
    color: var(--accent) !important;
}

/* Home stat cards: three different left-border colours became one accent rail,
   with the weak-area card keeping red because red *means* something there. */
body:not(.test-taking-mode) #home-view .stat-card {
    border-left-color: var(--primary) !important;
}

body:not(.test-taking-mode) #home-view .stat-card.stat-card-wide {
    border-left-color: var(--danger) !important;
}

body:not(.test-taking-mode) #home-view .stat-card .stat-value {
    color: var(--primary) !important;
}

body:not(.test-taking-mode) #home-view .stat-card.stat-card-wide .stat-value {
    color: var(--danger) !important;
}

body:not(.test-taking-mode) #home-view .icon-box.green-glow,
body:not(.test-taking-mode) #home-view .icon-box.blue-glow {
    color: var(--primary);
}

body:not(.test-taking-mode) #home-view .icon-box.red-glow {
    color: var(--danger);
}

body:not(.test-taking-mode) #coverage-bar {
    background: var(--primary);
}

/* Result KPI rails: teal / blue / amber / purple → accent for the hero, then
   primary, warning and primary for the three gauges. Amber stays on TIME
   because slow is a warning; purple had no meaning and goes. */
#result-view .stat-card[style*="#2196f3"] {
    border-top-color: var(--primary) !important;
}

#result-view .stat-card[style*="#ffca28"] {
    border-top-color: var(--warning) !important;
}

#result-view .stat-card[style*="#9c27b0"] {
    border-top-color: var(--primary) !important;
}

#result-view .stat-card .stat-label[style*="#2196f3"],
#result-view .stat-card .stat-label[style*="#9c27b0"] {
    color: var(--primary) !important;
}

#result-view .stat-card .stat-label[style*="#ffca28"] {
    color: var(--warning) !important;
}

#lbl-res-score-status {
    background: var(--primary) !important;
}

/* Smart revision pills and metric boxes. */
body:not(.test-taking-mode) .metric-box.box-purple {
    border-color: color-mix(in srgb, var(--primary) 40%, transparent);
}

body:not(.test-taking-mode) .metric-box.box-purple .metric-val {
    color: var(--primary);
}

/* ── 4a. MOBILE TAB BAR ─────────────────────────────────────────────────── */

.tab-bar {
    display: none;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 900;
    height: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px));
    padding-bottom: env(safe-area-inset-bottom, 0px);
    background: color-mix(in srgb, var(--surface-solid) 96%, transparent);
    border-top: 1px solid var(--line);
    box-shadow: 0 -2px 16px rgba(0, 0, 0, 0.14);
}

.tab-bar-item {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    border: 0;
    background: none;
    padding: 0;
    color: var(--text-muted);
    cursor: pointer;
    font-family: inherit;
    -webkit-tap-highlight-color: transparent;
    transition: color .16s ease;
}

.tab-bar-item i {
    font-size: 1rem;
    width: 46px;
    height: 26px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    transition: background-color .18s ease;
}

.tab-bar-item span {
    font-size: 0.62rem;
    font-weight: 600;
    letter-spacing: 0.01em;
}

.tab-bar-item.active {
    color: var(--primary);
}

.tab-bar-item.active i {
    background: var(--primary-soft);
}

.tab-bar-item:active i {
    transform: scale(0.92);
}

@media (max-width: 900px) {

    /* Answering questions is a full-screen task — the bar would only get in
       the way, and the test UI has its own bottom controls. */
    body:not(.test-taking-mode):not(.practice-taking-mode) .tab-bar {
        display: flex;
    }

    body:not(.test-taking-mode):not(.practice-taking-mode) .scroll-content {
        padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px) + var(--sp-4));
    }

    /* The Custom Test action bar shares the same corner — stack it above. */
    body:not(.test-taking-mode) .ct-float-bar {
        bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px));
    }

    body[data-view="custom-test"]:not(.test-taking-mode) .scroll-content {
        padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px) + 76px);
    }
}

/* ── 4b. SKELETON LOADERS ───────────────────────────────────────────────── */

.skl {
    position: relative;
    overflow: hidden;
    background: color-mix(in srgb, var(--text-muted) 16%, transparent);
    border-radius: 8px;
    color: transparent !important;
}

.skl::after {
    content: '';
    position: absolute;
    inset: 0;
    transform: translateX(-100%);
    background: linear-gradient(90deg,
            transparent,
            color-mix(in srgb, var(--text-main) 12%, transparent),
            transparent);
    animation: skl-sweep 1.15s ease-in-out infinite;
}

@keyframes skl-sweep {
    100% {
        transform: translateX(100%);
    }
}

.skl-line {
    height: 12px;
    margin: 6px 0;
    display: block;
}

.skl-line.w-40 {
    width: 40%;
}

.skl-line.w-60 {
    width: 60%;
}

.skl-line.w-80 {
    width: 80%;
}

.skl-card {
    height: 78px;
    border-radius: 16px;
}

/* A skeletonised element must not look interactive while it is still empty. */
.skl,
.skl * {
    pointer-events: none;
}

/* ── 4c. PULL TO REFRESH ────────────────────────────────────────────────── */

.ptr-indicator {
    position: fixed;
    top: 64px;
    left: 50%;
    z-index: 890;
    width: 34px;
    height: 34px;
    margin-left: -17px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--surface-solid);
    border: 1px solid var(--line);
    box-shadow: var(--shadow-sm);
    color: var(--primary);
    font-size: 0.85rem;
    opacity: 0;
    transform: translateY(-16px);
    pointer-events: none;
}

.ptr-indicator.ptr-spinning i {
    animation: ptr-spin 0.7s linear infinite;
}

@keyframes ptr-spin {
    100% {
        transform: rotate(360deg);
    }
}
