/* CSE 493L site styles.
   UW brand: Husky Purple #4b2e83, Husky Gold #b7a57a.
   Gold is decorative only: it fails text contrast on white. */

:root {
  --purple: #4b2e83;
  --gold: #b7a57a;
  --bg: #ffffff;
  --fg: #1c1c1c;
  --muted: #4a4a4a;
  --accent: #4b2e83;
  --panel: #f4f1f8;
  --rule: #d9d2e6;
  --banner-fg: #ffffff;
  --focus: #4b2e83;
  --todo-bg: #fff3c4;
  --todo-fg: #5c4300;
  color-scheme: light;
}

/* Dark colors apply when the system is dark and the visitor has not chosen
   light, or whenever the visitor chooses dark (see theme.js). */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #16121d;
    --fg: #eeeaf4;
    --muted: #c4bdd0;
    --accent: #c5b4e3;
    --panel: #231c30;
    --rule: #3a3149;
    --focus: #b7a57a;
    --todo-bg: #4a3b00;
    --todo-fg: #ffe9a3;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #16121d;
  --fg: #eeeaf4;
  --muted: #c4bdd0;
  --accent: #c5b4e3;
  --panel: #231c30;
  --rule: #3a3149;
  --focus: #b7a57a;
  --todo-bg: #4a3b00;
  --todo-fg: #ffe9a3;
  color-scheme: dark;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--fg);
  font-family: "Encode Sans", "Open Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 1.0625rem;
  line-height: 1.6;
}

a { color: var(--accent); text-underline-offset: 0.15em; }
a:focus-visible,
button:focus-visible,
summary:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  border-radius: 2px;
}

.skip-link {
  position: absolute;
  left: 1rem;
  top: -3rem;
  padding: 0.5rem 1rem;
  background: var(--bg);
  color: var(--accent);
  font-weight: 600;
  z-index: 10;
}
.skip-link:focus { top: 1rem; }

/* Banner and navigation */
.site-header {
  background: var(--purple);
  color: var(--banner-fg);
  border-bottom: 6px solid var(--gold);
}
.site-header .inner {
  max-width: 64rem;
  margin: 0 auto;
  padding: 1rem;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem 2rem;
}
.site-header a { color: var(--banner-fg); }
.site-header a:focus-visible { outline-color: var(--gold); }
.site-title {
  font-weight: 700;
  font-size: 1.15rem;
  text-decoration: none;
}
.site-title span { font-weight: 400; opacity: 0.9; }
.site-nav ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.25rem;
}
.site-nav a {
  font-weight: 600;
  text-decoration: none;
  padding: 0.25rem 0;
  border-bottom: 3px solid transparent;
}
.site-nav a:hover { border-bottom-color: var(--gold); }
.site-nav a[aria-current="page"] { border-bottom-color: var(--gold); }

/* Page body */
main {
  flex: 1;
  width: 100%;
  max-width: 48rem;
  margin: 0 auto;
  padding: 2.5rem 1rem 4rem;
}
main.wide { max-width: 64rem; }

.eyebrow {
  font-weight: 700;
  font-size: 0.9rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 0.25rem;
}
h1 {
  font-size: clamp(1.9rem, 5vw, 2.5rem);
  line-height: 1.15;
  margin: 0 0 1rem;
}
h2 {
  font-size: 1.5rem;
  line-height: 1.25;
  margin: 2.75rem 0 0.75rem;
  padding-bottom: 0.35rem;
  border-bottom: 2px solid var(--rule);
}
h3 {
  font-size: 1.15rem;
  margin: 1.75rem 0 0.5rem;
}
h2, h3 { scroll-margin-top: 1rem; }
p, ul, ol, dl, table { margin-top: 0; margin-bottom: 1rem; }
li { margin-bottom: 0.3rem; }
li > ul { margin-top: 0.3rem; }

.lede { font-size: 1.2rem; }

.callout {
  background: var(--panel);
  border-left: 6px solid var(--gold);
  border-radius: 0 6px 6px 0;
  padding: 1rem 1.25rem;
  margin: 1.5rem 0;
}
.callout > :last-child { margin-bottom: 0; }

/* Info box with an icon, e.g. the AI policy note in the syllabus. The icon
   sits on a white tile because it is black line art on a transparent
   background. */
.info-box {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: var(--panel);
  border-left: 6px solid var(--accent);
  border-radius: 0 6px 6px 0;
  padding: 0.9rem 1.1rem;
  margin: 1.25rem 0;
}
.info-box img {
  flex: none;
  width: 3.5rem;
  height: 3.5rem;
  padding: 0.3rem;
  background: #ffffff;
  border: 2px solid var(--gold);
  border-radius: 8px;
}
.info-box p { margin: 0; }

/* Page heading with an icon (front matter extra.icon), e.g. the AI policy.
   The icon is black line art on a transparent background, so it always
   sits on a white tile to stay visible in dark mode. */
.policy-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1.25rem 1.5rem;
  margin-bottom: 1rem;
}
.policy-head h1 { margin: 0; }
.policy-icon {
  flex: none;
  width: 7.5rem;
  height: 7.5rem;
  padding: 0.6rem;
  background: #ffffff;
  border: 3px solid var(--gold);
  border-radius: 12px;
}

/* Allowed / Not allowed examples in two columns like a table: labels share
   one column sized to the widest label, and each example wraps within its
   own column. */
.examples {
  list-style: none;
  padding-left: 0;
  display: grid;
  grid-template-columns: max-content 1fr;
  column-gap: 0.75rem;
}
.examples li {
  display: grid;
  grid-column: 1 / -1;
  grid-template-columns: subgrid;
}
.examples .tag { font-weight: 700; }
.examples .yes .tag { color: var(--accent); }

/* Smaller, muted paragraph for source notes */
.muted-note { color: var(--muted); font-size: 0.95rem; }

/* Key/value facts such as meeting times */
.facts {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.4rem 1.25rem;
}
.facts dt { font-weight: 700; color: var(--accent); }
.facts dd { margin: 0; }
@media (max-width: 30rem) {
  .facts { grid-template-columns: 1fr; gap: 0.1rem; }
  .facts dd { margin-bottom: 0.6rem; }
}

/* Tables */
.table-wrap { overflow-x: auto; margin-bottom: 1rem; }
table.data {
  border-collapse: collapse;
  width: 100%;
}
table.data caption {
  text-align: left;
  font-weight: 700;
  padding-bottom: 0.5rem;
}
table.data th,
table.data td {
  text-align: left;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--rule);
  vertical-align: top;
}
table.data thead th {
  background: var(--panel);
  border-bottom: 2px solid var(--accent);
}
table.data td.num, table.data th.num { text-align: right; white-space: nowrap; }

/* Staff list */
.staff {
  list-style: none;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr));
  gap: 0.75rem;
}
.staff li {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  background: var(--panel);
  border-radius: 6px;
  padding: 0.75rem 1rem;
  margin: 0;
}
.staff .avatar {
  flex: none;
  width: 4rem;
  height: 4rem;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--gold);
  background: var(--bg);
}
.staff .name { display: block; font-weight: 700; }
.staff .role { color: var(--muted); font-size: 0.95rem; }

/* Table of contents: a sticky sidebar on wide screens, a panel under the
   page title on narrow ones. page-nav.js marks the section in view. */
main.with-toc { max-width: 48rem; }
.toc {
  background: var(--panel);
  border-radius: 6px;
  padding: 1rem 1.25rem;
  margin-bottom: 2rem;
}
.toc h2 {
  font-size: 0.85rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 0.5rem;
  padding: 0;
  border: 0;
}
.toc ol {
  list-style: none;
  margin: 0;
  padding: 0;
  columns: 2 12rem;
}
.toc li { margin: 0; break-inside: avoid; }
.toc a {
  display: block;
  padding: 0.2rem 0 0.2rem 0.75rem;
  border-left: 3px solid transparent;
  color: var(--fg);
  text-decoration: none;
  line-height: 1.35;
}
.toc a:hover { color: var(--accent); text-decoration: underline; }
.toc a[aria-current] {
  border-left-color: var(--gold);
  color: var(--accent);
  font-weight: 700;
}

@media (min-width: 68rem) {
  main.with-toc {
    max-width: 68rem;
    display: grid;
    grid-template-columns: 15rem minmax(0, 48rem);
    grid-template-areas: "toc title" "toc content";
    grid-template-rows: auto 1fr;
    column-gap: 3rem;
    justify-content: center;
  }
  .with-toc > .page-title { grid-area: title; }
  .with-toc > .content { grid-area: content; }
  .with-toc > .toc {
    grid-area: toc;
    align-self: start;
    position: sticky;
    top: 1.5rem;
    max-height: calc(100vh - 3rem);
    overflow-y: auto;
    margin: 0.5rem 0 0;
    background: none;
    padding: 0;
    border-left: 1px solid var(--rule);
  }
  .with-toc > .toc h2 { padding-left: 0.9rem; }
  .with-toc > .toc ol { columns: auto; }
  .with-toc > .toc a { margin-left: -2px; }
}

/* Back-to-top button; page-nav.js shows it once the reader scrolls down */
.back-to-top {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 5;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.5rem 0.9rem;
  border-radius: 999px;
  background: var(--purple);
  color: #ffffff;
  border: 2px solid var(--gold);
  font-weight: 600;
  font-size: 0.95rem;
  text-decoration: none;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
  opacity: 0;
  visibility: hidden;
  transform: translateY(0.5rem);
  transition: opacity 0.2s, transform 0.2s, visibility 0.2s;
}
.back-to-top.is-visible { opacity: 1; visibility: visible; transform: none; }
.back-to-top:hover { text-decoration: underline; }
.back-to-top:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; }
.back-to-top svg { width: 1em; height: 1em; }

/* Keep links reached by keyboard from scrolling under the back-to-top
   button (WCAG 2.4.11, Focus Not Obscured). */
html { scroll-padding-bottom: 5rem; }

@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}
@media (prefers-reduced-motion: reduce) {
  .back-to-top { transition: none; }
}

/* Placeholder links to fill in before going live */
.todo {
  background: var(--todo-bg);
  color: var(--todo-fg);
  outline: 2px dashed currentColor;
  outline-offset: 1px;
  padding: 0 0.2rem;
}

/* Light/dark switch in the banner (hidden until theme.js enables it) */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font: inherit;
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--banner-fg);
  background: transparent;
  border: 2px solid rgba(255, 255, 255, 0.6);
  border-radius: 999px;
  padding: 0.2rem 0.75rem;
  cursor: pointer;
}
.theme-toggle:hover { border-color: var(--gold); }
.theme-toggle:focus-visible { outline-color: var(--gold); }
.theme-toggle[hidden] { display: none; }
.theme-toggle svg { width: 1.1em; height: 1.1em; }
.theme-toggle[aria-pressed="true"] {
  background: rgba(255, 255, 255, 0.16);
  border-color: var(--gold);
}
.header-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1.5rem;
}

.site-footer {
  border-top: 1px solid var(--rule);
  padding: 1.5rem 1rem;
  text-align: center;
  font-size: 0.9rem;
  color: var(--muted);
}
.site-footer p { margin: 0; }

.print-only { display: none; }

@media print {
  /* Always print in light colors, even if the reader chose dark mode.
     These selectors match the dark-mode ones and come later, so they win. */
  :root[data-theme],
  :root:not([data-theme]) {
    --bg: #ffffff;
    --fg: #000000;
    --muted: #333333;
    --accent: #4b2e83;
    --panel: #f4f1f8;
    --rule: #bbbbbb;
    color-scheme: light;
  }

  @page { margin: 0.6in 0.7in; }
  body {
    display: block;
    min-height: 0;
    background: #ffffff;
    color: #000000;
    font-size: 10.5pt;
    line-height: 1.45;
  }
  .skip-link, .site-nav, .theme-toggle, .back-to-top, .eyebrow { display: none !important; }
  .print-only { display: block; }

  .site-header { background: none; color: #000; border-bottom: 2px solid #000; }
  .site-header .inner { padding: 0 0 0.4rem; }
  .site-header a { color: #000; text-decoration: none; }
  main, main.with-toc, main.wide { display: block; max-width: none; padding: 0.75rem 0 0; }

  /* The table of contents prints as a plain two-column list after the title */
  .toc {
    position: static;
    max-height: none;
    overflow: visible;
    background: none;
    border: 1px solid var(--rule);
    padding: 0.6rem 0.9rem;
    margin: 0.75rem 0 1rem;
  }
  .toc ol { columns: 2; }
  .toc a,
  .toc a[aria-current] {
    border-left: 0;
    padding: 0.1rem 0;
    color: var(--fg);
    font-weight: 400;
  }

  h2 { margin-top: 1.5rem; }
  h2, h3 { break-after: avoid; page-break-after: avoid; }
  .callout, .info-box, table, tr, li, .staff li { break-inside: avoid; page-break-inside: avoid; }
  p { orphans: 3; widows: 3; }
}
