/* ============================================================
   PSE-823 course site — shared stylesheet
   Mobile-first; light/dark via prefers-color-scheme.
   ============================================================ */

/* ---------- tokens ---------- */
:root {
  --brand: #0b3d91;
  --brand-hover: #0a337a;
  --brand-contrast: #ffffff;
  --brand-soft: #eaf1fd;
  --accent: #1f6feb;

  --bg: #f6f8fc;
  --surface: #ffffff;
  --surface-2: #f1f4fa;
  --text: #121620;
  --text-muted: #566072;
  --border: #e2e7f0;
  --border-strong: #ccd4e2;
  --bar-bg: rgba(255, 255, 255, .82);

  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow-md: 0 10px 28px -10px rgba(16, 24, 40, .18), 0 2px 6px -2px rgba(16, 24, 40, .08);

  --radius: 16px;
  --radius-sm: 10px;
  --measure: 1040px;
  --gutter: 20px;
  --font: "Inter", "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont,
          "Helvetica Neue", Arial, "Noto Sans", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --brand: #8ab4f8;
    --brand-hover: #a9c8ff;
    --brand-contrast: #0b1220;
    --brand-soft: #172445;
    --accent: #8ab4f8;

    --bg: #0b0e13;
    --surface: #131820;
    --surface-2: #1a212b;
    --text: #e7eaf0;
    --text-muted: #9aa3b2;
    --border: #232a34;
    --border-strong: #333c49;
    --bar-bg: rgba(11, 14, 19, .8);

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow-md: 0 12px 30px -10px rgba(0, 0, 0, .65), 0 2px 6px -2px rgba(0, 0, 0, .4);
  }
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: 80px;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  overflow-wrap: break-word;
}

a { color: var(--brand); }
img, svg { max-width: 100%; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 6px;
}

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.wrap {
  max-width: var(--measure);
  margin-inline: auto;
  padding-inline: max(var(--gutter), env(safe-area-inset-left));
}

.skip-link {
  position: absolute;
  left: 12px; top: -60px;
  background: var(--brand);
  color: var(--brand-contrast);
  padding: 8px 14px;
  border-radius: 8px;
  z-index: 100;
  text-decoration: none;
  font-weight: 600;
}
.skip-link:focus { top: 10px; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--bar-bg);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
  backdrop-filter: saturate(160%) blur(14px);
  border-bottom: 1px solid var(--border);
}

.topbar .wrap {
  display: flex;
  align-items: center;
  gap: 8px 20px;
  min-height: 60px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  flex: none;
  font-weight: 700;
  font-size: 1.02rem;
  letter-spacing: -.01em;
  color: var(--text);
  text-decoration: none;
}
.brand img { width: 30px; height: 30px; border-radius: 8px; display: block; }

.nav {
  display: flex;
  gap: 2px;
  margin-left: auto;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.nav::-webkit-scrollbar { display: none; }

.nav a {
  flex: none;
  padding: 8px 13px;
  border-radius: 999px;
  font-size: .92rem;
  font-weight: 550;
  color: var(--text-muted);
  text-decoration: none;
  transition: background-color .15s ease, color .15s ease;
}
.nav a:hover { color: var(--text); background: var(--surface-2); }
.nav a[aria-current="page"] {
  color: var(--brand);
  background: var(--brand-soft);
}

/* ---------- hero / page header ---------- */
.hero {
  position: relative;
  overflow: hidden;
  color: #fff;
  background:
    radial-gradient(90% 120% at 100% -10%, #2a6fe0 0%, rgba(42, 111, 224, 0) 60%),
    radial-gradient(60% 90% at -10% 120%, #0f4bb5 0%, rgba(15, 75, 181, 0) 60%),
    linear-gradient(165deg, #0b3d91 0%, #071f4d 100%);
}

/* faint control-loop grid texture */
.hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, .05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, .05) 1px, transparent 1px);
  background-size: 36px 36px;
  -webkit-mask-image: radial-gradient(70% 90% at 90% 0%, #000, transparent 75%);
  mask-image: radial-gradient(70% 90% at 90% 0%, #000, transparent 75%);
  pointer-events: none;
}

.hero .wrap {
  position: relative;
  padding-block: 44px 40px;
}

.hero-lg .wrap { padding-block: 56px 52px; }

.eyebrow {
  display: inline-block;
  font-size: .74rem;
  font-weight: 650;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, .95);
  background: rgba(255, 255, 255, .12);
  border: 1px solid rgba(255, 255, 255, .2);
  border-radius: 999px;
  padding: 5px 12px;
  margin-bottom: 18px;
}

.hero h1 {
  margin: 0;
  font-size: clamp(1.75rem, 1.1rem + 3.2vw, 3rem);
  line-height: 1.12;
  font-weight: 750;
  letter-spacing: -.025em;
  max-width: 22ch;
  text-wrap: balance;
}

.hero .lede {
  margin: 16px 0 0;
  font-size: clamp(1rem, .95rem + .25vw, 1.12rem);
  color: rgba(255, 255, 255, .88);
  max-width: 58ch;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 26px;
}

.btn-hero {
  background: #fff;
  color: #0b3d91;
}
.btn-hero:hover { background: #e6efff; }

.btn-ghost {
  color: #fff;
  border-color: rgba(255, 255, 255, .35);
  background: rgba(255, 255, 255, .08);
}
.btn-ghost:hover { background: rgba(255, 255, 255, .18); }

.byline {
  margin: 26px 0 0;
  font-size: .92rem;
  color: rgba(255, 255, 255, .78);
}
.byline strong { color: #fff; font-weight: 600; }

/* quick facts strip */
.facts {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  list-style: none;
  padding: 0;
  margin: 26px 0 0;
}
.facts li {
  font-size: .85rem;
  color: rgba(255, 255, 255, .9);
  background: rgba(255, 255, 255, .1);
  border: 1px solid rgba(255, 255, 255, .16);
  border-radius: 999px;
  padding: 6px 13px;
}
.facts b { color: #fff; font-weight: 650; }

/* ---------- sections ---------- */
main .wrap { padding-block: 40px 16px; }

.section + .section { margin-top: 48px; }

.section-head {
  display: flex;
  align-items: baseline;
  gap: 14px;
  margin-bottom: 20px;
}
.section-head h2 {
  margin: 0;
  font-size: clamp(1.2rem, 1.1rem + .5vw, 1.4rem);
  font-weight: 700;
  letter-spacing: -.015em;
}
.section-head .rule { flex: 1; height: 1px; background: var(--border); }
.count {
  font-size: .85rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* ---------- lecture cards ---------- */
.lecture-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 14px;
}

.lecture-card {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow .18s ease, border-color .18s ease, transform .18s ease;
}
.lecture-card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.card-index {
  font-size: .9rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--brand);
  background: var(--brand-soft);
  border-radius: 12px;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
}

.card-title {
  margin: 0;
  font-size: 1.08rem;
  font-weight: 650;
  line-height: 1.38;
  letter-spacing: -.01em;
  text-wrap: pretty;
}
.card-meta {
  margin: 6px 0 0;
  font-size: .9rem;
  color: var(--text-muted);
}

.card-actions {
  margin-top: 16px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.card-actions .btn-primary { grid-column: 1 / -1; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: .92rem;
  font-weight: 600;
  font-family: inherit;
  line-height: 1.2;
  min-height: 44px;              /* comfortable touch target */
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background-color .15s ease, border-color .15s ease, color .15s ease;
}
.btn svg { width: 16px; height: 16px; flex: none; }

.btn-primary { background: var(--brand); color: var(--brand-contrast); }
.btn-primary:hover { background: var(--brand-hover); }

.btn-outline {
  border-color: var(--border-strong);
  color: var(--text);
  background: var(--surface);
}
.btn-outline:hover { border-color: var(--accent); color: var(--brand); }

.btn-quiet {
  color: var(--text-muted);
  background: var(--surface-2);
}
.btn-quiet:hover { color: var(--brand); }

/* ---------- placeholder note ---------- */
.upcoming {
  margin: 14px 0 0;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  padding: 16px 20px;
  font-size: .92rem;
  color: var(--text-muted);
}

/* ---------- link-out cards (home) ---------- */
.link-grid {
  display: grid;
  gap: 14px;
}

.link-card {
  display: flex;
  flex-direction: column;
  gap: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 20px;
  box-shadow: var(--shadow-sm);
}
.link-card h3 { margin: 0; font-size: 1.06rem; font-weight: 650; letter-spacing: -.01em; }
.link-card p { margin: 6px 0 0; font-size: .92rem; color: var(--text-muted); }
.link-card .btn { align-self: flex-start; }

.link-icon {
  width: 42px; height: 42px;
  display: grid; place-items: center;
  border-radius: 12px;
  background: var(--brand-soft);
  color: var(--brand);
  margin-bottom: 14px;
}
.link-icon svg { width: 20px; height: 20px; }

/* ---------- prose + formats ---------- */
.prose p {
  margin: 0 0 16px;
  max-width: 68ch;
}
.prose p:last-child { margin-bottom: 0; }
.prose code {
  background: var(--brand-soft);
  color: var(--brand);
  border-radius: 5px;
  padding: 1px 6px;
  font-size: .88em;
}

.formats {
  list-style: none;
  margin: 24px 0 0;
  padding: 0;
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}
.formats li {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 16px 18px;
}
.format-name { font-weight: 650; font-size: .96rem; margin-bottom: 4px; }
.formats p { margin: 0; max-width: none; font-size: .9rem; line-height: 1.6; color: var(--text-muted); }

/* ---------- resources ---------- */
.file-list {
  list-style: none;
  margin: 0;
  padding: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.file-list li + li { border-top: 1px solid var(--border); }

.file-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 2px 14px;
  padding: 14px 16px;
  color: var(--text);
  text-decoration: none;
  min-height: 64px;
  transition: background-color .15s ease;
}
.file-row:hover { background: var(--surface-2); }

.file-badge {
  grid-row: 1 / span 2;
  width: 44px; height: 44px;
  border-radius: 12px;
  display: grid; place-items: center;
  font-size: .68rem;
  font-weight: 750;
  letter-spacing: .04em;
  color: #b3261e;
  background: #fdecea;
}
.file-badge.pptx { color: #a34a06; background: #fdf0e0; }
@media (prefers-color-scheme: dark) {
  .file-badge { color: #ff8a80; background: #3a1a18; }
  .file-badge.pptx { color: #ffb066; background: #38240f; }
}

.file-name { font-weight: 600; font-size: .98rem; line-height: 1.35; }
.file-num { color: var(--text-muted); font-weight: 600; font-variant-numeric: tabular-nums; }
.file-sub { grid-column: 2; font-size: .84rem; color: var(--text-muted); }
.file-dl {
  grid-row: 1 / span 2;
  grid-column: 3;
  width: 20px; height: 20px;
  color: var(--text-muted);
}
.file-row:hover .file-dl { color: var(--brand); }

.note {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  background: var(--brand-soft);
  border-radius: var(--radius);
  padding: 14px 16px;
  font-size: .92rem;
  margin: 40px 0 28px;
}
.note svg { width: 20px; height: 20px; flex: none; margin-top: 2px; color: var(--brand); }
.note p { margin: 0; }

/* ---------- course info ---------- */
.info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 40px;
}
.info-tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
}
.info-tile .k {
  font-size: .76rem;
  font-weight: 650;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.info-tile .v { margin-top: 2px; font-size: 1.15rem; font-weight: 700; letter-spacing: -.01em; }

.bullets { margin: 0; padding-left: 1.15em; }
.bullets li { margin-bottom: 10px; max-width: 70ch; }
.bullets li::marker { color: var(--accent); }

.topics {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 12px;
  counter-reset: topic;
}
.topics li {
  counter-increment: topic;
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px 16px 62px;
  box-shadow: var(--shadow-sm);
}
.topics li::before {
  content: counter(topic);
  position: absolute;
  left: 16px; top: 16px;
  width: 32px; height: 32px;
  border-radius: 10px;
  display: grid; place-items: center;
  font-size: .88rem;
  font-weight: 700;
  color: var(--brand);
  background: var(--brand-soft);
}
.topics h3 { margin: 0; font-size: 1.02rem; font-weight: 650; letter-spacing: -.01em; }
.topics p { margin: 4px 0 0; font-size: .92rem; color: var(--text-muted); }

.refs {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 12px;
}
.refs li {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  font-size: .95rem;
}
.refs cite { font-style: italic; }

/* ---------- footer ---------- */
.site-footer {
  margin-top: 56px;
  border-top: 1px solid var(--border);
  background: var(--surface);
}
.site-footer .wrap {
  padding-block: 26px calc(34px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 8px 20px;
  font-size: .88rem;
  color: var(--text-muted);
}
.site-footer a {
  color: var(--text-muted);
  text-decoration: none;
  border-bottom: 1px solid var(--border-strong);
}
.site-footer a:hover { color: var(--brand); border-bottom-color: var(--brand); }

/* ---------- 640px and up ---------- */
@media (min-width: 640px) {
  :root { --gutter: 28px; }

  .hero .wrap { padding-block: 56px 48px; }
  .hero-lg .wrap { padding-block: 76px 68px; }

  main .wrap { padding-block: 56px 24px; }
  .section + .section { margin-top: 60px; }

  .lecture-card {
    grid-template-columns: auto 1fr;
    gap: 20px;
    padding: 24px 26px;
  }
  .card-actions { display: flex; flex-wrap: wrap; gap: 9px; }
  .btn { min-height: 40px; padding: 9px 15px; }

  .link-grid { grid-template-columns: 1fr 1fr; }
  .formats { grid-template-columns: repeat(2, 1fr); }
  .info-grid { grid-template-columns: repeat(4, 1fr); }
  .topics { grid-template-columns: 1fr 1fr; }

  .site-footer .wrap { flex-direction: row; justify-content: space-between; align-items: center; }
}

@media (min-width: 960px) {
  .formats { grid-template-columns: repeat(4, 1fr); }
}

/* ---------- very small phones ---------- */
@media (max-width: 560px) {
  .brand span { display: none; }   /* keep all four nav links visible */
  .nav { margin-left: 0; }
  .nav a { padding: 8px 10px; font-size: .88rem; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; scroll-behavior: auto !important; }
  .lecture-card:hover { transform: none; }
}

/* ---------- placeholder (slot) lecture cards ---------- */
.lecture-card.is-slot {
  background: transparent;
  border-style: dashed;
  box-shadow: none;
}
.lecture-card.is-slot:hover { transform: none; box-shadow: none; }
.lecture-card.is-slot .card-index { color: var(--text-muted); background: var(--surface-2); }
.lecture-card.is-slot .card-title { color: var(--text-muted); }
.slot-note {
  margin: 10px 0 0;
  font-size: .88rem;
  color: var(--text-muted);
}

/* ---------- textbook chapter list ---------- */
.chapter-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .93rem;
}
.chapter-table th, .chapter-table td {
  text-align: left;
  vertical-align: top;
  padding: 10px 8px;
  border-bottom: 1px solid var(--border);
}
.chapter-table th { color: var(--text-muted); font-weight: 600; font-size: .85rem; }
.chapter-table .ch-num { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--brand); width: 3em; }
.chapter-table .ch-secs { display: block; color: var(--text-muted); font-size: .85rem; margin-top: 2px; }
.chapter-table .ch-read { white-space: nowrap; }
.ch-status { color: var(--text-muted); font-size: .85rem; }
.ch-link[hidden], .ch-status[hidden] { display: none; }
.notice {
  background: var(--brand-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  font-size: .93rem;
}
@media (max-width: 560px) {
  .chapter-table .ch-lect { display: none; }
}
