/* ===== Reset (간단) ===== */
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 10px;
  background: #121212;         /* dark background */
  color: #e6e6e6;               /* light text */
  font: 16px/1.55 system-ui,-apple-system,Segoe UI,Roboto,Inter,Arial,sans-serif;
}

/* ===== Tooltip ===== */
#tooltip {
  position: fixed;
  background: rgba(20, 20, 20, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  padding: 12px 14px;
  font-size: 12px;
  color: #e8e8e8;
  pointer-events: none;
  z-index: 10200;
  opacity: 0;
  transition: opacity 0.15s;
  max-width: 280px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.6);
  display: block;
  visibility: visible;
  line-height: 1.4;
}

/* style.css: 프로젝트 질문 스타일 추가 */

/* ===== Project Question (core) ===== */
.project-question {
  grid-column: 1 / span 2;
  margin: 8px 0 12px 0;
  padding: 0;
  background: none;
  border-left: none;
  border-radius: 0;
}

.project-question .question {
  margin: 0 0 8px 0;
  font-size: 16px;
  line-height: 1.35;
  color: #e8e8e8;
  letter-spacing: 0.2px;
}

.project-question .question strong {
  color: #ffffff;
  font-weight: 600;
}

.project-question .purpose {
  margin: 0;
  font-size: 14px;
  line-height: 1.6;
  color: #b8c0cc;
}

.project-question .purpose em {
  color: #4a9eff;
  font-style: normal;
  font-weight: 500;
}

/* ===== Header / Top UI ===== */
.page-head {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: flex-start;
  margin-bottom: 8px;
  padding-left: 12px;
  padding-top: 12px;
}

.header-top {
  display: flex;
  align-items: center;
  gap: 16px;
  width: 100%;
  justify-content: space-between;
}

.page-head h1 {
  margin: 0;
  font-size: 28px;
  font-weight: 700;
  line-height: 1.08;
  letter-spacing: 0.12px;
  margin-bottom: 0;
  gap: 6px;
  display: flex;
  flex-direction: column;
  flex: 1;
}

.toggle-country-btn {
  padding: 6px 12px;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 4px;
  color: #ffffff;
  font-size: 12px;
  font-weight: 400;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
  height: 32px;
  display: flex;
  align-items: center;
  margin-top: 0;
}

.toggle-country-btn:hover {
  background: rgba(122, 156, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.4);
}

.toggle-country-btn.active {
  background: rgba(122, 156, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.5);
  color: #ffffff;
}

.page-head .subtitle {
  margin: 0;
  color: #b8c0cc;
  font-size: 13px;
  line-height: 1.35;
}

/* ===== Sentiment Legend ===== */
.legend {
  display: flex;
  align-items: center;
  gap: 12px;
  color: #ddd;
  font-size: 14px;
}

.legend .lbl { 
  font-size: 14px; 
  color: #d9d9d9; 
  font-weight: 500;
}

.sentiment-scale {
  display: flex;
  gap: 16px;
  align-items: center;
}

.scale-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: #cfcfcf;
}

.color-box {
  width: 22px;
  height: 14px;
  border-radius: 3px;
  border: 1px solid #2a2a2a;
  display: inline-block;
}

.color-box.neg { background: #d73027; }
.color-box.neu { background: #9aa0a6; }
.color-box.pos { background: #1a9850; }

.legend .note { 
  font-size: 12px; 
  color: #8a8e93; 
  margin-left: 4px;
  font-style: italic;
}

/* ===== Controls ===== */
.controls {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: #d6d6d6;
}

/* ===== Explain ===== */
.explain { 
  margin: 0 0 20px 0; 
  color: #b1b6bd; 
  font-size: 14px;
  line-height: 1.6;
}

.explain .sub {
  margin: 0 0 10px 0;
}

.explain .sub:last-child {
  margin-bottom: 0;
}

.explain .sub strong {
  color: #d6d6d6;
  font-weight: 600;
}

/* ===== Source ===== */
.source { 
  margin-top: 24px; 
  margin-bottom: 12px;
  color: #7a7e83; 
  font-size: 13px;
}

.source strong {
  color: #9a9a9a;
  font-weight: 600;
}

/* ===== Chart Area ===== */
/* two-column layout: chart + right panel */
.content { display: flex; gap: 18px; align-items: flex-start; }

#chart{
  flex: 1 1 auto;
  display: block;
  overflow: auto;
  /* reduce chart height so footer and header remain visible in one viewport */
  height: auto;
  width: auto;
  border: 1px solid #242424;
  border-radius: 12px;
  padding: 6px;
  background: #0e0e0e;
}
#chart svg { display: block; overflow: visible; }

/* Country chart container - same styling as franchise chart */
#country-chart-container {
  flex: 1 1 auto;
  display: block;
  overflow: auto;
  height: auto;
  width: auto;
  border: 1px solid #242424;
  border-radius: 12px;
  padding: 6px;
  background: #0e0e0e;
}
#country-chart-container svg { display: block; overflow: visible; }

/* Highlight selected season bar */
#chart svg rect.season-selected {
  stroke: rgba(255, 255, 255, 0.425);
  stroke-width: 3px;
  /* lift the selected bar slightly and add a soft outer glow for contrast */
  transform-origin: center;
  filter: drop-shadow(0px 10px 26px rgba(0,0,0,0.65)) drop-shadow(0px 0px 10px rgba(255,255,255,0.04));
  transition: transform 160ms ease, stroke-width 160ms ease, filter 200ms ease;
}

/* If the bar is very light (near neutral color), make stroke a subtle dark outline instead for contrast */
#chart svg rect.season-selected[fill="#9aa0a6"] {
  stroke: rgba(0,0,0,0.45);
}

/* ===== Tooltip ===== */
.tooltip{
  position: fixed;
  pointer-events: none;
  background: #0f0f0f;
  color: #eee;
  padding: 8px 10px;
  border: 1px solid #2a2a2a;
  border-radius: 8px;
  font-size: 12px;
  line-height: 1.4;
  box-shadow: 0 4px 14px rgba(0,0,0,0.35);
  z-index: 9999;
  display: none;
  opacity: 0;
  white-space: nowrap;
  transition: opacity 0.1s ease;
}

/* ===== Right-side Panel (Episode summaries + Legend) ===== */
#episode-wall{
  /* keep the panel inside the content flow and stick it while scrolling the chart */
  position: sticky;
  align-self: flex-start;
  top: 86px;
  width: 300px;
  /* fix panel height and allow internal scrolling */
  height: auto;
  overflow-y: auto;
  padding: 14px 16px;
  background: linear-gradient(180deg, #0f0f0f, #0b0b0b);
  border: 1px solid #232323;
  border-radius: 10px;
  font-size: 13px;
  line-height: 1.45;
  color: #e3e3e3;
  display: block;
}

#episode-wall .panel-head h2 { margin: 0 0 6px 0; font-size: 16px; }
#episode-wall .panel-note { margin: 8px 0 12px 0; color:#9a9a9a; font-size:13px; line-height:1.4 }
#episode-wall .panel-note { margin: 0 0 12px 0; color:#9a9a9a; font-size:12px }
#episode-wall .panel-section { margin-bottom: 12px; }
#episode-wall .sentiment-legend { display:flex; flex-direction:column; gap:8px; margin-top:8px }
.legend-row { display:flex; align-items:center; gap:8px; color:#cfcfcf }
.sw { width:18px; height:12px; display:inline-block; border-radius:3px; border:1px solid rgba(0,0,0,0.4) }
.sw-neg { background:#d73027 }
.sw-neu { background:#9aa0a6 }
.sw-pos { background:#1a9850 }
.snip-instructions { color:#9a9a9a; font-size:13px; }

/* Word highlights (snippet)
  Simplified, flat highlight chips for better readability and less visual noise.
  Consolidated definitions to avoid duplicate/contradictory rules. */
.hi-pos {
  background: #1a9850; /* flat muted green */
  color: #f0fff4; /* light text for contrast */
  padding: 0 4px; border-radius: 3px; font-weight: 600; letter-spacing: 0.02em;
}

.hi-neg {
  background: #d73027;
  color: #fff6f6; /* light text for contrast */
  padding: 0 4px; border-radius: 3px; font-weight: 600; letter-spacing: 0.02em;
}

/* keep a minimal soft emphasis option */
.hi-soft{ background: rgba(255,255,255,0.03); padding:0 2px; border-radius:2px; color:inherit }

/* ===== Axis text color adjustments (in case theme overrides) ===== */
.axis text { fill: #e6e6e6; }

/* Pure-CSS spacing for axis labels (no JS measurement required) */
#chart svg { --label-gap: 10px; }
/* Tick label positioning is handled in JS to ensure reliable two-line wrapping
   across browsers and avoid transform-related clipping issues. */
/* Reintroduce transform-based label offset to address glyph/spacing oddities seen
   with explicit x-setting in some system fonts. */
/* Tick label offset: handled in JS for deterministic layout. Removed
  the previous transform-based offsets so JS `x`/`tspan` positioning
  determines alignment. */

/* ===== Season popup (inline drill-down) ===== */
.season-popup {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Inter, Arial, sans-serif;
  background: linear-gradient(180deg, #0d0d0d, #080808);
  color: #e6e6e6;
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 8px;
  box-shadow: 0 10px 36px rgba(0,0,0,0.6);
  padding: 14px;
  z-index: 9999;
  /* larger default size to reduce off-screen positioning issues */
  width: min(900px, calc(100vw - 48px));
  min-width: 420px;
  max-width: 95vw;
  max-height: 72vh;
}
.season-popup { pointer-events: auto !important; }
.season-popup button, .season-popup a, .season-popup .season-popup-overview { pointer-events: auto; }
.season-popup .overview-body { color: #dcdcdc; line-height: 1.5; font-size: 13px; }
.season-popup button { background: transparent; color: #e6e6e6; border: 1px solid rgba(255,255,255,0.06); padding: 6px 8px; border-radius:4px; cursor:pointer; transition: background-color 160ms ease, color 160ms ease, transform 120ms ease, box-shadow 160ms ease; }
.season-popup button:hover { background: rgba(255,255,255,0.03); transform: translateY(-1px); }
.season-popup button:focus { outline: 3px solid rgba(122,156,255,0.18); outline-offset: 2px; }
.season-popup .season-popup-overview { margin-top:8px; padding-top:8px; border-top:1px solid rgba(255,255,255,0.03); }
.season-popup .season-popup-overview .overview-body .hi-neg { background: rgba(200,60,60,0.22); color:#fff6f6; padding:0 4px; border-radius:3px; font-weight:600 }
.season-popup .season-popup-overview .overview-body .hi-pos { background: rgba(46,139,87,0.22); color:#f0fff4; padding:0 4px; border-radius:3px; font-weight:600 }

/* Make popup responsive on narrow viewports */
@media (max-width: 880px){
  .season-popup { left: 8px !important; right: 8px !important; min-width: auto; max-width: calc(100vw - 16px); width: calc(100vw - 16px); }
  .season-popup button { font-size: 12px; padding: 6px 6px; }
}

/* Prepare right panel as a metadata/description area (visual de-emphasis of snippets)
  We'll keep the panel but make snippet area subtle while we migrate interaction into popups. */
#episode-wall { width: 300px; }
#episode-wall #panel-snippets { opacity: 0.95; font-size:13px; color:#bdbdbd; }
#episode-wall .panel-section#panel-snippets { background: transparent; border-top: 1px dashed rgba(255,255,255,0.03); padding-top:8px }

/* ===== Center modal overlay (Netflix/YouTube style) ===== */
.season-overlay {
  position: fixed;
  left: 0; top: 0; width: 100%; height: 100%;
  display: none;
  align-items: center; justify-content: center;
  background: rgba(0,0,0,0.55); /* backdrop dimming */
  z-index: 10050;
}
.season-overlay.active { display: flex; }
.season-modal {
  background: linear-gradient(180deg,#0b0b0b,#080808);
  border: 1px solid rgba(255,255,255,0.06);
  color: #e6e6e6;
  border-radius: 12px;
  padding: 18px;
  width: min(1100px, calc(100% - 96px));
  max-height: calc(100vh - 120px);
  overflow: auto;
  box-shadow: 0 30px 80px rgba(0,0,0,0.7);
  z-index: 10100;
}
.season-modal .modal-head { display:flex; align-items:center; justify-content:space-between; gap:12px; margin-bottom:12px }
.season-modal .modal-title { font-weight:700; font-size:18px }
.season-modal .modal-close { background:transparent; border:0; color:#cfcfcf; font-size:16px; cursor:pointer; padding:6px 8px; border-radius:6px }
.season-modal .modal-close:hover { background:rgba(255,255,255,0.02) }
.season-modal .ep-row { display:flex; flex-wrap:wrap; gap:8px; margin-bottom:12px }
.season-modal .ep-pill { border:1px solid rgba(255,255,255,0.06); padding:8px 10px; border-radius:8px; background:rgba(255,255,255,0.01); cursor:pointer; font-size:13px }
.season-modal .ep-pill { color: #e6e6e6; transition: background-color 160ms ease, color 160ms ease, transform 140ms ease, box-shadow 160ms ease; }
.season-modal .ep-pill:hover { background:rgba(255,255,255,0.02); transform: translateY(-1px); }
.season-modal .ep-pill:focus { outline: 3px solid rgba(255,255,255,0.12); outline-offset: 2px; }
.season-modal .ep-pill span { color: #e6e6e6; display:inline-block; vertical-align:middle }
.season-modal .ep-pill.selected { border-color: #fff !important; box-shadow: 0 6px 20px rgba(0,0,0,0.6), 0 0 0 6px rgba(255,255,255,0.03); background: rgba(255,255,255,0.03); }

/* If pills are colored inline (JS sets background), soften border and add subtle inset to improve legibility */
.season-modal .ep-pill[style] { border: 1px solid rgba(255,255,255,0.06); box-shadow: inset 0 -2px 0 rgba(0,0,0,0.18); }

/* Ensure season-popup chips get same focus styles */
.season-popup button:focus { outline: 3px solid rgba(255,255,255,0.12); outline-offset: 2px; }
.season-modal .ep-overview { color:#dcdcdc; line-height:1.5; font-size:14px }

@media (max-width: 720px){
  .season-modal { width: calc(100% - 32px); padding: 12px }
  .season-modal .modal-title { font-size:16px }
}


footer {
  margin-top: 12px;
  margin-left: 12px;
  margin-bottom: 18px;
  font-size: 18px;
  color: #7a7e83;
  
}

.footer-note { font-size:13px; color:#8f9498; margin-top:8px }

/* === Force unified highlight colors across popup + panel === */
.hi-pos,
.season-popup .overview-body .hi-pos {
  background: #34c759 !important; /* bright green */
  color: #0b0b0b !important;
  padding: 2px 6px !important;
  border-radius: 4px !important;
  font-weight: 600 !important;
}

.hi-neg,
.season-popup .overview-body .hi-neg {
  background: #ff453a !important; /* bright red */
  color: #fff !important;
  padding: 2px 6px !important;
  border-radius: 4px !important;
  font-weight: 600 !important;
}

.hi-soft,
.season-popup .overview-body .hi-soft {
  background: rgba(255,255,255,0.10) !important;
  color: #fff !important;
  padding: 1px 4px !important;
  border-radius: 3px !important;
}


