/* ==========================================================================
   SAL Annual Report 2025 — styles
   1. Tokens  2. Base  3. Loader  4. Chrome (top bar, rail, hint)
   5. Cards  6. Labels  7. 3D livery  8. Responsive  9. Reduced motion  10. Static fallback
   ========================================================================== */

/* 1. Tokens ----------------------------------------------------------------
   The 3D scene reads --red, --white, --salt and --black on load,
   so changing them here recolours the line, globe, vehicles and routes too. */
:root {
  --red: #EA0029;
  --white: #FFFFFF;
  --salt: #F3F3F3;
  --black: #000000;

  --text: var(--black);
  --muted: rgba(0, 0, 0, 0.58);
  --hairline: rgba(0, 0, 0, 0.12);
  --shadow: 0 28px 60px -28px rgba(0, 0, 0, 0.28);

  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --pad: clamp(16px, 3.2vw, 44px);
  --rail-space: 46px;
  --topbar-h: 72px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --ease: cubic-bezier(.2, .7, .1, 1);

  --scroll-length: 1088vh; /* longer = slower story */
}

/* 2. Base ---------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; padding: 0; }
html, body { background: var(--salt); color: var(--text); font-family: var(--font); -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
body { overflow-x: hidden; font-feature-settings: 'tnum' 1; }
::selection { background: var(--red); color: var(--white); }
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }

.scroll-space { height: var(--scroll-length); pointer-events: none; }

.stage, .livery-layer { position: fixed; top: 0; left: 0; width: 100%; height: 100vh; height: 100lvh; }
.stage { z-index: 0; }
.stage canvas { display: block; width: 100%; height: 100%; outline: none; touch-action: pan-y; }
.stage.is-draggable canvas { cursor: grab; }
body.is-dragging .stage canvas { cursor: grabbing; }
.livery-layer { z-index: 1; pointer-events: none; overflow: hidden; }
.livery-layer * { pointer-events: none; }

/* SAL logo: assets/sal-logo.svg used as a mask, so it takes the current text colour */
.logo { display: inline-block; flex: none; height: 26px; aspect-ratio: 108 / 44; color: var(--red); background-color: currentColor;
  -webkit-mask: url('../assets/sal-logo.svg') center / contain no-repeat; mask: url('../assets/sal-logo.svg') center / contain no-repeat; }
.logo--lg { height: 40px; }

/* 3. Loader -------------------------------------------------------------- */
.loader { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; background: var(--salt); transition: opacity 1s var(--ease), visibility 1s; }
.loader.is-done { opacity: 0; visibility: hidden; }
.loader__inner { width: min(340px, 78vw); }
.loader__title { margin-top: 18px; font-size: 22px; font-weight: 800; letter-spacing: -.02em; }
.loader__bar { height: 3px; margin: 22px 0 12px; background: var(--hairline); overflow: hidden; }
.loader__bar i { display: block; height: 100%; background: var(--red); transform: scaleX(0); transform-origin: left; transition: transform .6s var(--ease); }
.loader__status { font-size: 13px; color: var(--muted); }
.loader__error { display: none; margin-top: 14px; font-size: 14px; line-height: 1.55; }
.loader__error.is-visible { display: block; }

/* 4. Chrome -------------------------------------------------------------- */
.topbar { position: fixed; top: 0; left: 0; right: 0; z-index: 30; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: var(--safe-t) var(--pad) 20px; pointer-events: none; background: transparent; }
.topbar .brand { align-self: flex-start; }
.topbar__actions { padding-top: 6px; }
.brand { display: flex; align-items: center; gap: 14px; min-width: 0; }
.brand__meta { font-size: 12px; line-height: 1.35; color: var(--muted); white-space: nowrap; }
.brand__meta b { display: block; color: var(--text); font-weight: 700; }
/* Hamburger (top right) → section menu */
.topbar .logo { height: 48px; pointer-events: auto; }
.topbar__actions { display: flex; align-items: center; gap: 18px; min-width: 0; }
.topbar__title { font-size: 13px; font-weight: 500; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lang-btn { flex: none; display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; font-size: 12px; font-weight: 500; color: var(--red); text-decoration: none; border: 1px solid var(--red); pointer-events: auto; transition: background-color .2s, color .2s; }
.lang-btn:hover { background: var(--red); color: var(--white); }
.lang-btn:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; }

.menu-btn { flex: none; display: grid; grid-template-columns: repeat(3, 7px); grid-auto-rows: 7px; gap: 4px; place-content: center; width: 44px; height: 44px; margin-right: -9px; padding: 0; background: none; border: 0; cursor: pointer; pointer-events: auto; }
.menu-btn i { display: block; background: var(--red); transition: opacity .25s, transform .35s var(--ease), background-color .2s; }
.menu-btn:hover i { background: var(--black); }
.menu-btn:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; }
body.is-menu-open .menu-btn i:nth-child(even) { opacity: 0; transform: scale(.4); }

.menu { position: fixed; z-index: 40; right: var(--pad); top: calc(var(--safe-t) + var(--topbar-h) - 4px); width: min(300px, calc(100vw - 2 * var(--pad))); padding: 10px 0; background: var(--white); box-shadow: var(--shadow);
  opacity: 0; visibility: hidden; transform: translate3d(0, -8px, 0); transition: opacity .3s var(--ease), transform .3s var(--ease), visibility .3s; }
.menu::before { content: ''; position: absolute; left: 0; top: 0; width: 56px; height: 4px; background: var(--red); }
body.is-menu-open .menu { opacity: 1; visibility: visible; transform: none; }
.menu__list { list-style: none; }
.menu__list button { display: flex; align-items: baseline; gap: 14px; width: 100%; padding: 11px 22px; background: none; border: 0; text-align: left; font-size: 15px; font-weight: 600; cursor: pointer; transition: background-color .2s, color .2s; }
.menu__list button b { min-width: 20px; font-size: 12px; font-weight: 800; color: var(--muted); }
.menu__list button:hover, .menu__list button:focus-visible { background: var(--salt); outline: none; }
.menu__list button.is-active { color: var(--red); }
.menu__list button.is-active b { color: var(--red); }
.topbar__progress { position: absolute; left: 0; right: 0; bottom: 0; height: 2px; background: transparent; }
.topbar__progress i { display: block; height: 100%; background: var(--red); transform: scaleX(0); transform-origin: left; }

.rail { position: fixed; z-index: 30; right: calc(var(--pad) - 4px); top: 50%; transform: translateY(-50%); width: 20px; height: min(44vh, 360px); }
.rail__track, .rail__fill { position: absolute; left: 50%; top: 0; width: 2px; height: 100%; margin-left: -1px; }
.rail__track { background: var(--hairline); }
.rail__fill { background: var(--red); transform: scaleY(0); transform-origin: top; }
/* Square markers, spaced evenly by js/hud.js (the fill tracks progress between them) */
.rail button { position: absolute; left: 50%; width: 12px; height: 12px; padding: 0; transform: translate(-50%, -50%); background: #DCDCDC; border: 0; cursor: pointer; transition: background .3s; }
.rail button:hover { background: #C4C4C4; }
.rail button span { position: absolute; right: 24px; top: 50%; transform: translateY(-50%); white-space: nowrap; font-size: 12px; font-weight: 600; opacity: 0; transition: opacity .3s; pointer-events: none; }
.rail button:hover span, .rail button:focus-visible span, .rail button.is-active span { opacity: 1; }
.rail button.is-active, .rail button.is-past { background: var(--red); }
.rail button:focus-visible { outline: 2px solid var(--red); outline-offset: 4px; }


.hint { position: fixed; z-index: 25; left: 50%; bottom: calc(var(--safe-b) + 28px); transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 10px; font-size: 12px; font-weight: 600; pointer-events: none; }
.hint i { width: 2px; height: 38px; background: linear-gradient(var(--red), rgba(234,0,41,0)); transform-origin: top; animation: drip 2s var(--ease) infinite; }
@keyframes drip { 0% { transform: scaleY(0); } 50% { transform: scaleY(1); } 100% { transform: scaleY(1); opacity: 0; } }

/* 5. Cards ----------------------------------------------------------------
   JS sets opacity and --v (0 → 1) from the data-in / data-out ranges. */
.card { position: fixed; z-index: 20; opacity: 0; visibility: hidden; pointer-events: none; --v: 0; will-change: opacity, transform; }

.panel { position: relative; width: min(440px, calc(100vw - 2 * var(--pad))); padding: 28px 30px 26px; background: var(--white); color: var(--text); box-shadow: var(--shadow); }
.panel::before { content: ''; position: absolute; left: 0; top: 0; width: 56px; height: 4px; background: var(--red); }
.panel__kicker { font-size: 13px; font-weight: 700; color: var(--red); }
.panel__label { margin-top: 18px; font-size: 13px; font-weight: 500; color: var(--muted); }
.figure { display: flex; align-items: baseline; gap: 10px; margin-top: 6px; font-weight: 800; font-size: clamp(46px, 5.4vw, 74px); line-height: 1; letter-spacing: -.045em; color: var(--red); }
.figure__unit { font-size: .36em; font-weight: 800; letter-spacing: 0; }
.figure__suffix { font-size: .3em; font-weight: 600; letter-spacing: 0; color: var(--muted); }
.chip { display: inline-flex; align-items: center; gap: 9px; margin-top: 18px; padding: 8px 12px; font-size: 14px; font-weight: 700; border: 2px solid currentColor; }
.chip::before { content: ''; border-left: 5px solid transparent; border-right: 5px solid transparent; border-bottom: 8px solid currentColor; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 26px; }
.stats .figure { font-size: clamp(42px, 4.6vw, 62px); }
.stat__caption { margin-top: 8px; font-size: 13px; font-weight: 600; }

/* "Read more" button at the bottom of a box (cards ignore the mouse, so the button opts back in) */
.read-more { display: inline-flex; align-items: center; gap: 10px; margin-top: 20px; padding: 10px 16px; font-size: 13px; font-weight: 700; line-height: 1;
  color: var(--white); background: var(--red); text-decoration: none; pointer-events: auto; cursor: pointer; transition: background-color .2s, color .2s; }
.read-more::after { content: ''; width: 7px; height: 7px; border-top: 2px solid currentColor; border-right: 2px solid currentColor; transform: rotate(45deg); transition: transform .25s var(--ease); }
.read-more:hover, .read-more:focus-visible { background: var(--black); outline: none; }
.read-more:hover::after, .read-more:focus-visible::after { transform: translateX(3px) rotate(45deg); }
.read-more:focus-visible { outline: 2px solid var(--red); outline-offset: 3px; }
.panel--compact .read-more { margin: 4px 0 18px; }

/* Red variant — white type on brand red */
.card--red .read-more { color: var(--red); background: var(--white); }
.card--red .read-more:hover, .card--red .read-more:focus-visible { color: var(--white); background: var(--black); }
.card--red .read-more:focus-visible { outline-color: var(--white); }
.card--red .panel { background: var(--red); color: var(--white); }
.card--red .panel::before { background: var(--white); }
.card--red .panel__kicker, .card--red .figure { color: var(--white); }
.card--red .panel__label, .card--red .figure__suffix { color: rgba(255,255,255,.78); }

.card--left  { left: var(--pad); top: 50%; transform: translate3d(calc((1 - var(--v)) * -32px), -50%, 0); }
.card--right { right: calc(var(--pad) + var(--rail-space)); top: 50%; transform: translate3d(calc((1 - var(--v)) * 32px), -50%, 0); }

/* Hero */
.card--hero { left: var(--pad); bottom: calc(var(--safe-b) + 13vh); max-width: calc(100vw - 2 * var(--pad) - var(--rail-space)); transform: translate3d(0, calc((1 - var(--v)) * 34px), 0); }
.hero__title { font-weight: 900; font-size: clamp(42px, 7.6vw, 116px); line-height: .9; letter-spacing: -.045em; text-transform: uppercase; color: var(--red); }
.hero__line { display: block; overflow: hidden; padding-bottom: .04em; }
.hero__line > span { display: inline-block; }
.hero__sub { display: flex; align-items: center; gap: 14px; margin-top: 24px; font-size: 16px; font-weight: 700; }
.hero__sub::before { content: ''; width: 56px; height: 3px; background: var(--black); }
body.is-ready .hero__line > span { animation: rise 1.3s var(--ease) both; }
body.is-ready .hero__line:nth-child(2) > span { animation-delay: .12s; }
@keyframes rise { from { transform: translateY(105%); } to { transform: translateY(0); } }

/* Chairman / CEO message */
.message__head { display: flex; align-items: flex-end; gap: 20px; }
.message__by { display: flex; flex-direction: column; gap: 3px; padding-bottom: 4px; font-size: 13px; }
.message__by .panel__kicker { margin-bottom: 10px; }
.message__by b { font-size: 17px; font-weight: 800; letter-spacing: -.01em; }
.message__by span { color: var(--muted); font-weight: 500; }
.message__quote { position: relative; margin-top: 22px; padding-top: 30px; border-top: 1px solid var(--hairline); font-size: clamp(18px, 1.5vw, 22px); font-weight: 600; line-height: 1.4; letter-spacing: -.01em; }
.message__quote::before { content: '\201C'; position: absolute; left: -2px; top: 4px; font-size: 64px; font-weight: 900; line-height: .6; color: var(--red); }

/* Portrait in the brand shape: square with the bottom-left corner cut at 45° (15.7% of the side) */
.portrait { position: relative; flex: none; width: 128px; aspect-ratio: 1; background: var(--red); overflow: hidden;
  clip-path: polygon(0 0, 100% 0, 100% 100%, 15.7% 100%, 0 84.3%); }
.portrait img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: var(--focus-x, 50%) 100%; }

/* Globe heading */
.card--globe { left: var(--pad); bottom: calc(var(--safe-b) + 7vh); max-width: min(760px, calc(100vw - 2 * var(--pad))); transform: translate3d(0, calc((1 - var(--v)) * 30px), 0); }
.globe__title { font-weight: 900; font-size: clamp(32px, 4.7vw, 72px); line-height: .95; letter-spacing: -.04em; text-transform: uppercase; color: var(--red); max-width: 14ch; }

/* Metric lists: SAL at a glance (red, left) and Market overview (white, top right) */
.panel--compact { width: 340px; padding: 22px 24px 8px; }
.metrics { list-style: none; margin-top: 8px; }
.metric { display: flex; align-items: center; gap: 16px; padding: 14px 0; border-top: 1px solid var(--hairline); }
.metric:first-child { border-top: 0; }
.metric__value { display: flex; align-items: baseline; gap: 4px; min-width: 128px; font-size: 38px; font-weight: 800; line-height: 1; letter-spacing: -.04em; color: var(--red); white-space: nowrap; }
.metric__value small { font-size: .38em; font-weight: 800; letter-spacing: 0; }
.metric__label { display: flex; flex-direction: column; gap: 3px; font-size: 13px; font-weight: 700; line-height: 1.3; }
.metric__label span { font-size: 12px; font-weight: 500; color: var(--muted); }
.card--red .metric { border-color: rgba(255,255,255,.28); }
.card--red .metric__value { color: var(--white); }
.card--red .metric__label span { color: rgba(255,255,255,.8); }

/* 6. Vehicle tags (positioned by JS) ------------------------------------------- */
.labels { position: fixed; inset: 0; z-index: 12; pointer-events: none; overflow: hidden; }
.vtag { position: absolute; left: 0; top: 0; padding-left: 12px; white-space: nowrap; opacity: 0; will-change: transform, opacity; }
.vtag::before { content: ''; position: absolute; left: 0; top: 2px; width: 3px; height: calc(100% + 28px); background: linear-gradient(var(--red), rgba(234,0,41,0)); }
.vtag span { display: block; font-size: 11px; font-weight: 700; color: var(--red); }
.vtag b { display: block; font-size: 15px; font-weight: 800; }

/* 7. 3D livery ------------------------------------------------------------
   Live HTML placed on the models. Box size is fixed by the model (200px = 1 unit);
   change content, colours and proportions freely. */
.livery { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4%; font-family: var(--font); font-weight: 800; line-height: 1; white-space: nowrap; overflow: hidden; backface-visibility: hidden; -webkit-backface-visibility: hidden; user-select: none; }
.livery .logo { height: 70%; }
.livery small { display: block; font-size: 44px; font-weight: 700; letter-spacing: .03em; color: var(--black); }
.livery--fin { color: var(--white); }
.livery--fin .logo { color: var(--white); height: 58%; }
.livery--fuselage { flex-direction: row; gap: 28px; color: var(--red); font-size: 64px; }
.livery--fuselage .logo { height: 78%; }
.livery--hull .logo { height: 78%; }
.livery--trailer .logo { height: 62%; }
.livery--wall { background: var(--white); }
.livery--wall .logo { height: 58%; }
.livery--wall small { font-size: 90px; }

.noscript { padding: 40px; max-width: 60ch; line-height: 1.6; }

/* 8. Responsive (desktop-first) ------------------------------------------ */
@media (max-width: 760px) {
  :root { --rail-space: 0px; --topbar-h: 62px; }
  .rail { display: none; }
  .topbar { padding-bottom: 16px; }
  .topbar .logo { height: 38px; }
  .topbar__actions { gap: 12px; }
  .topbar__title { font-size: 12px; }

  /* Cards become bottom sheets */
  .card--left, .card--right { left: var(--pad); right: var(--pad); top: auto; bottom: calc(var(--safe-b) + 18px); transform: translate3d(0, calc((1 - var(--v)) * 26px), 0); }
  .panel { width: auto; padding: 22px 22px 20px; }
  .figure { font-size: clamp(40px, 12vw, 56px); }
  .stats { gap: 16px; }
  .stats .figure { font-size: clamp(36px, 11vw, 48px); }

  .card--hero { bottom: calc(var(--safe-b) + 96px); }
  .hero__title { font-size: clamp(38px, 12.4vw, 68px); }
  .hero__sub { font-size: 14px; }

  .message__head { gap: 14px; }
  .portrait { width: 88px; }
  .message__by .panel__kicker { margin-bottom: 6px; }
  .message__by b { font-size: 15px; }
  .message__quote { font-size: 16px; margin-top: 14px; padding-top: 24px; }
  .message__quote::before { font-size: 52px; }

  .card--globe { bottom: calc(var(--safe-b) + 22px); }
  .globe__title { font-size: clamp(30px, 9.5vw, 46px); }

  .panel--compact { width: auto; padding: 14px 16px 4px; }
  .metrics { display: grid; grid-template-columns: repeat(3, 1fr); margin-top: 4px; }
  .metric { flex-direction: column; align-items: flex-start; gap: 6px; padding: 8px 10px 12px; border-top: 0; border-left: 1px solid var(--hairline); }
  .metric:first-child { padding-left: 0; border-left: 0; }
  .metric__value { min-width: 0; font-size: clamp(20px, 6.2vw, 26px); }
  .metric__label { font-size: 11px; }
  .metric__label span { display: none; }
  .read-more { margin-top: 14px; padding: 9px 14px; font-size: 12px; }
  .panel--compact .read-more { margin: 2px 0 12px; }

  .vtag b { font-size: 13px; }
  .hint { bottom: calc(var(--safe-b) + 20px); }
}

@media (max-width: 380px) {
  .topbar__title { display: none; }
  .stats { grid-template-columns: 1fr; gap: 10px; }
}

/* Phones in landscape: keep everything clear of the short viewport */
@media (max-height: 520px) and (orientation: landscape) {
  :root { --topbar-h: 54px; }
  .topbar { padding-bottom: 12px; }
  .rail { display: none; }
  .message__quote { font-size: 15px; margin-top: 10px; padding-top: 20px; }
  .portrait { width: 72px; }
  .panel--compact { width: 260px; padding: 12px 16px 2px; }
  .metric { padding: 8px 0; }
  .metric__value { min-width: 84px; font-size: 26px; }
  .metric__label span { display: none; }
  .card--hero { bottom: calc(var(--safe-b) + 24px); }
  .hero__title { font-size: clamp(32px, 8vh + 2vw, 56px); }
  .card--left, .card--right { top: auto; bottom: calc(var(--safe-b) + 14px); transform: translate3d(0, calc((1 - var(--v)) * 20px), 0); }
  .card--right { right: var(--pad); }
  .panel { width: min(380px, 46vw); padding: 16px 18px; }
  .figure { font-size: 40px; }
  .stats .figure { font-size: 34px; }
  .globe__title { font-size: 30px; }
  .card--globe { bottom: calc(var(--safe-b) + 14px); }
}

/* 9. Reduced motion ------------------------------------------------------ */
@media (prefers-reduced-motion: reduce) {
  body.is-ready .hero__line > span, .hint i { animation: none; }
}

/* 10. Static fallback (no WebGL or blocked CDN) --------------------------- */
body.is-fallback .stage, body.is-fallback .livery-layer, body.is-fallback .labels, body.is-fallback .rail,
body.is-fallback .hint, body.is-fallback .scroll-space, body.is-fallback .menu-btn, body.is-fallback .menu { display: none; }
body.is-fallback .story { display: flex; flex-direction: column; gap: 40px; padding: calc(var(--safe-t) + 110px) var(--pad) 80px; }
body.is-fallback .card { position: relative; inset: auto; opacity: 1 !important; visibility: visible !important; transform: none !important; max-width: none; }
