/* ═══════════════════════════════════════════
   Tom's Journey — Stylesheet
   ═══════════════════════════════════════════ */

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

:root {
  --bg: #0a0e1a;
  --bg-card: #12151f;
  --bg-lesson: #161a26;
  --text-primary: #e8ddd3;
  --text-bright: #f0e6d8;
  --accent: #c9956b;
  --accent-hover: #d4a574;
  --accent-muted: #8b7355;
  --warm-gray: #4a4540;
  --border: #2a2520;
  --thread-building: #c9956b;
  --thread-teaching: #c4857a;
  --thread-bridging: #7a9e8c;
  --font-serif: 'Cormorant Garamond', 'Georgia', serif;
  --font-sans: 'Inter', -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

html {
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  background: var(--bg);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-weight: 400;
  font-size: 16px;
  line-height: 1.75;
  overflow-x: hidden;
}

/* ── Sections & Spacing ──────────────────── */

.section {
  position: relative;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.section-gap--hero-map { height: 50vh; }
.section-gap--map-timeline { height: 30vh; }
.section-gap--timeline-connections { height: 30vh; }
.section-gap--connections-convergence { height: 60vh; }
.section-end {
  height: 30vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.closing {
  text-align: center;
}

.closing-line {
  display: inline-block;
  width: 40px;
  height: 1px;
  background: var(--warm-gray);
}

.section-title {
  font-family: var(--font-serif);
  font-size: 42px;
  font-weight: 400;
  line-height: 1.15;
  color: var(--text-primary);
  margin-bottom: 60px;
  text-align: center;
}

/* ── Hero ─────────────────────────────────── */

#hero {
  height: 100vh;
}

.hero-content {
  text-align: center;
  padding-top: 40vh;
}

.hero-name {
  font-family: var(--font-serif);
  font-size: 72px;
  font-weight: 400;
  line-height: 1.1;
  letter-spacing: 0.02em;
  color: var(--text-bright);
  opacity: 0;
  animation: heroFadeIn 1200ms ease-out forwards;
}

.hero-tagline {
  font-family: var(--font-sans);
  font-size: 18px;
  font-weight: 300;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--accent-muted);
  margin-top: 20px;
  opacity: 0;
  animation: heroFadeIn 800ms ease-out 600ms forwards;
}

@keyframes heroFadeIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

.scroll-hint {
  position: absolute;
  bottom: 40px;
  left: 50%;
  transform: translateX(-50%);
  opacity: 0;
  animation: heroFadeIn 800ms ease-out 1800ms forwards;
}

.scroll-hint-line {
  width: 1px;
  height: 40px;
  background: linear-gradient(to bottom, var(--accent-muted), transparent);
  animation: scrollPulse 2s ease-in-out infinite;
}

@keyframes scrollPulse {
  0%, 100% { opacity: 0.3; transform: scaleY(1); }
  50% { opacity: 0.6; transform: scaleY(1.2); }
}

/* ── Map ──────────────────────────────────── */

.section--map {
  width: 100%;
  padding: 0 40px;
}

#map {
  width: 100%;
  height: 60vh;
  border-radius: 4px;
  opacity: 0;
  transition: opacity 1200ms ease-out;
}

#map.visible {
  opacity: 1;
}

/* Override Leaflet controls */
.leaflet-control-container { display: none !important; }
.leaflet-container { background: var(--bg) !important; }

.map-label {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  font-family: var(--font-sans) !important;
  font-size: 11px !important;
  font-weight: 300 !important;
  color: var(--accent-muted) !important;
  letter-spacing: 0.05em !important;
  text-transform: uppercase !important;
  transition: opacity 600ms ease !important;
}

.map-label::before {
  display: none !important;
}

.map-arc {
  filter: drop-shadow(0 0 6px rgba(201, 149, 107, 0.3));
}

/* ── Timeline ─────────────────────────────── */

.timeline {
  position: relative;
  max-width: 700px;
  width: 100%;
  padding: 0 24px 0 60px;
}

.timeline-line {
  position: absolute;
  left: 36px;
  top: 0;
  bottom: 0;
  width: 1px;
  background: var(--border);
  transition: background 800ms ease;
}

.timeline-node {
  position: relative;
  margin-bottom: 20vh;
}

.timeline-node:last-child {
  margin-bottom: 0;
}

.timeline-dot {
  position: absolute;
  left: -32px;
  top: 28px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--border);
  border: 2px solid var(--warm-gray);
  transition: all 800ms ease;
  z-index: 1;
}

.timeline-node.active .timeline-dot {
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 0 20px rgba(201, 149, 107, 0.3);
}

.timeline-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 28px 32px;
  cursor: pointer;
  transition: border-color 400ms ease;
  position: relative;
}

.timeline-card:hover {
  border-color: var(--warm-gray);
}

/* Expand chevron — visible affordance for clickability */
.timeline-chevron {
  position: absolute;
  top: 28px;
  right: 24px;
  width: 12px;
  height: 12px;
  border-right: 1.5px solid var(--accent-muted);
  border-bottom: 1.5px solid var(--accent-muted);
  transform: rotate(45deg);
  transition: transform 400ms ease, opacity 400ms ease;
  opacity: 0.5;
}

.timeline-node.expanded .timeline-chevron {
  transform: rotate(-135deg);
  opacity: 0.3;
}

.timeline-date {
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 300;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent-muted);
}

.timeline-title {
  font-family: var(--font-serif);
  font-size: 28px;
  font-weight: 500;
  line-height: 1.2;
  color: var(--accent);
  margin-top: 8px;
}

.timeline-subtitle {
  font-family: var(--font-sans);
  font-size: 15px;
  font-weight: 300;
  color: var(--text-primary);
  margin-top: 6px;
  opacity: 0.8;
}

.timeline-detail {
  max-height: 0;
  overflow: hidden;
  transition: max-height 400ms ease-out, opacity 400ms ease-out;
  opacity: 0;
}

.timeline-node.expanded .timeline-detail {
  max-height: 600px;
  opacity: 1;
}

.timeline-detail p {
  font-family: var(--font-sans);
  font-size: 15px;
  font-weight: 400;
  line-height: 1.75;
  color: var(--text-primary);
  margin-top: 16px;
  max-width: 580px;
}

/* ── Lesson Cards ─────────────────────────── */

.lesson-card {
  position: relative;
  background: var(--bg-lesson);
  border-left: 2px solid var(--accent);
  padding: 20px 24px;
  margin-top: 20px;
}

.lesson-text {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 300;
  line-height: 1.6;
  color: #d4cdc4;
}

.lesson-icon {
  position: absolute;
  top: 12px;
  right: 12px;
  font-size: 16px;
  color: var(--accent);
  opacity: 0;
  cursor: pointer;
  transition: opacity 200ms ease;
  display: none;
}

.edit-mode .lesson-icon {
  display: block;
}

.lesson-card:hover .lesson-icon {
  opacity: 0.5;
}

.lesson-icon:hover {
  opacity: 1 !important;
}

.lesson-reset {
  display: none;
  background: none;
  border: none;
  color: var(--accent-muted);
  font-family: var(--font-sans);
  font-size: 11px;
  cursor: pointer;
  margin-top: 10px;
  padding: 0;
  opacity: 0.6;
  transition: opacity 200ms ease;
}

.lesson-reset:hover {
  opacity: 1;
}

.edit-mode .lesson-reset {
  display: inline;
}

.lesson-card.editing .lesson-text {
  outline: none;
  border-bottom: 1px solid var(--accent);
  padding-bottom: 4px;
}

.lesson-save-confirm {
  position: absolute;
  top: 12px;
  right: 12px;
  color: var(--accent);
  font-size: 16px;
  opacity: 0;
  animation: saveConfirm 2300ms ease forwards;
}

@keyframes saveConfirm {
  0% { opacity: 0; }
  13% { opacity: 1; }
  56% { opacity: 1; }
  100% { opacity: 0; }
}

/* ── Connection Web ───────────────────────── */

#connections-section {
  position: relative;
}

#connection-web {
  width: 100%;
  max-width: 800px;
  height: 500px;
}

#connection-web svg {
  width: 100%;
  height: 100%;
}

.conn-node circle {
  transition: all 200ms ease;
}

.conn-node:hover circle {
  filter: url(#glow);
}

.conn-node text {
  font-family: var(--font-sans);
  font-size: 11px;
  fill: var(--accent-muted);
  text-anchor: middle;
  pointer-events: none;
}

.conn-link {
  stroke: var(--warm-gray);
  stroke-width: 1;
  stroke-dasharray: 4, 4;
  opacity: 0.6;
}

.conn-phase-node circle {
  r: 8;
}

.conn-phase-node text {
  font-size: 12px;
  font-weight: 400;
  fill: var(--text-primary);
}

#add-connection-btn {
  display: none;
  position: absolute;
  bottom: 20px;
  right: 20px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--accent);
  font-size: 20px;
  cursor: pointer;
  transition: all 200ms ease;
  line-height: 1;
}

.edit-mode #add-connection-btn {
  display: block;
}

#add-connection-btn:hover {
  border-color: var(--accent);
  box-shadow: 0 0 8px rgba(201, 149, 107, 0.2);
}

/* ── Convergence ──────────────────────────── */

#convergence-section {
  padding: 0 24px;
}

.convergence-visual {
  width: 100%;
  max-width: 400px;
  margin-bottom: 80px;
}

#convergence-svg {
  width: 100%;
  height: auto;
}

.convergence-path {
  stroke-dasharray: 300;
  stroke-dashoffset: 300;
  transition: stroke-dashoffset 1500ms ease-in-out;
  opacity: 0.7;
}

.convergence-path.animated {
  stroke-dashoffset: 0;
}

.path-teaching { transition-delay: 300ms; }
.path-bridging { transition-delay: 600ms; }

.convergence-center-dot {
  opacity: 0;
  transition: opacity 800ms ease 1200ms;
}

.convergence-visual.animated .convergence-center-dot {
  opacity: 1;
}

.convergence-label {
  font-family: var(--font-serif);
  font-size: 18px;
  font-weight: 400;
  letter-spacing: 0.02em;
}

.convergence-label--center {
  text-anchor: middle;
}

.convergence-label--right {
  text-anchor: end;
}

.convergence-threads {
  max-width: 560px;
  width: 100%;
}

.convergence-thread {
  margin-bottom: 15vh;
}

.convergence-thread:last-child {
  margin-bottom: 0;
}

.convergence-heading {
  font-family: var(--font-serif);
  font-size: 32px;
  font-weight: 400;
  line-height: 1.2;
  margin-bottom: 20px;
}

.convergence-body {
  font-family: var(--font-sans);
  font-size: 18px;
  font-weight: 400;
  line-height: 1.8;
  max-width: 560px;
  color: var(--text-primary);
}

.convergence-final {
  margin-top: 15vh;
  max-width: 600px;
  text-align: center;
}

.convergence-final-text {
  font-family: var(--font-serif);
  font-size: 36px;
  font-weight: 400;
  font-style: italic;
  line-height: 1.3;
  color: var(--text-bright);
}

/* ── Observe / Scroll Animations ──────────── */

.observe-fade {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 800ms ease-out, transform 800ms ease-out;
}

.observe-fade.visible {
  opacity: 1;
  transform: translateY(0);
}

/* Slower reveal for convergence elements */
.convergence-thread.observe-fade {
  transition-duration: 1000ms;
}

.convergence-final.observe-fade {
  transition-duration: 1500ms;
}

/* ── Modal ────────────────────────────────── */

.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 400ms ease;
}

.modal.hidden {
  opacity: 0;
  pointer-events: none;
}

.modal-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(10, 14, 26, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.modal-content {
  position: relative;
  z-index: 1;
}

#password-input {
  width: 280px;
  background: var(--bg-card);
  border: 1px solid var(--warm-gray);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 16px;
  padding: 12px 16px;
  outline: none;
  caret-color: var(--accent);
  border-radius: 0;
}

#password-input:focus {
  border-color: var(--accent-muted);
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-8px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-6px); }
  80% { transform: translateX(6px); }
}

#password-input.shake {
  animation: shake 300ms ease;
}

/* ── Connection Form Modal ────────────────── */

.connection-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 280px;
}

.connection-form input,
.connection-form select {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--warm-gray);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 14px;
  padding: 10px 14px;
  outline: none;
  caret-color: var(--accent);
  border-radius: 0;
  -webkit-appearance: none;
}

.connection-form select {
  color: var(--accent-muted);
}

.connection-form input:focus,
.connection-form select:focus {
  border-color: var(--accent-muted);
}

#conn-submit {
  background: var(--bg-card);
  border: 1px solid var(--accent);
  color: var(--accent);
  font-family: var(--font-sans);
  font-size: 14px;
  padding: 10px;
  cursor: pointer;
  transition: all 200ms ease;
  border-radius: 0;
}

#conn-submit:hover {
  background: var(--accent);
  color: var(--bg);
}

/* ── Delete button for custom connections ─── */

.conn-delete {
  display: none;
  cursor: pointer;
}

.edit-mode .conn-delete {
  display: block;
}

.conn-delete circle {
  fill: var(--bg-card);
  stroke: var(--warm-gray);
  transition: stroke 200ms ease;
}

.conn-delete:hover circle {
  stroke: #c4857a;
}

.conn-delete text {
  fill: var(--accent-muted);
  font-size: 10px;
  text-anchor: middle;
  dominant-baseline: central;
  pointer-events: none;
}

/* ── Desktop text bump ────────────────────── */

@media (min-width: 769px) {
  .timeline-detail p {
    font-size: 16px;
  }
  .lesson-text {
    font-size: 15px;
  }
}

/* ── Mobile ───────────────────────────────── */

@media (max-width: 768px) {
  .hero-name { font-size: 42px; }
  .hero-tagline { font-size: 14px; }
  .section-title { font-size: 28px; margin-bottom: 40px; }

  .section-gap--hero-map { height: 30vh; }
  .section-gap--map-timeline { height: 18vh; }
  .section-gap--timeline-connections { height: 18vh; }
  .section-gap--connections-convergence { height: 36vh; }
  .section-end { height: 18vh; }

  .section--map { padding: 0; }
  #map { height: 50vh; }

  /* Timeline: remove left offset, full width cards */
  .timeline { padding: 0 16px; max-width: 100%; }
  .timeline-line { display: none; }
  .timeline-dot { display: none; }
  .timeline-node { margin-bottom: 10vh; }
  .timeline-card { padding: 20px 18px; }
  .timeline-title { font-size: 24px; }
  .timeline-subtitle { font-size: 14px; }
  .timeline-detail p { font-size: 15px; }
  .lesson-text { font-size: 13px; }
  .lesson-card { padding: 16px 18px; }
  .timeline-chevron { top: 20px; right: 18px; }

  /* Network: grouped list on mobile */
  #connection-web { height: auto; min-height: 0; padding: 0; }

  /* Convergence: ensure text is on screen */
  #convergence-section { padding: 0 20px; }
  .convergence-heading { font-size: 26px; }
  .convergence-body { font-size: 16px; line-height: 1.7; max-width: 100%; }
  .convergence-thread { margin-bottom: 8vh; }
  .convergence-final { margin-top: 8vh; }
  .convergence-final-text { font-size: 24px; }
  .convergence-threads { max-width: 100%; }

  #password-input,
  .connection-form { width: 90vw; max-width: 280px; }
}

/* ── Mobile grouped list for connections ─── */

.conn-list {
  width: 100%;
  max-width: 560px;
  padding: 0 20px;
}

.conn-group {
  margin-bottom: 28px;
}

.conn-group:last-child {
  margin-bottom: 0;
}

.conn-group-heading {
  font-family: var(--font-serif);
  font-size: 20px;
  font-weight: 500;
  margin-bottom: 10px;
}

.conn-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.conn-pill {
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 300;
  color: var(--text-primary);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 5px 14px;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.conn-pill-delete {
  color: var(--accent-muted);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  transition: color 200ms ease;
}

.conn-pill-delete:hover {
  color: #c4857a;
}
