/* Google Fonts */
@import url("https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,100..1000;1,9..40,100..1000&family=Noto+Sans+JP:wght@100..900&family=Zen+Kaku+Gothic+New:wght@400;500;700&display=swap");

/* ============================================
   Design Tokens
   ============================================ */

:root {
  /* 基本単位 */
  --base-unit: 8px;
  --half-unit: 4px;

  /* 余白 ----------------------------------------------------------------- */
  --spacing-1: calc(var(--base-unit) * 1); /* 8px */
  --spacing-2: calc(var(--base-unit) * 2); /* 16px */
  --spacing-3: calc(var(--base-unit) * 3); /* 24px */
  --spacing-4: calc(var(--base-unit) * 4); /* 32px */
  --spacing-5: calc(var(--base-unit) * 5); /* 40px */
  --spacing-6: calc(var(--base-unit) * 6); /* 48px */
  --spacing-8: calc(var(--base-unit) * 8); /* 64px */
  --spacing-10: calc(var(--base-unit) * 10); /* 80px */
  --spacing-12: calc(var(--base-unit) * 12); /* 96px */
  --spacing-16: calc(var(--base-unit) * 16); /* 128px */
  --spacing-20: calc(var(--base-unit) * 20); /* 160px */

  /* 特殊ケース */
  --spacing-min: 1px;
  --spacing-min-2: 2px;
  --spacing-half: var(--half-unit);
  --spacing-1_5: calc(var(--half-unit) * 3);
  --spacing-2_5: calc(var(--half-unit) * 5);

  /* 文字 ----------------------------------------------------------------- */
  --font-heading: "Zen Kaku Gothic New", sans-serif;
  --font-accent: "DM Sans", sans-serif;
  --font-body: "Noto Sans JP", sans-serif;
  --font-mono: "JetBrains Mono", monospace;

  --font-weight-light: 300;
  --font-weight-regular: 400;
  --font-weight-medium: 500;
  --font-weight-bold: 700;

  font-size: 62.5%; /* 1rem = 10px 基準 */

  /* Font Size (実際のUIで頻出するサイズに厳選) */
  --font-size-10: 1rem; /* メタ情報、バッジ、タグ */
  --font-size-12: 1.2rem; /* サブテキスト、注釈 */
  --font-size-14: 1.4rem; /* 本文 (デフォルト) */
  --font-size-16: 1.6rem; /* 小見出し、重要テキスト */
  --font-size-18: 1.8rem; /* 中間サイズ */
  --font-size-20: 2rem; /* 中見出し、カードタイトル */
  --font-size-22: 2.2rem; /* h3用 */
  --font-size-24: 2.4rem; /* 大見出し、ページタイトル */
  --font-size-28: 2.8rem; /* h2用 */
  --font-size-32: 3.2rem; /* ヒーロータイトル */
  --font-size-48: 4.8rem; /* 特大タイトル、装飾文字 */

  --line-height-100: 1;
  --line-height-120: 1.2;
  --line-height-150: 1.5;
  --line-height-160: 1.6;
  --line-height-180: 1.8;
  --line-height-200: 2;

  --font-size-default: var(--font-size-14);
  --line-height-default: var(--line-height-150);

  /* ボーダー ----------------------------------------------------------------- */
  --radius-2: 2px;
  --radius-4: 4px;
  --radius-8: 8px;
  --radius-12: 12px;
  --radius-16: 16px;
  --radius-32: 32px;
  --radius-full: 9999px;

  /* 影 ----------------------------------------------------------------- */
  /* 最前面に浮くUI（モーダル等）専用。通常はフラットデザイン */
  --shadow-overlay: 0 20px 40px -12px oklch(0 0 0 / 0.1);

  /* ====================================================================
     OKLCH Color System
     ==================================================================== */

  /* === Tier 1: プリミティブトークン === */

  /* Theme Hue - Forest Monochrome（クローバーのDNAを含んだ深い緑） */
  --theme-hue: 150;

  /* Gray Scale (OKLCH) - フォレスト・ブラック */
  --gray-0: oklch(1 0 0); /* Pure white */
  --gray-25: oklch(0.99 0.001 var(--theme-hue));
  --gray-50: oklch(0.98 0.002 var(--theme-hue)); /* キャンバス */
  --gray-75: oklch(0.97 0.002 var(--theme-hue));
  --gray-100: oklch(0.96 0.003 var(--theme-hue));
  --gray-150: oklch(0.94 0.004 var(--theme-hue));
  --gray-200: oklch(0.92 0.005 var(--theme-hue));
  --gray-300: oklch(0.87 0.006 var(--theme-hue));
  --gray-400: oklch(0.76 0.007 var(--theme-hue));
  --gray-500: oklch(0.65 0.008 var(--theme-hue)); /* Muted */
  --gray-600: oklch(0.54 0.008 var(--theme-hue));
  --gray-700: oklch(0.44 0.007 var(--theme-hue)); /* Sub */
  --gray-800: oklch(0.34 0.006 var(--theme-hue));
  --gray-850: oklch(0.29 0.005 var(--theme-hue));
  --gray-900: oklch(0.24 0.004 var(--theme-hue));
  --gray-950: oklch(0.18 0.005 var(--theme-hue)); /* Main (オフブラック) */
  --gray-1000: oklch(0.05 0.005 var(--theme-hue));

  /* Transparent Colors - Black */
  --black-transparent-60: oklch(0.18 0.005 var(--theme-hue) / 0.6);
  --black-transparent-40: oklch(0.18 0.005 var(--theme-hue) / 0.4);
  --black-transparent-20: oklch(0.18 0.005 var(--theme-hue) / 0.2);
  --black-transparent-10: oklch(0.18 0.005 var(--theme-hue) / 0.1);
  --black-transparent-5: oklch(0.18 0.005 var(--theme-hue) / 0.05);

  /* Transparent Colors - White */
  --white-transparent-95: oklch(0.985 0 0 / 0.95);
  --white-transparent-90: oklch(0.985 0 0 / 0.9);
  --white-transparent-70: oklch(0.985 0 0 / 0.7);
  --white-transparent-50: oklch(0.985 0 0 / 0.5);
  --white-transparent-30: oklch(0.985 0 0 / 0.3);
  --white-transparent-10: oklch(0.985 0 0 / 0.1);

  /* ボーダー定義（透過ブラックを使用） */
  --border-hairline: 1px solid var(--black-transparent-10);
  --border-strong: 1px solid var(--gray-300);
  --border-selected: 1px solid var(--gray-950);

  /* === Tier 2: セマンティックトークン === */

  /* 💡 背景 (Backgrounds) */
  --bg-canvas: var(--gray-50); /* 床：ほんのり色がついた極薄グレー */
  --bg-surface: var(--gray-0); /* 箱：純白（入力欄やメニューなど） */
  --bg-sunken: var(--gray-100); /* 沈んだ床：キャンバスより1段暗いグレー */
  --bg-elevated: var(--gray-0); /* 浮き上がった要素（カード等） */
  --bg-inverse: var(
    --gray-950
  ); /* 反転：プライマリーボタンなど、2%の特異点に使う黒 */
  --bg-overlay: var(--black-transparent-60); /* モーダルの裏の黒幕 */
  --bg-hover: var(--black-transparent-5); /* 汎用ホバー（薄い黒アルファ） */
  --bg-pressed: var(
    --black-transparent-10
  ); /* 汎用プレス（ホバーより少し濃い） */
  --bg-skeleton: var(--gray-100); /* スケルトンローディング */
  --bg-muted: var(--gray-400); /* 中間色（スライダー、バッジ等） */

  /* 💡 テキスト (Typography) */
  --text-main: var(--gray-950); /* 主な文字（緑成分を含んだオフブラック） */
  --text-sub: var(--gray-700); /* サブテキスト */
  --text-muted: var(--gray-500); /* 補助 */
  --text-placeholder: var(--gray-300); /* プレースホルダー */
  --text-inverse: var(--gray-0); /* 反転文字（白） */
  --text-link: var(--gray-950); /* リンク */
  --text-link-hover: var(--gray-600);

  /* 💡 ステートカラー (Semantic State Colors) 
     - subtle: 薄め (背景・カード用)
     - main  : 普通 (アイコン・ボーダー用)
     - strong: 濃いめ (テキスト・強調用)
  */
  --color-danger-subtle: oklch(0.96 0.03 25);
  --color-danger-main: oklch(0.65 0.2 25);
  --color-danger-strong: oklch(0.45 0.18 25);

  --color-success-subtle: oklch(0.96 0.03 145);
  --color-success-main: oklch(0.7 0.18 145);
  --color-success-strong: oklch(0.45 0.15 145);

  --color-warning-subtle: oklch(0.96 0.03 80);
  --color-warning-main: oklch(0.8 0.18 80);
  --color-warning-strong: oklch(0.55 0.15 80);

  /* インデックス・レイアウト ------------------------------------------------ */
  --z-header: 50;
  --z-quickbar: 60;
  --z-modal: 100;
  --z-layer-a: 10;

  --header-height: 56px;
  --quickbar-offset: var(--spacing-3);
  --quickbar-item-size: 48px;
  --icon-button-size: 40px;
  --hamburger-menu-modal-width: 320px;

  --content-width-s: 480px;
  --content-width-m: 600px;
  --content-width-l: 800px;
  --content-width-xl: 1000px;
  --content-width-max: 1400px;

  /* トランジション ---------------------------------------------------------- */
  --ease-flat: cubic-bezier(0.2, 1, 0.2, 1);
  --transition-fast: 0.15s var(--ease-flat);
  --transition-normal: 0.3s var(--ease-flat);
  --transition-slow: 0.6s var(--ease-flat);
  --transition-smooth: 0.3s ease-out;

  /* 状態 ----------------------------------------------------------------- */
  --state-disabled-opacity: 0.5;

  /* レイヤー（追加） ------------------------------------------------------- */
  --layer-c: 30;
  --layer-max: 9999;
}

/* ============================================
   Dark Mode Overrides
   ============================================ */

[data-theme="dark"] {
  /* 背景 */
  --bg-canvas: var(--gray-1000); /* Pure Black寄りのフォレストブラック */
  --bg-surface: var(--gray-900); /* ダークグレー */
  --bg-sunken: var(--gray-950);
  --bg-elevated: var(--gray-850); /* 浮き上がった要素（カード等） */
  --bg-inverse: var(--gray-0); /* ダークモードの反転色は「白」 */
  --bg-overlay: oklch(0 0 0 / 0.8);
  --bg-hover: var(--white-transparent-10);
  --bg-pressed: var(--white-transparent-20);
  --bg-skeleton: var(--gray-800); /* スケルトンローディング */
  --bg-muted: var(--gray-600); /* 中間色（スライダー、バッジ等） */

  /* テキスト: 反転 */
  --text-main: var(--gray-50);
  --text-sub: var(--gray-300);
  --text-muted: var(--gray-500);
  --text-inverse: var(--gray-950);
  --text-link: var(--gray-0);
  --text-link-hover: var(--gray-300);

  /* ボーダー */
  --border-hairline: 1px solid var(--gray-800);
  --border-strong: 1px solid var(--gray-700);

  /* シャドウ */
  --shadow-overlay: 0 20px 40px -12px oklch(0 0 0 / 0.5);

  /* ステートカラー (ダークモードでは文字を明るく、背景を暗くしてコントラストを担保) */
  --color-danger-subtle: oklch(0.2 0.03 25);
  --color-danger-main: oklch(0.7 0.2 25);
  --color-danger-strong: oklch(0.85 0.15 25);

  --color-success-subtle: oklch(0.2 0.03 145);
  --color-success-main: oklch(0.75 0.18 145);
  --color-success-strong: oklch(0.85 0.12 145);

  --color-warning-subtle: oklch(0.2 0.03 80);
  --color-warning-main: oklch(0.85 0.18 80);
  --color-warning-strong: oklch(0.95 0.12 80);
}

/* ============================================
   Reset Styles
   ============================================ */

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

:where([hidden]:not([hidden="until-found"])) {
  display: none !important;
}

:where(html) {
  -webkit-text-size-adjust: none;
  -moz-tab-size: 4;
  tab-size: 4;
  color-scheme: dark light;
}

@supports not (min-block-size: 100dvb) {
  :where(html) {
    block-size: 100%;
  }
}

@media (prefers-reduced-motion: no-preference) {
  :where(html:focus-within) {
    scroll-behavior: smooth;
  }
}

:where(body) {
  block-size: 100%;
  block-size: 100dvb;
  line-height: var(--line-height-default);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

:where(input, button, textarea, select) {
  font: inherit;
  color: inherit;

  &:-webkit-autofill,
  &:-webkit-autofill:hover,
  &:-webkit-autofill:focus {
    -webkit-box-shadow: 0 0 0 1000px var(--bg-surface) inset;
    -webkit-text-fill-color: var(--text-main);
    caret-color: var(--text-main);
    color: var(--text-main);
  }
}

:where(textarea) {
  resize: vertical;
  resize: block;
}

:where(button, label, select, summary, [role="button"], [role="option"]) {
  cursor: pointer;
}

:where(:disabled) {
  cursor: not-allowed;
}

:where(label:has(> input:disabled), label:has(+ input:disabled)) {
  cursor: not-allowed;
}

:where(button) {
  background: none;
  border: none;
}

:where(a) {
  color: inherit;
  text-decoration: none;
  text-underline-offset: 0.2ex;
}

:where(ul, ol) {
  list-style: none;
}

:where(img, svg, video, canvas, audio, iframe, embed, object) {
  display: block;
}

:where(img, picture, svg, video) {
  max-inline-size: 100%;
  block-size: auto;
}

:where(p, h1, h2, h3, h4, h5, h6) {
  overflow-wrap: break-word;
}

:where(h1, h2, h3) {
  line-height: calc(1em + 0.5rem);
}

:where(hr) {
  border: none;
  border-block-start: 1px solid;
  color: inherit;
  block-size: 0;
  overflow: visible;
}

:where(:focus-visible, [data-focus-visible]) {
  outline: var(--border-strong);
  outline-offset: 2px;
  opacity: 1;
}

a,
button {
  &:where(:disabled, [data-disabled="true"]) {
    opacity: 0.4;
    cursor: not-allowed;
  }
}

:where(
  .visually-hidden:not(:focus, :active, :focus-within, .not-visually-hidden)
) {
  clip-path: inset(50%) !important;
  height: 1px !important;
  width: 1px !important;
  overflow: hidden !important;
  position: absolute !important;
  white-space: nowrap !important;
  border: 0 !important;
}

/* ============================================
   Global Styles
   ============================================ */

body {
  max-width: 100%;
  font-family: var(--font-body);
  font-size: var(--font-size-default);
  font-weight: var(--font-weight-regular);
  line-height: var(--line-height-default);
  font-optical-sizing: auto;
  font-style: normal;
  text-align: justify;
  letter-spacing: 0;
  color: var(--text-main);
  background: var(--bg-canvas);
  font-feature-settings: "palt" 1;
}

h1,
h2,
h3,
h4,
h5,
h6 {
  font-family: var(--font-heading);
  color: var(--text-main);
  font-weight: var(--font-weight-bold);
  line-height: var(--line-height-120);
  letter-spacing: -0.02em;
  font-feature-settings: "palt" 1;
}

a {
  color: var(--text-link);
  text-decoration: none;
  transition: all var(--transition-fast);

  &:hover,
  &[data-hovered] {
    color: var(--text-link-hover);
  }

  &:active {
    color: var(--text-sub);
  }
}

img {
  width: 100%;
  max-width: 100%;
  height: auto;
  vertical-align: bottom;
}

/* スクロールバー */
::-webkit-scrollbar {
  width: var(--spacing-1);
  border-radius: var(--radius-8);
}

::-webkit-scrollbar-track {
  background-color: var(--bg-sunken);
}

::-webkit-scrollbar-thumb {
  background-color: var(--bg-muted);
  border-radius: var(--radius-8);

  &:hover {
    background-color: var(--text-muted);
  }
}

/* ============================================
   Utility Classes
   ============================================ */

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

.container {
  width: 100%;
  max-width: var(--content-width-xl);
  margin: 0 auto;
  padding: 0 var(--spacing-2);
}

/* ============================================
   Animations
   ============================================ */

@keyframes marquee {
  0% {
    transform: translateX(0);
  }

  100% {
    transform: translateX(-50%);
  }
}

@keyframes float {
  0%,
  100% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(-10px);
  }
}

@keyframes revealText {
  0% {
    transform: translateY(100%);
    opacity: 0;
  }

  100% {
    transform: translateY(0);
    opacity: 1;
  }
}

.animate-marquee {
  animation: marquee 30s linear infinite;
}

.animate-float {
  animation: float 6s ease-in-out infinite;
}
