/* ──────────────────────────────────────────────
 * Token + atomic primitive imports.
 * Source-of-truth: site/src/styles/tokens.css.
 * Atomic primitives: site/src/styles/atoms.css.
 * Component styles below use canonical tokens only.
 * ────────────────────────────────────────────── */
@import "./tokens.css";
@import "./motion.css";       /* iter-10 */
@import "./gradients.css";    /* iter-10 */
@import "./atoms.css";

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

html {
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-size-adjust: 100%;
  background: var(--paper);
}

body {
  font-family: var(--font-sans-jp);
  font-size: 16px;
  line-height: 1.82;
  color: var(--ink-primary);
  background: var(--paper);
  font-feature-settings: "palt", "kern";
  letter-spacing: 0;
  text-spacing-trim: trim-start;
  min-width: 320px;
}

/* Numeric figures: tabular for data, proportional for prose */
.tabular {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum", "kern";
}

/* Stat number block — used in metric displays */
.stat-number {
  font-family: var(--font-display);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.03em;
}

/* Pull quote */
.pullquote {
  font-family: var(--font-display-jp);
  font-size: clamp(22px, 2.2vw, 30px);
  font-weight: 700;
  line-height: 1.56;
  color: var(--ink-primary);
  border-left: 2px solid var(--accent-shu);
  padding: 4px 0 4px 20px;
  margin: 32px 0;
  letter-spacing: -0.01em;
}

.pullquote-jp {
  font-family: var(--font-display-jp);
  font-weight: 700;
  letter-spacing: 0;
}

/* JP optical kerning class — for headlines containing punctuation */
[lang="ja"],
.jp {
  font-feature-settings: "palt" 1;
}

/* Body copy max width for readability */
.prose {
  max-width: 70ch;
}
.prose-narrow {
  max-width: 60ch;
}

@media (min-width: 768px) {
  body {
    font-size: 17px;
  }
}

@media (min-width: 1280px) {
  body {
    font-size: 18px;
  }
}

/* iter-10: Dopamine link state — underline-grow on hover.
 * Opt-out for nav / tag-style links: add class="nolink". */
a {
  color: inherit;
  text-decoration: none;
  background-image: linear-gradient(var(--shu), var(--shu));
  background-size: 0% 1px;
  background-position: 0 100%;
  background-repeat: no-repeat;
  transition: color var(--dur-fast) var(--ease-trust),
              background-size var(--dur-base) var(--ease-trust);
}
a:hover {
  color: var(--shu);
  background-size: 100% 1px;
}
a.nolink {
  background-image: none !important;
}

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

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

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

/* Layout */
.shell {
  width: 100%;
  max-width: var(--max-content);
  margin: 0 auto;
  padding: 0 24px;
}

@media (min-width: 768px) {
  .shell {
    padding: 0 48px;
  }
}

@media (min-width: 1280px) {
  .shell {
    padding: 0 80px;
  }
}

/* Typography utility */
.eyebrow {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-secondary);
}

@media (min-width: 768px) {
  .eyebrow {
    font-size: 12px;
  }
}

.display {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1.08;
}

.display-jp {
  font-family: var(--font-display-jp);
  font-weight: 800;
  letter-spacing: -0.01em;
  line-height: 1.26;
}

.h1 {
  font-family: var(--font-display-jp);
  font-size: clamp(34px, 4.2vw, 58px);
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.18;
}

.h1-jp {
  font-family: var(--font-display-jp);
  font-size: clamp(30px, 4vw, 52px);
  font-weight: 800;
  letter-spacing: -0.015em;
  line-height: 1.24;
}

.h2 {
  font-family: var(--font-sans-jp);
  font-size: clamp(24px, 2.6vw, 36px);
  font-weight: 800;
  letter-spacing: -0.01em;
  line-height: 1.38;
}

.h3 {
  font-family: var(--font-sans-jp);
  font-size: clamp(18px, 1.9vw, 24px);
  font-weight: 700;
  line-height: 1.5;
}

.lede {
  font-size: clamp(16px, 1.35vw, 19px);
  line-height: 1.9;
  color: var(--ink-secondary);
  max-width: 60ch;
}

.body {
  font-size: clamp(15px, 1.1vw, 17px);
  line-height: 1.8;
  color: var(--ink-primary);
}

.caption {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-secondary);
  letter-spacing: 0.12em;
  font-variant-numeric: tabular-nums;
}

.shu {
  color: var(--accent-shu);
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 8px 12px;
  border: 1px solid rgba(10, 22, 40, 0.16);
  background: var(--surface);
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-primary);
}

.tag::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-shu);
}

.surface-card {
  background: var(--surface);
  border: 1px solid rgba(10, 22, 40, 0.12);
  box-shadow: 0 20px 46px -34px rgba(10, 22, 40, 0.26);
}

.ledger {
  display: grid;
  gap: 12px;
  padding: 20px;
  background: var(--surface-strong);
  border: 1px solid rgba(10, 22, 40, 0.14);
}

.ledger-row {
  display: grid;
  grid-template-columns: 100px 1fr;
  gap: 16px;
  align-items: baseline;
  padding-top: 10px;
  border-top: 1px solid rgba(10, 22, 40, 0.1);
}

.ledger-row:first-child {
  padding-top: 0;
  border-top: 0;
}

.ledger-key {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  color: var(--accent-shu);
  text-transform: uppercase;
}

.ledger-value {
  color: var(--ink-primary);
  font-size: 14px;
  line-height: 1.62;
}

/* Sections */
section.block {
  padding: clamp(64px, 10vw, 128px) 0;
  position: relative;
}

section.block + section.block {
  border-top: 1px solid var(--ink-faint);
}

/* Grid helpers */
.grid {
  display: grid;
  gap: 24px;
}

@media (min-width: 768px) {
  .grid {
    gap: 32px;
  }
}

.grid-12 {
  grid-template-columns: repeat(12, 1fr);
}

.col-12 {
  grid-column: span 12;
}

@media (min-width: 768px) {
  .md-col-6 {
    grid-column: span 6;
  }
  .md-col-4 {
    grid-column: span 4;
  }
  .md-col-8 {
    grid-column: span 8;
  }
}

@media (min-width: 1024px) {
  .lg-col-4 {
    grid-column: span 4;
  }
  .lg-col-5 {
    grid-column: span 5;
  }
  .lg-col-6 {
    grid-column: span 6;
  }
  .lg-col-7 {
    grid-column: span 7;
  }
  .lg-col-8 {
    grid-column: span 8;
  }
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 14px 24px;
  font-family: var(--font-sans-jp);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.01em;
  border-radius: 3px;
  transition: all 220ms ease;
  position: relative;
  min-height: 50px;
}

.btn-primary {
  background: var(--ink-primary);
  color: var(--paper);
  border: 1px solid var(--ink-primary);
}

.btn-primary:hover {
  background: var(--accent-shu);
  border-color: var(--accent-shu);
  color: var(--paper);
}

.btn-ghost {
  background: transparent;
  color: var(--ink-primary);
  border: 1px solid var(--ink-primary);
}

.btn-ghost:hover {
  background: var(--ink-primary);
  color: var(--paper);
}

.btn-soft {
  background: rgba(250, 246, 237, 0.86);
  color: var(--ink-primary);
  border: 1px solid rgba(10, 22, 40, 0.18);
}

.btn-soft:hover {
  background: var(--paper);
  border-color: var(--ink-primary);
}

.btn-arrow::after {
  content: "→";
  font-family: var(--font-mono);
  font-weight: 400;
  transition: transform 220ms ease;
}

.btn-arrow:hover::after {
  transform: translateX(4px);
}

/* Diagonal accent */
.accent-line {
  display: inline-block;
  width: 40px;
  height: 1px;
  background: var(--accent-shu);
  vertical-align: middle;
  margin: 0 12px;
}

.diagonal {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.diagonal::before {
  content: "";
  position: absolute;
  top: 50%;
  left: -10%;
  width: 120%;
  height: 1px;
  background: var(--accent-shu);
  transform: rotate(-2deg);
  opacity: 0.3;
}

/* iter-10: keyframes + .reveal moved to motion.css.
 * Legacy .reveal-1…5 delays remapped onto the new transition system. */
.reveal-1 { transition-delay: calc(var(--stagger-step) * 0); }
.reveal-2 { transition-delay: calc(var(--stagger-step) * 1); }
.reveal-3 { transition-delay: calc(var(--stagger-step) * 2); }
.reveal-4 { transition-delay: calc(var(--stagger-step) * 3); }
.reveal-5 { transition-delay: calc(var(--stagger-step) * 4); }

/* Rules */
.rule {
  height: 1px;
  background: var(--ink-faint);
  border: 0;
  margin: 32px 0;
}

.rule-double {
  border-top: 1px solid var(--ink-primary);
  border-bottom: 1px solid var(--ink-primary);
  height: 5px;
  background: transparent;
  margin: 32px 0;
}

/* Print */
@media print {
  body {
    background: white;
    color: black;
  }
  .no-print {
    display: none !important;
  }
  .document-body {
    background: white;
  }
}

/* Visibility utilities — !important to win over component scoped styles */
.mobile-only {
  display: block !important;
}

.desktop-only {
  display: none !important;
}

@media (min-width: 1024px) {
  .mobile-only {
    display: none !important;
  }
  .desktop-only {
    display: flex !important;
  }
}

/* hidden attribute must always win over visibility utilities */
[hidden] {
  display: none !important;
}

/* Visually hidden — for SR-only alternate text */
.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

/* iter-10: prefers-reduced-motion handled in motion.css.
 * Capture-safety override kept here for legacy .scroll-reveal. */
@media (prefers-reduced-motion: reduce) {
  .scroll-reveal {
    opacity: 1 !important;
    transform: none !important;
    transition: none !important;
  }
}

/* Hide Astro dev toolbar in dev screenshots / prod (no-op when not present) */
astro-dev-toolbar {
  display: none !important;
}

.document-body {
  background: var(--paper);
}
