:root {
  --navy: #1E2761;
  --ink: #16192B;
  --muted: #5B6178;
  --accent: #02C39A;
  --hairline: #E5E7F0;
  --bg: #FFFFFF;
  --panel: #F6F7FB;
  --font-head: Georgia, "Times New Roman", serif;
  --font-body: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  overflow: hidden;
}

#app {
  height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ---------- header ---------- */

#chrome {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.1rem 1.8rem;
  flex: 0 0 auto;
}

#brand {
  font-family: var(--font-head);
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--navy);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#brand span {
  font-family: var(--font-body);
  font-weight: 400;
  color: var(--muted);
  font-size: 0.95rem;
}

#controls {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex: 0 0 auto;
}

#speed-switch {
  display: flex;
  gap: 0.4rem;
  flex: 0 0 auto;
}

#speed-switch button {
  font-family: var(--font-body);
  font-size: 0.78rem;
  letter-spacing: 0.02em;
  padding: 0.4rem 0.85rem;
  border-radius: 999px;
  border: 1px solid var(--hairline);
  background: var(--bg);
  color: var(--muted);
  cursor: pointer;
}

#speed-switch button.active {
  background: var(--navy);
  border-color: var(--navy);
  color: #fff;
}

#playPauseBtn {
  font-family: var(--font-body);
  font-size: 0.7rem;
  width: 2rem;
  height: 2rem;
  border-radius: 999px;
  border: 1px solid var(--hairline);
  background: var(--bg);
  color: var(--muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}

#playPauseBtn:hover { color: var(--navy); border-color: var(--navy); }

body.paused #playPauseBtn { color: var(--accent); border-color: var(--accent); }

/* ---------- stage ---------- */

#stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  touch-action: pan-y;
}

.nav-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 2.4rem;
  height: 2.4rem;
  border-radius: 999px;
  border: none;
  background: rgba(22, 25, 43, 0.32);
  color: #fff;
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.45;
  transition: opacity 0.2s ease, background 0.2s ease;
  z-index: 5;
}

.nav-arrow:hover { opacity: 1; background: rgba(22, 25, 43, 0.55); }

.nav-prev { left: 0.8rem; }
.nav-next { right: 0.8rem; }

@media (max-width: 860px) {
  .nav-arrow { opacity: 0.6; width: 2.1rem; height: 2.1rem; font-size: 1.2rem; }
}

.slide-layer {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: stretch;
  padding: 0 1.8rem 1.6rem;
  gap: 2.2rem;
  opacity: 0;
  transform: scale(0.985);
  transition: opacity 0.7s ease, transform 0.7s ease;
  pointer-events: none;
}

.slide-layer.active {
  opacity: 1;
  transform: scale(1);
  pointer-events: auto;
  z-index: 2;
}

.media-pane {
  flex: 1 1 56%;
  min-width: 0;
  border-radius: 14px;
  overflow: hidden;
  background: var(--panel);
  box-shadow: 0 18px 40px -22px rgba(30, 39, 97, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.media-pane img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center; /* per-projekt override: se project.imagePosition i script.js */
}

.year-badge {
  position: absolute;
  top: 1rem;
  left: 1rem;
  background: var(--navy);
  color: #fff;
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  font-weight: 700;
  padding: 0.28rem 0.6rem;
  border-radius: 999px;
}

/* ---------- prompt-reveal (hovra/tryck för att visa en fullständig prompt) ---------- */

.media-pane.has-prompt-reveal { cursor: pointer; }

.prompt-hint {
  position: absolute;
  bottom: 1rem;
  right: 1rem;
  background: rgba(255, 255, 255, 0.92);
  color: var(--navy);
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.32rem 0.7rem;
  border-radius: 999px;
  pointer-events: none;
  transition: opacity 0.15s ease;
}

.media-pane.has-prompt-reveal:hover .prompt-hint,
.media-pane.has-prompt-reveal.show-prompt .prompt-hint {
  opacity: 0;
}

.prompt-reveal {
  position: absolute;
  inset: 0;
  background: rgba(30, 39, 97, 0.95);
  color: #fff;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 1.8rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.media-pane.has-prompt-reveal:hover .prompt-reveal,
.media-pane.has-prompt-reveal.show-prompt .prompt-reveal {
  opacity: 1;
  pointer-events: auto;
}

.prompt-reveal-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  margin: 0 0 0.6rem;
}

.prompt-reveal-text {
  font-family: "Courier New", Courier, monospace;
  font-size: clamp(0.78rem, 1.3vw, 0.95rem);
  line-height: 1.6;
  margin: 0;
}

/* code-card slides (no live screenshot) */
.code-card {
  width: 100%;
  height: 100%;
  background: #12142A;
  color: #D9DCF2;
  font-family: "Courier New", Courier, monospace;
  font-size: clamp(0.72rem, 1.15vw, 0.95rem);
  line-height: 1.65;
  padding: 2.9rem 1.8rem 1.6rem;
  overflow: hidden;
  white-space: pre;
}

.code-card .cmt { color: #7B8FD1; }
.code-card .kw  { color: #02C39A; }
.code-card .str { color: #E7C87A; }

.text-pane {
  flex: 1 1 44%;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.9rem;
  padding: 0.4rem 0.6rem;
}

.counter {
  font-family: var(--font-body);
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  color: var(--accent);
  font-weight: 700;
  text-transform: uppercase;
}

.text-pane h1 {
  font-family: var(--font-head);
  font-size: clamp(1.5rem, 3vw, 2.4rem);
  line-height: 1.15;
  margin: 0;
  color: var(--navy);
}

.text-pane p {
  font-family: var(--font-body);
  font-size: clamp(0.95rem, 1.3vw, 1.12rem);
  line-height: 1.55;
  color: var(--ink);
  margin: 0;
  max-width: 46ch;
}

.text-pane a.visit {
  font-size: 0.85rem;
  color: var(--muted);
  text-decoration: none;
  border-bottom: 1px solid var(--hairline);
  padding-bottom: 0.15rem;
  width: fit-content;
}

.text-pane a.visit:hover { color: var(--accent); border-color: var(--accent); }

.text-pane a.visit.source {
  font-style: italic;
  font-size: 0.8rem;
  border-color: transparent;
}

/* ---------- klickbara begrepp (diskret, smälter in i löptexten) ---------- */

.term-link {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px dotted currentColor;
}

.term-link:hover { border-bottom-style: solid; }

/* ---------- term-tooltip (hovringsbar beskrivning, t.ex. "SUHF-modellen") ---------- */

.term-tooltip-wrap {
  position: relative;
  display: inline-block;
  cursor: help;
  border-bottom: 1px dotted currentColor;
}

.term-tooltip {
  position: absolute;
  left: 50%;
  bottom: 100%;
  transform: translate(-50%, -8px);
  width: min(300px, 78vw);
  background: var(--navy);
  color: #fff;
  font-family: var(--font-body);
  font-size: 0.78rem;
  line-height: 1.5;
  padding: 0.85rem 1rem;
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease, transform 0.15s ease;
  z-index: 5;
}

.term-tooltip-wrap:hover .term-tooltip,
.term-tooltip-wrap:focus-within .term-tooltip,
.term-tooltip-wrap.show-tooltip .term-tooltip {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, -4px);
}

.term-tooltip-text {
  display: block;
  margin-bottom: 0.55rem;
}

/* Under ~640px kan termen sitta nära vänsterkanten av en smal text-pane —
   centrerad under termen (ovan) klipps då av skärmkanten. Ankra i stället
   till skärmens mitt, samma princip som prompt-reveal-panelen redan använder
   (media-pane, inset: 0) — en fast, alltid synlig panel i stället för en
   liten pil-popover. Verifierat med resize_window (mobile, 375px) 2026-08-20:
   utan detta hamnade tooltipen delvis utanför skärmen till vänster. */
@media (max-width: 640px) {
  .term-tooltip {
    position: fixed;
    left: 1rem;
    right: 1rem;
    top: 50%;
    bottom: auto;
    width: auto;
    transform: translateY(-50%);
  }

  .term-tooltip-wrap:hover .term-tooltip,
  .term-tooltip-wrap:focus-within .term-tooltip,
  .term-tooltip-wrap.show-tooltip .term-tooltip {
    transform: translateY(-50%);
  }
}

.term-tooltip-link {
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
}

.term-tooltip-link:hover { text-decoration: underline; }

/* ---------- avslutande referens-slides (begreppslista + källförteckning) ---------- */

.reference-pane {
  flex: 1 1 100%;
  width: 100%;
  height: 100%;
  background: var(--panel);
  border-radius: 14px;
  padding: 2.4rem 2.8rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.reference-pane h1 {
  font-family: var(--font-head);
  color: var(--navy);
  margin: 0;
  font-size: clamp(1.4rem, 2.6vw, 2rem);
}

.reference-pane .ref-year {
  display: inline-block;
  background: var(--navy);
  color: #fff;
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  font-weight: 700;
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  width: fit-content;
}

.reference-pane .ref-intro {
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.5;
  margin: -0.4rem 0 0;
  max-width: 70ch;
}

.glossary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 0.55rem 1.5rem;
}

.glossary-grid a {
  color: var(--ink);
  text-decoration: none;
  border-bottom: 1px dotted var(--muted);
  font-size: 0.92rem;
  width: fit-content;
}

.glossary-grid a:hover { border-color: var(--accent); color: var(--accent); }

.bib-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.bib-list li {
  font-size: 0.86rem;
  line-height: 1.55;
  color: var(--ink);
  padding-left: 1.3rem;
  text-indent: -1.3rem;
}

.bib-list a {
  color: var(--muted);
  font-size: 0.82rem;
}

.bib-list .annot {
  display: block;
  text-indent: 0;
  color: var(--muted);
  font-style: italic;
  font-size: 0.82rem;
  margin-top: 0.1rem;
}

.bib-list a.pick-title {
  color: var(--ink);
  font-size: 0.92rem;
  font-weight: 600;
}

.bib-list .pick-meta {
  display: block;
  text-indent: 0;
  color: var(--muted);
  font-size: 0.78rem;
  margin-top: 0.1rem;
}

@media (max-width: 860px) {
  .reference-pane { padding: 1.6rem 1.3rem; }
}

/* ---------- milestone interlude ---------- */

.milestone-pane {
  flex: 1 1 100%;
  width: 100%;
  height: 100%;
  background: var(--navy);
  color: #fff;
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 1.4rem;
  padding: 2rem;
}

.year-card-label {
  font-family: var(--font-body);
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--accent);
}

.year-card-personal .year-card-label { color: #E8B4D8; }

.milestone-year {
  font-family: var(--font-head);
  font-size: clamp(3.5rem, 9vw, 6rem);
  font-weight: 700;
  line-height: 1;
  color: #fff;
}

.milestone-facts {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  max-width: 40ch;
}

.milestone-facts li {
  font-family: var(--font-body);
  font-size: clamp(0.95rem, 1.5vw, 1.1rem);
  line-height: 1.5;
  color: #E8EAF6;
}

.milestone-facts li.quote {
  font-style: italic;
  color: #fff;
}

.milestone-facts li.quote::before { content: "\201C"; }
.milestone-facts li.quote::after { content: "\201D"; }

.milestone-facts a.fact-source {
  display: block;
  font-size: 0.78rem;
  font-style: italic;
  color: var(--accent);
  text-decoration: none;
  margin-top: 0.15rem;
}

.milestone-facts a.fact-source:hover { text-decoration: underline; }

.milestone-facts a.term-link {
  color: inherit;
  border-bottom: 1px dotted rgba(255, 255, 255, 0.6);
}

.milestone-facts a.term-link:hover { border-bottom-style: solid; }

/* ---------- progress ---------- */

#progress-track {
  flex: 0 0 auto;
  display: flex;
  gap: 0.35rem;
  padding: 0 1.8rem 1.1rem;
}

.seg {
  flex: 1 1 0;
  height: 3px;
  background: var(--hairline);
  border-radius: 999px;
  overflow: hidden;
}

.seg .fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
}

.seg .fill.animating {
  width: 100%;
  transition: width linear;
}

.seg.done .fill {
  width: 100%;
  transition: none;
}

/* ---------- responsive ---------- */

/* ---------- corner buttons + tech modal ---------- */

.corner {
  position: fixed;
  bottom: 14px;
  font-family: "Courier New", Courier, monospace;
  font-size: 0.78rem;
  color: var(--muted);
  background: var(--bg);
  border: 1px solid var(--hairline);
  border-radius: 999px;
  padding: 0.3rem 0.7rem;
  text-decoration: none;
  cursor: pointer;
  opacity: 0.55;
  transition: opacity 0.2s ease, color 0.2s ease;
  z-index: 10;
}

.corner:hover { opacity: 1; color: var(--navy); }

.corner-left { left: 14px; }
.corner-right { right: 14px; }

.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(22, 25, 43, 0.55);
  align-items: center;
  justify-content: center;
  z-index: 20;
  padding: 1rem;
}

.modal-overlay.show { display: flex; }

.modal {
  position: relative;
  background: var(--bg);
  border-radius: 16px;
  max-width: 640px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  padding: 2rem;
}

.modal h2 {
  font-family: var(--font-head);
  color: var(--navy);
  margin: 0 0 0.5rem;
  font-size: 1.4rem;
}

.modal > p {
  color: var(--muted);
  font-size: 0.92rem;
  margin: 0 0 1.4rem;
}

.modal-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: none;
  border: none;
  font-size: 1.4rem;
  line-height: 1;
  color: var(--muted);
  cursor: pointer;
}

.tech-section-title {
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 1.4rem 0 0.7rem;
}

.tech-section-title:first-of-type { margin-top: 0.4rem; }

.tech-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.tech-card h3 {
  font-size: 0.95rem;
  color: var(--navy);
  margin: 0 0 0.3rem;
}

.tech-card p {
  font-size: 0.85rem;
  color: var(--ink);
  line-height: 1.5;
  margin: 0;
}

.tech-card code {
  background: var(--panel);
  border-radius: 4px;
  padding: 0.05rem 0.3rem;
  font-size: 0.82em;
}

@media (max-width: 860px) {
  .slide-layer {
    flex-direction: column;
    padding: 0 1.1rem 1.1rem;
    gap: 1rem;
  }
  .media-pane { flex: 1 1 48%; }
  .text-pane { flex: 1 1 40%; justify-content: flex-start; padding-top: 0.4rem; }
  .text-pane p { max-width: none; }
  #chrome { padding: 0.9rem 1.1rem; }
  #brand span { display: none; }
  .code-card { white-space: pre-wrap; word-break: break-word; }
  .tech-grid { grid-template-columns: 1fr; }
  .modal { padding: 1.4rem; }
}
