/* R1 landing (spec §6.1): Field Journal by day, Night Atlas by night (ws-ui-v2).
   The globe column is sticky on desktop and unrolls into a flat map across the steps;
   phones read top to bottom. Every motion stops under reduced motion. */

/* Full width so the paper reaches both edges; the content column stays 84 rem.
   The bar is the page banner (outside main) and shares the column. */
.ws-landing,
.ws-landing__bar {
  --landing-gutter: clamp(1.25rem, 4vw, 3rem);
  --landing-side: max(var(--landing-gutter), calc((100% - 84rem) / 2));
  padding-right: max(var(--landing-side), env(safe-area-inset-right, 0px));
  padding-left: max(var(--landing-side), env(safe-area-inset-left, 0px));
  color: var(--ws-ink);
}

/* flow-root: the stage's top margin must not escape main and show body behind it. */
.ws-landing {
  display: flow-root;
  min-height: 100vh;
  min-height: 100dvh;
  padding-bottom: max(2.5rem, env(safe-area-inset-bottom, 0px));
  overflow-x: clip;
}

:is(.ws-landing, .ws-landing__bar) a:not(.button) {
  color: var(--ws-accent-text);
  font-weight: var(--ws-weight-bold);
  text-underline-offset: 0.2em;
}

:is(.ws-landing, .ws-landing__bar) :where(a, button, [tabindex]):focus-visible {
  outline: 3px solid var(--ws-focus);
  outline-offset: 3px;
}

:is(.ws-landing, .ws-landing__bar) .button {
  display: inline-flex;
  min-height: 2.75rem;
  align-items: center;
  justify-content: center;
  padding: 0.8rem 1.4rem;
  color: var(--ws-on-accent);
  font: var(--ws-weight-bold) 1rem / 1 var(--ws-font-ui);
  text-decoration: none;
  background: var(--ws-accent-text);
  border: 1px solid transparent;
  border-radius: 999px;
  transition: transform var(--ws-t-fast) var(--ws-ease-out), background-color var(--ws-t-fast) ease;
}

.ws-landing .button--secondary {
  color: var(--ws-ink);
  background: transparent;
  border-color: var(--ws-muted);
}

/* Bar: wordmark, language and account. */
.ws-landing__bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1.25rem;
  padding-top: max(var(--landing-gutter), env(safe-area-inset-top, 0px));
}

.ws-landing__brand {
  display: inline-flex;
  min-height: 2.75rem;
  align-items: center;
  margin-right: auto;
  border-radius: 0.5rem;
}

.ws-landing__brand .ws-logo {
  display: block;
  width: clamp(11rem, 20vw, 14rem);
  height: auto;
}

.ws-landing__langs {
  display: flex;
  gap: 0.25rem;
  padding: 0.25rem;
  border: 1px solid var(--ws-line);
  border-radius: 999px;
}

.ws-landing__bar .ws-landing__langs a {
  display: grid;
  min-width: 2.75rem;
  min-height: 2.75rem;
  place-items: center;
  color: var(--ws-muted);
  font: var(--ws-weight-bold) 0.8rem / 1 var(--ws-font-mono);
  letter-spacing: 0.08em;
  text-decoration: none;
  border-radius: 999px;
}

.ws-landing__bar .ws-landing__langs a[aria-current="page"] {
  color: var(--ws-paper);
  background: var(--ws-ink);
}

/* Phones: the hero carries both calls to action, so the bar keeps brand and language. */
@media (max-width: 39.99rem) {
  .ws-landing__account {
    display: none;
  }
}

.ws-landing__signin {
  display: inline-flex;
  min-height: 2.75rem;
  align-items: center;
  padding-inline: 0.5rem;
}

/* Stage: hero, globe and steps. */
.ws-landing__stage {
  display: grid;
  /* minmax(0, 1fr): enlarged text wraps inside the screen instead of widening the column (Codex R3-01). */
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas: "hero" "globe" "steps";
  gap: clamp(2rem, 6vw, 4rem);
  margin-top: clamp(1.5rem, min(8vw, 6vh), 5rem);
}

.ws-landing__hero {
  grid-area: hero;
}

.ws-landing__eyebrow {
  margin: 0 0 0.85rem;
  color: var(--ws-accent-text);
  font: var(--ws-weight-bold) 0.78rem / 1.3 var(--ws-font-mono);
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

/* Sized by width and height, so the call to action stays above the fold on laptops. */
.ws-landing h1 {
  max-width: 13ch;
  margin: 0;
  font: var(--ws-weight-bold) clamp(2.5rem, min(7.4vw, 10.5vh), 5.75rem) / 0.98 var(--ws-font-display);
  letter-spacing: var(--ws-tracking-tight);
  text-wrap: balance;
  overflow-wrap: anywhere;
}

/* A word wider than its column breaks rather than being clipped (200 % text; Codex R3-01). */
.ws-landing :is(p, h2, h3, figcaption, li) {
  overflow-wrap: anywhere;
}

/* One word in the logo's terracotta (as "Stamped" in the wordmark). The heading is
   at least 40 px, so 3.3:1 on paper meets WCAG AA for large text. */
.ws-landing__accent {
  color: #df5637;
}

.ws-landing__lead {
  max-width: 36rem;
  margin: 1.25rem 0 0;
  color: var(--ws-ink-soft);
  font-size: clamp(1.05rem, 1.6vw, 1.25rem);
  line-height: 1.6;
}

.ws-landing__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1.75rem;
}

/* Globe: its still (the same render) until the live map has painted, in one square box. */
.ws-landing__globe {
  grid-area: globe;
  margin: 0;
}

.ws-landing__sphere {
  position: relative;
  width: min(100%, 36rem);
  aspect-ratio: 1;
  margin-inline: auto;
}

.ws-landing__poster,
.ws-landing__map {
  position: absolute;
  inset: 0;
}

.ws-landing__poster img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.ws-landing__map {
  overflow: hidden;
  border-radius: 1.75rem;
  opacity: 0;
  transition: opacity var(--ws-t-hero) var(--ws-ease-out);
}

[data-globe="ready"] .ws-landing__map {
  opacity: 1;
}

/* The live globe fades in over its still, which leaves only once it is covered. */
[data-globe="ready"] .ws-landing__poster {
  visibility: hidden;
  transition: visibility 0s var(--ws-t-hero);
}

[data-globe="loading"] .ws-landing__caption {
  visibility: hidden;
}

/* The few MapLibre rules the landing needs (its 81 KB stylesheet is not loaded here). */
.ws-landing__map .maplibregl-canvas {
  position: absolute;
  top: 0;
  left: 0;
}

.ws-landing__map .maplibregl-canvas-container.maplibregl-interactive {
  cursor: grab;
}

.ws-landing__map .maplibregl-marker {
  position: absolute;
  top: 0;
  left: 0;
  will-change: transform;
}

.ws-landing__pin {
  pointer-events: none;
}

.ws-landing__pin > span {
  display: grid;
  width: 2.6rem;
  aspect-ratio: 1;
  place-items: center;
  color: var(--ws-status-visited);
  font: var(--ws-weight-bold) 0.8rem / 1 var(--ws-font-mono);
  background: color-mix(in srgb, var(--ws-surface) 86%, transparent);
  border: 2px solid currentColor;
  border-radius: 50%;
  box-shadow: inset 0 0 0 2px var(--ws-surface), inset 0 0 0 3.5px currentColor;
  rotate: -8deg;
}

.ws-landing__caption[hidden] {
  display: none;
}

.ws-landing__caption {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.5rem 0.75rem;
  max-width: 34rem;
  margin: 1rem auto 0;
  color: var(--ws-muted);
  font-size: 0.95rem;
  line-height: 1.5;
  text-align: center;
}

.ws-landing__badge {
  padding: 0.2rem 0.6rem;
  color: var(--ws-accent-text);
  font: var(--ws-weight-bold) 0.72rem / 1.3 var(--ws-font-mono);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  border: 1.5px dashed currentColor;
  border-radius: 999px;
}

.ws-landing__tally {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--ws-ink);
  font: var(--ws-weight-bold) 0.9rem / 1.3 var(--ws-font-mono);
}

.ws-landing__tally[hidden] {
  display: none;
}

.ws-landing__clear {
  min-height: 2.75rem;
  padding: 0 0.85rem;
  color: var(--ws-ink);
  font: var(--ws-weight-bold) 0.85rem / 1 var(--ws-font-ui);
  background: transparent;
  border: 1px solid var(--ws-muted);
  border-radius: 999px;
  cursor: pointer;
}

/* Steps: three journal entries with stamped numbers. */
.ws-landing__steps {
  grid-area: steps;
}

.ws-landing h2 {
  margin: 0;
  font: var(--ws-weight-bold) clamp(1.75rem, 3.4vw, 2.6rem) / 1.08 var(--ws-font-display);
  letter-spacing: var(--ws-tracking-tight);
}

.ws-landing__steps ol {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1rem;
  margin: 1.5rem 0 0;
  padding: 0;
  list-style: none;
}

.ws-landing__step {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  column-gap: 1rem;
  padding: 1.25rem;
  background: var(--ws-surface);
  border: 1px solid var(--ws-line);
  border-radius: 1.25rem;
}

.ws-landing__step-mark {
  display: grid;
  grid-row: span 2;
  width: 2.75rem;
  aspect-ratio: 1;
  place-items: center;
  color: var(--ws-accent-text);
  font: var(--ws-weight-bold) 1rem / 1 var(--ws-font-mono);
  border: 2px solid currentColor;
  border-radius: 50%;
  box-shadow: inset 0 0 0 2px var(--ws-surface), inset 0 0 0 3.5px currentColor;
  rotate: -8deg;
}

.ws-landing__step h3 {
  margin: 0.15rem 0 0;
  font: var(--ws-weight-bold) 1.2rem / 1.25 var(--ws-font-ui);
}

.ws-landing__step p {
  margin: 0.35rem 0 0;
  color: var(--ws-ink-soft);
  line-height: 1.55;
}

/* Privacy and the atlas: journal pages under the stage. */
.ws-landing__privacy,
.ws-landing__atlas {
  max-width: 52rem;
  margin: clamp(3rem, 8vw, 5.5rem) auto 0;
}

.ws-landing__privacy {
  padding: clamp(1.5rem, 4vw, 2.5rem);
  background: var(--ws-surface);
  border: 1px solid var(--ws-line);
  border-radius: 1.5rem;
}

.ws-landing__privacy p,
.ws-landing__atlas p {
  max-width: 42rem;
  margin: 0.85rem 0 0;
  color: var(--ws-ink-soft);
  font-size: 1.05rem;
  line-height: 1.65;
}

.ws-landing__atlas ul {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 12rem), 1fr));
  gap: 0.75rem;
  margin: 1.5rem 0 0;
  padding: 0;
  list-style: none;
}

.ws-landing__atlas li {
  padding: 1.1rem 1.25rem;
  color: var(--ws-ink-soft);
  background: var(--ws-paper-strong);
  border: 1.5px dashed var(--ws-line-strong);
  border-radius: 1rem;
}

.ws-landing__atlas strong {
  display: block;
  color: var(--ws-ink);
  font: var(--ws-weight-bold) clamp(1.9rem, 4vw, 2.6rem) / 1.05 var(--ws-font-display);
  letter-spacing: var(--ws-tracking-tight);
}

.ws-landing__footer {
  display: grid;
  justify-items: center;
  gap: 1.25rem;
  margin-top: clamp(3rem, 8vw, 5rem);
  padding-top: 2rem;
  border-top: 1px solid var(--ws-line);
  text-align: center;
}

.ws-landing__sources {
  margin: 0;
  color: var(--ws-muted);
  font-size: 0.85rem;
}

@media (hover: hover) {
  :is(.ws-landing, .ws-landing__bar) .button:hover {
    transform: translateY(-2px);
  }

  .ws-landing .button--secondary:hover,
  .ws-landing__clear:hover {
    background: var(--ws-paper-strong);
  }
}

/* Desktop: copy and steps on the left, the sticky globe on the right. */
@media (min-width: 64rem) {
  .ws-landing__stage {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr);
    grid-template-areas: "hero globe" "steps globe";
    align-items: start;
    column-gap: clamp(2.5rem, 5vw, 5rem);
  }

  .ws-landing__hero {
    align-self: center;
    padding-block: clamp(1rem, 5vh, 4rem);
  }

  .ws-landing__globe {
    position: sticky;
    top: max(1.5rem, calc(50vh - 20rem));
    align-self: start;
  }

  /* The globe, its caption and the tally fit one screen while the column sticks. */
  .ws-landing__sphere {
    width: min(100%, 38rem, calc(100vh - 14.5rem));
  }
}

/* Motion: steps rise into place as they scroll in; with time to unroll the globe. */
@media (min-width: 64rem) and (prefers-reduced-motion: no-preference) {
  .ws-landing__stage:has([data-globe="ready"]) .ws-landing__steps ol {
    position: relative;
    gap: min(24vh, 14rem);
    padding-block: min(10vh, 6rem) min(26vh, 16rem);
  }

  /* The route between the stamps: dashes flow down the gaps (scroll on), and the
     travelled part draws in solid ink as the steps pass. Cards sit above it. */
  .ws-landing__stage:has([data-globe="ready"]) .ws-landing__steps ol::before,
  .ws-landing__stage:has([data-globe="ready"]) .ws-landing__steps ol::after {
    position: absolute;
    top: calc(min(10vh, 6rem) + 3rem);
    bottom: calc(min(26vh, 16rem) + 3rem);
    left: calc(2.625rem - 1px);
    width: 2px;
    content: "";
  }

  .ws-landing__stage:has([data-globe="ready"]) .ws-landing__steps ol::before {
    background: repeating-linear-gradient(to bottom, var(--ws-accent-text) 0 0.5rem, transparent 0.5rem 1rem);
    opacity: 0.45;
    animation: ws-landing-route 1.1s linear infinite;
  }

  .ws-landing__stage:has([data-globe="ready"]) .ws-landing__steps ol::after {
    background: var(--ws-accent-text);
    transform-origin: top;
    animation: ws-landing-draw linear both;
    animation-range: entry 35% exit 55%;
    animation-timeline: view();
  }

  .ws-landing__stage:has([data-globe="ready"]) .ws-landing__step {
    position: relative;
    z-index: 1;
  }

  /* A chevron under each entry bobs along the route: there is more below. */
  .ws-landing__stage:has([data-globe="ready"]) .ws-landing__step:not(:last-child)::after {
    position: absolute;
    top: calc(100% + min(9vh, 5rem));
    left: calc(2.625rem - 0.45rem);
    width: 0.9rem;
    height: 0.9rem;
    content: "";
    border-right: 2.5px solid var(--ws-accent-text);
    border-bottom: 2.5px solid var(--ws-accent-text);
    background: var(--ws-paper);
    box-shadow: 0 0 0 0.35rem var(--ws-paper);
    rotate: 45deg;
    animation: ws-landing-cue 1.6s var(--ws-ease-out) infinite;
  }
}

@keyframes ws-landing-route {
  to {
    background-position: 0 1rem;
  }
}

@keyframes ws-landing-draw {
  from {
    transform: scaleY(0);
  }
}

@keyframes ws-landing-cue {
  0%,
  100% {
    translate: 0 -0.4rem;
    opacity: 0.55;
  }

  50% {
    translate: 0 0.5rem;
    opacity: 1;
  }
}

@media (prefers-reduced-motion: no-preference) {
  .ws-landing__pin > span {
    animation: ws-landing-stamp var(--ws-t-slow) var(--ws-spring) both;
  }

  @supports (animation-timeline: view()) {
    .ws-landing__step {
      animation: ws-landing-rise linear both;
      animation-range: entry 5% cover 30%;
      animation-timeline: view();
    }
  }
}

@keyframes ws-landing-stamp {
  from {
    opacity: 0;
    scale: 1.8;
    rotate: -30deg;
  }
}

@keyframes ws-landing-rise {
  from {
    opacity: 0;
    translate: 0 2rem;
  }
}

@media (prefers-color-scheme: dark) {
  /* Night Atlas: a faint warm halo keeps the dark globe apart from the night paper. */
  .ws-landing__sphere::before {
    position: absolute;
    inset: 4%;
    content: "";
    background: radial-gradient(circle, rgb(242 166 90 / 14%) 0 58%, transparent 71%);
    border-radius: 50%;
  }
}

@media (prefers-reduced-motion: reduce) {
  .ws-landing .button,
  .ws-landing__map,
  .ws-landing__poster {
    transition: none;
  }
}

@media (forced-colors: active) {
  .ws-landing__step,
  .ws-landing__privacy,
  .ws-landing__atlas li {
    border: 1px solid CanvasText;
  }

  .ws-landing__bar .ws-landing__langs a[aria-current="page"] {
    outline: 2px solid Highlight;
  }

  :is(.ws-landing, .ws-landing__bar) .button:not(.button--secondary) {
    border-width: 3px;
  }
}

@media print {
  .ws-landing__globe,
  .ws-landing__bar nav {
    display: none;
  }

  .ws-landing__step {
    animation: none;
  }

  :is(.ws-landing, .ws-landing__bar) .button {
    color: #000;
    background: none;
    border: 1px solid #000;
  }
}

.ws-landing__legal {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.25rem;
}

.ws-landing__legal a {
  display: inline-flex;
  min-height: 2.75rem;
  align-items: center;
  color: inherit;
}

/* Phones: a sideways swipe turns the globe (landing.js), up and down scroll the page. */
.ws-landing__map .maplibregl-canvas-container,
.ws-landing__map canvas {
  touch-action: pan-y;
}

/* Native disclosures keep the short product help available without JavaScript. */
.ws-landing__help {
  margin-block: clamp(2rem, 5vw, 4rem);
  max-width: 70rem;
}

.ws-landing__help h2 {
  margin-block-end: 1rem;
}

.ws-landing__help details {
  border-block-end: 1px solid var(--ws-line);
}

.ws-landing__help summary {
  min-height: 2.75rem;
  padding-block: 0.8rem;
  font-weight: var(--ws-weight-bold);
  line-height: 1.5;
  cursor: pointer;
}

.ws-landing__help summary:focus-visible {
  outline: 3px solid var(--ws-focus);
  outline-offset: 3px;
}

.ws-landing__help p {
  max-width: 68ch;
  margin-block: 0 1.25rem;
  line-height: 1.6;
}

.ws-landing__sources {
  padding: 0;
  list-style: none;
}

.ws-landing__sources a {
  display: inline-flex;
  align-items: center;
  min-height: 2.75rem;
}

@media (forced-colors: active) {
  .ws-landing__help details {
    border-color: CanvasText;
  }
}
