/*
 * Alternative page layouts (see layouts.js).
 *
 * Everything here is scoped to html.layout-descent / html.layout-porthole
 * (both also carry .layout-alt), so the classic page is untouched.
 */

.story-q { display: none; }

/* ======================================================================
   Preview switcher (temporary, while a layout is being chosen)
   ====================================================================== */

.layout-switch {
  position: fixed;
  z-index: 2500;
  left: 50%;
  bottom: calc(10px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  display: flex;
  gap: 2px;
  padding: 3px;
  border-radius: 999px;
  background: rgba(8, 16, 25, 0.92);
  border: 1px solid var(--line-strong);
  box-shadow: 0 8px 26px rgba(0, 0, 0, 0.5);
  direction: ltr;
  white-space: nowrap;
}
.layout-switch a {
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  color: var(--dim);
  text-decoration: none;
}
.layout-switch a:hover { color: var(--text); }
.layout-switch a.active { background: var(--accent); color: var(--accent-ink); }
.layout-classic .layout-switch { bottom: auto; top: calc(78px + env(safe-area-inset-top, 0px)); }
.map-expanded .layout-switch { display: none; }

/* ======================================================================
   Shared by both alternatives: a page that scrolls
   ====================================================================== */

html.layout-alt, .layout-alt body { height: auto; min-height: 100%; }

.layout-alt .app {
  height: auto;
  min-height: 100dvh;
  overflow: visible;
}

.layout-alt .topbar,
.layout-alt .sheet-handle,
.layout-alt .panel-footer { display: none; }

.layout-alt .panel {
  position: static;
  inset: auto;
  width: auto;
  height: auto;
  max-height: none;
  display: block;
  background: none;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  transform: none !important;
  opacity: 1 !important;
  pointer-events: auto !important;
  transition: none;
}
.layout-alt .panel-scroll { overflow: visible; }

.layout-alt .story-q {
  display: block;
  margin: 0 0 12px;
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 600;
  line-height: 1.25;
  color: var(--text);
}
.layout-alt .story-q + .block-title { display: none; }

/* Help and language sit in the page corners. */
.page-corner {
  position: absolute;
  z-index: 30;
  top: calc(12px + var(--safe-top));
  inset-inline: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  pointer-events: none;
}
.page-corner > * { pointer-events: auto; }
.page-corner .icon-button,
.page-corner .lang-control select { background-color: rgba(8, 16, 25, 0.6); }

/* The hero is the top of the page, not a curtain over it. */
.layout-alt .hero,
.layout-alt .hero[hidden] {
  position: relative;
  inset: auto;
  z-index: auto;
  display: grid;
}
.layout-alt .hero.leaving { opacity: 1; pointer-events: auto; }

/* Map, taken out of the background and given a frame. */
.layout-alt #map { position: relative; inset: auto; }
.layout-alt .leaflet-top { top: 0; }
.layout-alt .leaflet-bottom.leaflet-right { bottom: 0; }

.map-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px 10px;
}

.layout-alt .map-legend {
  position: static;
  max-width: none;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 16px;
  box-shadow: none;
}
.layout-alt .map-legend[hidden] { display: none; }
.layout-alt .map-legend h4 { margin: 0; }
.layout-alt .map-legend .legend-row { margin-top: 0 !important; }

.map-expand {
  padding: 7px 13px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: var(--glass-solid);
  color: var(--text);
  font: inherit;
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.45);
  white-space: nowrap;
}
.map-expand:hover { border-color: var(--accent); }

/* "Big map": the classic full-screen view, for walking the field. */
html.map-expanded { overflow: hidden; }
html.map-expanded #map {
  position: fixed !important;
  inset: 0 !important;
  width: auto !important;
  height: auto !important;
  margin: 0 !important;
  border: 0 !important;
  border-radius: 0 !important;
  clip-path: none !important;
  z-index: 1500;
}
html.map-expanded .map-legend:not([hidden]) {
  position: fixed;
  z-index: 1600;
  inset-inline-end: 12px;
  bottom: 28px;
  display: block;
  max-width: 200px;
  background: var(--glass-solid);
}
html.map-expanded .map-legend h4 { margin-bottom: 6px; }
html.map-expanded .map-legend .legend-row { margin-top: 5px !important; }
html.map-expanded .page-corner { display: none; }

/* ======================================================================
   A. The descent
   ====================================================================== */

.layout-descent .app {
  background: linear-gradient(to bottom, #0a1520 0, #0b1b2a 55%, #0d211d 100%);
}

.layout-descent .hero { min-height: min(90dvh, 800px); }
.layout-descent .hero-sky::after {
  background:
    linear-gradient(to bottom, rgba(10, 21, 32, 0) 62%, #0a1520 100%),
    radial-gradient(120% 90% at 50% 38%, rgba(10,21,32,0) 0%, rgba(10,21,32,0.35) 55%, rgba(10,21,32,0.82) 100%),
    linear-gradient(to bottom, rgba(10,21,32,0.35), rgba(10,21,32,0.15) 40%, rgba(10,21,32,0.7));
}

.layout-descent .panel-scroll {
  position: relative;
  max-width: 640px;
  margin: 0 auto;
  padding: 8px 16px 96px;
  padding-inline-start: 56px;
}

.layout-descent .block,
.layout-descent .advanced {
  margin: 0 0 14px;
  padding: 16px 18px;
  background: rgba(13, 27, 41, 0.78);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.layout-descent .block:last-of-type { border-bottom: 1px solid var(--line); }
.layout-descent .step { position: relative; margin-bottom: 44px; }
.layout-descent .step:last-of-type { margin-bottom: 14px; }

/* Each question is a stop on the altitude line. */
.layout-descent .step::before {
  content: "";
  position: absolute;
  top: 21px;
  inset-inline-start: -36px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #0a1520;
  border: 2px solid var(--accent);
}

.descent-rail {
  position: absolute;
  inset-inline-start: 26px;
  width: 2px;
  border-radius: 2px;
  background: linear-gradient(to bottom, var(--accent), rgba(255, 255, 255, 0.28));
  pointer-events: none;
}
.descent-glider {
  position: absolute;
  left: 50%;
  top: 0;
  z-index: 2;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.descent-canopy {
  font-size: 24px;
  line-height: 1;
  filter: drop-shadow(0 2px 5px rgba(0, 0, 0, 0.7));
}
.descent-alt {
  padding: 1px 5px;
  border-radius: 6px;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 10px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  direction: ltr;
}
.descent-alt[hidden] { display: none; }

/* The ground: wider than the column of questions, because it is the place
   you actually look. */
.layout-descent .ground {
  --ground: min(1100px, 100vw - 32px);
  width: var(--ground);
  margin-block: 0 22px;
  margin-inline-start: calc((100% - var(--ground)) / 2 - 20px);
}
.layout-descent .map-tools {
  padding: 10px 12px;
  background: var(--glass-solid);
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: 24px 24px 0 0;
}
.layout-descent #map {
  height: clamp(340px, 62dvh, 640px);
  border: 1px solid var(--line);
  border-radius: 0 0 24px 24px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
}
.layout-descent .map-legend {
  margin-top: 10px;
  background: rgba(13, 27, 41, 0.78);
}

/* ======================================================================
   C. The porthole
   ====================================================================== */

.layout-porthole .hero {
  display: block;
  min-height: 0;
  overflow: visible;
  padding-top: calc(52px + var(--safe-top));
  text-align: center;
}
.layout-porthole .hero[hidden] { display: block; }
/* The sky stays put behind the whole page. */
.layout-porthole .hero-sky { position: fixed; z-index: 0; }
.layout-porthole .hero-inner {
  z-index: 1;
  margin: 0 auto;
  padding: 0 20px 6px;
  animation: none;
}
.layout-porthole .hero-brand { margin-bottom: 8px; }
.layout-porthole .hero-headline { font-size: clamp(26px, 4vw, 40px); margin-bottom: 6px; }
.layout-porthole .hero-sub { max-width: none; margin-bottom: 0; font-size: 15px; }
.layout-porthole .hero-steps,
.layout-porthole .hero-cta,
.layout-porthole .hero-free { display: none; }

.porthole-stage {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 18px;
  max-width: 1080px;
  margin: 0 auto;
  padding: 4px 16px 96px;
}
.porthole-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
@media (min-width: 980px) {
  .porthole-stage { grid-template-columns: minmax(0, 1fr) 380px; align-items: start; gap: 28px; }
  .porthole-col { position: sticky; top: min(8px, 100dvh - var(--col-height, 0px) - 8px); }
}
html.map-expanded .porthole-col { z-index: 3000; }

.porthole {
  --d: min(50dvh, 500px, (100vw - 32px) / 1.3);
  position: relative;
  width: var(--d);
  height: var(--d);
  margin: calc(var(--d) * 0.14) calc(var(--d) * 0.14) calc(var(--d) * 0.13);
  border-radius: 50%;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.55);
}
.layout-porthole #map {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  clip-path: circle(50%);
}

.wind-ring {
  position: absolute;
  inset: -13%;
  width: 126%;
  height: 126%;
  overflow: visible;
  pointer-events: none;
}
html.map-expanded .wind-ring { display: none; }
.ring-bezel { fill: none; stroke: #0d1b29; stroke-width: 8; }
.ring-edge { fill: none; stroke: var(--accent); stroke-width: 1.2; }
.ring-tick { stroke: rgba(255, 255, 255, 0.55); stroke-width: 0.7; stroke-linecap: round; }
.ring-tick.major { stroke: #fff; stroke-width: 1.1; }
.ring-letter {
  fill: #fff;
  font-family: var(--font-display);
  font-size: 9px;
  font-weight: 700;
  text-anchor: middle;
  dominant-baseline: central;
  paint-order: stroke;
  stroke: rgba(10, 21, 32, 0.7);
  stroke-width: 2.5px;
}
.ring-wind { stroke: var(--accent); stroke-width: 2.2; stroke-linecap: round; }
.ring-wind-tip { fill: var(--accent); }
.ring-gear { stroke: #fff; stroke-width: 1.6; }

/* Inside a circle the corners are gone, so Leaflet's furniture moves to the
   four points of the compass. */
html.layout-porthole:not(.map-expanded) .leaflet-top.leaflet-left {
  top: 9%; left: 50%; transform: translateX(-50%);
}
html.layout-porthole:not(.map-expanded) .leaflet-top.leaflet-right {
  top: 50%; right: 2px; transform: translateY(-50%);
}
html.layout-porthole:not(.map-expanded) .leaflet-bottom.leaflet-left {
  left: 50%; bottom: 12%; transform: translateX(-50%);
}
html.layout-porthole:not(.map-expanded) .leaflet-bottom.leaflet-right {
  right: auto; left: 50%; bottom: 3.5%; transform: translateX(-50%);
}
html.layout-porthole:not(.map-expanded) .leaflet-control { margin: 0 6px; }
html.layout-porthole:not(.map-expanded) .leaflet-control-attribution {
  max-width: calc(var(--d) * 0.4);
  border-radius: 6px;
  font-size: 8.5px !important;
  line-height: 1.25;
  text-align: center;
  white-space: normal;
}

.ring-caption {
  max-width: 400px;
  margin: 0;
  padding: 5px 12px;
  border-radius: 999px;
  background: rgba(10, 21, 32, 0.7);
  font-size: 12px;
  color: var(--text);
  text-align: center;
}
.ring-caption[hidden] { display: none; }

.layout-porthole .map-tools {
  padding: 8px 10px;
  border-radius: 999px;
  background: rgba(10, 21, 32, 0.78);
  border: 1px solid var(--line);
}
.porthole-col .block,
.layout-porthole .map-legend {
  width: min(100%, 440px);
  padding: 13px 16px;
  background: rgba(10, 21, 32, 0.82);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.porthole-col .story-q { text-align: center; }
.porthole-col .hint { text-align: center; margin: -6px 0 10px; }
.porthole-col .coord input {
  font-family: var(--font-display);
  font-size: 17px;
  text-align: center;
}

.layout-porthole .panel {
  background: rgba(10, 21, 32, 0.84);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 14px 44px rgba(0, 0, 0, 0.45);
}
.layout-porthole .panel-scroll { padding: 4px 18px 18px; }

@media (max-width: 560px) {
  .layout-porthole .map-tools { border-radius: 20px; }
  .layout-descent .map-tools { border-radius: 18px 18px 0 0; }
  .layout-descent #map { border-radius: 0 0 18px 18px; }
}
