/* ============================================================
   トップページ (Telisia Works) スタイル
   ── 無限キャンバス + 浮遊ヘッダー + キャプションピル
   元: src/index.njk の <style> 部分から外部化 (2026-05-20)
   ============================================================ */

:root {
  --bg:        #ede4d3;
  --bg-soft:   #f5eee0;
  --bg-warm:   #e0d4be;
  --ink:       #2a2218;
  --ink2:      #5b4a35;
  --ink3:      #8b7861;
  --line:      rgba(42,34,24,0.12);
  --line-strong: rgba(42,34,24,0.22);
  --accent:    #c8541e;
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  height: 100%;
  overflow: hidden;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}
html, body {
  /* iOS Safariのアドレスバー表示時、 .viewport(fixed) との微妙なズレで
     下に背景と同じ色の「帯」が見える現象対策: body にも同じドット背景を入れる */
  background: var(--bg);
  background-image: radial-gradient(circle, rgba(42,34,24,0.05) 1px, transparent 1px);
  background-size: 32px 32px;
}
body.home-redesign {
  font-family: -apple-system, "Segoe UI", "Yu Gothic UI", "Hiragino Sans", "Noto Sans JP", sans-serif;
  color: var(--ink);
  user-select: none;
  -webkit-user-select: none;
}

/* ===== ビューポート(画面全体) ===== */
.viewport {
  position: fixed;
  inset: 0;
  overflow: hidden;
  cursor: grab;
  background: var(--bg);
  background-image:
    radial-gradient(circle, rgba(42,34,24,0.05) 1px, transparent 1px);
  background-size: 32px 32px;
  touch-action: none;
}
.viewport.dragging { cursor: grabbing; }
.viewport.dragging * { pointer-events: none; }
.viewport.dragging .cell {
  transition: none !important;
  transform: none !important;
  filter: none !important;
}

/* ===== 無限キャンバス ===== */
/* PC: 1セル 320px + 隙間 130px、 2×2 → タイル幅 2 × (130 + 320) = 900px
   モバイル: 1セル 170px + 隙間 60px → タイル幅 460px (JSで位置も再計算) */
.canvas {
  position: absolute;
  width: 900px;
  height: 900px;
  will-change: transform;
  transform: translate3d(0, 0, 0);
}
@media (max-width: 767px) {
  .canvas { width: 460px; height: 460px; }
}

/* ===== セル ===== */
/* セル自体の背景・枠線とも無し → 画像のみ浮かぶ印象
   ★ 透過 WebP に綺麗に影を落とすため、 hover 時は
      box-shadow (矩形に影) ではなく filter: drop-shadow (シルエットに沿った影) を使用
      ※ overflow: hidden は drop-shadow の出力を切り取ってしまうので無し
        img が cell の inset:0 なので、 はみ出しの心配なし
   (Telisia さん提案、 2026-05-19) */
.cell {
  position: absolute;
  width: 320px;
  height: 320px;
  background: transparent;
  border: none;
  cursor: pointer;
  transition: transform 0.35s cubic-bezier(0.2, 0.8, 0.3, 1.0),
              filter 0.35s ease;
  text-decoration: none;
  color: inherit;
  transform-origin: center center;
  contain: layout style;
  /* <a>タグ自体のネイティブなドラッグ挙動(URLゴースト引きずり)を抑止 */
  -webkit-user-drag: none;
  user-drag: none;
}
.cell:hover {
  transform: translateY(-6px) scale(1.04);
  z-index: 10;
  filter: drop-shadow(0 14px 30px rgba(42,34,24,0.18));
}
@media (max-width: 767px) {
  .cell { width: 170px; height: 170px; }
}

/* thumb が cell 全体を覆う(画像を全面表示)。 背景も透明 */
.cell .thumb {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: transparent;
  overflow: hidden;
}
.cell .thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  user-select: none;
  -webkit-user-drag: none;
}

/* ===== ホバー時の Caption Pill =====
   アイコンの下に角丸 pill 型のキャプションプレートが、 中央から拡大しながらふわっと現れる。
   アイコンの角丸とpillの完全角丸が呼応し、 スマホでも 「これは何のツールか」 が即わかる。
   (2026-05-20 Telisia さん選定 / 案C 採用) */
.cell .pill {
  position: absolute;
  bottom: -22px;
  left: 50%;
  transform: translateX(-50%) scale(0.7);
  background: var(--bg-soft);
  border: 1px solid var(--line-strong);
  padding: 8px 22px;
  border-radius: 999px;       /* 完全角丸 (pill 型) */
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.35s ease,
              transform 0.45s cubic-bezier(0.2, 0.8, 0.3, 1.0);
  pointer-events: none;
  z-index: 5;
  box-shadow: 0 6px 16px rgba(42,34,24,0.12);
  display: inline-flex;
  align-items: center;
}
.cell:hover .pill {
  opacity: 1;
  transform: translateX(-50%) scale(1);
}
.cell .pill .en {
  font-family: "Cormorant Garamond", "Yu Mincho", serif;
  font-style: italic;
  font-weight: 500;
  font-size: 0.95rem;
  color: var(--accent);
  letter-spacing: 0.04em;
}
.cell .pill .sep {
  color: var(--ink3);
  margin: 0 8px;
  font-size: 0.8rem;
}
.cell .pill .ja {
  font-size: 0.74rem;
  color: var(--ink2);
  letter-spacing: 0.06em;
  font-weight: 600;
}

/* モバイル時の Caption Pill 微調整 */
@media (max-width: 767px) {
  .cell .pill {
    bottom: -18px;
    padding: 6px 16px;
    box-shadow: 0 4px 12px rgba(42,34,24,0.12);
  }
  .cell .pill .en { font-size: 0.82rem; }
  .cell .pill .sep { margin: 0 6px; font-size: 0.72rem; }
  .cell .pill .ja { font-size: 0.66rem; }
}
.cell .num {
  position: absolute;
  top: 10px;
  left: 12px;
  font-family: ui-monospace, monospace;
  font-size: 0.66rem;
  color: var(--ink3);
  letter-spacing: 0.1em;
  z-index: 2;
}
/* セル種類別の特別表示は廃止 (全セル枠線なし・統一感重視) */


/* ===== 浮遊ヘッダー ===== */
.floating-header {
  position: fixed;
  top: 24px; left: 32px;
  z-index: 100;
  pointer-events: auto;
}
.floating-header a.logo-link {
  text-decoration: none;
  color: var(--ink);
  display: block;
}
.floating-header .logo {
  font-family: "Cormorant Garamond", "Yu Mincho", serif;
  font-size: 1.4rem;
  font-weight: 500;
  letter-spacing: 0.18em;
  color: var(--ink);
}
.floating-header .logo .em { color: var(--accent); }
.floating-header .tagline {
  font-size: 0.7rem;
  color: var(--ink3);
  letter-spacing: 0.16em;
  margin-top: 2px;
}

/* ===== 浮遊ナビ ===== */
.floating-nav {
  position: fixed;
  top: 24px; right: 32px;
  z-index: 100;
  display: flex;
  gap: 22px;
  align-items: center;
}
.floating-nav a {
  color: var(--ink);
  text-decoration: none;
  font-size: 0.86rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-weight: 700;
  transition: color 0.2s;
  position: relative;
  padding: 4px 0;
}
.floating-nav a:hover { color: var(--accent); }
.floating-nav a::after {
  content: "";
  position: absolute;
  left: 0; bottom: 0;
  width: 100%; height: 1px;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.25s;
}
.floating-nav a:hover::after { transform: scaleX(1); }

/* ===== モバイル用ハンバーガーボタン ===== */
.floating-menu-btn {
  display: none;
  position: fixed;
  top: 16px; right: 16px;
  z-index: 101;
  flex-direction: column;
  gap: 4px;
  background: rgba(245,238,224,0.85);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--line);
  padding: 10px 12px;
  cursor: pointer;
  border-radius: 4px;
}
.floating-menu-btn span {
  display: block;
  width: 20px;
  height: 1.5px;
  background: var(--ink);
  transition: transform 0.3s, opacity 0.3s;
}
.floating-menu-btn.open span:nth-child(1) {
  transform: translateY(5.5px) rotate(45deg);
}
.floating-menu-btn.open span:nth-child(2) { opacity: 0; }
.floating-menu-btn.open span:nth-child(3) {
  transform: translateY(-5.5px) rotate(-45deg);
}

/* ===== スマホ対応 (ナビ重なり防止) ===== */
@media (max-width: 767px) {
  .floating-header {
    top: 16px;
    left: 16px;
  }
  .floating-header .logo { font-size: 1.05rem; letter-spacing: 0.14em; }

  .floating-menu-btn { display: flex; }

  .floating-nav {
    top: 60px;
    right: 16px;
    left: auto;
    flex-direction: column;
    align-items: flex-end;
    gap: 0;
    background: rgba(245,238,224,0.95);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    padding: 0 22px;
    border: 1px solid var(--line);
    border-radius: 6px;
    box-shadow: 0 8px 24px rgba(42,34,24,0.12);
    max-height: 0;
    opacity: 0;
    pointer-events: none;
    overflow: hidden;
    transition: max-height 0.3s ease, opacity 0.25s ease, padding 0.3s ease;
  }
  .floating-nav.open {
    max-height: 400px;
    opacity: 1;
    pointer-events: auto;
    padding: 16px 22px;
  }
  .floating-nav a {
    padding: 8px 0;
    font-size: 0.92rem;
  }
}

/* ===== 初回案内バルーン ===== */
.first-visit-hint {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  place-items: center;
  pointer-events: none;
  animation: hintFadeIn 0.5s ease both;
}
.first-visit-hint.hide {
  animation: hintFadeOut 0.4s ease both;
}
.first-visit-hint .balloon {
  background: rgba(245,238,224,0.95);
  border: 1px solid var(--line);
  padding: 24px 38px;
  border-radius: 4px;
  text-align: center;
  box-shadow: 0 12px 36px rgba(42,34,24,0.16);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.first-visit-hint .arrow {
  font-size: 1.6rem;
  color: var(--accent);
  margin-bottom: 10px;
  letter-spacing: 0.4em;
  display: block;
  animation: arrowSwing 1.4s ease-in-out infinite;
}
.first-visit-hint .text-ja {
  font-size: 1.02rem;
  color: var(--ink);
  letter-spacing: 0.06em;
  font-weight: 700;
  margin-bottom: 4px;
}
.first-visit-hint .text-en {
  font-size: 0.78rem;
  color: var(--ink3);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-family: "Cormorant Garamond", serif;
  font-style: italic;
}
@keyframes hintFadeIn {
  from { opacity: 0; transform: scale(0.92); }
  to   { opacity: 1; transform: scale(1); }
}
@keyframes hintFadeOut {
  from { opacity: 1; transform: scale(1); }
  to   { opacity: 0; transform: scale(0.95); visibility: hidden; }
}
@keyframes arrowSwing {
  0%, 100% { transform: translateX(0); }
  50%      { transform: translateX(8px); }
}

/* ===== カスタムカーソル(円 + 中央点) ===== */
@media (hover: hover) and (pointer: fine) {
  *, .viewport, .viewport * { cursor: none !important; }
  a { cursor: none !important; }
  .custom-cursor {
    position: fixed;
    top: 0; left: 0;
    width: 32px; height: 32px;
    border: 1.5px solid var(--ink);
    border-radius: 50%;
    pointer-events: none;
    z-index: 9999;
    transform: translate(-50%, -50%);
    transition:
      width 0.25s cubic-bezier(0.2, 0.8, 0.3, 1.0),
      height 0.25s cubic-bezier(0.2, 0.8, 0.3, 1.0),
      border-color 0.25s ease,
      background 0.25s ease;
    display: grid;
    place-items: center;
    will-change: left, top;
  }
  .custom-cursor::after {
    content: "";
    width: 4px; height: 4px;
    background: var(--ink);
    border-radius: 50%;
    transition: background 0.25s ease, width 0.25s ease, height 0.25s ease;
  }
  .custom-cursor.hover {
    width: 64px; height: 64px;
    border-color: var(--accent);
    background: rgba(200,84,30,0.05);
  }
  .custom-cursor.hover::after {
    background: var(--accent);
    width: 6px; height: 6px;
  }
  .custom-cursor.dragging {
    width: 22px; height: 22px;
    border-color: var(--accent);
  }
  .custom-cursor.dragging::after {
    background: var(--accent);
  }
}
@media (hover: none), (pointer: coarse) {
  .custom-cursor { display: none !important; }
}
