/* ==========================================================
   Sciencekakura holding page: one screen, no scrolling.
   Brand tokens match assets/css/styles.css (red #CC0000, navy #000066,
   the logo's red-to-navy gradient, Source Serif 4 + IBM Plex Sans, self-hosted).
   Sizes scale with the smaller of the screen's width and height, so the
   whole page fits one screen. At very high zoom it scrolls instead of
   cutting text off.
   The construction site, under a dusk sky in the logo's gradient: a tower
   crane brings the logo in and keeps working on a 12-second loop (lift, move
   along the arm, back, set down). Equipment stands along the edge of the
   site; below it run the sidewalk, the curb and the road, which
   carries the footer. Landscape screens put the crane beside the headline,
   portrait screens underneath it.
   Motion tokens follow transitions.dev (texts reveal, badge pop).
   ========================================================== */

@font-face { font-family: "Source Serif 4"; src: url("../fonts/source-serif-4-600.woff2") format("woff2"); font-weight: 600; font-style: normal; font-display: swap; }
@font-face { font-family: "IBM Plex Sans"; src: url("../fonts/ibm-plex-sans-400.woff2") format("woff2"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "IBM Plex Sans"; src: url("../fonts/ibm-plex-sans-500.woff2") format("woff2"); font-weight: 500; font-style: normal; font-display: swap; }

:root {
  /* Colour roles */
  --red: #CC0000;
  --navy: #000066;
  --plum: #61005C;            /* from the logo gradient */
  --lavender: #CFCFF5;        /* secondary text on navy (11:1) */
  --paper: #FFFFFF;
  --deep: #00003A;            /* tyres, tracks, pipes */
  --slab: #2E2E8C;            /* sidewalk */
  --curb: #DCDCF5;
  --asphalt: #07072F;         /* road */

  /* Type: four sizes */
  --font-display: "Source Serif 4", Georgia, "Times New Roman", serif;
  --font-body: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --step-hero: clamp(30px, min(10.4vw, 13.5svh), 156px);
  --step-lede: clamp(20px, min(2.4vw, 3.6svh), 34px);
  --step-body: 17px;
  --step-small: 14px;

  /* Frame */
  --margin: clamp(16px, 3.2vw, 48px);
  --crane-col: clamp(150px, 27vw, 500px);
  --col-gap: clamp(24px, 3vw, 48px);
  --sink: 44px;                                     /* the bottom strip of the site, where the crane and the equipment stand */
  --kit: clamp(40px, min(11vw, 9svh), 110px);       /* height of the excavator; the other equipment is to scale */

  /* The crane's working loop: starts once the logo has arrived and settled */
  --loop: 12s;
  --loop-start: 4100ms;

  /* Motion tokens (transitions.dev) */
  --duration-quick: 150ms;
  --ease-out: ease-out;
  --ease-smooth-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-bounce: cubic-bezier(0.34, 1.36, 0.64, 1);
  --stagger-dur: 600ms;
  --stagger-distance: 20px;
  --stagger-stagger: 70ms;
  --stagger-blur: 3px;
  --stagger-ease: cubic-bezier(0.22, 1, 0.36, 1);
}

*, *::before, *::after { box-sizing: border-box; }

html {
  background: var(--navy);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--navy);
  color: var(--paper);
  font: 400 var(--step-body)/1.5 var(--font-body);
  -webkit-font-smoothing: antialiased;
}

::selection { background: var(--paper); color: var(--navy); }

p, h1 { margin: 0; }

a {
  color: inherit;
  text-decoration-line: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
  transition: text-underline-offset var(--duration-quick) var(--ease-out);
}
a:hover { text-underline-offset: 0.32em; }

:focus-visible { outline: 3px solid var(--paper); outline-offset: 3px; border-radius: 4px; }

/* ---------- The one screen ---------- */
.page {
  min-height: 100vh; /* taste-skill-ignore: fallback for browsers without svh */
  min-height: 100svh;
  display: grid;
  grid-template-rows: 1fr auto auto auto;   /* stage, site edge, sidewalk, road */
  /* The crane and the headline drawing must not add scrolling. */
  position: relative;
  overflow: hidden;
  overflow: clip;
  /* Dusk over the site: navy overhead, turning to the logo's plum and red at the horizon. */
  background: linear-gradient(180deg, #00004A 0%, var(--navy) 32%, #22006A 58%, var(--plum) 82%, #870050 100%); /* taste-skill-ignore: the logo's own navy-to-red gradient as the sky */

  /* The headline drawing (transitions.dev text variant), in light dots on navy */
  --tig-line: rgba(207, 207, 245, 0.55);
  --tig-strong: #FFFFFF;
  --tig-ink: rgba(255, 255, 255, 0.5);
  --tig-surface: var(--navy);
  --tig-text: #FFFFFF;
  --tig-muted: var(--lavender);
  --tig-font: var(--font-body);
}

/* Portrait screens: the headline at the top, the crane filling the space below it. */
.stage {
  grid-row: 1;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  row-gap: clamp(12px, 3svh, 32px);
  padding: clamp(24px, 6svh, 72px) var(--margin) 0;
}
.copy { min-width: 0; }

.title {
  font: 600 var(--step-hero)/0.98 var(--font-display);
  letter-spacing: -0.03em;
  font-optical-sizing: none;   /* the drawing traces the same letter shapes the page shows */
}
.draw-wait .title { opacity: 0; }
.line { display: block; }

.lede {
  margin-top: clamp(14px, 3svh, 32px);
  font: 500 var(--step-lede)/1.3 var(--font-body);
  color: var(--lavender);
}

/* ---------- The crane ---------- */
.crane {
  display: block;
  width: 100%;
  height: 100%;
  contain: size;          /* the crane fills the space left; it never makes the page taller */
  overflow: visible;
  translate: 0 var(--sink);   /* its foot stands on the sidewalk edge, like the equipment */
}

.crane-steel { fill: none; stroke: var(--paper); stroke-width: 3; stroke-linejoin: round; stroke-linecap: round; }
.crane-lace { stroke: var(--lavender); stroke-width: 1.75; }
.crane-tie { stroke: var(--lavender); stroke-width: 1.5; }
.crane-red { fill: var(--red); stroke: var(--paper); stroke-width: 2; }
.crane-glass { fill: var(--lavender); stroke: none; }
.crane-trolley, .crane-bar { fill: var(--paper); }
.crane-cable path { fill: none; stroke: var(--paper); stroke-width: 1.5; vector-effect: non-scaling-stroke; }
.crane-load { cursor: grab; }

/* The cable, the swing and the nudge all pivot on the trolley. */
.crane-cable, .crane-swing, .crane-nudge {
  transform-box: view-box;
  transform-origin: 165px 148px;
}

/* Arrival: 1. the trolley runs out along the jib, 2. the cable lowers the logo, 3. it sways and settles. */
.crane-run   { animation: crane-run 1000ms var(--ease-smooth-out) 300ms both; }
.crane-cable { animation: crane-cable 1300ms var(--ease-smooth-out) 1200ms both; }
.crane-load  { animation: crane-load 1300ms var(--ease-smooth-out) 1200ms both; }
.crane-swing { animation: crane-sway 3000ms ease-in-out 1100ms both; }

/* Then, with JavaScript (so the footer button can stop it), the crane keeps working.
   Each loop starts and ends with the logo at rest, so it repeats without a jump. */
.js .crane-run {
  animation:
    crane-run 1000ms var(--ease-smooth-out) 300ms both,
    crane-run-loop var(--loop) ease-in-out var(--loop-start) infinite;
}
.js .crane-cable {
  animation:
    crane-cable 1300ms var(--ease-smooth-out) 1200ms both,
    crane-cable-loop var(--loop) ease-in-out var(--loop-start) infinite;
}
.js .crane-load {
  animation:
    crane-load 1300ms var(--ease-smooth-out) 1200ms both,
    crane-load-loop var(--loop) ease-in-out var(--loop-start) infinite;
}
.js .crane-swing {
  animation:
    crane-sway 3000ms ease-in-out 1100ms both,
    crane-sway-loop var(--loop) ease-in-out var(--loop-start) infinite;
}

/* Stopped on an earlier visit: the logo waits at rest. Starting again skips the
   arrival and goes straight into the loop at the lift. */
.crane-still :is(.crane-run, .crane-cable, .crane-load, .crane-swing) { animation: none; }
.crane-restart .crane-run   { animation: crane-run-loop var(--loop) ease-in-out calc(var(--loop) * -0.28) infinite; }
.crane-restart .crane-cable { animation: crane-cable-loop var(--loop) ease-in-out calc(var(--loop) * -0.28) infinite; }
.crane-restart .crane-load  { animation: crane-load-loop var(--loop) ease-in-out calc(var(--loop) * -0.28) infinite; }
.crane-restart .crane-swing { animation: crane-sway-loop var(--loop) ease-in-out calc(var(--loop) * -0.28) infinite; }

/* Stopped during this visit: everything holds where it is. */
.crane-paused :is(.crane-run, .crane-cable, .crane-load, .crane-swing) { animation-play-state: paused; }

/* The cable runs 272 units from the trolley (148) to the hook block (420);
   the cable's scale and the load's lift always use the same numbers, so the hook stays on the cable. */
@keyframes crane-run   { from { transform: translateX(150px); } to { transform: none; } }
@keyframes crane-cable { from { transform: scaleY(0.2); } to { transform: none; } }
@keyframes crane-load  { from { transform: translateY(-217.6px); } to { transform: none; } }
@keyframes crane-sway {
  0%   { transform: rotate(0deg); }
  14%  { transform: rotate(2.2deg); }
  34%  { transform: rotate(-1.45deg); }
  54%  { transform: rotate(0.85deg); }
  72%  { transform: rotate(-0.4deg); }
  88%  { transform: rotate(0.12deg); }
  100% { transform: rotate(0deg); }
}

/* The loop, 12 seconds:
   0–28% rest · 28–38% lift · 38–48% out along the jib · 48–60% hold ·
   60–70% back · 70–80% set down · 80–100% settle. */
@keyframes crane-run-loop {
  0%, 38%   { transform: none; }
  48%, 60%  { transform: translateX(-40px); }
  70%, 100% { transform: none; }
}
@keyframes crane-cable-loop {
  0%, 28%   { transform: none; }
  38%, 70%  { transform: scaleY(0.6); }
  80%, 100% { transform: none; }
}
@keyframes crane-load-loop {
  0%, 28%   { transform: none; }
  38%, 70%  { transform: translateY(-108.8px); }
  80%, 100% { transform: none; }
}
/* Positive turns swing the logo left. It lags behind the trolley as it sets off,
   and swings on when the trolley stops. */
@keyframes crane-sway-loop {
  0%, 38%   { transform: rotate(0deg); }
  41%       { transform: rotate(-1.9deg); }
  46%       { transform: rotate(-0.5deg); }
  51%       { transform: rotate(2deg); }
  54%       { transform: rotate(-1.1deg); }
  57%       { transform: rotate(0.5deg); }
  60%       { transform: rotate(0deg); }
  63%       { transform: rotate(1.9deg); }
  68%       { transform: rotate(0.5deg); }
  73%       { transform: rotate(-2deg); }
  76%       { transform: rotate(1deg); }
  79%       { transform: rotate(-0.5deg); }
  83%       { transform: rotate(0.25deg); }
  87%       { transform: rotate(-0.1deg); }
  91%, 100% { transform: rotate(0deg); }
}

/* ---------- Cones ---------- */
.cone-red { fill: var(--red); }
.cone-white { fill: var(--paper); }
.cone {
  transform-box: fill-box;
  transform-origin: 50% 100%;
  animation: cone-pop 520ms var(--ease-bounce) both;
}
.cone--1 { animation-delay: 2300ms; }
.cone--2 { animation-delay: 2440ms; }
@keyframes cone-pop { from { opacity: 0; transform: scale(0.3); } to { opacity: 1; transform: none; } }

/* ---------- The site edge: equipment along the sidewalk ---------- */
.ground {
  grid-row: 2;
  position: relative;
  z-index: 3;
  height: var(--sink);
}

/* The equipment stands on the sidewalk's edge, between the left margin and the hanging
   logo (coming-soon.js measures where the logo hangs and sets --site-right).
   Every drawing is 120 units tall with its ground at the bottom, so they share one scale
   and one height. Items that don't fit wrap onto a second row above, which is cut off
   completely, so only whole items show and the first in the list are kept. */
.site {
  position: absolute;
  z-index: 1;
  left: var(--margin);
  right: var(--site-right, 62%);
  bottom: 0;
  height: var(--kit);
  display: flex;
  flex-wrap: wrap-reverse;
  align-content: flex-start;   /* with wrap-reverse: the first row sits at the bottom */
  align-items: flex-start;     /* and its items stand on the bottom edge */
  justify-content: space-between;
  column-gap: clamp(16px, 2.5vw, 48px);
  overflow: hidden;
}
.kit { display: block; flex: none; width: auto; height: var(--kit); overflow: visible; }

.kit-line { fill: none; stroke: var(--paper); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.kit-red { fill: var(--red); stroke: var(--paper); stroke-width: 2; stroke-linejoin: round; }
.kit-dark { fill: var(--deep); stroke: var(--paper); stroke-width: 2.5; }
.kit-soft { fill: none; stroke: var(--lavender); stroke-width: 2; stroke-linecap: round; }
.kit-glass { fill: var(--lavender); }
.kit-pale { fill: var(--paper); }
.kit-dot { fill: var(--lavender); }
.kit-stripe { fill: var(--red); }
.kit-outline { fill: none; stroke: var(--paper); stroke-width: 2; }
.kit-arm, .kit-arm-core { fill: none; stroke-linecap: round; stroke-linejoin: round; }
.kit-arm { stroke: var(--paper); stroke-width: 10; }
.kit-arm-core { stroke: var(--red); stroke-width: 5; }
.kit-sand { fill: rgba(207, 207, 245, 0.32); stroke: var(--paper); stroke-width: 2.5; stroke-linejoin: round; }

/* ---------- Sidewalk and curb ---------- */
.sidewalk {
  grid-row: 3;
  position: relative;
  z-index: 3;
  height: clamp(16px, 2.6svh, 26px);
  border-top: 2px solid var(--lavender);    /* the paving's edge */
  border-bottom: 5px solid var(--curb);     /* the curb */
  background: repeating-linear-gradient(90deg, var(--slab) 0 62px, var(--deep) 62px 64px); /* taste-skill-ignore: paving slabs and their joints, two flat colours */
}

/* ---------- The road, which carries the footer ---------- */
.foot {
  grid-row: 4;
  position: relative;
  z-index: 3;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 6px 24px;
  padding: 34px var(--margin) clamp(12px, 2.4svh, 22px);
  background: var(--asphalt);
  font-size: var(--step-small);
  color: var(--lavender);
}
/* the lane markings */
.foot::before {
  content: "";
  position: absolute;
  left: 0; right: 0;
  top: 14px;
  height: 4px;
  background: repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.85) 0 36px, transparent 36px 72px); /* taste-skill-ignore: dashed lane line */
}
.foot-legal { display: flex; flex-wrap: wrap; gap: 4px 16px; }

/* Stop / start the crane. Only with JavaScript, and never with reduced motion. */
.crane-toggle {
  display: none;
  align-items: center;
  gap: 8px;
  min-height: 32px;
  margin: -6px -12px;
  padding: 6px 12px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--lavender);
  font: 500 var(--step-small)/1.2 var(--font-body);
  cursor: pointer;
  transition:
    background-color var(--duration-quick) var(--ease-out),
    color var(--duration-quick) var(--ease-out);
}
.js .crane-toggle { display: inline-flex; }
.crane-toggle:hover { background: rgba(255, 255, 255, 0.12); color: var(--paper); }
.crane-toggle-icon { display: block; width: 14px; height: 14px; fill: currentColor; }
.icon-play { display: none; }
:is(.crane-paused, .crane-still) .icon-pause { display: none; }
:is(.crane-paused, .crane-still) .icon-play { display: inline; }

/* ---------- Landscape screens: the crane beside the headline ---------- */
@media (min-aspect-ratio: 5/4) {
  :root {
    --step-hero: clamp(30px, min(8.2vw, 13.5svh), 156px);
    --kit: clamp(40px, min(13svh, 7vw), 140px);
  }
  .stage {
    grid-template-rows: none;
    grid-template-columns: minmax(0, 1fr) var(--crane-col);
    align-items: center;
    column-gap: var(--col-gap);
    padding: clamp(16px, 4svh, 48px) var(--margin) 0;
  }
  /* keep the headline clear of the equipment below it */
  .copy { padding-bottom: calc(var(--kit) + clamp(12px, 3svh, 32px)); }
  .crane { align-self: stretch; }
  .site { right: var(--site-right, calc(var(--margin) + var(--crane-col) + var(--col-gap))); }
}

/* Short screens (phones held sideways): a shallower street. */
@media (max-height: 520px) {
  :root { --sink: 30px; }
  .stage { padding-top: 10px; }
  .sidewalk { height: 12px; border-bottom-width: 4px; }
  .foot { padding-top: 22px; padding-bottom: 8px; row-gap: 2px; }
  .foot::before { top: 8px; height: 3px; }
}

/* ---------- Entrance (only with JavaScript, never with reduced motion) ---------- */
.js .rv {
  opacity: 0;
  translate: 0 var(--stagger-distance);
  filter: blur(var(--stagger-blur));
}
.js.is-in .rv {
  opacity: 1;
  translate: none;
  filter: none;
  transition:
    opacity var(--stagger-dur) var(--stagger-ease),
    translate var(--stagger-dur) var(--stagger-ease),
    filter var(--stagger-dur) var(--stagger-ease);
  transition-delay: calc(var(--i, 0) * var(--stagger-stagger));
}

/* Reduced motion: the logo hangs still, nothing loops, and there is nothing to stop. */
@media (prefers-reduced-motion: reduce) {
  .js .rv { opacity: 1; translate: none; filter: none; }
  .crane-run, .crane-cable, .crane-load, .crane-swing, .cone { animation: none !important; }
  .crane-toggle { display: none !important; }
  *, *::before, *::after { transition: none !important; }
}
