/* readdown.app shared tokens and components. Pages add only their own layout. */

:root {
  --bg: #0a0a1a;
  --border: #1e1e3a;
  --text: #e8e8f0;
  --text-secondary: #a0a0be;
  --text-faint: #7c7c9e;
  --accent: #6c63ff;
  --accent-hover: #7f78ff;
  /* Button fill, darker than --accent so white text passes AA. */
  --accent-fill: #5d54f2;
  --accent-fill-hover: #6c63ff;
  --accent-wash: rgba(108, 99, 255, 0.04);
  --accent-tint: rgba(108, 99, 255, 0.08);
  --accent-line: rgba(108, 99, 255, 0.15);
  --accent-edge: rgba(108, 99, 255, 0.35);
  --success: #2ebe3d;
  --success-tint: rgba(46, 190, 61, 0.08);
  --success-edge: rgba(46, 190, 61, 0.35);
  --surface-raised: rgba(255, 255, 255, 0.02);
  --surface-code: rgba(255, 255, 255, 0.04);
  --surface-strong: rgba(255, 255, 255, 0.08);
  --on-accent: #fff;
  --accent-glow: 0 4px 24px rgba(108, 99, 255, 0.25);
  --accent-glow-hover: 0 8px 32px rgba(108, 99, 255, 0.35);
  --accent-gradient: linear-gradient(180deg, rgb(108 99 255 / 0.07), rgb(108 99 255 / 0.02));
  --overlay: rgba(5, 5, 15, 0.7);
  --bar-glass: rgba(10, 10, 26, 0.85);
  --nav-height: 3.5rem;
  --shadow-window: 0 2px 8px rgba(0, 0, 0, 0.3), 0 16px 56px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.06);
  --shadow-window-raised: 0 2px 8px rgba(0, 0, 0, 0.3), 0 20px 64px rgba(0, 0, 0, 0.55), 0 0 0 1px var(--accent-line), 0 0 40px rgba(108, 99, 255, 0.06);
  --shadow-image: 0 2px 8px rgba(0, 0, 0, 0.3), 0 8px 32px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(255, 255, 255, 0.06);

  --heading-font: "SF Pro Rounded", "SF Pro Display", ui-rounded, -apple-system, system-ui, sans-serif;
  --body-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  --mono-font: ui-monospace, SFMono-Regular, Menlo, monospace;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 14px;
  --radius-xl: 20px;
  --tap: 44px;

  --z-nav: 50;
  --z-float: 100;

  --motion-sheet: 220ms;
  --ease-out: cubic-bezier(0.2, 0.8, 0.2, 1);

  --width-article: 720px;
  --width-section: 780px;
  --width-wide: 1000px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
:root { color-scheme: dark; }
/* Components set display; this keeps the hidden attribute working on all of them. */
[hidden] { display: none !important; }
@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}
/* One focus ring for every link and button. */
:where(a, button, input, summary):focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

body {
  font-family: var(--body-font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  /* Footer sits at the bottom of the viewport on short pages. */
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}
body > main { flex: 1 0 auto; width: 100%; }

/* Zero specificity, hover included, so every component (.cta, .cta-outline,
   footer links) wins in every state; :hover would otherwise outrank a class. */
:where(a) {
  color: var(--text);
  text-decoration: underline;
  text-underline-offset: 2px;
}
:where(a:hover) { color: var(--accent); }

.section-heading {
  font-family: var(--heading-font);
  font-size: 2.2rem;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.text-secondary {
  font-size: 0.95rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

/* ── Primary button ── */

.cta {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  padding: 1rem 2.25rem;
  background: var(--accent-fill);
  color: var(--on-accent);
  text-decoration: none;
  border-radius: var(--radius-lg);
  font-size: 1.1rem;
  font-weight: 600;
  width: fit-content;
  box-shadow: var(--accent-glow);
  transition: background 0.2s, transform 0.15s, box-shadow 0.2s;
}
.cta:hover {
  color: var(--on-accent);
  background: var(--accent-fill-hover);
  transform: translateY(-2px);
  box-shadow: var(--accent-glow-hover);
}
.cta svg { width: 20px; height: 20px; }
.cta-small { padding: 0.7rem 1.25rem; font-size: 0.95rem; border-radius: var(--radius-md); }

.cta-block { width: 100%; justify-content: center; text-align: center; }

/* Secondary action next to a page's single .cta. */
.cta-outline {
  display: inline-flex;
  align-items: center;
  padding: 0.7rem 1.25rem;
  border: 1px solid var(--accent-edge);
  border-radius: var(--radius-md);
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.95rem;
  transition: border-color 0.2s, background 0.2s, color 0.2s;
}
.cta-outline:hover { border-color: var(--accent); background: var(--accent-tint); color: var(--accent-hover); }

/* ── Plan list: equal-weight options with one button below (scripts/support.js) ── */

.plans { display: flex; flex-shrink: 0; flex-direction: column; border: 1px solid var(--border); border-radius: var(--radius-md); overflow: hidden; }
.plan { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; padding: 1rem 1.1rem; cursor: pointer; text-align: left; transition: background 0.15s; }
.plan + .plan { border-top: 1px solid var(--border); }
.plan:hover { background: var(--surface-raised); }
.plan.selected { background: var(--accent-tint); }
.plan-text { display: flex; flex-direction: column; gap: 0.2rem; min-width: 0; }
.plan-title { display: flex; align-items: center; gap: 0.5rem; font-weight: 600; color: var(--text); }
.plan-price { color: var(--text-secondary); font-variant-numeric: tabular-nums; }
.plan-note { font-size: 0.85rem; color: var(--text-faint); }
/* Amounts and notes open only on the selected plan, so one choice is ever highlighted. */
.plan:not(.selected) :is(.plan-amounts, .plan-note) { display: none; }
.plan-amounts { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0.4rem; margin-top: 0.6rem; }
@media (max-width: 420px) {
  .plan-amounts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
/* First in the DOM for tab order, drawn on the right. */
.plan input { order: 1; appearance: none; flex: none; width: 22px; height: 22px; margin-top: 2px; border: 2px solid var(--text-faint); border-radius: 50%; cursor: pointer; }
.plan input:checked { border: 6px solid var(--accent); }
.methods { text-align: center; font-size: 0.8rem; color: var(--text-faint); }

/* ── Sheet: modal dialog, bottom sheet on phones ── */

.sheet {
  width: min(440px, calc(100% - 2rem));
  max-height: calc(100dvh - 2rem);
  overflow-y: auto;
  margin: auto;
  padding: 2rem 1.5rem 1.25rem;
  border: 1px solid var(--accent-edge);
  border-radius: var(--radius-xl);
  background: var(--bg);
  color: var(--text);
}
.sheet:focus { outline: none; }
/* The page behind an open sheet doesn't scroll. */
html.sheet-open { overflow: hidden; }
.sheet[open] { display: flex; flex-direction: column; gap: 1rem; }
/* The sheet scrolls as a whole; its parts never squeeze. */
.sheet[open] > * { flex-shrink: 0; }
/* The button stays in reach when the sheet scrolls. */
.sheet .cta { position: sticky; bottom: 0; }
.sheet .plan { scroll-margin-bottom: 7rem; }
.sheet::backdrop { background: var(--overlay); backdrop-filter: blur(4px); }

/* Open and close: fade and rise, a slide up on phones. Browsers without
   @starting-style just show and hide it; reduced motion is handled globally. */
.sheet {
  --sheet-from: translateY(12px) scale(0.98);
  opacity: 0;
  transform: var(--sheet-from);
  transition: opacity var(--motion-sheet) var(--ease-out), transform var(--motion-sheet) var(--ease-out),
    overlay var(--motion-sheet) allow-discrete, display var(--motion-sheet) allow-discrete;
}
.sheet[open] { opacity: 1; transform: none; }
.sheet::backdrop {
  opacity: 0;
  transition: opacity var(--motion-sheet) var(--ease-out),
    overlay var(--motion-sheet) allow-discrete, display var(--motion-sheet) allow-discrete;
}
.sheet[open]::backdrop { opacity: 1; }
@starting-style {
  .sheet[open] { opacity: 0; transform: var(--sheet-from); }
  .sheet[open]::backdrop { opacity: 0; }
}
.sheet-close { position: absolute; top: 0.6rem; right: 0.6rem; width: var(--tap); height: var(--tap); display: grid; place-items: center; border: 0; border-radius: 50%; background: var(--surface-raised); color: var(--text-secondary); font-size: 1.3rem; line-height: 1; cursor: pointer; }
.sheet-close:hover { color: var(--text); }
.sheet-icon { width: 64px; height: 64px; border-radius: 15px; align-self: center; }
.sheet-title { font-family: var(--heading-font); font-size: 1.6rem; font-weight: 800; letter-spacing: -0.02em; text-align: center; }
.sheet-lede { text-align: center; color: var(--text-secondary); }
.sheet-dismiss { font: inherit; padding: 0.7rem; border: 0; border-radius: var(--radius-md); background: var(--surface-raised); color: var(--text-secondary); cursor: pointer; }
.sheet-dismiss:hover { color: var(--text); }
@media (max-height: 760px) {
  .sheet-icon { display: none; }
  .sheet[open] { gap: 0.75rem; }
}
@media (max-width: 600px) {
  .sheet { --sheet-from: translateY(100%); width: 100%; max-width: none; margin: auto 0 0; padding-inline: 1.25rem; border-radius: var(--radius-xl) var(--radius-xl) 0 0; }
}

/* ── Card ── */

.card {
  padding: 1.75rem;
  background: var(--accent-wash);
  border: 1px solid var(--accent-line);
  border-radius: var(--radius-md);
}

/* ── Pill: static label, or a toggle when it's a button ── */

.pill {
  padding: 0.5rem 1rem;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font: inherit;
  font-size: 0.9rem;
  color: var(--text-secondary);
}
button.pill { cursor: pointer; transition: border-color 0.15s, color 0.15s; }
button.pill:hover { color: var(--text); }
button.pill[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-tint); color: var(--text); }
/* A choosable amount: large, full-strength text so unselected never reads as disabled. */
button.pill.amount {
  padding: 0.8rem 0.5rem;
  font-family: var(--heading-font);
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  text-align: center;
}

/* ── Avatar ── */

.avatar, .contributors-list img { width: 56px; height: 56px; border-radius: 50%; border: 1px solid var(--border); display: block; }

/* ── Byline: avatar beside a name or a short note ── */

.byline { display: flex; align-items: center; gap: 0.9rem; }
.byline strong { display: block; font-weight: 600; }
.byline span { font-size: 0.9rem; color: var(--text-faint); }

/* ── Name list (supporters, founders, sponsors) ── */

.names { list-style: none; display: flex; flex-wrap: wrap; gap: 0.5rem; }
.logos { list-style: none; display: flex; flex-wrap: wrap; align-items: center; gap: 1.5rem 2.5rem; }
.logos img { height: 34px; width: auto; display: block; opacity: 0.9; transition: opacity 0.15s ease; }
.logos a:hover img { opacity: 1; }
.names { gap: 0.25rem 0; }
.names .name { font-size: 1.05rem; font-weight: 500; color: var(--text); }
.names li + li::before { content: "\00b7"; margin: 0 0.6rem; color: var(--text-faint); }
.names .others { font-size: 0.9rem; color: var(--text-secondary); }

/* ── Contributor avatars ── */

.contributors-list {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 1.75rem 2.25rem;
  padding: 0;
  margin: 0;
}
.contributors-list a {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 0.55rem;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.9rem;
  transition: color 0.15s ease;
}
.contributors-list a:hover { color: var(--text); }
.contributors-list img {
  filter: grayscale(100%);
  transition: filter 0.15s ease;
}
.contributors-list a:hover img { filter: grayscale(0%); }

/* ── Sponsor banner (homepage people band, /sponsors example) ── */

.sponsor {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  text-align: center;
  padding: 1.9rem 1.75rem;
  margin-bottom: 0.85rem;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--accent-gradient);
  color: inherit;
  text-decoration: none;
  transition: border-color 0.15s ease;
}
.sponsor:hover { border-color: var(--accent-edge); }
.sponsor-eyebrow {
  font-size: 0.66rem;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--text-secondary);
  opacity: 0.8;
}
.sponsor-logo img {
  height: 34px;
  width: auto;
  display: block;
  opacity: 0.95;
  transition: opacity 0.15s ease;
}
.sponsor:hover .sponsor-logo img { opacity: 1; }
.sponsor-tagline {
  font-size: 0.82rem;
  color: var(--text-secondary);
  max-width: 24rem;
  line-height: 1.5;
  opacity: 0.75;
  text-wrap: balance;
}
.sponsor-cta {
  font-size: 0.85rem;
  color: var(--accent);
  text-decoration: none;
  transition: color 0.15s ease;
}
.sponsor-cta:hover { color: var(--accent-hover); }

/* ── Sub-page top bar ── */

.topbar {
  width: 100%;
  max-width: var(--width-article);
  margin: 0 auto;
  padding: 2rem 1.5rem 0;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.topbar a {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.9rem;
  transition: color 0.2s;
}
.topbar a:hover { color: var(--text); }
.topbar img { width: 28px; height: 28px; border-radius: 7px; }

/* ── Changelog list (/changelog, and the homepage's latest releases) ── */

.changelog-list { list-style: none; }
.changelog-list > li { padding: 1.25rem 0; border-top: 1px solid var(--border); scroll-margin-top: 2rem; }
.changelog-version { font-size: 1rem; font-weight: 600; margin-bottom: 0.35rem; }
.changelog-version span { font-weight: 400; color: var(--text-secondary); font-size: 0.85rem; margin-left: 0.5rem; }
.changelog-list ul { list-style: none; padding: 0; }
.changelog-list ul li { padding: 0.15rem 0; color: var(--text-secondary); font-size: 0.9rem; }
.changelog-list ul li::before { content: "\00b7"; margin-right: 0.5rem; color: var(--accent); }

/* ── Sub-page layout (privacy, support, thanks, changelog) ── */

.subpage main {
  max-width: var(--width-article);
  margin: 0 auto;
  padding: 3rem 1.5rem 4rem;
}
.subpage.wide .topbar,
.subpage.wide main { max-width: var(--width-wide); }
.subpage h1 {
  font-family: var(--heading-font);
  font-size: 2.6rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.15;
  text-wrap: balance;
  margin-bottom: 1.5rem;
}
.subpage h2 {
  font-family: var(--heading-font);
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 2.25rem 0 0.75rem;
}
/* Prose links on sub-pages; zero specificity like the base link above. */
:where(.subpage main a) { color: var(--accent); text-decoration: underline; text-decoration-color: var(--accent-edge); }
:where(.subpage main a:hover) { color: var(--accent-hover); text-decoration: underline; }
.subpage .lede { max-width: 65ch; font-size: 1.1rem; color: var(--text-secondary); line-height: 1.7; }
.subpage .meta {
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
  font-size: 0.85rem;
  color: var(--text-secondary);
}

/* ── Footer ── */

footer {
  text-align: center;
  padding: 3rem 2rem;
  border-top: 1px solid var(--border);
  color: var(--text-faint);
  font-size: 0.8rem;
}
footer a {
  color: var(--text-secondary);
  text-decoration: none;
  margin: 0 0.4rem;
  transition: color 0.2s;
}
footer a:hover { color: var(--text); }
footer .copyright { margin-top: 0.75rem; }
/* Quiet by default, accent on hover; footer-only so it never competes with the download. */
footer .studio-credit { margin-top: 0.5rem; }
footer .studio-credit a { margin: 0; color: var(--text-secondary); }
footer .studio-credit a:hover { color: var(--accent); }
/* Room for the floating support button below the last line. */
@media (max-width: 600px) {
  footer { padding-bottom: 6rem; }
}

/* ── Floating support button ── */

.support-link {
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  z-index: var(--z-float);
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  min-height: var(--tap);
  padding: 0.6rem 1.4rem;
  border: 1px solid var(--accent-edge);
  border-radius: var(--radius-md);
  background: var(--bg);
  color: var(--accent);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  transition: border-color 0.2s, background 0.2s, color 0.2s;
}
.support-link:hover {
  border-color: var(--accent);
  background: var(--accent-tint);
  color: var(--accent-hover);
}

@media (max-width: 768px) {
  .section-heading { font-size: 1.8rem; }
}
