/* Triforce Archive. One bold idea: the three hosts as three colours (the mark, their names in
   answers). Everything else stays quiet so the answers carry the page. */

@font-face {
  font-family: "Bricolage Grotesque";
  src: url("/static/fonts/bricolage-grotesque.woff2") format("woff2");
  font-weight: 700;
  font-display: swap;
}
@font-face {
  font-family: "Atkinson Hyperlegible";
  src: url("/static/fonts/atkinson-hyperlegible-400.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "Atkinson Hyperlegible";
  src: url("/static/fonts/atkinson-hyperlegible-700.woff2") format("woff2");
  font-weight: 700;
  font-display: swap;
}

:root {
  --paper: #f2f4f1;
  --surface: #ffffff;
  --ink: #1c2230;
  --muted: #5b6475;
  --line: #d5dad2;
  --lewis: #2f6feb;
  --sips: #b37f00;      /* mustard, darkened for text contrast; the mark uses #d99a00 */
  --sips-mark: #d99a00;
  --pyrion: #c2366b;
  --focus: #2f6feb;
  --display: "Bricolage Grotesque", ui-rounded, system-ui, sans-serif;
  --body: "Atkinson Hyperlegible", system-ui, sans-serif;
  --step--1: 0.875rem;
  --step-0: 1.0625rem;
  --step-1: 1.25rem;
  --step-2: 1.75rem;
  --step-3: 2.75rem;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #151a24;
    --surface: #1d2431;
    --ink: #e8ebf0;
    --muted: #9aa3b2;
    --line: #2e3646;
    --lewis: #6e9cff;
    --sips: #f0b93a;
    --pyrion: #ef6a9b;
    --focus: #6e9cff;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--paper);
  color: var(--ink);
  font: var(--step-0)/1.55 var(--body);
}
h1, h2, h3 { font-family: var(--display); font-weight: 700; line-height: 1.1; letter-spacing: -0.015em; margin: 0 0 0.5em; }
a { color: var(--lewis); }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
[hidden] { display: none !important; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }

/* --- top bar ------------------------------------------------------------------------------- */
.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem clamp(1rem, 3vw, 2rem);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 0.6rem; color: inherit; text-decoration: none; }
.mark { width: 2rem; height: auto; }
.t-lewis { fill: var(--lewis); }
.t-sips { fill: var(--sips-mark); }
.t-pyrion { fill: var(--pyrion); }
.wordmark { font: 700 var(--step-1)/1 var(--display); letter-spacing: -0.02em; }
.bar-right { display: flex; align-items: center; gap: 0.75rem; }
.quota { color: var(--muted); font-size: var(--step--1); }
.quota-out { color: var(--pyrion); }
.kofi {
  font-size: var(--step--1);
  font-weight: 700;
  text-decoration: none;
  color: var(--ink);
  padding: 0.4rem 0.8rem;
  border: 2px solid var(--sips-mark);
  border-radius: 999px;
}
.kofi:hover { background: var(--sips-mark); color: #1c2230; }

.account { position: relative; }
.account summary {
  list-style: none;
  width: 2.25rem; height: 2.25rem;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--ink); color: var(--paper);
  font-weight: 700;
  cursor: pointer;
}
.account summary::-webkit-details-marker { display: none; }
.menu {
  position: absolute; right: 0; top: calc(100% + 0.5rem); z-index: 10;
  min-width: 14rem;
  display: flex; flex-direction: column;
  padding: 0.5rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 10px 30px rgb(28 34 48 / 0.18);
}
.menu-email { margin: 0.25rem 0.5rem 0.5rem; color: var(--muted); font-size: var(--step--1); overflow-wrap: anywhere; }
.menu button, .menu a {
  text-align: left; padding: 0.5rem; border: 0; background: none; border-radius: 6px;
  color: var(--ink); text-decoration: none;
}
.menu button:hover, .menu a:hover { background: var(--paper); }
.icon-button { display: none; border: 0; background: none; padding: 0.25rem; }
.icon-button svg { width: 1.5rem; height: 1.5rem; stroke: currentColor; stroke-width: 2; fill: none; }

/* --- logged out ---------------------------------------------------------------------------- */
.welcome {
  flex: 1;
  width: min(68rem, 100%);
  margin: 0 auto;
  padding: clamp(2rem, 8vw, 6rem) clamp(1rem, 3vw, 2rem);
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  gap: clamp(2rem, 6vw, 5rem);
  align-items: start;
}
.intro h1 { font-size: clamp(2.25rem, 6vw, 4rem); max-width: 12ch; }
.intro p { max-width: 38rem; font-size: var(--step-1); color: var(--muted); }
.intro .coverage { font-size: var(--step-0); color: var(--ink); border-left: 4px solid var(--lewis); padding-left: 0.8rem; }

.auth { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 1.5rem; }
.tabs { display: flex; gap: 1.25rem; margin-bottom: 1.25rem; }
.tabs button {
  border: 0; background: none; padding: 0 0 0.3rem;
  font: 700 var(--step-1)/1.2 var(--display);
  color: var(--muted);
  border-bottom: 3px solid transparent;
}
.tabs button[aria-selected="true"] { color: var(--ink); border-color: var(--pyrion); }
form label { display: flex; flex-direction: column; gap: 0.3rem; margin-bottom: 1rem; font-weight: 700; font-size: var(--step--1); }
input[type="email"], input[type="password"], input[type="number"] {
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  font-weight: 400;
  font-size: var(--step-0);
}
.hint { color: var(--muted); font-size: var(--step--1); margin: -0.25rem 0 1rem; }
.error { color: var(--pyrion); font-size: var(--step--1); min-height: 1.2em; margin: 0 0 0.75rem; }
.primary {
  padding: 0.7rem 1.2rem;
  border: 0;
  border-radius: 8px;
  background: var(--ink);
  color: var(--paper);
  font-weight: 700;
}
.primary:disabled { opacity: 0.5; cursor: progress; }
.auth .primary { width: 100%; }

/* --- logged in ----------------------------------------------------------------------------- */
.app { flex: 1; display: grid; grid-template-columns: 17rem 1fr; min-height: 0; }
.sidebar {
  border-right: 1px solid var(--line);
  padding: 1rem;
  overflow-y: auto;
  max-height: calc(100dvh - 4rem);
  position: sticky; top: 0;
}
.new-chat {
  width: 100%;
  padding: 0.6rem;
  border: 1px dashed var(--muted);
  border-radius: 8px;
  background: none;
  font-weight: 700;
  margin-bottom: 1rem;
}
.sidebar ul { list-style: none; margin: 0; padding: 0; }
.sidebar li { display: flex; align-items: center; border-radius: 6px; }
.sidebar li.current { background: var(--surface); }
.conv-open {
  flex: 1; min-width: 0;
  text-align: left; border: 0; background: none;
  padding: 0.45rem 0.5rem;
  font-size: var(--step--1);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.conv-delete { border: 0; background: none; color: var(--muted); padding: 0.25rem 0.5rem; font-size: 1.1rem; visibility: hidden; }
.sidebar li:hover .conv-delete, .conv-delete:focus-visible { visibility: visible; }

.chat {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 0 clamp(1rem, 3vw, 2rem);
}
.thread { flex: 1; width: min(46rem, 100%); margin: 0 auto; padding: 2rem 0 1rem; }
.empty { padding-top: clamp(1rem, 8vh, 5rem); }
.empty h1 { font-size: var(--step-3); }
.empty p { color: var(--muted); max-width: 34rem; }
.examples { display: flex; flex-direction: column; align-items: flex-start; gap: 0.5rem; margin-top: 1.5rem; }
.example {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 999px;
  padding: 0.5rem 1rem;
  text-align: left;
}
.example:hover { border-color: var(--ink); }

.question {
  margin: 2rem 0 0.75rem auto;
  width: fit-content;
  max-width: 85%;
  padding: 0.6rem 1rem;
  background: var(--ink);
  color: var(--paper);
  border-radius: 14px 14px 4px 14px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.answer { max-width: 70ch; }
.answer p, .answer ul, .answer ol { margin: 0 0 0.8em; }
.answer li { margin-bottom: 0.3em; }
.answer h3 { font-size: var(--step-1); margin-top: 1em; }
.answer.notice { color: var(--muted); border-left: 4px solid var(--sips-mark); padding-left: 0.9rem; }
.status { color: var(--muted); font-style: italic; margin: 0; }
.answer.pending .status::before {
  content: "";
  display: inline-block;
  width: 0.7em; height: 0.6em;
  margin-right: 0.5em;
  background: conic-gradient(var(--lewis) 0 33%, var(--sips-mark) 0 66%, var(--pyrion) 0);
  clip-path: polygon(50% 0, 100% 100%, 0 100%);
  animation: spin 1.2s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* host names and episode citations inside answers */
.host { font-weight: 700; }
.host-lewis { color: var(--lewis); }
.host-sips { color: var(--sips); }
.host-pyrion { color: var(--pyrion); }
.cite {
  display: inline;
  font-size: var(--step--1);
  padding: 0.05em 0.45em;
  border-radius: 4px;
  background: var(--surface);
  border: 1px solid var(--line);
  white-space: normal;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}
.cite-short { white-space: nowrap; }
.cite .host { font-weight: 400; color: inherit; }

.ask {
  position: sticky; bottom: 0;
  width: min(46rem, 100%);
  margin: 0 auto;
  display: flex; gap: 0.5rem; align-items: flex-end;
  padding: 0.75rem 0 0.25rem;
  background: linear-gradient(transparent, var(--paper) 30%);
}
.ask textarea {
  flex: 1;
  resize: none;
  padding: 0.75rem 1rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  max-height: 200px;
}
.fineprint { width: min(46rem, 100%); margin: 0 auto 0.75rem; color: var(--muted); font-size: 0.8rem; }

dialog { border: 1px solid var(--line); border-radius: 14px; padding: 1.5rem; background: var(--surface); color: var(--ink); width: min(24rem, calc(100% - 2rem)); }
dialog::backdrop { background: rgb(21 26 36 / 0.5); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 0.5rem; }
.dialog-actions button:not(.primary) { border: 1px solid var(--line); background: none; border-radius: 8px; padding: 0.7rem 1rem; }

/* --- small screens ------------------------------------------------------------------------- */
@media (max-width: 760px) {
  .welcome { grid-template-columns: 1fr; }
  .quota { display: none; }
  .icon-button { display: block; }
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; inset: 3.6rem 0 0 0; z-index: 5;
    max-height: none;
    background: var(--paper);
    border-right: 0;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
  }
  body.sidebar-open .sidebar { transform: none; }
  .wordmark { font-size: 1.05rem; }
  .kofi { padding: 0.3rem 0.6rem; }
  .conv-delete { visibility: visible; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before { animation: none !important; transition: none !important; }
}

/* --- cited moments + player ---------------------------------------------------------------- */
.cite-play {
  font: inherit;
  font-size: var(--step--1);
  color: inherit;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.35em;
  vertical-align: baseline;
}
.cite-play:hover { border-color: var(--ink); }
.cite-play .play { width: 0.6em; height: 0.7em; fill: var(--pyrion); }
.cite-play.playing { border-color: var(--pyrion); }

.player {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; align-items: center; gap: 1rem;
  padding: 0.6rem clamp(1rem, 3vw, 2rem);
  background: var(--surface);
  border-top: 3px solid;
  border-image: linear-gradient(90deg, var(--lewis) 0 33.3%, var(--sips-mark) 0 66.6%, var(--pyrion) 0) 1;
}
.player-info { display: flex; flex-direction: column; min-width: 0; flex: 0 1 22rem; }
.player-info strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.player-info span { color: var(--muted); font-size: var(--step--1); }
.player audio { flex: 1; min-width: 0; height: 2.5rem; }
.player-close { display: block; }
body.player-open .ask { bottom: 4.5rem; }
body.player-open .thread { padding-bottom: 5rem; }
.signup-note { margin: 1rem 0 0; }

@media (max-width: 760px) {
  .player { flex-wrap: wrap; gap: 0.4rem 0.75rem; }
  .player-info { flex-basis: calc(100% - 3rem); }
  .player audio { flex-basis: 100%; }
  body.player-open .ask { bottom: 7.5rem; }
}

/* --- privacy note -------------------------------------------------------------------------- */
.privacy-note {
  max-width: 38rem;
  margin-top: 1.5rem;
  padding-left: 0.8rem;
  border-left: 4px solid var(--pyrion);
  color: var(--muted);
  font-size: var(--step--1);
}
.intro .privacy-note { font-size: var(--step-0); }
.empty .privacy-note { margin-top: 2.5rem; }
