/* ==============================================
   FRONTIER TRAILS — frontier.css
   /the-frontier/: two frames.
     1. The intro: a few lines about Spain that make you ask "where?"
        (reuses the homepage's hook section).
     2. The map, clean, with the list of four beside it. Pick one and it opens.
   Two map modes, switched by body.has-map (set in js/frontier.js):
     · map mode — live 3D map filling the second frame; scrolling snaps
       from the intro onto it. Screens at least 900 x 560 and wider than
       tall (desktops, laptops, tablets on their side).
     · static mode (default) — the baked relief image, with the list as
       plain links: phones, upright tablets, reduced motion, no JS/WebGL.
   ============================================== */

/* ── 1. The intro ── */
/* At least one screen tall, measured without the phone's browser bars
   (svh), so "Scroll" isn't hidden under them. On short screens (a phone
   on its side) it grows with the text instead of cutting it off. */
.frontier-hook {
  isolation: isolate;
  height: auto;
  min-height: 100vh;
  min-height: 100svh;
  padding-top: 5.5rem;
  padding-bottom: 5.5rem;
}
/* A faint relief of Spain behind the words: a hint of what's below. */
.frontier-hook::before {
  content: '';
  position: absolute;
  inset: -10% -5%;
  z-index: -1;
  background: url('/img/relief-spain.webp') no-repeat 62% 40% / cover;
  opacity: 0.09;   /* the relief is brighter since 2026-11-17 */
  -webkit-mask-image: radial-gradient(ellipse 60% 60% at 60% 45%, #000 30%, transparent 80%);
  mask-image: radial-gradient(ellipse 60% 60% at 60% 45%, #000 30%, transparent 80%);
}
.frontier-hook-label { margin-bottom: 2rem; }
.frontier-hook-ask {
  margin-top: 2.6rem;
  font-family: var(--font-display);
  font-style: italic;
  font-size: clamp(1.4rem, 2vw, 2rem);
  line-height: 1.3;
  color: var(--accent);
}
/* The lines arrive one by one. */
.frontier-hook .hook-inner > * { opacity: 0; animation: fade-up 0.9s var(--ease-out) forwards; }
.frontier-hook .frontier-hook-label { animation-delay: 0.2s; }
.frontier-hook .hook-heading        { animation-delay: 0.45s; }
.frontier-hook .hook-sub            { animation-delay: 0.9s; }
.frontier-hook .frontier-hook-ask   { animation-delay: 1.5s; }

/* The scroll cue: centred, and a real link down to the map. */
.frontier-scroll-cue {
  right: auto;
  left: 50%;
  bottom: 4vh;
  margin-left: -1.5rem;
  width: 3rem;
  padding: 0.5rem 0;
  animation-delay: 2.2s;
}
.frontier-scroll-cue:hover .scroll-cue-label { color: var(--accent); }

/* ── 2. The map, static mode (the default the HTML ships with) ── */
/* Phones, tablets upright, reduced motion: the map image, then the list,
   together about one screen. */
.frontier-stage {
  position: relative;
  background: #000;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 1.6rem;
  min-height: 100vh;
  min-height: 100svh;
  padding: 4.5rem clamp(1rem, 4vw, 3rem) 1.5rem;
}
.frontier-map,
.frontier-shade,
.frontier-detail { display: none; }

.frontier-static { order: 1; }
.static-map { position: relative; max-width: 1100px; width: 100%; margin: 0 auto; }
.static-map img {
  display: block; width: 100%; height: auto;
  /* The baked relief stops in straight lines (France, Africa); fade all
     four edges into the page. */
  -webkit-mask-image:
    linear-gradient(90deg, transparent, #000 9%, #000 91%, transparent),
    linear-gradient(180deg, transparent, #000 9%, #000 91%, transparent);
  -webkit-mask-composite: source-in;
  mask-image:
    linear-gradient(90deg, transparent, #000 9%, #000 91%, transparent),
    linear-gradient(180deg, transparent, #000 9%, #000 91%, transparent);
  mask-composite: intersect;
}
.frontier-legend { order: 2; max-width: 1100px; width: 100%; margin: 0 auto; }
.frontier-credits { order: 4; max-width: 1100px; width: 100%; margin: 0 auto; }

/* Tablets upright: keep the map and the list in one screen. */
@media (min-width: 600px) and (orientation: portrait) {
  .static-map { max-width: min(100%, calc((100svh - 30rem) * 1.225)); }
  .frontier-legend,
  .frontier-credits { max-width: 520px; }
}

/* A phone or small tablet on its side: map left, list right. */
@media (orientation: landscape) and (max-height: 700px) {
  .frontier-stage {
    display: grid;
    grid-template-columns: minmax(0, 1.35fr) minmax(220px, 1fr);
    grid-template-areas: 'map list' 'credits credits';
    align-items: center;
    column-gap: clamp(1.5rem, 4vw, 3rem);
    row-gap: 0.5rem;
    padding-top: 4rem;
  }
  .frontier-static { grid-area: map; }
  .static-map img { max-height: calc(100svh - 7rem); width: auto; max-width: 100%; margin: 0 auto; }
  .frontier-legend { grid-area: list; }
  .frontier-credits { grid-area: credits; }
}

/* The map itself stays clean: nothing written or drawn on it (Tom,
   2026-11-17). The list below is how you pick a landscape. */

/* ── "Where do you want to go?": the four, by name ── */
.frontier-legend { display: flex; flex-direction: column; }
.frontier-legend-title {
  order: 0;
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 400;
  font-size: clamp(1.7rem, 2.4vw, 2.2rem);
  line-height: 1.1;
  color: var(--text);
  text-wrap: balance;
}
.frontier-hint {
  order: 1;
  margin: 0.6rem 0 0.9rem;
  padding-bottom: 0.6rem;
  border-bottom: 1px solid rgba(240, 235, 224, 0.22);
  font-family: var(--font-mono);
  font-size: 0.64rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--accent);
}
.frontier-legend ol { order: 2; list-style: none; }
.frontier-legend a,
.frontier-legend .legend-item {   /* a name whose page doesn't exist yet */
  display: flex;
  align-items: baseline;
  gap: 0.9rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--rule);
  color: var(--text-secondary);
  transition: color 0.2s ease, padding 0.3s var(--ease-out);
}
.frontier-legend a:hover,
.frontier-legend a:focus-visible,
.frontier-legend a.is-hover,
body.has-map .frontier-legend .legend-item:hover,
body.has-map .frontier-legend .legend-item:focus-visible,
body.has-map .frontier-legend .legend-item.is-hover { color: var(--accent); padding-left: 0.35rem; }
body.has-map .frontier-legend .legend-item { cursor: pointer; }
.legend-num { font-family: var(--font-mono); font-size: 0.66rem; letter-spacing: 0.14em; color: var(--text-muted); }
.legend-name { font-family: var(--font-display); font-size: 1.18rem; line-height: 1.25; }

/* ── Credits: required, kept small ── */
.frontier-credits { font-family: var(--font-mono); font-size: 0.62rem; letter-spacing: 0.12em; color: var(--text-muted); }
.frontier-credits summary { cursor: pointer; text-transform: uppercase; padding: 0.6rem 0; list-style: none; }
.frontier-credits summary::-webkit-details-marker { display: none; }
.frontier-credits summary:hover { color: var(--text-secondary); }
.frontier-credits-body { line-height: 1.7; letter-spacing: 0.02em; text-transform: none; font-family: var(--font-body); font-size: 0.74rem; }
.frontier-credits-body p, .frontier-credits-body li { margin-bottom: 0.35rem; }
.frontier-credits-body ul { list-style: none; }
.frontier-credits-body a { color: var(--text-secondary); text-decoration: underline; }

/* ── Map mode: the second frame, full screen ── */
/* Scrolling snaps between the two frames: one flick and you're on the map. */
html:has(body.frontier-page.has-map) { scroll-snap-type: y mandatory; }
body.has-map .frontier-hook,
body.has-map .frontier-stage { scroll-snap-align: start; }

body.has-map .frontier-static { display: none; }

body.has-map .frontier-stage {
  display: block;
  height: 100vh;
  height: 100dvh;
  min-height: 520px;
  padding: 0;
  overflow: hidden;
}
body.has-map .frontier-map { display: block; position: absolute; inset: 0; }

/* The map's loader covers this frame only, so the intro can be read
   while the tiles warm up. */
.frontier-page #loader { position: absolute; z-index: 5; }

/* Darkens the top (so the intro flows into the map), and the right under
   the list, so type stays readable. */
body.has-map .frontier-shade {
  display: block;
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(180deg, #000 0%, rgba(0, 0, 0, 0) 18%),
    linear-gradient(270deg, rgba(0, 0, 0, 0.7) 0%, rgba(0, 0, 0, 0.25) 24%, rgba(0, 0, 0, 0) 40%);
  transition: opacity 0.6s ease;
}

/* The list grows a little on big screens, so it doesn't look lost on a
   wide monitor, and sits a bit higher on short ones. */
body.has-map .frontier-legend {
  position: absolute;
  right: clamp(1rem, 4vw, 3rem);
  bottom: clamp(2.2rem, 6vh, 4.5rem);
  width: clamp(290px, 20vw, 380px);
  margin: 0;
  z-index: 3;
}
body.has-map .frontier-legend-title { font-size: clamp(1.7rem, 2.1vw, 2.6rem); }
body.has-map .legend-name { font-size: clamp(1.18rem, 1.05vw, 1.45rem); }
body.has-map .frontier-legend a,
body.has-map .frontier-legend .legend-item {
  padding-top: clamp(0.5rem, 0.9vh, 0.7rem);
  padding-bottom: clamp(0.5rem, 0.9vh, 0.7rem);
}
body.has-map .frontier-credits {
  position: absolute;
  width: auto;
  margin: 0;
  left: clamp(1rem, 4vw, 3rem);
  bottom: 0.8rem;
  z-index: 4;
}
body.has-map .frontier-credits-body {
  position: absolute;
  bottom: 100%;
  left: 0;
  width: min(460px, 80vw);
  max-height: 55vh;
  overflow: auto;
  padding: 1rem 1.2rem;
  background: rgba(10, 9, 8, 0.97);
  border: 1px solid var(--rule);
}

.frontier-legend { transition: opacity 0.45s ease, visibility 0.45s ease; }

/* Open landscape: the list makes way for its card. */
body.has-map .is-focused .frontier-legend { opacity: 0; visibility: hidden; }

/* The card after the zoom, while a landscape has no page yet: its number,
   its name and the way back. */
body.has-map .frontier-detail:not([hidden]) {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  position: absolute;
  left: clamp(1rem, 4vw, 3rem);
  bottom: 3.4rem;
  width: min(420px, calc(100% - 2rem));
  padding: 1.6rem 1.75rem 1.4rem;
  background: rgba(0, 0, 0, 0.82);
  border: 1px solid rgba(var(--accent-rgb), 0.45);
  z-index: 3;
  animation: detail-in 0.7s var(--ease-out) 0.5s both;
}
.frontier-detail:focus { outline: none; }
@keyframes detail-in { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
.frontier-detail-place { font-size: 0.68rem; letter-spacing: 0.18em; }
.frontier-detail-name {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 400;
  font-size: clamp(2rem, 2.8vw, 2.6rem);
  line-height: 1.05;
  letter-spacing: -0.01em;
}
.frontier-detail-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem 1.4rem; margin-top: 0.5rem; }

/* ── Phones (static mode only) ── */
@media (max-width: 768px) {
  .frontier-hook-ask { margin-top: 2rem; }
  .frontier-scroll-cue { bottom: 1.5rem; }
  /* The four landscapes cover all of Spain, so phones show the whole
     peninsula (the north-east crop went with the old six, 2026-11-17). */
}
/* Short screens: the intro's text a little tighter. */
@media (max-height: 560px) {
  .frontier-hook .hook-heading { margin-bottom: 1.4rem; }
  .frontier-hook-label { margin-bottom: 1.2rem; }
  .frontier-hook-ask { margin-top: 1.6rem; }
  .frontier-scroll-cue { bottom: 1rem; }
}

@media (prefers-reduced-motion: reduce) {
  .frontier-hook .hook-inner > * { opacity: 1; animation: none; }
  .frontier-detail, .frontier-legend a, .frontier-legend .legend-item { transition: none; animation: none; }
}
