/* R5 foundation: fonts, tokens, reset, type ramp, buttons, nav, reveal.
   Section styles live in sections.css. */

/* ---------- Fonts ---------- */

@font-face {
  font-family: 'Geist';
  src: url('/fonts/Geist-Variable.woff2') format('woff2');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Geist Mono';
  src: url('/fonts/GeistMono-Variable.woff2') format('woff2');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

/* Neo Forma is unlicensed as of R5 build: stack falls through to Georgia. */

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

:root {
  --paper: #F5F3EC;
  --card: #EBE7DD;
  --card-alt: #EBE7DE;
  --ink: #121517;
  --ink-2: #171A1B;
  --dark-deep: #0F1214;
  --warm-shadow: rgba(180, 172, 147, 0.12);
  --shadow-warm-pair: 0 8px 24px 0 var(--warm-shadow), 0 4px 12px 0 var(--warm-shadow);
  --inset-glass: inset 0 1px 4px 0 rgba(245, 243, 236, 0.6), inset 0 0 1px 0 rgba(245, 243, 236, 0.5);
  --font-serif: 'Neo Forma', Georgia, 'Times New Roman', serif;
  --font-sans: 'Geist', -apple-system, 'Helvetica Neue', Arial, sans-serif;
  --font-mono: 'Geist Mono', 'SFMono-Regular', Menlo, monospace;
  --r-btn: 8px;
  --r-sm: 4px;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --nav-h: 88px;
}

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

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

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  scroll-behavior: smooth;
}

body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-sans);
  overflow-x: clip;
}

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

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

button {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
  cursor: pointer;
}

.container {
  max-width: 1440px;
  margin-inline: auto;
  padding-inline: 80px;
}

/* ---------- Type ramp ---------- */

.display-1 {
  font-family: var(--font-serif);
  font-weight: 400;
  font-size: 56px;
  line-height: 1.2;
  letter-spacing: -0.04em;
  color: var(--ink);
}

.body-lg {
  font-family: var(--font-sans);
  font-weight: 400;
  font-size: 20px;
  line-height: 1.8;
  letter-spacing: -0.02em;
  color: rgba(18, 21, 23, 0.8);
}

.mono-label {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 16px;
  line-height: 1;
  letter-spacing: 0.8px;
  text-transform: uppercase;
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  height: 56px;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 16px;
  line-height: 1;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  white-space: nowrap;
  transition: transform 0.25s var(--ease-out), box-shadow 0.25s var(--ease-out), background-color 0.25s var(--ease-out), opacity 0.25s var(--ease-out);
}

.btn-primary {
  --btn-label: #EBE7DD;
  padding: 4px 16px 4px 20px;
  border-radius: var(--r-btn);
  background: var(--ink-2);
  border: 1px solid rgba(23, 26, 27, 0.4);
  box-shadow: var(--shadow-warm-pair), var(--inset-glass);
  color: var(--btn-label);
}

/* Nav instance is roomier than the hero instance; both are in the design. */
.btn-primary--roomy {
  padding: 4px 32px 4px 40px;
}

.btn-arrow {
  width: 20px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.btn-arrow svg {
  transition: transform 0.25s var(--ease-out);
}

/* Hover states are builder proposals: nothing is authored in Figma. */
.btn-primary:hover .btn-arrow svg {
  transform: translateX(3px);
}

.btn-primary:hover {
  box-shadow: 0 10px 28px 0 rgba(180, 172, 147, 0.18), 0 4px 12px 0 var(--warm-shadow), var(--inset-glass);
}

.btn-secondary {
  /* Figma label font is Phonic Trial Monospaced Medium; standardized on Geist Mono Medium per brief. */
  font-weight: 500;
  padding: 8px 20px;
  border-radius: var(--r-sm);
  background: var(--card);
  border: 1px solid rgba(214, 208, 193, 0.2);
  color: var(--ink);
}

.btn-secondary:hover {
  background: #E4DFD2;
}

.btn-ghost {
  padding: 20px;
  border-radius: 36px;
  color: rgba(23, 26, 27, 0.8);
  letter-spacing: 0.96px;
}

.btn-ghost:hover {
  background: rgba(23, 26, 27, 0.06);
}

/* ---------- Nav ---------- */

.nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  height: var(--nav-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 80px;
  transition: background-color 0.35s ease, box-shadow 0.35s ease;
}

/* Scrolled treatment is a builder proposal (nav must stay legible over dark sections). */
.nav.is-scrolled {
  background: rgba(245, 243, 236, 0.88);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  box-shadow: 0 1px 0 rgba(23, 26, 27, 0.06);
}

.nav-links {
  display: flex;
  align-items: center;
  padding: 4px 16px;
  border-radius: 8px;
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.12)) drop-shadow(0 1px 1px rgba(0, 0, 0, 0.12));
}

.nav-link {
  display: inline-flex;
  align-items: center;
  height: 48px;
  padding: 4px 16px;
  border-radius: var(--r-sm);
  font-family: var(--font-sans);
  font-weight: 500;
  font-size: 16px;
  line-height: 1;
  letter-spacing: 0.01em;
  text-transform: capitalize;
  color: rgba(23, 26, 27, 0.8);
  transition: background-color 0.25s var(--ease-out);
}

.nav-link:hover {
  background: rgba(23, 26, 27, 0.05);
}

.nav-wordmark {
  position: absolute;
  left: 50%;
  top: 28px;
  transform: translateX(-50%);
}

.nav-wordmark svg {
  width: 65px;
  height: 32px;
  fill: var(--ink-2);
}

.nav-cta {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* ---------- Scroll reveal ----------
   Hidden-by-default only when the inline head script has tagged <html> with
   .js — no-JS visitors and main.js load failures keep all content visible.
   :where() keeps specificity at 0-1-0 so the reduced-motion override wins. */

:where(.js) [data-reveal] {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.7s var(--ease-out), transform 0.7s var(--ease-out);
}

[data-reveal].is-in {
  opacity: 1;
  transform: none;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  [data-reveal] {
    opacity: 1;
    transform: none;
    transition: none;
  }
}

/* ---------- Responsive foundation ---------- */

@media (max-width: 1200px) {
  .container {
    padding-inline: 40px;
  }
  .nav {
    padding-inline: 40px;
  }
}

@media (max-width: 1320px) {
  /* Responsive proposal: links collapse into the menu, wordmark moves in-flow
     left so it can never collide with the CTA cluster. With five links the
     absolutely-centered wordmark clears the link row only above ~1310px. */
  .nav-links {
    display: none;
  }
  .nav .nav-menu-btn {
    display: inline-flex;
  }
  .nav-wordmark {
    position: static;
    transform: none;
  }
}

@media (max-width: 640px) {
  .container {
    padding-inline: 24px;
  }
  .nav {
    padding-inline: 24px;
  }
  .btn-ghost {
    display: none;
  }
}

/* Below ~480px the roomy CTA + menu button + wordmark exceed the viewport. */
@media (max-width: 480px) {
  .nav .btn-primary--roomy {
    padding: 4px 16px 4px 20px;
  }
  .nav .btn-primary--roomy .btn-arrow {
    display: none;
  }
}

/* Mobile menu button (hidden on desktop) */
.nav-menu-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: var(--r-sm);
}

.nav-menu-btn:hover {
  background: rgba(23, 26, 27, 0.05);
}

.nav-wordmark {
  color: var(--ink-2);
}

.nav-mobile {
  position: absolute;
  top: var(--nav-h);
  left: 0;
  right: 0;
  display: flex;
  flex-direction: column;
  padding: 8px 24px 16px;
  background: rgba(245, 243, 236, 0.97);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  box-shadow: 0 12px 24px rgba(23, 26, 27, 0.08);
}

.nav-mobile .nav-link {
  height: 52px;
}

.nav-mobile[hidden] {
  display: none;
}

/* Never leave an open mobile menu behind after resizing past the breakpoint. */
@media (min-width: 1321px) {
  .nav-mobile {
    display: none;
  }
}

/* Fixed nav is 88px tall; give its in-page anchor targets clearance. */
#zero-tax,
#organizations,
#comparison,
#footer-cta {
  scroll-margin-top: calc(var(--nav-h) + 16px);
}

/* ---------- Dark stack (organizations through comparison) ----------
   Mirrors Figma frame 19039:7683: one #171A1B ground carrying the 160px
   vertical rhythm between the dark sections. */

.dark-stack {
  background: var(--ink-2);
  display: flex;
  flex-direction: column;
  gap: 160px;
  padding-block: 160px;
}

@media (max-width: 900px) {
  /* Responsive proposal: tighter rhythm on small screens. */
  .dark-stack {
    gap: 96px;
    padding-block: 96px;
  }
}

/* ---------- Focus ---------- */

:focus-visible {
  outline: 2px solid rgba(23, 26, 27, 0.6);
  outline-offset: 2px;
}

.dark-stack :focus-visible,
#platform :focus-visible,
.demo-dialog :focus-visible {
  outline-color: rgba(245, 243, 236, 0.5);
}

/* ---------- Demo request dialog (builder proposal, no comp exists) ---------- */

.demo-dialog {
  margin: auto; /* the universal reset zeroes margins, which kills UA dialog centering */
  border: 1px solid rgba(23, 26, 27, 0.08);
  border-radius: 12px;
  background: var(--paper);
  padding: 48px;
  width: min(480px, calc(100vw - 48px));
  box-shadow: 0 24px 64px rgba(18, 21, 23, 0.25), var(--shadow-warm-pair);
}

.demo-dialog::backdrop {
  background: rgba(18, 21, 23, 0.55);
}

/* Mirror the UA's top-layer styles for the non-modal fallback (pre-15.4
   Safari), where dialog[open] would otherwise sit in flow after the footer
   with body scroll locked. No-op in browsers with showModal(). */
.demo-dialog[open] {
  position: fixed;
  inset: 0;
  height: fit-content;
  max-height: calc(100vh - 48px);
  overflow: auto;
  z-index: 200;
}

.demo-close {
  position: absolute;
  top: 20px;
  right: 20px;
  width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--r-sm);
  color: rgba(18, 21, 23, 0.6);
}

.demo-close:hover {
  background: rgba(23, 26, 27, 0.06);
  color: var(--ink);
}

.demo-title {
  font-family: var(--font-serif);
  font-weight: 400;
  font-size: 32px;
  line-height: 1.2;
  letter-spacing: -0.04em;
  color: var(--ink);
  margin-bottom: 8px;
}

.demo-sub {
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
  color: rgba(18, 21, 23, 0.8);
  margin-bottom: 24px;
}

.demo-field {
  display: block;
  margin-bottom: 16px;
}

.demo-field span {
  display: block;
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: 12px;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: rgba(18, 21, 23, 0.6);
  margin-bottom: 6px;
}

.demo-field input {
  width: 100%;
  font-family: var(--font-sans);
  font-size: 16px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid rgba(23, 26, 27, 0.15);
  border-radius: var(--r-sm);
  padding: 12px 14px;
  transition: border-color 0.25s var(--ease-out);
}

.demo-field input:focus {
  border-color: rgba(23, 26, 27, 0.45);
}

.demo-submit {
  width: 100%;
  margin-top: 8px;
}

.demo-status {
  min-height: 1.2em;
  margin-top: 12px;
  font-size: 14px;
  color: #A03A2E;
}
