/* Elkia Trading Co. — homepage hero: the animated dusk map and the hero panel,
   plus the scene styles shared with the small map in How it works.
   Loaded on the homepage only, after styles.css. */

/* ------------------------------------------------------------ Hero layout

   Phones (under 720px): a compact panel, then the step controls, then the
   tall map with its empty top band cropped off, then the trust line.
   Tablets (720–1023px): the panel and the tall map side by side.
   Desktop (1024px and up): the wide map fills a hero sized to the screen
   (692–820px), anchored to its bottom edge, with the panel on top. */

.hero-map {
  position: relative;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  overflow: clip;
  border-bottom: 4px solid var(--color-line);
  background-color: var(--color-panel);
  background-image:
    linear-gradient(var(--color-panel) 30px, transparent 30px),
    linear-gradient(90deg, var(--color-line) 2px, transparent 2px);
  background-size: 32px 32px;
}

.hero-panel {
  position: relative;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  width: min(600px, calc(100% - 2 * var(--gutter) - 6px));
  margin: 16px auto 0;
  padding: 16px;
  border: 4px solid var(--color-text);
  background: var(--color-night);
  box-shadow: 6px 6px 0 var(--color-pink);
  text-align: center;
}

.hero-panel .eyebrow {
  display: none;
  justify-content: center;
  margin: 0;
}

.hero-panel__title {
  font-size: 16px;
  line-height: 1.75;
  text-shadow: 2px 2px 0 var(--color-pink);
}

.hero-panel__lead {
  max-width: 46ch;
  color: var(--color-text-muted);
  font-size: 16px;
}

.hero-panel__actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  width: 100%;
}

.hero-panel__actions .btn--primary {
  width: calc(100% - 6px);
  margin-right: 6px;
}

.hero-panel__actions .btn--secondary {
  display: none;
}

.hero-panel__textlink {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  color: var(--color-cyan);
  font-weight: 700;
  font-size: 16px;
  text-decoration: underline;
  text-underline-offset: 4px;
}

.hero-panel__textlink img {
  width: 16px;
  height: 16px;
  transform: rotate(90deg);
}

.hero-panel__trust {
  display: none;
  width: 100%;
  padding-top: 12px;
  border-top: 2px solid var(--color-line);
  color: var(--color-text-muted);
  font-size: 13px;
}

.hero-map__trust {
  margin: 16px var(--gutter) 24px;
  color: var(--color-text-muted);
  font-size: 13px;
  text-align: center;
}

/* The hero map window. On phones the controls sit on top and the map shows
   the tall layout from y = 300 (the band above is empty). */

.hero-map .map {
  position: relative;
  height: 616px;
  margin-top: 16px;
  overflow: hidden;
}

.hero-map .map__stage {
  position: absolute;
  top: -204px;
  left: 50%;
  transform: translateX(-50%);
}

.map__ext {
  display: none;
}

.map__controls {
  position: absolute;
  top: 0;
  left: 50%;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border: 4px solid var(--color-line);
  background: var(--color-night);
  transform: translateX(-50%);
  transition: opacity 200ms steps(2);
}

.map--intro .map__controls {
  opacity: 0;
}

/* Dusk over the whole map window, then a dithered vignette framing it. */

.map__dusk {
  position: absolute;
  inset: 96px 0 0;
  z-index: 1;
  background: rgba(13, 10, 36, 0.3);
  pointer-events: none;
}

.map__vignette {
  position: absolute;
  inset: 96px 0 0;
  z-index: 1;
  pointer-events: none;
  --vignette: 24px;
  --vignette-dense: 8px;
}

.map__vignette-edge {
  position: absolute;
  background: repeating-conic-gradient(var(--color-night-deep) 0 25%, transparent 0 100%) 0 0 / 8px 8px;
}

.map__vignette-edge::before {
  content: "";
  position: absolute;
  background: repeating-conic-gradient(var(--color-night-deep) 0 25%, transparent 0 50%) 0 0 / 8px 8px;
}

.map__vignette-edge--l,
.map__vignette-edge--r {
  top: 0;
  bottom: 0;
  width: var(--vignette);
}

.map__vignette-edge--l {
  left: 0;
}

.map__vignette-edge--r {
  right: 0;
}

.map__vignette-edge--l::before,
.map__vignette-edge--r::before {
  top: 0;
  bottom: 0;
  width: var(--vignette-dense);
}

.map__vignette-edge--l::before {
  left: 0;
}

.map__vignette-edge--r::before {
  right: 0;
}

.map__vignette-edge--t,
.map__vignette-edge--b {
  left: 0;
  right: 0;
  height: 12px;
}

.map__vignette-edge--t {
  top: 0;
}

.map__vignette-edge--b {
  bottom: 0;
}

.map__stage--top {
  z-index: 2;
  pointer-events: none;
}

.map__stage--top .map__tag {
  pointer-events: auto;
}

@media (min-width: 640px) {
  .hero-panel {
    box-shadow: 8px 8px 0 var(--color-pink);
  }
}

/* Tablets: panel left, tall map right. */
@media (min-width: 720px) {
  .hero-map {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 390px;
    gap: 24px;
    align-items: start;
    padding: 24px 0 24px 24px;
  }

  .hero-panel {
    align-items: stretch;
    gap: 16px;
    width: auto;
    margin: 0 8px 0 0;
    padding: 20px;
    text-align: left;
  }

  .hero-panel .eyebrow {
    display: flex;
    justify-content: flex-start;
  }

  .hero-panel__actions {
    align-items: stretch;
    padding-right: 6px;
  }

  .hero-panel__actions .btn {
    width: 100%;
    margin-right: 0;
  }

  .hero-panel__actions .btn--secondary {
    display: inline-flex;
  }

  .hero-panel__textlink,
  .hero-map__trust {
    display: none;
  }

  .hero-panel__trust {
    display: block;
  }

  .hero-map .map {
    width: 390px;
    height: 640px;
    margin: 0;
  }

  .hero-map .map__stage {
    top: -300px;
  }

  .map__controls {
    top: auto;
    bottom: 20px;
  }

  .map__dusk,
  .map__vignette {
    inset: 0;
  }
}

/* Desktop: the wide map fills a hero sized to the screen. */
@media (min-width: 1024px) {
  .hero-map {
    display: block;
    height: clamp(692px, calc(100vh - var(--header-h) - 4px), 820px);
    height: clamp(692px, calc(100svh - var(--header-h) - 4px), 820px);
    padding: 0;
  }

  .hero-panel {
    position: absolute;
    top: 48px;
    left: 50%;
    align-items: center;
    gap: 20px;
    width: min(600px, calc(100% - 32px));
    margin: 0;
    padding: 32px;
    text-align: center;
    transform: translateX(-50%);
  }

  .hero-panel .eyebrow {
    justify-content: center;
  }

  .hero-panel__title {
    font-size: 24px;
    line-height: 1.6;
    text-shadow: 3px 3px 0 var(--color-pink);
  }

  .hero-panel__lead {
    font-size: 17px;
  }

  .hero-panel__actions {
    flex-flow: row wrap;
    justify-content: center;
    align-items: center;
    width: auto;
    padding-right: 0;
  }

  .hero-panel__actions .btn {
    width: auto;
  }

  .hero-panel__trust {
    padding-top: 16px;
  }

  /* The map element spans the hero; its only in-flow child is the control
     bar, which sticks to the bottom of the screen while the hero shows. */
  .hero-map .map {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: center;
    width: auto;
    height: auto;
    overflow: visible;
  }

  .hero-map .map__stage {
    top: auto;
    bottom: 0;
  }

  .map__controls {
    position: sticky;
    top: auto;
    bottom: 16px;
    left: auto;
    gap: 12px;
    margin-bottom: 20px;
    transform: none;
  }

  .map__dusk,
  .map__vignette {
    inset: 0;
  }

  .map__vignette {
    --vignette: 80px;
    --vignette-dense: 32px;
  }

  /* On screens wider than the 1440px map, carry the sea and the lower road
     out to the edges. */
  .map__ext {
    position: absolute;
    display: block;
  }

  .map__ext--sea {
    top: 0;
    right: 0;
    bottom: 0;
    left: calc(50% + 720px);
    background: var(--color-night-deep);
  }

  .map__ext--lane {
    bottom: 68px;
    left: 0;
    width: calc(50% - 720px);
    height: 16px;
    background:
      linear-gradient(var(--color-line) 6px, transparent 6px 10px, var(--color-line) 10px),
      repeating-linear-gradient(90deg, var(--color-line-strong) 0 12px, var(--color-line) 12px 28px);
  }
}

/* Shorter desktop screens: a compact panel so the stops stay clear of it. */
@media (min-width: 1024px) and (max-height: 895px) {
  .hero-panel {
    top: 24px;
    gap: 16px;
    width: min(640px, calc(100% - 32px));
    padding: 24px;
  }

  .hero-panel .eyebrow {
    display: none;
  }

  .hero-panel__trust {
    padding-top: 12px;
  }
}

/* ------------------------------------------------------- The mini map

   The 288×216 map in How it works. Its frame comes from sections.css. */

.map--mini {
  width: max-content;
}

.map--mini .map__stage {
  position: relative;
  overflow: hidden;
  background-color: var(--color-panel);
  background-image:
    linear-gradient(var(--color-panel) 14px, transparent 14px),
    linear-gradient(90deg, var(--color-line) 2px, transparent 2px);
  background-size: 16px 16px;
}

.map--mini .map__bubble {
  gap: 4px;
  width: 44px;
  height: 28px;
  transform-origin: 10px 30px;
}

.map--mini .map__bubble-dot {
  width: 4px;
  height: 4px;
}

.map--mini .map__bubble-tail {
  bottom: -8px;
  left: 4px;
  width: 4px;
  height: 4px;
}

.map--mini .map__parcel,
.map--mini .map__parcel img {
  width: 24px;
  height: 24px;
}

.map--mini .map__spark--1 {
  left: -8px;
}

.map--mini .map__spark--2 {
  right: -8px;
}

.map--mini .map__spark--3 {
  top: -8px;
  left: 10px;
}

.map--mini .map__ring {
  border-width: 2px;
}

/* ------------------------------------------------------ Scene elements */

.map__stage {
  overflow: hidden;
}

.map__stage > *,
.map__layer > * {
  position: absolute;
}

.map__stage img,
.map__stage svg {
  max-width: none;
}

.map__svg {
  pointer-events: none;
}

.map__district {
  border: 4px solid var(--color-line);
}

.map__district--home {
  background: #201550;
}

.map__district--market {
  background: repeating-conic-gradient(#1a1140 0 25%, var(--color-night) 0 50%) 0 0 / 16px 16px;
}

.map__district--depot {
  background: repeating-linear-gradient(45deg, rgba(255, 201, 74, 0.18) 0 8px, var(--color-night-deep) 8px 16px);
}

.map__district--apron {
  background: var(--color-night-deep);
}

.map__sea {
  border-left: 4px solid var(--color-line);
  background: var(--color-night-deep);
}

.map__wave,
.map__ripple {
  position: absolute;
  background: var(--color-cyan);
  opacity: 0.5;
}

.map__ripple {
  width: 16px;
  height: 4px;
  opacity: 0.6;
}

.map--mini .map__ripple {
  width: 8px;
  height: 2px;
}

.map__ripple--1 {
  top: 32%;
  left: 20%;
}

.map__ripple--2 {
  top: 64%;
  left: 56%;
}

.map__lane {
  background: var(--color-line);
}

.map__lane-dash {
  position: absolute;
  top: 6px;
  right: 0;
  left: 0;
  height: 4px;
  background: repeating-linear-gradient(90deg, var(--color-line-strong) 0 12px, transparent 12px 28px);
}

.map__lake {
  border: 4px solid var(--color-line);
  background: var(--color-night-deep);
}

.map--mini .map__lake {
  border-width: 2px;
}

.map__field {
  border: 4px solid var(--color-line);
  background: repeating-linear-gradient(90deg, #1f7a7a 0 8px, var(--color-panel) 8px 16px);
}

.map__sprite,
.map__courier-body {
  filter: drop-shadow(4px 4px 0 var(--color-night-deep));
}

.map--mini .map__sprite,
.map--mini .map__courier-body {
  filter: drop-shadow(2px 2px 0 var(--color-night-deep));
}

.map__stop {
  transform-origin: 50% 100%;
}

.map__village--a .map__roof {
  fill: var(--color-line-strong);
}

.map__village--b .map__roof {
  fill: #3a2e7a;
}

/* Dusk: an evening tint over the land; lights are drawn above it. */
.map__layer--dusk {
  background: rgba(13, 10, 36, 0.3);
  pointer-events: none;
}

.map__layer--lights {
  pointer-events: none;
}

.map__beacon {
  animation: map-beacon 1.6s steps(1) infinite;
}

/* Pause stops every moving part of the scene, the beacon included. */
.map--paused .map__beacon {
  animation-play-state: paused;
}

@keyframes map-beacon {
  50% {
    opacity: 0.35;
  }
}

.map__tag {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border: 2px solid var(--color-line-strong);
  background: var(--color-night);
  box-shadow: 0 0 0 4px rgba(51, 225, 255, 0.12);
  color: var(--color-text-muted);
  font-family: var(--font-pixel);
  font-size: 16px;
  line-height: 1;
  text-decoration: none;
  -webkit-font-smoothing: none;
}

.map__tag::before {
  content: "";
  width: 4px;
  height: 4px;
  background: var(--color-gold);
}

.map__tag:hover {
  border-color: var(--color-cyan);
  color: var(--color-text);
}

.map__ring {
  border: 4px dashed var(--color-gold);
  opacity: 0;
}

.map__plane,
.map__pop,
.map__drift {
  image-rendering: pixelated;
}

.map__plane {
  filter: drop-shadow(4px -4px 0 var(--color-night-deep));
  transform: rotate(90deg);
}

.map__pop {
  opacity: 0;
}

.map__bubble {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 64px;
  height: 40px;
  border: 4px solid var(--color-pink);
  background: var(--color-text);
  opacity: 0;
  transform-origin: 16px 44px;
}

.map__bubble-dot {
  width: 8px;
  height: 8px;
  background: var(--color-night);
}

.map__bubble-tail {
  position: absolute;
  bottom: -12px;
  left: 8px;
  width: 8px;
  height: 8px;
  background: var(--color-pink);
}

.map__parcel {
  width: 48px;
  height: 48px;
}

.map__parcel img {
  width: 48px;
  height: 48px;
}

.map__spark {
  position: absolute;
  width: 4px;
  height: 4px;
}

.map__spark--1 {
  top: 4px;
  left: -12px;
  background: var(--color-cyan);
}

.map__spark--2 {
  top: 12px;
  right: -12px;
  background: var(--color-gold);
}

.map__spark--3 {
  top: -12px;
  left: 20px;
  background: var(--color-text);
}

.map__courier-body {
  position: relative;
  width: 100%;
  height: 100%;
}

.map__courier-body svg {
  display: block;
}

.map__carry {
  position: absolute;
  top: 42%;
  left: 62%;
  width: 38%;
  height: 30%;
  border-left: 6px solid var(--color-pink);
  background: var(--color-gold);
  opacity: 0;
}

.map--mini .map__carry {
  border-left-width: 3px;
}

.map__cloud {
  width: 80px;
  height: 24px;
  opacity: 0.16;
}

.map__cloud::before,
.map__cloud::after {
  content: "";
  position: absolute;
  background: var(--color-text);
}

.map__cloud::before {
  top: 8px;
  left: 0;
  width: 100%;
  height: 16px;
}

.map__cloud::after {
  top: 0;
  left: 20px;
  width: 36px;
  height: 8px;
}

.map__cloud--2 {
  width: 64px;
  opacity: 0.14;
}

.map__cloud--2::after {
  left: 16px;
  width: 28px;
}

/* ------------------------------------------------- Step controls (B2)

   Buttons lift on hover, the icon pops 1.25× on click and settles. */

.map__button {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  padding: 0;
  border: 4px solid var(--color-line-strong);
  border-radius: 0;
  background: var(--color-night);
  cursor: pointer;
  transition:
    transform 80ms steps(2),
    box-shadow 80ms steps(2),
    border-color 80ms steps(2);
}

.map__button:hover {
  border-color: var(--color-cyan);
  box-shadow: 0 6px 0 var(--color-night-deep);
  transform: translateY(-4px);
}

.map__button:active {
  box-shadow: none;
  transform: translateY(0);
}

.map__button img {
  width: 32px;
  height: 32px;
  transition: transform 120ms steps(2);
}

.map__step[aria-current="step"] {
  border-color: var(--color-gold);
  background: var(--color-line);
  box-shadow: inset 0 -4px 0 var(--color-gold);
}

.map__step[aria-current="step"]:hover {
  box-shadow:
    inset 0 -4px 0 var(--color-gold),
    0 6px 0 var(--color-night-deep);
}

.map__step.is-popping img {
  transform: scale(1.25);
}

.map__divider {
  flex: none;
  width: 4px;
  height: 32px;
  background: var(--color-line);
}

.map__pause-icon {
  width: 18px;
  height: 20px;
  background: linear-gradient(90deg, var(--color-text) 0 6px, transparent 6px 12px, var(--color-text) 12px 18px);
}

.map__play-icon {
  display: none;
  width: 0;
  height: 0;
  margin-left: 4px;
  border-block: 10px solid transparent;
  border-left: 16px solid var(--color-text);
}

.map__pause.is-paused .map__pause-icon {
  display: none;
}

.map__pause.is-paused .map__play-icon {
  display: block;
}

@media (prefers-reduced-motion: reduce) {
  .map__button:hover,
  .map__button:active {
    transform: none;
  }

  .map__step.is-popping img {
    transform: none;
  }
}

/* ------------------------------------------------------ Review fixes */

/* Without script the map is never drawn, so its controls stay hidden. */
.hero-map .map:not(.map--ready) .map__controls {
  display: none;
}

/* Keep the hero buttons on one line in the narrow tablet panel. */
@media (min-width: 720px) and (max-width: 1023px) {
  .hero-panel__actions .btn {
    padding-inline: 12px;
    white-space: nowrap;
  }
}

.hero-panel__trust {
  text-wrap: balance;
}

/* Between 1024 and 1279px the map is cropped at the sides, so a narrower
   vignette keeps the house and runway clear of it. */
@media (min-width: 1024px) and (max-width: 1279px) {
  .map__vignette {
    --vignette: 24px;
    --vignette-dense: 8px;
  }
}

/* Past 1440px the sea carries on to the screen edge with its swell marks. */
@media (min-width: 1024px) {
  .map__ext--sea {
    background:
      linear-gradient(90deg, transparent 0 24px, rgba(51, 225, 255, 0.35) 24px 40px, transparent 40px) 0 88px / 100% 4px no-repeat,
      linear-gradient(90deg, transparent 0 72px, rgba(51, 225, 255, 0.3) 72px 84px, transparent 84px) 0 300px / 100% 4px no-repeat,
      linear-gradient(90deg, transparent 0 40px, rgba(51, 225, 255, 0.35) 40px 56px, transparent 56px) 0 520px / 100% 4px no-repeat,
      linear-gradient(90deg, transparent 0 120px, rgba(51, 225, 255, 0.3) 120px 132px, transparent 132px) 0 680px / 100% 4px no-repeat,
      var(--color-night-deep);
  }
}

@media (forced-colors: active) {
  .map__play-icon {
    border-top-color: Canvas;
    border-bottom-color: Canvas;
    border-left-color: ButtonText;
  }

  .map__pause-icon {
    forced-color-adjust: none;
    background: linear-gradient(90deg, ButtonText 0 6px, transparent 6px 12px, ButtonText 12px 18px);
  }

  .map__step[aria-current="step"] {
    outline: 4px solid Highlight;
    outline-offset: -8px;
  }
}
