/* The Rational Quant — Phase 1 dashboard styling.
   Single stylesheet, no framework. Clemson orange (#F66733) as the accent.
   Designed to feel academic-clean rather than corporate-flashy. */

:root {
    --clemson-orange:   #F66733;
    --clemson-purple:   #522D80;
    --bg:               #fafafa;
    --bg-elev:          #ffffff;
    --bg-sub:           #f3f4f6;
    --border:           #e5e7eb;
    --border-strong:    #cbd5e1;
    --ink:              #111827;
    --ink-soft:         #374151;
    --ink-muted:        #6b7280;

    --status-live:      #2e8b3a;
    --status-rendered:  #5a8dee;
    --status-scripted:  #c08600;
    --status-drafted:   #94a3b8;

    --radius:           10px;
    --shadow-soft:      0 1px 2px rgba(15, 23, 42, 0.04), 0 1px 3px rgba(15, 23, 42, 0.06);
    --shadow-pop:       0 4px 12px rgba(15, 23, 42, 0.08);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 15px;
    line-height: 1.5;
}

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

.site-header {
    background: linear-gradient(135deg, #fff 0%, #fef9f5 100%);
    border-bottom: 1px solid var(--border);
    padding: 28px 32px;
}

.brand {
    max-width: 1100px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 18px;
}

.brand-mark {
    width: 56px;
    height: 56px;
    border-radius: 12px;
    background: var(--clemson-orange);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 18px;
    letter-spacing: 0.5px;
    box-shadow: var(--shadow-soft);
}

.brand-text h1 {
    margin: 0;
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.brand-text .subtitle {
    margin: 2px 0 0;
    font-size: 13px;
    color: var(--ink-muted);
}

/* ---------- Container ---------- */

.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 28px 32px 64px;
}

/* ---------- Course stats ---------- */

.course-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 12px;
    margin-bottom: 24px;
}

.stat {
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 16px;
    box-shadow: var(--shadow-soft);
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.stat-value {
    font-size: 28px;
    font-weight: 700;
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    color: var(--ink);
    line-height: 1.1;
}

.stat-label {
    font-size: 12px;
    color: var(--ink-muted);
    letter-spacing: 0.02em;
}

.stat-live    .stat-value { color: var(--status-live); }
.stat-rendered .stat-value { color: var(--status-rendered); }
.stat-scripted .stat-value { color: var(--status-scripted); }
.stat-drafted .stat-value { color: var(--ink-muted); }

/* ---------- Legend ---------- */

.legend {
    display: flex;
    flex-wrap: wrap;
    gap: 18px;
    padding: 10px 16px;
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 16px;
    font-size: 13px;
    color: var(--ink-soft);
}

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

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.status-dot.status-live    { background: var(--status-live); }
.status-dot.status-rendered { background: var(--status-rendered); }
.status-dot.status-scripted { background: var(--status-scripted); }
.status-dot.status-drafted { background: var(--status-drafted); border: 1px solid #94a3b8; }

/* ---------- Tree controls ---------- */

.tree-controls {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

.ghost-btn {
    background: var(--bg-elev);
    border: 1px solid var(--border);
    color: var(--ink-soft);
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.12s ease, border-color 0.12s ease;
}

.ghost-btn:hover {
    background: var(--bg-sub);
    border-color: var(--border-strong);
}

/* ---------- Tree ---------- */

.tree { display: flex; flex-direction: column; gap: 8px; }

details { border-radius: var(--radius); }

details > summary {
    list-style: none;
    cursor: pointer;
    user-select: none;
    display: flex;
    align-items: center;
    gap: 8px;
}

details > summary::-webkit-details-marker { display: none; }
details > summary::marker { content: ''; }

.caret {
    display: inline-block;
    width: 0;
    height: 0;
    border-left: 5px solid var(--ink-muted);
    border-top: 4px solid transparent;
    border-bottom: 4px solid transparent;
    transition: transform 0.12s ease;
    flex-shrink: 0;
}

details[open] > summary > .caret {
    transform: rotate(90deg);
}

/* --- Module level --- */

.module {
    background: var(--bg-elev);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-soft);
}

.module > summary {
    padding: 14px 18px;
    border-radius: var(--radius);
    transition: background 0.12s ease;
}

.module > summary:hover { background: var(--bg-sub); }

.module-num {
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-size: 13px;
    color: var(--clemson-orange);
    font-weight: 600;
    letter-spacing: 0.02em;
}

.module-name {
    font-size: 17px;
    font-weight: 600;
    color: var(--ink);
}

.module-body {
    padding: 0 14px 12px 32px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

/* --- Sub-unit level --- */

.sub-unit {
    border: 1px solid transparent;
    border-radius: 6px;
}

.sub-unit > summary {
    padding: 8px 12px;
    border-radius: 6px;
    transition: background 0.12s ease;
}

.sub-unit > summary:hover { background: var(--bg-sub); }

.sub-name {
    font-size: 14px;
    color: var(--ink-soft);
    font-weight: 500;
    flex: 1;
}

.pdf-badge {
    background: var(--clemson-orange);
    color: white;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.04em;
    padding: 2px 7px;
    border-radius: 4px;
    text-decoration: none;
    transition: background 0.12s ease;
}

.pdf-badge:hover {
    background: #d8521f;
}

/* --- Video list --- */

.videos {
    list-style: none;
    padding: 4px 0 8px 28px;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.video {
    display: flex;
    flex-direction: column;
    border-radius: 4px;
    font-size: 13.5px;
}

.video-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 8px;
    border-radius: 4px;
    transition: background 0.08s ease;
}

.video:hover > .video-row { background: var(--bg-sub); }

.vnum {
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-size: 11.5px;
    color: var(--ink-muted);
    background: var(--bg-sub);
    padding: 1px 6px;
    border-radius: 3px;
    flex-shrink: 0;
}

.video-link {
    color: var(--ink);
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: border-color 0.12s ease;
    flex: 1;
    cursor: pointer;
}

.video-link:not(.disabled):hover {
    border-bottom-color: var(--clemson-orange);
    color: var(--clemson-orange);
}

.video-link.disabled {
    color: var(--ink-muted);
    cursor: default;
}

.open-in-yt {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 4px;
    color: var(--ink-muted);
    text-decoration: none;
    font-size: 14px;
    line-height: 1;
    transition: color 0.12s ease, background 0.12s ease;
    flex-shrink: 0;
}

.open-in-yt:hover {
    color: var(--clemson-orange);
    background: var(--bg-sub);
}

/* ---------- Inline YouTube player ---------- */

.player-slot {
    margin: 8px 0 14px 32px;
    max-width: 880px;
}

.player-wrap {
    position: relative;
    padding-bottom: 56.25%;  /* 16:9 */
    height: 0;
    overflow: hidden;
    background: #000;
    border-radius: 8px;
    box-shadow: var(--shadow-pop);
}

.player-wrap iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: 0;
}

.player-close {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 30px;
    height: 30px;
    border: none;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: background 0.12s ease, transform 0.12s ease;
}

.player-close:hover {
    background: rgba(0, 0, 0, 0.92);
    transform: scale(1.06);
}

@media (max-width: 640px) {
    .player-slot {
        margin-left: 8px;
        margin-right: 8px;
    }
}

.player-loading {
    padding: 0;
    color: #fff;
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 60px;
    font-size: 13px;
}

/* ---------- Per-video recommendation colors ---------- */

/* Left-edge accent for each video row, keyed by the student's tier
   (computed on Harrison's laptop from Canvas correctness; uploaded
   precomputed). Grey = no exam taken yet (no border). */

:root {
    --rec-green:  #16a34a;   /* Mastered */
    --rec-yellow: #ca8a04;   /* Review (the middle color) */
    --rec-red:    #dc2626;   /* Study Me */
    --rec-grey:   transparent;
}

.video.rec > .video-row {
    border-left: 4px solid var(--rec-grey);
    padding-left: 12px;
}

.video.rec-green  > .video-row { border-left-color: var(--rec-green); }
.video.rec-yellow > .video-row { border-left-color: var(--rec-yellow); }
.video.rec-red    > .video-row { border-left-color: var(--rec-red); }
.video.rec-grey   > .video-row { border-left-color: var(--rec-grey); }

/* The recommendation badge: a colored pill with the label INSIDE
   (Mastered / Review / Study Me). Shown on each video row and rolled up onto
   the Module / Sub-unit summaries (= the worst recommendation inside). The
   color IS the recommendation — no percentages anywhere. */
.rec-badge {
    display: inline-block;
    padding: 2px 9px;
    border-radius: 11px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.02em;
    line-height: 1.5;
    white-space: nowrap;
    flex-shrink: 0;
    color: #fff;
}

.rec-badge.rec-green  { background: var(--rec-green); }
.rec-badge.rec-yellow { background: var(--rec-yellow); color: #3a2c00; }  /* dark text — contrast on yellow */
.rec-badge.rec-red    { background: var(--rec-red); }

.rec-concepts {
    margin: 4px 0 8px 32px;
    padding: 6px 10px;
    background: #fffbeb;
    border-left: 2px solid var(--rec-yellow);
    border-radius: 0 6px 6px 0;
    font-size: 12.5px;
    color: var(--ink-soft);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    max-width: 880px;
}

.rec-concepts-label {
    font-weight: 600;
    color: var(--ink);
    text-transform: uppercase;
    font-size: 10.5px;
    letter-spacing: 0.04em;
    margin-right: 4px;
}

.concept-pill {
    display: inline-block;
    padding: 1px 8px;
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: 12px;
    font-size: 12px;
    color: var(--ink-soft);
}

/* ---------- Practice questions ---------- */

.practice-controls {
    display: inline-flex;
    gap: 6px;
    margin-left: auto;
    flex-shrink: 0;
}

.practice-btn {
    background: var(--bg-elev);
    border: 1px solid var(--border);
    color: var(--ink-soft);
    padding: 3px 10px;
    border-radius: 6px;
    font-family: inherit;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
    white-space: nowrap;
}

.practice-btn:hover {
    background: #fff5ef;
    border-color: var(--clemson-orange);
    color: var(--clemson-orange);
}

.practice-slot {
    margin: 8px 0 14px 32px;
    max-width: 720px;
}

.practice-card {
    position: relative;
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-left: 3px solid var(--clemson-orange);
    border-radius: var(--radius);
    padding: 16px 20px 16px 18px;
    box-shadow: var(--shadow-soft);
}

.practice-card-error {
    border-left-color: var(--status-drafted);
}

.practice-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.practice-card-tag {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--clemson-orange);
    font-weight: 600;
}

.practice-close {
    border: none;
    background: transparent;
    color: var(--ink-muted);
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    padding: 0 4px;
    border-radius: 4px;
}

.practice-close:hover {
    background: var(--bg-sub);
    color: var(--ink);
}

.practice-prompt {
    font-size: 14.5px;
    color: var(--ink);
    margin-bottom: 12px;
    line-height: 1.5;
}

.practice-options {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 12px;
}

.practice-option {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 6px 8px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.12s ease;
}

.practice-option:hover {
    background: var(--bg-sub);
}

.practice-option input[type=radio] {
    margin-top: 3px;
    flex-shrink: 0;
}

.practice-option .opt-letter {
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-size: 12.5px;
    color: var(--ink-muted);
    flex-shrink: 0;
}

.practice-actions {
    display: flex;
    gap: 8px;
}

.practice-feedback {
    margin-top: 12px;
    padding: 10px 12px;
    border-radius: 6px;
    font-size: 14px;
    line-height: 1.5;
    background: var(--bg-sub);
    color: var(--ink-soft);
}

.practice-feedback.correct {
    background: #ecfdf3;
    color: #166534;
    border: 1px solid #bbf7d0;
}

.practice-feedback.incorrect {
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.practice-feedback .feedback-headline {
    font-weight: 600;
    margin-bottom: 4px;
}

.practice-feedback .feedback-actual {
    margin-top: 6px;
    font-size: 13px;
    color: var(--ink-soft);
}

@media (max-width: 640px) {
    .practice-controls {
        margin-left: 0;
        margin-top: 4px;
        flex-basis: 100%;
    }

    .practice-slot {
        margin-left: 8px;
        margin-right: 8px;
    }
}

/* ---------- Footer ---------- */

.site-footer {
    border-top: 1px solid var(--border);
    background: var(--bg-elev);
    padding: 20px 32px;
    text-align: center;
    color: var(--ink-muted);
    font-size: 12.5px;
}

.site-footer p { margin: 0; }

/* ---------- Mobile ---------- */

@media (max-width: 640px) {
    .site-header { padding: 20px 16px; }
    .brand-text h1 { font-size: 19px; }
    .container { padding: 20px 16px 48px; }
    .module > summary { padding: 12px 14px; }
    .module-body { padding: 0 8px 10px 22px; }
    .videos { padding-left: 18px; }
    .module-name { font-size: 16px; }
    .user-strip { margin-left: 0; margin-top: 8px; align-self: flex-start; }
}

/* ---------- User strip (top-right of header) ---------- */

.user-strip {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 14px;
    font-size: 13px;
    color: var(--ink-soft);
}

.user-email {
    background: var(--bg-sub);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 4px 12px;
    font-weight: 500;
    color: var(--ink-soft);
    white-space: nowrap;
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-logout {
    color: var(--ink-muted);
    text-decoration: none;
    font-weight: 500;
}
.user-logout:hover { color: var(--clemson-orange); text-decoration: underline; }

/* ---------- Primary nav (Library / My Calendar) ---------- */

.site-nav {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 8px;
}

.site-nav a {
    font-size: 13px;
    font-weight: 600;
    color: var(--ink-soft);
    text-decoration: none;
    padding: 7px 14px;
    border-radius: 8px;
    border: 1px solid var(--border-strong);
    background: var(--bg-elev);
    box-shadow: var(--shadow-soft);
    transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}

.site-nav a:hover {
    background: #fff5ef;
    border-color: var(--clemson-orange);
    color: var(--clemson-orange);
}

.site-nav a.active {
    background: var(--clemson-orange);
    border-color: var(--clemson-orange);
    color: #fff;
}

/* When the nav is present it takes the auto-margin; the user strip then sits
   just to its right rather than also pushing all the way left. */
.site-header .brand .site-nav ~ .user-strip { margin-left: 12px; }

@media (max-width: 640px) {
    .site-nav { margin-left: 0; margin-top: 8px; flex-basis: 100%; order: 3; }
    .site-header .brand { flex-wrap: wrap; }
}

/* ---------- Auth pages (login / sent / invalid token) ---------- */

.auth-card {
    max-width: 460px;
    margin: 48px auto;
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-soft);
    padding: 36px 32px;
}

.auth-title {
    margin: 0 0 12px;
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--ink);
}

.auth-lede {
    margin: 0 0 24px;
    color: var(--ink-soft);
    font-size: 14.5px;
    line-height: 1.55;
}

.auth-error {
    margin: 0 0 18px;
    padding: 10px 14px;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 8px;
    color: #991b1b;
    font-size: 13.5px;
}

.auth-form { display: flex; flex-direction: column; gap: 10px; }

.auth-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--ink-soft);
    margin-bottom: -4px;
}

.auth-input {
    font: inherit;
    padding: 10px 14px;
    border: 1px solid var(--border-strong);
    border-radius: 8px;
    background: #fff;
    color: var(--ink);
    transition: border-color 0.12s, box-shadow 0.12s;
}
.auth-input:focus {
    outline: none;
    border-color: var(--clemson-orange);
    box-shadow: 0 0 0 3px rgba(246, 103, 51, 0.18);
}

.auth-submit {
    margin-top: 4px;
    padding: 11px 14px;
    background: var(--clemson-orange);
    color: white;
    border: none;
    border-radius: 8px;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.12s, transform 0.02s;
}
.auth-submit:hover { background: #e25a2a; }
.auth-submit:active { transform: translateY(1px); }

.auth-fineprint {
    margin: 22px 0 0;
    font-size: 12.5px;
    color: var(--ink-muted);
    line-height: 1.55;
}
.auth-fineprint code {
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-size: 11.5px;
    background: var(--bg-sub);
    padding: 1px 6px;
    border-radius: 4px;
    color: var(--ink-soft);
}
.auth-fineprint a { color: var(--clemson-orange); }
