/* ==========================================================================
   SYLLABUS TRACKER — dedicated page

   The old tracker was one inline-styled list: a big teal percentage and a row
   per chapter reading "0/2 Done". It only ever counted practice parts, so a
   student who tested a chapter instead of practising it saw 0%.

   This is the replacement. Same design-system tokens as the rest of the
   premium surfaces (test-history.css is its sibling), so both themes work with
   no second stylesheet. Prefix is syl- throughout.
   ========================================================================== */

#syllabus-view {
    padding: 0;
}

.syl-page {
    max-width: 1200px;
    margin: 0 auto;
    padding: 4px 0 48px;
    color: var(--text-main);
    animation: syl-rise 0.3s ease both;
}

@keyframes syl-rise {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: none;
    }
}

/* Nothing inside may set a floor on the page's width — .content-area is a flex
   item, so a wide table or grid would push the whole app shell out and give
   every screen a horizontal scrollbar. */
.syl-two-col > *,
.syl-card,
.syl-chart-wrap,
.syl-row,
.syl-row-main > * {
    min-width: 0;
}

.syl-table-scroll {
    overflow-x: auto;
    contain: inline-size;
}

/* ── Hero ───────────────────────────────────────────────────────────────── */

.syl-hero {
    position: relative;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background:
        radial-gradient(circle at 10% -40%, color-mix(in srgb, var(--brand) 26%, transparent), transparent 60%),
        radial-gradient(circle at 90% -20%, color-mix(in srgb, var(--brand-2) 22%, transparent), transparent 55%),
        var(--surface-solid);
    box-shadow: var(--shadow-sm);
    padding: 22px 24px;
    display: flex;
    flex-wrap: wrap;
    gap: 22px;
    align-items: center;
    margin-bottom: var(--sp-4);
}

.syl-hero-ring {
    position: relative;
    width: 132px;
    height: 132px;
    flex-shrink: 0;
}

.syl-hero-ring svg {
    width: 132px;
    height: 132px;
    transform: rotate(-90deg);
}

.syl-hero-ring circle {
    fill: none;
    stroke-width: 11;
    stroke-linecap: round;
}

.syl-ring-track {
    stroke: color-mix(in srgb, var(--text-muted) 18%, transparent);
}

.syl-ring-value {
    stroke: var(--brand);
    transition: stroke-dasharray 0.6s ease;
}

.syl-ring-label {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.syl-ring-label b {
    font-size: 1.6rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    line-height: 1;
}

.syl-ring-label span {
    margin-top: 4px;
    font-size: 0.62rem;
    font-weight: 800;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.syl-hero-body {
    flex: 1;
    min-width: 250px;
}

.syl-subject-chip {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 4px 12px 4px 8px;
    border-radius: 999px;
    background: var(--brand-soft);
    border: 1px solid color-mix(in srgb, var(--brand) 34%, transparent);
    color: var(--brand);
    font-size: 0.74rem;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.syl-hero-body h2 {
    margin: 10px 0 6px;
    font-size: 1.7rem;
    font-weight: 800;
    letter-spacing: -0.02em;
}

.syl-hero-sub {
    margin: 0 0 14px;
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 500;
}

.syl-hero-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

/* ── Buttons ────────────────────────────────────────────────────────────── */

.syl-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 9px 16px;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: var(--surface-raised);
    color: var(--text-main);
    font-family: inherit;
    font-size: 0.82rem;
    font-weight: 700;
    cursor: pointer;
    white-space: nowrap;
    transition: transform 0.15s ease, background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.syl-btn:hover {
    transform: translateY(-1px);
    border-color: color-mix(in srgb, var(--brand) 45%, transparent);
}

.syl-btn:active {
    transform: translateY(0) scale(0.98);
}

.syl-btn.primary {
    background: var(--brand);
    border-color: var(--brand);
    color: #0b1220;
}

html.theme-light .syl-btn.primary {
    color: #fff;
}

.syl-btn.accent {
    background: color-mix(in srgb, var(--brand-2) 16%, transparent);
    border-color: color-mix(in srgb, var(--brand-2) 45%, transparent);
    color: var(--brand-2);
}

.syl-btn.tiny {
    padding: 6px 12px;
    font-size: 0.76rem;
}

/* ── KPI strip ──────────────────────────────────────────────────────────── */

.syl-kpis {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(178px, 1fr));
    gap: var(--sp-3);
    margin-bottom: var(--sp-4);
}

.syl-kpi {
    position: relative;
    background: var(--surface-solid);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    padding: 15px 16px;
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    transition: transform 0.18s ease, border-color 0.18s ease;
}

.syl-kpi::before {
    content: '';
    position: absolute;
    inset: 0 auto 0 0;
    width: 3px;
    background: var(--kpi-tint, var(--brand));
}

.syl-kpi:hover {
    transform: translateY(-2px);
    border-color: color-mix(in srgb, var(--kpi-tint, var(--brand)) 40%, transparent);
}

.syl-kpi-label {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--text-muted);
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.syl-kpi-label i {
    color: var(--kpi-tint, var(--brand));
}

.syl-kpi-value {
    margin-top: 8px;
    font-size: 1.55rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    line-height: 1.1;
}

.syl-kpi-value small {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-muted);
}

.syl-kpi-foot {
    margin-top: 5px;
    font-size: 0.74rem;
    color: var(--text-muted);
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ── Insights ───────────────────────────────────────────────────────────── */

.syl-insights {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: var(--sp-3);
    margin-bottom: var(--sp-4);
}

.syl-insight {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    padding: 14px 16px;
    border-radius: var(--radius-sm);
    border: 1px solid color-mix(in srgb, var(--ins-tint, var(--brand)) 30%, transparent);
    background: color-mix(in srgb, var(--ins-tint, var(--brand)) 9%, var(--surface-solid));
}

.syl-insight > i {
    font-size: 1rem;
    color: var(--ins-tint, var(--brand));
    margin-top: 2px;
}

.syl-insight h5 {
    margin: 0 0 3px;
    font-size: 0.86rem;
    font-weight: 800;
}

.syl-insight p {
    margin: 0;
    font-size: 0.78rem;
    line-height: 1.45;
    color: var(--text-muted);
    font-weight: 500;
}

.syl-insight .syl-btn {
    margin-top: 9px;
}

/* ── Cards ──────────────────────────────────────────────────────────────── */

.syl-card {
    background: var(--surface-solid);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 18px 20px;
    margin-bottom: var(--sp-4);
}

.syl-card-head {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
}

.syl-card-head h4 {
    margin: 0;
    font-size: 1rem;
    font-weight: 800;
    display: flex;
    align-items: center;
    gap: 8px;
}

.syl-card-head h4 i {
    color: var(--brand);
}

.syl-card-head p {
    margin: 3px 0 0;
    font-size: 0.76rem;
    color: var(--text-muted);
    font-weight: 500;
}

.syl-two-col {
    display: grid;
    grid-template-columns: 1.5fr 1fr;
    gap: var(--sp-4);
    align-items: start;
}

/* ── Segmented control ──────────────────────────────────────────────────── */

.syl-seg {
    display: inline-flex;
    padding: 3px;
    gap: 2px;
    background: var(--surface-raised);
    border: 1px solid var(--line);
    border-radius: 999px;
}

.syl-seg button {
    border: 0;
    background: transparent;
    color: var(--text-muted);
    font-family: inherit;
    font-size: 0.74rem;
    font-weight: 700;
    padding: 6px 13px;
    border-radius: 999px;
    cursor: pointer;
    transition: background 0.18s ease, color 0.18s ease;
}

.syl-seg button.active {
    background: var(--brand);
    color: #0b1220;
}

html.theme-light .syl-seg button.active {
    color: #fff;
}

/* ── Progress chart ─────────────────────────────────────────────────────── */

.syl-chart {
    width: 100%;
    height: auto;
    display: block;
    overflow: visible;
}

.syl-chart .syl-grid-line {
    stroke: var(--line);
    stroke-width: 1;
}

.syl-chart .syl-axis-text {
    fill: var(--text-muted);
    font-size: 9px;
    font-weight: 600;
}

.syl-chart .syl-line {
    fill: none;
    stroke: var(--brand);
    stroke-width: 2.4;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.syl-chart .syl-forecast {
    fill: none;
    stroke: var(--brand-2);
    stroke-width: 1.8;
    stroke-dasharray: 6 5;
    opacity: 0.9;
}

.syl-chart .syl-dot {
    fill: var(--surface-solid);
    stroke: var(--brand);
    stroke-width: 2;
}

.syl-chart-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    margin-top: 10px;
    font-size: 0.74rem;
    color: var(--text-muted);
    font-weight: 600;
}

.syl-chart-legend span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.syl-swatch {
    width: 12px;
    height: 3px;
    border-radius: 2px;
    background: var(--brand);
}

.syl-swatch.dashed {
    background: repeating-linear-gradient(90deg, var(--brand-2) 0 4px, transparent 4px 7px);
}

.syl-chart-empty {
    padding: 26px 0;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.83rem;
    font-weight: 600;
    line-height: 1.6;
}

/* ── Donut ──────────────────────────────────────────────────────────────── */

.syl-donut-row {
    display: flex;
    align-items: center;
    gap: 18px;
    flex-wrap: wrap;
}

.syl-donut-center {
    position: relative;
    width: 132px;
    height: 132px;
    flex-shrink: 0;
}

.syl-donut {
    width: 132px;
    height: 132px;
    transform: rotate(-90deg);
}

.syl-donut circle {
    fill: none;
    stroke-width: 13;
}

.syl-donut-hole {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.syl-donut-hole b {
    font-size: 1.35rem;
    font-weight: 800;
    line-height: 1;
}

.syl-donut-hole span {
    font-size: 0.62rem;
    color: var(--text-muted);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-top: 3px;
}

.syl-legend {
    display: flex;
    flex-direction: column;
    gap: 9px;
    flex: 1;
    min-width: 150px;
}

.syl-legend-row {
    display: flex;
    align-items: center;
    gap: 9px;
    font-size: 0.8rem;
    font-weight: 600;
}

.syl-legend-row i.key {
    width: 10px;
    height: 10px;
    border-radius: 3px;
    flex-shrink: 0;
}

.syl-legend-row b {
    margin-left: auto;
    font-weight: 800;
}

/* ── Section bars ───────────────────────────────────────────────────────── */

.syl-bars {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.syl-bar-row {
    display: grid;
    grid-template-columns: minmax(120px, 1.4fr) 1fr auto;
    gap: 12px;
    align-items: center;
    font-size: 0.82rem;
}

.syl-bar-name {
    font-weight: 700;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 7px;
}

.syl-bar-track {
    position: relative;
    height: 9px;
    border-radius: 999px;
    background: color-mix(in srgb, var(--text-muted) 16%, transparent);
    overflow: hidden;
}

.syl-bar-fill {
    position: absolute;
    inset: 0 auto 0 0;
    border-radius: 999px;
    background: var(--bar-tint, var(--brand));
    transition: width 0.5s ease;
}

/* The slice of the bar that tests contributed, drawn over the practice fill so
   a student can see which half of the coverage came from where. */
.syl-bar-fill.test {
    background: repeating-linear-gradient(135deg,
            color-mix(in srgb, var(--brand-2) 90%, transparent) 0 5px,
            color-mix(in srgb, var(--brand-2) 55%, transparent) 5px 10px);
}

.syl-bar-val {
    font-weight: 800;
    font-size: 0.8rem;
    min-width: 70px;
    text-align: right;
    color: var(--text-muted);
}

.syl-bar-val b {
    color: var(--text-main);
}

/* ── Toolbar ────────────────────────────────────────────────────────────── */

.syl-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    margin-bottom: 14px;
}

.syl-search {
    position: relative;
    flex: 1;
    min-width: 190px;
}

.syl-search i {
    position: absolute;
    left: 13px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 0.8rem;
    pointer-events: none;
}

.syl-search input {
    width: 100%;
    padding: 10px 14px 10px 34px;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: var(--surface-raised);
    color: var(--text-main);
    font-family: inherit;
    font-size: 0.83rem;
    font-weight: 500;
    outline: none;
    box-sizing: border-box;
    transition: border-color 0.18s ease;
}

.syl-search input:focus {
    border-color: color-mix(in srgb, var(--brand) 55%, transparent);
}

.syl-select {
    padding: 9px 12px;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: var(--surface-raised);
    color: var(--text-main);
    font-family: inherit;
    font-size: 0.79rem;
    font-weight: 700;
    cursor: pointer;
    outline: none;
}

/* ── Section group ──────────────────────────────────────────────────────── */

.syl-group {
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--surface-raised);
    margin-bottom: 12px;
    overflow: hidden;
}

.syl-group-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    cursor: pointer;
    transition: background 0.15s ease;
}

.syl-group-head:hover {
    background: color-mix(in srgb, var(--brand) 6%, transparent);
}

.syl-group-title {
    flex: 1;
    min-width: 160px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.98rem;
    font-weight: 800;
}

.syl-group-title small {
    font-weight: 600;
    color: var(--text-muted);
    font-size: 0.74rem;
}

.syl-group-meter {
    flex: 1;
    min-width: 120px;
    max-width: 260px;
}

.syl-group-pct {
    font-weight: 800;
    font-size: 0.95rem;
    min-width: 56px;
    text-align: right;
}

.syl-group-chevron {
    color: var(--text-muted);
    font-size: 0.8rem;
    transition: transform 0.22s ease;
}

.syl-group.open .syl-group-chevron {
    transform: rotate(180deg);
}

.syl-group-body {
    display: none;
    border-top: 1px dashed var(--line);
}

.syl-group.open .syl-group-body {
    display: block;
    animation: syl-rise 0.2s ease both;
}

/* ── Chapter row ────────────────────────────────────────────────────────── */

.syl-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 14px;
    padding: 13px 16px;
    border-bottom: 1px solid color-mix(in srgb, var(--line) 55%, transparent);
    transition: background 0.15s ease;
}

.syl-row:last-child {
    border-bottom: 0;
}

.syl-row:hover {
    background: color-mix(in srgb, var(--brand) 5%, transparent);
}

.syl-row-id {
    flex: 1;
    min-width: 190px;
}

.syl-row-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    font-weight: 700;
    margin-bottom: 5px;
}

.syl-row-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    color: var(--text-muted);
    font-size: 0.73rem;
    font-weight: 600;
}

.syl-row-meta span {
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.syl-row-meter {
    width: 150px;
}

.syl-row-actions {
    display: flex;
    gap: 7px;
    align-items: center;
    margin-left: auto;
}

/* ── Pills ──────────────────────────────────────────────────────────────── */

.syl-pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 0.69rem;
    font-weight: 800;
    white-space: nowrap;
    border: 1px solid transparent;
}

.syl-pill.done {
    color: var(--success);
    background: color-mix(in srgb, var(--success) 14%, transparent);
    border-color: color-mix(in srgb, var(--success) 34%, transparent);
}

.syl-pill.progress {
    color: var(--warning);
    background: color-mix(in srgb, var(--warning) 14%, transparent);
    border-color: color-mix(in srgb, var(--warning) 34%, transparent);
}

.syl-pill.new {
    color: var(--text-muted);
    background: color-mix(in srgb, var(--text-muted) 12%, transparent);
    border-color: var(--line);
}

.syl-pill.weak {
    color: var(--danger);
    background: color-mix(in srgb, var(--danger) 14%, transparent);
    border-color: color-mix(in srgb, var(--danger) 34%, transparent);
}

/* ── Empty state ────────────────────────────────────────────────────────── */

.syl-empty {
    text-align: center;
    padding: 50px 20px;
}

.syl-empty-icon {
    width: 76px;
    height: 76px;
    margin: 0 auto 16px;
    border-radius: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.9rem;
    color: var(--brand);
    background: var(--brand-soft);
    border: 1px solid color-mix(in srgb, var(--brand) 30%, transparent);
}

.syl-empty h4 {
    margin: 0 0 7px;
    font-size: 1.1rem;
    font-weight: 800;
}

.syl-empty p {
    margin: 0 auto 18px;
    max-width: 420px;
    color: var(--text-muted);
    font-size: 0.86rem;
    line-height: 1.55;
    font-weight: 500;
}

/* ── Toast ──────────────────────────────────────────────────────────────── */

.syl-toast {
    position: fixed;
    left: 50%;
    bottom: 34px;
    transform: translateX(-50%) translateY(14px);
    z-index: 100000;
    padding: 11px 20px;
    border-radius: 999px;
    background: var(--surface-solid);
    border: 1px solid var(--line);
    box-shadow: var(--shadow-md);
    color: var(--text-main);
    font-size: 0.83rem;
    font-weight: 700;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.syl-toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* The mobile tab bar owns the bottom of the screen — sit above it. */
@media (max-width: 900px) {

    body:not(.test-taking-mode):not(.practice-taking-mode) .syl-toast {
        bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px) + 14px);
    }
}

/* ── Responsive ─────────────────────────────────────────────────────────── */

@media (max-width: 980px) {
    .syl-two-col {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 720px) {
    .syl-hero {
        padding: 18px;
        gap: 16px;
    }

    .syl-hero-ring,
    .syl-hero-ring svg {
        width: 104px;
        height: 104px;
    }

    .syl-hero-body h2 {
        font-size: 1.35rem;
    }

    .syl-hero-actions {
        width: 100%;
    }

    .syl-hero-actions .syl-btn {
        flex: 1;
    }

    .syl-kpis {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    .syl-kpi-value {
        font-size: 1.3rem;
    }

    .syl-card {
        padding: 15px;
        border-radius: 14px;
    }

    .syl-bar-row {
        grid-template-columns: 1fr auto;
    }

    .syl-bar-row .syl-bar-track {
        grid-column: 1 / -1;
        order: 3;
    }

    .syl-row {
        padding: 12px 14px;
    }

    .syl-row-meter {
        width: 100%;
    }

    .syl-toolbar .syl-select {
        flex: 1;
    }
}
