/* ============================================================
   株式会社ミドリノート — tokens.css
   The shared CSS foundation: design tokens, reset, base type,
   grain, utilities, components. Pages link ONLY this file.
   Concept: 再生紙のノートに万年筆の一筆 — 丸ゴシック × 双葉グリーン。
   ============================================================ */

:root {
  /* ---- Palette : Recycled Paper / Ink Pine / Sprout / Hemp / Moss ---- */
  --paper: #F5F2E9;
  --ink: #1B241C;
  --sprout: #2F9E63;
  --hemp: #E7DFC9;
  --moss: #7F887A;

  --color-bg: var(--paper);
  --color-fg: var(--ink);
  --color-accent: var(--sprout);
  --color-surface: var(--hemp);
  --color-muted: var(--moss);

  /* tints derived only from the palette */
  --hairline: color-mix(in srgb, var(--ink) 12%, transparent);
  --hairline-soft: color-mix(in srgb, var(--ink) 8%, transparent);
  --hairline-strong: color-mix(in srgb, var(--ink) 18%, transparent);
  --accent-soft: color-mix(in srgb, var(--sprout) 14%, transparent);
  --grid-line: color-mix(in srgb, var(--sprout) 8%, transparent);
  --surface-deep: color-mix(in srgb, var(--hemp) 82%, var(--ink) 6%);

  /* ---- Type families ---- */
  --font-display: "Zen Maru Gothic", "Hiragino Maru Gothic ProN", "YuGothic", system-ui, sans-serif;
  --font-body: "Zen Kaku Gothic New", "Hiragino Kaku Gothic ProN", "Yu Gothic", system-ui, sans-serif;
  --font-mono: "Space Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;

  /* ---- Fluid type scale (every clamp has a deliberate max) ---- */
  --step--1: clamp(0.82rem, 0.78rem + 0.2vw, 0.95rem);
  --step-0:  clamp(1rem, 0.94rem + 0.3vw, 1.15rem);
  --step-1:  clamp(1.25rem, 1.05rem + 0.9vw, 1.8rem);
  --step-2:  clamp(1.7rem, 1.3rem + 1.8vw, 2.9rem);
  --step-3:  clamp(2.4rem, 1.4rem + 4.4vw, 5.5rem);
  --step-display: clamp(3rem, 9vw, 9rem);

  /* ---- Spacing scale (fluid, capped) ---- */
  --space-1: clamp(0.5rem, 0.4rem + 0.3vw, 0.75rem);
  --space-2: clamp(0.85rem, 0.7rem + 0.5vw, 1.2rem);
  --space-3: clamp(1.25rem, 1rem + 1vw, 2rem);
  --space-4: clamp(2rem, 1.5rem + 2vw, 3.5rem);
  --space-5: clamp(3rem, 2rem + 4vw, 6rem);
  --space-6: clamp(4.5rem, 3rem + 6vw, 9rem);
  --space-7: clamp(6rem, 4rem + 9vw, 13rem);
  --space-8: clamp(9rem, 6rem + 12vw, 18rem);

  --gutter: clamp(1rem, 0.6rem + 1.8vw, 2.4rem);
  --page-inline: clamp(1.25rem, 5vw, 6rem);
  --shell-max: 1760px;

  /* ---- Motion tokens ---- */
  --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-out-quart: cubic-bezier(0.25, 1, 0.5, 1);
  --ease-in-out-quart: cubic-bezier(0.76, 0, 0.24, 1);
  --ease-back: cubic-bezier(0.34, 1.56, 0.64, 1);
  --dur-1: 0.4s;
  --dur-2: 0.8s;
  --dur-3: 1.2s;

  --radius: 3px;
  color-scheme: light;
}

/* ============================================================
   Modern reset
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
body { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; text-rendering: optimizeLegibility; }
img, picture, video, canvas, svg { display: block; max-width: 100%; }
input, button, textarea, select { font: inherit; color: inherit; }
button { background: none; border: none; cursor: pointer; }
a { color: inherit; text-decoration: none; }
ul, ol { list-style: none; padding: 0; }
p { overflow-wrap: break-word; }
:where(h1, h2, h3, h4, h5, h6) { font-weight: inherit; font-size: inherit; }

/* ============================================================
   Base elements
   ============================================================ */
html { color: var(--color-fg); background: var(--color-bg); }

body {
  font-family: var(--font-body);
  font-weight: 400;
  font-size: var(--step-0);
  line-height: 1.95;
  color: var(--color-fg);
  background-color: var(--color-bg);
  /* 方眼 grid paper : faint sprout ruling, fixed like a notebook page */
  background-image:
    linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: 2.2rem 2.2rem;
  background-position: center top;
  background-attachment: fixed;
  min-height: 100svh;
  overflow-x: clip;
  position: relative;
}

body.is-loading { overflow: hidden; height: 100svh; }
body.nav-open { overflow: hidden; }

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

/* Headings mapped onto the scale, display leading, palt kerning */
h1, h2, h3, .display {
  font-family: var(--font-display);
  font-weight: 900;
  line-height: 1.0;
  letter-spacing: 0.004em;
  font-feature-settings: "palt" 1;
  word-break: keep-all;
}
h1 { font-size: var(--step-3); line-height: 1.02; }
h2 { font-size: var(--step-2); line-height: 1.06; }
h3 { font-size: var(--step-1); font-weight: 700; line-height: 1.2; }
h4 { font-family: var(--font-display); font-weight: 700; font-size: var(--step-0); line-height: 1.4; }

p { max-width: 62ch; }
strong, b { font-weight: 700; }
em { font-style: normal; color: var(--color-accent); font-weight: 500; }

/* editorial link underline drawn in from the left */
a:not([class]) {
  background-image: linear-gradient(var(--color-accent), var(--color-accent));
  background-repeat: no-repeat;
  background-position: 0 100%;
  background-size: 0% 1px;
  transition: background-size var(--dur-1) var(--ease-out-quart);
  padding-bottom: 0.06em;
}
a:not([class]):hover, a:not([class]):focus-visible { background-size: 100% 1px; }

:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 3px;
  border-radius: var(--radius);
}
:focus:not(:focus-visible) { outline: none; }

.mono, time, .index-num, [data-year], .num { font-family: var(--font-mono); font-feature-settings: normal; }

/* thin themed scrollbar */
* { scrollbar-width: thin; scrollbar-color: var(--color-muted) transparent; }
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: color-mix(in srgb, var(--color-muted) 70%, transparent);
  border-radius: 20px;
  border: 2px solid transparent;
  background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover { background: var(--color-muted); }

/* ============================================================
   Grain overlay (no extra markup)
   ============================================================ */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 9998;
  pointer-events: none;
  mix-blend-mode: multiply;
  opacity: 0.05;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.6'/%3E%3C/svg%3E");
  background-size: 240px 240px;
  background-repeat: repeat;
}

/* ============================================================
   Layout utilities
   ============================================================ */
.container {
  width: 100%;
  max-width: var(--shell-max);
  margin-inline: auto;
  padding-inline: var(--page-inline);
}
.bleed { width: 100%; }
.inset { padding-inline: var(--page-inline); }

.grid12 {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  column-gap: var(--gutter);
  row-gap: var(--gutter);
}
@media (max-width: 720px) {
  .grid12 { grid-template-columns: repeat(2, 1fr); }
}

.section { padding-block: var(--space-6); position: relative; }
.silence { height: clamp(14vh, 22vh, 40vh); }

/* hairline rules */
.hairline { border: 0; border-top: 1px solid var(--hairline); width: 100%; height: 0; }
.hairline--strong { border-top-color: var(--hairline-strong); }
.hairline--accent { border-top-color: var(--accent-soft); }

/* hemp surface panel */
.panel {
  background: var(--color-surface);
  position: relative;
  overflow: hidden;
  border-radius: var(--radius);
}
.panel--deep { background: var(--surface-deep); }

/* oversized index number */
.index-num {
  font-family: var(--font-mono);
  font-weight: 700;
  line-height: 0.8;
  font-size: clamp(3rem, 9vw, 8rem);
  color: var(--color-fg);
  letter-spacing: -0.02em;
}
.index-num--accent { color: var(--color-accent); }
.index-num--sm { font-size: clamp(1.4rem, 3vw, 2.4rem); }

/* small-caps mono labels */
.label {
  font-family: var(--font-mono);
  font-size: var(--step--1);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--color-muted);
  display: inline-block;
}
.label--accent { color: var(--color-accent); }

/* vertical accent (JP considered typesetting) */
.vertical {
  writing-mode: vertical-rl;
  text-orientation: mixed;
  font-family: var(--font-mono);
  letter-spacing: 0.14em;
  font-size: var(--step--1);
  text-transform: uppercase;
  color: var(--color-muted);
  line-height: 1;
}

/* giant background latin texture word */
.ghost-word {
  font-family: var(--font-display);
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: -0.02em;
  line-height: 0.85;
  color: var(--color-fg);
  opacity: 0.04;
  pointer-events: none;
  user-select: none;
  white-space: nowrap;
}

.stroke-text {
  -webkit-text-stroke: 1px var(--color-fg);
  color: transparent;
}

/* buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.6em;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--step-0);
  color: var(--paper);
  background: var(--color-fg);
  padding: 0.85em 1.7em;
  border-radius: 100px;
  will-change: transform;
  transition: background var(--dur-1) var(--ease-out-quart), color var(--dur-1) var(--ease-out-quart);
}
.btn:hover { background: var(--color-accent); }
.btn--ghost { background: transparent; color: var(--color-fg); border: 1px solid var(--hairline-strong); }
.btn--ghost:hover { background: var(--color-fg); color: var(--paper); }

/* signature ink-line svg helpers */
.ink-svg { display: block; overflow: visible; pointer-events: none; }
.ink-path {
  fill: none;
  stroke: var(--color-accent);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.ink-path--thin { stroke-width: 1.5; }

/* ============================================================
   Marquee (CSS only)
   ============================================================ */
.marquee { width: 100%; overflow: hidden; }
.marquee-track {
  display: inline-flex;
  flex-wrap: nowrap;
  white-space: nowrap;
  will-change: transform;
  animation: marquee-scroll 32s linear infinite;
}
.marquee:hover .marquee-track { animation-play-state: paused; }
.marquee-track > * { flex: 0 0 auto; padding-inline: var(--space-3); }
@keyframes marquee-scroll {
  from { transform: translateX(0); }
  to { transform: translateX(-50%); }
}

/* ============================================================
   Split-text fragments (produced by motion.js splitText)
   ============================================================ */
.split-word { display: inline-block; overflow: hidden; vertical-align: top; }
.split-char, .split-unit { display: inline-block; will-change: transform; }

/* reveal init states — only while JS is active (no FOUC without JS) */
html.has-js [data-reveal] { opacity: 0; }
html.has-js [data-reveal-chars] { opacity: 0; }
html.has-js [data-reveal-clip] { clip-path: inset(0 0 100% 0); }

/* ============================================================
   Custom cursor
   ============================================================ */
.cursor, .cursor-ring {
  position: fixed;
  top: 0; left: 0;
  pointer-events: none;
  z-index: 9999;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  will-change: transform;
}
.cursor { width: 7px; height: 7px; background: var(--color-accent); }
.cursor-ring {
  width: 34px; height: 34px;
  border: 1px solid color-mix(in srgb, var(--ink) 45%, transparent);
  transition: width 0.3s var(--ease-out-quart), height 0.3s var(--ease-out-quart), border-color 0.3s;
}
.cursor-ring.is-hover { width: 58px; height: 58px; border-color: var(--color-accent); }
@media (pointer: coarse), (hover: none) {
  .cursor, .cursor-ring { display: none !important; }
}

/* ============================================================
   Preloader
   ============================================================ */
#preloader {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: var(--color-fg);
  color: var(--paper);
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  padding: var(--page-inline);
  will-change: transform;
}
#preloader .preloader-count {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: clamp(3rem, 12vw, 9rem);
  line-height: 0.9;
  letter-spacing: -0.02em;
}
#preloader .preloader-count::after {
  content: "%";
  font-size: 0.4em;
  vertical-align: super;
  opacity: 0.55;
  margin-left: 0.05em;
}
#preloader .preloader-word {
  position: absolute;
  top: var(--page-inline);
  left: var(--page-inline);
  font-family: var(--font-display);
  font-weight: 900;
  font-size: var(--step-1);
  color: var(--color-accent);
  letter-spacing: 0.02em;
}

/* ============================================================
   Site header / nav (shared shell — mix-blend keeps it legible)
   ============================================================ */
.site-header {
  position: fixed;
  top: 0; left: 0;
  width: 100%;
  z-index: 9990;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) var(--page-inline);
  mix-blend-mode: difference;
  color: var(--paper);
  transition: padding var(--dur-2) var(--ease-out-quart);
}
.site-header.scrolled { padding-block: var(--space-2); }
.site-header a { color: inherit; }
.site-brand { font-family: var(--font-display); font-weight: 900; font-size: var(--step-0); letter-spacing: 0.02em; }
.site-nav { display: flex; gap: clamp(1rem, 2vw, 2.4rem); align-items: center; }
.site-nav a {
  font-family: var(--font-mono);
  font-size: var(--step--1);
  letter-spacing: 0.06em;
  position: relative;
  padding-block: 0.3em;
}
.site-nav a::after {
  content: "";
  position: absolute;
  left: 0; bottom: 0;
  width: 100%; height: 1px;
  background: currentColor;
  transform: scaleX(0);
  transform-origin: left;
  transition: transform var(--dur-1) var(--ease-out-quart);
}
.site-nav a:hover::after,
.site-nav a[aria-current="page"]::after { transform: scaleX(1); }
.site-nav a[aria-current="page"] { color: var(--color-accent); }

.nav-toggle {
  display: none;
  width: 44px; height: 44px;
  align-items: center;
  justify-content: center;
  color: inherit;
}

@media (max-width: 720px) {
  .nav-toggle { display: inline-flex; }
  .site-nav {
    position: fixed;
    inset: 0;
    flex-direction: column;
    justify-content: center;
    gap: var(--space-3);
    background: var(--color-fg);
    color: var(--paper);
    mix-blend-mode: normal;
    transform: translateY(-100%);
    transition: transform var(--dur-3) var(--ease-in-out-quart);
    z-index: 9995;
  }
  .site-nav.is-open { transform: translateY(0); }
  .site-nav a { font-family: var(--font-display); font-size: var(--step-2); }
}

/* ============================================================
   Visually hidden
   ============================================================ */
.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* ============================================================
   Responsive adjustments
   ============================================================ */
@media (max-width: 720px) {
  .vertical { writing-mode: horizontal-tb; text-orientation: mixed; }
  body { background-size: 1.6rem 1.6rem; }
  p { max-width: none; }
}
@media (min-width: 2100px) {
  /* wide screens: let the composed shell breathe with intentional margins */
  .container { --page-inline: clamp(4rem, 8vw, 10rem); }
}

/* ============================================================
   Reduced motion — neutralize CSS animation, reveal everything
   ============================================================ */
@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;
  }
  .marquee-track { animation: none !important; transform: none !important; }
  html.has-js [data-reveal],
  html.has-js [data-reveal-chars] { opacity: 1 !important; transform: none !important; }
  html.has-js [data-reveal-clip] { clip-path: inset(0 0 0% 0) !important; }
  .cursor, .cursor-ring { display: none !important; }
}
