/* =========================================================
   How the Internet Works — story experience
   ========================================================= */

.story {
  --story-soft: rgba(255, 255, 255, 0.06);
  position: relative;
}

/* ---- Deck mode: one scene at a time ---- */
.story--deck {
  padding-bottom: 5.5rem;
}
.story--deck > [data-scene] {
  display: none !important;
  min-height: calc(100svh - 9rem);
  align-items: center;
  justify-content: center;
}
.story--deck > [data-scene].is-current {
  display: flex !important;
}

.story-controls {
  position: fixed;
  left: 50%;
  bottom: 1.1rem;
  transform: translateX(-50%);
  z-index: 90;
  width: min(640px, calc(100vw - 1.5rem));
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 0.85rem;
  background: rgba(11, 17, 32, 0.92);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(10px);
}
.story-controls[hidden] {
  display: none !important;
}
.story--deck.story--controls-hidden {
  padding-bottom: 2rem;
}
.story-controls__btn {
  min-width: 7.5rem;
}
.story-controls__btn:first-child {
  justify-self: start;
}
.story-controls__btn:last-child {
  justify-self: end;
}
.story-controls__btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}
.story-controls__status {
  margin: 0;
  text-align: center;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-dim);
  letter-spacing: 0.02em;
  white-space: nowrap;
}

@media (max-width: 560px) {
  .story-controls {
    grid-template-columns: 1fr 1fr;
    grid-template-areas:
      "status status"
      "prev next";
  }
  .story-controls__status { grid-area: status; }
  .story-controls__btn:first-child { grid-area: prev; width: 100%; }
  .story-controls__btn:last-child { grid-area: next; width: 100%; min-width: 0; }
}

/* ---- Progress rail ---- */
.story__progress {
  position: fixed;
  top: 0; left: 0;
  width: 100%;
  height: 3px;
  z-index: 95;
  transform-origin: left center;
  transform: scaleX(0);
  background: linear-gradient(90deg, var(--gold), var(--accent), var(--teal));
  pointer-events: none;
}

/* ---- Start / intro ---- */
.story-intro {
  min-height: calc(100svh - 4rem);
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 7rem 1.5rem 7rem;
  position: relative;
  overflow: hidden;
  width: 100%;
}
.story-intro__glow {
  position: absolute;
  width: 520px; height: 520px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(245, 185, 66, 0.14), transparent 70%);
  filter: blur(10px);
  pointer-events: none;
}
.story-intro__inner { position: relative; z-index: 1; max-width: 640px; }
.story-intro__question {
  font-family: var(--font-head);
  font-size: clamp(1.8rem, 5vw, 3rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
  margin-bottom: 1.2rem;
}
.story-intro__sub {
  color: var(--text-dim);
  font-size: 1.05rem;
  margin-bottom: 2rem;
}
.story-intro__hint {
  margin-top: 1.4rem;
  font-size: 0.82rem;
  color: var(--text-dim);
  opacity: 0.75;
}

/* ---- Scenes ---- */
.story-scene {
  min-height: 100svh;
  display: flex;
  align-items: center;
  padding: 6rem 0 7rem;
  position: relative;
  border-top: 1px solid transparent;
  width: 100%;
}
.story-scene__inner {
  width: min(980px, 92vw);
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: clamp(1.5rem, 4vw, 3.5rem);
  align-items: center;
}
@media (max-width: 820px) {
  .story-scene__inner {
    grid-template-columns: 1fr;
    text-align: center;
  }
  .story-scene__copy { order: 2; }
  .story-scene__art { order: 1; }
}

.story-scene__kicker {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 0.8rem;
}
.story-scene__title {
  font-family: var(--font-head);
  font-size: clamp(1.6rem, 3.5vw, 2.3rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 1rem;
  line-height: 1.15;
}
.story-scene__text {
  color: var(--text-dim);
  font-size: 1.08rem;
  line-height: 1.55;
  margin-bottom: 0.9rem;
  max-width: 34ch;
}
@media (max-width: 820px) {
  .story-scene__text { margin-left: auto; margin-right: auto; }
}
.story-scene__note {
  display: inline-flex;
  align-items: flex-start;
  gap: 0.45rem;
  background: rgba(245, 185, 66, 0.08);
  border: 1px solid rgba(245, 185, 66, 0.25);
  border-radius: 12px;
  padding: 0.65rem 0.9rem;
  font-size: 0.88rem;
  color: var(--gold);
  max-width: 36ch;
  text-align: left;
}

.story-scene__art {
  position: relative;
  min-height: 280px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Soft card behind illustrations */
.art-card {
  width: 100%;
  max-width: 460px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: clamp(1.2rem, 3vw, 1.8rem);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.28);
  position: relative;
  overflow: hidden;
}

/* ---- Browser ---- */
.s-browser {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
}
.s-browser__chrome {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.7rem 0.85rem;
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
}
.s-browser__dots { display: flex; gap: 5px; }
.s-browser__dots i {
  width: 9px; height: 9px; border-radius: 50%;
  background: rgba(255,255,255,0.18);
  display: block;
}
.s-browser__dots i:nth-child(1) { background: #ef482c; }
.s-browser__dots i:nth-child(2) { background: #f5b942; }
.s-browser__dots i:nth-child(3) { background: #2dd4bf; }
.s-browser__bar {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 0.45rem 0.75rem;
  font-family: "SF Mono", ui-monospace, Menlo, monospace;
  font-size: 0.92rem;
  min-height: 2.1rem;
  color: var(--text);
}
.s-browser__typed { color: var(--gold); }
.s-browser__caret {
  width: 2px; height: 1em;
  background: var(--accent);
  display: inline-block;
  vertical-align: text-bottom;
}
.s-browser__view {
  min-height: 150px;
  padding: 1.4rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #0b1120;
}
.s-browser__loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.7rem;
  color: var(--text-dim);
  font-size: 0.85rem;
  opacity: 0;
}
.s-spinner {
  width: 28px; height: 28px;
  border: 2px solid rgba(255,255,255,0.12);
  border-top-color: var(--gold);
  border-radius: 50%;
}

/* ---- DNS / contacts ---- */
.s-contacts {
  text-align: center;
}
.s-contacts__book {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 1.4rem 1.2rem;
  position: relative;
}
.s-contacts__icon {
  font-size: 2.2rem;
  margin-bottom: 0.6rem;
}
.s-contacts__status {
  font-size: 0.88rem;
  color: var(--text-dim);
  min-height: 1.4em;
  margin-bottom: 1rem;
}
.s-contacts__ip {
  font-family: "SF Mono", ui-monospace, Menlo, monospace;
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--gold);
  letter-spacing: 0.03em;
  opacity: 0;
  transform: scale(0.92);
}
.s-contacts__check {
  position: absolute;
  top: 1rem; right: 1rem;
  width: 28px; height: 28px;
  border-radius: 50%;
  background: rgba(45, 212, 191, 0.15);
  color: var(--teal);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  opacity: 0;
  scale: 0.5;
}
.s-contacts__example {
  margin-top: 0.7rem;
  font-size: 0.75rem;
  color: var(--text-dim);
  opacity: 0;
}

/* ---- Travel / map ---- */
.s-map {
  width: 100%;
}
.s-map__svg { width: 100%; height: auto; display: block; overflow: visible; }
.s-map__route {
  fill: none;
  stroke: url(#storyRouteGrad);
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-dasharray: 5 7;
  opacity: 0.85;
}
.s-map__node {
  fill: var(--surface);
  stroke: rgba(245, 185, 66, 0.5);
  stroke-width: 1.5;
}
.s-map__label {
  fill: var(--text-dim);
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 600;
}
.s-map__packet {
  font-size: 18px;
}

/* ---- Server building ---- */
.s-server {
  text-align: center;
}
.s-server__building {
  width: 140px;
  margin: 0 auto 1.2rem;
  background: linear-gradient(180deg, var(--surface-2), var(--bg));
  border: 1px solid var(--line);
  border-radius: 14px 14px 8px 8px;
  padding: 1rem 0.8rem 0.8rem;
  position: relative;
}
.s-server__roof {
  position: absolute;
  top: -12px; left: 50%;
  transform: translateX(-50%);
  width: 70%;
  height: 12px;
  background: var(--accent);
  border-radius: 4px 4px 0 0;
  opacity: 0.85;
}
.s-server__window {
  height: 14px;
  background: rgba(245, 185, 66, 0.15);
  border: 1px solid rgba(245, 185, 66, 0.25);
  border-radius: 3px;
  margin-bottom: 0.45rem;
}
.s-server__door {
  width: 36px; height: 28px;
  margin: 0.5rem auto 0;
  background: rgba(239, 72, 44, 0.25);
  border: 1px solid rgba(239, 72, 44, 0.4);
  border-radius: 4px 4px 0 0;
}
.s-server__label {
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 0.95rem;
  margin-bottom: 1rem;
}
.s-server__files {
  display: flex;
  justify-content: center;
  gap: 0.7rem;
  flex-wrap: wrap;
}
.s-file {
  width: 56px; height: 64px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  opacity: 0;
  transform: translateY(12px);
}

/* ---- Package return ---- */
.s-package {
  text-align: center;
}
.s-package__box {
  width: 120px; height: 90px;
  margin: 0 auto 1.2rem;
  position: relative;
}
.s-package__lid {
  position: absolute;
  top: 0; left: 10%;
  width: 80%; height: 22px;
  background: linear-gradient(180deg, var(--gold), #d49a20);
  border-radius: 6px 6px 2px 2px;
  transform-origin: left center;
  z-index: 2;
}
.s-package__body {
  position: absolute;
  bottom: 0; left: 0;
  width: 100%; height: 70px;
  background: linear-gradient(180deg, #c4841a, #8a5a10);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  font-size: 1.1rem;
}
.s-package__path {
  height: 3px;
  background: repeating-linear-gradient(90deg, rgba(245,185,66,0.5) 0 8px, transparent 8px 16px);
  margin: 1rem 0;
  position: relative;
  border-radius: 2px;
}
.s-package__dot {
  position: absolute;
  top: 50%; left: 0;
  transform: translate(-50%, -50%);
  font-size: 1.3rem;
}

/* ---- Assemble / render ---- */
.s-assemble .s-browser__view {
  min-height: 200px;
  padding: 0;
  align-items: stretch;
  justify-content: stretch;
}
.s-page {
  padding: 1.1rem 1.15rem;
  width: 100%;
  opacity: 0;
}
.s-page__nav {
  height: 10px; width: 36%;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--accent), var(--gold));
  margin-bottom: 0.9rem;
  opacity: 0;
}
.s-page__hero {
  height: 56px;
  border-radius: 10px;
  background: rgba(245, 185, 66, 0.12);
  border: 1px solid rgba(245, 185, 66, 0.22);
  margin-bottom: 0.8rem;
  opacity: 0;
  transform: scale(0.96);
}
.s-page__title {
  font-family: var(--font-head);
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 0.55rem;
  opacity: 0;
}
.s-page__line {
  height: 7px;
  border-radius: 4px;
  background: rgba(255,255,255,0.1);
  margin-bottom: 0.4rem;
  opacity: 0;
}
.s-page__line:nth-child(4) { width: 92%; }
.s-page__line:nth-child(5) { width: 78%; }
.s-page__line:nth-child(6) { width: 85%; }

@media (prefers-reduced-motion: reduce) {
  .story__progress { transform: none !important; }
  .s-browser__caret { opacity: 1 !important; animation: none !important; }
  .s-spinner { border-top-color: var(--gold); }
}
.s-page__icons {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.8rem;
}
.s-page__icon {
  width: 28px; height: 28px;
  border-radius: 8px;
  background: rgba(45, 212, 191, 0.15);
  border: 1px solid rgba(45, 212, 191, 0.3);
  opacity: 0;
  transform: translateY(8px);
}

/* ---- Finish ---- */
.story-finish {
  min-height: 100svh;
  display: flex;
  align-items: center;
  padding: 6rem 0 7rem;
  width: 100%;
}
.story-finish__inner {
  width: min(980px, 92vw);
  margin: 0 auto;
  text-align: center;
}
.story-finish__badge {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  background: rgba(45, 212, 191, 0.12);
  border: 1px solid rgba(45, 212, 191, 0.4);
  color: var(--teal);
  border-radius: 999px;
  padding: 0.45rem 1rem;
  font-weight: 700;
  font-size: 0.88rem;
  margin-bottom: 1.2rem;
}
.story-finish__title {
  font-family: var(--font-head);
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  font-weight: 800;
  margin-bottom: 0.8rem;
}
.story-finish__text {
  color: var(--text-dim);
  font-size: 1.05rem;
  max-width: 42ch;
  margin: 0 auto 2.2rem;
}

/* ---- Interactive journey timeline (hand-drawn path) ---- */
.story-timeline {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: clamp(1.35rem, 3vw, 2.25rem);
  text-align: center;
  overflow: visible;
}
.story-timeline__title {
  font-family: var(--font-head);
  font-size: 1.1rem;
  margin-bottom: 0.4rem;
}
.story-timeline__hint {
  color: var(--text-dim);
  font-size: 0.88rem;
  margin-bottom: 1.75rem;
}

.story-journey {
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
}

.story-journey__map {
  position: relative;
  width: 100%;
  aspect-ratio: 920 / 460;
  margin: 0 auto;
  overflow: visible;
}

.story-journey__svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
}

.story-journey__ground {
  fill: rgba(245, 185, 66, 0.1);
  stroke: none;
}

.story-journey__lane {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.story-journey__lane--outer {
  stroke: rgba(255, 255, 255, 0.1);
  stroke-width: 1.5;
}
.story-journey__lane--inner {
  stroke: rgba(255, 255, 255, 0.08);
  stroke-width: 1.25;
}

.story-journey__path {
  fill: none;
  stroke: url(#journeyGrad);
  stroke-width: 3.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.story-journey__flow {
  fill: none;
  stroke: rgba(245, 185, 66, 0.65);
  stroke-width: 2.25;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 10 22 4 18;
  opacity: 0.9;
}

.story-journey__runner {
  pointer-events: none;
}
.story-journey__runner-glow {
  fill: rgba(245, 185, 66, 0.4);
}
.story-journey__runner-core {
  fill: #f5b942;
  stroke: #fff8e7;
  stroke-width: 1.5;
  filter: drop-shadow(0 0 6px rgba(245, 185, 66, 0.85));
}

@media (prefers-reduced-motion: reduce) {
  .story-journey__flow,
  .story-journey__runner {
    display: none;
  }
}

.story-journey__start {
  position: absolute;
  left: 22%;
  top: 4%;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  transform: translate(-50%, -50%);
  pointer-events: none;
  white-space: nowrap;
}
.story-journey__start-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 0 4px rgba(245, 185, 66, 0.2), 0 0 16px rgba(245, 185, 66, 0.45);
  flex-shrink: 0;
}
.story-journey__start-label {
  font-family: var(--font-head);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--gold);
  background: rgba(11, 17, 32, 0.9);
  border: 1px solid rgba(245, 185, 66, 0.4);
  border-radius: 999px;
  padding: 0.28rem 0.65rem;
}

.story-journey__card {
  position: absolute;
  left: 50%;
  top: 50%;
  translate: -50% -50%;
  z-index: 2;
  width: min(42%, 260px);
  min-height: 0;
  padding: 1.25rem 1.35rem 1.35rem;
  text-align: left;
  background: rgba(11, 17, 32, 0.94);
  border: 1px solid rgba(245, 185, 66, 0.3);
  border-radius: 18px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.42);
  display: grid;
  gap: 0.55rem;
  align-content: start;
  backdrop-filter: blur(10px);
}

.story-orbit__step {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0;
}

.story-orbit__name {
  font-family: var(--font-head);
  font-weight: 700;
  font-size: clamp(1.15rem, 2.2vw, 1.35rem);
  margin: 0;
  line-height: 1.2;
  letter-spacing: -0.01em;
}

.story-orbit__desc {
  color: var(--text-dim);
  font-size: clamp(0.92rem, 1.7vw, 1.02rem);
  line-height: 1.55;
  margin: 0;
  max-width: none;
}

/* Fixed positions around the track — no JS required for layout */
.story-node {
  --x: 50%;
  --y: 50%;
  position: absolute;
  left: var(--x);
  top: var(--y);
  width: auto;
  min-width: 0;
  margin: 0;
  padding: 0.15rem;
  border: none;
  background: none;
  color: inherit;
  font: inherit;
  cursor: pointer;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  transform: translate(-50%, -50%);
}
.story-node--top {
  flex-direction: column-reverse;
}
.story-node--bottom {
  flex-direction: column;
}
.story-node--left {
  flex-direction: row-reverse;
}
.story-node--right {
  flex-direction: row;
}

.story-node:hover,
.story-node.is-active {
  z-index: 4;
}
.story-node:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 4px;
  border-radius: 12px;
}

.story-node__dot {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: var(--bg);
  border: 1.5px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.28);
  transition: border-color 0.25s, box-shadow 0.25s, transform 0.25s, background 0.25s;
  flex-shrink: 0;
}
.story-node:hover .story-node__dot,
.story-node.is-active .story-node__dot {
  border-color: var(--accent);
  background: rgba(239, 72, 44, 0.12);
  box-shadow: 0 0 0 4px rgba(239, 72, 44, 0.12), 0 10px 24px rgba(0, 0, 0, 0.35);
  transform: scale(1.06);
}

.story-node__label {
  font-weight: 700;
  font-family: var(--font-head);
  font-size: 0.72rem;
  letter-spacing: 0.02em;
  white-space: nowrap;
  color: var(--text-dim);
  transition: color 0.25s, border-color 0.25s;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  background: rgba(11, 17, 32, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
}
.story-node:hover .story-node__label,
.story-node.is-active .story-node__label {
  color: var(--text);
  border-color: rgba(245, 185, 66, 0.35);
}

@media (max-width: 720px) {
  .story-journey__card {
    width: min(48%, 200px);
    padding: 1rem 1.05rem 1.1rem;
  }
  .story-node__dot {
    width: 38px;
    height: 38px;
    font-size: 0.95rem;
  }
  .story-node__label {
    font-size: 0.62rem;
    padding: 0.15rem 0.4rem;
  }
  .story-journey__start {
    left: 18%;
    top: 3%;
  }
  .story-journey__start-label {
    font-size: 0.62rem;
    padding: 0.22rem 0.5rem;
  }
}

.story-finish__cta {
  margin-top: 2rem;
  display: flex;
  gap: 0.8rem;
  justify-content: center;
  flex-wrap: wrap;
}

/* Floating ambient dots in scenes */
.story-float {
  position: absolute;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--gold);
  opacity: 0.35;
  pointer-events: none;
}

body.projector .story-scene__title { font-size: clamp(1.9rem, 4vw, 2.6rem); }
body.projector .story-scene__text { font-size: 1.18rem; }
body.projector .story-node__label { font-size: 0.78rem; }
body.projector .story-orbit__name { font-size: 1.45rem; }
body.projector .story-orbit__desc { font-size: 1.12rem; }
