/* Perdix hangar page (body.ap), on top of site.css, perdix.css and perdix-film.css (the shared bar and sign-up block).
   Base rules = the simple page, which is also the page without JavaScript and without WebGL: the line as the game's
   stills sorted by mass, the hangar as the chosen aircraft's game card, then every card. Colours follow the theme.
   html.ap-3d = the 3D page (perdix-ap-head.html, perdix-appareils.js): the line at true scale and the hangar form one
   dark band in both themes, like the game page's film; what follows them takes the theme. */

body.ap {
  --ap-side: clamp(20px, 4.5vw, 72px);
  --ap-ease: cubic-bezier(.2, .7, .2, 1);
  --ap-acc: var(--px-acc);
  --ap-r: 14px;
}

/* ---------- Opening: the line ---------- */

.ap-line { position: relative; padding: clamp(36px, 5vw, 64px) 0 clamp(36px, 5vw, 56px); }
.ap-line__head { padding: 0 var(--ap-side); text-align: center; }
.ap-line__head h1 { margin: 0; font-size: clamp(48px, 7.4vw, 108px); line-height: .98; letter-spacing: -.045em; }
.ap-line__head p {
  margin: 14px auto 0; max-width: 34ch; font-size: clamp(19px, 1.9vw, 26px); line-height: 1.25; font-weight: 600;
  letter-spacing: -.02em; color: var(--text-2); text-wrap: balance;
}
.ap-line__stage, .ap-line__note { display: none; }

/* The stills: the game's minis, lightest first. */
.ap-flat {
  list-style: none; margin: 32px auto 0; padding: 0 var(--ap-side); max-width: 1440px;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 22px 14px;
}
.ap-flat__a { display: block; color: inherit; text-decoration: none; }
.ap-flat__a img { display: block; width: 100%; height: auto; aspect-ratio: 16 / 10; object-fit: cover; border-radius: 10px; background: var(--bg-alt); }
.ap-flat__a b { display: block; margin-top: 7px; font-size: 14px; font-weight: 600; letter-spacing: -.01em; }
.ap-flat__a span { display: block; font-size: 13px; color: var(--muted); }
.ap-flat__a:hover b { color: var(--ap-acc); }

/* ---------- The hangar: the game card with the aircraft's sheet (simple page) ---------- */

.ap-hg { position: relative; padding: clamp(28px, 4vw, 56px) 0; }
.ap-hg__stage {
  max-width: 1440px; margin: 0 auto; padding: 0 var(--ap-side);
  display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); grid-template-areas: "card id" "card specs" "pick pick";
  gap: 18px clamp(24px, 4vw, 56px); align-items: start;
}
.ap-hg__view, .ap-hg__top, .ap-hg__load { display: none; }
.ap-hg__card { grid-area: card; display: block; width: 100%; height: auto; aspect-ratio: 16 / 10; object-fit: cover; border-radius: var(--ap-r); background: var(--bg-alt); }
.ap-hg__id { grid-area: id; }
.ap-hg__specs { grid-area: specs; }
.ap-hg__pick { grid-area: pick; min-width: 0; margin-top: 12px; }

.ap-hg__kind { margin: 0 0 6px; font-size: 18px; font-weight: 600; letter-spacing: -.01em; color: var(--ap-acc); }
.ap-hg__name { margin: 0; font-size: clamp(34px, 4.4vw, 68px); line-height: 1; letter-spacing: -.04em; text-wrap: balance; }
.ap-hg__role { margin: 14px 0 0; max-width: 38ch; font-size: 18px; line-height: 1.42; color: var(--muted); letter-spacing: -.01em; }
.ap-hg__where { margin: 10px 0 0; font-size: 15px; color: var(--text-2); }
.ap-hg__where span { color: var(--muted); margin-right: 4px; }
.ap-hg__where .pf-link { color: var(--ap-acc); }
.ap-hg__id > * { transition: opacity .35s var(--ap-ease), transform .35s var(--ap-ease); }
.ap-hg__id.is-swap > * { opacity: 0; transform: translateY(8px); }

.ap-hg__listen {
  margin-top: 18px; display: inline-flex; align-items: center; gap: 9px;
  padding: 9px 16px 9px 13px; border-radius: 999px; border: 0; cursor: pointer; color: var(--text);
  background: color-mix(in srgb, var(--text) 10%, transparent); font: 500 15px/1.2 var(--px-body);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); transition: background .2s;
}
.ap-hg__listen:hover { background: color-mix(in srgb, var(--text) 16%, transparent); }
.ap-hg__listen svg { width: 18px; height: 18px; }
.ap-hg__listen .w1, .ap-hg__listen .w2 { opacity: .35; }
.ap-hg__listen[aria-pressed="true"] { background: var(--text); color: var(--bg); }
.ap-hg__listen[aria-pressed="true"] .w1 { animation: ap-wave 1s infinite; }
.ap-hg__listen[aria-pressed="true"] .w2 { animation: ap-wave 1s .25s infinite; }
@keyframes ap-wave { 0%, 100% { opacity: .3; } 50% { opacity: 1; } }

.ap-hg__specs { margin: 0; display: grid; grid-template-columns: repeat(3, auto); justify-content: start; gap: 14px 32px; }
.ap-hg__specs dt { font-size: 14px; color: var(--muted); }
.ap-hg__specs dd { margin: 0; font-size: clamp(28px, 3.2vw, 46px); line-height: 1.05; font-weight: 600; letter-spacing: -.035em; font-variant-numeric: tabular-nums; transition: opacity .35s; }
.ap-hg__specs dd small { font-size: .5em; font-weight: 500; letter-spacing: -.01em; color: var(--muted); margin-left: .18em; }
.ap-hg__specs .ap-hg__power { grid-column: 1 / -1; }
.ap-hg__specs .ap-hg__power dd { font-size: 17px; font-weight: 500; letter-spacing: -.01em; color: var(--text-2); line-height: 1.35; }
.ap-hg__specs.is-swap dd { opacity: 0; }
.ap-hg__specs [hidden] { display: none; }

/* The picker: families, then one strip of the game's minis */
.ap-hg__fams { display: flex; gap: 6px; padding: 0 0 12px; overflow-x: auto; scrollbar-width: none; }
.ap-hg__fams::-webkit-scrollbar, .ap-hg__strip::-webkit-scrollbar { display: none; }
.ap-fam {
  flex: none; border: 0; cursor: pointer; padding: 6px 14px; border-radius: 999px; min-height: 32px;
  background: transparent; color: var(--muted); font: 500 14px/1.2 var(--px-body); transition: color .2s, background .2s;
}
.ap-fam:hover { color: var(--text); }
.ap-fam[aria-current="true"] { background: color-mix(in srgb, var(--text) 12%, transparent); color: var(--text); }
.ap-hg__strip { display: flex; gap: 10px; overflow-x: auto; scroll-snap-type: x proximity; scrollbar-width: none; padding: 4px 2px; }
.ap-group { display: flex; gap: 10px; flex: none; scroll-snap-align: start; }
.ap-group + .ap-group { margin-left: 22px; }
.ap-ac { flex: none; width: 128px; padding: 0; border: 0; background: none; cursor: pointer; text-align: left; color: inherit; font: inherit; }
.ap-ac img {
  display: block; width: 100%; height: auto; aspect-ratio: 16 / 10; object-fit: cover; border-radius: 10px;
  background: var(--bg-alt); opacity: .7; transition: opacity .25s, box-shadow .25s;
}
.ap-ac span { display: block; margin-top: 6px; font-size: 12.5px; line-height: 1.25; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; transition: color .2s; }
.ap-ac:hover img { opacity: .9; }
.ap-ac[aria-pressed="true"] img { opacity: 1; box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--ap-acc); }
.ap-ac[aria-pressed="true"] span { color: var(--text); }

/* ---------- All nineteen, from the game's renders ---------- */

.ap-all { max-width: 1440px; margin: 0 auto; padding: clamp(64px, 9vw, 140px) var(--ap-side) clamp(56px, 8vw, 120px); }
.ap-all h2 { margin: 0 0 clamp(36px, 4.5vw, 64px); font-size: clamp(40px, 6vw, 80px); line-height: 1; letter-spacing: -.04em; }
.ap-all__fam + .ap-all__fam { margin-top: clamp(44px, 5vw, 64px); }
.ap-all__fam h3 { margin: 0 0 20px; font-size: 24px; font-weight: 600; letter-spacing: -.02em; }
.ap-all__grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 28px 20px; }
.ap-card { display: block; width: 100%; padding: 0; border: 0; background: none; cursor: pointer; text-align: left; color: inherit; font: inherit; }
.ap-card picture { display: block; overflow: hidden; border-radius: 18px; }
.ap-card img { display: block; width: 100%; height: auto; aspect-ratio: 16 / 10; object-fit: cover; border-radius: 18px; background: var(--bg-alt); transition: transform .6s var(--ap-ease); }
.ap-card:hover img { transform: scale(1.02); }
.ap-card b { display: block; margin-top: 14px; font-size: 19px; font-weight: 600; letter-spacing: -.02em; }
.ap-card span { display: block; margin-top: 2px; font-size: 15px; color: var(--muted); }

/* =====================================================================================================================
   The 3D page (html.ap-3d): one dark band, the same in both themes.
   ===================================================================================================================== */

.ap-3d .ap-line, .ap-3d .ap-hg {
  --text: #f5f5f7; --text-2: #d2d2d7; --muted: #a1a1a6; --ap-mute2: #86868b; --bg-alt: #1d1d1f; --ap-acc: #6aa9ff;
  background: #000; color: var(--text);
}
.ap-3d .ap-flat { display: none; }

/* The line at true scale: a picture whose height the script sets from the rows it lays out. */
.ap-3d .ap-line { padding-bottom: 28px; }
.ap-3d .ap-line__stage { display: block; position: relative; margin-top: 18px; height: 62vh; }
.ap-line__view, .ap-line__view canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.ap-line__view {
  opacity: 0; transition: opacity 1.2s var(--ap-ease);
  -webkit-mask-image: linear-gradient(180deg, transparent 0, #000 7%, #000 90%, transparent 100%);
  mask-image: linear-gradient(180deg, transparent 0, #000 7%, #000 90%, transparent 100%);
}
.ap-line__labels { position: absolute; inset: 0; pointer-events: none; opacity: 0; transition: opacity .8s .5s var(--ap-ease); }
.ap-line__stage.is-ready .ap-line__view, .ap-line__stage.is-ready .ap-line__labels { opacity: 1; }
.ap-line__load { position: absolute; left: 50%; top: 40%; transform: translateX(-50%); margin: 0; font-size: 15px; color: var(--muted); }
.is-ready .ap-line__load { display: none; }
.ap-3d .ap-line__note { display: block; margin: 6px 0 0; padding: 0 var(--ap-side); text-align: center; font-size: 14px; color: var(--ap-mute2); }

.ap-lbl {
  position: absolute; left: 0; top: 0; pointer-events: auto; color: inherit;
  padding: 2px 4px; border: 0; background: none; text-align: center; white-space: nowrap; cursor: pointer;
  font: 13.5px/1.2 var(--px-body); letter-spacing: -.01em;
}
.ap-lbl b { display: block; font-weight: 600; color: var(--text-2); transition: color .2s; }
.ap-lbl span { display: block; font-size: 12.5px; color: var(--ap-mute2); transition: color .2s; }
.ap-lbl:hover b, .ap-lbl.is-hover b, .ap-lbl:focus-visible b { color: var(--text); }
.ap-lbl:hover span, .ap-lbl.is-hover span { color: var(--muted); }
.ap-lbl--person { cursor: default; pointer-events: none; font-weight: 500; color: var(--muted); }

/* The hangar: one screen under the Perdix bar, the 3D behind, the sheet and the controls over it. */
/* (scroll-margin: an anchor to #hangar lands right under the bar; the page's scroll-padding is 64 px.) */
.ap-3d .ap-hg { height: calc(100vh - var(--pf-bar)); height: calc(100svh - var(--pf-bar)); min-height: 560px; padding: 0; scroll-margin-top: calc(var(--pf-bar) - 64px); }
.ap-3d .ap-hg__stage { position: absolute; inset: 0; display: block; max-width: none; padding: 0; overflow: hidden; background: #000; }
.ap-3d .ap-hg__card { display: none; }
.ap-3d .ap-hg__view, .ap-hg__view canvas { display: block; position: absolute; inset: 0; width: 100%; height: 100%; }
.ap-hg__view canvas { touch-action: pan-y; cursor: grab; }
.ap-hg__view canvas:active { cursor: grabbing; }
.ap-3d .ap-hg__load { display: block; position: absolute; left: 50%; top: 45%; transform: translate(-50%, -50%); margin: 0; font-size: 15px; color: var(--muted); }
.ap-3d .ap-hg__load[hidden] { display: none; }

/* The overlays come up once the lights are on and the aircraft is in. The text lets a drag through to the canvas
   (orbit); only its controls take the pointer. */
.ap-3d :is(.ap-hg__top, .ap-hg__id, .ap-hg__specs, .ap-hg__pick) {
  position: absolute; opacity: 0; transform: translateY(14px); pointer-events: none;
  transition: opacity .9s var(--ap-ease), transform .9s var(--ap-ease);
}
.ap-3d :is(.ap-hg__top, .ap-hg__id) :is(button, a), .ap-3d :is(.ap-hg__fams, .ap-hg__strip) { pointer-events: auto; }
.ap-3d .ap-hg.is-on :is(.ap-hg__top, .ap-hg__id, .ap-hg__specs, .ap-hg__pick) { opacity: 1; transform: none; }
.ap-3d .ap-hg.is-on .ap-hg__id { transition-delay: 1.5s; }
.ap-3d .ap-hg.is-on .ap-hg__specs { transition-delay: 1.7s; }
.ap-3d .ap-hg.is-on .ap-hg__top { transition-delay: 2s; }
.ap-3d .ap-hg.is-on .ap-hg__pick { transition-delay: 2.2s; }

.ap-3d .ap-hg__top {
  display: grid; left: var(--ap-side); right: var(--ap-side); top: 30px;
  grid-template-columns: 1fr auto 1fr; align-items: start; gap: 20px;
}
.ap-hg__moves h2 { margin: 0 0 10px; font-size: 19px; font-weight: 600; letter-spacing: -.01em; }
.ap-hg__moves ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 18px; max-width: 560px; }
.ap-hg__moves.is-empty { visibility: hidden; } /* keeps its place, so the switch stays put */
.ap-move {
  border: 0; background: none; padding: 3px 0; cursor: pointer; text-align: left;
  font: 600 clamp(20px, 1.8vw, 26px)/1.2 var(--px-body); letter-spacing: -.03em;
  color: var(--text); opacity: .55; transition: opacity .3s var(--ap-ease), color .3s;
}
.ap-move:hover { opacity: .85; }
.ap-move.is-on, .ap-move[aria-pressed="true"] { opacity: 1; color: var(--ap-acc); }
.ap-hg__hint { margin: 4px 0 0; font-size: 14px; color: var(--muted); white-space: nowrap; pointer-events: none; transition: opacity .6s; }
.ap-hg.is-dragged .ap-hg__hint { opacity: 0; }

/* Au sol / En vol: a quiet two-state switch */
.ap-hg__mode {
  justify-self: end; display: inline-flex; padding: 3px; border-radius: 999px;
  background: rgba(255, 255, 255, .08); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
}
.ap-hg__mode button {
  border: 0; cursor: pointer; padding: 7px 16px; border-radius: 999px; background: transparent;
  font: 500 14px/1.2 var(--px-body); color: var(--muted); transition: background .3s var(--ap-ease), color .3s;
}
.ap-hg__mode button:hover { color: var(--text); }
.ap-hg__mode button[aria-pressed="true"] { background: rgba(255, 255, 255, .16); color: var(--text); }

.ap-3d .ap-hg__id { left: var(--ap-side); bottom: 200px; max-width: min(560px, 44vw); }
.ap-3d .ap-hg__specs { right: var(--ap-side); bottom: 200px; text-align: right; grid-template-columns: none; gap: 14px; }
.ap-3d .ap-hg__specs .ap-hg__power dd { max-width: 22ch; margin-left: auto; }
.ap-3d .ap-hg__pick { left: 0; right: 0; bottom: 0; margin: 0; padding: 0 0 22px; }
.ap-3d .ap-hg__fams { padding: 0 var(--ap-side) 12px; }
.ap-3d .ap-hg__strip {
  padding: 4px var(--ap-side); scroll-padding: 0 var(--ap-side);
  -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 var(--ap-side), #000 calc(100% - var(--ap-side)), transparent 100%);
  mask-image: linear-gradient(90deg, transparent 0, #000 var(--ap-side), #000 calc(100% - var(--ap-side)), transparent 100%);
}
.ap-3d .ap-ac img { opacity: .62; }
.ap-3d .ap-ac[aria-pressed="true"] img { opacity: 1; box-shadow: 0 0 0 2px #000, 0 0 0 4px var(--ap-acc); }

/* ---------- Phone ---------- */

@media (max-width: 700px) {
  .ap-line__head h1 { font-size: 52px; }
  .ap-line__head p { margin-top: 10px; font-size: 19px; }
  .ap-flat { grid-template-columns: repeat(3, 1fr); gap: 14px 10px; margin-top: 24px; }
  .ap-flat__a img { border-radius: 8px; }
  .ap-flat__a b { margin-top: 5px; font-size: 12.5px; line-height: 1.25; }
  .ap-flat__a span { font-size: 12px; }

  .ap-hg__stage { grid-template-columns: 1fr; grid-template-areas: "id" "card" "specs" "pick"; gap: 16px; }
  .ap-hg__kind { font-size: 15px; margin-bottom: 4px; }
  .ap-hg__name { font-size: 32px; letter-spacing: -.035em; }
  .ap-hg__role { margin-top: 8px; font-size: 15px; line-height: 1.38; }
  .ap-hg__where { margin-top: 6px; font-size: 13.5px; }
  .ap-hg__listen { margin-top: 10px; padding: 6px 13px 6px 10px; font-size: 13.5px; }
  .ap-hg__specs { grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .ap-hg__specs dt { font-size: 12px; }
  .ap-hg__specs dd { font-size: 26px; }
  .ap-hg__fams { gap: 2px; }
  .ap-fam { padding: 5px 11px; font-size: 13px; }
  .ap-hg__strip { gap: 8px; }
  .ap-group { gap: 8px; }
  .ap-group + .ap-group { margin-left: 16px; }
  .ap-ac { width: 92px; }
  .ap-ac img { border-radius: 8px; }
  .ap-ac span { font-size: 11px; margin-top: 4px; }

  .ap-all__grid { grid-template-columns: 1fr 1fr; gap: 20px 12px; }
  .ap-card img { border-radius: 12px; }
  .ap-card b { font-size: 15px; margin-top: 8px; letter-spacing: -.01em; }
  .ap-card span { font-size: 13px; }

  .ap-3d .ap-line__stage { height: 120vh; margin-top: 8px; }
  .ap-lbl { font-size: 11.5px; padding: 2px; }
  .ap-lbl span { font-size: 11px; }
  .ap-3d .ap-line__note { font-size: 13px; }

  .ap-3d .ap-hg { min-height: 600px; }
  .ap-3d .ap-hg__id { left: 20px; right: 20px; top: 18px; bottom: auto; max-width: none; }
  .ap-3d .ap-hg__role { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
  .ap-3d .ap-hg__where { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  /* Bottom, from the top down: the switch on its own line, what moves (wrapping onto a second line if it needs to),
     the figures, the picker. */
  .ap-3d .ap-hg__top { left: 0; right: 0; top: auto; bottom: 212px; display: flex; flex-direction: column; align-items: flex-start; gap: 12px; padding: 0 20px; }
  .ap-hg__mode { order: -1; }
  .ap-hg__moves { min-width: 0; }
  .ap-hg__moves.is-empty { display: none; }
  .ap-hg__moves h2 { font-size: 13px; color: var(--muted); font-weight: 500; margin-bottom: 2px; }
  .ap-hg__moves ul { flex-wrap: wrap; max-width: none; gap: 0 14px; }
  .ap-move { font-size: 17px; letter-spacing: -.02em; padding: 2px 0; }
  .ap-hg__hint { display: none; }
  .ap-hg__mode button { padding: 6px 11px; font-size: 13px; }
  .ap-3d .ap-hg__specs { left: 20px; right: 20px; bottom: 146px; grid-template-columns: repeat(3, 1fr); gap: 8px; text-align: left; }
  .ap-3d .ap-hg__specs .ap-hg__power { display: none; }
  .ap-3d .ap-hg__pick { padding-bottom: 14px; }
  .ap-3d .ap-hg__fams { padding: 0 20px 8px; }
  .ap-3d .ap-hg__strip { padding: 2px 20px; scroll-padding: 0 20px; }
}

@media (prefers-reduced-motion: reduce) {
  .ap-line__view, .ap-line__labels, .ap-hg__id > *, .ap-hg__specs dd, .ap-card img,
  .ap-3d :is(.ap-hg__top, .ap-hg__id, .ap-hg__specs, .ap-hg__pick) { transition: none !important; }
  .ap-3d :is(.ap-hg__top, .ap-hg__id, .ap-hg__specs, .ap-hg__pick) { transform: none; }
  .ap-hg__listen[aria-pressed="true"] :is(.w1, .w2) { animation: none; opacity: 1; }
}
