/*
 * CI245 lecture processing - site styles.
 *
 * CoveyCS brand palette (Shared Guidelines color_scheme.json / NetworkTopology AGENTS.md
 * rule 4). This is CoveyCS's own course infrastructure, so it takes the CoveyCS palette
 * rather than the Mad Angel Films one.
 */

:root {
  /* Surfaces. Covey Navy #161340 is the brand dark; the deeper shade is a derived
     background so elevated cards read against it without inventing a second hue. */
  --ci-bg: #100d33;
  --ci-bg-elevated: #161340;
  --ci-bg-sunken: #0a081f;
  --ci-border: #2c2969;

  /* Text
     The palette's Slate Blue Gray (#6E738F) is role "Text/Background - Dark 2": a dark ink,
     meant for light backgrounds. Used as body text on this navy it measures 3.76:1, below
     the 4.5:1 WCAG AA needs for sub-18pt text. It is kept as a non-text token (borders,
     inert glyphs) and the readable tints below are used for anything anyone has to read. */
  --ci-text: #ffffff;
  --ci-text-muted: #a2a8c4;      /* 7.44:1 on elevated - secondary text */
  --ci-text-dim: #9aa0bd;        /* 6.77:1 - tertiary text */
  --ci-slate: #6e738f;           /* Slate Blue Gray - NOT for text on dark */

  /* Accents */
  --ci-accent: #2d5bba;          /* Steel Blue */
  --ci-accent-soft: rgba(45, 91, 186, 0.16);
  /* Link Blue (#2E6BE6) is 3.63:1 on the elevated surface - fine on white, not here.
     These are the same hue lightened until they pass; the brand value is kept below for
     fills and borders, where contrast rules do not apply. */
  --ci-link: #7da7f5;            /* 7.26:1 on elevated */
  --ci-link-hover: #a9c5fa;      /* 10.03:1 */
  --ci-link-brand: #2e6be6;      /* Link Blue - fills and borders only */
  --ci-visited: #5d3aae;         /* Visited Violet */
  --ci-ok: #1e7a5f;              /* Pine Green */
  --ci-warn: #f2b233;            /* Amber Gold */
  --ci-danger: #c6354e;          /* Crimson Red */
  --ci-purple: #6a35c9;          /* Royal Purple */

  /* Stage colors. Whisper and ffmpeg get distinct hues so the two progress bars are
     distinguishable at a glance without reading their labels. */
  --ci-whisper: #6a35c9;
  --ci-ffmpeg: #2d5bba;
}

* { box-sizing: border-box; }

html, body {
  background: var(--ci-bg);
  color: var(--ci-text);
  min-height: 100%;
}

body {
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 0.95rem;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  margin: 0;
}

/* Underlined by default. Removing them site-wide leaves colour as the only thing marking
   a link, which fails WCAG 1.4.1 for anyone who cannot distinguish these two blues.
   Buttons and the brand mark opt out explicitly below, because their shape carries the
   affordance instead. */
a { color: var(--ci-link); text-decoration: underline; text-underline-offset: 0.15em; }
a:hover { color: var(--ci-link-hover); }
.ci-topbar .brand, .ci-download, .logout-link { text-decoration: none; }

code, .mono {
  font-family: "Cascadia Code", "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

/* ---------- Top bar ---------- */
.ci-topbar {
  background: linear-gradient(90deg, #0a0824 0%, #100d33 60%);
  border-bottom: 1px solid var(--ci-border);
  height: 56px;
  flex: 0 0 auto;
}
.ci-topbar .brand {
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--ci-text);
}
.ci-topbar .brand:hover { text-decoration: none; color: var(--ci-text); }
.ci-topbar .brand .fa-closed-captioning { color: var(--ci-accent); }

.course-pill {
  background: var(--ci-accent-soft);
  border: 1px solid var(--ci-border);
  border-radius: 999px;
  color: var(--ci-text-dim);
  font-size: 0.78rem;
  padding: 0.15rem 0.7rem;
}

.refresh-state {
  color: var(--ci-text-muted);
  font-size: 0.8rem;
}
.refresh-state .fa-rotate { margin-right: 0.35rem; }
/* Spin only while a fetch is genuinely in flight, so the icon means something. */
.refresh-state.is-busy .fa-rotate { animation: ci-spin 1s linear infinite; }
.refresh-state.is-stale { color: var(--ci-warn); }
@keyframes ci-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .refresh-state.is-busy .fa-rotate { animation: none; }
}

.logout-link { color: var(--ci-text-muted); font-size: 0.85rem; }
.logout-link:hover { color: var(--ci-text); text-decoration: none; }

/* ---------- Main ---------- */
.ci-main { flex: 1 0 auto; padding: 1.5rem 0 2.5rem; }

.ci-page-title {
  font-size: 1.35rem;
  font-weight: 650;
  margin-bottom: 0.15rem;
}
.ci-page-sub { color: var(--ci-text-muted); font-size: 0.87rem; }

/* ---------- Summary strip ---------- */
.ci-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.75rem;
  margin: 1.25rem 0 1.5rem;
}
.ci-stat {
  background: var(--ci-bg-elevated);
  border: 1px solid var(--ci-border);
  border-radius: 8px;
  padding: 0.7rem 0.9rem;
}
.ci-stat .value { font-size: 1.5rem; font-weight: 650; line-height: 1.1; }
.ci-stat .label {
  color: var(--ci-text-muted);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-top: 0.15rem;
}
.ci-stat.is-active .value { color: var(--ci-warn); }
.ci-stat.is-done .value { color: #57c79a; }
.ci-stat.is-failed .value { color: var(--ci-danger); }

/* ---------- Lecture cards ---------- */
.ci-lectures { display: flex; flex-direction: column; gap: 0.75rem; }

.ci-lecture {
  background: var(--ci-bg-elevated);
  border: 1px solid var(--ci-border);
  border-left: 3px solid var(--ci-text-muted);
  border-radius: 8px;
  padding: 0.9rem 1.1rem;
}
.ci-lecture.state-running   { border-left-color: var(--ci-warn); }
.ci-lecture.state-completed { border-left-color: var(--ci-ok); }
.ci-lecture.state-failed    { border-left-color: var(--ci-danger); }
.ci-lecture.state-found     { border-left-color: var(--ci-text-muted); }

.ci-lecture-head {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.5rem 0.9rem;
}
.ci-lecture-name { font-size: 1.02rem; font-weight: 620; }
.ci-lecture-meta { color: var(--ci-text-muted); font-size: 0.8rem; }

.ci-badge {
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  padding: 0.12rem 0.6rem;
  text-transform: uppercase;
}
.ci-badge.state-found     { background: rgba(110,115,143,0.18); color: #b6bad2; }
.ci-badge.state-running   { background: rgba(242,178,51,0.16);  color: var(--ci-warn); }
.ci-badge.state-completed { background: rgba(30,122,95,0.22);   color: #57c79a; }
.ci-badge.state-failed    { background: rgba(198,53,78,0.18);   color: #e8798c; }

/* ---------- Progress ---------- */
.ci-stages {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 0.6rem 1.5rem;
  margin-top: 0.8rem;
}
.ci-stage-label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 0.78rem;
  color: var(--ci-text-dim);
  margin-bottom: 0.25rem;
}
.ci-stage-label .pct { font-variant-numeric: tabular-nums; font-weight: 600; }

.ci-track {
  background: var(--ci-bg-sunken);
  border: 1px solid var(--ci-border);
  border-radius: 999px;
  height: 8px;
  overflow: hidden;
}
.ci-bar {
  height: 100%;
  border-radius: 999px;
  /* Percentages arrive from a poll, so animate the width rather than jumping. */
  transition: width 0.4s ease;
}
.ci-bar.stage-whisper { background: var(--ci-whisper); }
.ci-bar.stage-ffmpeg  { background: var(--ci-ffmpeg); }
.ci-bar.is-complete   { background: var(--ci-ok); }
.ci-bar.is-failed     { background: var(--ci-danger); }
@media (prefers-reduced-motion: reduce) {
  .ci-bar { transition: none; }
}

/* ---------- Footer of a lecture card ---------- */
.ci-lecture-foot {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.6rem 1rem;
  margin-top: 0.85rem;
}
.ci-download {
  background: var(--ci-accent);
  border: 1px solid var(--ci-accent);
  border-radius: 6px;
  color: #fff;
  font-size: 0.83rem;
  font-weight: 600;
  padding: 0.35rem 0.85rem;
}
.ci-download:hover { background: #3a6cd4; color: #fff; text-decoration: none; }
.ci-filesize { color: var(--ci-text-muted); font-size: 0.78rem; }

.ci-error {
  background: rgba(198,53,78,0.10);
  border: 1px solid rgba(198,53,78,0.35);
  border-radius: 6px;
  color: #e8798c;
  font-size: 0.8rem;
  margin-top: 0.7rem;
  padding: 0.5rem 0.75rem;
}

/* ---------- Empty state ---------- */
.ci-empty {
  border: 1px dashed var(--ci-border);
  border-radius: 8px;
  color: var(--ci-text-muted);
  padding: 3rem 1.5rem;
  text-align: center;
}
.ci-empty .fa-folder-open { color: var(--ci-slate); font-size: 2.2rem; }

/* ---------- Login ---------- */
.ci-login-wrap {
  align-items: center;
  display: flex;
  flex: 1 0 auto;
  justify-content: center;
  padding: 2rem 1rem;
}
.ci-login {
  background: var(--ci-bg-elevated);
  border: 1px solid var(--ci-border);
  border-radius: 10px;
  max-width: 380px;
  padding: 2rem;
  width: 100%;
}
.ci-login h1 { font-size: 1.15rem; font-weight: 650; margin-bottom: 0.25rem; }
.ci-login .sub { color: var(--ci-text-muted); font-size: 0.85rem; margin-bottom: 1.25rem; }
.ci-login .form-control {
  background: var(--ci-bg-sunken);
  border: 1px solid var(--ci-border);
  color: var(--ci-text);
}
.ci-login .form-control:focus {
  background: var(--ci-bg-sunken);
  border-color: var(--ci-accent);
  box-shadow: 0 0 0 0.2rem var(--ci-accent-soft);
  color: var(--ci-text);
}
.ci-login .btn-signin {
  background: var(--ci-accent);
  border: none;
  color: #fff;
  font-weight: 600;
  width: 100%;
}
.ci-login .btn-signin:hover { background: #3a6cd4; }
.ci-login .alert-fail {
  background: rgba(198,53,78,0.12);
  border: 1px solid rgba(198,53,78,0.35);
  border-radius: 6px;
  color: #e8798c;
  font-size: 0.83rem;
  margin-bottom: 1rem;
  padding: 0.55rem 0.75rem;
}

/* ---------- Footer ---------- */
.ci-footer {
  border-top: 1px solid var(--ci-border);
  color: var(--ci-text-muted);
  flex: 0 0 auto;
  font-size: 0.78rem;
}

