/* ============================================================
   星空図譜 — 星景写真集スタイル
   漆黒の空に浮かぶ、静かなダークガラスの UI
   ============================================================ */

:root {
  --bg: #04060d;
  --glass: rgba(12, 17, 28, 0.58);
  --glass-border: rgba(255, 255, 255, 0.12);
  --text: rgba(233, 240, 250, 0.92);
  --text-soft: rgba(200, 212, 230, 0.6);
  --text-faint: rgba(190, 205, 225, 0.38);
  --accent: rgba(140, 175, 235, 0.85);
  --accent-bg: rgba(120, 160, 225, 0.22);
  --serif: "Shippori Mincho", "Yu Mincho", "Hiragino Mincho ProN", serif;
  --sans: "Noto Sans JP", "Hiragino Kaku Gothic ProN", "Yu Gothic", sans-serif;
}

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

html, body {
  height: 100%;
  overflow: hidden;
  font-family: var(--sans);
  font-weight: 300;
  color: var(--text);
  background: var(--bg);
}

/* ---------- 全画面キャンバス ---------- */
#sky-canvas {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  display: block;
  cursor: grab;
  z-index: 0;
  touch-action: none;  /* タッチでのドラッグ/ピンチを自前処理する */
}
#sky-canvas.dragging { cursor: grabbing; }

/* ---------- タイトル（縦書き・画面中央・青いきらめき） ---------- */
.title-plaque {
  /* どのブラウザ・フォールバックフォントでも正確に中央に来るよう
     全画面固定 + flex センタリングにする（縦書きは行箱が右端から
     流れるため、箱の幅が想定より広がると右寄りに見える） */
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  pointer-events: none;
}
.title-plaque h1 {
  font-family: var(--serif);
  writing-mode: vertical-rl;
  font-size: clamp(1.9rem, 4.2vw, 3rem);
  font-weight: 400;
  letter-spacing: 0.5em;
  line-height: 1;
  color: #ffffff;
  animation: title-glow 5s ease-in-out infinite alternate;
}
@keyframes title-glow {
  from {
    text-shadow:
      0 0 6px rgba(160, 195, 255, 0.5),
      0 0 20px rgba(110, 160, 245, 0.35),
      0 0 52px rgba(80, 130, 235, 0.25);
  }
  to {
    text-shadow:
      0 0 10px rgba(180, 208, 255, 0.85),
      0 0 34px rgba(125, 170, 250, 0.6),
      0 0 80px rgba(95, 145, 245, 0.45);
  }
}

/* ---------- SEO 用テキスト（クローラー・スクリーンリーダー向け） ---------- */
.seo-content {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* ---------- フローティングウィンドウ ---------- */
.float-win {
  position: fixed;
  z-index: 20;
  width: 252px;
  background: var(--glass);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.45);
  user-select: none;
  overflow: hidden;
}
.win-title {
  font-size: 0.68rem;
  font-weight: 400;
  letter-spacing: 0.42em;
  text-indent: 0.42em;
  text-align: center;
  color: var(--text-soft);
  padding: 0.6em 0.8em 0.5em;
  cursor: move;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}
.win-body { padding: 0.75rem 0.85rem; }
.win-row {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-wrap: wrap;
}
.win-row + .win-row,
.win-row + .location-label,
.win-row + .win-note { margin-top: 0.55rem; }
.win-note {
  font-size: 0.68rem;
  color: var(--text-faint);
  letter-spacing: 0.06em;
  margin-top: 0.55rem;
}
.location-label {
  font-size: 0.72rem;
  color: var(--text-soft);
  letter-spacing: 0.03em;
  margin-top: 0.55rem;
  line-height: 1.6;
}

input[type="text"],
input[type="datetime-local"] {
  font-family: var(--sans);
  font-weight: 300;
  font-size: 0.85rem;
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 7px;
  padding: 0.38em 0.6em;
  outline: none;
  transition: border-color 0.2s, background 0.2s;
}
input[type="text"] { width: 10.5em; }
input:focus {
  border-color: var(--accent);
  background: rgba(255, 255, 255, 0.09);
}
input::placeholder { color: var(--text-faint); }
input[type="datetime-local"]::-webkit-calendar-picker-indicator {
  filter: invert(0.85);
  opacity: 0.6;
}

.antique-btn {
  font-family: var(--sans);
  font-weight: 300;
  font-size: 0.78rem;
  letter-spacing: 0.12em;
  color: var(--text);
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 7px;
  padding: 0.36em 0.85em;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, color 0.2s;
}
.antique-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.3);
}
.antique-btn.small { font-size: 0.72rem; padding: 0.3em 0.7em; }
.antique-btn.active {
  background: var(--accent-bg);
  border-color: var(--accent);
  color: rgba(235, 243, 255, 1);
  box-shadow: 0 0 12px rgba(120, 160, 230, 0.18);
}

/* ---------- 操作盤トグルスイッチ ---------- */
.panel-switch {
  position: fixed;
  top: 20px;
  right: 22px;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 0.55em;
  cursor: pointer;
  user-select: none;
  opacity: 0.85;
  transition: opacity 0.35s;
}
.panel-switch input { display: none; }
.switch-track {
  position: relative;
  width: 36px;
  height: 19px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.07);
  transition: background 0.25s, border-color 0.25s;
}
.switch-knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: rgba(235, 242, 252, 0.9);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
  transition: left 0.25s, background 0.25s;
}
.panel-switch input:checked + .switch-track {
  background: var(--accent-bg);
  border-color: var(--accent);
}
.panel-switch input:checked + .switch-track .switch-knob { left: 19px; }
.switch-label {
  font-size: 0.68rem;
  font-weight: 300;
  letter-spacing: 0.26em;
  color: var(--text-soft);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
}
/* 操作盤を消したらスイッチも夜空に溶ける（ホバーで浮かぶ） */
body.panels-hidden .panel-switch { opacity: 0.12; }
body.panels-hidden .panel-switch:hover { opacity: 0.7; }
body.panels-hidden .float-win { display: none; }

/* ---------- スマホ用 操作盤シート（PC では一切表示しない） ---------- */
.mobile-panel-btn,
.panel-backdrop,
.save-settings-btn { display: none; }

@media (max-width: 720px) {
  /* PC 用トグルスイッチは隠し、はっきり読めるボタンに置き換える */
  .panel-switch { display: none !important; }

  .mobile-panel-btn {
    display: inline-block;
    position: fixed;
    top: 14px;
    right: 14px;
    z-index: 30;
    font-family: var(--sans);
    font-weight: 400;
    font-size: 0.82rem;
    letter-spacing: 0.14em;
    color: var(--text);
    background: rgba(12, 17, 28, 0.72);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.35);
    border-radius: 999px;
    padding: 0.55em 1.1em;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.5);
    cursor: pointer;
  }
  body.m-open .mobile-panel-btn { display: none; }

  body.m-open .panel-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 15;
    background: rgba(3, 5, 10, 0.85);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
  }

  body.m-open .save-settings-btn {
    display: block;
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    z-index: 22;
    font-family: var(--sans);
    font-weight: 400;
    font-size: 0.98rem;
    letter-spacing: 0.32em;
    text-indent: 0.32em;
    color: rgba(240, 246, 255, 1);
    background: rgba(120, 160, 225, 0.32);
    border: 1px solid var(--accent);
    border-radius: 12px;
    padding: 0.95em;
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.5), 0 0 18px rgba(120, 160, 230, 0.25);
    cursor: pointer;
  }
}

/* ---------- キャンバス上の情報 ---------- */
.sky-info {
  position: fixed;
  bottom: 26px;
  left: 28px;
  z-index: 10;
  font-size: 0.8rem;
  font-weight: 300;
  line-height: 1.9;
  letter-spacing: 0.1em;
  color: var(--text-soft);
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.9);
  pointer-events: none;
  white-space: pre-line;
}
.sky-hint {
  position: fixed;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  font-size: 0.66rem;
  letter-spacing: 0.2em;
  color: var(--text-faint);
  pointer-events: none;
  white-space: nowrap;
}
.credit {
  position: fixed;
  bottom: 16px;
  right: 22px;
  z-index: 10;
  font-size: 0.6rem;
  letter-spacing: 0.06em;
  color: rgba(190, 205, 225, 0.28);
  pointer-events: none;
}

.star-tooltip {
  position: fixed;
  pointer-events: none;
  background: rgba(8, 12, 20, 0.82);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: var(--text);
  font-size: 0.84rem;
  font-weight: 300;
  letter-spacing: 0.12em;
  padding: 0.4em 0.85em;
  border-radius: 8px;
  white-space: nowrap;
  z-index: 60;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
}
.star-tooltip .tt-sub {
  display: block;
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  color: var(--text-soft);
}

/* ---------- 星座物語パネル ---------- */
.myth-panel {
  position: fixed;
  inset: 0;
  background: rgba(2, 4, 9, 0.6);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 1.2rem;
}
.myth-panel[hidden] { display: none; }
.myth-panel-inner {
  position: relative;
  width: min(640px, 94vw);
  max-height: 82vh;
  overflow-y: auto;
  background: rgba(10, 15, 26, 0.88);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 16px;
  padding: 2.4rem 2.6rem 2.5rem;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
}
.myth-panel-inner::-webkit-scrollbar { width: 6px; }
.myth-panel-inner::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 3px;
}
.myth-close {
  position: absolute;
  top: 1rem;
  right: 1.2rem;
  background: none;
  border: none;
  font-size: 1.05rem;
  color: var(--text-faint);
  cursor: pointer;
  transition: color 0.2s;
}
.myth-close:hover { color: var(--text); }
#myth-title {
  font-family: var(--serif);
  text-align: center;
  font-size: 1.4rem;
  font-weight: 400;
  letter-spacing: 0.4em;
  text-indent: 0.4em;
  color: rgba(240, 245, 252, 0.95);
  padding-bottom: 0.7rem;
  margin-bottom: 1.1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}
.myth-body {
  font-family: var(--serif);
  font-size: 0.94rem;
  line-height: 2.15;
  color: rgba(222, 230, 242, 0.88);
}
.myth-body .myth-en {
  display: block;
  text-align: center;
  font-style: italic;
  font-size: 0.95rem;
  letter-spacing: 0.14em;
  color: var(--text-faint);
  margin-bottom: 1.2rem;
}
.myth-body p { margin-bottom: 1.1em; text-align: justify; }

/* ---------- レスポンシブ（スマートフォン縦持ち） ---------- */
@media (max-width: 720px) {
  .sky-hint, .credit { display: none; }
  /* ウィンドウは左右いっぱいに広げて縦に積む（left/right は JS が指定） */
  .float-win { width: auto; }
  .win-body { padding: 0.65rem 0.75rem; }
  input[type="datetime-local"] { flex: 1; min-width: 0; }
  input[type="text"] { flex: 1; min-width: 0; width: auto; }
  .location-label { max-width: none; }
  .title-plaque h1 {
    font-size: 1.7rem;
    letter-spacing: 0.45em;
  }
  .sky-info { font-size: 0.7rem; bottom: 14px; left: 14px; line-height: 1.8; }
  .myth-panel { padding: 0.8rem; }
  .myth-panel-inner { padding: 1.6rem 1.3rem; max-height: 86vh; }
  .myth-body { font-size: 0.9rem; line-height: 2; }
  #myth-title { font-size: 1.15rem; }
}
