/* Odysseia — bronze-age parchment over the wine-dark sea */

:root {
  --gold: #e8c26a;
  --gold-dim: rgba(232, 194, 106, 0.4);
  --parchment: #efe3c8;
  --ink: #0a0f1c;
  --panel: rgba(10, 15, 28, 0.86);
  --panel-edge: rgba(232, 194, 106, 0.22);
  --text: #d8d4c8;
  --text-dim: #9a97a8;
  --serif: 'Cormorant Garamond', Georgia, serif;
  --display: 'Cinzel', 'Times New Roman', serif;
}

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

html, body, #app {
  width: 100%; height: 100%;
  overflow: hidden;
  background: #0a0f1c;
  font-family: var(--serif);
  color: var(--text);
}

#gl { position: absolute; inset: 0; width: 100%; height: 100%; display: block; cursor: grab; }
#gl:active { cursor: grabbing; }

.hidden { display: none !important; }

button { font-family: inherit; cursor: pointer; }

/* ---------- veil ---------- */
#veil {
  position: absolute; inset: 0; z-index: 60;
  background: radial-gradient(ellipse at 50% 60%, #14203a 0%, #0a0f1c 70%);
  display: flex; align-items: center; justify-content: center;
  transition: opacity 1.2s ease;
}
#veil.fading { opacity: 0; pointer-events: none; }
.veil-inner { text-align: center; }
.veil-kicker {
  font-family: var(--serif); font-style: italic; font-size: 18px; color: var(--text-dim);
  margin-bottom: 18px; letter-spacing: 0.04em;
}
.veil-title {
  font-family: var(--display); font-size: clamp(42px, 8vw, 92px); font-weight: 700;
  color: var(--gold); letter-spacing: 0.18em; text-shadow: 0 0 60px rgba(232, 194, 106, 0.35);
}
.veil-sub { margin-top: 16px; font-size: 17px; font-style: italic; color: var(--text-dim); }

/* ---------- intro ---------- */
#intro {
  position: absolute; inset: 0; z-index: 55;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at 50% 55%, rgba(10, 15, 28, 0.25) 0%, rgba(10, 15, 28, 0.78) 100%);
  animation: fadeIn 0.9s ease;
}
.intro-card { text-align: center; max-width: 640px; padding: 32px; }
.intro-kicker { font-family: var(--display); font-size: 12px; letter-spacing: 0.32em; color: var(--text-dim); }
.intro-title {
  font-family: var(--display); font-size: clamp(38px, 6vw, 68px); color: var(--gold);
  letter-spacing: 0.08em; margin: 14px 0 12px;
  text-shadow: 0 0 50px rgba(232, 194, 106, 0.3);
}
.intro-text { font-size: 20px; font-style: italic; color: var(--parchment); margin-bottom: 30px; }
.intro-choices { display: flex; flex-direction: column; gap: 12px; }
.intro-btn {
  display: flex; flex-direction: column; gap: 3px;
  padding: 14px 22px;
  background: var(--panel); border: 1px solid var(--panel-edge); border-radius: 4px;
  color: var(--text); text-align: left;
  transition: border-color 0.25s, background 0.25s, transform 0.25s;
}
.intro-btn:hover {
  border-color: var(--gold); background: rgba(30, 38, 58, 0.9);
  transform: translateX(4px);
}
.intro-btn-title { font-family: var(--display); font-size: 15px; letter-spacing: 0.12em; color: var(--gold); }
.intro-btn-sub { font-size: 16px; font-style: italic; color: var(--text-dim); }
.intro-hint { margin-top: 24px; font-size: 14px; letter-spacing: 0.06em; color: var(--text-dim); font-style: italic; }

/* ---------- top bar ---------- */
#topbar {
  position: absolute; top: 0; left: 0; right: 0; z-index: 40;
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 18px;
  background: linear-gradient(to bottom, rgba(10, 15, 28, 0.9), rgba(10, 15, 28, 0));
}
#brand {
  font-family: var(--display); font-size: 15px; letter-spacing: 0.22em; color: var(--gold);
  white-space: nowrap;
}
.brand-mark { opacity: 0.7; }
#modes { display: flex; gap: 4px; flex-wrap: wrap; justify-content: center; }
.mode-btn {
  padding: 7px 14px;
  background: transparent; border: 1px solid transparent; border-radius: 3px;
  color: var(--text-dim); font-family: var(--display); font-size: 11.5px; letter-spacing: 0.1em;
  transition: all 0.25s;
}
.mode-btn:hover { color: var(--parchment); border-color: var(--panel-edge); }
.mode-btn.active {
  color: var(--gold); border-color: var(--gold-dim);
  background: rgba(232, 194, 106, 0.07);
}
#top-actions { display: flex; gap: 6px; }
.icon-btn {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--panel); border: 1px solid var(--panel-edge);
  color: var(--gold); font-size: 15px;
  transition: all 0.25s;
}
.icon-btn:hover { border-color: var(--gold); }
.icon-btn.muted { color: var(--text-dim); text-decoration: line-through; }

/* ---------- thread filter ---------- */
#thread-filter {
  position: absolute; top: 52px; left: 50%; transform: translateX(-50%); z-index: 39;
  display: flex; gap: 6px; flex-wrap: wrap; justify-content: center;
  max-width: 90vw;
}
.thread-chip {
  padding: 4px 11px; border-radius: 20px; font-size: 13.5px;
  background: var(--panel); border: 1px solid var(--panel-edge); color: var(--text-dim);
  transition: all 0.2s;
}
.thread-chip .dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; }
.thread-chip:hover, .thread-chip.active { color: var(--parchment); border-color: var(--gold-dim); }
.thread-chip.active { background: rgba(232, 194, 106, 0.1); }

/* ---------- breadcrumb ---------- */
#breadcrumb {
  position: absolute; top: 54px; left: 18px; z-index: 38;
  font-family: var(--display); font-size: 12px; letter-spacing: 0.1em;
  color: var(--text-dim);
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
#breadcrumb .crumb { cursor: pointer; transition: color 0.2s; }
#breadcrumb .crumb:hover { color: var(--gold); }
#breadcrumb .crumb.current { color: var(--gold); }
#breadcrumb .sep { opacity: 0.4; }
#breadcrumb .band-tag {
  font-size: 10px; padding: 2px 8px; border: 1px solid var(--panel-edge);
  border-radius: 20px; color: var(--text-dim); letter-spacing: 0.16em;
}

/* ---------- teaser ---------- */
#teaser {
  position: absolute; top: 88px; left: 50%; transform: translateX(-50%); z-index: 37;
  text-align: center; pointer-events: none;
  animation: teaserIn 0.8s ease;
}
@keyframes teaserIn { from { opacity: 0; transform: translate(-50%, -12px); } to { opacity: 1; transform: translate(-50%, 0); } }
.teaser-title {
  font-family: var(--display); font-size: clamp(26px, 4vw, 44px); color: var(--parchment);
  letter-spacing: 0.1em; text-shadow: 0 2px 30px rgba(10, 15, 28, 0.9);
}
.teaser-sub {
  font-size: 17px; font-style: italic; color: var(--gold); margin-top: 4px;
  text-shadow: 0 2px 20px rgba(10, 15, 28, 0.9);
}

/* ---------- panels ---------- */
.panel {
  position: absolute; top: 0; bottom: 0; z-index: 42;
  width: min(430px, 92vw);
  background: var(--panel);
  backdrop-filter: blur(14px);
  border-right: 1px solid var(--panel-edge);
  display: flex; flex-direction: column;
  animation: panelIn 0.45s cubic-bezier(0.2, 0.9, 0.25, 1);
}
#episode-panel { left: 0; }
#char-panel { right: 0; border-right: none; border-left: 1px solid var(--panel-edge); }
@keyframes panelIn { from { opacity: 0; transform: translateX(-30px); } to { opacity: 1; transform: none; } }
#char-panel { animation-name: panelInR; }
@keyframes panelInR { from { opacity: 0; transform: translateX(30px); } to { opacity: 1; transform: none; } }
.panel-close {
  position: absolute; top: 10px; right: 12px; z-index: 2;
  width: 30px; height: 30px; border-radius: 50%;
  background: transparent; border: 1px solid var(--panel-edge);
  color: var(--text-dim); font-size: 17px;
}
.panel-close:hover { color: var(--gold); border-color: var(--gold); }
.panel-content { overflow-y: auto; padding: 26px 26px 60px; scrollbar-width: thin; scrollbar-color: var(--gold-dim) transparent; }
.panel-content::-webkit-scrollbar { width: 5px; }
.panel-content::-webkit-scrollbar-thumb { background: var(--gold-dim); border-radius: 3px; }

.ep-kicker { font-family: var(--display); font-size: 10.5px; letter-spacing: 0.28em; color: var(--text-dim); margin-bottom: 10px; }
.ep-title { font-family: var(--display); font-size: 30px; color: var(--gold); letter-spacing: 0.06em; line-height: 1.15; }
.ep-subtitle { font-size: 18px; font-style: italic; color: var(--parchment); margin: 6px 0 4px; }
.ep-books { font-size: 13.5px; font-style: italic; color: var(--text-dim); margin-bottom: 16px; }
.ep-section-label {
  font-family: var(--display); font-size: 10px; letter-spacing: 0.26em; color: var(--gold);
  margin: 22px 0 8px; padding-top: 14px; border-top: 1px solid var(--panel-edge);
}
.ep-text { font-size: 16.5px; line-height: 1.55; color: var(--text); margin-bottom: 12px; }
.ep-text em { color: var(--parchment); }

.moment-item {
  padding: 10px 12px; margin-bottom: 8px;
  border: 1px solid var(--panel-edge); border-radius: 4px;
  cursor: pointer; transition: all 0.2s;
  background: rgba(232, 194, 106, 0.03);
}
.moment-item:hover { border-color: var(--gold-dim); background: rgba(232, 194, 106, 0.08); }
.moment-item-title { font-family: var(--display); font-size: 12.5px; letter-spacing: 0.06em; color: var(--gold); margin-bottom: 3px; }
.moment-item-text { font-size: 14.5px; line-height: 1.45; color: var(--text-dim); }

.chip-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.char-chip {
  padding: 5px 11px; border-radius: 20px; font-size: 14px;
  background: rgba(232, 194, 106, 0.06); border: 1px solid var(--panel-edge);
  color: var(--parchment); transition: all 0.2s;
}
.char-chip:hover { border-color: var(--gold); background: rgba(232, 194, 106, 0.14); }
.char-chip .chip-kind { font-size: 11px; color: var(--text-dim); margin-left: 5px; font-style: italic; }

/* ---------- character panel ---------- */
.char-head { display: flex; align-items: center; gap: 14px; margin-bottom: 6px; }
.char-medal {
  width: 54px; height: 54px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--display); font-size: 24px; color: var(--ink);
  border: 2px solid var(--gold-dim);
}
.char-name { font-family: var(--display); font-size: 25px; color: var(--gold); letter-spacing: 0.05em; line-height: 1.1; }
.char-epithet { font-size: 15.5px; font-style: italic; color: var(--parchment); }
.char-kindline { font-size: 13px; color: var(--text-dim); font-style: italic; margin-bottom: 4px; }
.char-role { font-size: 16px; line-height: 1.5; color: var(--parchment); margin: 12px 0; padding: 10px 12px; border-left: 2px solid var(--gold-dim); background: rgba(232, 194, 106, 0.05); }
.char-voice {
  font-size: 17px; line-height: 1.6; font-style: italic; color: var(--parchment);
  padding: 14px; border: 1px solid var(--panel-edge); border-radius: 4px;
  background: rgba(20, 28, 46, 0.5);
}
.char-voice::before { content: '“'; color: var(--gold); font-size: 26px; line-height: 0; margin-right: 2px; }
.char-voice::after { content: '”'; color: var(--gold); font-size: 26px; line-height: 0; margin-left: 2px; }

.rel-item {
  display: block; width: 100%; text-align: left;
  padding: 9px 12px; margin-bottom: 7px;
  border: 1px solid var(--panel-edge); border-radius: 4px;
  background: transparent; transition: all 0.2s;
}
.rel-item:hover { border-color: var(--rel-color, var(--gold)); background: rgba(255, 255, 255, 0.04); }
.rel-item-top { display: flex; align-items: center; gap: 8px; }
.rel-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; box-shadow: 0 0 8px currentColor; }
.rel-name { font-family: var(--display); font-size: 13px; color: var(--parchment); letter-spacing: 0.04em; }
.rel-label { font-size: 13px; font-style: italic; color: var(--rel-color, var(--gold)); margin-left: auto; }
.rel-note { font-size: 13.5px; line-height: 1.4; color: var(--text-dim); margin-top: 4px; }
.rel-go { font-size: 12px; color: var(--gold); letter-spacing: 0.08em; margin-top: 4px; font-family: var(--display); }

/* ---------- moment modal ---------- */
#moment-modal {
  position: absolute; inset: 0; z-index: 50;
  display: flex; align-items: center; justify-content: center;
  background: rgba(6, 9, 16, 0.55); backdrop-filter: blur(3px);
  animation: fadeIn 0.35s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.moment-card {
  position: relative; max-width: 560px; width: 92vw; max-height: 80vh; overflow-y: auto;
  background: var(--panel); border: 1px solid var(--panel-edge); border-radius: 6px;
  padding: 34px 34px 30px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5);
}
.moment-episode { font-family: var(--display); font-size: 10.5px; letter-spacing: 0.28em; color: var(--text-dim); margin-bottom: 12px; }
.moment-title { font-family: var(--display); font-size: 26px; color: var(--gold); letter-spacing: 0.04em; margin-bottom: 14px; }
.moment-text { font-size: 18px; line-height: 1.6; color: var(--text); }
.moment-quote {
  margin-top: 20px; padding: 16px 18px;
  border-left: 2px solid var(--gold); background: rgba(232, 194, 106, 0.06);
  font-size: 19px; line-height: 1.55; font-style: italic; color: var(--parchment);
}
.moment-src { margin-top: 8px; font-size: 13px; font-style: normal; color: var(--gold); font-family: var(--display); letter-spacing: 0.1em; }

/* ---------- cast drawer ---------- */
#cast-drawer {
  position: absolute; top: 0; right: 0; bottom: 0; z-index: 44;
  width: min(560px, 96vw);
  background: rgba(8, 12, 22, 0.94); backdrop-filter: blur(16px);
  border-left: 1px solid var(--panel-edge);
  display: flex; flex-direction: column;
  animation: panelInR 0.4s cubic-bezier(0.2, 0.9, 0.25, 1);
}
.cast-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 22px; border-bottom: 1px solid var(--panel-edge);
  font-family: var(--display); font-size: 15px; letter-spacing: 0.16em; color: var(--gold);
}
.cast-grid {
  flex: 1; overflow-y: auto; padding: 18px 22px;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px;
  scrollbar-width: thin;
}
.cast-card {
  padding: 12px; border: 1px solid var(--panel-edge); border-radius: 4px;
  background: rgba(20, 28, 46, 0.4); cursor: pointer; transition: all 0.2s;
}
.cast-card:hover { border-color: var(--gold); transform: translateY(-2px); }
.cast-card-name { font-family: var(--display); font-size: 13.5px; color: var(--gold); letter-spacing: 0.04em; }
.cast-card-epithet { font-size: 12.5px; font-style: italic; color: var(--text-dim); margin-top: 3px; line-height: 1.3; }
.cast-card-kind { font-size: 10.5px; letter-spacing: 0.14em; color: var(--text-dim); margin-top: 6px; font-family: var(--display); }

/* ---------- tooltip ---------- */
#tooltip {
  position: absolute; z-index: 48; pointer-events: none;
  padding: 6px 12px; border-radius: 3px;
  background: rgba(8, 12, 22, 0.92); border: 1px solid var(--panel-edge);
  font-size: 14.5px; color: var(--parchment);
  transform: translate(-50%, calc(-100% - 14px));
  white-space: nowrap;
}
#tooltip .tt-kind { color: var(--gold); font-size: 12px; font-style: italic; margin-left: 6px; }

/* ---------- tour controls ---------- */
#tour-controls {
  position: absolute; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 41;
  display: flex; align-items: center; gap: 10px;
  background: var(--panel); border: 1px solid var(--panel-edge); border-radius: 40px;
  padding: 8px 12px;
  backdrop-filter: blur(12px);
}
.tour-btn {
  width: 38px; height: 38px; border-radius: 50%;
  background: transparent; border: 1px solid var(--panel-edge);
  color: var(--gold); font-size: 19px; transition: all 0.2s;
}
.tour-btn:hover { border-color: var(--gold); background: rgba(232, 194, 106, 0.1); }
.tour-btn:disabled { opacity: 0.3; cursor: default; }
.tour-exit { font-size: 13px; color: var(--text-dim); }
#tour-status { text-align: center; min-width: 200px; max-width: 46vw; }
#tour-kicker { font-size: 10.5px; letter-spacing: 0.24em; color: var(--text-dim); font-family: var(--display); }
#tour-title { font-size: 16.5px; color: var(--parchment); font-family: var(--display); letter-spacing: 0.04em; margin-top: 2px; }

#narration-banner {
  position: absolute; top: 74px; left: 50%; transform: translateX(-50%); z-index: 40;
  padding: 8px 22px; border-radius: 30px;
  background: rgba(90, 74, 142, 0.2); border: 1px solid rgba(167, 139, 250, 0.4);
  backdrop-filter: blur(8px);
  animation: teaserIn 0.8s ease;
}
.narration-quote { font-size: 15.5px; font-style: italic; color: #c8bcf0; }

/* ---------- timeline ---------- */
#timeline { position: absolute; bottom: 0; left: 0; right: 0; z-index: 39; pointer-events: none; }
#timeline-toggle {
  pointer-events: auto;
  position: absolute; bottom: 0; left: 50%; transform: translateX(-50%);
  z-index: 3;
  padding: 7px 26px;
  background: var(--panel); border: 1px solid var(--panel-edge); border-bottom: none;
  border-radius: 6px 6px 0 0;
  color: var(--text-dim); font-family: var(--display); font-size: 10.5px; letter-spacing: 0.22em;
  transition: color 0.2s;
}
#timeline-toggle:hover { color: var(--gold); }
#timeline-toggle .tl-arrow { display: inline-block; transition: transform 0.3s; }
#timeline-toggle.open .tl-arrow { transform: rotate(180deg); }
#timeline-body {
  pointer-events: auto;
  background: rgba(8, 12, 22, 0.92); backdrop-filter: blur(14px);
  border-top: 1px solid var(--panel-edge);
  padding: 18px 26px 12px;
}
#timeline-tracks { position: relative; }
.tl-track { position: relative; height: 46px; margin-bottom: 4px; }
.tl-track-label {
  position: absolute; left: 0; top: 50%; transform: translateY(-50%);
  font-family: var(--display); font-size: 9.5px; letter-spacing: 0.18em; color: var(--text-dim);
  width: 86px;
}
.tl-lane { position: absolute; left: 96px; right: 8px; top: 50%; height: 2px; background: rgba(216, 212, 200, 0.14); }
.tl-lane.war { background: repeating-linear-gradient(90deg, rgba(216, 212, 200, 0.1) 0 6px, transparent 6px 12px); height: 3px; }
.tl-event {
  position: absolute; top: 50%; transform: translate(-50%, -50%);
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  background: none; border: none;
}
.tl-event .tl-dot {
  width: 10px; height: 10px; border-radius: 50%;
  border: 1.5px solid var(--gold); background: var(--ink);
  transition: all 0.2s; cursor: pointer;
}
.tl-event.home-dot .tl-dot { border-color: #6ab0e8; }
.tl-event.son-dot .tl-dot { border-color: #8bc48a; }
.tl-event:hover .tl-dot, .tl-event.current .tl-dot { background: var(--gold); box-shadow: 0 0 12px var(--gold); }
.tl-event.home-dot:hover .tl-dot, .tl-event.home-dot.current .tl-dot { background: #6ab0e8; box-shadow: 0 0 12px #6ab0e8; }
.tl-event-label {
  font-size: 10.5px; color: var(--text-dim); white-space: nowrap;
  letter-spacing: 0.03em; max-width: 110px; overflow: hidden; text-overflow: ellipsis;
}
.tl-event:hover .tl-event-label { color: var(--parchment); }
.tl-year-mark { position: absolute; top: -14px; font-size: 9.5px; color: rgba(154, 151, 168, 0.6); transform: translateX(-50%); }
#timeline-legend { display: flex; align-items: center; gap: 8px; padding: 6px 0 2px 96px; font-size: 12.5px; font-style: italic; color: var(--text-dim); }
.tl-key { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-left: 14px; }
.voyage-key { border: 1.5px solid var(--gold); margin-left: 0; }
.home-key { border: 1.5px solid #6ab0e8; }

/* ---------- help ---------- */
#help-overlay {
  position: absolute; inset: 0; z-index: 52;
  display: flex; align-items: center; justify-content: center;
  background: rgba(6, 9, 16, 0.7); backdrop-filter: blur(4px);
  animation: fadeIn 0.3s ease;
}
.help-card {
  position: relative; max-width: 780px; width: 94vw; max-height: 84vh; overflow-y: auto;
  background: var(--panel); border: 1px solid var(--panel-edge); border-radius: 6px;
  padding: 34px 38px;
}
.help-card h2 { font-family: var(--display); color: var(--gold); letter-spacing: 0.08em; font-size: 24px; margin-bottom: 18px; }
.help-card h3 { font-family: var(--display); color: var(--parchment); letter-spacing: 0.1em; font-size: 13px; margin: 16px 0 6px; }
.help-card p { font-size: 15.5px; line-height: 1.55; color: var(--text-dim); }
.help-card b { color: var(--parchment); }
.help-card i { color: var(--gold); }
.help-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 28px; }

/* ---------- toast ---------- */
#toast {
  position: absolute; bottom: 90px; left: 50%; transform: translateX(-50%); z-index: 49;
  padding: 10px 24px; border-radius: 30px;
  background: var(--panel); border: 1px solid var(--gold-dim);
  font-size: 15.5px; font-style: italic; color: var(--parchment);
  animation: toastIn 0.4s ease;
  pointer-events: none; text-align: center; max-width: 88vw;
}
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 10px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ---------- responsive ---------- */
@media (max-width: 820px) {
  #modes { display: none; }
  .panel { width: 100vw; top: auto; bottom: 0; max-height: 62vh; border-right: none; border-top: 1px solid var(--panel-edge); }
  #char-panel { border-left: none; }
  #breadcrumb { top: 52px; }
  .help-cols { grid-template-columns: 1fr; }
  #tour-status { min-width: 120px; }
  #timeline-body { padding: 14px 10px 10px; }
  .tl-track-label { display: none; }
  .tl-lane { left: 10px; }
  #timeline-legend { padding-left: 10px; }
}
