:root {
  --bg-main: #f5f0e8;
  --bg-sidebar: #1a1d23;
  --bg-card-header: #2d3139;
  --text-primary: #3b3228;
  --text-secondary: #7c7164;
  --terminal-green: #a3b18a;
  --accent-gold: #c9a96e;
  --burnt-umber: #6b4226;
  --warm-honey: #d4a843;
  --parchment-edge: #ddd5c4;
  --cinnabar: #b85c3a;
  --cool-slate: #4a5568;
  --font-body: 'Cormorant Garamond', Georgia, serif;
  --font-mono: 'IBM Plex Mono', 'Courier New', monospace;
}

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

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-body);
  background: var(--bg-main);
  color: var(--text-primary);
  overflow-x: hidden;
}

/* ======== BOOT SCREEN ======== */
#boot-screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: var(--bg-sidebar);
  z-index: 10000;
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
  padding: 48px;
  transition: opacity 0.8s ease-out;
}

#boot-screen.fade-out {
  opacity: 0;
  pointer-events: none;
}

#boot-screen.hidden {
  display: none;
}

#boot-text {
  font-family: var(--font-mono);
  font-size: 0.875rem;
  color: var(--terminal-green);
  line-height: 1.8;
  white-space: pre-wrap;
}

/* ======== SCROLL PROGRESS ======== */
#scroll-progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 2px;
  width: 0%;
  background: var(--accent-gold);
  z-index: 9999;
  transition: width 0.1s linear;
}

/* ======== CURSOR GHOST ======== */
#cursor-ghost {
  position: fixed;
  pointer-events: none;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--accent-gold);
  opacity: 0;
  z-index: 9998;
  transition: opacity 0.3s ease;
}

#cursor-ghost.visible {
  opacity: 0.4; /* 40% opacity */
}

/* ======== SIDEBAR ======== */
#sidebar {
  position: fixed;
  left: 0;
  top: 0;
  width: 280px;
  height: 100vh;
  background: var(--bg-sidebar);
  border-right: 1px solid rgba(163, 177, 138, 0.15);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  transform: translateX(-100%);
  transition: transform 0.8s cubic-bezier(0.23, 1, 0.32, 1);
}

#sidebar.visible {
  transform: translateX(0);
}

#sidebar-logo {
  height: 64px;
  display: flex;
  align-items: center;
  padding: 0 20px;
  border-bottom: 1px solid rgba(163, 177, 138, 0.1);
}

.logo-text {
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--terminal-green);
  letter-spacing: 0.02em;
}

.blink-cursor {
  display: inline-block;
  width: 2px;
  height: 18px;
  background: var(--terminal-green);
  margin-left: 2px;
  vertical-align: middle;
  animation: blink 1.2s step-end infinite;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

/* ======== QUERY ZONE ======== */
#query-zone {
  padding: 16px 20px;
  border-bottom: 1px solid rgba(163, 177, 138, 0.1);
}

#query-input {
  width: 100%;
  background: transparent;
  border: none;
  outline: none;
  font-family: var(--font-mono);
  font-size: 0.875rem;
  color: var(--terminal-green);
  padding: 8px 0;
}

#query-input::placeholder {
  color: var(--text-secondary);
  font-style: italic;
}

.query-underline {
  height: 1px;
  background: var(--terminal-green);
  opacity: 0.4;
  transition: opacity 0.3s ease;
}

#query-input:focus ~ .query-underline {
  opacity: 1;
}

/* ======== ERA ZONE ======== */
#era-zone {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
  scrollbar-width: thin;
  scrollbar-color: rgba(163, 177, 138, 0.2) transparent;
}

.era-tags {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 24px;
}

.era-tag {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 12px;
  border: none;
  border-radius: 4px;
  background: rgba(163, 177, 138, 0.12);
  color: var(--terminal-green);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.era-tag:hover {
  transform: scale(1.06);
  background: rgba(163, 177, 138, 0.25);
}

.era-tag.active {
  background: rgba(163, 177, 138, 0.3);
  font-weight: 700;
}

/* ======== TIMELINE WAVEFORM ======== */
#timeline-waveform {
  position: relative;
  width: 100%;
  height: 300px;
  display: flex;
  justify-content: center;
}

#timeline-svg {
  width: 40px;
  height: 100%;
  filter: drop-shadow(0 0 3px rgba(201, 169, 110, 0.4));
}

#timeline-tooltip {
  position: absolute;
  left: 50px;
  background: var(--bg-card-header);
  color: var(--terminal-green);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  padding: 4px 8px;
  border-radius: 2px;
  white-space: nowrap;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

#timeline-tooltip.hidden {
  opacity: 0;
}

/* ======== SIDEBAR TOGGLE ======== */
#sidebar-toggle {
  display: none;
  position: fixed;
  top: 16px;
  left: 16px;
  z-index: 1001;
  width: 40px;
  height: 40px;
  background: var(--bg-sidebar);
  border: 1px solid rgba(163, 177, 138, 0.2);
  border-radius: 4px;
  cursor: pointer;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.toggle-bar {
  display: block;
  width: 20px;
  height: 2px;
  background: var(--terminal-green);
  transition: transform 0.3s ease;
}

/* ======== MAIN CONTENT ======== */
#content-pane {
  margin-left: 280px;
  padding: 48px 60px 120px;
  max-width: 900px;
  opacity: 0;
  transition: opacity 0.6s ease;
}

#content-pane.visible {
  opacity: 1;
}

/* ======== SECTION TITLES ======== */
.section-title-wrapper {
  margin: 48px 0 32px;
}

.section-title {
  font-family: var(--font-body);
  font-weight: 700;
  font-style: italic;
  font-size: clamp(1.75rem, 4vw, 3.5rem);
  color: var(--burnt-umber);
  text-shadow: 0 1px 2px rgba(107, 66, 38, 0.15);
  line-height: 1.2;
}

/* ======== HISTORY CARDS ======== */
.history-card {
  margin-bottom: 32px;
  border-radius: 6px;
  overflow: hidden;
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.6s cubic-bezier(0.23, 1, 0.32, 1),
              transform 0.6s cubic-bezier(0.23, 1, 0.32, 1);
  position: relative;
}

.history-card.visible {
  opacity: 1;
  transform: translateY(0);
}

.history-card:nth-child(odd) {
  margin-left: 0;
}

.history-card:nth-child(even) {
  margin-left: 32px;
}

.card-header {
  position: relative;
  background: var(--bg-card-header);
  padding: 16px 20px;
  min-height: 60px;
  display: flex;
  align-items: center;
}

.circuit-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0.2;
  transition: opacity 0.3s ease;
}

.history-card:hover .circuit-canvas {
  opacity: 0.8;
}

.card-meta {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 16px;
  width: 100%;
}

.card-date {
  font-family: var(--font-mono);
  font-size: 0.875rem;
  color: var(--terminal-green);
  font-weight: 700;
}

.card-tag {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--accent-gold);
  padding: 2px 8px;
  border: 1px solid rgba(201, 169, 110, 0.3);
  border-radius: 3px;
}

.card-body {
  background: var(--bg-main);
  border: 1px solid var(--parchment-edge);
  border-top: none;
  padding: 24px;
  border-radius: 0 0 6px 6px;
}

.card-title {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 1.5rem;
  color: var(--text-primary);
  margin-bottom: 12px;
  line-height: 1.3;
}

.card-body p {
  font-family: var(--font-body);
  font-size: 1.125rem;
  line-height: 1.72;
  letter-spacing: 0.01em;
  color: var(--text-primary);
}

.card-body em {
  font-style: italic;
  color: var(--burnt-umber);
}

/* Card Click Ripple */
.card-ripple {
  position: absolute;
  border-radius: 50%;
  background: var(--accent-gold);
  opacity: 0.1;
  transform: scale(0);
  animation: ripple-expand 0.5s ease-out forwards;
  pointer-events: none;
}

@keyframes ripple-expand {
  to {
    transform: scale(1);
    opacity: 0;
  }
}

/* ======== GENERATIVE DIVIDERS ======== */
.gen-divider {
  margin: 32px 0;
  height: 30px;
  opacity: 0.4;
}

.divider-svg {
  width: 100%;
  height: 100%;
}

.divider-svg path {
  fill: none;
  stroke: var(--accent-gold);
  stroke-width: 1.5;
}

/* ======== ARCHIVE END ======== */
#archive-end {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 80px 0 40px;
  gap: 24px;
}

#compass-rose {
  animation: compass-spin 720s linear infinite;
}

@keyframes compass-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

#compass-rose line {
  stroke: var(--accent-gold);
  stroke-linecap: round;
}

#end-dates {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
}

.end-date {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--accent-gold);
  opacity: 0.5;
  animation: pulse-date 3s ease-in-out infinite;
}

.end-date:nth-child(2) { animation-delay: 0.5s; }
.end-date:nth-child(3) { animation-delay: 1s; }
.end-date:nth-child(4) { animation-delay: 1.5s; }
.end-date:nth-child(5) { animation-delay: 2s; }
.end-date:nth-child(6) { animation-delay: 2.5s; }

@keyframes pulse-date {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 0.7; }
}

.archive-end-text {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-secondary);
}

/* ======== RESPONSIVE ======== */
@media (max-width: 1024px) {
  #sidebar {
    width: 56px;
    overflow: hidden;
  }
  #sidebar.visible {
    width: 280px;
    overflow: visible;
  }
  #sidebar.collapsed {
    transform: translateX(0);
    width: 56px;
  }
  #sidebar.collapsed .logo-text,
  #sidebar.collapsed #query-zone,
  #sidebar.collapsed .era-tags,
  #sidebar.collapsed #timeline-waveform {
    display: none;
  }
  #content-pane {
    margin-left: 56px;
    padding: 32px 40px 120px;
  }
}

@media (max-width: 768px) {
  #sidebar {
    transform: translateX(-100%);
    width: 280px;
  }
  #sidebar.visible {
    transform: translateX(0);
  }
  #sidebar-toggle {
    display: flex;
  }
  #content-pane {
    margin-left: 0;
    padding: 72px 24px 120px;
  }
  .history-card:nth-child(even) {
    margin-left: 0;
  }
  .section-title {
    font-size: 1.75rem;
  }
}
