/* ==========================================================================
   OCR Translator — editorial / translation journal
   Mirrors dashboard/src/index.css tokens + dashboard primitives
   (Navbar, Kicker, SectionHeading, Surface, StatFigure, Divider, buttonClass,
   ThemeToggle). Light = warm cream paper · Dark = warm espresso.
   One accent (oxblood/sienna). Rules, not shadows. Tiny radii.
   Motion only on load/transition.
   ========================================================================== */

:root {
  --paper: #faf7f0;
  --paper-raised: #ffffff;
  --paper-sunken: #f3eee2;

  --ink: #1a1714;
  --ink-muted: #6b6358;
  --ink-faint: #9a9082;

  --rule: #e0d8c8;
  --rule-strong: #c8be9f;

  --accent: #9a3412;
  --accent-ink: #7c2d12;
  --accent-surface: #fbf0e6;

  --font-serif: "Fraunces", Georgia, "Times New Roman", serif;
  --font-sans: "Hanken Grotesk", ui-sans-serif, system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", monospace;

  --maxw: 80rem; /* max-w-7xl */
  --readw: 42rem; /* max-w-2xl */
  --radius: 3px;
}

.dark {
  --paper: #1c1916;
  --paper-raised: #26221d;
  --paper-sunken: #15120f;

  --ink: #f5efe2;
  --ink-muted: #a89f90;
  --ink-faint: #736b5e;

  --rule: #3a342c;
  --rule-strong: #564e42;

  --accent: #e8825a;
  --accent-ink: #f0a17e;
  --accent-surface: #3a241a;
}

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

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-sans);
  background-color: var(--paper);
  color: var(--ink);
  line-height: 1.6;
  font-feature-settings: "ss01", "cv01";
  overflow-x: hidden;
}

::selection {
  background-color: var(--accent);
  color: var(--paper-raised);
}

/* Subtle paper grain (dashboard/index.css). */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.035;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

main,
.masthead,
.colophon {
  position: relative;
  z-index: 1;
}

.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;
}

.tabular {
  font-variant-numeric: tabular-nums;
}

/* ---- Kicker (ui/Kicker.tsx): mono uppercase tracked ---- */
.kicker {
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.2em;
  font-size: 0.6875rem;
  font-weight: 500;
  color: var(--accent);
}

/* ============== Masthead (Navbar.tsx) ============== */
.masthead {
  position: sticky;
  top: 0;
  z-index: 50;
  border-bottom: 1px solid var(--rule);
  background-color: color-mix(in srgb, var(--paper) 85%, transparent);
  backdrop-filter: saturate(140%) blur(8px);
}

.masthead-inner {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}

/* Wordmark lockup: icon + serif semibold "OCR Translator" */
.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  flex-shrink: 0;
}
.wordmark-icon {
  display: grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  overflow: hidden;
}
.wordmark-icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.wordmark-name {
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: 1.25rem;
  letter-spacing: -0.015em;
  color: var(--ink);
}

/* Numbered/mono nav (Dashboard.tsx link style) */
.masthead-nav {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  margin-left: auto;
}
.nav-link {
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.72rem;
  color: var(--ink-muted);
  text-decoration: none;
  padding: 0.35rem 0;
  border-bottom: 1px solid transparent;
  transition:
    color 0.15s ease,
    border-color 0.15s ease;
}
.nav-link:hover {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.masthead-tools {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  border-left: 1px solid var(--rule);
  padding-left: 1rem;
}

/* Language selector — ruled, square (Field/Select feel) */
.language-selector {
  display: inline-flex;
  align-items: center;
}
.lang-select {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--ink);
  background-color: transparent;
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius);
  padding: 0.45rem 0.65rem;
  padding-right: 1.7rem;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--ink-muted) 50%),
    linear-gradient(135deg, var(--ink-muted) 50%, transparent 50%);
  background-position:
    calc(100% - 14px) calc(50% - 1px),
    calc(100% - 9px) calc(50% - 1px);
  background-size:
    5px 5px,
    5px 5px;
  background-repeat: no-repeat;
  transition: border-color 0.15s ease;
}
.lang-select:hover,
.lang-select:focus {
  border-color: var(--accent);
  outline: none;
}

/* Theme toggle (ThemeToggle.tsx): h-9 w-9, border-rule, hover sunken */
.theme-toggle {
  display: inline-grid;
  place-items: center;
  width: 2.25rem;
  height: 2.25rem;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background-color: transparent;
  color: var(--ink-muted);
  cursor: pointer;
  transition:
    border-color 0.15s ease,
    background-color 0.15s ease,
    color 0.15s ease;
}
.theme-toggle:hover {
  border-color: var(--rule-strong);
  background-color: var(--paper-sunken);
  color: var(--ink);
}
.theme-toggle svg {
  width: 16px;
  height: 16px;
}
/* Light → Moon, Dark → Sun (matches ThemeToggle.tsx) */
.dark .moon-icon,
html:not(.dark) .sun-icon {
  display: none;
}

/* Mobile menu trigger (Navbar.tsx) */
.menu-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0 0.55rem;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: transparent;
  cursor: pointer;
}
.menu-bar {
  display: block;
  height: 1.5px;
  background-color: var(--ink-muted);
  transition:
    transform 0.2s ease,
    opacity 0.2s ease;
}
.menu-toggle.is-open .menu-bar:nth-child(1) {
  transform: translateY(5.5px) rotate(45deg);
}
.menu-toggle.is-open .menu-bar:nth-child(2) {
  opacity: 0;
}
.menu-toggle.is-open .menu-bar:nth-child(3) {
  transform: translateY(-5.5px) rotate(-45deg);
}

/* Mobile overlay nav (Navbar.tsx overlay) */
.mobile-nav {
  display: none;
  flex-direction: column;
  border-top: 1px solid var(--rule);
  background-color: var(--paper);
}
.mobile-nav.is-open {
  display: flex;
}
.mobile-link {
  font-family: var(--font-serif);
  font-size: 1.5rem;
  letter-spacing: -0.015em;
  color: var(--ink-muted);
  text-decoration: none;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--rule);
  transition: color 0.15s ease;
}
.mobile-link:hover {
  color: var(--accent);
}

/* ============== Spreads ============== */
.spread {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: clamp(3.5rem, 8vw, 6rem) 1rem;
  border-bottom: 1px solid var(--rule);
}

/* ============== Hero (Login.tsx pattern) ============== */
.hero {
  text-align: center;
}
.hero-inner {
  max-width: var(--readw);
  margin: 0 auto;
}

.display {
  font-family: var(--font-serif);
  font-weight: 600;
  font-optical-sizing: auto;
  font-size: clamp(2.75rem, 7vw, 3.75rem);
  line-height: 1.02;
  letter-spacing: -0.025em;
  margin-top: 1rem;
  color: var(--ink);
}
/* spacers for the kicker above (kicker is inline-flow w/ margin) */
.hero-inner .kicker {
  display: inline-block;
}

.lede {
  max-width: 28rem;
  margin: 1.25rem auto 0;
  font-size: clamp(1rem, 1.4vw, 1.0625rem);
  line-height: 1.6;
  color: var(--ink-muted);
}

.cta-row {
  margin-top: 2rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.625rem;
  justify-content: center;
}

/* Button (buttonClass.tsx) */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  border-radius: var(--radius);
  font-family: var(--font-sans);
  font-weight: 500;
  font-size: 0.875rem;
  padding: 0.5rem 1rem;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition:
    background-color 0.15s ease,
    border-color 0.15s ease,
    color 0.15s ease;
}
.btn--mono {
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 0.6875rem;
  font-weight: 500;
  padding: 0.6rem 1rem;
}
.btn--accent {
  background-color: var(--accent);
  color: #ffffff;
  border-color: var(--accent);
}
.btn--accent:hover {
  background-color: var(--accent-ink);
  border-color: var(--accent-ink);
}
.btn--outline {
  background-color: transparent;
  color: var(--ink);
  border-color: var(--rule-strong);
}
.btn--outline:hover {
  background-color: var(--paper-sunken);
}

/* StatFigure row: serif tabular numbers + mono labels, column rules */
.stats {
  margin: 3rem auto 0;
  display: flex;
  border-top: 1px solid var(--rule);
  max-width: 32rem;
}
.stat {
  flex: 1;
  padding: 1.25rem 0.5rem 0;
  border-right: 1px solid var(--rule);
}
.stat:first-child {
  padding-left: 0;
}
.stat:last-child {
  border-right: 0;
  padding-right: 0;
}
.stat dt {
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.6875rem;
  font-weight: 500;
  color: var(--ink-muted);
  margin-bottom: 0.5rem;
}
.stat dd {
  font-family: var(--font-serif);
  font-weight: 500;
  font-size: 1.75rem;
  letter-spacing: -0.02em;
  color: var(--ink);
}
.stat-of {
  font-size: 1rem;
  color: var(--ink-faint);
}

/* Hero visual — Surface (inset) */
.hero-visual {
  max-width: 52rem;
  margin: 4rem auto 0;
}

/* Divider (Divider.tsx) */
.divider-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
}
.rule-line {
  height: 1px;
  flex: 1;
  background-color: var(--rule-strong);
}
.divider-label {
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.6875rem;
  color: var(--ink-faint);
}

/* Surface (Surface.tsx): flat, ruled, rounded-[3px] */
.surface {
  border-radius: var(--radius);
  border: 1px solid var(--rule);
}
.surface--inset {
  background-color: var(--paper-sunken);
}
.surface--demo {
  background-color: var(--paper-sunken);
  padding: 0.25rem;
}
.demo-gif,
.demo-iframe {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 2px;
}
.demo-iframe {
  height: clamp(520px, 78vh, 1024px);
  border: 0;
}

/* ============== SectionHeading (SectionHeading.tsx) ============== */
.section-head {
  margin-bottom: clamp(2.5rem, 5vw, 3.5rem);
}
.section-head-top {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
}
.section-ord {
  font-family: var(--font-mono);
  font-size: 0.875rem;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
}
.section-title {
  font-family: var(--font-serif);
  font-weight: 600;
  font-optical-sizing: auto;
  font-size: clamp(1.75rem, 3.6vw, 2.75rem);
  line-height: 1.05;
  letter-spacing: -0.02em;
  margin-top: 0.375rem;
  color: var(--ink);
  max-width: 40rem;
}
.section-title em {
  font-style: italic;
  color: var(--accent);
}
.section-sub {
  max-width: 40rem;
  margin-top: 0.5rem;
  font-size: 0.9rem;
  line-height: 1.6;
  color: var(--ink-muted);
}
.section-rule {
  margin-top: 1.25rem;
  height: 1px;
  width: 100%;
  background-color: var(--rule-strong);
}

/* ============== Features ============== */
.feature-grid {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border-top: 1px solid var(--rule);
}
.feature {
  padding: clamp(1.75rem, 3vw, 2.5rem) clamp(1.25rem, 2vw, 2rem);
  border-right: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
}
.feature:nth-child(3n) {
  border-right: 0;
}
.feature-ord {
  display: block;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 0.875rem;
  color: var(--accent);
  margin-bottom: 1.25rem;
}
.feature-title {
  font-family: var(--font-serif);
  font-weight: 600;
  font-optical-sizing: auto;
  font-size: 1.35rem;
  line-height: 1.15;
  letter-spacing: -0.015em;
  margin-bottom: 0.625rem;
  color: var(--ink);
}
.feature-desc {
  color: var(--ink-muted);
  font-size: 0.95rem;
  line-height: 1.55;
}

/* ============== Colophon ============== */
.colophon {
  border-top: 1px solid var(--rule);
  background-color: var(--paper-sunken);
}
.colophon-inner {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 2rem 1rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1.5rem;
}
.colophon .wordmark-name {
  font-size: 1.05rem;
}
.colophon-text {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  color: var(--ink-muted);
}
.colophon-imprint {
  width: 100%;
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.65rem;
  color: var(--ink-faint);
}

/* ============== Motion: one-shot load reveal (MotionReveal.tsx) ============== */
.reveal {
  opacity: 0;
  transform: translateY(10px);
  animation: reveal-up 0.7s cubic-bezier(0.2, 0.65, 0.3, 1) forwards;
  animation-delay: var(--reveal-delay, 0ms);
}
@keyframes reveal-up {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ============== Responsive ============== */
@media (max-width: 860px) {
  .masthead-nav {
    display: none;
  }
  .menu-toggle {
    display: flex;
  }
  .feature-grid {
    grid-template-columns: 1fr;
  }
  .feature {
    border-right: 0 !important;
  }
}

@media (max-width: 560px) {
  .masthead-tools {
    padding-left: 0.625rem;
  }
  .lang-select {
    font-size: 0.68rem;
    padding-right: 1.5rem;
  }
  .colophon-inner {
    flex-direction: column;
    align-items: flex-start;
  }
  .colophon-text {
    margin-left: 0;
  }
}

/* ============== Reduced motion (MotionConfig reducedMotion="user") ============== */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  .reveal {
    animation: none;
    opacity: 1;
    transform: none;
  }
  *,
  *::before,
  *::after {
    transition-duration: 0.001ms !important;
  }
}
