/* ============================================================================
   Exam terms + the timetable (#172).

   A SCHEDULER, not a mark book: date · class/section · subject · time window.
   Nobody reads an exam schedule row by row, so this is styled as a WALL CHART —
   two lenses over the same slots (a cohort's own sheet, and the whole school).

   Tokens only (--yb-*); light + dark via the existing [data-theme="dark"] overrides.
   ============================================================================ */

/* ── Controls: branch, then term ──────────────────────────────────────────── */
/* Two selectors on one row, which is the same two-per-row rhythm every search panel
   in the app uses (.row > .col-md-6). The third column used to hold two primary
   import buttons; they now sit in the ERP note below, where the identical sentence
   already lives and where Students and Subjects keep theirs. */
.yb-exam-controls {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
    align-items: end;
    margin-top: 0.75rem;
}

@media (max-width: 900px) {
    .yb-exam-controls { grid-template-columns: 1fr; }
}

/* ── The term header + lens toggle ────────────────────────────────────────── */
.yb-exam-term {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.yb-exam-term__name {
    margin: 0;
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--yb-text);
}

.yb-exam-term__meta {
    display: block;
    margin-top: 0.2rem;
    font-size: 0.82rem;
    color: var(--yb-text-muted);
}

.yb-exam-term__meta code {
    padding: 0.05rem 0.3rem;
    font-size: 0.76rem;
    color: var(--yb-text);
    background: var(--yb-surface-2);
    border: 1px solid var(--yb-border);
    border-radius: var(--yb-radius-sm);
}

.yb-exam-lens { flex: none; }

.yb-exam-cohortpick {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

/* ── Lens 1: one cohort's sheet ───────────────────────────────────────────── */
/* Five columns is more than a phone holds, so the sheet scrolls inside itself exactly
   as the whole-school matrix does. The frame lives on the wrapper — a border on a table
   that overflows its own box draws a line through the middle of the scroll. */
.yb-exam-sheet__scroll {
    overflow-x: auto;
    border: 1px solid var(--yb-border);
    border-radius: var(--yb-radius-sm);
    background: var(--yb-surface);
}

.yb-exam-sheet {
    width: 100%;
    min-width: 560px;
    border-collapse: collapse;
    background: var(--yb-surface);
}

.yb-exam-sheet th,
.yb-exam-sheet td {
    padding: 0.6rem 0.8rem;
    text-align: left;
    border-bottom: 1px solid var(--yb-border);
    font-size: 0.87rem;
    vertical-align: middle;
}

.yb-exam-sheet thead th {
    font-size: 0.74rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--yb-text-muted);
    background: var(--yb-surface-2);
    white-space: nowrap;
}

.yb-exam-sheet tbody th {
    font-weight: 600;
    color: var(--yb-text);
    white-space: nowrap;
    background: var(--yb-surface-2);
}

.yb-exam-sheet tbody tr:last-child th,
.yb-exam-sheet tbody tr:last-child td { border-bottom: 0; }

.yb-exam-sheet__subject { font-weight: 600; color: var(--yb-text); }

.yb-exam-sheet__time {
    font-family: var(--yb-font-mono, ui-monospace, SFMono-Regular, Menlo, monospace);
    white-space: nowrap;
    color: var(--yb-text);
}

/* A free day is shown, never skipped — a gap in an exam week is information.
   It is quiet, so the days that DO carry a paper are what the eye lands on. */
.yb-exam-sheet__free th,
.yb-exam-sheet__free td {
    color: var(--yb-text-muted);
    background: transparent;
}

.yb-exam-sheet__none {
    font-size: 0.8rem;
    font-style: italic;
    color: var(--yb-text-muted);
    opacity: 0.75;
}

/* A second paper the same day shares the date cell above it. */
.yb-exam-sheet__also td { border-top: 1px dashed var(--yb-border); }

/* ── Lens 2: the whole school ─────────────────────────────────────────────── */
/* Wide by nature. It scrolls inside itself — the page body must never scroll sideways. */
.yb-exam-matrix__scroll {
    overflow-x: auto;
    border: 1px solid var(--yb-border);
    border-radius: var(--yb-radius-sm);
    background: var(--yb-surface);
}

.yb-exam-matrix {
    width: 100%;
    border-collapse: collapse;
    min-width: 640px;
}

.yb-exam-matrix th,
.yb-exam-matrix td {
    padding: 0.5rem 0.7rem;
    text-align: left;
    border-bottom: 1px solid var(--yb-border);
    border-right: 1px solid var(--yb-border);
    font-size: 0.83rem;
    vertical-align: top;
}

.yb-exam-matrix th:last-child,
.yb-exam-matrix td:last-child { border-right: 0; }

.yb-exam-matrix thead th {
    font-size: 0.74rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--yb-text-muted);
    background: var(--yb-surface-2);
    white-space: nowrap;
}

/* The date column is the reader's anchor across a wide scroll — pin it. */
.yb-exam-matrix__daycol {
    position: sticky;
    left: 0;
    z-index: 1;
    white-space: nowrap;
    font-weight: 600;
    color: var(--yb-text);
    background: var(--yb-surface-2);
}

.yb-exam-matrix__subject {
    display: block;
    font-weight: 600;
    color: var(--yb-text);
}

.yb-exam-matrix__time {
    display: block;
    font-size: 0.74rem;
    font-family: var(--yb-font-mono, ui-monospace, SFMono-Regular, Menlo, monospace);
    color: var(--yb-text-muted);
}

.yb-exam-matrix__free { background: transparent; }
.yb-exam-matrix__dash { color: var(--yb-text-muted); opacity: 0.5; }

/* A day nobody sits anything recedes — the exam days are the signal. */
.yb-exam-matrix__freeday .yb-exam-matrix__daycol { color: var(--yb-text-muted); font-weight: 500; }

/* ── "Exams in progress now" ──────────────────────────────────────────────── */
/* The operator's question: unusual sensor activity in a room — is it mid-exam? */
.yb-exam-live {
    margin-bottom: 1.25rem;
    padding: 0.85rem 1rem;
    border: 1px solid var(--yb-border);
    border-left: 3px solid var(--yb-border-strong);
    border-radius: var(--yb-radius-sm);
    background: var(--yb-surface-2);
}

.yb-exam-live.is-active {
    border-color: rgba(var(--yb-info-rgb), 0.3);
    border-left-color: var(--yb-info);
    background: rgba(var(--yb-info-rgb), 0.07);
}

.yb-exam-live__head {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.yb-exam-live__dot {
    flex: none;
    width: 0.55rem;
    height: 0.55rem;
    border-radius: 50%;
    background: var(--yb-text-muted);
    opacity: 0.4;
}

/* Live and running. The pulse is the one thing on the page that says "right now". */
.yb-exam-live.is-active .yb-exam-live__dot {
    background: var(--yb-info);
    opacity: 1;
    animation: yb-exam-pulse 2s ease-in-out infinite;
}

@keyframes yb-exam-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(var(--yb-info-rgb), 0.5); }
    50%      { box-shadow: 0 0 0 5px rgba(var(--yb-info-rgb), 0); }
}

@media (prefers-reduced-motion: reduce) {
    .yb-exam-live.is-active .yb-exam-live__dot { animation: none; }
}

.yb-exam-live__title {
    margin: 0;
    font-size: 0.92rem;
    font-weight: 700;
    color: var(--yb-text);
}

.yb-exam-live__when {
    font-size: 0.76rem;
    color: var(--yb-text-muted);
}

.yb-exam-live__refresh {
    margin-left: auto;
    padding: 0.2rem 0.45rem;
    color: var(--yb-text-muted);
    background: transparent;
    border: 1px solid var(--yb-border);
    border-radius: var(--yb-radius-sm);
    cursor: pointer;
}

.yb-exam-live__refresh:hover:not(:disabled) { color: var(--yb-text); border-color: var(--yb-border-strong); }
.yb-exam-live__refresh:disabled { opacity: 0.5; cursor: default; }

.yb-exam-live__error {
    margin: 0.5rem 0 0;
    font-size: 0.82rem;
    color: var(--yb-danger);
}

.yb-exam-live__list {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    margin: 0.75rem 0 0;
    padding: 0;
    list-style: none;
}

.yb-exam-live__item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-wrap: wrap;
    padding: 0.45rem 0.6rem;
    border: 1px solid rgba(var(--yb-info-rgb), 0.24);
    border-radius: var(--yb-radius-sm);
    background: var(--yb-surface);
}

.yb-exam-cohort {
    padding: 0.14rem 0.45rem;
    font-size: 0.74rem;
    font-weight: 700;
    color: var(--yb-brand-600);
    background: rgba(var(--yb-info-rgb), 0.1);
    border: 1px solid rgba(var(--yb-info-rgb), 0.28);
    border-radius: var(--yb-radius-sm);
    white-space: nowrap;
}

[data-theme="dark"] .yb-exam-cohort { color: var(--yb-brand-400); }

.yb-exam-live__subject { font-weight: 600; font-size: 0.86rem; color: var(--yb-text); }

.yb-exam-live__window {
    font-size: 0.8rem;
    font-family: var(--yb-font-mono, ui-monospace, SFMono-Regular, Menlo, monospace);
    color: var(--yb-text-muted);
}

.yb-exam-live__room {
    margin-left: auto;
    font-size: 0.78rem;
    color: var(--yb-text-muted);
    white-space: nowrap;
}

/* ── Shared states ────────────────────────────────────────────────────────── */
/* .yb-exam-loading removed — ExamTimetable uses YbSkeletonTable (#233). */
/* .yb-exam-empty removed — its four "nothing to show" answers are YbStateBlock now, so
   the page's empty and error states carry the app's state spine instead of a bespoke
   centred dashed box. This was one of the eleven treatments .yb-state replaced. */

/* ── The exam chip on analytics (#172) ────────────────────────────────────── */
/* Two strengths, and they are DIFFERENT claims: "during the paper" versus "on a day
   they sat one". A stress spike means something quite different in each. */
.detail-exam-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.12rem 0.4rem;
    font-size: 0.7rem;
    font-weight: 700;
    line-height: 1.2;
    white-space: nowrap;
    color: var(--yb-text-muted);
    background: var(--yb-surface-2);
    border: 1px solid var(--yb-border);
    border-radius: var(--yb-radius-sm);
}

/* Mid-exam. The strong claim, and the one worth reading a spike against. */
.detail-exam-chip.is-during {
    color: var(--yb-brand-600);
    background: rgba(var(--yb-info-rgb), 0.1);
    border-color: rgba(var(--yb-info-rgb), 0.32);
}

[data-theme="dark"] .detail-exam-chip.is-during { color: var(--yb-brand-400); }
