/* ═══════════════════════════════════════════════
   HANABI — 合図で、咲く。
   夏の夜の藍 × 金 × 水面
   ═══════════════════════════════════════════════ */

:root {
  --night:   #070b1a;   /* 夜空の底 */
  --night-2: #0c1228;   /* 少し明るい藍 */
  --moon:    #f0ead9;   /* 月明かりの白 */
  --fog:     #9aa0b8;   /* 霞んだ文字色 */
  --gold:    #c9a86a;   /* 金（アクセント） */
  --gold-2:  #e6c982;   /* 明るい金 */
  --line:    rgba(201, 168, 106, 0.22);

  --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(--night);
  color: var(--moon);
  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;
  touch-action: none;
}
body.has-cursor, body.has-cursor a, body.has-cursor button { cursor: none; }

::selection { background: var(--gold); color: var(--night); }

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

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

body.no-canvas .fx-canvas, body.no-canvas .bg-canvas { display: none; }
body.no-canvas::before {
  content: "このブラウザではCanvasが使えないため、花火を打ち上げられません。";
  position: fixed; inset: auto var(--pad) 50% var(--pad);
  text-align: center; font-size: 13px; color: var(--fog);
}

.grain {
  position: fixed; inset: -60%;
  z-index: 3; pointer-events: none;
  opacity: 0.04;
  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(--night);
  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__glow {
  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(230, 201, 130, 0.20) 0%,
    rgba(201, 168, 106, 0.09) 40%,
    rgba(201, 168, 106, 0.03) 66%,
    transparent 78%);
  filter: blur(8px);
}
.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(--moon);
  text-shadow: 0 0 40px rgba(230, 201, 130, 0.35);
}
.loader__count {
  margin-top: 10px;
  font-family: var(--font-latin);
  font-weight: 300; font-size: 20px; letter-spacing: 0.3em;
  color: var(--gold);
}
.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(--gold-2);
  box-shadow: 0 0 10px rgba(230, 201, 130, 0.8);
  transition: transform 0.25s var(--ease-out), background 0.3s;
}
.cursor__ring {
  position: absolute; top: -16px; left: -16px;
  width: 32px; height: 32px; border-radius: 50%;
  border: 1px solid rgba(230, 201, 130, 0.45);
  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(--gold-2); }
.cursor.is-hover .cursor__ring { transform: scale(1.5); border-color: var(--gold); }

/* 選んだ色に合わせて火種の色が変わる */
body[data-color="beni"]     .cursor__tip { background: #e0455a; box-shadow: 0 0 10px rgba(224, 69, 90, 0.8); }
body[data-color="ao"]       .cursor__tip { background: #5b8fe0; box-shadow: 0 0 10px rgba(91, 143, 224, 0.8); }
body[data-color="midori"]   .cursor__tip { background: #4fc276; box-shadow: 0 0 10px rgba(79, 194, 118, 0.8); }
body[data-color="murasaki"] .cursor__tip { background: #a86fe0; box-shadow: 0 0 10px rgba(168, 111, 224, 0.8); }
body[data-color="niji"]     .cursor__tip { background: conic-gradient(#e0455a, #e6c982, #4fc276, #5b8fe0, #a86fe0, #e0455a); }

/* ═══════════ ヘッダー ═══════════ */
.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(--gold); }
.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(--moon);
}

.header__right { display: flex; align-items: center; gap: clamp(14px, 2.5vw, 28px); }
.counter span { color: var(--gold-2); }
.share {
  pointer-events: auto;
  color: var(--moon); text-decoration: none;
  border: 1px solid var(--line); border-radius: 999px;
  padding: 8px 18px;
  background: rgba(12, 18, 40, 0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  transition: border-color 0.3s, background 0.3s, color 0.3s;
}
.share:hover { border-color: var(--gold); color: var(--gold-2); background: rgba(201, 168, 106, 0.1); }

/* 言語スイッチャー */
.lang {
  display: flex; align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px;
  gap: 2px;
  background: rgba(12, 18, 40, 0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.lang button {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.08em;
  color: var(--fog);
  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(--moon); }
.lang button.is-on { color: var(--night); background: var(--gold); }

/* 韓国語・中国語のフォント差し替え（選択時に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; }

/* Canvas非対応メッセージの多言語版 */
body[data-lang="en"].no-canvas::before { content: "Canvas is not available in this browser, so the fireworks cannot launch."; }
body[data-lang="ko"].no-canvas::before { content: "이 브라우저에서는 Canvas를 사용할 수 없어 불꽃을 쏘아 올릴 수 없습니다."; }
body[data-lang="zh"].no-canvas::before { content: "此浏览器不支持 Canvas，无法燃放烟花。"; }

/* ═══════════ タイトル ═══════════ */
.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); color: rgba(201, 168, 106, 0.85); }

.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(--moon);
  text-shadow: 0 0 60px rgba(230, 201, 130, 0.18);
}
.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(--moon);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 16px;
  background: rgba(10, 15, 34, 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(9, 13, 30, 0.68);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.5);
  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(--fog);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 9px 14px;
  display: inline-flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  white-space: nowrap;
  transition: color 0.25s, background 0.25s, border-color 0.25s, transform 0.2s var(--ease-out);
}
.dock__main { display: inline-flex; align-items: center; gap: 7px; }

/* 非日本語時のみ表示する訳語サブラベル */
.dock button small {
  font-family: var(--font-body);
  font-weight: 400;
  font-size: 8.5px;
  letter-spacing: 0.04em;
  line-height: 1;
  opacity: 0.6;
  white-space: nowrap;
}
body[data-lang="ja"] .dock small { display: none; }
body:not([data-lang="ja"]) .dock button { padding: 6px 12px; }
.dock button:hover { color: var(--moon); transform: translateY(-1px); }
.dock button.is-on {
  color: var(--gold-2);
  background: rgba(201, 168, 106, 0.1);
  border-color: rgba(201, 168, 106, 0.45);
}
.dock button:active { transform: scale(0.94); }
.dock button.is-disabled { opacity: 0.35; pointer-events: none; }

/* 色見本 */
.swatch {
  width: 12px; height: 12px; border-radius: 50%;
  border: 1px solid rgba(240, 234, 217, 0.25);
}
.swatch--kin      { background: #e6c069; }
.swatch--beni     { background: #e0455a; }
.swatch--ao       { background: #5b8fe0; }
.swatch--midori   { background: #4fc276; }
.swatch--murasaki { background: #a86fe0; }
.swatch--niji     { background: conic-gradient(#e0455a, #e6c982, #4fc276, #5b8fe0, #a86fe0, #e0455a); }

/* ═══════════ フッター ═══════════ */
.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(154, 160, 184, 0.85); text-align: center; }

/* ═══════════ ブランド刻印（花） ═══════════ */
.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(--gold);
  color: var(--night);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 24px;
  border-radius: 6px;
  box-shadow: 0 4px 18px rgba(201, 168, 106, 0.35);
  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: 1120px) {
  body:not([data-lang="ja"]) .dock {
    left: 12px; right: 12px;
    transform: none;
    flex-wrap: wrap;
    justify-content: center;
    row-gap: 6px;
    border-radius: 16px;
  }
  body:not([data-lang="ja"]) .dock__rule,
  body:not([data-lang="ja"]) .dock__label { display: none; }
}

@media (max-width: 860px) {
  .pc-only { display: none; }
  .counter { display: none; }
  .intro { right: var(--pad); }
  .intro__title { font-size: clamp(46px, 13vw, 76px); }

  .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; }
  .lang button { min-width: 26px; padding: 5px 6px; }
  .share { padding: 7px 13px; }
  .dock button small { font-size: 8px; }
}

/* ═══════════ 動きを減らす設定 ═══════════ */
@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; }
}
