/* ==========================================================================
   ghostties.org — shared stylesheet

   Loaded by every page before its own <style> block, so page rules always
   win at equal specificity. Spec and rationale: web/DESIGN.md

   Contents:
     1. Tokens
     2. Reset + document
     3. Typography
     4. Layout
     5. Components
     6. Footer
     7. Responsive
   ========================================================================== */

/* 1. Tokens ================================================================ */

:root {
  /* --- Surfaces --- */
  --bg: #1a1a2e;
  --surface-raised: rgba(255, 255, 255, 0.04); /* .note, pre */
  --surface-inline: rgba(255, 255, 255, 0.07); /* inline <code> */

  /* --- Text ramp (white on --bg) ---
     Alphas raised 2026-08-03 to clear WCAG AA (4.5:1 body text) against
     --bg; see DESIGN.md §3 for the audit numbers and web/DESIGN.md history
     for the pre-fix values. No longer densest-to-faintest in this order —
     --text-faint (0.55) ended up brighter than --text-note/--text-meta/
     --text-label/--text-label-quiet below it once each was raised only as
     far as its own AA requirement demanded. All still pass AA; this list is
     grouped by role (prose ramp, then footer/timestamp ramp), not by value. */
  --text-heading: #fff;
  --text-primary: rgba(255, 255, 255, 0.85); /* body default */
  --text-body: rgba(255, 255, 255, 0.65); /* prose, links */
  --text-note: rgba(255, 255, 255, 0.52); /* callout copy */
  --text-meta: rgba(255, 255, 255, 0.5); /* file size, release links */
  --text-label: rgba(255, 255, 255, 0.48); /* eyebrows, back link, dates */
  --text-label-quiet: rgba(255, 255, 255, 0.46); /* changelog subsections */
  --text-faint: rgba(255, 255, 255, 0.55); /* footer, timestamps, bullets */
  --text-heading-soft: rgba(255, 255, 255, 0.9); /* licenses section titles */

  /* --- Text hover pairs --- */
  --text-body-hover: rgba(255, 255, 255, 0.9);
  --text-meta-hover: rgba(255, 255, 255, 0.65);
  --text-label-hover: rgba(255, 255, 255, 0.6);
  --text-faint-hover: rgba(255, 255, 255, 0.65);

  /* --- Lines --- */
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.12);
  --line-faint: rgba(255, 255, 255, 0.07);

  /* --- Accent ---
     Terracotta. Dropped as an app brand color but still shipping on the web
     in two places (product captions, 404 home link). See DESIGN.md §3. */
  --accent: #c97350;

  /* --- Hero + product surfaces (index.html) ---
     The homepage terminal is its own small palette: a lighter foreground than
     the prose ramp, plus the red/green diff pair. The JS at the bottom of
     index.html re-states --diff-add-* inline; see DESIGN.md §6. */
  --surface-card: #0f0f1a; /* product window behind the video */
  --terminal-fg: #e0e0e0;
  --diff-add-fg: rgba(100, 220, 120, 0.9);
  --diff-add-bg: rgba(80, 210, 100, 0.13);
  --diff-del-fg: rgba(
    255,
    100,
    100,
    0.95
  ); /* 4.72:1 against its own diff-del-bg composite; see DESIGN.md §3 */
  --diff-del-bg: rgba(255, 80, 80, 0.13);

  /* --- Type --- */
  --font-ui: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono:
    "SFMono-Regular", "SF Mono", "Fira Code", "Cascadia Code", "JetBrains Mono",
    monospace;

  /* Sizes are rem against the unmodified 16px browser default — no page sets
     a root font-size, so 1rem = 16px and every value below renders at the
     same pixel size as its old px literal. */
  --size-caption: 0.75rem; /* 12px */
  --size-small: 0.8125rem; /* 13px */
  --size-meta: 0.875rem; /* 14px */
  --size-body: 0.9375rem; /* 15px */
  --size-lead: 1rem; /* 16px */
  --size-title-sm: 1.375rem; /* 22px, h1 under 480px */
  --size-title: 1.75rem; /* 28px */

  --leading-snug: 1.6;
  --leading-body: 1.65;

  /* --- Radii --- */
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;

  /* --- Motion ---
     Mirrored quartic pair. --ease-out is the site's default arrival curve;
     --ease-in is acceleration under gravity. Deliberately no spring or
     overshoot curve: it dates a page fast and pulls attention to the motion
     rather than the thing moving. */
  --transition: 0.2s;
  --ease-out: cubic-bezier(0.25, 1, 0.5, 1);
  --ease-in: cubic-bezier(0.5, 0, 0.75, 0);
}

/* 2. Reset + document ====================================================== */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html,
body {
  min-height: 100dvh;
  background: var(--bg);
}

body {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 64px 24px 64px;
  font-family: var(--font-ui);
  color: var(--text-primary);
}

/* Keyboard focus. Replaces the browser default with a visible ring that
   reads against --bg; :focus-visible means it never shows on mouse/touch. */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* Visually hidden until focused — skip link, and reused for the homepage h1 */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  top: -40px;
  left: 8px;
  z-index: 100;
  padding: 8px 16px;
  background: var(--bg);
  color: var(--text-primary);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  text-decoration: none;
}

.skip-link:focus {
  top: 8px;
}

/* 3. Typography ============================================================ */

h1 {
  font-size: var(--size-title);
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 12px;
  color: var(--text-heading);
}

/* Section eyebrow. licenses.html overrides this with a larger title style. */
h2 {
  font-size: var(--size-small);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-label);
  margin-bottom: 10px;
  margin-top: 36px;
}

p {
  font-size: var(--size-body);
  line-height: var(--leading-body);
  color: var(--text-body);
  margin-bottom: 12px;
}

.lead {
  font-size: var(--size-lead);
  line-height: var(--leading-snug);
  color: var(--text-body);
  margin-bottom: 40px;
}

ul {
  list-style: none;
  margin-bottom: 12px;
}

ul li {
  font-size: var(--size-body);
  line-height: var(--leading-body);
  color: var(--text-body);
  padding-left: 16px;
  position: relative;
  margin-bottom: 4px;
}

ul li::before {
  content: "–";
  position: absolute;
  left: 0;
  color: var(--text-faint);
}

a {
  color: var(--text-body);
  text-decoration: underline;
  text-underline-offset: 2px;
}

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

code {
  font-family: var(--font-mono);
  font-size: var(--size-small);
  background: var(--surface-inline);
  padding: 1px 5px;
  border-radius: var(--radius-sm);
  color: rgba(255, 255, 255, 0.75);
  /* Long unbroken paths (e.g. bundle IDs) have no natural break point;
     without this the <code> run forces its container wider than the
     viewport at narrow widths. Letting it break mid-token beats letting it
     push the page into horizontal scroll. */
  overflow-wrap: anywhere;
}

pre {
  font-family: var(--font-mono);
  font-size: var(--size-caption);
  line-height: 1.7;
  color: var(--text-note);
  background: var(--surface-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 20px;
  margin-top: 16px;
  margin-bottom: 12px;
  white-space: pre-wrap;
  word-break: break-word;
}

/* 4. Layout ================================================================ */

/* Flex item in the body column. Explicit width keeps percentage-sized
   children (e.g. .scene, .content) resolving against a real containing
   block instead of main's shrink-to-fit default. flex:1 makes main (not
   footer's margin-top:auto) the thing that claims the column's free space
   on short pages — that's what lets a page center its own content inside
   <main> (see 404.html) while the footer still lands at the bottom. */
main {
  width: 100%;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.content {
  width: 100%;
  max-width: 600px;
}

/* 5. Components ============================================================ */

/* Back-to-home link at the top of every document page */
.back {
  display: inline-block;
  margin-bottom: 40px;
  font-size: var(--size-small);
  color: var(--text-label);
  text-decoration: none;
  transition: color var(--transition);
}

.back:hover {
  color: var(--text-label-hover);
}

/* Quiet callout box */
.note {
  margin-top: 36px;
  padding: 16px 20px;
  background: var(--surface-raised);
  border-left: 2px solid var(--line-strong);
  border-radius: var(--radius-sm);
}

.note p {
  font-size: var(--size-small);
  color: var(--text-note);
  margin-bottom: 0;
}

/* "Last updated …" timestamp */
.updated {
  margin-top: 48px;
  font-size: var(--size-caption);
  color: var(--text-faint);
}

/* 6. Footer ================================================================ */

/* Static, not fixed: a viewport-pinned footer renders on top of body text
   on any page taller than one screen (confirmed colliding with a code span
   on /support at mobile width). index.html re-pins its own footer to fixed
   in its page <style> block — the homepage is a single, exactly-viewport-
   height hero and is designed around a footer glued to its bottom edge. */
footer {
  position: static;
  /* body centers flex items by default (align-items:center), so without an
     explicit width footer would shrink-wrap its content and float centered
     in the middle of the page instead of spanning edge to edge the way the
     old fixed/inset:0 footer did. Same reasoning as main's width:100% above. */
  width: 100%;
  /* Pushes the footer to the bottom of the flex column on short pages. Now a
     backstop, not the primary mechanism: main's flex:1 above is what claims
     the column's free space, so this margin is normally a no-op. It stays
     so the footer is still bottom-anchored if a page ever has content
     outside <main> in the flex column. */
  margin-top: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  font-family: var(--font-ui);
  font-size: var(--size-small);
  color: var(--text-faint);
}

footer a {
  color: var(--text-faint);
  transition: color var(--transition);
  text-decoration: none;
}

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

footer svg {
  width: 16px;
  height: 16px;
  display: block;
}

/* Wrapping link row (copyright + Changelog/Privacy/Support[/Licenses], and
   the same markup reused for index.html's footer). Real flex layout, not a
   line-height trick: each link is a flex item, so padding on it is counted
   in its own box and reserved by the row — unlike padding on a plain inline
   element, which paints outside the line box without pushing anything
   apart. That's what let two wrapped rows overlap before. row-gap adds
   guaranteed clearance between wrapped rows on top of that. */
.footer-links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 0;
}

/* Middot separators travel with the link that follows them (as ::before,
   inside that link's own flex item) so a wrap can only ever break between
   an item and its separator, never leave a dangling "·" at the end of a
   row. */
.footer-links > * + *::before {
  content: "\00B7" / "";
  margin: 0 8px;
}

/* 7. Responsive ============================================================ */

@media (max-width: 480px) {
  body {
    padding: 48px 16px 48px;
  }

  h1 {
    font-size: var(--size-title-sm);
  }

  footer {
    padding: 8px 16px;
    font-size: var(--size-caption);
  }

  /* Touch targets: because .footer-links is a real flex row (see above),
     padding here grows each link's box the same way it grows any block
     box — reserved space, not just paint — so rows can't collide. 13px top
     and bottom lands the box at ~40px tall against this caption-size text;
     44px would need either a third row or padding large enough to make the
     dot-separated row wrap earlier and orphan more links, so this trades
     down to ~40px rather than risk overlap. */
  .footer-links a {
    padding: 13px 6px;
  }

  /* No middot at mobile widths: a wrap can land at any point depending on
     link count and viewport, so any separator scheme risks a dangling
     leading or trailing "·" on some row. Dropping it removes the
     possibility entirely; the flex gap above already separates items.
     row-gap (the first value) is pure inter-row breathing room, not an
     overlap guard — flex-wrap already reserves each row's full box height
     regardless of gap, so this can go lower than the old 6px without risk. */
  .footer-links {
    gap: 4px 12px;
  }

  .footer-links > * + *::before {
    content: none;
    margin: 0;
  }

  .back {
    padding: 14px 4px;
    margin: -14px -4px 26px;
  }
}
