/* ============================================================
   Aria Bolour — Design System
   Apple × Stripe × Linear × Notion. Typography is the hero.
   ============================================================ */

/* ---------- Tokens ---------- */

/* Palette follows Apple's own developer.apple.com tokens: fill blue #0071e3 for
   filled controls, link blue #0066cc (light) / figure blue #2997ff (dark) for
   text, and the Xcode syntax colors for code. */
:root {
  --bg: #ffffff;
  --bg-subtle: #f5f5f7;
  --bg-elevated: #fafafc;
  --bg-inverse: #1d1d1f;

  --text: #1d1d1f;
  --text-secondary: #6e6e73;
  --text-tertiary: #86868b;
  --text-inverse: #f5f5f7;

  --accent: #0071e3;
  --accent-strong: #0077ed;
  --accent-text: #0066cc;
  --accent-soft: rgba(0, 113, 227, 0.08);

  --green: #03a10e;
  --green-text: #008009;
  --green-soft: #f5fff6;
  --orange: #f56300;
  --orange-text: #b64400;
  --orange-soft: #fff9f4;
  --red: #e30000;
  --red-text: #e30000;
  --red-soft: #fff2f4;

  --hairline: rgba(0, 0, 0, 0.08);
  --hairline-strong: rgba(0, 0, 0, 0.16);

  --diagram-line: #a6a6ab;
  --diagram-fill: #f5f5f7;

  /* Xcode syntax palette, light */
  --code-bg: #f5f5f7;
  --code-inline-bg: #f5f5f7;
  --code-border: rgba(0, 0, 0, 0.08);
  --code-plain: #1d1d1f;
  --code-keyword: #ad3ea4;
  --code-string: #d22e1b;
  --code-number: #2629d7;
  --code-comment: #007400;
  --code-type: #804fb8;
  --code-method: #4a22b0;

  --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.04), 0 8px 24px rgba(0, 0, 0, 0.05);
  --shadow-card-hover: 0 2px 4px rgba(0, 0, 0, 0.04), 0 16px 40px rgba(0, 0, 0, 0.08);

  --radius-lg: 18px;
  --radius-md: 12px;
  --radius-sm: 8px;

  --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text",
    "Helvetica Neue", Helvetica, Arial, sans-serif;
  --font-mono: "SF Mono", ui-monospace, "Cascadia Code", Menlo, Consolas, monospace;

  --w-content: 1080px;
  --w-prose: 44rem;

  --ease: cubic-bezier(0.25, 0.1, 0.25, 1);

  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #000000;
    --bg-subtle: #141414;
    --bg-elevated: #1d1d1f;
    --bg-inverse: #f5f5f7;

    --text: #f5f5f7;
    --text-secondary: #a1a1a6;
    --text-tertiary: #86868b;
    --text-inverse: #1d1d1f;

    --accent: #0071e3;
    --accent-strong: #0077ed;
    --accent-text: #2997ff;
    --accent-soft: rgba(41, 151, 255, 0.14);

    --green: #30d158;
    --green-text: #30d158;
    --green-soft: rgba(48, 209, 88, 0.12);
    --orange: #ff9f0a;
    --orange-text: #ff9f0a;
    --orange-soft: rgba(255, 159, 10, 0.12);
    --red: #ff453a;
    --red-text: #ff453a;
    --red-soft: rgba(255, 69, 58, 0.12);

    --hairline: rgba(255, 255, 255, 0.12);
    --hairline-strong: #424245;

    --diagram-line: #6e6e73;
    --diagram-fill: #1d1d1f;

    /* Xcode syntax palette, dark */
    --code-bg: #282a2f;
    --code-inline-bg: rgba(255, 255, 255, 0.1);
    --code-border: rgba(214, 214, 214, 0.2);
    --code-plain: #f5f5f7;
    --code-keyword: #ff7ab2;
    --code-string: #ff8170;
    --code-number: #d8c97c;
    --code-comment: #7e8c98;
    --code-type: #acf2e4;
    --code-method: #dabaff;

    --shadow-card: none;
    --shadow-card-hover: none;

    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #000000;
  --bg-subtle: #141414;
  --bg-elevated: #1d1d1f;
  --bg-inverse: #f5f5f7;

  --text: #f5f5f7;
  --text-secondary: #a1a1a6;
  --text-tertiary: #86868b;
  --text-inverse: #1d1d1f;

  --accent: #0071e3;
  --accent-strong: #0077ed;
  --accent-text: #2997ff;
  --accent-soft: rgba(41, 151, 255, 0.14);

  --green: #30d158;
  --green-text: #30d158;
  --green-soft: rgba(48, 209, 88, 0.12);
  --orange: #ff9f0a;
  --orange-text: #ff9f0a;
  --orange-soft: rgba(255, 159, 10, 0.12);
  --red: #ff453a;
  --red-text: #ff453a;
  --red-soft: rgba(255, 69, 58, 0.12);

  --hairline: rgba(255, 255, 255, 0.12);
  --hairline-strong: #424245;

  --diagram-line: #6e6e73;
  --diagram-fill: #1d1d1f;

  /* Xcode syntax palette, dark */
  --code-bg: #282a2f;
  --code-inline-bg: rgba(255, 255, 255, 0.1);
  --code-border: rgba(214, 214, 214, 0.2);
  --code-plain: #f5f5f7;
  --code-keyword: #ff7ab2;
  --code-string: #ff8170;
  --code-number: #d8c97c;
  --code-comment: #7e8c98;
  --code-type: #acf2e4;
  --code-method: #dabaff;

  --shadow-card: none;
  --shadow-card-hover: none;

  color-scheme: dark;
}

/* ---------- Reset & base ---------- */

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-sans);
  font-size: 1.0625rem; /* 17px */
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

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

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

a:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 4px;
}

::selection {
  background: var(--accent);
  color: #fff;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ---------- Typography ---------- */

h1,
h2,
h3,
h4 {
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.15;
  color: var(--text);
}

.display {
  font-size: clamp(2.875rem, 7.2vw, 5.25rem);
  font-weight: 700;
  letter-spacing: -0.035em;
  line-height: 1.03;
}

.title-lg {
  font-size: clamp(2rem, 4.2vw, 3rem);
  letter-spacing: -0.03em;
  line-height: 1.08;
}

.title-md {
  font-size: clamp(1.5rem, 2.8vw, 2rem);
  letter-spacing: -0.025em;
  line-height: 1.15;
}

.title-sm {
  font-size: 1.1875rem;
  letter-spacing: -0.015em;
}

.lede {
  font-size: clamp(1.1875rem, 2vw, 1.375rem);
  line-height: 1.5;
  letter-spacing: -0.012em;
  color: var(--text-secondary);
  font-weight: 400;
}

.eyebrow {
  display: block;
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--accent-text);
  margin-bottom: 1.1rem;
}

.muted {
  color: var(--text-secondary);
}

.small {
  font-size: 0.9375rem;
}

/* ---------- Layout ---------- */

.container {
  width: 100%;
  max-width: var(--w-content);
  margin-inline: auto;
  padding-inline: clamp(1.25rem, 4vw, 2rem);
}

.section {
  padding-block: clamp(4.5rem, 10vw, 8rem);
}

.section--tight {
  padding-block: clamp(3rem, 6vw, 5rem);
}

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

.section-head {
  max-width: 44rem;
  margin-bottom: clamp(2.5rem, 5vw, 4rem);
}

.section-head p {
  margin-top: 1.1rem;
  color: var(--text-secondary);
  font-size: 1.125rem;
}

/* ---------- Navigation ---------- */

.nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg);
  border-bottom: 1px solid var(--hairline);
}

.nav-inner {
  max-width: var(--w-content);
  margin-inline: auto;
  padding-inline: clamp(1.25rem, 4vw, 2rem);
  height: 3.5rem;
  display: flex;
  align-items: center;
  gap: 2rem;
}

.nav-brand {
  font-weight: 650;
  font-size: 1rem;
  letter-spacing: -0.015em;
  color: var(--text);
  white-space: nowrap;
}

.nav-brand:hover {
  text-decoration: none;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 1.6rem;
  list-style: none;
  margin-left: auto;
}

.nav-links a {
  font-size: 0.875rem;
  color: var(--text-secondary);
  transition: color 0.15s var(--ease);
}

.nav-links a:hover {
  color: var(--text);
  text-decoration: none;
}

.nav-links a[aria-current="page"] {
  color: var(--text);
  font-weight: 600;
}

/* Scoped to .nav-links so the pill outranks the plain `.nav-links a` rules —
   otherwise the mobile menu's `display: block` flattens it into a full-width bar. */
.nav-links .nav-cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: auto;
  font-size: 0.8125rem;
  font-weight: 600;
  color: #fff !important;
  background: var(--accent);
  padding: 0.42em 1.05em;
  border-radius: 980px;
  transition: background 0.15s var(--ease);
}

.nav-links .nav-cta:hover {
  background: var(--accent-strong);
  text-decoration: none;
}

.theme-toggle,
.nav-menu-btn {
  appearance: none;
  border: none;
  background: none;
  color: var(--text-secondary);
  width: 2.1rem;
  height: 2.1rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  cursor: pointer;
  transition: color 0.15s var(--ease), background 0.15s var(--ease);
}

.theme-toggle:hover,
.nav-menu-btn:hover {
  color: var(--text);
  background: var(--bg-subtle);
}

.theme-toggle .icon-sun { display: none; }
.theme-toggle .icon-moon { display: block; }

:root[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .icon-sun { display: block; }
  :root:not([data-theme="light"]) .theme-toggle .icon-moon { display: none; }
}

.nav-menu-btn {
  display: none;
}

@media (max-width: 860px) {
  .nav-menu-btn {
    display: inline-flex;
    margin-left: auto;
  }

  /* 2.1rem is a 34px hit area — under the 44px touch minimum, and these two are
     the most-tapped controls on a phone. The 3.5rem bar has room for it. */
  .theme-toggle,
  .nav-menu-btn {
    width: 2.75rem;
    height: 2.75rem;
  }

  .nav-links {
    display: none;
    position: absolute;
    top: 3.5rem;
    left: 0;
    right: 0;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    background: var(--bg);
    border-bottom: 1px solid var(--hairline);
    padding: 0.5rem 0 1rem;
  }

  .nav.is-open .nav-links {
    display: flex;
  }

  .nav-links li {
    padding-inline: clamp(1.25rem, 4vw, 2rem);
  }

  .nav-links a {
    display: block;
    font-size: 1.0625rem;
    padding: 0.72rem 0;
  }

  .nav-links li:has(.nav-cta) {
    margin-top: 0.85rem;
  }

  .nav-links .nav-cta {
    font-size: 0.9375rem;
    padding: 0 1.35em;
    min-height: 2.75rem;
  }
}

/* ---------- Buttons & text links ---------- */

.btn {
  display: inline-block;
  font-size: 1.0625rem;
  font-weight: 500;
  color: #fff;
  background: var(--accent);
  padding: 0.72em 1.5em;
  border-radius: 980px;
  border: none;
  cursor: pointer;
  font-family: inherit;
  letter-spacing: -0.01em;
  transition: background 0.18s var(--ease), transform 0.18s var(--ease);
}

.btn:hover {
  background: var(--accent-strong);
  text-decoration: none;
}

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

.btn--quiet {
  color: var(--text);
  background: var(--bg-subtle);
}

.btn--quiet:hover {
  background: var(--hairline);
}

.arrow-link {
  display: inline-flex;
  align-items: center;
  gap: 0.35em;
  font-size: 1.0625rem;
  font-weight: 500;
  color: var(--accent-text);
  letter-spacing: -0.01em;
}

.arrow-link::after {
  content: "→";
  transition: transform 0.18s var(--ease);
}

.arrow-link:hover {
  text-decoration: none;
}

.arrow-link:hover::after {
  transform: translateX(3px);
}

/* ---------- Hero ---------- */

.hero {
  padding-block: clamp(5rem, 12vw, 10rem) clamp(4rem, 9vw, 7rem);
}

.hero .display {
  max-width: 13ch;
}

.hero .lede {
  max-width: 40rem;
  margin-top: 1.75rem;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1.5rem;
  margin-top: 2.5rem;
}

/* Restrained entrance — hero only */
.hero > * {
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.7s var(--ease), transform 0.7s var(--ease);
}

body.is-loaded .hero > * {
  opacity: 1;
  transform: none;
}

body.is-loaded .hero > *:nth-child(2) { transition-delay: 0.08s; }
body.is-loaded .hero > *:nth-child(3) { transition-delay: 0.16s; }
body.is-loaded .hero > *:nth-child(4) { transition-delay: 0.24s; }
body.is-loaded .hero > *:nth-child(5) { transition-delay: 0.32s; }

.hero-intro {
  margin-top: 1.5rem;
  max-width: 40rem;
  color: var(--text-secondary);
}

.hero-intro a {
  color: var(--accent-text);
}

@media (prefers-reduced-motion: reduce) {
  .hero > * {
    opacity: 1;
    transform: none;
  }
}

/* ---------- Stats ---------- */

.stats {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 1px;
  background: var(--hairline);
  border-block: 1px solid var(--hairline);
}

.stat {
  background: var(--bg);
  padding: 2.25rem 1.75rem;
}

.stat--num {
  grid-column: span 2;
}

.stat--wide {
  grid-column: span 3;
}

.stat-value {
  font-size: clamp(2.25rem, 4.5vw, 3.25rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.05;
}

.stat-value em {
  font-style: normal;
  color: var(--accent-text);
}

.stat-label {
  margin-top: 0.5rem;
  font-size: 0.9375rem;
  color: var(--text-secondary);
}

.stat--wide .stat-value {
  font-size: clamp(1.5rem, 2.6vw, 1.9rem);
  letter-spacing: -0.02em;
}

@media (max-width: 720px) {
  .stat--num {
    grid-column: span 3;
  }

  .stat--num:nth-child(3) {
    grid-column: span 6;
  }

  .stat--wide {
    grid-column: span 6;
  }

  .stat {
    padding: 1.75rem 1.25rem;
  }
}

/* ---------- Cards & work grid ---------- */

.work-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.5rem;
}

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--bg-subtle);
  border: 1px solid transparent;
  border-radius: var(--radius-lg);
  padding: clamp(1.75rem, 3vw, 2.5rem);
  overflow: hidden;
  transition: transform 0.22s var(--ease), box-shadow 0.22s var(--ease),
    border-color 0.22s var(--ease);
}

:root[data-theme="dark"] .card { border-color: var(--hairline); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .card { border-color: var(--hairline); }
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-card-hover);
  border-color: var(--hairline-strong);
}

.card--feature {
  grid-column: 1 / -1;
  flex-direction: row;
  align-items: center;
  gap: clamp(2rem, 5vw, 4rem);
}

.card-body {
  flex: 1;
  min-width: 0;
}

.card-kicker {
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  margin-bottom: 0.85rem;
}

.card h3 {
  font-size: clamp(1.375rem, 2.4vw, 1.75rem);
  letter-spacing: -0.022em;
}

.card p {
  margin-top: 0.8rem;
  color: var(--text-secondary);
  max-width: 34rem;
}

.card .arrow-link {
  margin-top: 1.4rem;
  font-size: 0.9375rem;
}

.card-link-cover::before {
  content: "";
  position: absolute;
  inset: 0;
}

.card:hover .arrow-link::after {
  transform: translateX(3px);
}

.card--cta {
  align-items: flex-start;
  justify-content: center;
  background: transparent;
  border: 1px dashed var(--hairline-strong);
}

.card--cta:hover {
  box-shadow: none;
  border-color: var(--accent);
}

.card-visual {
  flex-shrink: 0;
  display: flex;
  justify-content: center;
}

@media (max-width: 860px) {
  .work-grid {
    grid-template-columns: 1fr;
  }

  .card--feature {
    flex-direction: column;
    align-items: stretch;
  }

  .card-visual {
    order: -1;
  }
}

/* ---------- Device frame + abstract mock UI ---------- */

.device {
  width: 232px;
  aspect-ratio: 9 / 19;
  border: 1px solid var(--hairline-strong);
  border-radius: 38px;
  padding: 9px;
  background: var(--bg);
  box-shadow: var(--shadow-card);
}

.device--sm {
  width: 176px;
  border-radius: 30px;
  padding: 7px;
}

.device-screen {
  height: 100%;
  border-radius: 29px;
  background: var(--bg-subtle);
  overflow: hidden;
  padding: 1.1rem 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.device--sm .device-screen {
  border-radius: 23px;
  padding: 0.85rem 0.7rem;
  gap: 0.5rem;
}

:root[data-theme="dark"] .device-screen { background: var(--bg-elevated); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .device-screen { background: var(--bg-elevated); }
}

/* Abstract UI atoms — deliberately schematic, never fake screenshots */
.m-bar {
  height: 8px;
  border-radius: 4px;
  background: var(--hairline-strong);
}

.m-bar--60 { width: 60%; }
.m-bar--40 { width: 40%; }
.m-bar--80 { width: 80%; }
.m-bar--accent { background: var(--accent); }

.m-title {
  height: 14px;
  width: 52%;
  border-radius: 5px;
  background: var(--text);
  opacity: 0.85;
}

.m-card {
  border-radius: 12px;
  background: var(--bg);
  border: 1px solid var(--hairline);
  padding: 0.7rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.m-card--accent {
  background: var(--accent);
  border-color: transparent;
}

.m-card--accent .m-bar {
  background: rgba(255, 255, 255, 0.45);
}

.m-card--accent .m-bar--bright {
  background: rgba(255, 255, 255, 0.95);
}

.m-row {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.m-row .m-bar { flex: none; }

.m-dot {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--hairline-strong);
  flex: none;
}

.m-dot--accent { background: var(--accent-soft); }

.m-glyph {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  margin: 0.6rem auto 0.2rem;
  border: 2px solid var(--accent-text);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-text);
}

.m-spacer { flex: 1; }

.m-keypad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.45rem;
  margin-top: 0.2rem;
}

.m-key {
  aspect-ratio: 1.6;
  border-radius: 8px;
  background: var(--bg);
  border: 1px solid var(--hairline);
}

/* ---------- Split hero (case studies) ---------- */

.hero-split {
  display: flex;
  align-items: center;
  gap: clamp(2rem, 6vw, 5rem);
}

.hero-split > div:first-child {
  flex: 1;
  min-width: 0;
}

.hero-split .case-visual {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

@media (max-width: 860px) {
  .hero-split {
    flex-direction: column;
    align-items: flex-start;
  }
}

/* Below ~560px two device mocks side by side are wider than the viewport.
   Cap the row and let the mocks scale down — aspect-ratio keeps them in shape. */
@media (max-width: 560px) {
  .hero-split .case-visual {
    max-width: 100%;
    gap: 0.85rem;
  }

  .hero-split .case-visual > * {
    flex-shrink: 1;
    min-width: 0;
  }
}

/* Widget-shaped mock (HeyWeather etc.) */
.m-widget {
  width: 150px;
  aspect-ratio: 1;
  border-radius: 26px;
  border: 1px solid var(--hairline-strong);
  background: var(--bg-subtle);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  box-shadow: var(--shadow-card);
}

:root[data-theme="dark"] .m-widget { background: var(--bg-elevated); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .m-widget { background: var(--bg-elevated); }
}

.m-sun {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0.85;
}

/* ---------- Quote band ---------- */

.quote-band {
  background: var(--bg-subtle);
  border-block: 1px solid var(--hairline);
}

.quote-band blockquote {
  font-size: clamp(1.5rem, 3.4vw, 2.375rem);
  font-weight: 600;
  letter-spacing: -0.028em;
  line-height: 1.25;
  max-width: 26em;
}

.quote-band blockquote em {
  font-style: normal;
  color: var(--accent-text);
}

.quote-band figcaption {
  margin-top: 1.5rem;
}

/* ---------- Case study ---------- */

.case-hero {
  padding-block: clamp(4.5rem, 10vw, 8rem) clamp(3rem, 6vw, 5rem);
}

.case-hero .lede {
  max-width: 42rem;
  margin-top: 1.5rem;
}

.spec-table {
  display: grid;
  /* minmax(0, 1fr) — otherwise a long unbreakable token (URLSessionWebSocketTask)
     sets the track's min-content width and pushes the grid past the viewport. */
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  background: var(--hairline);
  border-block: 1px solid var(--hairline);
}

.spec {
  background: var(--bg);
  padding: 1.5rem 1.5rem 1.6rem;
}

.spec dt {
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-tertiary);
}

.spec dd {
  margin-top: 0.45rem;
  font-size: 1rem;
  font-weight: 500;
  letter-spacing: -0.01em;
  overflow-wrap: anywhere;
}

@media (max-width: 760px) {
  .spec-table {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .spec {
    padding: 1.25rem 1.15rem 1.35rem;
  }
}

/* Two columns leave ~130px per cell on a phone, which breaks long type names
   mid-word. One column gives them the full measure. */
@media (max-width: 480px) {
  .spec-table {
    grid-template-columns: minmax(0, 1fr);
  }

  .spec {
    padding: 1.15rem clamp(1.25rem, 4vw, 2rem);
  }
}

/* ---------- Diagram ---------- */

.diagram {
  border: 1px solid var(--hairline);
  border-radius: var(--radius-lg);
  background: var(--bg);
  padding: clamp(1.25rem, 3vw, 2.5rem);
  overflow-x: auto;
}

.diagram svg {
  min-width: 640px;
  width: 100%;
  height: auto;
  font-family: var(--font-sans);
}

.diagram figcaption,
figure.fig > figcaption {
  margin-top: 1rem;
  font-size: 0.9375rem;
  color: var(--text-tertiary);
  padding-inline: 0.25rem;
}

/* SVG diagram vocabulary */
.d-box {
  fill: var(--diagram-fill);
  stroke: var(--diagram-line);
  stroke-width: 1;
}

.d-box--accent {
  fill: var(--accent-soft);
  stroke: var(--accent);
}

.d-box--plain {
  fill: var(--bg);
  stroke: var(--diagram-line);
}

.d-group {
  fill: none;
  stroke: var(--diagram-line);
  stroke-width: 1;
  stroke-dasharray: 4 4;
}

.d-label {
  fill: var(--text);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.d-label--accent {
  fill: var(--accent-text);
}

.d-sub {
  fill: var(--text-secondary);
  font-size: 11px;
  font-weight: 400;
}

.d-line {
  stroke: var(--diagram-line);
  stroke-width: 1.25;
  fill: none;
}

.d-head {
  fill: var(--text-tertiary);
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.09em;
}

.d-line--accent {
  stroke: var(--accent-text);
}

/* ---------- Decisions / numbered blocks ---------- */

.decision-list {
  display: grid;
  gap: 0;
  border-top: 1px solid var(--hairline);
}

.decision {
  display: grid;
  grid-template-columns: 4.5rem 1fr;
  gap: 1.5rem;
  padding-block: 2.25rem;
  border-bottom: 1px solid var(--hairline);
}

.decision-num {
  font-family: var(--font-mono);
  font-size: 0.9375rem;
  color: var(--text-tertiary);
  padding-top: 0.3rem;
}

.decision h3 {
  font-size: 1.25rem;
  letter-spacing: -0.018em;
}

.decision p {
  margin-top: 0.7rem;
  color: var(--text-secondary);
  max-width: 40rem;
}

.decision p + p {
  margin-top: 0.9rem;
}

@media (max-width: 640px) {
  .decision {
    grid-template-columns: 1fr;
    gap: 0.6rem;
  }
}

/* ---------- Trade-offs ---------- */

.tradeoff-list {
  border-top: 1px solid var(--hairline);
}

.tradeoff {
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  gap: clamp(1.5rem, 4vw, 3.5rem);
  padding-block: 2rem;
  border-bottom: 1px solid var(--hairline);
}

.tradeoff h3 {
  font-size: 1.125rem;
  letter-spacing: -0.014em;
}

.tradeoff .gain {
  margin-top: 0.55rem;
  color: var(--text-secondary);
  max-width: 32rem;
}

/* "The cost" — Apple tints cautionary labels rather than leaving them grey. */
.t-label {
  display: block;
  font-size: 0.78125rem;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--orange-text);
  margin-bottom: 0.5rem;
}

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

@media (max-width: 700px) {
  .tradeoff {
    grid-template-columns: 1fr;
    gap: 1.1rem;
  }
}

/* ---------- Notes ---------- */

.note-list {
  border-top: 1px solid var(--hairline);
  max-width: 52rem;
}

.note {
  padding-block: 2.5rem;
  border-bottom: 1px solid var(--hairline);
}

.note-text {
  font-size: clamp(1.3125rem, 2.4vw, 1.75rem);
  font-weight: 600;
  letter-spacing: -0.022em;
  line-height: 1.3;
  max-width: 26em;
}

.note-more {
  margin-top: 0.75rem;
  color: var(--text-secondary);
  max-width: 40rem;
}

.note time {
  display: block;
  margin-top: 1rem;
  font-size: 0.875rem;
  color: var(--text-tertiary);
  font-variant-numeric: tabular-nums;
}

/* ---------- Reading ---------- */

.book-list {
  border-top: 1px solid var(--hairline);
}

.book {
  display: grid;
  grid-template-columns: 17rem 1fr;
  gap: clamp(1.5rem, 4vw, 3rem);
  padding-block: 1.9rem;
  border-bottom: 1px solid var(--hairline);
}

.book h3 {
  font-size: 1.0625rem;
  letter-spacing: -0.012em;
}

.book .author {
  margin-top: 0.25rem;
  font-size: 0.9375rem;
  color: var(--text-tertiary);
}

.book p.why {
  color: var(--text-secondary);
  max-width: 40rem;
}

@media (max-width: 700px) {
  .book {
    grid-template-columns: 1fr;
    gap: 0.6rem;
  }
}

/* ---------- Metrics ---------- */

.metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.5rem;
}

.metric {
  background: var(--bg-subtle);
  border-radius: var(--radius-md);
  padding: 1.75rem;
}

:root[data-theme="dark"] .metric { border: 1px solid var(--hairline); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .metric { border: 1px solid var(--hairline); }
}

.metric-value {
  font-size: clamp(1.9rem, 3.4vw, 2.5rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.05;
  color: var(--accent-text);
}

.metric-label {
  margin-top: 0.5rem;
  font-weight: 600;
  font-size: 0.9375rem;
  letter-spacing: -0.005em;
}

.metric-note {
  margin-top: 0.35rem;
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

@media (max-width: 760px) {
  .metrics {
    grid-template-columns: 1fr;
  }
}

/* ---------- Prose (articles, essays, case narrative) ---------- */

.prose {
  max-width: var(--w-prose);
}

.prose > * + * {
  margin-top: 1.35rem;
}

.prose h2 {
  font-size: 1.625rem;
  letter-spacing: -0.022em;
  margin-top: 3.25rem;
}

.prose h3 {
  font-size: 1.25rem;
  letter-spacing: -0.015em;
  margin-top: 2.5rem;
}

.prose p,
.prose li {
  color: var(--text);
}

.prose p {
  line-height: 1.7;
}

.prose ul,
.prose ol {
  padding-left: 1.35rem;
}

.prose li + li {
  margin-top: 0.5rem;
}

.prose strong {
  font-weight: 650;
}

.prose blockquote {
  border-left: 3px solid var(--accent);
  padding: 0.35rem 0 0.35rem 1.5rem;
  font-size: 1.25rem;
  font-weight: 550;
  letter-spacing: -0.015em;
  line-height: 1.45;
  color: var(--text);
  margin-block: 2.25rem;
}

.prose hr {
  border: none;
  border-top: 1px solid var(--hairline);
  margin-block: 3rem;
}

.prose code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  background: var(--code-inline-bg);
  border: 1px solid var(--code-border);
  border-radius: 5px;
  padding: 0.12em 0.38em;
  white-space: nowrap;
}

.prose pre {
  background: var(--code-bg);
  border: 1px solid var(--code-border);
  border-radius: var(--radius-md);
  padding: 1.4rem 1.5rem;
  overflow-x: auto;
  line-height: 1.6;
  margin-block: 1.75rem;
}

.prose pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: 0.8525rem;
  white-space: pre;
  color: var(--code-plain);
}

/* Xcode syntax colors, applied by the highlighter in js/main.js */
.tok-keyword { color: var(--code-keyword); }
.tok-string { color: var(--code-string); }
.tok-number { color: var(--code-number); }
.tok-comment { color: var(--code-comment); }
.tok-type { color: var(--code-type); }
.tok-method { color: var(--code-method); }

/* nowrap keeps short identifiers intact on desktop, but a long API name has to
   be allowed to break on a phone rather than push the page sideways. */
@media (max-width: 640px) {
  .prose :not(pre) > code {
    white-space: normal;
    overflow-wrap: anywhere;
  }
}

.prose figure {
  margin-block: 2.25rem;
}

/* ---------- Article meta ---------- */

.article-hero {
  padding-block: clamp(4rem, 9vw, 7rem) clamp(2.5rem, 5vw, 4rem);
}

.article-hero h1 {
  font-size: clamp(2.125rem, 4.6vw, 3.25rem);
  letter-spacing: -0.03em;
  line-height: 1.08;
  max-width: 20ch;
}

.article-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem 1rem;
  margin-top: 1.4rem;
  font-size: 0.9375rem;
  color: var(--text-tertiary);
}

.article-meta .sep {
  opacity: 0.6;
}

/* Technology chips, tinted the way developer.apple.com tags its frameworks. */
.tag {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--accent-text);
  background: var(--accent-soft);
  border: 1px solid transparent;
  border-radius: 980px;
  padding: 0.22em 0.75em;
}

/* ---------- Writing index ---------- */

.article-list {
  border-top: 1px solid var(--hairline);
}

.article-row {
  position: relative;
  display: grid;
  grid-template-columns: 9rem 1fr auto;
  gap: 1.5rem;
  align-items: baseline;
  padding-block: 2rem;
  border-bottom: 1px solid var(--hairline);
  transition: background 0.15s var(--ease);
}

.article-row:hover {
  background: var(--bg-subtle);
}

.article-row time {
  font-size: 0.9375rem;
  color: var(--text-tertiary);
  font-variant-numeric: tabular-nums;
}

.article-row h3 {
  font-size: 1.3125rem;
  letter-spacing: -0.018em;
}

.article-row h3 a {
  color: var(--text);
}

.article-row h3 a:hover {
  text-decoration: none;
  color: var(--accent-text);
}

.article-row p {
  margin-top: 0.5rem;
  color: var(--text-secondary);
  max-width: 38rem;
}

.article-row .tags {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  justify-content: flex-end;
  max-width: 14rem;
}

@media (max-width: 760px) {
  .article-row {
    grid-template-columns: 1fr;
    gap: 0.5rem;
  }

  .article-row .tags {
    justify-content: flex-start;
    margin-top: 0.4rem;
  }
}

/* ---------- Open-source packages ---------- */

.pkg-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.5rem;
}

.pkg {
  border: 1px solid var(--hairline);
  border-radius: var(--radius-lg);
  padding: 2rem;
  display: flex;
  flex-direction: column;
  transition: border-color 0.2s var(--ease), transform 0.2s var(--ease);
}

.pkg:hover {
  border-color: var(--hairline-strong);
  transform: translateY(-2px);
}

.pkg-name {
  font-family: var(--font-mono);
  font-size: 1.125rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  min-width: 0;
  overflow-wrap: anywhere;
}

.pkg-status {
  display: inline-flex;
  align-items: center;
  gap: 0.45em;
  font-size: 0.78125rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-left: auto;
}

.pkg-status::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-tertiary);
}

.pkg-status--active::before { background: var(--green); }
.pkg-status--design::before { background: var(--accent-text); }

.pkg-status--active { color: var(--green-text); }
.pkg-status--design { color: var(--accent-text); }

.pkg-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
}

.pkg p {
  margin-top: 1rem;
  color: var(--text-secondary);
}

.pkg ul {
  margin-top: 1.1rem;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  font-size: 0.9375rem;
  color: var(--text-secondary);
}

.pkg ul li::before {
  content: "—";
  color: var(--text-tertiary);
  margin-right: 0.55em;
}

@media (max-width: 760px) {
  .pkg-grid {
    grid-template-columns: 1fr;
  }
}

/* Once the status chip wraps under the package name, pushing it right leaves it
   stranded — align it with the name instead. */
@media (max-width: 480px) {
  .pkg-status {
    margin-left: 0;
  }
}

.pkg--full {
  padding: clamp(2rem, 4vw, 2.75rem);
}

.pkg--full:hover {
  transform: none;
}

.pkg-mission {
  margin-top: 0.9rem;
  font-size: 1.1875rem;
  font-weight: 550;
  letter-spacing: -0.015em;
  line-height: 1.45;
  max-width: 36rem;
}

.pkg-cols {
  display: grid;
  grid-template-columns: 1.1fr 1.1fr 1fr;
  gap: clamp(1.5rem, 3.5vw, 3rem);
  margin-top: 1.75rem;
  padding-top: 1.75rem;
  border-top: 1px solid var(--hairline);
}

.pkg-cols h4 {
  font-size: 0.78125rem;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-tertiary);
}

.pkg-cols p {
  margin-top: 0.65rem;
  font-size: 0.9875rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

.pkg-cols ul {
  margin-top: 0.65rem;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  font-size: 0.9375rem;
  color: var(--text-secondary);
}

.pkg-cols ul strong {
  color: var(--text);
  font-weight: 600;
}

@media (max-width: 760px) {
  .pkg-cols {
    grid-template-columns: 1fr;
  }
}

/* ---------- Roadmap timeline ---------- */

.timeline {
  border-left: 1px solid var(--hairline-strong);
  margin-left: 0.4rem;
  padding-left: 2rem;
  display: flex;
  flex-direction: column;
  gap: 2.5rem;
}

.timeline-item {
  position: relative;
}

.timeline-item::before {
  content: "";
  position: absolute;
  left: calc(-2rem - 5px);
  top: 0.5rem;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--bg);
  border: 2px solid var(--text-tertiary);
}

.timeline-item--now::before {
  background: var(--accent);
  border-color: var(--accent);
}

.timeline-date {
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-tertiary);
}

.timeline-item h3 {
  margin-top: 0.4rem;
  font-size: 1.1875rem;
  letter-spacing: -0.015em;
}

.timeline-item p {
  margin-top: 0.5rem;
  color: var(--text-secondary);
  max-width: 38rem;
}

/* ---------- Contact / list rows ---------- */

.link-rows {
  border-top: 1px solid var(--hairline);
  max-width: 44rem;
}

.link-row {
  display: flex;
  align-items: baseline;
  gap: 1.5rem;
  padding-block: 1.6rem;
  border-bottom: 1px solid var(--hairline);
}

.link-row dt {
  flex: 0 0 8.5rem;
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-tertiary);
}

.link-row dd {
  font-size: 1.1875rem;
  letter-spacing: -0.012em;
  font-weight: 500;
  min-width: 0;
  overflow-wrap: anywhere;
}

/* The label column plus an email address does not fit on a narrow phone. */
@media (max-width: 560px) {
  .link-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.45rem;
  }

  .link-row dt {
    flex: none;
  }

  /* These are the page's primary actions; give them a full touch target. */
  .link-row dd a {
    display: inline-flex;
    align-items: center;
    min-height: 2.75rem;
  }
}

/* ---------- Résumé ---------- */

.resume {
  max-width: 50rem;
}

.resume-section {
  margin-top: 3.5rem;
}

.resume-section > h2 {
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--accent-text);
  padding-bottom: 0.85rem;
  border-bottom: 1px solid var(--hairline);
}

.resume-item {
  display: grid;
  grid-template-columns: 10.5rem 1fr;
  gap: 1.75rem;
  padding-block: 1.9rem;
  border-bottom: 1px solid var(--hairline);
}

.resume-item time,
.resume-item .where {
  font-size: 0.9375rem;
  color: var(--text-tertiary);
  font-variant-numeric: tabular-nums;
}

.resume-item h3 {
  font-size: 1.125rem;
  letter-spacing: -0.014em;
}

.resume-item .org {
  margin-top: 0.15rem;
  font-size: 0.9875rem;
  color: var(--text-secondary);
}

.resume-item ul {
  margin-top: 0.9rem;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  color: var(--text-secondary);
  font-size: 0.9875rem;
  line-height: 1.6;
}

.resume-item ul li::before {
  content: "—";
  color: var(--text-tertiary);
  margin-right: 0.55em;
}

.skill-cols {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2rem;
  padding-top: 1.75rem;
}

.skill-cols h3 {
  font-size: 0.9375rem;
  letter-spacing: -0.005em;
}

.skill-cols ul {
  margin-top: 0.7rem;
  list-style: none;
  color: var(--text-secondary);
  font-size: 0.9375rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

@media (max-width: 720px) {
  .resume-item {
    grid-template-columns: 1fr;
    gap: 0.5rem;
  }

  .skill-cols {
    grid-template-columns: 1fr;
  }
}

/* ---------- Footer ---------- */

.footer {
  border-top: 1px solid var(--hairline);
  padding-block: 3.5rem 3rem;
  font-size: 0.9375rem;
}

.footer-grid {
  display: grid;
  grid-template-columns: 1.7fr 1fr 1fr 1fr;
  gap: 2.5rem;
}

.footer-brand {
  font-weight: 650;
  letter-spacing: -0.015em;
  color: var(--text);
  font-size: 1rem;
}

.footer-tagline {
  margin-top: 0.6rem;
  color: var(--text-tertiary);
  max-width: 20rem;
}

.footer h4 {
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-tertiary);
}

.footer ul {
  list-style: none;
  margin-top: 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.footer a {
  color: var(--text-secondary);
}

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

.footer-bottom {
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--hairline);
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  justify-content: space-between;
  align-items: baseline;
  color: var(--text-tertiary);
  font-size: 0.875rem;
}

.footer-motto {
  font-size: 0.9375rem;
  font-weight: 600;
  letter-spacing: -0.008em;
  color: var(--text);
}

@media (max-width: 720px) {
  .footer-grid {
    grid-template-columns: 1fr 1fr;
  }

  .footer-grid > div:first-child {
    grid-column: 1 / -1;
  }
}

/* ---------- Pagination between case studies / articles ---------- */

.next-nav {
  border-top: 1px solid var(--hairline);
  display: grid;
  grid-template-columns: 1fr 1fr;
}

.next-nav a {
  padding: 2.5rem clamp(1.25rem, 4vw, 2rem);
  color: var(--text);
  transition: background 0.15s var(--ease);
}

.next-nav a:hover {
  background: var(--bg-subtle);
  text-decoration: none;
}

.next-nav a + a {
  border-left: 1px solid var(--hairline);
  text-align: right;
}

.next-nav .dir {
  display: block;
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  margin-bottom: 0.5rem;
}

.next-nav .dest {
  font-size: 1.25rem;
  font-weight: 650;
  letter-spacing: -0.018em;
}

/* ---------- Print (résumé) ---------- */

@media print {
  :root {
    --bg: #ffffff;
    --bg-subtle: #f4f4f5;
    --text: #111111;
    --text-secondary: #444448;
    --text-tertiary: #6e6e73;
    --accent: #0064d1;
    --hairline: #d9d9de;
    --hairline-strong: #c5c5cb;
  }

  .nav,
  .footer,
  .no-print {
    display: none !important;
  }

  body {
    font-size: 10pt;
    background: #fff;
  }

  .resume-section {
    margin-top: 2rem;
  }

  .resume-item {
    padding-block: 1.2rem;
  }

  .resume-item ul {
    gap: 0.4rem;
  }

  .section {
    padding-block: 0;
  }

  .resume {
    max-width: none;
  }

  .resume-hero {
    padding-top: 0 !important;
  }

  .resume-section > h2,
  .resume-item h3 {
    break-after: avoid;
  }

  .resume-item li,
  .skill-cols {
    break-inside: avoid;
  }

  a {
    color: inherit;
    text-decoration: none;
  }

  @page {
    margin: 1.6cm 1.8cm;
  }
}
