/*
 * Seminario 1: stylesheet.
 *
 * The whole presentation is drawn on a fixed 1920 x 1080 stage that deck.js
 * scales to fit the window, so every size below is in stage pixels and the
 * layout is identical on a 720p projector and a 1080p one. Sizes are chosen
 * for the back row of a classroom: nothing a student has to read is under
 * 24 stage pixels, and no line that carries meaning is thin or pale.
 */

/* ---- Fonts: bundled, never fetched ------------------------------------
 * "Sem Sans" is a composite: Atkinson Hyperlegible Next for the letters, built
 * to be told apart at a distance, and Fira Sans for the ten digits, because
 * Atkinson's zero is slashed and a maths class reads that as another symbol.
 */
@font-face {
  font-family: "Sem Sans";
  src: url(../fonts/atkinson/atkinson-hyperlegible-next-latin-400-normal.woff2) format("woff2");
  font-weight: 400; font-style: normal; font-display: block;
}
@font-face {
  font-family: "Sem Sans";
  src: url(../fonts/fira/fira-sans-latin-400-normal.woff2) format("woff2");
  font-weight: 400; font-style: normal; font-display: block;
  unicode-range: U+0030-0039;
}
@font-face {
  font-family: "Sem Sans";
  src: url(../fonts/atkinson/atkinson-hyperlegible-next-latin-500-normal.woff2) format("woff2");
  font-weight: 500; font-style: normal; font-display: block;
}
@font-face {
  font-family: "Sem Sans";
  src: url(../fonts/fira/fira-sans-latin-500-normal.woff2) format("woff2");
  font-weight: 500; font-style: normal; font-display: block;
  unicode-range: U+0030-0039;
}
@font-face {
  font-family: "Sem Sans";
  src: url(../fonts/atkinson/atkinson-hyperlegible-next-latin-600-normal.woff2) format("woff2");
  font-weight: 600; font-style: normal; font-display: block;
}
@font-face {
  font-family: "Sem Sans";
  src: url(../fonts/fira/fira-sans-latin-600-normal.woff2) format("woff2");
  font-weight: 600; font-style: normal; font-display: block;
  unicode-range: U+0030-0039;
}
@font-face {
  font-family: "Sem Sans";
  src: url(../fonts/atkinson/atkinson-hyperlegible-next-latin-700-normal.woff2) format("woff2");
  font-weight: 700; font-style: normal; font-display: block;
}
@font-face {
  font-family: "Sem Sans";
  src: url(../fonts/fira/fira-sans-latin-700-normal.woff2) format("woff2");
  font-weight: 700; font-style: normal; font-display: block;
  unicode-range: U+0030-0039;
}
@font-face {
  font-family: "Sem Sans";
  src: url(../fonts/atkinson/atkinson-hyperlegible-next-latin-800-normal.woff2) format("woff2");
  font-weight: 800; font-style: normal; font-display: block;
}
@font-face {
  font-family: "Sem Sans";
  src: url(../fonts/fira/fira-sans-latin-800-normal.woff2) format("woff2");
  font-weight: 800; font-style: normal; font-display: block;
  unicode-range: U+0030-0039;
}
@font-face {
  font-family: "Sem Sans";
  src: url(../fonts/atkinson/atkinson-hyperlegible-next-latin-400-italic.woff2) format("woff2");
  font-weight: 400; font-style: italic; font-display: block;
}

:root {
  /* UPF identity, from settings.tex and the logo */
  --paper: #ffffff;
  --mist: #e6e9ee;
  --mist-2: #f2f4f7;
  --ink: #202326;
  --ink-2: #4a5158;
  --navy: #173459;
  --red: #c8102e;

  /* One meaning each, all session */
  --fn: #1d5aa8;       /* the function, the preferences */
  --lim: #c8102e;      /* the constraint */
  --slope: #007f5f;    /* slopes, tangents, anything marginal */
  --second: #9333ea;   /* the second measure */

  --grid: #c2c9d2;
  --rule: #b4bcc6;

  --sans: "Sem Sans", "Segoe UI", system-ui, sans-serif;
  --math: KaTeX_Math, "Times New Roman", serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--navy);
  color: var(--ink);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
}

#viewport { position: fixed; inset: 0; overflow: hidden; background: var(--navy); }

#stage {
  position: absolute; left: 0; top: 0;
  width: 1920px; height: 1080px;
  transform-origin: 0 0;
  background: var(--paper);
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
}

.off { opacity: 0 !important; pointer-events: none !important; }
.gone { display: none !important; }
.fade { transition: opacity 320ms ease; }

i.v { font-family: var(--math); font-style: italic; font-size: 1.08em; }
b { font-weight: 700; }
/* A formula never breaks across lines: split after its "=", it reads as two. */
.katex .katex-html { white-space: nowrap; }

/* ---- Route bar: where we are in the session ---------------------------- */
#route {
  position: absolute; left: 0; top: 0; width: 1920px; height: 56px;
  background: var(--navy);
  display: flex; align-items: stretch;
  padding: 0 20px 0 28px;
  font-size: 24px; font-weight: 500;
  color: #fff;
}
#route .sec {
  position: relative;
  display: flex; align-items: center; gap: 10px;
  padding: 0 18px;
  color: rgba(255, 255, 255, 0.72);
  cursor: pointer;
  border: 0; background: none; font: inherit;
}
#route .sec:hover { color: #fff; }
#route .sec .n { font-weight: 700; font-variant-numeric: tabular-nums; }
#route .sec.cur { color: #fff; font-weight: 700; }
#route .sec.cur::after {
  content: ""; position: absolute; left: 12px; right: 12px; bottom: 0; height: 6px;
  background: #fff;
}
#route .sep {
  align-self: center; margin: 0 14px 0 16px; padding-left: 18px;
  border-left: 2px solid rgba(255, 255, 255, 0.4);
  font-size: 21px; font-weight: 400; color: rgba(255, 255, 255, 0.72);
  white-space: nowrap; line-height: 28px;
}
#route .gap { flex: 1; }
#route .aux {
  display: flex; align-items: center; gap: 22px;
  font-size: 21px; font-weight: 400; color: rgba(255, 255, 255, 0.72);
  font-variant-numeric: tabular-nums;
}
#route .aux button {
  font: inherit; color: inherit; background: none; cursor: pointer;
  border: 2px solid rgba(255, 255, 255, 0.45); border-radius: 6px;
  padding: 2px 12px; line-height: 28px;
}
#route .aux button:hover { color: #fff; border-color: #fff; }
#clock { min-width: 64px; text-align: right; }

/* ---- The band: the question for the room ------------------------------- */
#band {
  position: absolute; left: 0; top: 56px; width: 1920px; height: 132px;
  background: var(--paper);
  border-bottom: 3px solid var(--mist);
  display: flex; align-items: center;
  padding: 0 64px;
}
#band .q {
  font-size: 44px; line-height: 52px; font-weight: 700;
  color: var(--navy);
  letter-spacing: -0.005em;
  max-width: 1792px;
  text-wrap: balance;           /* a two-line question breaks near its middle, never before its last word */
}
/* A hidden twin of the question, used to measure how wide a sentence sets. */
#band .q.measure {
  position: absolute; left: 0; top: 0; visibility: hidden; pointer-events: none;
  white-space: nowrap; max-width: none;
}
#band .q .katex { font-size: 1.02em; }

/* ---- Figure and panel --------------------------------------------------- */
#fig {
  position: absolute; left: 0; top: 188px; width: 1240px; height: 892px;
  background: var(--paper);
  overflow: hidden;
}
#panel {
  position: absolute; left: 1240px; top: 188px; width: 680px; height: 892px;
  background: var(--mist);
  padding: 30px 44px 20px 44px;
  display: flex; flex-direction: column;
}
#ans {
  font-size: 34px; line-height: 44px; font-weight: 400;
  color: var(--ink);
  min-height: 44px;
}
#ans .katex { font-size: 1.04em; }
#ans p { margin: 0 0 14px 0; }
#ans p:last-child { margin-bottom: 0; }
#known, #ans, #live, #controls, #foot { flex: none; }
#known { margin-bottom: 18px; }
#known:empty { display: none; }
#live { margin-top: 22px; }
#live:empty { display: none; }
#grow { flex: 1; min-height: 8px; }
#controls { display: flex; flex-direction: column; gap: 14px; }
#controls:empty { display: none; }

#foot {
  margin-top: 16px; padding-top: 14px;
  border-top: 2px solid var(--rule);
  display: flex; align-items: center; gap: 18px;
  font-size: 22px; color: var(--ink-2);
  font-variant-numeric: tabular-nums;
}
#dots { display: flex; gap: 10px; flex: 1; flex-wrap: wrap; }
#dots button {
  width: 18px; height: 18px; border-radius: 50%; padding: 0;
  border: 3px solid var(--navy); background: transparent; cursor: pointer;
}
#dots button.done { background: var(--navy); }
#dots button.cur { background: var(--navy); outline: 3px solid var(--navy); outline-offset: 3px; }
#foot .nav {
  font: inherit; font-size: 26px; line-height: 1; cursor: pointer;
  width: 52px; height: 44px; border-radius: 6px;
  border: 2px solid var(--navy); background: transparent; color: var(--navy);
}
#foot .nav:hover { background: var(--navy); color: #fff; }

/* Full-stage layout (title screen): the figure takes everything below the route bar. */
#stage.full #band, #stage.full #panel { display: none; }
#stage.full #fig { top: 56px; width: 1920px; height: 1024px; }

/* ---- Panel pieces -------------------------------------------------------- */
/* RMS against RMT: two columns, one row per step. */
.versus { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 22px; }
.versus .vh { font-size: 30px; font-weight: 700; color: var(--ink); padding-bottom: 6px; border-bottom: 2px solid var(--rule); }
.versus .vh .key { display: inline-block; width: 16px; height: 16px; border-radius: 50%; margin-right: 10px; vertical-align: 2px; }
.versus .vc { font-size: 26px; line-height: 34px; color: var(--ink); }
.known tr:nth-child(odd):not(:first-child) > * { padding-top: 8px; }

/* What the room knows when a question is asked: a white card on the grey panel. */
.known { background: var(--paper); border-radius: 10px; padding: 10px 18px 8px; }
.known .kh { margin: 0 0 2px 0; font-size: 22px; line-height: 28px; font-weight: 700; color: var(--ink-2); }
.known ul { list-style: none; margin: 0; padding: 0; }
.known li { font-size: 28px; line-height: 38px; color: var(--ink); }
.known li .katex { font-size: 1.04em; }
.known table { border-collapse: collapse; font-size: 24px; line-height: 34px; font-variant-numeric: tabular-nums; margin: 2px 0 6px; }
.known th { text-align: left; font-weight: 600; color: var(--ink-2); padding: 0 14px 0 0; }
.known td { text-align: right; padding: 0 0 0 12px; min-width: 34px; }
.eq { font-size: 38px; line-height: 1.25; color: var(--ink); margin: 0 0 16px 0; min-height: 48px; }
.eq .katex-display { margin: 0; text-align: left; }
.eq .katex-display > .katex { text-align: left; }
.eq.small { font-size: 32px; }

.ro { display: flex; align-items: baseline; gap: 16px; margin: 0 0 12px 0; }
.ro .key {
  flex: none; width: 22px; height: 22px; border-radius: 50%; align-self: center;
  background: var(--ink);
}
.ro .nm { font-size: 28px; line-height: 36px; font-weight: 500; color: var(--ink); flex: 1; }
.ro .val {
  font-size: 40px; line-height: 44px; font-weight: 700;
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.ro .val small { font-size: 26px; font-weight: 500; color: var(--ink-2); }
.ro.big .val { font-size: 52px; line-height: 56px; }

/* A derivation that grows one line per step */
.deriv { margin: 0; padding: 0; list-style: none; }
.deriv li {
  display: flex; gap: 14px; align-items: baseline;
  font-size: 28px; line-height: 36px; color: var(--ink);
  padding: 12px 0; border-top: 2px solid var(--rule);
}
.deriv li:first-child { border-top: 0; padding-top: 0; }
.deriv li .why { flex: none; width: 196px; color: var(--ink-2); font-size: 27px; line-height: 34px; }
.deriv li .what { flex: 1; font-size: 35px; line-height: 44px; }
.deriv li .what .katex { font-size: 1em; }
.deriv li.now .why { color: var(--ink); font-weight: 700; }
.deriv li.wait { display: none; }
.deriv.wide li .why { width: 250px; }
.deriv.stack li { flex-direction: column; gap: 2px; padding: 10px 0; }
.deriv.stack li .why { width: auto; }
.deriv.stack li .what { font-size: 33px; line-height: 46px; }

/* Gauge: a value, its bar, and the highest point it has reached */
.gauge .ro { margin-bottom: 6px; }
.gtrack { position: relative; height: 26px; background: #fff; border: 2px solid var(--ink); border-radius: 4px; }
.gfill { position: absolute; left: 0; top: 0; bottom: 0; background: var(--fn); }
.gmark { position: absolute; top: -8px; bottom: -8px; width: 6px; margin-left: -3px; background: var(--ink); border-radius: 3px; }
.gnote { display: flex; align-items: center; gap: 10px; font-size: 24px; line-height: 30px; color: var(--ink-2); margin-top: 10px; }
.gkey { display: inline-block; width: 6px; height: 22px; background: var(--ink); border-radius: 3px; }

.points { list-style: none; margin: 0; padding: 0; }
.points li { font-size: 32px; line-height: 42px; padding: 14px 0; border-top: 2px solid var(--rule); }
.points li:first-child { border-top: 0; padding-top: 0; }
.points li .katex { font-size: 1.02em; }

/* Options the room votes on */
.opts { list-style: none; margin: 0; padding: 0; }
.opts li {
  display: flex; gap: 16px; align-items: baseline;
  font-size: 32px; line-height: 42px; padding: 7px 0;
}
.opts li .tag {
  flex: none; width: 46px; height: 46px; border-radius: 50%;
  border: 3px solid var(--ink); font-weight: 700; font-size: 28px;
  display: flex; align-items: center; justify-content: center; align-self: flex-start;
}
.opts li.right .tag { background: var(--ink); color: #fff; }
.opts li.wrong { color: var(--ink-2); text-decoration: line-through; text-decoration-thickness: 2px; }
.opts li.wrong .tag { border-color: var(--ink-2); }

/* Slider: a custom one, so the arrow keys always belong to the deck */
.sl { }
.sl .row { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; }
.sl .name { font-size: 28px; line-height: 36px; color: var(--ink); }
.sl .value { font-size: 34px; line-height: 36px; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.sl .value small { font-size: 24px; font-weight: 500; color: var(--ink-2); }
.sl .track {
  position: relative; height: 50px; margin-top: 0; cursor: pointer; touch-action: none;
}
.sl .rail {
  position: absolute; left: 0; right: 0; top: 21px; height: 10px; border-radius: 5px;
  background: #fff; border: 2px solid var(--ink);
}
.sl .fill { position: absolute; left: 0; top: 21px; height: 10px; border-radius: 5px; background: var(--ink); }
.sl .thumb {
  position: absolute; top: 4px; width: 44px; height: 44px; margin-left: -22px; border-radius: 50%;
  background: var(--ink); border: 5px solid #fff; box-shadow: 0 0 0 2px var(--ink);
}
.sl .track:hover .thumb, .sl .track.dragging .thumb { transform: scale(1.1); }
.sl .ticks { position: absolute; left: 0; right: 0; top: 34px; height: 12px; pointer-events: none; }
.sl .ticks i { position: absolute; top: 0; width: 2px; height: 10px; margin-left: -1px; background: var(--ink-2); }

/* Segmented buttons and plain buttons */
.seg { display: flex; flex-wrap: wrap; gap: 0; }
.seg .cap { width: 100%; font-size: 26px; line-height: 34px; color: var(--ink); margin-bottom: 6px; }
.btn { align-self: flex-start; }
.seg button, .btn {
  font: inherit; font-size: 27px; font-weight: 600; line-height: 30px;
  padding: 11px 20px; cursor: pointer;
  color: var(--navy); background: #fff;
  border: 3px solid var(--navy);
}
.seg button { margin-right: -3px; flex: 1 1 auto; white-space: nowrap; }
.seg button:first-of-type { border-radius: 8px 0 0 8px; }
.seg button:last-of-type { border-radius: 0 8px 8px 0; margin-right: 0; }
.seg button.on { background: var(--navy); color: #fff; }
.btn { border-radius: 8px; }
.btn:hover, .seg button:hover { background: var(--mist-2); }
.seg button.on:hover { background: var(--navy); }

.hint { font-size: 25px; line-height: 32px; color: var(--ink-2); margin: 0; }

.row2 { display: flex; gap: 36px; align-items: center; flex-wrap: wrap; }
.row2 .eq { margin-bottom: 10px; }

/* Panel pieces appear with one short fade, when they are first shown. */
#live > *, #controls > *, .row2 > * { animation: appear 300ms ease both; }
@keyframes appear { from { opacity: 0; } to { opacity: 1; } }

/* ---- SVG figures --------------------------------------------------------- */
svg.plot { position: absolute; left: 0; top: 0; display: block; overflow: visible; }
svg.plot text { font-family: var(--sans); fill: var(--ink); }
svg.plot .var { font-family: var(--math); font-style: italic; font-size: 1.1em; }
.tick { font-size: 26px; fill: var(--ink-2) !important; font-variant-numeric: tabular-nums; }
.axt { font-size: 28px; font-weight: 600; }
/* The white outline that keeps a label readable over lines and fills. It is
   made from the whole label at once (the filter is in index.html): a stroke
   is painted piece by piece, and the outline of an italic x would rub out
   the 3 before it. */
.lab {
  font-size: 30px; font-weight: 700;
  filter: url(#lab-halo);
}
.lab.sm { font-size: 26px; }
.lab.lg { font-size: 36px; }
.lab.plain { filter: none; }
.gridl { stroke: var(--grid); stroke-width: 2; }
.gridl.strong { stroke: #a9b2bd; }
.axis { stroke: var(--ink); stroke-width: 3.5; fill: none; stroke-linecap: square; }
.tk { stroke: var(--ink); stroke-width: 3; }
.curve { fill: none; stroke-width: 7; stroke-linecap: round; stroke-linejoin: round; }
.thin { stroke-width: 4; }
.dash { stroke-dasharray: 14 12; }
.guide { stroke: var(--ink-2); stroke-width: 3; stroke-dasharray: 5 9; stroke-linecap: round; fill: none; }
.ring { stroke: #fff; stroke-width: 5; paint-order: stroke; }

.handle { cursor: grab; }
.handle.dragging { cursor: grabbing; }
.handle .hit { fill: transparent; }
.handle .knob { stroke: #fff; stroke-width: 5; transition: r 120ms ease; }
.handle .halo { fill: none; stroke-width: 3; opacity: 0.55; }
.handle:hover .knob, .handle.dragging .knob { r: 19px; }

/* 3D canvases */
.s3d { position: absolute; }
.s3d canvas { display: block; cursor: grab; touch-action: none; }
.s3d canvas.dragging { cursor: grabbing; }

/* ---- Title screen -------------------------------------------------------- */
.title { position: absolute; inset: 0; }
.title .logo { position: absolute; left: 96px; top: 76px; width: 520px; height: auto; display: block; }
.title .words { position: absolute; left: 96px; top: 268px; width: 1560px; }
.title .course { font-size: 44px; line-height: 52px; font-weight: 500; color: var(--ink-2); margin: 0 0 22px 0; }
.title h1 {
  font-size: 176px; line-height: 168px; font-weight: 800; letter-spacing: -0.025em;
  color: var(--navy); margin: 0 0 46px -7px;
  text-wrap: balance;
}
.title .who { font-size: 44px; line-height: 54px; font-weight: 600; color: var(--ink); margin: 0; }
.title .who span { display: block; color: var(--ink-2); font-weight: 400; }
/* The reference, set as a footnote: a short rule, then small type. */
.title .src {
  position: absolute; left: 96px; bottom: 44px; width: 1640px; margin: 0;
  font-size: 27px; line-height: 36px; color: var(--ink-2);
}
.title .src::before { content: ""; display: block; width: 140px; height: 3px; background: var(--rule); margin-bottom: 16px; }
.nw { white-space: nowrap; }
.kbd {
  display: inline-block; min-width: 40px; padding: 2px 12px; margin: 0 4px;
  border: 2px solid var(--ink-2); border-bottom-width: 5px; border-radius: 8px;
  font-size: 0.92em; font-weight: 600; text-align: center; color: var(--ink);
  background: #fff;
}

/* ---- Overlays: menu, blank screen ---------------------------------------- */
#menu {
  position: absolute; left: 0; top: 56px; width: 1920px; height: 1024px;
  background: var(--paper);
  padding: 40px 56px 32px 64px;
  display: flex; gap: 48px;
  z-index: 20;
}
#menu .cols { flex: 1; display: grid; grid-template-columns: repeat(3, 1fr); gap: 28px 44px; align-content: start; }
#menu .card { border-top: 6px solid var(--navy); padding-top: 12px; }
#menu .card.opt { border-top-color: var(--rule); }
#menu .card h3 {
  margin: 0 0 8px 0; font-size: 30px; line-height: 36px; font-weight: 700; color: var(--navy);
  display: flex; gap: 12px; align-items: baseline;
}
#menu .card h3 .min { margin-left: auto; font-size: 22px; font-weight: 500; color: var(--ink-2); white-space: nowrap; }
#menu .card button {
  display: block; width: 100%; text-align: left;
  font: inherit; font-size: 25px; line-height: 32px; color: var(--ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  background: none; border: 0; padding: 4px 8px; margin: 0 -8px; border-radius: 6px; cursor: pointer;
}
#menu .card button:hover { background: var(--mist); }
#menu .card button.cur { background: var(--navy); color: #fff; }
#menu .keys { flex: none; width: 600px; border-left: 3px solid var(--mist); padding-left: 40px; }
#menu .keys h3 { margin: 0 0 14px 0; font-size: 30px; color: var(--navy); }
#menu .keys dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 16px 20px; font-size: 24px; line-height: 32px; align-items: center; }
#menu .keys .kbd { font-size: 22px; min-width: 38px; padding: 1px 9px; margin: 0 2px; }
#menu .keys dt { white-space: nowrap; }
#menu .keys dd { margin: 0; color: var(--ink); }
#menu .keys p { font-size: 22px; line-height: 30px; color: var(--ink-2); margin: 22px 0 0 0; }

#blank { position: absolute; inset: 0; background: #000; z-index: 40; }

#oops {
  position: absolute; left: 24px; bottom: 24px; z-index: 30; max-width: 1100px;
  background: #fff; border: 3px solid var(--red); border-radius: 8px;
  padding: 12px 18px; font-size: 22px; line-height: 28px; color: var(--ink);
}

@media (prefers-reduced-motion: reduce) {
  .fade { transition: none; }
  #live > *, #controls > *, .row2 > * { animation: none; }
}
