/* Kieksi Digital studio page. The portfolio's DESIGN.md is the design system: one ink on one ground, IBM Plex Sans
   in thin weights, Plex Mono for labels and numerals only, no accent colour, every colour from a token.
   The page is dark only, like the stage, so the tokens are not themed. */

@font-face { font-family: "IBM Plex Sans"; src: url("../fonts/plex-sans-var.woff2") format("woff2"); font-weight: 100 700; font-style: normal; font-display: swap; }
@font-face { font-family: "IBM Plex Sans"; src: url("../fonts/plex-sans-italic.woff2") format("woff2"); font-weight: 100 700; font-style: italic; font-display: swap; }
@font-face { font-family: "IBM Plex Mono"; src: url("../fonts/plex-mono-400.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "IBM Plex Mono"; src: url("../fonts/plex-mono-500.woff2") format("woff2"); font-weight: 500; font-display: swap; }

:root {
  --ground: #050607;
  --ink: #EEF1F3;
  --ink-2: #9AA3AA;
  --ink-3: #5E676E;
  --line: rgba(238, 241, 243, .28);
  --line-soft: rgba(238, 241, 243, .14);
  --hud-bg: rgba(5, 6, 7, .55);
  --halo: rgba(5, 6, 7, .9);
  --veil: rgba(5, 6, 7, .62);
  --vignette: rgba(0, 0, 0, .6);

  --f-sans: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --f-mono: "IBM Plex Mono", ui-monospace, Menlo, Consolas, monospace;
  /* the stage's sizes at 1920 px wide, scaled down to a phone */
  --fs-h1: clamp(40px, 5vw, 96px);
  --fs-body: clamp(18px, 1.36vw, 26px);
  --fs-mail: clamp(28px, 2.5vw, 48px);
  --fs-label: 16px;
  --gutter: max(16px, min(7.1vw, 136px));
  --top: clamp(88px, 11.8vh, 128px);

  --ease: cubic-bezier(.65, 0, .35, 1);
  --dur-out: 250ms;
  --dur-in: 600ms;
  --dur-line: 700ms;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { background: var(--ground); }
body { margin: 0; background: var(--ground); color: var(--ink); font-family: var(--f-sans); font-weight: 300; font-size: var(--fs-body); line-height: 1.5;
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
p, h1, h2, figure, ol { margin: 0; }
img { max-width: 100%; height: auto; display: block; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 4px; }

.label { font-family: var(--f-mono); font-size: var(--fs-label); font-weight: 400; letter-spacing: .16em; text-transform: uppercase; color: var(--ink-2); }
.skip { position: absolute; left: 16px; top: -60px; z-index: 30; padding: 10px 14px; background: var(--ink); color: var(--ground);
  font-family: var(--f-mono); font-size: var(--fs-label); text-decoration: none; }
.skip:focus { top: 16px; }

/* ---- the scene behind everything ---- */
.scene-canvas { position: fixed; inset: 0; width: 100%; height: 100%; display: block; z-index: 0; }
.vignette { position: fixed; inset: 0; z-index: 1; pointer-events: none; background: radial-gradient(ellipse 75% 70% at 50% 45%, transparent 50%, var(--vignette) 100%); }
.grain { position: fixed; inset: 0; z-index: 1; pointer-events: none; opacity: .09; mix-blend-mode: screen;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='240' height='240'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 1  0 0 0 0 1  0 0 0 0 1  0 0 0 .55 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>"); }

/* ---- top bar ---- */
.top { position: fixed; left: 0; right: 0; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between;
  padding: max(20px, env(safe-area-inset-top)) max(var(--gutter), env(safe-area-inset-right)) 20px max(var(--gutter), env(safe-area-inset-left)); pointer-events: none; }
.top a { pointer-events: auto; }
.brand { display: inline-flex; align-items: center; gap: 12px; text-decoration: none; }
.brand__mark { width: 24px; height: 23px; fill: var(--ink); }
.brand__name { font-family: var(--f-mono); font-size: var(--fs-label); letter-spacing: .16em; text-transform: uppercase; }
.top__hello { font-family: var(--f-mono); font-size: var(--fs-label); letter-spacing: .16em; text-transform: uppercase; text-decoration: none;
  padding: 10px 14px; border: 1px solid var(--line); background: var(--hud-bg); backdrop-filter: blur(6px); }
.top__hello:hover { border-color: var(--ink-2); }

/* ---- sections ---- */
main { position: relative; z-index: 2; }
.sec { position: relative; min-height: 190vh; min-height: 190lvh; }
.sec__text { position: sticky; top: var(--top); width: min(100%, calc(780px + 2 * var(--gutter))); padding: 0 var(--gutter); }
.sec[data-pos="tr"] .sec__text { margin-left: auto; text-align: right; }
.sec__h { font-weight: 280; font-size: var(--fs-h1); line-height: 1.02; letter-spacing: -.02em; margin: 18px 0 24px; text-wrap: balance; }
.sec__body { color: var(--ink-2); font-weight: 400; max-width: 780px; text-wrap: pretty; }
.sec[data-pos="tr"] .sec__body { margin-left: auto; }
.is-wide .sec--case .sec__body { max-width: min(780px, 40vw); }   /* stays in its half, clear of the picture */
.sec__link { display: inline-block; margin-top: 24px; font-family: var(--f-mono); font-size: var(--fs-label); letter-spacing: .16em; text-transform: uppercase;
  text-decoration: underline; text-decoration-color: var(--line); text-underline-offset: 6px; }
.sec__link:hover { text-decoration-color: var(--ink); }
.sec__mail { font-size: var(--fs-mail); font-weight: 250; margin-top: 8px; }
.sec__mail a { text-decoration: underline; text-decoration-thickness: 1px; text-decoration-color: var(--line); text-underline-offset: .18em; }
.sec__mail a:hover { text-decoration-color: var(--ink); }
.sec__note { margin-top: 28px; color: var(--ink-2); font-size: 18px; }
.foot { position: absolute; left: var(--gutter); bottom: max(32px, env(safe-area-inset-bottom)); font-family: var(--f-mono); font-size: var(--fs-label);
  letter-spacing: .16em; text-transform: uppercase; color: var(--ink-3); }

/* text comes in when its scene rests and goes out first when the camera leaves (DESIGN.md: motion) */
.js .sec__text > * { opacity: 0; transform: translateY(10px); transition: opacity var(--dur-out) var(--ease), transform var(--dur-out) var(--ease); }
.js .sec.is-in .sec__text > * { opacity: 1; transform: none; transition: opacity var(--dur-in) var(--ease), transform var(--dur-in) var(--ease); }
.js .sec.is-in .sec__text > :nth-child(2) { transition-delay: 80ms; }
.js .sec.is-in .sec__text > :nth-child(3) { transition-delay: 160ms; }
.js .sec.is-in .sec__text > :nth-child(4) { transition-delay: 240ms; }

/* ---- marks as a list (phones, no WebGL); on a wide window the scene draws them ---- */
.marks-list { list-style: none; padding: 0 var(--gutter); margin: 40px 0 0; display: grid; gap: 18px; max-width: calc(780px + 2 * var(--gutter)); }
.m-n { display: block; font-family: var(--f-mono); font-size: var(--fs-label); letter-spacing: .16em; text-transform: uppercase; color: var(--ink-3); }
.m-t { display: block; font-family: var(--f-mono); font-size: var(--fs-label); letter-spacing: .1em; text-transform: uppercase; color: var(--ink); }
.m-d { display: block; color: var(--ink-2); font-size: 18px; line-height: 1.45; }
.marks-list .m-n:has(+ .m-d) { color: var(--ink); }
.is-wide.has-gl .marks-list { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; margin: 0; padding: 0; }

/* pictures: planes in the scene on a wide window; images in the flow otherwise */
.sec__pic { margin: 40px var(--gutter) 0; }
.sec__pic img { width: min(300px, 70vw); margin: 0 auto; border-radius: 18px; -webkit-mask-image: linear-gradient(#000 84%, transparent); mask-image: linear-gradient(#000 84%, transparent); }
.sec__pic--wide img { width: min(760px, 100%); border-radius: 12px; }
.is-wide.has-gl .sec__pic { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); margin: 0; }

/* the marks layer over the scene (wide windows): leader lines, rings and labels in CSS px */
.marks-layer { position: fixed; inset: 0; z-index: 3; pointer-events: none; opacity: 0; transition: opacity 300ms; }
.marks-layer.is-in { opacity: 1; }
.marks-layer svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; filter: drop-shadow(0 0 1.5px var(--halo)); }
.marks-layer line { stroke: var(--line); stroke-width: 1; stroke-dasharray: 1200; stroke-dashoffset: 1200; transition: stroke-dashoffset var(--dur-line) var(--ease) 250ms; }
.marks-layer.is-in line { stroke-dashoffset: 0; }
.marks-layer .dot { fill: var(--ink); opacity: 0; transition: opacity 400ms 200ms; }
.marks-layer .ring { fill: none; stroke: var(--line); opacity: 0; transition: opacity 400ms 200ms; }
.marks-layer.is-in .dot, .marks-layer.is-in .ring { opacity: 1; }
.mark { position: absolute; text-shadow: 0 0 6px var(--halo); opacity: 0; transition: opacity 500ms 550ms; }
.mark .m-n { margin-bottom: 6px; }
.mark .m-d { font-size: 1.12em; line-height: 1.4; color: var(--ink); text-shadow: 0 0 8px var(--halo), 0 0 2px var(--halo); }
.mark.is-left { text-align: right; }
.marks-layer.is-in .mark { opacity: 1; }

/* ---- scroll hint: bottom centre, a mouse whose wheel rolls gently down, while a section is still below (wide windows only) ---- */
.scroll-hint { position: fixed; left: 50%; bottom: max(28px, env(safe-area-inset-bottom)); z-index: 4; transform: translateX(-50%);
  display: none; pointer-events: none; opacity: 0; transition: opacity 500ms var(--ease); }
.is-wide.has-gl .scroll-hint { display: block; }
.scroll-hint.is-on { opacity: 1; }
.scroll-hint svg { display: block; width: 28px; height: 60px; overflow: visible; fill: none; stroke: var(--ink); stroke-width: 1.5;
  stroke-linecap: round; stroke-linejoin: round; filter: drop-shadow(0 0 2px var(--halo)); }   /* the marks' halo: legible over bright particles */
.scroll-hint .wheel { fill: var(--ink); stroke: none; animation: scroll-wheel 1.8s var(--ease) infinite; }
@keyframes scroll-wheel {
  0% { transform: translateY(0); opacity: 0; }
  15% { transform: translateY(0); opacity: 1; }
  75% { transform: translateY(8px); opacity: 0; }
  100% { transform: translateY(8px); opacity: 0; }
}

/* ---- narrow windows: the same story, scrolled as a page ---- */
/* the text flows like a page and stays put; the scene changes behind it as you scroll */
@media (max-width: 1099px), (orientation: portrait) {   /* in step with studio.js fit() */
  .sec { min-height: 0; padding: calc(var(--top) + 6vh) 0 30vh; }
  /* the scene gets its own window between the text and the list: it rests there, centred, with nothing over it */
  #services .sec__text, #approach .sec__text { margin-bottom: 58vh; margin-bottom: 58svh; }
  .sec--hero { min-height: 100vh; min-height: 100svh; padding-bottom: 0; }
  .sec--contact { min-height: 100vh; min-height: 100svh; }
  .sec__text { position: relative; top: 0; }
  .sec[data-pos="tr"] .sec__text { margin-left: 0; text-align: left; }
  .sec[data-pos="tr"] .sec__body { margin-left: 0; }
  .sec__h { margin: 14px 0 18px; }
  .top { background: linear-gradient(var(--ground) 55%, transparent); padding-bottom: 28px; }
  .sec__text, .marks-list { text-shadow: 0 0 14px var(--ground), 0 0 4px var(--ground); }
  .js .sec__text > *, .js .sec.is-in .sec__text > * { opacity: 1; transform: none; transition: none; }
}

/* ---- without the scene (no WebGL2, or no JavaScript): every section is a still of its scene ---- */
.no-gl .sec, html:not(.js) .sec { min-height: 100vh; min-height: 100svh; padding: var(--top) 0 96px; background: var(--ground) no-repeat center / cover; }
.no-gl .sec__text, html:not(.js) .sec__text { position: relative; top: 0; }
.no-gl #studio, html:not(.js) #studio { background-image: linear-gradient(transparent 60%, var(--ground)), url("../img/stills/studio.jpg"); }
.no-gl #services, html:not(.js) #services { background-image: linear-gradient(var(--veil), transparent 40%, var(--ground)), url("../img/stills/services.jpg"); }
.no-gl #approach, html:not(.js) #approach { background-image: linear-gradient(var(--veil), transparent 40%, var(--ground)), url("../img/stills/approach.jpg"); }
.no-gl .sec--case, html:not(.js) .sec--case { background-image: linear-gradient(var(--veil), transparent 40%, var(--ground)), url("../img/stills/products.jpg"); }
.no-gl #contact, html:not(.js) #contact { background-image: linear-gradient(transparent 60%, var(--ground)), url("../img/stills/contact.jpg"); }

/* ---- reduced motion: static scene, no fades, no line draw ---- */
@media (prefers-reduced-motion: reduce) {
  .js .sec__text > *, .marks-layer, .marks-layer line, .marks-layer .dot, .marks-layer .ring, .mark { transition: none !important; transform: none !important; }
  .scroll-hint { transition: none; }
  .scroll-hint .wheel { animation: none; }
}
html.reduce-motion .sec__text > *, html.reduce-motion .marks-layer, html.reduce-motion .marks-layer line,
html.reduce-motion .marks-layer .dot, html.reduce-motion .marks-layer .ring, html.reduce-motion .mark { transition: none !important; transform: none !important; }
html.reduce-motion .scroll-hint { transition: none; }
html.reduce-motion .scroll-hint .wheel { animation: none; }

/* a still for the stills tool and the share image: the scene only, or the scene with the hero text */
.still .top, .still .scroll-hint, .still .marks-layer, .still .skip { display: none !important; }
.still--bare .sec__text { visibility: hidden; }
.still .sec__text > * { transition: none !important; }

/* ---- 404 ---- */
.lost { min-height: 100vh; min-height: 100svh; display: grid; align-content: center; padding: var(--top) var(--gutter); max-width: calc(780px + 2 * var(--gutter)); }
