/* Near-monochrome so the video or paper is the only colour on screen. */
:root {
  --paper: #f4f4f2;
  --surface: #ffffff;
  --track: #e9e9e6;
  --ink: #1f2124;
  --graphite: #6b6f75;
  --rule: #e1e2df;
  --stage: #1d1f22;
  --below-bar: calc(100vh - 4rem);
  --sans: "Geist", system-ui, sans-serif;
  --mono: "Geist Mono", ui-monospace, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #1b1c1f;
    --surface: #34373c;
    --track: #26282c;
    --ink: #e7e8e9;
    --graphite: #979ca3;
    --rule: #2d2f33;
    --stage: #121315;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --paper: #1b1c1f;
  --surface: #34373c;
  --track: #26282c;
  --ink: #e7e8e9;
  --graphite: #979ca3;
  --rule: #2d2f33;
  --stage: #121315;
  color-scheme: dark;
}

* { box-sizing: border-box; }

/* No rubber-band bounce when scrolling past the edges */
html, body, .details { overscroll-behavior: none; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--paper);
  color: var(--ink);
  font: 400 1rem/1.5 var(--sans);
}

[hidden] { display: none !important; }

a { color: inherit; text-underline-offset: 0.2em; }

button { font: inherit; color: inherit; cursor: pointer; }

:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }

/* Header */

.bar {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 0.75rem 1.5rem;
  border-bottom: 1px solid var(--rule);
}

/* One weight for the whole name so it reads as one font; Focus stands out by colour */
.wordmark {
  font: 700 1.0625rem/1 var(--mono);
  letter-spacing: -0.02em;
  color: var(--graphite);
  text-decoration: none;
}

.wordmark strong { font-weight: inherit; color: var(--ink); }

.modes {
  display: flex;
  margin-left: auto;
  background: var(--track);
  border-radius: 999px;
  padding: 3px;
}

.modes button {
  border: 0;
  background: none;
  padding: 0.3rem 0.9rem;
  border-radius: 999px;
  font-size: 0.875rem;
  color: var(--graphite);
}

.modes button[aria-pressed="true"] {
  background: var(--surface);
  color: var(--ink);
  font-weight: 600;
}

.links { display: flex; gap: 1.25rem; }

.link {
  border: 0;
  background: none;
  padding: 0.3rem 0;
  font-size: 0.875rem;
  color: var(--graphite);
  text-decoration: underline;
  text-underline-offset: 0.2em;
}

/* Focus view: the item fills a dark stage, details sit beside it */

#focus {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 24rem;
}

.stage {
  background: var(--stage);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
}

.stage iframe {
  display: block;
  width: 100%;
  border: 0;
  background: var(--stage);
}

#focus[data-kind="video"] .stage iframe { height: auto; aspect-ratio: 16 / 9; max-height: var(--below-bar); }
#focus[data-kind="paper"] .stage iframe { height: var(--below-bar); }

.details {
  display: flex;
  flex-direction: column;
  padding: 2rem 1.75rem;
  border-left: 1px solid var(--rule);
  overflow-y: auto;
  max-height: var(--below-bar);
}

.details h1 {
  font: 600 1.625rem/1.2 var(--sans);
  letter-spacing: -0.025em;
  margin: 0 0 0.5rem;
  text-wrap: balance;
}

.by { margin: 0 0 1.5rem; color: var(--graphite); font-size: 0.9375rem; }

.summary { font-size: 1.0625rem; line-height: 1.6; margin: 0 0 1.5rem; }

.details h2 { font-size: 0.875rem; font-weight: 600; margin: 0 0 0.25rem; }

.why { line-height: 1.6; margin: 0 0 1.5rem; color: var(--graphite); }

.filed { color: var(--graphite); font-size: 0.8125rem; margin: 0 0 2rem; }

.done {
  margin-top: auto;
  border: 0;
  border-radius: 10px;
  background: var(--ink);
  color: var(--paper);
  font-size: 1.1875rem;
  font-weight: 600;
  padding: 1rem 1.5rem;
}

/* While Done is locked, a thin line along its bottom fills as the wait runs down */
.done:disabled {
  cursor: not-allowed;
  color: var(--graphite);
  background:
    linear-gradient(var(--ink), var(--ink)) left bottom / var(--progress, 0%) 3px no-repeat,
    var(--track);
}

.open { margin-top: 0.9rem; text-align: center; font-size: 0.875rem; color: var(--graphite); }

/* Shown when Videos/Papers/Shuffle or topics changed; sits just above Done */
.next { margin: auto 0 0.75rem; text-align: center; font-size: 0.8125rem; color: var(--graphite); }
.next:not([hidden]) + .done { margin-top: 0; }

/* One crossfade when the next item arrives */

.arriving .stage, .arriving .details > * { animation: arrive 360ms ease-out; }

@keyframes arrive { from { opacity: 0; } to { opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
  .arriving .stage, .arriving .details > * { animation: none; }
}

/* Topic picker, history and empty state */

.picker, .empty, .history {
  flex: 1;
  width: 100%;
  max-width: 62rem;
  margin: 0 auto;
  padding: 3rem 1.5rem;
}

.picker h1, .empty h1, .history h1 {
  font: 600 2.5rem/1.1 var(--sans);
  letter-spacing: -0.035em;
  margin: 0 0 1rem;
}

.lede, .empty p { font-size: 1.125rem; line-height: 1.6; max-width: 36em; margin: 0 0 2.5rem; color: var(--graphite); }

/* 19rem fits the longest topic name on one line; equal rows keep the grid even if one still wraps */
.areas {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(19rem, 100%), 1fr));
  grid-auto-rows: 1fr;
  gap: 0.6rem;
  margin-bottom: 2.5rem;
}

.areas button {
  text-align: left;
  border: 1px solid var(--rule);
  border-radius: 10px;
  background: none;
  padding: 0.8rem 1rem;
}

.areas button[aria-pressed="true"] {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--paper);
}

.areas .name { display: block; font-weight: 600; }

.areas .count { display: block; font-size: 0.8125rem; opacity: 0.7; }

.picker .done, .empty .done { min-width: 12rem; }

.back {
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: none;
  padding: 0.35rem 1rem;
  margin-bottom: 1.5rem;
  font-size: 0.875rem;
}

.history-list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--rule); }

.history-list li {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1.5rem;
  padding: 0.9rem 0;
  border-bottom: 1px solid var(--rule);
}

.history-list a { font-weight: 600; text-decoration: none; }
.history-list a:hover { text-decoration: underline; }

.history-list .source, .history-list time { color: var(--graphite); font-size: 0.875rem; }
.history-list time { white-space: nowrap; }

/* Phones and narrow windows: details move under the stage */

@media (max-width: 52rem) {
  .bar { flex-wrap: wrap; gap: 0.75rem 1rem; padding: 0.75rem 1rem; }
  .modes { order: 3; margin-left: 0; width: 100%; justify-content: space-between; }
  .modes button { flex: 1; }
  .links { margin-left: auto; }
  #focus { grid-template-columns: 1fr; }
  .details { border-left: 0; max-height: none; padding: 1.5rem 1rem 2rem; }
  .done { margin-top: 0.5rem; }
  /* Phone browsers can't show a whole PDF inside a page, so papers open on arXiv instead. */
  #focus[data-kind="paper"] .stage { display: none; }
  #focus[data-kind="paper"] .open {
    order: 1;
    margin: 0 0 0.75rem;
    padding: 1rem;
    border: 1px solid var(--rule);
    border-radius: 10px;
    color: var(--ink);
    font-weight: 600;
    font-size: 1rem;
    text-decoration: none;
  }
  #focus[data-kind="paper"] .done { order: 2; }
  .picker, .empty, .history { padding: 2rem 1rem; }
  .picker h1, .empty h1, .history h1 { font-size: 2rem; }
}
