/*
 * Dogosy web wedge — design token contract + global base styles.
 *
 * Mirrors DESIGN.md §CSS Variable Contract verbatim. The Notion canon
 * (Brand Position v0.1 + Visual Identity v0.1) is the source-of-truth;
 * DESIGN.md mirrors Notion; this file mirrors DESIGN.md.
 *
 * Light-mode-primary per Visual Identity v0.1 §6 — dark mode is deferred
 * and must not be authored without explicit Hathaway sign-off.
 *
 * Components MUST consume tokens (var(--*)) — never hardcode hex, raw px
 * sizes, or font names. Frontend lint enforces this.
 */

:root[data-theme="light"],
:root:not([data-theme]) {
  /* Surfaces */
  --paper: #f4efe6;
  --fog: #e8e4d8;

  /* Text */
  --ink: #1a1a1a;
  --ink-soft: #4d4a45;
  --ink-muted: #807b72;
  --ink-disabled: #b8b0a2;

  /* Brand */
  --olive: #3d4a36;
  --olive-hover: #2f3a2a;
  --olive-fg: #f4efe6;

  /* Accents */
  --brick: #a8553a;
  --brick-fg: #f4efe6;

  /* Vulnerable-state ONLY (replaces olive on AT-DogOS-1-amplified surfaces) */
  --slate: #4d5a66;
  --slate-fg: #f4efe6;

  /* Structural */
  --border-soft: #ddd6c8;
  --border-strong: #c7bfb0;
  --rule: #d4ccc0;
}

:root {
  /* Spacing — 4px base */
  --space-2xs: 2px;
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-2xl: 48px;
  --space-3xl: 64px;
  --space-4xl: 96px;

  /* Radius (hierarchical, NOT uniform) */
  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-pill: 9999px;

  /* Motion */
  --motion-micro: 80ms;
  --motion-short: 180ms;
  --motion-medium: 280ms;
  --motion-long: 480ms;

  --ease-out: cubic-bezier(0.2, 0.6, 0.2, 1);
  --ease-in: cubic-bezier(0.6, 0.2, 1, 0.8);
  --ease-in-out: cubic-bezier(0.6, 0.2, 0.2, 1);

  /* Typography */
  --font-display: "Source Serif 4", "Source Serif 4 Fallback", Georgia, serif;
  --font-body: "Inter", system-ui, -apple-system, sans-serif;

  --type-body: 17px;
  --type-body-sm: 14px;
  --type-caption: 13px;
  --type-h3: 22px;
  --type-h2: 28px;
  --type-h1: 40px;
  /* Engine sentence display — clamp tightened so 375px floors at 28px (was 40px,
     a wall of serif). 5vw scales smoothly between 28 and 64; ceiling capped at
     64 (was 72) to keep the hero from dwarfing the photograph at 1440+. */
  --type-display: clamp(28px, 5vw, 64px);

  /* Form atoms — pre-staged for PR 4 (signup/login). Values mirror DESIGN.md
     §/signup + /login: 17px text, 48px tall, radius 6px. Components consume
     these tokens; never hardcode. */
  --field-h: 48px;
  --field-radius: var(--radius-sm);
  --field-border: var(--border-strong);
  --field-focus-ring: var(--olive);
  --field-padding-x: var(--space-md);
  --field-label-gap: var(--space-xs);

  /* Layout */
  --reading-col: 45rem;
  --shell-w: 67.5rem;
  --bleed-w: 80rem;
}

/* ─── Source Serif 4 size-adjust override ─────────────────────────────────
   Match Georgia (the system fallback in --font-display) metrics so the swap
   from Georgia → Source Serif 4 doesn't reflow the Engine sentence. Numbers
   tuned by visual diff against Source Serif 4 cap-height + x-height ratios.
   Without this override, FOUC visibly jumps the hero on slow connections. */
@font-face {
  font-family: "Source Serif 4 Fallback";
  src: local("Georgia");
  size-adjust: 102%;
  ascent-override: 95%;
  descent-override: 25%;
  line-gap-override: 0%;
}

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

* {
  margin: 0;
  padding: 0;
}

html,
body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--type-body);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body {
  min-height: 100vh;
}

h1,
h2,
h3 {
  font-family: var(--font-display);
  font-weight: 400;
  color: var(--ink);
  line-height: 1.15;
  letter-spacing: -0.01em;
}

h2 {
  font-weight: 500;
  line-height: 1.2;
}

h3 {
  font-weight: 500;
  line-height: 1.25;
}

p {
  color: var(--ink-soft);
}

a {
  color: var(--olive);
  text-decoration: none;
  transition: color var(--motion-micro) var(--ease-out);
}

a:hover {
  color: var(--olive-hover);
}

a:focus-visible {
  outline: 2px solid var(--olive);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

button {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  background: none;
  border: 0;
  cursor: pointer;
}

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

::selection {
  background: var(--fog);
  color: var(--ink);
}

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

/* ────────────────────────────────────────────────────────────────────
 * Marketing surfaces (/, /try)
 * ────────────────────────────────────────────────────────────────── */

.dgy-shell {
  width: 100%;
  max-width: var(--bleed-w);
  margin: 0 auto;
  padding: 0 var(--space-lg);
}

.dgy-mark {
  display: inline-flex;
  align-items: center;
  font-family: var(--font-display);
  font-size: var(--type-h3);
  font-weight: 500;
  color: var(--ink);
  letter-spacing: -0.01em;
  padding: var(--space-md) 0;
}

.dgy-mark a,
.dgy-mark a:hover {
  color: var(--ink);
}

.dgy-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: var(--space-md);
}

.dgy-topbar-nav {
  display: flex;
  gap: var(--space-lg);
  font-size: var(--type-body-sm);
  color: var(--ink-soft);
}

.dgy-topbar-nav a {
  color: var(--ink-soft);
}

.dgy-topbar-nav a:hover {
  color: var(--ink);
}

/* ── Hero (marketing landing) ─────────────────────────────────────── */

.dgy-hero {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-2xl);
  padding-top: var(--space-3xl);
  padding-bottom: var(--space-4xl);
  align-items: center;
}

@media (min-width: 960px) {
  .dgy-hero {
    grid-template-columns: 7fr 5fr;
    gap: var(--space-4xl);
    padding-top: var(--space-4xl);
    /* Image anchors the right rail (matching headline column height) rather
       than floating mid-column at its own intrinsic dimensions. */
    align-items: stretch;
  }

  .dgy-hero-image {
    align-self: stretch;
  }

  .dgy-hero-image img {
    height: 100%;
  }
}

.dgy-hero-text {
  /* No max-width here — let the grid column size the line-length. The prior
     45rem cap fought the 7fr column at desktop and produced ragged orphans
     ("humans," / "no obstacles." on their own lines). */
}

.dgy-engine {
  font-family: var(--font-display);
  font-size: var(--type-display);
  font-weight: 400;
  line-height: 1.1;
  letter-spacing: -0.015em;
  color: var(--ink);
  font-feature-settings: "lnum" 1;
  /* 2026 baseline — the Engine sentence is the brand's load-bearing typographic
     asset; balanced wrapping prevents orphan words across breakpoints. */
  text-wrap: balance;
}

.dgy-engine .num {
  color: var(--olive);
  font-variant-numeric: tabular-nums lining-nums;
}

/* Honest-uncertainty visual semantic (5.4A). Renders when DOB is owner-estimate
   or unknown — DESIGN.md §Voice "Estimated 9 weeks / around 9 weeks ... NEVER
   fake confidence with the same emphasis as exact DOB." Dotted underline reads
   as approximate without crowding the headline. */
.dgy-engine .num[data-confidence="estimated"] {
  text-decoration: underline dotted;
  text-decoration-color: var(--ink-muted);
  text-decoration-thickness: 1px;
  text-underline-offset: 4px;
}

/* Manual SMALL CAPS via uppercase + letter-spacing (5.1A). Bunny's Source Serif
   4 subset doesn't ship the smcp OpenType feature, so font-feature-settings:
   "smcp" 1 silently no-ops. This is the working substitute. */
.dgy-citation {
  margin-top: var(--space-lg);
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.dgy-subhead {
  margin-top: var(--space-xl);
  font-size: var(--type-body);
  color: var(--ink-soft);
  max-width: 32rem;
  line-height: 1.55;
}

.dgy-cta-row {
  margin-top: var(--space-2xl);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-lg);
}

.dgy-cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: var(--space-sm) var(--space-xl);
  font-family: var(--font-body);
  font-size: var(--type-body);
  font-weight: 500;
  border-radius: var(--radius-md);
  transition: background var(--motion-short) var(--ease-out), color var(--motion-short)
    var(--ease-out), transform var(--motion-micro) var(--ease-out);
}

.dgy-cta:active {
  transform: translateY(1px);
}

/* Universal CTA focus ring (6.3A). Paper inner + olive outer reads on every
   button background (brick, olive, ghost) and against the paper page bg.
   Default link outline is invisible on dark olive. */
.dgy-cta:focus-visible {
  outline: 3px solid var(--paper);
  outline-offset: 0;
  box-shadow: 0 0 0 5px var(--olive);
}

.dgy-cta-brick {
  background: var(--brick);
  color: var(--brick-fg);
}

.dgy-cta-brick:hover {
  background: #95492f;
  color: var(--brick-fg);
}

.dgy-cta-olive {
  background: var(--olive);
  color: var(--olive-fg);
}

.dgy-cta-olive:hover {
  background: var(--olive-hover);
  color: var(--olive-fg);
}

.dgy-cta-ghost {
  background: transparent;
  color: var(--ink-soft);
  border: 1px solid var(--border-strong);
}

.dgy-cta-ghost:hover {
  color: var(--ink);
  border-color: var(--ink-soft);
  background: transparent;
}

/* Slate CTA (5.3A). Vulnerable-state ONLY per DESIGN.md §Slate discipline.
   Used by PR 8 (Vet Delegate viewer), Lost-Dog Mode, Incident Mode, and
   low-DOB-confidence onboarding. Softer transition (motion-medium 280ms vs
   motion-short 180ms) reads calmer than olive — celebration timing reads
   wrong on vulnerable surfaces. */
.dgy-cta-slate {
  background: var(--slate);
  color: var(--slate-fg);
  transition: background var(--motion-medium) var(--ease-out), color var(--motion-medium)
    var(--ease-out), transform var(--motion-micro) var(--ease-out);
}

.dgy-cta-slate:hover {
  background: #3d4954;
  color: var(--slate-fg);
}

/* Suppress brick on AT-DogOS-1-amplified surfaces (5.3A modifier). DESIGN.md
   §Brick discipline: "Vulnerable-state surfaces (slate-active) suppress brick
   entirely. CTAs in those surfaces use slate or ink, not brick." Make the
   suppression mechanical rather than vigilance-dependent — any subtree marked
   data-state="vulnerable" hides brick CTAs automatically. */
[data-state="vulnerable"] .dgy-cta-brick {
  display: none;
}

.dgy-hero-image {
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--fog);
  /* CSS-only fallback if <img> errors out (6.2A + 2.2A). The figure background
     is fog; if the image fails to load (404 during deploy regression, or a
     bundling issue with [assets]), the figure gracefully reverts to a calm
     fog-tinted block instead of a broken-image icon. */
}

.dgy-hero-image img {
  width: 100%;
  height: auto;
  /* Portrait crop on desktop honors the source content's vertical composition
     (people standing, kitchen verticality); 3/4 on mobile reduces vertical
     space hog when the figure stacks below the text column. */
  aspect-ratio: 4 / 5;
  object-fit: cover;
}

@media (max-width: 960px) {
  .dgy-hero-image img {
    aspect-ratio: 3 / 4;
  }
}

/* Anchor scroll offset — keeps section headings clear of the topbar after
   in-page navigation (#how on /try). Scoped to .dgy-frame so the rule does
   not bleed onto any future page that uses an unrelated id="how". Token-
   driven so it scales with spacing adjustments. */
.dgy-frame[id="how"] {
  scroll-margin-top: var(--space-3xl);
}

/* ── Pull-quote (1.1A + 7.1A) ──────────────────────────────────────────
   Sits between hero and editorial frame. Source Serif 4 italic on a left
   olive rule — NYT Magazine kicker register. Carries the brand's memorable
   thing per DESIGN.md §Memorable Thing — the load-bearing distinctive
   asset that names the outcome (the part that distinguishes Dogosy from
   any well-typeset family product). */
.dgy-pullquote {
  padding: var(--space-3xl) 0;
  border-top: 1px solid var(--rule);
}

.dgy-pullquote-text {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 400;
  font-size: clamp(22px, 3vw, 32px);
  line-height: 1.3;
  color: var(--ink);
  max-width: var(--reading-col);
  padding-left: var(--space-xl);
  border-left: 4px solid var(--olive);
  text-wrap: balance;
}

/* ── Skip-to-content link (6.3A) ───────────────────────────────────────
   Visible only on keyboard focus. Per Krug "wayfinding" + 8-to-80 a11y
   commitment in DESIGN.md. Lands keyboard users at #main, bypassing topbar
   on every page. */
.dgy-skip-link {
  position: absolute;
  top: -100px;
  left: var(--space-md);
  z-index: 100;
  background: var(--ink);
  color: var(--paper);
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-sm);
  font-size: var(--type-body-sm);
  font-weight: 500;
  text-decoration: none;
  transition: top var(--motion-short) var(--ease-out);
}

.dgy-skip-link:focus,
.dgy-skip-link:focus-visible {
  top: var(--space-sm);
  color: var(--paper);
}

/* ── Editorial frame (below the fold) ─────────────────────────────── */

.dgy-frame {
  padding: var(--space-4xl) 0;
  border-top: 1px solid var(--rule);
}

.dgy-frame-inner {
  max-width: var(--reading-col);
}

.dgy-frame h2 {
  font-size: var(--type-h2);
  margin-bottom: var(--space-lg);
}

.dgy-frame p + p {
  margin-top: var(--space-lg);
}

/* ── Footer ───────────────────────────────────────────────────────── */

.dgy-foot {
  padding: var(--space-2xl) 0 var(--space-3xl);
  border-top: 1px solid var(--rule);
  font-size: var(--type-caption);
  color: var(--ink-muted);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-lg);
}

.dgy-foot a {
  color: var(--ink-muted);
}

.dgy-foot a:hover {
  color: var(--ink);
}

/* ────────────────────────────────────────────────────────────────────
 * Auth surfaces (/signup, /login) — Better Auth client flows.
 *
 * Symmetric centering per DESIGN.md §Composition (utility surfaces)
 * — asymmetric editorial layout is reserved for marketing. Form atoms
 * consume the pre-staged tokens from :root (--field-h, --field-radius,
 * etc.); never hardcode in components.
 *
 * Spec: DESIGN.md §Per-Surface Style Notes /signup + /login —
 * single-column form, max-width 480px, 17px text, 48px tall inputs,
 * radius 6px, label always above input, olive magic-link CTA, ghost
 * social buttons.
 * ────────────────────────────────────────────────────────────────── */

.dgy-auth-shell {
  max-width: 480px;
  margin: 0 auto;
  padding: var(--space-3xl) var(--space-lg) var(--space-4xl);
}

.dgy-auth-header {
  margin-bottom: var(--space-2xl);
  text-align: center;
}

.dgy-auth-header h1 {
  font-family: var(--font-display);
  font-size: var(--type-h1);
  font-weight: 400;
  line-height: 1.15;
  letter-spacing: -0.01em;
  margin-bottom: var(--space-md);
}

.dgy-auth-header p {
  font-size: var(--type-body);
  color: var(--ink-soft);
  text-wrap: balance;
}

.dgy-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.dgy-field {
  display: flex;
  flex-direction: column;
  gap: var(--field-label-gap);
}

/* Visible label — never placeholder-as-label per DESIGN.md §62 (8-to-80
   accessibility floor). Inter 500 small body, ink-strong. */
.dgy-label {
  font-family: var(--font-body);
  font-size: var(--type-body-sm);
  font-weight: 500;
  color: var(--ink);
}

.dgy-input {
  height: var(--field-h);
  padding: 0 var(--field-padding-x);
  font-family: var(--font-body);
  font-size: var(--type-body);
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--field-border);
  border-radius: var(--field-radius);
  transition: border-color var(--motion-short) var(--ease-out), box-shadow var(--motion-short)
    var(--ease-out);
}

.dgy-input:focus {
  outline: none;
  border-color: var(--field-focus-ring);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--field-focus-ring) 22%, transparent);
}

.dgy-input::placeholder {
  color: var(--ink-muted);
}

.dgy-form-help {
  font-size: var(--type-caption);
  color: var(--ink-muted);
  line-height: 1.5;
}

/* Quiet em-dashed divider above social buttons. Carries lowercase "or" in
   the same SMALL-CAPS register as .dgy-eyebrow / .dgy-citation. */
.dgy-form-divider {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  margin: var(--space-lg) 0 var(--space-md);
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.dgy-form-divider::before,
.dgy-form-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--rule);
}

/* Auth-shell CTAs are full-width — magic-link form button + each social
   button stretch the form column. Scoped to the shell so marketing
   surfaces keep their inline-flex CTA sizing. */
.dgy-auth-shell .dgy-cta {
  width: 100%;
  margin-top: var(--space-sm);
}

.dgy-auth-shell .dgy-form-divider + form .dgy-cta {
  margin-top: 0;
}

.dgy-auth-foot {
  margin-top: var(--space-2xl);
  text-align: center;
  font-size: var(--type-body-sm);
  color: var(--ink-soft);
}

/* ── /try variant — reduced weight ────────────────────────────────── */

.dgy-try-hero {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-2xl);
  padding-top: var(--space-3xl);
  padding-bottom: var(--space-3xl);
  align-items: center;
}

@media (min-width: 960px) {
  .dgy-try-hero {
    grid-template-columns: 6fr 4fr;
    gap: var(--space-3xl);
  }
}

.dgy-try-hero .dgy-engine {
  font-size: clamp(32px, 4.5vw, 56px);
}

.dgy-try-hero .dgy-hero-image {
  max-width: 22rem;
}

.dgy-try-hero .dgy-hero-image img {
  aspect-ratio: 4 / 5;
}

/* Same manual SMALL CAPS treatment as .dgy-citation (5.1A) — Bunny doesn't
   ship smcp glyphs in Source Serif 4. */
.dgy-eyebrow {
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: var(--space-md);
}

.dgy-try-prose {
  margin-top: var(--space-2xl);
  max-width: var(--reading-col);
}

.dgy-try-prose p + p {
  margin-top: var(--space-md);
}
