/* ============================================================
   MERIDIAN — Scroll-Driven 3D Site Template
   テーマ差し替えは :root のトークンを書き換えるだけで完結する。
   ============================================================ */

/* ---- Design Tokens (Theme A: Light) ---- */
:root {
  --bg: #F7F5F1;
  --surface: #FFFFFF;
  --ink: #1A1D21;
  --ink-muted: #5C6066;
  --line: #D8D4CC;
  --accent: #0F4C81;
  --accent-soft: rgba(15, 76, 129, 0.08);
  --photo-tint-top: rgba(15, 76, 129, 0.25);
  --photo-tint-bottom: rgba(15, 76, 129, 0.05);
  --photo-blend: multiply;

  /* Typography */
  --font-sans: "Zen Kaku Gothic New", "Hiragino Kaku Gothic ProN", "Noto Sans JP", sans-serif;
  --font-display: "Space Grotesk", "Zen Kaku Gothic New", sans-serif;
  --fs-display: clamp(2.75rem, 1.5rem + 6vw, 7rem);
  --fs-h2: clamp(1.75rem, 1.2rem + 2.2vw, 3rem);
  --fs-h3: clamp(1.25rem, 1.05rem + 0.8vw, 1.625rem);
  --fs-body: clamp(0.9375rem, 0.875rem + 0.25vw, 1.0625rem);
  --fs-label: 0.75rem;

  /* Spacing scale (8px base): 8/16/24/40/64/104/168 */
  --sp-1: 8px;  --sp-2: 16px; --sp-3: 24px; --sp-4: 40px;
  --sp-5: 64px; --sp-6: 104px; --sp-7: 168px;
  --pad-x: clamp(20px, 5vw, 64px);
  --pad-section: clamp(96px, 14vh, 168px);
  --content-max: 1200px;

  /* モーション: power4.out 相当を基準イージングにする（linear は使わない） */
  --ease: cubic-bezier(.16, 1, .3, 1);
}

/* ---- Theme B: Dark（data-theme="dark" で一括切替） ---- */
[data-theme="dark"] {
  --bg: #101216;
  --surface: #191C22;
  --ink: #ECEAE4;
  --ink-muted: #9BA0A8;
  --line: #2A2E36;
  --accent: #7FB0E0;
  --accent-soft: rgba(127, 176, 224, 0.10);
  --photo-tint-top: rgba(127, 176, 224, 0.22);
  --photo-tint-bottom: rgba(127, 176, 224, 0.04);
  --photo-blend: screen;
}

/* ---- Reset & Base ---- */
* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: auto; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: var(--fs-body);
  line-height: 1.9;
  letter-spacing: 0.02em;
  overflow-x: hidden;
  transition: background-color 0.5s ease, color 0.5s ease;
}
::selection { background: var(--ink); color: var(--bg); }
img { display: block; max-width: 100%; height: auto; }
a { color: inherit; }
h1, h2, h3 { font-feature-settings: "palt"; }
h2 { font-size: var(--fs-h2); line-height: 1.3; letter-spacing: 0.04em; font-weight: 700; }
h3 { font-size: var(--fs-h3); line-height: 1.35; letter-spacing: 0.03em; font-weight: 500; }
.body-copy { max-width: 36em; color: var(--ink); }

.visually-hidden {
  position: absolute; width: 1px; height: 1px;
  clip-path: inset(50%); overflow: hidden; white-space: nowrap;
}
.skip-link {
  position: fixed; top: -48px; left: var(--sp-2);
  z-index: 100; padding: 10px 18px;
  background: var(--ink); color: var(--bg);
  font-size: 0.8125rem; text-decoration: none;
  transition: top 0.2s ease;
}
.skip-link:focus { top: var(--sp-2); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

/* ---- WebGL canvas: 固定背景 ---- */
#gl {
  position: fixed; inset: 0;
  width: 100%; height: 100%;
  z-index: 0; display: block;
  opacity: var(--gl-opacity, 1);
}
main { position: relative; z-index: 1; }

/* ---- Section label（全セクション共通の背骨） ---- */
.sec-label {
  display: flex; align-items: baseline; gap: 10px;
  font-family: var(--font-display);
  font-size: var(--fs-label);
  letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--ink-muted);
  margin-bottom: var(--sp-4);
}
.sec-label .no { color: var(--accent); }
.sec-label::after {
  content: ""; flex: 0 0 40px; height: 1px;
  background: var(--line); align-self: center;
}

/* ---- Header ----
   mix-blend-mode: difference は 3D の中間調の上でコントラストが落ちるため撤去し、
   紙色の半透明地＋ブラーに置き換えた（ライト/ダークともトークンで追従する）。 */
.site-header {
  position: fixed; top: 0; left: 0; right: 0; z-index: 10;
  display: flex; justify-content: space-between; align-items: center;
  padding: 20px var(--pad-x);
  color: var(--ink);
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid color-mix(in srgb, var(--line) 60%, transparent);
}
.logo {
  font-family: var(--font-display);
  font-size: 1.125rem; font-weight: 500;
  letter-spacing: 0.32em; text-decoration: none;
}
.site-header nav { display: flex; gap: var(--sp-3); }
.site-header nav a {
  font-family: var(--font-display);
  font-size: var(--fs-label); letter-spacing: 0.14em;
  text-transform: uppercase; text-decoration: none;
  opacity: 0.72;
  transition: opacity 0.3s var(--ease);
}
.site-header nav a:hover, .site-header nav a:focus-visible { opacity: 1; }
#theme-toggle {
  width: 34px; height: 20px; border: 1px solid currentColor;
  border-radius: 10px; background: none; cursor: pointer;
  position: relative; color: inherit;
}
#theme-toggle .dot {
  position: absolute; top: 3px; left: 3px;
  width: 12px; height: 12px; border-radius: 50%;
  background: currentColor;
  transition: transform 0.3s var(--ease);
}
[data-theme="dark"] #theme-toggle .dot { transform: translateX(14px); }

/* ============================================================
   S1 HERO — 150vh / sticky スクラブ
   ============================================================ */
.hero { height: 150vh; position: relative; }
.hero-sticky {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; justify-content: flex-end;
  padding: 0 var(--pad-x) 8vh;
}
/* ── 見出しスクリム（品質仕様 A: テキスト可読性）──────────────
   3D 柱列は「背景」、見出しが常に主役。紙色から透明への 2 層グラデーションを
   見出しブロック（左下）の背後に敷き、柱が文字に食い込むのを防ぐ。
   1 層目 = 左→右（テキストカラム方向）、2 層目 = 下→上（メタ行の可読性）。 */
.hero-sticky::before {
  content: ""; position: absolute; inset: 0; z-index: 0;
  background:
    linear-gradient(102deg,
      color-mix(in srgb, var(--bg) 96%, transparent) 0%,
      color-mix(in srgb, var(--bg) 90%, transparent) 26%,
      color-mix(in srgb, var(--bg) 52%, transparent) 46%,
      transparent 66%),
    linear-gradient(180deg,
      transparent 24%,
      color-mix(in srgb, var(--bg) 66%, transparent) 68%,
      color-mix(in srgb, var(--bg) 90%, transparent) 100%);
  pointer-events: none;
}
.hero-sticky > * { position: relative; z-index: 1; }
.hero .sec-label { margin-bottom: var(--sp-2); }
.display {
  font-family: var(--font-display);
  font-size: var(--fs-display);
  font-weight: 500; line-height: 1.15;
  letter-spacing: -0.02em; text-transform: uppercase;
}
.display .line { display: block; overflow: hidden; }
/* 初期非表示は JS 有効時（html.js）のみ。JS/CDN 死亡時も h1 は必ず見える */
.display .line span { display: inline-block; }
.js .display .line span { transform: translateY(112%); }
.hero-meta {
  display: flex; justify-content: space-between; align-items: flex-end;
  margin-top: var(--sp-3); padding-top: var(--sp-3);
  border-top: 1px solid var(--line);
}
/* 日本語の提案文は第2階層。本文サイズのままだと欧文 h1 との階層が逆転する */
.hero-meta p:first-child {
  font-size: var(--fs-h3); line-height: 1.7; letter-spacing: 0.04em;
}
.js .hero-meta { opacity: 0; }
.scroll-cue {
  display: flex; align-items: center; gap: 10px;
  font-family: var(--font-display);
  font-size: var(--fs-label); letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--ink-muted);
}
.cue-bar {
  width: 1px; height: 36px; background: var(--ink-muted);
  transform-origin: top; animation: cue 1.8s ease-in-out infinite;
}
@keyframes cue {
  0% { transform: scaleY(0); transform-origin: top; }
  45% { transform: scaleY(1); transform-origin: top; }
  55% { transform: scaleY(1); transform-origin: bottom; }
  100% { transform: scaleY(0); transform-origin: bottom; }
}

/* ============================================================
   S2 STATEMENT — 120vh / テキスト充填スクラブ
   ============================================================ */
.statement { height: 120vh; position: relative; }
.statement-sticky {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; justify-content: center;
  padding: 0 var(--pad-x);
  max-width: calc(var(--content-max) + var(--pad-x) * 2);
  margin: 0 auto;
}
.statement-copy {
  font-size: var(--fs-h2); line-height: 1.7;
  letter-spacing: 0.04em; font-weight: 700;
  max-width: 24em;
}
/* 充填量は --seg-fill (0→1) だけを GSAP で動かし、色解決は常に現テーマのトークンで行う
   （inline color を書くとテーマ切替時に旧テーマの色が残るため） */
.statement-copy .seg {
  --seg-fill: 0;
  color: color-mix(in srgb, var(--ink) calc(var(--seg-fill) * 100%), var(--ink-muted));
  opacity: calc(0.45 + 0.55 * var(--seg-fill));
}

/* ============================================================
   S3 ABOUT — マスク展開
   ============================================================ */
.about { padding: var(--pad-section) var(--pad-x); }
.about-inner {
  max-width: var(--content-max); margin: 0 auto;
  display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr);
  gap: var(--sp-5); align-items: center;
}
.about-text h2 { margin-bottom: var(--sp-3); }
.about-text .body-copy { color: var(--ink); margin-bottom: var(--sp-4); }
.text-link {
  font-family: var(--font-display);
  font-size: var(--fs-label); letter-spacing: 0.14em;
  text-transform: uppercase; text-decoration: none;
  color: var(--accent);
  border-bottom: 1px solid var(--accent);
  padding-bottom: 4px;
  transition: opacity 0.3s var(--ease);
}
.text-link:hover { opacity: 0.7; }

/* 写真の共通処理: モノトーン + accent 単色オーバーレイ */
.photo-wrap { position: relative; overflow: hidden; border-radius: 2px; }
.photo-wrap img {
  width: 100%; height: 100%; object-fit: cover;
  /* --photo-desat を 0 にすればカラー写真のまま使える（案件流用用トークン） */
  filter: grayscale(var(--photo-desat, 1)) contrast(1.08) brightness(1.02);
}
.photo-wrap::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(180deg, var(--photo-tint-top), var(--photo-tint-bottom));
  mix-blend-mode: var(--photo-blend);
  pointer-events: none;
}
.about-photo { aspect-ratio: 4 / 3; }
.js .about-photo { clip-path: inset(12% 8% 12% 8%); }
.js .about-photo img { transform: scale(1.12); }

/* ============================================================
   S4 SERVICES — 300vh / sticky 横スクロール風
   ============================================================ */
.services { height: 300vh; position: relative; }
.services-sticky {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; justify-content: center;
  overflow: hidden; padding: 0 0 0 var(--pad-x);
}
.services-track {
  display: flex; gap: var(--sp-3);
  width: max-content; will-change: transform;
}
.svc-card {
  width: min(420px, 78vw);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 2px;
  padding: var(--sp-4) var(--sp-3) var(--sp-3);
  min-height: 340px;
  display: flex; flex-direction: column;
  transition: background-color 0.5s ease;
}
.svc-card .svc-no {
  font-family: var(--font-display);
  font-size: var(--fs-label); letter-spacing: 0.14em;
  color: var(--accent); margin-bottom: var(--sp-5);
}
.svc-card h3 { margin-bottom: var(--sp-2); }
.svc-card p:last-child { color: var(--ink-muted); margin-top: auto; }

/* ============================================================
   S5 SHOWCASE — 通常フロー + パララックス（解放パート）
   ============================================================ */
.works { padding: var(--pad-section) var(--pad-x); }
.works > .sec-label { max-width: var(--content-max); margin-left: auto; margin-right: auto; margin-bottom: var(--sp-5); }
.works-list {
  list-style: none;
  max-width: var(--content-max); margin: 0 auto;
  display: flex; flex-direction: column; gap: var(--sp-6);
}
.work { display: grid; grid-template-columns: minmax(0, 8fr) minmax(0, 3fr); gap: var(--sp-4); align-items: end; }
.work:nth-child(even) { grid-template-columns: minmax(0, 3fr) minmax(0, 8fr); }
.work:nth-child(even) .work-photo { order: 2; }
.work-photo { aspect-ratio: 16 / 10; }
.work-photo img { height: 120%; will-change: transform; }
.work-caption h3 { margin-bottom: var(--sp-1); }
.work-caption p { color: var(--ink-muted); font-size: 0.875rem; }

/* ============================================================
   S6 NUMBERS — カウントアップ
   ============================================================ */
.numbers { padding: var(--pad-section) var(--pad-x); }
.numbers > .sec-label, .numbers-grid { max-width: var(--content-max); margin-left: auto; margin-right: auto; }
.numbers-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1px; background: var(--line); border: 1px solid var(--line);
}
.num {
  background: var(--bg); padding: var(--sp-4) var(--sp-3);
  transition: background-color 0.5s ease;
}
.num dt {
  font-size: var(--fs-label); letter-spacing: 0.14em;
  color: var(--ink-muted); margin-bottom: var(--sp-3);
}
.num dd {
  font-family: var(--font-display);
  font-variant-numeric: tabular-nums;
  font-size: clamp(2.5rem, 2rem + 2.5vw, 4.5rem);
  font-weight: 500; line-height: 1;
}
.num .unit { font-size: 0.4em; color: var(--accent); margin-left: 6px; }

/* ============================================================
   S7 PROCESS — SVG 線の描画
   ============================================================ */
.process { padding: var(--pad-section) var(--pad-x); }
.process > .sec-label, .process-inner { max-width: var(--content-max); margin-left: auto; margin-right: auto; }
.process-inner { position: relative; padding-left: var(--sp-4); }
.process-line {
  position: absolute; left: 0; top: 0;
  width: 2px; height: 100%;
}
.process-line line {
  stroke: var(--accent); stroke-width: 3;
  vector-effect: non-scaling-stroke; /* viewBox の非等比スケールでも線幅を保つ */
  stroke-dasharray: 1;
}
.js .process-line line { stroke-dashoffset: 1; }
.steps { list-style: none; display: flex; flex-direction: column; gap: var(--sp-5); }
.step { max-width: 40em; }
.step-no {
  font-family: var(--font-display);
  font-size: var(--fs-label); letter-spacing: 0.14em;
  color: var(--accent); margin-bottom: var(--sp-1);
}
.step h3 { margin-bottom: var(--sp-1); }
.step p:last-child { color: var(--ink-muted); }

/* ============================================================
   S8 CTA — 収束
   ============================================================ */
.cta {
  position: relative; min-height: 110vh;
  display: flex; align-items: center;
  padding: var(--pad-section) var(--pad-x);
  overflow: hidden;
}
.cta-bg { position: absolute; inset: 0; opacity: 0.12; }
.cta-bg img {
  width: 100%; height: 100%; object-fit: cover;
  filter: grayscale(var(--photo-desat, 1)) contrast(1.08);
}
.cta-inner { position: relative; max-width: var(--content-max); margin: 0 auto; width: 100%; }
.cta h2 { margin-bottom: var(--sp-3); }
.cta .body-copy { margin-bottom: var(--sp-4); }
.btn {
  display: inline-flex; align-items: center; gap: 14px;
  font-family: var(--font-display);
  font-size: 0.875rem; letter-spacing: 0.14em; text-transform: uppercase;
  text-decoration: none;
  color: var(--bg); background: var(--ink);
  padding: 18px 32px; border-radius: 2px;
  transition: background-color 0.3s var(--ease), transform 0.3s var(--ease);
}
.btn:hover, .btn:focus-visible { background: var(--accent); transform: translateY(-2px); }
.btn-arrow { transition: transform 0.3s var(--ease); }
.btn:hover .btn-arrow { transform: translateX(4px); }

/* ---- Footer ---- */
.site-footer {
  position: relative; z-index: 1;
  display: flex; justify-content: space-between;
  padding: var(--sp-3) var(--pad-x);
  border-top: 1px solid var(--line);
  font-size: var(--fs-label); letter-spacing: 0.14em;
  color: var(--ink-muted);
  background: var(--bg);
  transition: background-color 0.5s ease;
}
.site-footer a { color: inherit; text-decoration: none; }
.site-footer a:hover { color: var(--ink); }

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 860px) {
  /* モバイルは主導線（Contact）のみ残す。フルメニューが必要な案件では
     ここをハンバーガー実装に差し替える */
  .site-header nav a { display: none; }
  .site-header nav a[href="#contact"] { display: inline; }
  .about-inner { grid-template-columns: 1fr; gap: var(--sp-4); }
  .work, .work:nth-child(even) { grid-template-columns: 1fr; }
  .work:nth-child(even) .work-photo { order: 0; }
  .hero-meta { flex-direction: column; align-items: flex-start; gap: var(--sp-2); }
}

/* WebGL 初期化失敗時のフック（main.js が html に付与） */
.no-webgl #gl { display: none; }

/* ============================================================
   Reduced Motion — 演出を止めても全内容が読めること
   （html.js は reduced-motion 時には付与されないため、
     初期非表示系はここで打ち消す必要がない）
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  .cue-bar { animation: none; }
  #gl { opacity: 0.35; }
}

/* ──────────────────────────────────────────────────────────────
   和文タイポグラフィ調整
   1. palt        … 句読点・括弧まわりの余分なアキを詰める
   2. auto-phrase … 文節単位で折り返す（「書」「く。」のような分断を防ぐ）
   3. balance     … 見出しの行長を揃え、1文字だけ落ちる行を作らない
   4. strict      … 禁則処理を厳密にし、行頭に 。 、 」 が来ないようにする
   auto-phrase / balance / pretty は非対応ブラウザでは無視されるだけで、
   崩れることはない（プログレッシブ・エンハンスメント）。
   ────────────────────────────────────────────────────────────── */
body {
  font-feature-settings: "palt" 1;
  font-kerning: normal;
  line-break: strict;
  word-break: normal;
}
h1, h2, h3, h4, h5, .kicker, dt {
  word-break: auto-phrase;
  text-wrap: balance;
}
p, li, dd, td, .note, .desc, .caption,
.lede, .lead, .statement, blockquote, figcaption {
  word-break: auto-phrase;
  text-wrap: pretty;
}
/* 手動改行は広い画面でのみ効かせ、狭い画面では自動折り返しに任せる */
@media (max-width: 640px) {
  h1 br, h2 br, h3 br,
  .lede br, .lead br, .statement br { display: none; }
}


/* ── 書体設計（見出し＝個性 / 本文＝可読性） ──────────────────────
   見出し: Zen Old Mincho
   本文  : BIZ UDPMincho（Google Fonts の和文で palt が効く数少ない書体。
           読点のあとのアキが締まり、Mac / Windows で見え方が揃う）
   欧文は先頭に置いた書体から取り、和文だけが差し替わる。 */
h1, h2, h3, h4, .lede, .lead, .kicker, .statement, blockquote {
  font-family: "Space Grotesk", "Zen Old Mincho", serif;
}
p, li, dd, td, .note, .desc, .caption, figcaption, small {
  font-family: "BIZ UDPMincho", "Hiragino Mincho ProN", "Yu Mincho", serif;
}


/* ── 本文書体の取りこぼし防止（2026-08-05 に対象を縮小）──
   旧版は html body :is(p, li, dd, td, .note, …) で詳細度 (0,3,4) を持たせていたため、
   .sec-label / .svc-no / .step-no / .num dd といったサイト固有のタイポ指定を
   問答無用で潰し、Space Grotesk のアイブロウ体系とカウントアップ数字が
   本文明朝に化けていた。
   → class を持たない「素の本文」だけに絞る。class 付き要素は上の
     `p, li, dd, td, …` ルール（詳細度 0,0,1）で明朝が当たり、
     サイト固有の指定があればそちらが正しく勝つ。 */
/* dd / td はここから外す。数値表示（.num dd / .metric dd）は dd 自身に class が付かないため、
   :not([class]) を抜けてこの規則に捕まり、巨大数字が本文書体に化けていた。 */
html body :is(p, li, figcaption):not([class]):not(code):not(pre) {
  font-family: "BIZ UDPMincho", "Hiragino Mincho ProN", "Yu Mincho", serif;
}
