/* Pastura Pages — base design tokens and shared primitives.
   Inherits from docs/design/design-system.md. The "lp/*" typography
   tier is added here (not in lp.css) because it is consumable by
   future redesigns of pages/legal/ and pages/support/.

   Responsive contract (mobile-first):
   - Mobile sizing is the default; desktop values live behind
     `@media (min-width: 48rem)` (= 768px at default root). iPad portrait
     (exactly 768px) counts as desktop.
   - Breakpoints use `rem` so they honour user-set browser font size
     (WCAG accessibility — same reason as `html { font-size: 100% }`).
   - Typography idioms split by tier:
     • Display tier (.display, .display-sm, .lp-hero h1) uses fluid
       `clamp(min, vw + offset, max)`. Line-wrap shifts noticeably with
       font size at large sizes, so smooth scaling avoids breakpoint
       jumps. min/max ratio ≤ 2.5× per WCAG SC 1.4.4 (200% zoom safe).
     • Body tier (body, .section-title, .lead, .body, .eyebrow, .meta)
       uses plain `rem` + step at 48rem. The ~1 px fluid range yields
       no perceptible benefit; predictable reading rhythm matters more.
       Matches Vercel's pattern and Smashing/CSS-Tricks expert consensus
       that body fluid scaling at small ranges is counter-productive.
   - Container queries (`@container`) were evaluated for `.editor-mock`,
     `.journey-promo`, `.cap-item`. No current component has
     size-responsive internal variants, so viewport `@media` remains
     correct. Revisit if/when a component renders into multiple distinct
     container widths.
   - There are NO `.lp.desktop` or `.lp.mobile` ancestor classes — the
     JSX prototype gated these on a JS-set flag, but a static page must
     rely on media queries. */

:root {
  /* Surfaces */
  --page: #F3EFE7;
  --screen-bg: #FCFAF4;
  --bubble-bg: #FFFFFF;
  --promo-bg: #FBFAF2;
  --promo-border: #E4E7D2;

  /* Ink */
  --ink: #2D2E26;
  --ink-2: #5A5A55;
  --muted: #6B6B65;
  --rule: #E0DBCE;

  /* Moss accent */
  --moss: #8A9A6C;
  --moss-dark: #6B7852;
  --moss-ink: #3D4030;
  --moss-soft: #D4CBA8;
  --moss-light: #A8B68B; /* Lighter moss for accents on dark backgrounds */

  /* Character palette (sheep avatars) — body / face / horn per character.
     Mirrors Pastura/Pastura/Views/DesignTokens.swift PasturaPalette
     avatar* values (the Swift side is the source of truth). */
  --avatar-body-alice: #F2E3C8;
  --avatar-body-bob:   #DDE4CC;
  --avatar-body-carol: #EAD6D1;
  --avatar-body-dave:  #D9D7C9;
  --avatar-face-alice: #C9A979;
  --avatar-face-bob:   #8A9A6C;
  --avatar-face-carol: #B8877C;
  --avatar-face-dave:  #6B6858;
  --avatar-horn-alice: #B29364;
  --avatar-horn-bob:   #6F7F54;
  --avatar-horn-carol: #9C6E64;
  --avatar-horn-dave:  #4F4C3F;
  --avatar-highlight: rgba(255, 255, 255, 0.6);

  --r-card: 14px;
  --shadow-card:
    0 1px 2px rgba(90, 100, 60, 0.04),
    0 12px 26px -12px rgba(90, 100, 60, 0.2);
  --shadow-soft: 0 1px 2px rgba(60, 62, 48, 0.04);
}

/* ----- Base reset (very light) ----- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  /* Explicit base — 100% honours the user-set browser font size for
     accessibility (WCAG SC 1.4.4). All body-tier rem values key off this. */
  font-size: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--screen-bg);
  color: var(--ink);
  font-family: "Noto Sans JP", -apple-system, BlinkMacSystemFont, "Segoe UI",
    system-ui, sans-serif;
  font-size: 0.9375rem; /* 15px mobile */
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "palt";
  text-rendering: geometricPrecision;
}

@media (min-width: 48rem) {
  body {
    font-size: 1rem; /* 16px desktop */
  }
}

.mono {
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, monospace;
}

/* ----- Typography scale (LP-extended; see header for tier strategy) -----
   Display tier (.display, .display-sm) uses fluid clamp — no media query.
   Body tier (.section-title, .lead, .body, .eyebrow, .meta) uses rem at
   mobile defaults, with desktop step at @media (min-width: 48rem) below. */
.display {
  font-weight: 400;
  letter-spacing: -0.012em;
  color: var(--ink);
  text-wrap: balance;
  /* 32px-min at ≤375px viewport, 64px-max at ≥1024px viewport.
     min/max = 2.0× → WCAG SC 1.4.4 safe at 200% zoom. */
  font-size: clamp(2rem, 5vw + 0.5rem, 4rem);
  line-height: 1.08;
}

.display-sm {
  font-weight: 400;
  letter-spacing: -0.008em;
  color: var(--ink);
  text-wrap: balance;
  /* Fluid 18px → 44px. min/max ≈ 2.44× → WCAG SC 1.4.4 safe.
     Slope tuned so 430px viewport (iPhone 14 Pro Max) yields ~19px,
     letting longer JA section headlines fit on one line. */
  font-size: clamp(1.125rem, 3.5vw + 0.25rem, 2.75rem);
  line-height: 1.12;
}

.section-title {
  font-weight: 600;
  letter-spacing: -0.005em;
  color: var(--ink);
  text-wrap: balance;
  font-size: 1.375rem; /* 22px mobile */
  line-height: 1.25;
}

.lead {
  font-weight: 400;
  color: var(--ink-2);
  text-wrap: pretty;
  font-size: 0.9375rem; /* 15px mobile */
  line-height: 1.6;
}

.body {
  font-weight: 400;
  color: var(--ink-2);
  text-wrap: pretty;
  font-size: 0.9375rem; /* 15px mobile */
  line-height: 1.7;
}

.eyebrow {
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 0.6875rem; /* 11px */
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink-2);
  font-weight: 500;
}

.meta {
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 0.71875rem; /* 11.5px */
  letter-spacing: 0.06em;
  color: var(--muted);
}

@media (min-width: 48rem) {
  /* `.display` and `.display-sm` are fluid-typography (clamp())
     so they self-adjust without a media-query step. */
  .section-title {
    font-size: 2rem; /* 32px */
    line-height: 1.22;
  }
  .lead {
    font-size: 1.1875rem; /* 19px */
  }
  .body {
    font-size: 1rem; /* 16px */
  }
}

/* ----- Brand mark (app icon + word) ----- */
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--moss-ink);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-decoration: none;
}
.brand .icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: block;
  flex-shrink: 0;
}
.brand-name {
  font-size: 18px;
}

/* ----- Cross-page chrome (header / footer / language toggle) -----
   Shared by the landing page (pages/index.html) and prose pages
   (pages/support/, pages/legal/privacy-policy/). LP-specific bits
   like .lp-nav-links and the anchor menu live in lp.css instead. */

.lp-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
}
.lp-nav {
  display: flex;
  gap: 36px;
  align-items: center;
  color: var(--ink-2);
  font-size: 14px;
}
.lp-nav a {
  color: inherit;
  text-decoration: none;
}

@media (min-width: 48rem) {
  .lp-header {
    padding: 24px 56px;
  }
}

.lp-footer {
  border-top: 1px solid var(--rule);
  padding: 36px 20px;
  background: var(--page);
}
.foot-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 24px;
}
/* The first column stacks brand + App Store badge vertically. Without this,
   .brand (inline-flex) and .badges (inline-flex) would sit on one line. */
.foot-grid > div:first-child {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 24px;
}
.foot-link {
  display: block;
  color: var(--ink-2);
  text-decoration: none;
  font-size: 14px;
  line-height: 2;
}
.foot-h {
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 10px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 12px;
}
.foot-base {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 48px;
  padding-top: 24px;
  border-top: 1px solid var(--rule);
  font-size: 12px;
  color: var(--muted);
  gap: 16px;
  flex-wrap: wrap;
}
.foot-copy {
  flex: 1;
  min-width: 0;
}
.foot-note {
  margin: 12px 0 0;
  font-size: 11px;
  color: var(--muted);
  line-height: 1.6;
}

@media (min-width: 48rem) {
  .lp-footer {
    padding: 48px 56px 40px;
  }
  .foot-grid {
    grid-template-columns: 1.4fr 1fr 1fr;
    gap: 32px;
  }
}

.lang-toggle {
  display: inline-flex;
  border: 1px solid var(--rule);
  border-radius: 6px;
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 11px;
  overflow: hidden;
}
.lang-toggle a {
  color: var(--ink-2);
  font: inherit;
  letter-spacing: 0.18em;
  padding: 6px 12px;
  text-decoration: none;
  display: inline-block;
}
.lang-toggle a.on,
.lang-toggle a[aria-current="page"] {
  background: var(--ink);
  color: var(--screen-bg);
  cursor: default;
}

/* ----- Sheep avatar (SVG) -----
   Mirrors Pastura/Pastura/Views/Components/SheepAvatar.swift — 28-unit
   viewBox, five wool circles, face oval, two eyes, highlight dot, two
   horns. Decorative; names are conveyed by the adjacent .bubble-name. */
.sheep {
  width: 48px;
  height: 48px;
  display: block;
  flex-shrink: 0;
}
.sheep .wool { fill: currentColor; }
.sheep .eye { fill: var(--ink); }
.sheep .highlight { fill: var(--avatar-highlight); }
.sheep .horn {
  stroke-width: 1;
  stroke-linecap: round;
  fill: none;
}

.sheep[data-tone="alice"] { color: var(--avatar-body-alice); }
.sheep[data-tone="alice"] .face { fill: var(--avatar-face-alice); }
.sheep[data-tone="alice"] .horn { stroke: var(--avatar-horn-alice); }

.sheep[data-tone="bob"] { color: var(--avatar-body-bob); }
.sheep[data-tone="bob"] .face { fill: var(--avatar-face-bob); }
.sheep[data-tone="bob"] .horn { stroke: var(--avatar-horn-bob); }

.sheep[data-tone="carol"] { color: var(--avatar-body-carol); }
.sheep[data-tone="carol"] .face { fill: var(--avatar-face-carol); }
.sheep[data-tone="carol"] .horn { stroke: var(--avatar-horn-carol); }

.sheep[data-tone="dave"] { color: var(--avatar-body-dave); }
.sheep[data-tone="dave"] .face { fill: var(--avatar-face-dave); }
.sheep[data-tone="dave"] .horn { stroke: var(--avatar-horn-dave); }

/* ----- Chat row (avatar + content column) -----
   Mirrors Pastura/Pastura/Views/Components/ChatBubble.swift +
   AgentOutputRow.swift: HStack { AvatarSlot; VStack(name, bubble,
   thoughtSection) }. Tail at TOP-LEFT (4px), other corners 14px. */
.bubble-row {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}
.bubble-stack {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
  min-width: 0;
}
.bubble-name {
  font-size: 11px;
  color: var(--ink-2);
  font-weight: 500;
  letter-spacing: 0.04em;
}
.bubble {
  background: var(--bubble-bg);
  border: 1px solid rgba(90, 90, 70, 0.12);
  border-radius: 4px 14px 14px 14px;
  padding: 8px 12px;
  font-size: 14px;
  line-height: 1.65;
  color: var(--ink);
  box-shadow: var(--shadow-soft);
  max-width: 520px;
}
.bubble blockquote {
  margin: 0;
}

/* THINKING toggle row + thought body — sit OUTSIDE the bubble.
   Toggle: ▾ THINKING (chevron + small mono uppercase tag).
   Thought body: moss-soft 1.5px left rule with 8px gutter. */
.thinking-toggle {
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 10px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  font-weight: 600;
  margin-top: 2px;
}
.thinking-toggle .chev {
  color: var(--moss);
  margin-right: 4px;
}
.thinking-toggle .tag {
  color: var(--muted);
}
.thought-body {
  font-size: 13px;
  line-height: 1.65;
  color: var(--muted);
  border-left: 1.5px solid var(--moss-soft);
  padding-left: 8px;
  margin-top: 4px;
}

/* ----- Promo card (DS §5.4) ----- */
.promo {
  background: var(--promo-bg);
  border: 1px solid var(--promo-border);
  border-left: 3px solid var(--moss);
  border-radius: 14px;
  padding: 18px 20px;
}

/* ----- CTA badges ----- */
.badges {
  display: inline-flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}
.badge {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  border-radius: 10px;
  font-size: 13px;
  line-height: 1;
  border: 1px solid transparent;
  text-decoration: none;
  transition: all 0.25s ease-out;
}
/* When .badge is rendered as a <button> (e.g., disabled "Coming soon" CTA),
   strip browser-default button chrome so it matches the <a> path visually. */
button.badge {
  appearance: none;
  -webkit-appearance: none;
  font: inherit;
  cursor: pointer;
  text-align: left;
}
button.badge:disabled {
  cursor: not-allowed;
}

/* Apple's official "Download on the App Store" badge — used for the
   pre-launch CTA. The badge itself is unmodified per Apple's brand
   guidelines; visual disabled state is conveyed via opacity + a
   "Coming soon" caption below. */
.appstore-cta {
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
  border: 0;
  padding: 0;
  font: inherit;
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  text-decoration: none;
  cursor: not-allowed;
}
.appstore-cta .appstore-img {
  display: block;
  width: 144px;
  height: auto;
  opacity: 0.55;
  transition: opacity 0.2s ease-out;
}
.appstore-cta .appstore-status {
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 9.5px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--muted);
}
.badge .b-eyebrow {
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 9.5px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  display: block;
  margin-bottom: 3px;
}
.badge .b-label {
  font-size: 14px;
  font-weight: 500;
  display: block;
}
.badge.primary {
  background: var(--moss-ink);
  color: var(--page);
  border-color: var(--moss-ink);
}
.badge.primary .b-eyebrow {
  color: var(--moss-light);
}
.badge.secondary {
  background: transparent;
  color: var(--ink);
  border-color: var(--rule);
}
.badge.secondary .b-eyebrow {
  color: var(--muted);
}
.badge.ghost {
  background: transparent;
  color: var(--ink-2);
  border-color: transparent;
  padding: 12px 0;
}
.badge.is-disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

/* ===== Accessibility ===== */

/* Visually hidden but available to screen readers */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* Skip link — invisible until focused */
.skip-link {
  position: absolute;
  top: -100px;
  left: 16px;
  z-index: 100;
  background: var(--moss-ink);
  color: var(--screen-bg);
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 12px;
  letter-spacing: 0.06em;
  padding: 10px 16px;
  border-radius: 8px;
  text-decoration: none;
  transition: top 0.2s ease-out;
}
.skip-link:focus {
  top: 16px;
  outline: 2px solid var(--moss);
  outline-offset: 3px;
}

/* Universal focus ring — moss outline only on keyboard nav */
a:focus-visible,
button:focus-visible,
summary:focus-visible,
.badge:focus-visible {
  outline: 2px solid var(--moss-dark);
  outline-offset: 3px;
  border-radius: 4px;
}
.badge:focus-visible {
  border-radius: 10px;
}

/* Live indicator dot — slow pulse, killed under prefers-reduced-motion */
.live-dot {
  animation: livePulse 2400ms ease-in-out infinite;
}
@keyframes livePulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.45;
  }
}

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