/* Apex Atlas — motion layer ("in the manner of Formula 1").
   One idea per moment: start lights → launch → racing line → timing sectors.
   Everything is switched off for visitors who ask for reduced motion. */

:root {
  --f1-red: #e10600;
  --sector-yellow: #f5c518;
  --sector-green: #1fbf5c;
  --sector-purple: #a24bff;
  --launch-at: 2.9s;           /* when the five lights go out */
  --ease-launch: cubic-bezier(.16, .84, .24, 1);
}

/* ---------- 1. Start lights (home page head) ---------- */
.gantry { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.gantry .pod { display: flex; flex-direction: column; gap: 4px; padding: 5px; background: #14181f; border-radius: 6px; }
.gantry i {
  display: block; width: 16px; height: 16px; border-radius: 50%;
  background: #2a2f38; box-shadow: inset 0 0 0 1px #000;
  animation: light-on .01s linear forwards, light-off .12s linear forwards;
  animation-delay: var(--d), var(--launch-at);
}
.gantry .pod:nth-child(1) i { --d: .4s; }
.gantry .pod:nth-child(2) i { --d: .9s; }
.gantry .pod:nth-child(3) i { --d: 1.4s; }
.gantry .pod:nth-child(4) i { --d: 1.9s; }
.gantry .pod:nth-child(5) i { --d: 2.4s; }
.gantry .go {
  font-family: 'IBM Plex Mono', monospace; font-size: 11px; letter-spacing: .14em; color: #565b66;
  margin-left: 6px; opacity: 0; animation: fade-in .3s ease forwards; animation-delay: var(--launch-at);
}
@keyframes light-on  { to { background: var(--f1-red); box-shadow: 0 0 10px 2px rgb(225 6 0 / .55), inset 0 0 0 1px #000; } }
@keyframes light-off { to { background: #2a2f38; box-shadow: inset 0 0 0 1px #000; } }
@keyframes fade-in   { to { opacity: 1; } }

/* ---------- 2. Launch: the head picture arrives at lights out ---------- */
.hero { isolation: isolate; }
.hero-pic { animation: launch 1.1s var(--ease-launch) both; animation-delay: var(--launch-at); }
.hero-pic img { animation: pan 22s ease-in-out infinite alternate; animation-delay: calc(var(--launch-at) + 1.1s); }
.entry .hero-pic { animation-delay: .15s; }
.entry .hero-pic img { animation-delay: 1.2s; }
@keyframes launch {
  from { transform: translateX(14%); opacity: 0; filter: blur(10px); }
  60%  { filter: blur(2px); }
  to   { transform: none; opacity: 1; filter: none; }
}
@keyframes pan { from { transform: scale(1.04) translateX(0); } to { transform: scale(1.04) translateX(-2.5%); } }

/* speed streaks across the head at the moment of launch */
.hero::after {
  content: ""; position: absolute; inset: 0; pointer-events: none; z-index: 2;
  background:
    linear-gradient(90deg, transparent 0 40%, rgb(225 6 0 / .9) 50%, transparent 60%) 0 38% / 220% 2px no-repeat,
    linear-gradient(90deg, transparent 0 40%, rgb(244 241 234 / .7) 50%, transparent 60%) 0 62% / 220% 1px no-repeat,
    linear-gradient(90deg, transparent 0 40%, rgb(225 6 0 / .5) 50%, transparent 60%) 0 74% / 220% 1px no-repeat;
  opacity: 0;
  animation: streak .75s ease-out forwards; animation-delay: var(--launch-at);
}
.entry.hero::after { animation-delay: .1s; }
@keyframes streak {
  0%   { opacity: 1; background-position: 120% 38%, 140% 62%, 160% 74%; }
  100% { opacity: 0; background-position: -60% 38%, -40% 62%, -20% 74%; }
}

/* the term links under the title sit on paper, never on the photo */
.hero-terms { position: relative; z-index: 3; max-width: 34rem; }
.hero-terms a { background: rgb(244 241 234 / .88); padding: 0 3px; }

/* ---------- 3. Timing ticker (running strip of corners) ---------- */
.ticker-wrap { overflow: hidden; }
.ticker { width: max-content; animation: ticker 60s linear infinite; }
.ticker-wrap:hover .ticker, .ticker-wrap:focus-within .ticker { animation-play-state: paused; }
@keyframes ticker { to { transform: translateX(-50%); } }

/* ---------- 4. Tiles: lights-to-grid reveal + racing line on hover ---------- */
.js .reveal { opacity: 0; transform: translateY(18px); transition: opacity .6s ease, transform .6s var(--ease-launch); transition-delay: var(--stagger, 0s); }
.js .reveal.in { opacity: 1; transform: none; }
.tile::after {
  content: ""; position: absolute; left: 0; bottom: 0; height: 3px; width: 100%;
  background: var(--f1-red); transform: scaleX(0); transform-origin: left; transition: transform .45s var(--ease-launch);
}
.tile:hover::after, .tile:focus-within::after { transform: scaleX(1); }
.tile .tile-pic { transition: transform .8s var(--ease-launch), opacity .4s; }
.tile:hover .tile-pic { transform: translateX(-10px); opacity: .95; }
.pick { transition: border-color .3s; position: relative; }
.pick::before {
  content: ""; position: absolute; left: 0; top: -2px; height: 2px; width: 100%;
  background: var(--f1-red); transform: scaleX(0); transform-origin: left; transition: transform .4s var(--ease-launch);
}
.pick:hover::before { transform: scaleX(1); }

/* ---------- 5. Timing sectors ("A corner in five moves") ---------- */
.sectors > a { position: relative; }
.sectors > a::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 4px;
  background: #2a2f38; transform-origin: left;
}
.sectors.in > a::after { animation: sector .5s ease forwards; }
.sectors.in > a:nth-child(1)::after { animation-delay: .1s;  --sc: var(--sector-yellow); }
.sectors.in > a:nth-child(2)::after { animation-delay: .5s;  --sc: var(--sector-green); }
.sectors.in > a:nth-child(3)::after { animation-delay: .9s;  --sc: var(--sector-purple); }
.sectors.in > a:nth-child(4)::after { animation-delay: 1.3s; --sc: var(--sector-green); }
.sectors.in > a:nth-child(5)::after { animation-delay: 1.7s; --sc: var(--sector-purple); }
@keyframes sector { from { transform: scaleX(0); background: var(--sc); } to { transform: scaleX(1); background: var(--sc); } }
.sector-key { display: flex; gap: 14px; font-family: 'IBM Plex Mono', monospace; font-size: 11px; color: #565b66; }
.sector-key span::before { content: ""; display: inline-block; width: 10px; height: 4px; margin-right: 6px; vertical-align: middle; background: var(--c); }

/* ---------- 6. Entry page: onboard replay of the filmstrip ---------- */
.film-replay .frame { transition: outline-color .2s; outline: 2px solid transparent; outline-offset: -2px; }
.film-replay .frame.live { outline-color: #f08a76; }
.film-replay .frame .chase { animation: chase 2.4s var(--ease-launch) infinite; }
@keyframes chase { 0%, 20% { transform: translateX(0); } 70%, 100% { transform: translateX(26px); } }
.meter span { transform-origin: left; animation: meter .5s var(--ease-launch) both; }
.meter span:nth-child(1) { animation-delay: .6s; } .meter span:nth-child(2) { animation-delay: .75s; }
.meter span:nth-child(3) { animation-delay: .9s; } .meter span:nth-child(4) { animation-delay: 1.05s; }
.meter span:nth-child(5) { animation-delay: 1.2s; }
@keyframes meter { from { transform: scaleX(0); } }

/* ---------- 7. Chequered sign-off above the footer ---------- */
.chequer {
  height: 14px;
  background: conic-gradient(#14181f 25%, #f4f1ea 0 50%, #14181f 0 75%, #f4f1ea 0) 0 0 / 14px 14px;
  animation: chequer 1.2s linear infinite; animation-play-state: paused;
}
.chequer.in { animation-play-state: running; }
@keyframes chequer { to { background-position: 28px 0; } }

/* ---------- Reduced motion: everything settles, nothing moves ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .gantry .go, .js .reveal { opacity: 1 !important; transform: none !important; }
  .hero::after { display: none; }
  .sectors > a:nth-child(1)::after { background: var(--sector-yellow); }
  .sectors > a:nth-child(2)::after, .sectors > a:nth-child(4)::after { background: var(--sector-green); }
  .sectors > a:nth-child(3)::after, .sectors > a:nth-child(5)::after { background: var(--sector-purple); }
}

@media (max-width: 600px) {
  .gantry i { width: 12px; height: 12px; }
  .hero-terms a { background: rgb(244 241 234 / .92); }
}

/* ---------- Refinements: legibility over photos, phone layout ---------- */
.tile:not(.tile-dark) .tile-pic { opacity: .5; }
.tile:not(.tile-dark):hover .tile-pic { opacity: .75; }
.tile ul a { background: rgb(235 230 219 / .8); }
.tile-dark ul a { background: transparent; }

@media (max-width: 600px) {
  header form[role="search"] { order: 3; flex: 1 1 100% !important; max-width: none !important; }
  header button { margin-left: auto; }
  .hero-pic {
    position: relative !important; width: 100% !important; height: 210px !important; opacity: 1 !important;
    clip-path: polygon(0 0, 100% 0, 100% 82%, 0 100%) !important;
    -webkit-mask-image: linear-gradient(#000 65%, transparent) !important; mask-image: linear-gradient(#000 65%, transparent) !important;
  }
  .hero > div:not(.hero-pic) { padding-top: 8px !important; }
  .hero > div p.mono[style*="position:absolute"] { position: static !important; color: #565b66 !important; margin-top: 12px !important; }
  @keyframes launch { from { transform: translateX(30%); opacity: 0; filter: blur(10px); } to { transform: none; opacity: 1; filter: none; } }
}

/* picture strip on the editor picks */
.pick-pic { display: block; height: 120px; margin: -16px -16px 6px; overflow: hidden; }
.pick-pic img { transition: transform .8s var(--ease-launch); }
.pick:hover .pick-pic img { transform: scale(1.04) translateX(-6px); }

/* ---------- Colour on hover: two-tone pictures come alive ---------- */
.hero-pic img, .tile-pic, .pick-pic img { transition: filter .7s ease, transform .8s var(--ease-launch); }
.hero:hover .hero-pic img,
.tile:hover .tile-pic, .tile:focus-within .tile-pic, .tile.colour .tile-pic,
.pick:hover .pick-pic img, .pick:focus-visible .pick-pic img, .pick.colour .pick-pic img { filter: none !important; }
.tile:not(.tile-dark):hover .tile-pic, .tile:not(.tile-dark).colour .tile-pic { opacity: .9; }

/* the head picture lands in colour at lights out, then settles into two-tone */
.hero-pic img { animation: pan 22s ease-in-out infinite alternate, settle 2.6s ease forwards; animation-delay: calc(var(--launch-at) + 1.1s), var(--launch-at); }
.entry .hero-pic img { animation-delay: 1.2s, .15s; }
@keyframes settle { 0%, 45% { filter: none; } 100% { filter: grayscale(1) contrast(1.1) brightness(.92); } }

/* ---------- Pointer and scroll parallax (set by motion.js) ---------- */
.hero-pic img { translate: calc(var(--px, 0) * 14px) calc(var(--py, 0) * 10px + var(--sy, 0) * 1px); transition: filter .7s ease, translate .25s ease-out; }
.tile-pic { translate: calc(var(--tx, 0) * 12px) calc(var(--ty, 0) * 8px); }

/* ---------- Lower-third name graphic (TV style) ---------- */
.lower-third {
  position: absolute; right: 32px; bottom: 44px; z-index: 4; margin: 0;
  display: flex; align-items: stretch; box-shadow: 0 10px 30px rgb(20 24 31 / .35);
  clip-path: inset(0 100% 0 0); animation: lt-in .7s var(--ease-launch) forwards; animation-delay: calc(var(--launch-at) + .7s);
}
.lt-num { background: var(--f1-red); color: #fff; font-size: 22px; font-weight: 500; padding: 10px 14px; display: flex; align-items: center; }
.lt-text { background: #14181f; color: #f4f1ea; padding: 8px 18px 10px 16px; display: flex; flex-direction: column; gap: 2px; border-right: 4px solid var(--f1-red); }
.lt-kicker { font-size: 10px; letter-spacing: .18em; color: #9aa0aa; }
.lt-name { font-family: 'Newsreader', Georgia, serif; font-size: 26px; line-height: 1.1; letter-spacing: .01em; }
.lt-name b { font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
@keyframes lt-in { to { clip-path: inset(0 0 0 0); } }

@media (max-width: 600px) {
  .lower-third { right: 12px; bottom: auto; top: -78px; }
  .lt-name { font-size: 19px; }
  .lt-num { font-size: 17px; padding: 8px 10px; }
}
@media (prefers-reduced-motion: reduce) {
  .lower-third { clip-path: none !important; }
  .hero-pic img { translate: none !important; }
}
