/* IDB624 course site. One stylesheet for every page. */

:root {
  color-scheme: light;
  --page: #ffffff;
  --panel: #f2f7f6;
  --panel-2: #e4eeec;
  --line: #c4d6d2;
  --line-strong: #8fb0aa;
  --ink: #0e2522;
  --ink-2: #3a524e;
  --brand: #0d9488;          /* course brand colour: rules, marks, focus */
  --action: #0f766e;         /* buttons: white text on it is 5.5:1 */
  --action-ink: #ffffff;
  --action-hover: #115e59;
  --link: #0b5f58;
  --alert: #bb1e3e;
  --alert-panel: #fcecef;
  --ok-panel: #e3f4f1;
  --chart-mark: #0d9488;
  --chart-grid: #dde8e6;
  --logo-chip: transparent;
  --code-bg: #f7faf9;
  --radius: 10px;
  --font: "Atkinson Hyperlegible Next", "Atkinson Hyperlegible", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "Atkinson Hyperlegible Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0d1716;
    --panel: #13201e;
    --panel-2: #1b2c29;
    --line: #2c433f;
    --line-strong: #4d6c66;
    --ink: #e6f0ee;
    --ink-2: #a9bdb9;
    --brand: #20a898;
    --action: #5eead4;
    --action-ink: #04302b;
    --action-hover: #99f6e4;
    --link: #7fe0d2;
    --alert: #ff8fa3;
    --alert-panel: #3a1820;
    --ok-panel: #12312c;
    --chart-mark: #20a898;
    --chart-grid: #233633;
    --logo-chip: #ffffff;
    --code-bg: #101b1a;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d1716;
  --panel: #13201e;
  --panel-2: #1b2c29;
  --line: #2c433f;
  --line-strong: #4d6c66;
  --ink: #e6f0ee;
  --ink-2: #a9bdb9;
  --brand: #20a898;
  --action: #5eead4;
  --action-ink: #04302b;
  --action-hover: #99f6e4;
  --link: #7fe0d2;
  --alert: #ff8fa3;
  --alert-panel: #3a1820;
  --ok-panel: #12312c;
  --chart-mark: #20a898;
  --chart-grid: #233633;
  --logo-chip: #ffffff;
  --code-bg: #101b1a;
}

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

/* The hidden attribute always wins over a class that sets display. */
[hidden] { display: none !important; }

html {
  font-size: 118.75%; /* 19px */
  -webkit-text-size-adjust: 100%;
}
@media (min-width: 900px) { html { font-size: 125%; } } /* 20px */

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-family: var(--font);
  line-height: 1.6;
  overflow-wrap: break-word;
}

img, svg { max-width: 100%; }

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

:focus-visible {
  outline: 3px solid var(--brand);
  outline-offset: 3px;
  border-radius: 4px;
}

h1, h2, h3 { line-height: 1.2; margin: 0 0 0.5em; font-weight: 700; }
h1 { font-size: clamp(2rem, 6vw, 3rem); letter-spacing: -0.01em; }
h2 { font-size: 1.55rem; margin-top: 2.2rem; }
h3 { font-size: 1.2rem; margin-top: 1.6rem; }
p, ul, ol { margin: 0 0 1em; }
li { margin-bottom: 0.35em; }
code, kbd, pre, .mono { font-family: var(--mono); }
code {
  font-size: 0.92em;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 0.05em 0.3em;
}
strong { font-weight: 700; }

.skip {
  position: absolute; left: 12px; top: -60px; z-index: 10;
  background: var(--action); color: var(--action-ink); padding: 8px 14px; border-radius: 8px;
}
.skip:focus { top: 12px; }

/* ---------- Header ---------- */

.site-header {
  border-bottom: 1px solid var(--line);
  background: var(--page);
}
.site-header .bar {
  max-width: 1240px;
  margin: 0 auto;
  padding: 12px 16px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 20px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--ink);
  text-decoration: none;
  margin-right: auto;
}
.brand .logo {
  background: var(--logo-chip);
  border-radius: 6px;
  padding: 3px 6px;
  display: inline-flex;
}
.brand img { height: 30px; width: auto; display: block; }
.brand .name { font-weight: 700; line-height: 1.15; font-size: 0.95rem; }
.brand .name small { display: block; font-weight: 400; color: var(--ink-2); font-size: 0.8rem; }

.theme-btn {
  font: inherit;
  font-size: 0.85rem;
  color: var(--ink);
  background: transparent;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 6px 14px;
  min-height: 40px;
  cursor: pointer;
}
.theme-btn:hover { background: var(--panel); }

.site-nav { width: 100%; }
.site-nav ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.site-nav li { margin: 0; }
.site-nav a {
  display: block;
  padding: 8px 14px;
  min-height: 44px;
  border-radius: 8px;
  color: var(--ink);
  text-decoration: none;
  font-weight: 700;
  font-size: 0.95rem;
  border-bottom: 3px solid transparent;
}
.site-nav a:hover { background: var(--panel); }
@media (max-width: 520px) {
  .site-nav ul { gap: 0; justify-content: space-between; }
  .site-nav a { padding: 8px 7px; font-size: 0.84rem; }
  .brand .name { font-size: 0.85rem; }
  .brand img { height: 26px; }
  .theme-btn { font-size: 0.78rem; padding: 4px 10px; min-height: 36px; }
}
.site-nav a[aria-current="page"] {
  border-bottom-color: var(--brand);
  border-radius: 8px 8px 0 0;
}
@media (min-width: 900px) {
  .site-nav { width: auto; }
}

/* ---------- Page frame ---------- */

main { display: block; }
.wrap { max-width: 1240px; margin: 0 auto; padding: 0 16px; }
.prose { max-width: 40em; }
.page-head { padding: 2.2rem 0 0.6rem; }
.page-head p.lead { font-size: 1.15rem; color: var(--ink-2); max-width: 36em; }

.site-footer {
  margin-top: 4rem;
  border-top: 1px solid var(--line);
  color: var(--ink-2);
  font-size: 0.85rem;
}
.site-footer .wrap { padding-top: 1.2rem; padding-bottom: 2rem; }
.site-footer p { margin: 0 0 0.4em; }

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font: inherit;
  font-weight: 700;
  font-size: 1rem;
  line-height: 1.2;
  min-height: 48px;
  padding: 10px 20px;
  border-radius: 10px;
  border: 2px solid var(--action);
  background: var(--action);
  color: var(--action-ink);
  text-decoration: none;
  cursor: pointer;
}
.btn:hover { background: var(--action-hover); border-color: var(--action-hover); }
.btn.quiet {
  background: transparent;
  color: var(--ink);
  border-color: var(--line-strong);
}
.btn.quiet:hover { background: var(--panel); }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }

/* ---------- Home ---------- */

.hero { padding: 2.6rem 0 1rem; }
.hero h1 { max-width: 14em; }
.hero .code { color: var(--ink-2); font-weight: 700; margin-bottom: 0.4rem; }
.hero .lead { font-size: 1.2rem; max-width: 32em; color: var(--ink); }

.next-class {
  margin: 1.4rem 0 0.4rem;
  padding: 14px 18px;
  border-left: 6px solid var(--brand);
  background: var(--panel);
  border-radius: 0 var(--radius) var(--radius) 0;
  max-width: 40em;
}
.next-class p { margin: 0; }
.next-class .when { font-weight: 700; font-size: 1.1rem; }

.doors {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  margin: 1.8rem 0 1rem;
}
@media (min-width: 760px) { .doors { grid-template-columns: repeat(3, 1fr); } }
.door {
  display: block;
  padding: 22px 22px 20px;
  border: 2px solid var(--line-strong);
  border-left: 10px solid var(--brand);
  border-radius: var(--radius);
  color: var(--ink);
  text-decoration: none;
  background: var(--page);
  min-height: 132px;
}
.door:hover { background: var(--panel); border-color: var(--brand); }
.door .door-name { display: block; font-size: 1.7rem; font-weight: 700; line-height: 1.1; margin-bottom: 8px; }
.door .door-what { display: block; color: var(--ink-2); font-size: 1rem; }

.routine {
  list-style: none;
  counter-reset: step;
  padding: 0;
  margin: 1rem 0 1.4rem;
  display: grid;
  grid-template-columns: 1fr;
  gap: 0;
  max-width: 44em;
}
.routine li {
  counter-increment: step;
  display: grid;
  grid-template-columns: 2.4rem 1fr;
  gap: 4px 12px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
  margin: 0;
}
.routine li::before {
  content: counter(step);
  font-weight: 700;
  font-size: 1.3rem;
  color: var(--brand);
  line-height: 1.3;
}
.routine b { display: block; }

.home-cols { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0 56px; }
@media (min-width: 1200px) {
  .home-cols { grid-template-columns: minmax(0, 36em) minmax(0, 1fr); align-items: start; }
  .dates-col { position: sticky; top: 12px; }
}
.after-table { margin-top: 1rem; }
table.dates .tag { white-space: normal; border-radius: 8px; line-height: 1.3; padding: 2px 8px; }
.file-group.piece h2 { font-size: 1.55rem; }
table.dates td { padding-left: 6px; padding-right: 6px; }
.nowrap { white-space: nowrap; }

/* ---------- Tables (reading) ---------- */

.table-scroll { overflow-x: auto; max-width: 100%; -webkit-overflow-scrolling: touch; }
table.plain {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.95rem;
}
table.plain th, table.plain td {
  text-align: left;
  padding: 9px 10px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
table.plain th { font-weight: 700; border-bottom: 2px solid var(--line-strong); }
table.plain tr.is-next td { background: var(--ok-panel); }
table.plain tr.is-past td { color: var(--ink-2); }
.tag {
  display: inline-block;
  font-size: 0.78rem;
  font-weight: 700;
  padding: 1px 8px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  color: var(--ink-2);
  white-space: nowrap;
}
.tag + .tag { margin-left: 6px; }
/* Dates on a phone: one block per session, the tags under the time. */
@media (max-width: 600px) {
  table.dates thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  table.dates tr { display: grid; grid-template-columns: 6.4em 1fr; border-bottom: 1px solid var(--line); padding: 6px 0; }
  table.dates td { border: 0; padding: 2px 6px; }
  table.dates td:nth-child(3) { grid-column: 2; }
  table.dates td.no-tags { display: none; }
  table.dates .tag { white-space: normal; }
}
.tag.ready { border-color: var(--brand); color: var(--ink); background: var(--ok-panel); }

/* ---------- Study ---------- */

.session-list { list-style: none; padding: 0; margin: 1.2rem 0; max-width: 52em; }
.session-list li { margin: 0; border-top: 1px solid var(--line); }
.session-list li:last-child { border-bottom: 1px solid var(--line); }
.session-list a {
  display: grid;
  grid-template-columns: 3.2rem 1fr;
  gap: 2px 14px;
  padding: 14px 6px;
  text-decoration: none;
  color: var(--ink);
}
.session-list a:hover { background: var(--panel); }
.session-list .num { font-size: 1.6rem; font-weight: 700; color: var(--brand); line-height: 1.1; grid-row: span 3; }
.session-list .title { font-weight: 700; line-height: 1.3; }
.session-list .meta { color: var(--ink-2); font-size: 0.9rem; }

.file-group { margin: 1.6rem 0; max-width: 46em; }
.file-group h2 { margin-top: 0; font-size: 1.3rem; }
.files { list-style: none; padding: 0; margin: 0; }
.files li { margin: 0 0 10px; }
.file {
  display: grid;
  grid-template-columns: 5.2rem 1fr;
  gap: 2px 14px;
  align-items: start;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--ink);
  background: var(--page);
}
.file:hover { border-color: var(--brand); background: var(--panel); }
@media (max-width: 520px) {
  .file { grid-template-columns: 4.4rem 1fr; gap: 2px 10px; padding: 10px; }
}
.file .type {
  grid-row: span 2;
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 700;
  text-align: center;
  padding: 6px 4px;
  border-radius: 6px;
  border: 2px solid var(--brand);
  color: var(--ink);
}
.file .label { font-weight: 700; text-decoration: underline; text-decoration-color: var(--brand); text-underline-offset: 0.18em; }
.file .note { color: var(--ink-2); font-size: 0.92rem; }
.file .size { color: var(--ink-2); font-weight: 400; font-size: 0.85rem; white-space: nowrap; }

.callout {
  border: 1px solid var(--line);
  border-left: 6px solid var(--brand);
  background: var(--panel);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 14px 18px;
  margin: 1.2rem 0;
  max-width: 46em;
}
.callout > :last-child { margin-bottom: 0; }
.callout h2, .callout h3 { margin-top: 0; }
.callout.alert { border-left-color: var(--alert); background: var(--alert-panel); }

.pager {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin: 2.4rem 0 0;
  max-width: 46em;
}

/* ---------- Homework ---------- */

.due {
  font-size: 1.25rem;
  font-weight: 700;
  margin: 0.2rem 0 0.4rem;
}
.facts { display: grid; grid-template-columns: 1fr; gap: 0; margin: 1rem 0; max-width: 46em; }
.facts div { display: grid; grid-template-columns: 1fr; padding: 10px 0; border-top: 1px solid var(--line); }
@media (min-width: 640px) { .facts div { grid-template-columns: 9em 1fr; gap: 16px; } }
.facts dt { font-weight: 700; }
.facts dd { margin: 0; }
.submit-box {
  border: 2px dashed var(--line-strong);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin: 1rem 0;
  max-width: 46em;
}
.submit-box.ready { border-style: solid; border-color: var(--brand); }
.submit-box h3 { margin-top: 0; }
.submit-box p:last-child { margin-bottom: 0; }
.later-item { display: grid; gap: 4px; padding: 14px 4px; }
.later-item .title { font-weight: 700; line-height: 1.3; }
.later-item .meta { color: var(--ink-2); font-size: 0.92rem; }

/* ---------- Help ---------- */

.steps-list { padding-left: 1.4em; max-width: 44em; }
.steps-list li { margin-bottom: 0.7em; padding-left: 0.2em; }
.steps-list li::marker { font-weight: 700; color: var(--brand); }
pre.prompt {
  white-space: pre-wrap;
  background: var(--code-bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  font-size: 0.88rem;
  line-height: 1.55;
  max-width: 46em;
  overflow-x: auto;
}
dl.words { max-width: 46em; }
dl.words dt { font-weight: 700; margin-top: 0.8em; }
dl.words dd { margin: 0.1em 0 0; color: var(--ink); }

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}

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