/* CSE 541 course site — single stylesheet, no frameworks.
   Colors follow UW brand purple (#4b2e83) and gold (#b7a57a). */

:root {
  --purple: #4b2e83;
  --purple-deep: #32006e;
  --gold: #b7a57a;
  --gold-soft: #e8e3d3;
  --bg: #fbfaf8;
  --surface: #ffffff;
  --surface-2: #f4f1ea;
  --text: #1d1b22;
  --muted: #5d5a66;
  --border: #e3dfd6;
  --link: #4b2e83;
  --link-hover: #7a5bb5;
  --accent-bg: #f1ecfa;
  --ok: #2f7d4f;
  --warn-bg: #fff7e0;
  --warn-border: #e2c46b;
  --shadow: 0 1px 2px rgba(20, 10, 40, .05), 0 4px 16px rgba(20, 10, 40, .05);
  --focus: #4b2e83;
  --bad: #b3261e;
  --proj: #76613d;
  --radius: 10px;
  --maxw: 980px;
  --font: "Source Sans 3", "Source Sans Pro", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  --mono: "Source Code Pro", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15131a;
    --surface: #1d1a24;
    --surface-2: #25212e;
    --text: #ece9f2;
    --muted: #a7a2b3;
    --border: #36313f;
    --link: #c7b3f0;
    --link-hover: #e6dafc;
    --accent-bg: #2a2238;
    --gold-soft: #3a3426;
    --warn-bg: #2f2915;
    --warn-border: #7a6523;
    --shadow: none;
    --focus: #d9c8ff;
    --ok: #7fd1a0;
    --bad: #f2867e;
  }
  .footer-inner img { background: #fff; padding: 4px 8px; border-radius: 6px; }
  .icon-invert { filter: invert(1); }
}

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

html { scroll-padding-top: 76px; }
@media (prefers-reduced-motion: no-preference) { html { scroll-behavior: smooth; } }

body {
  margin: 0;
  font: 400 17px/1.6 var(--font);
  color: var(--text);
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
}

a { color: var(--link); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { color: var(--link-hover); }

code { font-family: var(--mono); font-size: .9em; background: var(--surface-2); padding: 1px 5px; border-radius: 4px; }

h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 .5em; font-weight: 700; }
h2 { font-size: 1.6rem; margin-top: 0; }
h3 { font-size: 1.2rem; margin-top: 1.6em; }
h4 { font-size: 1.05rem; margin-top: 1.4em; }
p, ul, ol { margin: 0 0 1em; }
ul, ol { padding-left: 1.3em; }
li { margin: .2em 0; }

.skip-link { position: absolute; left: -999px; top: 0; background: var(--surface); padding: 8px 12px; z-index: 100; }
.skip-link:focus { left: 8px; top: 8px; }

/* ---------- Header / nav ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: var(--purple);
  color: #fff;
  box-shadow: 0 2px 10px rgba(0, 0, 0, .15);
}
.topbar-inner {
  max-width: var(--maxw); margin: 0 auto; padding: 0 16px;
  display: flex; align-items: center; gap: 16px; min-height: 56px;
}
.brand { color: #fff; font-weight: 700; text-decoration: none; white-space: nowrap; font-size: 1.05rem; }
.brand:hover { color: var(--gold); }
.brand .qtr { font-weight: 400; opacity: .8; margin-left: 6px; }
.nav { margin-left: auto; display: flex; flex-wrap: wrap; gap: 2px; }
.nav a {
  color: #fff; text-decoration: none; padding: 6px 10px; border-radius: 6px;
  font-size: .95rem; white-space: nowrap;
}
.nav a:hover, .nav a:focus-visible { background: rgba(255, 255, 255, .14); color: #fff; }
.nav a.active { box-shadow: inset 0 -2px 0 var(--gold); }

@media (max-width: 720px) {
  .topbar { position: static; } /* don't let a tall wrapped header cover focused content */
  html { scroll-padding-top: 12px; }
  .topbar-inner { flex-wrap: wrap; padding-top: 6px; padding-bottom: 6px; gap: 4px; }
  .nav { margin-left: -10px; }
  .nav a { padding: 8px 10px; }
}

/* ---------- Hero ---------- */
.hero {
  background-color: var(--purple);
  background-image: linear-gradient(135deg, var(--purple-deep), var(--purple) 70%, #56379a);
  color: #fff;
  padding: 44px 0 36px;
}
.hero-inner { max-width: var(--maxw); margin: 0 auto; padding: 0 16px; }
.hero .eyebrow { text-transform: uppercase; letter-spacing: .12em; font-size: .8rem; color: #f0e2b6; font-weight: 700; margin: 0 0 6px; }
.hero h1 { font-size: clamp(2rem, 5vw, 2.8rem); margin: 0 0 8px; letter-spacing: -.01em; }
.hero .tagline { font-size: 1.15rem; opacity: .92; max-width: 46em; margin: 0; }

/* ---------- Layout ---------- */
.content { max-width: var(--maxw); margin: 0 auto; padding: 0 16px 48px; }
section { padding-top: 40px; }
section + section { border-top: 1px solid var(--border); margin-top: 40px; }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px 20px;
}

/* Quick-facts grid overlapping the hero */
.facts {
  display: grid; gap: 12px; margin-top: -22px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}
.fact { padding: 14px 16px; }
.fact .label { font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 700; margin-bottom: 2px; }
.fact .value { font-size: 1rem; }
.fact .value ul { list-style: none; padding: 0; margin: 0; }
.tbd { color: var(--muted); font-style: italic; }

/* Callouts */
.callout {
  border-left: 4px solid var(--purple); background: var(--accent-bg);
  padding: 14px 18px; border-radius: 0 var(--radius) var(--radius) 0; margin: 1.2em 0;
}
.callout > :last-child { margin-bottom: 0; }
.callout.gold { border-left-color: var(--gold); background: var(--gold-soft); }
.callout.warn { border-left-color: var(--warn-border); background: var(--warn-bg); }
.callout h3, .callout h4 { margin-top: 0; }

.announcements { margin-top: 20px; }
.announcements h2 { font-size: 1.1rem; margin-bottom: 8px; }
.announcements ul { margin: 0; padding-left: 1.1em; }
.announcements .date { font-weight: 700; color: var(--muted); font-variant-numeric: tabular-nums; margin-right: 6px; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--purple); color: #fff; text-decoration: none; font-weight: 600;
  padding: 9px 16px; border-radius: 8px; border: 0;
}
.btn:hover { background: var(--purple-deep); color: #fff; }
.btn.secondary { background: transparent; color: var(--link); border: 1.5px solid currentColor; }
.btn.secondary:hover { background: var(--accent-bg); color: var(--link); }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; margin: 12px 0 0; }

/* Two-column prose helpers */
.grid-2 { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }

/* Resource list */
.resources { list-style: none; padding: 0; }
.resources li { padding: 8px 0; border-bottom: 1px dashed var(--border); }
.resources li:last-child { border-bottom: 0; }
.tag {
  display: inline-block; font-size: .75rem; font-weight: 700; letter-spacing: .03em;
  padding: 1px 7px; border-radius: 999px; background: var(--surface-2); color: var(--muted);
  border: 1px solid var(--border); margin-right: 6px; vertical-align: 1px; white-space: nowrap;
}

/* Grade breakdown bar */
.grade-bar { display: flex; min-height: 36px; border-radius: 8px; overflow: hidden; margin: 8px 0 6px; font-size: .85rem; font-weight: 600; line-height: 1.2; }
.grade-bar > div { display: flex; align-items: center; justify-content: center; text-align: center; color: #fff; padding: 4px; min-width: 0; }
.grade-bar .proj + .proj { border-left: 2px solid var(--surface); }
.grade-bar .hw { background: var(--purple); }
.grade-bar .hw + .hw { border-left: 2px solid var(--surface); }
.grade-bar .proj { background: var(--proj); }

/* Assignments */
.assignments { display: grid; gap: 10px; }
.assignment {
  display: grid; grid-template-columns: 1fr auto; gap: 4px 16px; align-items: center;
  padding: 12px 16px;
}
.assignment .name { font-weight: 700; }
.assignment .due { color: var(--muted); font-size: .95rem; }
.assignment .links { grid-row: span 2; }
@media (max-width: 560px) {
  .assignment { grid-template-columns: 1fr; }
  .assignment .links { grid-row: auto; }
}

/* Schedule */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
table.schedule { width: 100%; border-collapse: collapse; font-size: .96rem; }
.schedule th, .schedule td { text-align: left; padding: 10px 12px; vertical-align: top; border-bottom: 1px solid var(--border); }
.schedule thead th { background: var(--surface-2); font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); position: sticky; top: 0; }
.schedule tbody tr:last-child td { border-bottom: 0; }
.schedule .num { color: var(--muted); font-variant-numeric: tabular-nums; width: 2.5em; }
.schedule .date { white-space: nowrap; font-variant-numeric: tabular-nums; width: 7.5em; }
.schedule .topic { font-weight: 600; }
.schedule .reading { color: var(--muted); font-size: .92rem; font-weight: 400; margin-top: 2px; }
.schedule .slides { white-space: nowrap; width: 7em; }
.schedule tr.week-start td { border-top: 2px solid var(--border); }
.schedule tr.holiday td { background: var(--surface-2); color: var(--muted); font-style: italic; }
.schedule tr.due td { background: var(--gold-soft); }
.schedule tr.due .topic { font-weight: 600; }
.schedule tr.next td { background: var(--accent-bg); }
.badge { display: inline-block; margin-left: 6px; font-size: .75rem; font-weight: 700; background: var(--purple); color: #fff; padding: 1px 7px; border-radius: 999px; vertical-align: 1px; }
.slides .pending { color: var(--muted); font-size: .85rem; }

@media (max-width: 640px) {
  .schedule th, .schedule td { padding: 8px 8px; }
  .schedule .date { width: auto; white-space: normal; }
  .schedule .num { width: auto; }
  .schedule .slides { width: auto; }
}

/* Policy page */
.policy-head { display: flex; gap: 18px; align-items: center; }
.policy-head img { width: 72px; height: 72px; flex: none; }
.tldr { list-style: none; padding: 0; display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.tldr li { margin: 0; padding: 12px 14px 12px 42px; position: relative; }
.tldr li::before { position: absolute; left: 14px; top: 11px; font-weight: 700; }
.tldr .yes::before { content: "✓"; content: "✓" / ""; color: var(--ok); }
.tldr .no::before { content: "✕"; content: "✕" / ""; color: var(--bad); }
.tldr .note::before { content: "✎"; content: "✎" / ""; color: var(--muted); }
.policy h2 { font-size: 1.3rem; margin-top: 1.8em; border-bottom: 1px solid var(--border); padding-bottom: 4px; }
.policy .toc + h2 { margin-top: 1.2em; }
.policy blockquote { margin: 0 0 1em; padding: 10px 16px; border-left: 3px solid var(--border); color: var(--muted); }
.toc { font-size: .95rem; }
.toc ol { columns: 2; column-gap: 24px; margin: 0; }
@media (max-width: 560px) { .toc ol { columns: 1; } }

/* Footer */
footer.site-footer {
  border-top: 1px solid var(--border); margin-top: 48px; padding: 20px 16px 28px; color: var(--muted); font-size: .9rem;
}
.footer-inner { max-width: var(--maxw); margin: 0 auto; display: flex; flex-wrap: wrap; align-items: center; gap: 12px 24px; justify-content: space-between; }
.footer-inner img { height: 34px; width: auto; max-width: 100%; object-fit: contain; }
.footer-inner a { color: var(--muted); }

@media print {
  .topbar, .btn-row, .skip-link { display: none !important; }
  .hero { background: none; color: #000; padding: 0 0 12px; }
  .hero .eyebrow { color: #000; }
  body { background: #fff; }
}

.muted { color: var(--muted); }
.assignment .pending { color: var(--muted); font-size: .9rem; white-space: nowrap; }

/* Acceptable / not acceptable AI prompt comparison */
.compare { display: grid; gap: 14px; grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); margin: 1em 0 1.2em; }
@media (max-width: 720px) { .compare { grid-template-columns: 1fr; } }
.ex { background: var(--surface); border: 1px solid var(--border); border-top: 4px solid; border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.ex.bad { border-top-color: var(--bad); }
.ex.good { border-top-color: var(--ok); }
.ex-label { font-weight: 700; font-size: .85rem; text-transform: uppercase; letter-spacing: .06em; margin-bottom: 8px; }
.ex.bad .ex-label { color: var(--bad); }
.ex.good .ex-label { color: var(--ok); }
.ex p { margin: 0; color: var(--muted); font-size: .95rem; }
.prompt { margin: 0 0 10px; padding: 10px 14px; background: var(--surface-2); border-radius: 8px; font-size: .95rem; }
.prompt .math { display: block; text-align: center; margin: 8px 0; font-family: "Cambria Math", "STIX Two Math", Georgia, serif; font-size: 1.05rem; }
var { font-family: "Cambria Math", "STIX Two Math", Georgia, serif; }

.prompt math[display="block"] { margin: 8px 0; font-size: 1.1rem; }
math { font-family: "STIX Two Math", "Cambria Math", "Latin Modern Math", math; }

/* ---------- Accessibility helpers ---------- */
.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0;
}
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 3px; }
.topbar :focus-visible, .hero :focus-visible { outline-color: #fff; }
.btn:focus-visible { outline-offset: 3px; }
.callout h2 { font-size: 1.25rem; }
.callout h3.no-rule { border: 0; padding: 0; font-size: 1.05rem; }
@media (forced-colors: active) {
  .btn, .card, .callout, .ex, .badge, .tag { border: 1px solid CanvasText; }
  .grade-bar > div { border: 1px solid CanvasText; forced-color-adjust: none; }
}
body { overflow-wrap: break-word; }
.ex { min-width: 0; }
.prompt { overflow-x: auto; }
.table-wrap { position: relative; }

.quiet { color: var(--muted); font-size: .95rem; }
.toc li { margin: 0 0 .4em; break-inside: avoid; }
@media (max-width: 560px) {
  .grade-bar { flex-direction: column; }
  .grade-bar > div { flex: none !important; justify-content: flex-start; padding: 6px 10px; }
  .grade-bar .hw + .hw, .grade-bar .proj + .proj { border-left: 0; border-top: 2px solid var(--surface); }
  .grade-bar .hw { width: 28.6%; } .grade-bar .proj { width: 100%; }
}
