/* ---------------------------------------------------------------------------------------------------------------
   Unifloq: design tokens first. The 3D scene reads --bg, --model, --shade, --ink, --muted, --person-1..8 and the
   alphas from here once at load (src/theme.js), so change the look here. The colours are the product's own
   (docs/design/phase-4/DESIGN.md): warm paper and ink, white cards, and eight person colours. Colour means one thing
   only: who is looking after it. Red is for failure, so it does not appear on this site.
   --------------------------------------------------------------------------------------------------------------- */
@font-face {
  font-family: "Bricolage Grotesque";
  font-weight: 200 800;
  font-display: swap;
  src: url("fonts/bricolage-grotesque-latin-wght-normal.woff2") format("woff2");
  unicode-range:
    U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329,
    U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Bricolage Grotesque";
  font-weight: 200 800;
  font-display: swap;
  src: url("fonts/bricolage-grotesque-vietnamese-wght-normal.woff2") format("woff2");
  unicode-range:
    U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+0300-0301,
    U+0303-0304, U+0308-0309, U+0323, U+0329, U+1EA0-1EF9, U+20AB;
}
@font-face {
  font-family: "Be Vietnam Pro";
  font-weight: 400;
  font-display: swap;
  src: url("fonts/be-vietnam-pro-latin-400-normal.woff2") format("woff2");
  unicode-range:
    U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329,
    U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Be Vietnam Pro";
  font-weight: 400;
  font-display: swap;
  src: url("fonts/be-vietnam-pro-vietnamese-400-normal.woff2") format("woff2");
  unicode-range:
    U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+0300-0301,
    U+0303-0304, U+0308-0309, U+0323, U+0329, U+1EA0-1EF9, U+20AB;
}
@font-face {
  font-family: "Be Vietnam Pro";
  font-weight: 500;
  font-display: swap;
  src: url("fonts/be-vietnam-pro-latin-500-normal.woff2") format("woff2");
  unicode-range:
    U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329,
    U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Be Vietnam Pro";
  font-weight: 500;
  font-display: swap;
  src: url("fonts/be-vietnam-pro-vietnamese-500-normal.woff2") format("woff2");
  unicode-range:
    U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+0300-0301,
    U+0303-0304, U+0308-0309, U+0323, U+0329, U+1EA0-1EF9, U+20AB;
}
@font-face {
  font-family: "Be Vietnam Pro";
  font-weight: 600;
  font-display: swap;
  src: url("fonts/be-vietnam-pro-latin-600-normal.woff2") format("woff2");
  unicode-range:
    U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329,
    U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Be Vietnam Pro";
  font-weight: 600;
  font-display: swap;
  src: url("fonts/be-vietnam-pro-vietnamese-600-normal.woff2") format("woff2");
  unicode-range:
    U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+0300-0301,
    U+0303-0304, U+0308-0309, U+0323, U+0329, U+1EA0-1EF9, U+20AB;
}

:root {
  /* palette (read by the 3D scene) */
  --bg: #f5f2ed; /* paper: page, WebGL clear colour and fog */
  --model: #ffffff; /* M_Model: the message cards */
  --shade: #e3dacb; /* M_Shade: the table, a warm sand */
  --ink: #1e1b18; /* outlines, text, the draft's dashes, the citation tab */
  --muted: #756d64; /* secondary text, the writing lines on cards */
  --border: #e4ddd2;
  --person-1: #0f766e; /* jade */
  --person-2: #4338ca; /* indigo */
  --person-3: #b45309; /* saffron */
  --person-4: #be185d; /* rose */
  --person-5: #0369a1; /* sky */
  --person-6: #7e22ce; /* plum */
  --person-7: #4d7c0f; /* olive */
  --person-8: #c2410c; /* coral */
  --line-alpha: 0.5; /* opacity of the 3D ink outlines */
  --shadow-alpha: 0.15; /* how dark the table's shadow is on the floor */
  --exposure: 1.1;

  /* derived UI colours */
  --panel-bg: color-mix(in srgb, var(--bg) 88%, transparent);
  --rule: color-mix(in srgb, var(--ink) 20%, transparent);

  /* type */
  --font-display: "Bricolage Grotesque", "Be Vietnam Pro", "Helvetica Neue", Arial, sans-serif;
  --font-body: "Be Vietnam Pro", "Helvetica Neue", Arial, sans-serif;

  /* layout */
  --gutter: clamp(16px, 2.4vw, 40px);
  --bar-h: 64px;
  --panel-w: min(440px, 36vw);
  --rail-w: 28px;
  /* the part of the window where the 3D subject should sit: the camera's projection centre is moved into it */
  --view-top: var(--bar-h);
  --view-left: calc(var(--panel-w) + var(--gutter) * 2);
  --view-right: calc(var(--rail-w) + var(--gutter) + 8px);
  --view-bottom: 0px;
}

* {
  box-sizing: border-box;
}
html {
  background: var(--bg);
  scroll-behavior: auto;
  -webkit-text-size-adjust: 100%;
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 16px/1.55 var(--font-body);
  -webkit-font-smoothing: antialiased;
}
a {
  color: inherit;
}
:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 3px;
}

.skip {
  position: fixed;
  z-index: 10;
  top: 8px;
  left: 8px;
  padding: 10px 14px;
  background: var(--ink);
  color: var(--bg);
  transform: translateY(-200%);
}
.skip:focus {
  transform: none;
}

/* ---- layers: canvas, labels, bar and rail, then the reading panels ---- */
#scene {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  height: 100lvh;
  z-index: 0;
  display: block;
}
#view-frame {
  position: fixed;
  inset: var(--view-top) var(--view-right) var(--view-bottom) var(--view-left);
  visibility: hidden;
  pointer-events: none;
}
#labels {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  overflow: hidden;
}
#story {
  position: relative;
  z-index: 4;
  pointer-events: none;
}

/* ---- the bar: the wordmark on the left; language, Sign in and Get started on the right ---- */
.bar {
  position: fixed;
  z-index: 5;
  top: 0;
  left: 0;
  right: 0;
  height: var(--bar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--gutter);
  background: var(--panel-bg);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--rule);
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--ink);
}
.brand .mark {
  display: block;
  flex: none;
}
.brand .word {
  font: 800 23px/1 var(--font-display);
  letter-spacing: -0.03em;
}
.bar-actions {
  display: flex;
  align-items: center;
  gap: clamp(10px, 1.6vw, 22px);
}
.lang {
  display: inline-flex;
  border: 1px solid var(--rule);
  border-radius: 999px;
  padding: 2px;
}
.lang button {
  font: 600 12px/1 var(--font-body);
  letter-spacing: 0.04em;
  min-width: 36px;
  min-height: 28px;
  padding: 0 10px;
  border: 0;
  border-radius: 999px;
  background: none;
  color: var(--muted);
  cursor: pointer;
}
.lang button:hover {
  color: var(--ink);
}
.lang button[aria-pressed="true"] {
  background: var(--ink);
  color: var(--bg);
}

/* ---- buttons: one ink pill is the page's one action; Sign in is quieter, a text link ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 24px;
  border-radius: 999px;
  font: 600 15px/1 var(--font-body);
  text-decoration: none;
  transition:
    background-color 0.18s ease,
    transform 0.18s ease;
}
.btn-primary {
  background: var(--ink);
  color: var(--model);
}
.btn-primary:hover {
  background: color-mix(in srgb, var(--ink) 82%, var(--bg));
}
.btn-primary:active {
  transform: scale(0.98);
}
.btn-small {
  min-height: 36px;
  padding: 0 18px;
  font-size: 14px;
}
.link {
  font: 600 14px/1.2 var(--font-body);
  text-decoration: underline;
  text-decoration-color: var(--rule);
  text-underline-offset: 4px;
  text-decoration-thickness: 1px;
  padding: 10px 2px;
  transition: text-decoration-color 0.18s ease;
}
.link:hover {
  text-decoration-color: var(--ink);
}

/* ---- the rail: chapter links on the right (desktop only) ---- */
.rail {
  position: fixed;
  z-index: 3;
  top: 50%;
  right: var(--gutter);
  transform: translateY(-50%);
  width: var(--rail-w);
}
.rail ol {
  list-style: none;
  margin: 0;
  padding: 0;
}
.rail a {
  position: relative;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  min-height: 28px;
  color: var(--muted);
  text-decoration: none;
  font: 500 13px/1.3 var(--font-body);
}
.rail i {
  width: 9px;
  height: 9px;
  border: 1px solid var(--ink);
  border-radius: 50%;
  flex: none;
  margin-right: 7px;
}
.rail .num {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
}
/* the chapter's name shows on hover or keyboard focus, to the left of its dot */
.rail .name {
  position: absolute;
  right: 28px;
  padding: 4px 10px;
  white-space: nowrap;
  background: var(--panel-bg);
  border-top: 1px solid var(--ink);
  color: var(--ink);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
}
.rail a:hover .name,
.rail a:focus-visible .name {
  opacity: 1;
}
.rail a.current i {
  background: var(--ink);
}

/* ---- reading panels: glass with a thin ink rule on top ---- */
.stage {
  height: 100vh;
  height: calc(var(--stage-h, 100) * 1svh);
}
.beat {
  height: 100%;
  display: flex;
  align-items: center;
  padding: var(--bar-h) 0 0 var(--gutter);
}
.panel {
  width: var(--panel-w);
  pointer-events: auto;
  padding: 26px 28px 30px;
  background: var(--panel-bg);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--ink);
  transition: opacity 0.25s ease;
}
.panel-hero {
  width: min(520px, 38vw);
}
.is-hopping .panel {
  opacity: 0;
  pointer-events: none;
}
.kicker {
  margin: 0 0 16px;
  font: 600 12px/1.3 var(--font-body);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.kicker b {
  font-weight: 600;
  color: var(--ink);
  margin-right: 10px;
}
.panel h1,
.panel h2 {
  margin: 0 0 16px;
  font: 700 clamp(30px, 3.1vw, 46px) / 1.1 var(--font-display);
  letter-spacing: -0.02em;
  text-wrap: balance;
}
.panel h1 {
  font-weight: 800;
  font-size: clamp(36px, 4.2vw, 62px);
  line-height: 1.04;
  letter-spacing: -0.03em;
}
.panel .body {
  margin: 0;
  max-width: 44ch;
  font-size: 16.5px;
  line-height: 1.6;
}
.actions {
  margin: 24px 0 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 20px;
}

/* ---- labels over the scene: a square anchor, a hairline stem, a glass chip (strong = inverted) ---- */
.label {
  position: absolute;
  left: 0;
  top: 0;
  will-change: transform, opacity;
}
.label > i {
  position: absolute;
  left: -3px;
  top: -3px;
  width: 6px;
  height: 6px;
  background: var(--ink);
}
.label > b {
  position: absolute;
  left: -0.5px;
  bottom: 3px;
  width: 1px;
  height: var(--rise, 28px);
  background: var(--ink);
}
.label .chip {
  position: absolute;
  left: -1px;
  bottom: calc(var(--rise, 28px) + 3px);
  display: inline-flex;
  align-items: center;
  gap: 7px;
  white-space: nowrap;
  padding: 5px 9px 5px;
  font: 500 12.5px/1.25 var(--font-body);
  background: var(--panel-bg);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  color: var(--ink);
  border-top: 1px solid var(--ink);
}
.label .dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex: none;
}
.label.left .chip {
  left: auto;
  right: -1px;
}
.label.strong .chip {
  background: var(--ink);
  color: var(--bg);
}

/* ---- loader: a hairline in the free area, so the panels stay readable while the model loads ---- */
#loader {
  position: fixed;
  inset: var(--view-top) var(--view-right) var(--view-bottom) var(--view-left);
  z-index: 3;
  pointer-events: none;
  display: grid;
  place-content: center;
  transition:
    opacity 0.5s ease,
    visibility 0.5s;
}
#loader .track {
  width: 180px;
  height: 1px;
  background: var(--rule);
}
#loader .bar-fill {
  height: 1px;
  width: 0;
  background: var(--ink);
  transition: width 0.3s ease;
}
.ready #loader {
  opacity: 0;
  visibility: hidden;
}

/* ---- footer ---- */
.foot {
  position: relative;
  z-index: 4;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 14px var(--gutter) calc(14px + env(safe-area-inset-bottom));
  background: var(--panel-bg);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--rule);
  font: 500 13px/1.3 var(--font-body);
  color: var(--muted);
}

/* ---- phone: a slim bar, the panel low over the bottom, the table shifted up ---- */
@media (max-width: 760px) {
  :root {
    --bar-h: 52px;
    --view-left: 0px;
    --view-right: 0px;
    --view-top: calc(var(--bar-h) + 6px);
    --view-bottom: 50svh;
    --gutter: 16px;
  }
  .rail {
    display: none;
  }
  .brand .word {
    font-size: 20px;
  }
  .brand .mark {
    width: 24px;
    height: 24px;
  }
  .bar-actions {
    gap: 8px;
  }
  .btn-small {
    padding: 0 14px;
  }
  .beat {
    align-items: flex-end;
    padding: 0 12px 12px;
  }
  .panel,
  .panel-hero {
    width: 100%;
    padding: 18px 20px 20px;
  }
  .kicker {
    margin-bottom: 10px;
  }
  .panel h1,
  .panel h2 {
    font-size: clamp(25px, 7.4vw, 30px);
    margin-bottom: 10px;
  }
  .panel h1 {
    font-size: clamp(31px, 9vw, 38px);
  }
  .panel .body {
    font-size: 14.5px;
    line-height: 1.5;
  }
  .actions {
    margin-top: 16px;
  }
  .label .chip {
    font-size: 11.5px;
    padding: 4px 7px;
  }
  .label.minor {
    display: none;
  }
}
@media (max-width: 760px) and (max-height: 720px) {
  :root {
    --view-bottom: 58svh;
  }
  .panel .body {
    font-size: 13.5px;
  }
}
@media (max-width: 520px) {
  .bar-signin {
    display: none;
  }
}

/* ---- no WebGL or no JavaScript: the story is text, in order ---- */
.no-js #scene,
.no-js #labels,
.no-js .rail,
.no-js #loader,
.no-js #view-frame,
.no-js .lang,
.no-webgl #scene,
.no-webgl #labels,
.no-webgl .rail,
.no-webgl #loader,
.no-webgl #view-frame {
  display: none;
}
.no-js .bar,
.no-webgl .bar {
  position: static;
}
.no-js .stage,
.no-webgl .stage {
  height: auto;
}
.no-js .beat,
.no-webgl .beat {
  display: block;
  height: auto;
  padding: var(--gutter);
  max-width: 680px;
  margin: 0 auto;
}
.no-js .panel,
.no-webgl .panel {
  width: auto;
  background: var(--model);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}
.no-js .foot,
.no-webgl .foot {
  margin-top: var(--gutter);
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 0.2s !important;
    animation: none !important;
    scroll-behavior: auto !important;
  }
}
