/* OR12-live (D) — the door: the wind farm behind the crew entrance (`/`), the sign-in, the crew messages and the admin
   sign-in (/admin/login), rulings 139, 144, 150; part 2, ruling 155 (Ryan, 20 Oct 2026: two columns of turning
   turbines, the sea moving underneath, the Hercules logo in the middle and the sign-in box under it, realism).
   Ruling 156 (OR12g, Ryan 20 Oct ~12:45 / ~12:50: "The Hercules logo should be in the middle" — "Emblem and card as
   one group, centred on the screen"): on a landscape screen the emblem and the card are one group centred in the
   viewport; the card is headed by the brand line "Muster Point · HEA Hercules Crew Portal" (no h1); the e-mail step
   and the name step (crew/entrance.html, crew/name.html) share it.

   Served from /c/_a/door.css under `style-src 'self'`: no inline style anywhere. The scene is door3d.js's WebGL
   canvas (.scene-gl), drawn over the still frame (.scene-still, static/c/still/, rendered from the same scene) and
   faded in once its first frame is drawn (.scene.is-live). Without script, without WebGL 2, on a lost context and on
   the admin sign-in the still frame stays. The crew screens' band (.scene[data-farm="band"]) is a still frame only;
   pages.css sizes it.

   Layers, back to front: the still frame · the canvas · a vignette and a soft dark gradient behind the lower half (so
   the card reads over the sea) · the emblem and the card. Forced colours and print: no scene, the card alone. */

/* ---------------------------------------------------------------------------------------------- tokens */
.scene,
body[data-layout="door"] {
  --d-font-display: "Bahnschrift", "DIN Alternate", "DIN Next LT Pro", "sans-serif-condensed", "Roboto Condensed", "Arial Narrow", system-ui, sans-serif;
  --d-font-body: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --d-gutter: 16px;
  --d-tap: 44px;
  --d-page: #d9e6f1;
  --d-scene-bg: #9fbad3;
  --d-ink: #0f2340;
  --d-ink-2: #44526a;
  --d-glass: rgba(255, 251, 244, .9);
  --d-glass-line: rgba(255, 255, 255, .72);
  --d-glass-rule: rgba(22, 41, 77, .14);
  --d-glass-shadow: 0 24px 60px -26px rgba(7, 18, 38, .6), 0 2px 8px rgba(7, 18, 38, .1);
  --d-field-bg: #ffffff;
  --d-field-line: #7d8698;
  --d-btn-bg: #16294d;
  --d-btn-bg-h: #22406f;
  --d-btn-ink: #ffffff;
  --d-focus: #1f56c4;
  --d-link: #18478f;
  --d-emblem-shadow: rgba(7, 18, 38, .45);
  --d-bad: #b3261e;
  --d-bad-bg: #fbe3e0;
  --d-wait: #1f4f8f;
  --d-wait-bg: #e1ebf8;
  --d-veil-top: rgba(214, 228, 242, 0);
  --d-shade: rgba(6, 22, 40, .26);
  --d-vignette: rgba(4, 14, 28, .22);
}

@media (prefers-color-scheme: dark) {
  .scene,
  body[data-layout="door"] {
    --d-page: #071226;
    --d-scene-bg: #0b1730;
    --d-ink: #f2f5fa;
    --d-ink-2: #b9c5d7;
    --d-glass: rgba(7, 17, 36, .8);
    --d-glass-line: rgba(243, 201, 105, .26);
    --d-glass-rule: rgba(243, 201, 105, .2);
    --d-glass-shadow: 0 26px 70px -24px rgba(0, 0, 0, .75);
    --d-field-bg: rgba(255, 255, 255, .07);
    --d-field-line: rgba(196, 210, 232, .55);
    --d-btn-bg: #f0c35a;
    --d-btn-bg-h: #f7d47e;
    --d-btn-ink: #0d1b33;
    --d-focus: #f3c969;
    --d-link: #f3c969;
    --d-emblem-shadow: rgba(0, 0, 0, .6);
    --d-bad: #ff9a8f;
    --d-bad-bg: rgba(255, 154, 143, .13);
    --d-wait: #9cc3ff;
    --d-wait-bg: rgba(156, 195, 255, .13);
    --d-veil-top: rgba(4, 10, 23, .35);
    --d-shade: rgba(2, 6, 16, .5);
    --d-vignette: rgba(0, 0, 0, .36);
  }
}

/* ---------------------------------------------------------------------------------------------- base (door pages) */
body[data-layout="door"],
body[data-layout="door"] *,
body[data-layout="door"] *::before,
body[data-layout="door"] *::after { box-sizing: border-box; }

body[data-layout="door"] {
  margin: 0;
  min-height: 100vh;
  min-height: 100svh;
  background: var(--d-page);
  color: var(--d-ink);
  font: 16px/1.5 var(--d-font-body);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  overflow-x: clip;
  overflow-wrap: anywhere;
}
/* zero-specificity resets (:where), so every door class below wins over them */
:where(body[data-layout="door"]) :where(h1, p, form) { margin: 0; }
:where(body[data-layout="door"]) :focus-visible { outline: 3px solid var(--d-focus); outline-offset: 3px; border-radius: 6px; }

/* ---------------------------------------------------------------------------------------------- the scene */
.scene {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
  background: var(--d-scene-bg);
}
.scene[data-farm="band"] { position: absolute; inset: 0 0 auto 0; height: var(--band-h, 168px); }

/* the still frame: before the scene is live, without script or WebGL, on the band and the admin sign-in */
.scene-still {
  position: absolute;
  inset: 0;
  display: block;
}
.scene-still img {
  display: block;
  width: 100%;
  height: 100%;
  max-width: none;
  object-fit: cover;
  object-position: 50% 62%;
}
.scene[data-farm="band"] .scene-still img { object-position: 50% 70%; }

/* the live scene: door3d.js's canvas, faded in over the still once it has drawn */
.scene-gl {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  opacity: 0;
  transition: opacity .9s ease;
}
.scene.is-live .scene-gl { opacity: 1; }

/* a vignette, and a soft dark gradient behind the lower half so the card reads over the sea */
.scene[data-farm="door"]::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(to bottom, var(--d-veil-top) 0, transparent 30%, transparent 46%, var(--d-shade) 100%),
    radial-gradient(130% 95% at 50% 42%, transparent 58%, var(--d-vignette) 100%);
}

/* ---------------------------------------------------------------------------------------------- the door */
.gate {
  position: relative;
  z-index: 2;
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding:
    max(14px, env(safe-area-inset-top))
    max(var(--d-gutter), env(safe-area-inset-right))
    28px
    max(var(--d-gutter), env(safe-area-inset-left));
}

.emblem {
  display: block;
  width: clamp(76px, 11vh, 132px);
  height: auto;
  margin-top: clamp(0px, 2vh, 34px);
  filter: drop-shadow(0 10px 22px var(--d-emblem-shadow));
  transition: opacity .4s ease, transform .6s ease;
}

.door-card {
  width: 100%;
  max-width: 404px;
  margin-top: clamp(8px, 1.6vh, 22px);
  padding: 18px 20px 0;
  border-radius: 20px;
  background: var(--d-glass);
  border: 1px solid var(--d-glass-line);
  box-shadow: var(--d-glass-shadow);
  -webkit-backdrop-filter: blur(20px) saturate(1.2);
  backdrop-filter: blur(20px) saturate(1.2);
  transition: opacity .4s ease, transform .6s ease;
}

.door-brand {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 2px 8px;
  font-size: 13px;
  line-height: 1.35;
  color: var(--d-ink-2);
}
.door-brand b { font: 700 13px/1.35 var(--d-font-display); letter-spacing: .08em; text-transform: uppercase; color: var(--d-ink); }

/* ruling 156: the brand line is the card's heading where the h1 was — "MUSTER POINT" over "HEA Hercules Crew Portal" */
.door-brand.is-head { display: block; }
.door-brand.is-head b { display: block; letter-spacing: .14em; }
.door-brand.is-head span { display: block; margin-top: 2px; font: 600 24px/1.15 var(--d-font-display); letter-spacing: .005em; color: var(--d-ink); text-wrap: balance; }
.door-brand.is-head + .door-lead { margin-top: 8px; }

.door-card h1 { margin-top: 8px; font: 600 26px/1.12 var(--d-font-display); letter-spacing: .005em; text-wrap: balance; }
.door-lead { margin-top: 6px; font-size: 15px; line-height: 1.45; color: var(--d-ink-2); text-wrap: pretty; }

.door-notice { margin-top: 12px; padding: 10px 14px; border-radius: 12px; font-size: 15px; line-height: 1.4; }
.door-notice strong { display: block; }
.door-notice.bad { background: var(--d-bad-bg); color: var(--d-bad); }
.door-notice.wait { background: var(--d-wait-bg); color: var(--d-wait); }

.door-field { margin-top: 14px; }
.door-field + .door-field { margin-top: 12px; }
.door-field label { display: block; margin-bottom: 6px; font-size: 14px; font-weight: 600; line-height: 1.3; }
.door-field input {
  display: block;
  width: 100%;
  height: 48px;
  padding: 0 14px;
  border: 1px solid var(--d-field-line);
  border-radius: 10px;
  background: var(--d-field-bg);
  color: var(--d-ink);
  font: 16px/1.2 var(--d-font-body);
}
.door-field input:focus-visible { outline: 3px solid var(--d-focus); outline-offset: 2px; border-color: var(--d-focus); border-radius: 10px; }
.door-field input.code { text-transform: uppercase; letter-spacing: .12em; font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; }
.door-hint { margin-top: 6px; font-size: 13px; line-height: 1.4; color: var(--d-ink-2); }

/* the name step (ruling 156): the address typed at the first step, shown read-only, and the way back to change it */
.door-field input[readonly] { border-color: var(--d-glass-rule); background: transparent; color: var(--d-ink-2); }
.door-again {
  display: inline-flex;
  align-items: center;
  min-height: var(--d-tap);
  font-size: 14px;
  font-weight: 600;
  color: var(--d-link);
  text-underline-offset: 3px;
}

.door-btn {
  display: grid;
  place-items: center;
  width: 100%;
  min-height: 50px;
  margin-top: 10px;
  padding: 0 16px;
  border: 0;
  border-radius: 12px;
  background: var(--d-btn-bg);
  color: var(--d-btn-ink);
  font: 600 18px/1 var(--d-font-display);
  letter-spacing: .02em;
  cursor: pointer;
  transition: background-color .14s ease, transform .14s ease;
}
.door-btn:hover { background: var(--d-btn-bg-h); }
.door-btn:active { transform: translateY(1px) scale(.995); }
.door-btn:focus-visible { outline-offset: 3px; border-radius: 12px; }
.door-btn[disabled] { opacity: .7; cursor: progress; }

.door-foot {
  display: flex;
  align-items: center;
  min-height: var(--d-tap);
  margin: 12px -20px 0;
  padding: 6px 20px;
  border-top: 1px solid var(--d-glass-rule);
  font-size: 13px;
  line-height: 1.4;
  color: var(--d-ink-2);
}
.door-note { margin-top: 12px; padding-bottom: 18px; font-size: 13px; line-height: 1.45; color: var(--d-ink-2); }

/* phones: a compact card, so the farm shows below it */
@media (max-width: 639px) {
  .emblem { width: clamp(76px, 11.5vh, 122px); margin-top: clamp(0px, 1vh, 12px); }
  .door-card { padding: 14px 16px 0; border-radius: 18px; }
  .door-card h1 { font-size: 23px; }
  .door-brand.is-head span { font-size: 22px; }
  .door-lead { font-size: 14.5px; }
  .door-field { margin-top: 12px; }
  .door-btn { margin-top: 14px; }
  .door-foot { margin: 10px -16px 0; padding: 4px 16px; min-height: 40px; }
  .door-note { padding-bottom: 14px; }
}

@media (min-width: 640px) {
  .emblem { width: clamp(132px, 19vh, 208px); }
  .door-card { padding: 26px 30px 0; }
  .door-card h1 { font-size: 30px; }
  .door-brand.is-head span { font-size: 27px; }
  .door-foot { margin: 14px -30px 0; padding: 6px 30px; }
  .door-note { padding-bottom: 26px; }
}
@media (min-width: 1000px) { .emblem { width: clamp(152px, 23vh, 224px); } }
@media (max-height: 620px) and (min-width: 640px) { .emblem { width: clamp(104px, 17.5vh, 150px); } }

/* ruling 156: on a landscape screen — the aspect door3d.js frames as landscape (≥ 1.15) — the emblem and the card are
   ONE group centred in the viewport, between the two turbine columns (the scene re-frames its horizon under the card
   by itself). The auto margins centre the group and, on a screen too short for it, let it run off the bottom (where
   the page scrolls), never the top. Phones held sideways keep their row (below); a portrait screen keeps the group at
   the top, the button above the fold; the admin sign-in (.gate-office) is unchanged. */
@media (min-aspect-ratio: 23/20) and (min-height: 521px) {
  .gate:not(.gate-office) {
    min-height: 100vh;
    min-height: 100dvh;
    padding-top: max(16px, env(safe-area-inset-top));
    padding-bottom: 16px;
  }
  .gate:not(.gate-office) > .emblem { margin-top: auto; }
  .gate:not(.gate-office) > .door-card { margin-bottom: auto; }
}
/* a laptop's crew card a little wider, so the heading and the lead each keep to one line and the name step with its
   notice still fits a 1280 × 800 or 1366 × 768 screen */
@media (min-width: 1000px) { .gate:not(.gate-office) > .door-card { max-width: 460px; } }

/* phones held sideways: the emblem beside the card, so the button stays in view */
@media (max-height: 520px) and (orientation: landscape) {
  .gate { flex-direction: row; justify-content: center; align-items: flex-start; gap: 24px; padding-top: max(8px, env(safe-area-inset-top)); padding-bottom: 8px; }
  .emblem { width: 120px; margin-top: 6px; }
  .door-card { max-width: 460px; margin-top: 0; padding: 12px 20px 0; }
  .door-card h1 { margin-top: 4px; font-size: 22px; }
  .door-brand.is-head span { font-size: 20px; }
  .door-lead { margin-top: 2px; font-size: 14px; }
  .door-field { margin-top: 8px; }
  .door-field label { margin-bottom: 4px; }
  .door-field input { height: 44px; }
  .door-hint { margin-top: 4px; }
  .door-btn { min-height: 46px; margin-top: 10px; }
  .door-foot { min-height: 36px; margin: 6px -20px 0; padding: 2px 20px; }
  .door-note { margin-top: 8px; padding-bottom: 10px; }
}

/* the admin sign-in: the same door, a still frame, a smaller emblem */
.gate-office .emblem { width: clamp(64px, 9vh, 104px); }

/* ---------------------------------------------------------------------------------------------- still and plain */
@media (prefers-reduced-motion: reduce) {
  .scene-gl, .emblem, .door-card, .door-btn { transition: none; }
}

@media (forced-colors: active) {
  .scene { display: none; }
  .door-card { border: 1px solid CanvasText; }
}

@media print {
  .scene { display: none; }
}
