/* ===== Design tokens — shared across the .guide network ===== */

:root, [data-theme="light"] {
  /* Type scale — bumped for clarity. Body floor 17px, scales to ~19px on wide screens. */
  --text-xs: clamp(0.8125rem, 0.78rem + 0.18vw, 0.9375rem);
  --text-sm: clamp(0.9375rem, 0.88rem + 0.28vw, 1.0625rem);
  --text-base: clamp(1.0625rem, 1rem + 0.32vw, 1.1875rem);
  --text-lg: clamp(1.1875rem, 1.05rem + 0.7vw, 1.5rem);
  --text-xl: clamp(1.5rem, 1.2rem + 1.25vw, 2.25rem);
  --text-2xl: clamp(2rem, 1.2rem + 2.5vw, 3.5rem);
  --text-3xl: clamp(2.5rem, 1rem + 4vw, 5rem);

  /* Spacing — 4px base */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;
  --space-20: 5rem;
  --space-24: 6rem;
  --space-32: 8rem;

  /* Surfaces — paper warm */
  --color-bg: #f6f3ec;
  --color-surface: #fbf8f1;
  --color-surface-2: #efeadf;
  --color-divider: #d8d2c2;
  --color-border: #c8c1b0;

  /* Text — deep ink. Muted darkened from #6b665b to #4a463c for AA contrast on warm bg. */
  --color-text: #14130f;
  --color-text-muted: #4a463c;
  --color-text-faint: #7a7466;

  /* Defaults — overridden per site */
  --color-primary: #1f5e57;
  --color-primary-hover: #163f3a;
  --color-primary-soft: #e2ebe6;

  /* Functional */
  --color-warning: #964219;
  --color-error: #8a2547;
  --color-success: #2e6021;

  /* Radius */
  --radius-sm: 0.25rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-full: 9999px;

  /* Transitions */
  --transition-interactive: 200ms cubic-bezier(0.16, 1, 0.3, 1);

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(29, 28, 24, 0.06);
  --shadow-md: 0 6px 18px rgba(29, 28, 24, 0.08);

  /* Content widths — editorial */
  --content-narrow: 640px;
  --content-default: 880px;
  --content-wide: 1100px;

  /* Fonts — humanist sans (Source Sans 3, BA's nearest free relative) for body, matched serif for display. */
  --font-body: 'Source Sans 3', 'Helvetica Neue', Arial, sans-serif;
  --font-display: 'Source Serif 4', Georgia, serif;
}

[data-theme="dark"] {
  --color-bg: #15140f;
  --color-surface: #1c1b16;
  --color-surface-2: #24221c;
  --color-divider: #2d2b25;
  --color-border: #3b3830;
  --color-text: #e8e3d4;
  --color-text-muted: #8c8678;
  --color-text-faint: #5d5849;
  --color-primary-soft: #1b2925;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 6px 18px rgba(0, 0, 0, 0.4);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --color-bg: #15140f;
    --color-surface: #1c1b16;
    --color-surface-2: #24221c;
    --color-divider: #2d2b25;
    --color-border: #3b3830;
    --color-text: #e8e3d4;
    --color-text-muted: #8c8678;
    --color-text-faint: #5d5849;
    --color-primary-soft: #1b2925;
  }
}

/* ===== Reset ===== */

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

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  scroll-behavior: smooth;
  scroll-padding-top: var(--space-16);
}

body {
  min-height: 100dvh;
  line-height: 1.55;
  font-family: var(--font-body);
  font-size: var(--text-base);
  color: var(--color-text);
  background-color: var(--color-bg);
}

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

h1, h2, h3, h4 {
  text-wrap: balance;
  line-height: 1.15;
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: -0.015em;
}

p, li {
  text-wrap: pretty;
  max-width: 64ch;
}

button { cursor: pointer; background: none; border: none; }
a { color: inherit; text-decoration: none; }

::selection {
  background: var(--color-primary);
  color: var(--color-bg);
}

:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 3px;
  border-radius: var(--radius-sm);
}

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

a, button {
  transition: color var(--transition-interactive),
              background var(--transition-interactive),
              border-color var(--transition-interactive),
              opacity var(--transition-interactive);
}

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

/* ===== Layout primitives ===== */

.wrap {
  width: 100%;
  max-width: var(--content-default);
  margin-inline: auto;
  padding-inline: clamp(var(--space-5), 5vw, var(--space-8));
}

.wrap-narrow {
  max-width: var(--content-narrow);
  margin-inline: auto;
  padding-inline: clamp(var(--space-5), 5vw, var(--space-8));
}

section {
  padding-block: clamp(var(--space-12), 8vw, var(--space-24));
}

section + section {
  border-top: 1px solid var(--color-divider);
}

/* ===== Header ===== */

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(246, 243, 236, 0.85);
  backdrop-filter: saturate(140%) blur(10px);
  -webkit-backdrop-filter: saturate(140%) blur(10px);
  border-bottom: 1px solid var(--color-divider);
}

[data-theme="dark"] .site-header,
@media (prefers-color-scheme: dark) {
  .site-header { background: rgba(21, 20, 15, 0.85); }
}

.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-6);
  padding-block: var(--space-4);
  width: 100%;
  max-width: var(--content-default);
  margin-inline: auto;
  padding-inline: clamp(var(--space-5), 5vw, var(--space-8));
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  font-family: var(--font-body);
  font-weight: 700;
  font-size: var(--text-lg);
  letter-spacing: -0.02em;
  color: var(--color-text);
}

.brand-mark {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
}

.nav-links {
  display: flex;
  gap: var(--space-5);
  list-style: none;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-text);
}

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

.nav-actions {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.theme-toggle {
  width: 36px; height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-muted);
  border-radius: var(--radius-full);
}

.theme-toggle:hover {
  color: var(--color-text);
  background: var(--color-surface-2);
}

@media (max-width: 640px) {
  .nav-links { display: none; }
}

/* ===== Hero ===== */

.hero {
  padding-block: clamp(var(--space-16), 12vw, var(--space-32));
}

.hero-eyebrow {
  display: inline-block;
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--color-text-muted);
  margin-bottom: var(--space-6);
}

.hero h1 {
  font-size: var(--text-2xl);
  margin-bottom: var(--space-6);
  max-width: 22ch;
  font-weight: 600;
}

.hero-lede {
  font-size: var(--text-lg);
  color: var(--color-text);
  max-width: 56ch;
  margin-bottom: var(--space-8);
  line-height: 1.5;
}

.hero-meta {
  font-size: var(--text-sm);
  color: var(--color-text-faint);
  margin-top: var(--space-8);
  padding-top: var(--space-6);
  border-top: 1px solid var(--color-divider);
  max-width: 60ch;
}

/* ===== Sections ===== */

.section-eyebrow {
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--color-text-muted);
  margin-bottom: var(--space-4);
}

h2 {
  font-size: var(--text-xl);
  margin-bottom: var(--space-6);
  max-width: 26ch;
  font-weight: 600;
}

h3 {
  font-size: var(--text-lg);
  margin-bottom: var(--space-3);
  margin-top: var(--space-8);
  font-weight: 700;
  font-family: var(--font-body);
  letter-spacing: -0.005em;
}

p { margin-bottom: var(--space-4); }
p:last-child { margin-bottom: 0; }

/* Pull line — short emphatic */
.pull {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: var(--text-xl);
  line-height: 1.2;
  color: var(--color-text);
  max-width: 24ch;
  margin-block: var(--space-10);
  padding-left: var(--space-5);
  border-left: 3px solid var(--color-primary);
}

/* Body emphasis sentence */
.lede {
  font-size: var(--text-lg);
  line-height: 1.45;
  margin-bottom: var(--space-6);
  max-width: 60ch;
  color: var(--color-text);
  font-weight: 400;
}

.lede strong, p strong, li strong {
  font-weight: 700;
  color: var(--color-text);
}

/* Two-column on wider screens */
.two-col {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-10);
}

@media (min-width: 768px) {
  .two-col {
    grid-template-columns: 1fr 1fr;
    gap: var(--space-16);
  }
}

/* List — checkpoint style */
.checklist {
  list-style: none;
  display: grid;
  gap: var(--space-4);
  margin-block: var(--space-6);
}

.checklist li {
  padding-left: var(--space-6);
  position: relative;
  max-width: 64ch;
}

.checklist li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.6em;
  width: 12px;
  height: 1px;
  background: var(--color-primary);
}

/* CTA links — quiet, editorial */
.cta-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3) var(--space-6);
  margin-top: var(--space-8);
  font-size: var(--text-sm);
}

.cta {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-5);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  color: var(--color-text);
  font-weight: 500;
  background: var(--color-surface);
}

.cta:hover {
  border-color: var(--color-text);
  background: var(--color-surface-2);
}

.cta-primary {
  background: var(--color-text);
  border-color: var(--color-text);
  color: var(--color-bg);
}

.cta-primary:hover {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: var(--color-bg);
}

.cta-link {
  color: var(--color-text-muted);
  text-decoration: underline;
  text-decoration-color: var(--color-text-faint);
  text-underline-offset: 4px;
}

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

/* ===== Start-here list ===== */

.start-here {
  display: grid;
  gap: var(--space-5);
  list-style: none;
  margin-top: var(--space-8);
}

.start-here li {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-1);
  padding: var(--space-5) 0;
  border-bottom: 1px solid var(--color-divider);
  max-width: none;
}

.start-here li:first-child {
  border-top: 1px solid var(--color-divider);
}

.start-here .if {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

.start-here .then {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  color: var(--color-text);
}

.start-here a {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-4);
}

.start-here a:hover .then {
  color: var(--color-primary);
}

@media (min-width: 720px) {
  .start-here li {
    grid-template-columns: 1fr auto;
    align-items: baseline;
  }
}

/* ===== Footer ===== */

.site-footer {
  padding-block: var(--space-16) var(--space-12);
  border-top: 1px solid var(--color-divider);
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

.footer-grid {
  display: grid;
  gap: var(--space-10);
  grid-template-columns: 1fr;
  width: 100%;
  max-width: var(--content-default);
  margin-inline: auto;
  padding-inline: clamp(var(--space-5), 5vw, var(--space-8));
}

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

.footer-grid h4 {
  font-family: var(--font-body);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--color-text-muted);
  font-weight: 600;
  margin-bottom: var(--space-4);
}

.footer-grid ul {
  list-style: none;
  display: grid;
  gap: var(--space-2);
}

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

.footer-fine {
  margin-top: var(--space-12);
  padding-top: var(--space-6);
  border-top: 1px solid var(--color-divider);
  width: 100%;
  max-width: var(--content-default);
  margin-inline: auto;
  padding-inline: clamp(var(--space-5), 5vw, var(--space-8));
  font-size: var(--text-xs);
  color: var(--color-text-faint);
}

/* ===== Sister-site banner — subtle, not loud ===== */

.sister {
  background: var(--color-surface-2);
  font-size: var(--text-sm);
  padding: var(--space-3) 0;
  text-align: center;
  color: var(--color-text-muted);
  border-bottom: 1px solid var(--color-divider);
}

.sister a { color: var(--color-text); border-bottom: 1px solid var(--color-text-faint); }

/* ===== Crisis bar — sober.guide only ===== */

.crisis-strip {
  background: var(--color-surface-2);
  padding: var(--space-4) 0;
  font-size: var(--text-sm);
  border-bottom: 1px solid var(--color-divider);
  text-align: center;
}

.crisis-strip a {
  color: var(--color-text);
  font-weight: 600;
  border-bottom: 1px solid var(--color-text-faint);
}

/* ===== Quote block — closing ===== */

.closing-quote {
  padding-block: clamp(var(--space-16), 10vw, var(--space-24));
  text-align: center;
  background: var(--color-surface);
}

.closing-quote blockquote {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  line-height: 1.45;
  max-width: 32ch;
  margin-inline: auto;
  color: var(--color-text);
  padding-inline: clamp(var(--space-5), 5vw, var(--space-8));
}

.closing-quote cite {
  display: block;
  font-style: normal;
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin-top: var(--space-6);
  letter-spacing: 0.05em;
}
