/* ==========================================================================
   Tearther — the public site's one stylesheet.
   Dresses the landing page, the invitation-gated download page, and the
   admin. Dark, dim and quiet: near-black surfaces, hairlines, small display
   type, monospace meta lines. The one red mark is the wordmark's full stop;
   the only red surface is the primary button.
   ========================================================================== */

/* --------------------------------------------------------------------------
   The display face. One Oswald 600 file, self-hosted; the same cut the app
   and the intro are set in. It appears small here — the wordmark and the
   headings — and body copy stays on the system stack.
   -------------------------------------------------------------------------- */
@font-face {
  font-family: 'Tearther Display';
  src: url('/fonts/oswald-600.ttf') format('truetype');
  font-weight: 400 700;
  font-style: normal;
  font-display: swap;
}

/* --------------------------------------------------------------------------
   Tokens — the house palette, pulled a step darker and softer than the app.
   Every ink that carries words stays AA on its darkest ground:
   text 14.6:1, dim 7.8:1, faint 5.5:1 on --bg.
   -------------------------------------------------------------------------- */
:root {
  --bg: #101010;
  --surface: #181818;
  --raised: #232323;
  --border: #2e2e2e;
  --text: #ececec;
  --dim: #a6a6a6;
  --faint: #8a8a8a;
  --accent: #e50914;
  --accent-hover: #f6121d;

  /* derived: hairlines and states, always white-over-dark alphas so they
     read the same on every surface */
  --hairline: rgba(255, 255, 255, 0.08);
  --hairline-strong: rgba(255, 255, 255, 0.16);
  --focus: rgba(255, 255, 255, 0.92);
  --ok-ink: #86e0a8;
  --ok-edge: rgba(70, 200, 120, 0.35);
  --ok-tint: rgba(70, 200, 120, 0.07);
  --bad-ink: #ffb3b8;
  --bad-edge: rgba(229, 9, 20, 0.45);
  --bad-tint: rgba(229, 9, 20, 0.08);

  --display: 'Tearther Display', 'Avenir Next Condensed', Oswald, sans-serif;
  --body: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;

  /* radius by role: badges 4, controls 8, cards 12, floating panels 16 */
  --r-xs: 4px;
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
}

/* --------------------------------------------------------------------------
   Reset & base
   -------------------------------------------------------------------------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  color-scheme: dark;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--body);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: clip; /* the page never scrolls sideways; wide content scrolls itself */
}

h1,
h2,
h3,
h4,
p,
figure,
fieldset,
dl,
dd {
  margin: 0;
}

h1,
h2,
h3 {
  text-wrap: balance;
  line-height: 1.15;
}

p {
  text-wrap: pretty;
}

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

a {
  color: var(--text);
  text-decoration: underline;
  text-decoration-color: rgba(255, 255, 255, 0.35);
  text-underline-offset: 3px;
  transition-property: text-decoration-color, color;
  transition-duration: 150ms;
}

a:hover {
  text-decoration-color: var(--text);
}

/* Selection stays greyscale; red is not a highlighter here. */
::selection {
  background: #3a3a3a;
  color: var(--text);
}

::placeholder {
  color: var(--faint);
}

/* One visible focus treatment everywhere: the house 2px ring, 3px out.
   Inputs, which already own a border, switch that border instead. */
:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
  border-radius: 2px;
}

input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: none;
  border-color: var(--focus);
}

/* --------------------------------------------------------------------------
   Shell — header, footer, sections, the centred column
   -------------------------------------------------------------------------- */
.wrap {
  max-width: 1080px;
  margin-inline: auto;
  padding-inline: clamp(20px, 5vw, 40px);
}

.site-header {
  padding-block: 22px;
}

.site-header .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

/* The wordmark: the display face at a murmur, and the site's one red mark —
   a single full stop. */
.brand {
  font-family: var(--display);
  font-weight: 600;
  font-size: 19px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-decoration: none;
  line-height: 1;
  color: var(--text);
  display: inline-flex;
  align-items: baseline;
  padding-block: 10px; /* a 40px hit target without a bigger face */
}

.brand::after {
  content: '';
  width: 0.16em;
  height: 0.16em;
  background: var(--accent);
  margin-left: 0.14em;
}

/* The header's only other word. Mono, small, no shouting. */
.nav-link {
  font-family: var(--mono);
  font-size: 13px;
  letter-spacing: 0.06em;
  color: var(--dim);
  text-decoration-color: var(--hairline-strong);
  padding: 12px 4px; /* hit area */
}

.nav-link:hover {
  color: var(--text);
}

.site-footer {
  border-top: 1px solid var(--hairline);
  margin-top: clamp(48px, 10vw, 96px);
  padding-block: 32px 48px;
  color: var(--dim);
}

.site-footer p + p {
  margin-top: 8px;
}

.section {
  padding-block: clamp(48px, 9vw, 88px);
}

.section-line {
  border-top: 1px solid var(--hairline);
}

/* --------------------------------------------------------------------------
   Type. Headings are labels, not announcements: small caps of the display
   face, spaced out, over a lot of air. Meta lines go monospace.
   -------------------------------------------------------------------------- */
.eyebrow {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 400;
  letter-spacing: 0.14em;
  text-transform: lowercase;
  color: var(--faint);
  margin-bottom: 18px;
}

.lede {
  font-size: 16px;
  line-height: 1.65;
  color: var(--dim);
  max-width: 34em;
}

.muted {
  color: var(--dim);
}

.small {
  font-size: 14px;
  line-height: 1.55;
}

h1 {
  font-family: var(--display);
  font-weight: 600;
  font-size: clamp(23px, 3.4vw, 30px);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

h2 {
  font-family: var(--display);
  font-weight: 600;
  font-size: 17px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

/* --------------------------------------------------------------------------
   Buttons
   -------------------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 10px 22px;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  font-family: var(--body);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.2;
  color: var(--text);
  background: var(--raised);
  text-decoration: none;
  cursor: pointer;
  transition-property: background-color, border-color, color, transform;
  transition-duration: 150ms;
}

.btn:hover {
  background: #303030;
}

.btn:active {
  transform: scale(0.96);
}

.btn-primary {
  background: var(--accent);
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-ghost {
  background: transparent;
  border-color: rgba(255, 255, 255, 0.22);
}

.btn-ghost:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.38);
}

.btn-danger {
  background: transparent;
  border-color: var(--bad-edge);
  color: var(--bad-ink);
}

.btn-danger:hover {
  background: var(--bad-tint);
  border-color: rgba(229, 9, 20, 0.7);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

/* --------------------------------------------------------------------------
   Forms
   -------------------------------------------------------------------------- */
.field {
  margin-block: 22px;
  border: 0;
  padding: 0;
  min-width: 0;
}

.field > label,
.field > legend {
  display: block;
  font-weight: 600;
  font-size: 15px;
  margin-bottom: 8px;
  padding: 0;
}

.field-row {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: flex-end;
}

.field-row .field {
  flex: 1 1 220px;
  margin-block: 0;
}

input[type='text'],
input[type='email'],
input[type='password'],
select,
textarea {
  width: 100%;
  padding: 11px 14px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  font-family: var(--body);
  font-size: 16px; /* 16px so iPhones don't zoom the page on focus */
  line-height: 1.4;
  transition-property: border-color, background-color;
  transition-duration: 150ms;
}

input[type='text']:hover,
input[type='email']:hover,
input[type='password']:hover,
select:hover,
textarea:hover {
  border-color: var(--hairline-strong);
}

textarea {
  resize: vertical;
  min-height: 88px;
}

.hint {
  font-size: 14px;
  line-height: 1.5;
  color: var(--dim);
  margin-top: 8px;
}

.error-text {
  font-size: 14px;
  color: var(--bad-ink);
  margin-top: 8px;
}

/* Radio choices drawn as rows, the native control kept visible. */
.choices {
  display: grid;
  gap: 8px;
}

.choice {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface);
  cursor: pointer;
  transition-property: border-color, background-color;
  transition-duration: 150ms;
}

.choice:hover {
  border-color: var(--hairline-strong);
}

.choice:has(input:checked) {
  border-color: var(--focus);
  background: var(--raised);
}

.choice input[type='radio'] {
  accent-color: var(--text);
  width: 18px;
  height: 18px;
  margin: 0;
  flex: none;
}

/* The honeypot. Off-screen, never display:none, invisible to everyone real. */
.honey {
  position: absolute;
  left: -9999px;
  top: auto;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

/* --------------------------------------------------------------------------
   Notices
   -------------------------------------------------------------------------- */
.notice {
  padding: 16px 18px;
  border: 1px solid var(--hairline-strong);
  border-radius: var(--r-md);
  background: var(--surface);
  margin-block: 20px;
}

.notice p + p {
  margin-top: 10px;
}

.notice-ok {
  border-color: var(--ok-edge);
  background: var(--ok-tint);
}

.notice-ok > :first-child {
  color: var(--ok-ink);
}

.notice-bad {
  border-color: var(--bad-edge);
  background: var(--bad-tint);
}

.notice-bad > :first-child {
  color: var(--bad-ink);
}

/* --------------------------------------------------------------------------
   Cards — hairline panels, no fill, headings kept small
   -------------------------------------------------------------------------- */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(260px, 100%), 1fr));
  gap: 16px;
}

.card {
  padding: 24px;
  border: 1px solid var(--hairline);
  border-radius: var(--r-md);
  background: transparent;
  transition-property: border-color;
  transition-duration: 180ms;
}

.card:hover {
  border-color: var(--hairline-strong);
}

.card h3 {
  font-family: var(--display);
  font-weight: 600;
  font-size: 15px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 10px;
}

.card p {
  font-size: 15px;
  line-height: 1.6;
  color: var(--dim);
}

/* --------------------------------------------------------------------------
   Landing page — hero, the spec list, the waitlist
   -------------------------------------------------------------------------- */
.hero {
  padding-block: clamp(64px, 16vh, 160px) clamp(48px, 9vw, 88px);
}

.hero h1 {
  max-width: 18em;
  margin-bottom: 18px;
}

.hero-cta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 20px;
  margin-top: 36px;
}

.hero-cta .small {
  margin: 0;
}

/* What it does: a spec sheet, not a pitch. Mono keys, hairline rows. */
.spec {
  max-width: 760px;
  border-top: 1px solid var(--hairline);
}

.spec-row {
  display: grid;
  grid-template-columns: 9em 1fr;
  gap: 8px 20px;
  padding-block: 13px;
  border-bottom: 1px solid var(--hairline);
}

.spec-row dt {
  font-family: var(--mono);
  font-size: 13px;
  letter-spacing: 0.04em;
  color: var(--faint);
  padding-top: 2px;
}

.spec-row dd {
  font-size: 15px;
  line-height: 1.6;
  color: var(--dim);
  text-wrap: pretty;
}

.waitlist {
  max-width: 560px;
}

.waitlist h2 {
  margin-bottom: 14px;
}

/* The one thing the visitor must not miss: which address to give. The only
   boxed paragraph on the page, set in full ink where everything around it
   is dim — hierarchy, not volume. */
.store-note {
  margin-block: 24px;
  padding: 16px 18px;
  border: 1px solid var(--border);
  border-left: 2px solid var(--dim);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 15px;
  line-height: 1.6;
}

.waitlist-count {
  margin-top: 16px;
  font-family: var(--mono);
  font-size: 13px;
  color: var(--faint);
  font-variant-numeric: tabular-nums;
}

/* --------------------------------------------------------------------------
   Download page — the gate and the builds list
   -------------------------------------------------------------------------- */
.gate {
  max-width: 440px;
  margin: clamp(40px, 10vh, 96px) auto;
  padding: clamp(24px, 5vw, 40px);
  border: 1px solid var(--hairline);
  border-radius: var(--r-lg);
  background: var(--surface);
}

.builds {
  display: grid;
  gap: 0;
  border-top: 1px solid var(--hairline);
  margin-top: 24px;
}

.build {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 20px 4px;
  border-bottom: 1px solid var(--hairline);
}

.build-icon {
  width: 40px;
  height: 40px;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--hairline);
  border-radius: var(--r-sm);
  color: var(--dim);
}

.build-icon svg {
  width: 22px;
  height: 22px;
  stroke: currentColor;
}

.build-name {
  font-weight: 600;
  font-size: 16px;
}

.build-meta {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--dim);
  font-variant-numeric: tabular-nums;
}

/* Whichever ends the row — the button on a build that is ready, the badge on
   one that is not — sits at the right edge. */
.build .btn,
.build .badge {
  margin-left: auto;
}

.badge {
  display: inline-block;
  padding: 2px 10px;
  border: 1px solid var(--hairline-strong);
  border-radius: 999px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: lowercase;
  color: var(--dim);
}

.badge-soon {
  border-style: dashed;
  color: var(--faint);
}

/* An invitation code, shown to be copied by eye. */
.code {
  display: inline-block;
  font-family: var(--mono);
  font-size: 22px;
  letter-spacing: 0.3em;
  padding: 10px 16px 10px 20px; /* extra left pads out the trailing tracking */
  background: var(--raised);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  font-variant-numeric: tabular-nums;
  user-select: all;
}

/* --------------------------------------------------------------------------
   Admin — the table and the state pills
   -------------------------------------------------------------------------- */
.table {
  width: 100%;
  overflow-x: auto;
  font-variant-numeric: tabular-nums;
}

/* Works whether .table is the <table> itself or a wrapper around one. */
table.table {
  display: block;
  white-space: nowrap;
  border-collapse: collapse;
}

.table > table {
  width: 100%;
  white-space: nowrap;
  border-collapse: collapse;
}

.table th {
  text-align: left;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 400;
  letter-spacing: 0.12em;
  text-transform: lowercase;
  color: var(--dim);
  padding: 10px 10px;
  border-bottom: 1px solid var(--border);
}

/* Tight enough that the admin's seven columns — the last of which holds the
   buttons the page exists for — fit a laptop without a sideways scroll. */
.table td {
  padding: 10px 10px;
  font-size: 13px;
  border-bottom: 1px solid var(--hairline);
  vertical-align: middle;
}

/* The two columns that carry sentences may wrap; the rest stay on one line. */
.table td.wrap-cell {
  white-space: normal;
  min-width: 14em;
}

.table tbody tr:hover {
  background: rgba(255, 255, 255, 0.03);
}

.pill {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  border: 1px solid var(--hairline-strong);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: lowercase;
  color: var(--dim);
}

.pill-pending {
  border-color: var(--hairline-strong);
  color: var(--dim);
}

.pill-accepted {
  border-color: var(--ok-edge);
  color: var(--ok-ink);
}

.pill-declined {
  border-color: var(--hairline);
  color: var(--faint);
}

.pill-revoked {
  border-color: var(--bad-edge);
  color: var(--bad-ink);
}

.row-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.row-actions form {
  margin: 0;
}

.row-actions .btn {
  min-height: 32px;
  padding: 4px 12px;
  font-size: 13px;
}

/* --------------------------------------------------------------------------
   Utilities
   -------------------------------------------------------------------------- */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* --------------------------------------------------------------------------
   Motion off
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
  }

  .btn:active {
    transform: none;
  }
}

/* --------------------------------------------------------------------------
   Narrow screens
   -------------------------------------------------------------------------- */
@media (max-width: 480px) {
  .site-header .wrap {
    flex-wrap: wrap;
  }

  .spec-row {
    grid-template-columns: 1fr;
    gap: 2px;
  }

  .build {
    flex-wrap: wrap;
  }

  .build .btn {
    margin-left: 58px; /* icon width + gap, so it lines up under the name */
  }
}

/* --------------------------------------------------------------------------
   The pages the Worker draws itself — the gate, the downloads, the admin

   These are plain markup: a heading, a paragraph under it, a section or two.
   They carry none of the home page's wrappers, so `.page` is where that plain
   shape gets the same rhythm the rest of the site has.
   -------------------------------------------------------------------------- */
.page h1 + p,
.page h1 + .notice,
.page h2 + p,
.page h3 + p {
  margin-top: 14px;
}

.page .lede + .notice,
.page .notice + .builds {
  margin-top: 24px;
}

/* The admin is a tool, not a page of prose: its table earns the extra width,
   so its seven columns and the row's buttons sit on one line on a laptop. */
.wrap-wide {
  max-width: 1400px;
}

/* A second subject on the same page — the store builds under the desktop ones
   — is a hairline and a step down, not the full gap between two sections. */
.page .section-sub {
  margin-top: clamp(32px, 5vw, 56px);
  padding-top: clamp(24px, 4vw, 36px);
  border-top: 1px solid var(--hairline);
}

.page .section-sub + .small {
  margin-top: clamp(24px, 4vw, 40px);
}
