/* ═══════════════════════════════════════════════
   SUMI — 墨に、五彩あり。
   和紙の白 × 墨の黒 × 落款の朱
   ═══════════════════════════════════════════════ */

:root {
  --washi:   #f4efe4;   /* 和紙 */
  --ink:     #1b1917;   /* 墨 */
  --sumi-2:  #57524b;   /* 薄墨 */
  --shu:     #a8271c;   /* 朱（落款） */
  --line:    rgba(27, 25, 23, 0.16);

  --font-display: "Shippori Mincho B1", serif;
  --font-latin:   "Cormorant Garamond", serif;
  --font-body:    "Zen Kaku Gothic New", sans-serif;
  --font-mono:    "IBM Plex Mono", monospace;

  --ease-out:  cubic-bezier(0.16, 1, 0.3, 1);
  --ease-soft: cubic-bezier(0.45, 0, 0.15, 1);

  --pad: clamp(20px, 4vw, 48px);
  --load: 0;
}

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

html, body { height: 100%; }

body {
  background: var(--washi);
  color: var(--ink);
  font-family: var(--font-body);
  font-weight: 300;
  letter-spacing: 0.06em;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
body.has-cursor, body.has-cursor a, body.has-cursor button { cursor: none; }

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

.mono {
  font-family: var(--font-mono);
  font-weight: 400;
  font-size: 11px;
  letter-spacing: 0.22em;
  color: var(--sumi-2);
}

/* ═══════════ キャンバス ═══════════ */
.sumi-canvas { position: fixed; inset: 0; width: 100vw; height: 100vh; z-index: 0; }

body.no-webgl .sumi-canvas { display: none; }
body.no-webgl::before {
  content: "このブラウザではWebGLが使えないため、墨を落とせません。";
  position: fixed; inset: auto var(--pad) 50% var(--pad);
  text-align: center; font-size: 13px; color: var(--sumi-2);
}

.grain {
  position: fixed; inset: -60%;
  z-index: 3; pointer-events: none;
  opacity: 0.035;
  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.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='240' height='240' filter='url(%23n)' opacity='1'/%3E%3C/svg%3E");
  animation: grain 0.9s steps(4) infinite;
}
@keyframes grain {
  0% { transform: translate(0, 0); }
  25% { transform: translate(-3%, 2%); }
  50% { transform: translate(2%, -3%); }
  75% { transform: translate(-2%, -2%); }
  100% { transform: translate(3%, 3%); }
}

/* ═══════════ ローダー ═══════════ */
.loader {
  position: fixed; inset: 0; z-index: 100;
  background: var(--washi);
  display: grid; place-items: center;
  overflow: hidden;
  transition: opacity 0.9s var(--ease-soft) 0.25s, visibility 0s 1.2s;
}
body.is-loaded .loader { opacity: 0; visibility: hidden; }

/* 中央からにじむ墨 */
.loader__ink {
  position: absolute; left: 50%; top: 50%;
  width: 46vmax; height: 46vmax;
  border-radius: 50%;
  transform: translate(-50%, -50%) scale(var(--load));
  background: radial-gradient(circle,
    rgba(27, 25, 23, 0.16) 0%,
    rgba(27, 25, 23, 0.07) 42%,
    rgba(27, 25, 23, 0.025) 68%,
    transparent 78%);
  filter: blur(6px);
}
.loader__center { position: relative; text-align: center; }
.loader__kanji {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(64px, 11vw, 130px);
  color: var(--ink);
}
.loader__count {
  margin-top: 10px;
  font-family: var(--font-latin);
  font-weight: 300; font-size: 20px; letter-spacing: 0.3em;
  color: var(--shu);
}
.loader__count small { font-size: 12px; }

/* ═══════════ カーソル（筆先） ═══════════ */
.cursor { position: fixed; top: 0; left: 0; z-index: 90; pointer-events: none; will-change: transform; }
.cursor__tip {
  position: absolute; top: -3px; left: -3px;
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--ink);
  transition: transform 0.25s var(--ease-out);
}
.cursor__ring {
  position: absolute; top: -16px; left: -16px;
  width: 32px; height: 32px; border-radius: 50%;
  border: 1px solid rgba(27, 25, 23, 0.35);
  transition: transform 0.3s var(--ease-out), border-color 0.3s;
}
.cursor.is-down .cursor__tip { transform: scale(1.8); }
.cursor.is-down .cursor__ring { transform: scale(0.7); border-color: var(--ink); }
.cursor.is-hover .cursor__ring { transform: scale(1.5); border-color: var(--shu); }

/* 墨色に合わせて筆先の色が変わる */
body[data-ink="shu"] .cursor__tip { background: #a8271c; }
body[data-ink="ai"]  .cursor__tip { background: #1c3a66; }
body[data-ink="kin"] .cursor__tip { background: #9a7b2e; }

/* ═══════════ ヘッダー ═══════════ */
.site-header {
  position: fixed; top: 0; left: 0; right: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between;
  padding: clamp(16px, 2.6vw, 26px) var(--pad);
  pointer-events: none;
}
.site-header a, .site-header button { pointer-events: auto; }

.brand { display: inline-flex; align-items: center; gap: 12px; color: var(--shu); }
.brand__mark { width: 30px; height: 30px; }
.brand__name {
  font-family: var(--font-latin);
  font-weight: 500; font-size: 18px; letter-spacing: 0.42em;
  color: var(--ink);
}

.header__right { display: flex; align-items: center; gap: clamp(14px, 2.5vw, 28px); }
.counter span { color: var(--shu); }
.share {
  pointer-events: auto;
  color: var(--ink); text-decoration: none;
  border: 1px solid var(--line); border-radius: 999px;
  padding: 8px 18px;
  background: rgba(244, 239, 228, 0.6);
  transition: border-color 0.3s, background 0.3s, color 0.3s;
}
.share:hover { border-color: var(--shu); color: var(--shu); background: rgba(168, 39, 28, 0.06); }

/* 言語スイッチャー（和紙のライトテーマに合わせる） */
.lang {
  pointer-events: auto;
  display: flex; align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px;
  gap: 2px;
  background: rgba(244, 239, 228, 0.6);
}
.lang button {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.08em;
  color: var(--sumi-2);
  background: transparent;
  border: 0;
  border-radius: 999px;
  min-width: 30px;
  padding: 5px 8px;
  cursor: pointer;
  transition: color 0.25s, background 0.25s;
}
.lang button:hover { color: var(--ink); }
.lang button.is-on { color: var(--washi); background: var(--ink); }

/* 韓国語・中国語のフォント差し替え（選択時にJSがロード） */
body[data-lang="ko"] {
  --font-display: "Noto Serif KR", "Shippori Mincho B1", serif;
  --font-body: "Noto Sans KR", "Zen Kaku Gothic New", sans-serif;
}
body[data-lang="zh"] {
  --font-display: "Noto Serif SC", "Shippori Mincho B1", serif;
  --font-body: "Noto Sans SC", "Zen Kaku Gothic New", sans-serif;
}
body[data-lang="en"] .intro__title {
  letter-spacing: 0.01em;
  font-size: clamp(44px, 8.4vw, 118px);
}

/* ═══════════ タイトル ═══════════ */
.stage { position: relative; z-index: 2; height: 100svh; pointer-events: none; }

.intro {
  position: absolute;
  left: var(--pad); top: 50%;
  transform: translateY(-56%);
  transition: opacity 1.2s var(--ease-soft), transform 1.2s var(--ease-soft), filter 1.2s var(--ease-soft);
}
body.is-played .intro {
  opacity: 0;
  transform: translateY(-56%) scale(0.985);
  filter: blur(4px);
}

.intro__eyebrow { margin-bottom: clamp(14px, 2.4vw, 26px); }

.intro__title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(52px, 9.5vw, 132px);
  line-height: 1.22;
  letter-spacing: 0.05em;
  color: var(--ink);
}
.intro__line { display: block; overflow: hidden; }
.intro__line--indent { padding-left: clamp(28px, 7vw, 130px); }
.intro__line-inner {
  display: inline-block;
  transform: translateY(115%) rotate(1.2deg);
  transition: transform 1.3s var(--ease-out);
}
body.is-loaded .intro__line:nth-child(1) .intro__line-inner { transition-delay: 0.45s; transform: none; }
body.is-loaded .intro__line:nth-child(2) .intro__line-inner { transition-delay: 0.62s; transform: none; }

.intro__hint {
  display: flex; flex-wrap: wrap; gap: 10px;
  margin-top: clamp(22px, 3.4vw, 38px);
  opacity: 0; transform: translateY(20px);
  transition: opacity 1s var(--ease-out) 1s, transform 1s var(--ease-out) 1s;
}
body.is-loaded .intro__hint { opacity: 1; transform: none; }

.hint-chip {
  font-size: 12px; letter-spacing: 0.12em;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 16px;
  background: rgba(244, 239, 228, 0.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

/* ═══════════ 操作ドック ═══════════ */
.dock {
  position: fixed;
  left: 50%; bottom: clamp(18px, 3.4vh, 34px);
  transform: translateX(-50%);
  z-index: 60;
  display: flex; align-items: stretch;
  gap: clamp(10px, 1.6vw, 22px);
  padding: 12px clamp(14px, 2vw, 24px);
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(244, 239, 228, 0.72);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 18px 50px rgba(27, 25, 23, 0.14);
  opacity: 0; translate: 0 24px;
  transition: opacity 1s var(--ease-out) 1.2s, translate 1s var(--ease-out) 1.2s;
}
body.is-loaded .dock { opacity: 1; translate: 0 0; }

.dock__group { display: flex; align-items: center; gap: 6px; }
.dock__label {
  margin-right: 6px; font-size: 10px;
  writing-mode: vertical-rl;
  letter-spacing: 0.28em;
}
.dock__rule { width: 1px; background: var(--line); margin: 4px 0; }

.dock button {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 14px;
  letter-spacing: 0.1em;
  color: var(--sumi-2);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 9px 14px;
  display: inline-flex; align-items: center; gap: 7px;
  white-space: nowrap;
  transition: color 0.25s, background 0.25s, border-color 0.25s, transform 0.2s var(--ease-out);
}
.dock button:hover { color: var(--ink); transform: translateY(-1px); }
.dock button.is-on {
  color: var(--ink);
  background: rgba(27, 25, 23, 0.06);
  border-color: rgba(27, 25, 23, 0.35);
}
.dock button:active { transform: scale(0.94); }

/* ドックの漢字＋訳語サブラベル（非日本語時のみ表示） */
.dock__txt {
  display: inline-flex; flex-direction: column; align-items: center;
  line-height: 1.15;
}
.dock button small {
  font-family: var(--font-mono);
  font-weight: 400;
  font-size: 8.5px;
  letter-spacing: 0.06em;
  color: inherit;
  opacity: 0.62;
  margin-top: 2px;
  white-space: nowrap;
}
body[data-lang="ja"] .dock small { display: none; }

.dock__wash { color: var(--shu) !important; }
.dock__wash.is-on { border-color: rgba(168, 39, 28, 0.5) !important; background: rgba(168, 39, 28, 0.07) !important; }

/* 墨色見本 */
.swatch {
  width: 12px; height: 12px; border-radius: 50%;
  border: 1px solid rgba(27, 25, 23, 0.2);
}
.swatch--sumi { background: #211e1b; }
.swatch--shu  { background: #a8271c; }
.swatch--ai   { background: #1c3a66; }
.swatch--kin  { background: #b28f3a; }

/* ═══════════ フッター ═══════════ */
.site-footer {
  position: fixed;
  left: 50%; transform: translateX(-50%);
  bottom: clamp(140px, 19vh, 175px);
  z-index: 40;
  pointer-events: none;
  opacity: 0;
  transition: opacity 1s var(--ease-out) 1.5s;
}
body.is-loaded .site-footer { opacity: 1; }
.site-footer p { font-size: 10px; color: rgba(87, 82, 75, 0.8); }

/* ═══════════ 落款 ═══════════ */
.rakkan {
  position: fixed;
  right: var(--pad); bottom: clamp(20px, 3.4vh, 36px);
  z-index: 40;
  width: 44px; height: 44px;
  display: grid; place-items: center;
  background: var(--shu);
  color: var(--washi);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 24px;
  border-radius: 6px;
  box-shadow: 0 4px 14px rgba(168, 39, 28, 0.3);
  opacity: 0;
  transition: opacity 1s var(--ease-out) 1.7s;
}
body.is-loaded .rakkan { opacity: 0.92; }

/* ═══════════ レスポンシブ ═══════════ */
.pc-only { display: inline-flex; }

@media (max-width: 860px) {
  .pc-only { display: none; }
  .counter { display: none; }
  .intro { right: var(--pad); }
  .intro__title { font-size: clamp(46px, 13vw, 76px); }
  body[data-lang="en"] .intro__title { font-size: clamp(38px, 11vw, 64px); }
  .lang button { min-width: 26px; padding: 5px 6px; }
  .dock button small { font-size: 8px; }

  .dock {
    left: 12px; right: 12px;
    transform: none;
    flex-wrap: wrap;
    justify-content: center;
    row-gap: 6px;
    border-radius: 16px;
  }
  .dock__rule { display: none; }
  .dock__label { display: none; }
  .dock button { padding: 9px 12px; font-size: 13px; }

  .site-footer { display: none; }
  .rakkan { bottom: auto; top: 76px; width: 38px; height: 38px; font-size: 20px; }
}

@media (max-width: 520px) {
  .brand__name { display: none; }
  .header__right { gap: 10px; }
  .share { padding: 8px 12px; }
}

/* ═══════════ 動きを減らす設定 ═══════════ */
@media (prefers-reduced-motion: reduce) {
  .grain { animation: none; }
  .intro__line-inner, .intro__hint, .dock, .site-footer, .rakkan { transition: none; opacity: 1; transform: none; translate: 0 0; }
}

/* ═══════════ ハブ（SHIZEN）へ戻る ═══════════ */
.hub-link {
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  padding-right: 14px;
  margin-right: 2px;
  border-right: 1px solid var(--line);
  transition: color 0.3s;
}
.hub-link:hover { color: inherit; }
@media (max-width: 860px) {
  .hub-link { font-size: 9.5px; letter-spacing: 0.14em; padding-right: 10px; }
}
