/* Shared tokens and base styles (all pages) */
:root {
  --paper: #f7f3ec;
  --ink: #1f2330;
  --ink-soft: #5a5e6c;
  --rule: #e4ddd0;
  --racing-green: #0B6B42;
  --gulf-orange: #D4691A;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #1f2330;
    --ink: #f7f3ec;
    --ink-soft: #8a8578;
    --rule: rgba(247, 243, 236, 0.12);
  }
}

:root[data-theme="dark"] {
  --paper: #1f2330;
  --ink: #f7f3ec;
  --ink-soft: #8a8578;
  --rule: rgba(247, 243, 236, 0.12);
  --racing-green: #3FA876;
}

:root[data-theme="light"] {
  --paper: #f7f3ec;
  --ink: #1f2330;
  --ink-soft: #5a5e6c;
  --rule: #e4ddd0;
  --racing-green: #0B6B42;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --racing-green: #3FA876;
  }
}

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

html {
  background: var(--paper);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color 220ms ease, color 220ms ease;
}

@media (prefers-reduced-motion: reduce) {
  html { transition: none; }
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 16px;
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

main {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 80px 24px 48px;
}

.stack {
  width: 100%;
  max-width: 620px;
}

footer {
  padding: 24px;
  font-family: 'Inter', sans-serif;
  font-size: 12px;
  color: var(--ink-soft);
  max-width: 620px;
  margin: 0 auto;
  width: 100%;
}

footer p { margin: 0; }

/* Home page only (`index.html`, `body.home`) */
body.home .wordmark {
  font-family: 'Literata', Georgia, serif;
  font-weight: 500;
  font-size: clamp(44px, 8vw, 68px);
  line-height: 1;
  letter-spacing: -0.02em;
  margin: 0 0 56px;
}

body.home .wordmark .cairn { color: var(--ink); }
body.home .wordmark .basis { color: var(--racing-green); }

body.home .headline {
  font-family: 'Literata', Georgia, serif;
  font-weight: 400;
  font-size: clamp(28px, 4.2vw, 40px);
  line-height: 1.15;
  letter-spacing: -0.015em;
  margin: 0 0 20px;
  color: var(--ink);
}

body.home .subline {
  font-family: 'Literata', Georgia, serif;
  font-weight: 400;
  font-size: clamp(17px, 2.2vw, 20px);
  line-height: 1.45;
  color: var(--ink-soft);
  margin: 0 0 56px;
  max-width: 560px;
}

body.home .contact {
  border-top: 1px solid var(--rule);
  padding-top: 28px;
}

body.home .contact-label {
  font-family: 'Inter', sans-serif;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin: 0 0 12px;
}

body.home .contact-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
  margin: 0;
  padding: 0;
  list-style: none;
  font-family: 'Inter', sans-serif;
  font-size: 16px;
}

body.home .contact-links a {
  color: var(--ink);
  text-decoration: none;
  border-bottom: 1px solid var(--rule);
  padding-bottom: 2px;
  transition: color 150ms ease, border-color 150ms ease;
}

body.home .contact-links a:hover,
body.home .contact-links a:focus-visible {
  color: var(--racing-green);
  border-bottom-color: var(--racing-green);
}

body.home .contact-links a:focus-visible {
  outline: 2px solid var(--racing-green);
  outline-offset: 4px;
  border-radius: 2px;
}

body.home .theme-toggle {
  position: fixed;
  top: 20px;
  right: 20px;
  width: 36px;
  height: 36px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  color: var(--ink-soft);
  border: 1px solid var(--rule);
  border-radius: 7px;
  cursor: pointer;
  font: inherit;
  transition: color 150ms ease, border-color 150ms ease;
  -webkit-tap-highlight-color: transparent;
}

body.home .theme-toggle:hover,
body.home .theme-toggle:focus-visible {
  color: var(--racing-green);
  border-color: var(--racing-green);
}

body.home .theme-toggle:focus-visible {
  outline: 2px solid var(--racing-green);
  outline-offset: 4px;
}

body.home .theme-toggle svg {
  width: 16px;
  height: 16px;
  display: block;
}

body.home .theme-toggle .icon-sun { display: none; }

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

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

/* Not-found page only (`404.html`, `body.not-found`) */
body.not-found .wordmark-link {
  display: inline-block;
  text-decoration: none;
  color: inherit;
  margin: 0 0 48px;
  border-radius: 2px;
}

body.not-found .wordmark-link:focus-visible {
  outline: 2px solid var(--gulf-orange);
  outline-offset: 6px;
}

body.not-found .wordmark {
  font-family: 'Literata', Georgia, serif;
  font-weight: 500;
  font-size: clamp(32px, 5vw, 44px);
  line-height: 1;
  letter-spacing: -0.02em;
  margin: 0;
  color: var(--ink);
}

body.not-found .numeral {
  font-family: 'Literata', Georgia, serif;
  font-weight: 500;
  font-size: clamp(88px, 16vw, 148px);
  line-height: 0.95;
  letter-spacing: -0.03em;
  color: var(--gulf-orange);
  margin: 0 0 20px;
}

body.not-found .headline {
  font-family: 'Literata', Georgia, serif;
  font-weight: 400;
  font-size: clamp(24px, 3.4vw, 32px);
  line-height: 1.2;
  letter-spacing: -0.015em;
  margin: 0 0 40px;
  color: var(--ink);
}

body.not-found .back {
  border-top: 1px solid var(--rule);
  padding-top: 28px;
  font-family: 'Inter', sans-serif;
  font-size: 16px;
  margin: 0;
}

body.not-found .back a {
  color: var(--ink);
  text-decoration: none;
  border-bottom: 1px solid var(--rule);
  padding-bottom: 2px;
  transition: color 150ms ease, border-color 150ms ease;
}

body.not-found .back a:hover,
body.not-found .back a:focus-visible {
  color: var(--gulf-orange);
  border-bottom-color: var(--gulf-orange);
}

body.not-found .back a:focus-visible {
  outline: 2px solid var(--gulf-orange);
  outline-offset: 4px;
  border-radius: 2px;
}

/* Home page only: respect reduced motion for theme toggle */
@media (prefers-reduced-motion: reduce) {
  body.home .theme-toggle { transition: none; }
}

/* Responsive tweaks (shared + page-specific adjustments) */
@media (max-width: 480px) {
  main { padding: 56px 20px 32px; }
  footer { padding: 20px; }

  body.home .wordmark { margin-bottom: 40px; }
  body.home .subline { margin-bottom: 40px; }
  body.home .theme-toggle { top: 16px; right: 16px; }

  body.not-found .wordmark-link { margin-bottom: 32px; }
  body.not-found .numeral { margin-bottom: 16px; }
  body.not-found .headline { margin-bottom: 28px; }
}
