/* ===================================================
   style.css — History of English Interactive Timeline
   Phase 3: Navy page bg, Lavender timeline box, Terracotta pins, Amber stars
   =================================================== */

@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:ital,wght@0,400;0,700;1,400&family=Inter:wght@300;400;500;600&display=swap');

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

:root {
  --bg: #273469;
  /* dark navy — page background     */
  --surface: #F2EEFF;
  /* bright lavender-white — timeline display */
  --accent: #C17767;
  /* terracotta — pins, active       */
  --star-color: #DEB841;
  /* amber gold — IR event stars     */
  --space: #FAFAFF;
  /* near-white                      */
  --text: #FAFAFF;
  /* text on dark page               */
  --text-dim: rgba(250, 250, 255, 0.5);
  --text-on-sfc: #1a2248;
  /* text inside light surface       */
  --text-dim-sfc: rgba(39, 52, 105, 0.5);
  --border-dark: rgba(250, 250, 255, 0.12);
  --border-sfc: rgba(39, 52, 105, 0.15);
  --radius: 10px;
  --radius-lg: 16px;
  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

html,
body {
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.6;
}

#app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  max-width: 1300px;
  margin: 0 auto;
  padding: 0 32px 60px;
}

/* ── Header ── */
.site-header {
  padding: 32px 0 20px;
  border-bottom: 1px solid var(--border-dark);
}

.site-header h1 {
  font-family: 'Playfair Display', serif;
  font-size: clamp(1.6rem, 3vw, 2.4rem);
  font-weight: 700;
  color: var(--space);
}

.site-header .subtitle {
  font-size: 0.8rem;
  color: var(--text-dim);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-top: 4px;
}

/* ── Filter Instructions ── */
.filter-instructions {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 0 12px;
  margin-left: 0;
  /* Align with "WORDS" label */
  font-size: 0.7rem;
  color: var(--text-dim);
  text-transform: none;
  font-weight: 500;
  opacity: 0.8;
}

.help-circle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  border: 1px solid var(--text-dim);
  border-radius: 50%;
  font-size: 0.6rem;
  font-weight: 700;
  line-height: 1;
}

/* ── Filter chips row ── */
.filter-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 0 12px;
}

.filter-label {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-dim);
  flex-shrink: 0;
  white-space: nowrap;
}

.filter-chips {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: var(--surface);
  color: var(--text-on-sfc);
  border: 2px solid var(--surface);
  border-radius: 20px;
  padding: 5px 14px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition), color var(--transition),
    transform var(--transition), box-shadow var(--transition);
  user-select: none;
}

.filter-chip .chip-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.filter-chip:hover {
  box-shadow: 0 2px 14px rgba(228, 217, 255, 0.25);
  transform: translateY(-1px);
}

.filter-chip.inactive {
  background: rgba(228, 217, 255, 0.1);
  color: var(--text-dim);
  border-color: rgba(228, 217, 255, 0.2);
  opacity: 0.6;
}

.filter-chip.inactive .chip-dot {
  opacity: 0.35;
}

/* ── Timeline container (light surface card) ── */
.timeline-container {
  position: relative;
  background: var(--surface);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
}

/* ── Zoom controls ── */
.zoom-controls {
  position: absolute;
  top: 10px;
  right: 12px;
  z-index: 50;
  display: flex;
  gap: 3px;
}

.zoom-btn {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  border: 1.5px solid rgba(26, 34, 72, 0.25);
  background: rgba(26, 34, 72, 0.22);
  color: #1a2248;
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition), transform var(--transition);
  user-select: none;
}

.zoom-btn:hover {
  background: rgba(26, 34, 72, 0.48);
  transform: scale(1.08);
}

/* ── Era track (Background sections) ── */
.era-track {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
  display: flex;
}

.era-box {
  position: absolute;
  height: 100%;
  border-right: 1px dashed rgba(26, 34, 72, 0.08);
  transition: background var(--transition);
}

.era-box.era-middle {
  background: #F9F7FF;
  /* Very slight purple-rose tint */
}

/* Middle English */
.era-box.era-early {
  background: #F2EEFF;
  /* Original surface lavender */
}

/* Early Modern */
.era-box.era-modern {
  background: #EEF3FF;
  /* Very slight blue tint */
}

/* Modern */

.era-label {
  position: absolute;
  top: 10px;
  left: 12px;
  font-family: 'Playfair Display', serif;
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  white-space: nowrap;
  opacity: 0.55;
  /* Refined opacity as requested */
}

/* ── Bracket track (Top markers) ── */
.bracket-track {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  pointer-events: none;
  z-index: 100;
  /* Above eras and axis */
}

.bracket-wrapper {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.bracket-label-group {
  margin-bottom: 2px;
}

.bracket-title {
  font-family: 'Playfair Display', serif;
  font-size: 0.9rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  line-height: 1.1;
}

.bracket-subtitle {
  font-family: 'Inter', sans-serif;
  font-size: 0.65rem;
  font-style: italic;
  font-weight: 500;
  opacity: 0.8;
  margin-top: 1px;
}

.bracket-svg-container {
  width: 100%;
  height: 14px;
}

.timeline-viewport {
  width: 100%;
  overflow: hidden;
  cursor: grab;
  user-select: none;
  min-height: 220px;
}

.timeline-viewport:active {
  cursor: grabbing;
}

/* ── Canvas ── */
.timeline-canvas {
  position: relative;
  will-change: transform;
}

/* ── Pin track (attestation map pins — above axis) ── */
.pin-track {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  pointer-events: none;
}

/* ── Axis ── */
.timeline-axis {
  position: absolute;
  left: 0;
  right: 0;
  height: 2px;
  background: #1a2248;
}

/* ── Year labels ── */
.year-labels {
  position: absolute;
  left: 0;
  right: 0;
  pointer-events: none;
}

.year-label {
  position: absolute;
  transform: translateX(-50%);
  font-size: 0.78rem;
  font-weight: 600;
  color: #1a2248;
  letter-spacing: 0.04em;
  white-space: nowrap;
  user-select: none;
}

.year-label.minor {
  font-size: 0.62rem;
  font-weight: 400;
  color: rgba(26, 34, 72, 0.5);
}

.year-label::before {
  content: '';
  position: absolute;
  top: -10px;
  left: 50%;
  width: 1.5px;
  height: 7px;
  background: rgba(26, 34, 72, 0.45);
}

.year-label.minor::before {
  height: 4px;
  background: rgba(26, 34, 72, 0.25);
}

/* ── Star track (IR events) ── */
.star-track {
  position: absolute;
  left: 0;
  right: 0;
  pointer-events: none;
}

/* ── Attestation map pin ── */
.att-pin {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
  pointer-events: all;
  z-index: 10;
  transition: filter var(--transition), transform var(--transition);
}

.att-pin svg {
  display: block;
  overflow: visible;
}

.att-pin:hover {
  filter: brightness(1.2);
  z-index: 20;
}

.att-pin.hidden-word {
  display: none;
}

/* ── IR event star ── */
.ir-star {
  position: absolute;
  cursor: pointer;
  pointer-events: all;
  z-index: 15;
  transition: filter var(--transition), transform var(--transition);
}

.ir-star svg {
  display: block;
  overflow: visible;
}

.ir-star:hover {
  filter: brightness(1.25);
  z-index: 25;
}

/* ── Popup ── */
.timeline-popup {
  position: fixed;
  z-index: 200;
  background: var(--space);
  color: var(--text-on-sfc);
  border: 2px solid var(--surface);
  border-radius: var(--radius);
  padding: 16px;
  max-width: 300px;
  min-width: 200px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.3);
  pointer-events: all;
}

.timeline-popup.hidden {
  display: none;
}

.popup-close {
  position: absolute;
  top: 8px;
  right: 10px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--text-dim-sfc);
  line-height: 1;
  padding: 2px 4px;
  border-radius: 4px;
  transition: color var(--transition), background var(--transition);
}

.popup-close:hover {
  color: var(--accent);
  background: rgba(193, 119, 103, 0.1);
}

.popup-content {
  padding-right: 14px;
}

.popup-type-badge {
  display: inline-block;
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  border-radius: 10px;
  padding: 2px 8px;
  margin-bottom: 6px;
}

.popup-type-badge.event {
  background: rgba(222, 184, 65, 0.2);
  color: #7a5a00;
}

.popup-type-badge.word {
  background: rgba(193, 119, 103, 0.15);
  color: #7a3d28;
}

.popup-title {
  font-family: 'Playfair Display', serif;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-on-sfc);
  line-height: 1.3;
  margin-bottom: 4px;
}

.popup-date {
  font-size: 0.72rem;
  color: var(--text-dim-sfc);
  margin-bottom: 8px;
}

.popup-body {
  font-size: 0.78rem;
  color: var(--text-on-sfc);
  line-height: 1.6;
  font-style: italic;
  margin: 8px 0;
}

.popup-source {
  margin-top: 10px;
  margin-bottom: 0;
  font-size: 0.68rem;
  color: var(--text-dim-sfc);
  font-style: normal;
  border-top: 1px solid var(--border-sfc);
  padding-top: 8px;
}

.popup-desc {
  font-size: 0.8rem;
  color: var(--text-on-sfc);
  line-height: 1.6;
}

/* Arrow pointing down */
.popup-arrow {
  position: absolute;
  bottom: -9px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-top: 9px solid var(--surface);
}

.popup-arrow::after {
  content: '';
  position: absolute;
  top: -11px;
  left: -7px;
  width: 0;
  height: 0;
  border-left: 7px solid transparent;
  border-right: 7px solid transparent;
  border-top: 8px solid var(--space);
}

/* ── Pan slider ── */
.slider-row {
  padding: 14px 0 0;
}

.slider-labels {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.slider-label {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-dim);
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.window-range {
  font-size: 0.8rem;
  color: var(--surface);
  font-weight: 700;
  letter-spacing: 0.04em;
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  border-radius: 2px;
  outline: none;
  cursor: pointer;
  background: linear-gradient(90deg,
      var(--surface) var(--slider-pct, 0%),
      rgba(228, 217, 255, 0.2) var(--slider-pct, 0%));
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--surface);
  border: 3px solid var(--bg);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
  transition: box-shadow var(--transition), transform var(--transition);
}

input[type="range"]::-webkit-slider-thumb:hover {
  box-shadow: 0 3px 14px rgba(228, 217, 255, 0.5);
  transform: scale(1.15);
}

/* ── Responsive ── */
@media (max-width: 640px) {
  #app {
    padding: 0 16px 40px;
  }
}

/* ── Scrollbar ── */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: var(--bg);
}

::-webkit-scrollbar-thumb {
  background: rgba(228, 217, 255, 0.2);
  border-radius: 3px;
}

/* ── Footer / Methodology Note ── */
.footer-note {
  margin-top: 50px;
  padding: 30px 0;
  display: flex;
  gap: 20px;
  align-items: flex-start;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.asterisk {
  font-family: 'Playfair Display', serif;
  font-size: 3rem;
  line-height: 1;
  color: #DEB841;
  /* Amber Gold */
  font-weight: 700;
  margin-top: -8px;
}

.note-text {
  font-family: 'Outfit', sans-serif;
  font-size: 1.1rem;
  line-height: 1.8;
  color: rgba(255, 255, 255, 0.75);
  /* Soft white text */
  margin: 0;
  font-style: italic;
  max-width: 850px;
}

.note-text em {
  font-weight: 600;
  color: #DEB841;
  font-style: normal;
}