/* Dichroic Glass Man - the whole page behaves like a sheet of dichroic glass.
   --h   base hue, driven by pointer position and scroll (site.js)
   --ang gradient angle in degrees, driven by the pointer */
:root {
  --h: 190;
  --ang: 120;
  --dg-fade: 1;
  --ink: #ecebf5;
  --dim: #a9a8bd;
  --bg: #06060c;
  --panel: rgba(255, 255, 255, 0.045);
  --line: rgba(255, 255, 255, 0.12);
  --c1: hsl(calc(var(--h)) 95% 66%);
  --c2: hsl(calc(var(--h) + 75) 95% 66%);
  --c3: hsl(calc(var(--h) + 165) 95% 70%);
  --c4: hsl(calc(var(--h) + 255) 95% 68%);
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 17px/1.7 var(--sans);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
/* The sheet of glass behind everything: soft pools of the reflected and transmitted colours. */
body::before {
  content: "";
  position: fixed; inset: -20vmax; z-index: -2;
  background:
    radial-gradient(42vmax 42vmax at 18% 22%, hsl(calc(var(--h)) 90% 50% / 0.20), transparent 70%),
    radial-gradient(46vmax 46vmax at 84% 30%, hsl(calc(var(--h) + 180) 90% 52% / 0.17), transparent 70%),
    radial-gradient(50vmax 50vmax at 55% 92%, hsl(calc(var(--h) + 90) 90% 50% / 0.13), transparent 70%);
  filter: saturate(1.15);
}
/* A band of sheen that slides across as you move, like tilting the sheet. */
body::after {
  content: "";
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background: linear-gradient(calc(var(--ang) * 1deg),
    transparent 30%, hsl(calc(var(--h) + 40) 100% 75% / 0.05) 45%,
    hsl(calc(var(--h) + 140) 100% 75% / 0.07) 50%,
    hsl(calc(var(--h) + 240) 100% 75% / 0.05) 55%, transparent 70%);
}
img { max-width: 100%; height: auto; display: block; }
a { color: #fff; text-underline-offset: 3px; text-decoration-color: rgba(255, 255, 255, 0.45); }
a:hover { color: #fff; text-decoration-color: #fff; }
::selection { background: hsl(calc(var(--h) + 180) 90% 55% / 0.5); }

/* ---------- dichroic surfaces ---------- */
/* Lettering stays plain. The colour belongs to the glass, not the words. */
.dichro { color: #fff; }
.glass {
  position: relative;
  border-radius: 18px;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0.02));
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  padding: 1.5rem 1.6rem;
}
.glass::before {
  content: ""; position: absolute; inset: 0; border-radius: inherit; padding: 1.2px; pointer-events: none;
  background: conic-gradient(from calc(var(--ang) * 1deg), var(--c1), var(--c3), var(--c2), var(--c4), var(--c1));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude;
  opacity: 0.75;
}
.glass::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background: radial-gradient(380px circle at var(--mx, 50%) var(--my, -20%), hsl(calc(var(--h) + 200) 100% 72% / 0.16), transparent 62%);
}
.glass > * { position: relative; z-index: 1; }

/* ---------- header ---------- */
.top {
  position: fixed; top: 0; left: 0; z-index: 60;
  padding: 1.1rem 1.4rem;
}
.brand {
  font: 600 1.05rem/1 var(--serif); letter-spacing: 0.14em; text-transform: uppercase; text-decoration: none;
}

/* ---------- the sculpture menu ---------- */
#dg-canvas {
  position: fixed; z-index: 0; inset: 0; width: 100vw; height: 100vh; height: 100dvh;
  touch-action: pan-y; display: block; cursor: grab;
}
#dg-backdrop {
  position: fixed; inset: 0; z-index: 90; opacity: 0; pointer-events: none;
  background: rgba(4, 4, 10, 0.9);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  transition: opacity 0.35s;
}
#dg-labels { position: fixed; top: 0; left: 0; width: 0; height: 0; z-index: 3; }
.dg-label {
  position: absolute; top: 0; left: 0; white-space: nowrap;
  padding: 0.5rem 0.95rem; border-radius: 999px;
  font: 600 0.92rem/1 var(--sans); letter-spacing: 0.06em; text-transform: uppercase; text-decoration: none;
  color: var(--ink);
  background: rgba(8, 8, 16, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.22);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  opacity: calc(var(--front, 1) * var(--dg-fade));
  transition: background 0.2s, border-color 0.2s, box-shadow 0.2s, color 0.2s;
  will-change: transform;
}
.dg-label.hot, .dg-label:hover, .dg-label:focus-visible {
  color: #fff; opacity: var(--dg-fade); outline: none;
  border-color: var(--c1);
  background: rgba(8, 8, 16, 0.8);
  box-shadow: 0 0 0 1px var(--c3), 0 0 26px hsl(calc(var(--h)) 100% 60% / 0.55), 0 0 60px hsl(calc(var(--h) + 180) 100% 60% / 0.35);
}
.dg-label[aria-current="page"] { border-color: #fff; background: rgba(255, 255, 255, 0.14); }
#dg-hint {
  position: fixed; left: 0; right: 0; bottom: 1.1rem; z-index: 3; margin: 0; text-align: center;
  font-size: 0.8rem; letter-spacing: 0.16em; text-transform: uppercase; color: var(--dim);
  pointer-events: none; opacity: 0;
}
#dg-toggle {
  position: fixed; top: 0.7rem; right: 0.9rem; z-index: 120;
  width: 84px; height: 84px; border-radius: 50%; padding: 0;
  background: transparent; color: var(--ink); cursor: pointer;
  border: 1px solid rgba(255, 255, 255, 0.25);
  box-shadow: 0 0 22px hsl(calc(var(--h)) 100% 60% / 0.35), inset 0 0 18px hsl(calc(var(--h) + 180) 100% 60% / 0.25);
  display: grid; place-items: end center;
  transition: box-shadow 0.25s, transform 0.25s;
}
#dg-toggle span {
  font: 600 0.62rem/1 var(--sans); letter-spacing: 0.18em; text-transform: uppercase;
  padding-bottom: 7px; text-shadow: 0 0 6px #000, 0 0 12px #000;
}
#dg-toggle:hover, #dg-toggle:focus-visible {
  outline: none; transform: scale(1.06);
  box-shadow: 0 0 34px hsl(calc(var(--h)) 100% 60% / 0.7), inset 0 0 22px hsl(calc(var(--h) + 180) 100% 60% / 0.45);
}

/* mini: the sculpture is the round button in the corner */
[data-dg="mini"] #dg-canvas {
  inset: auto; top: 0.7rem; right: 0.9rem; width: 84px; height: 84px; border-radius: 50%;
  z-index: 110; pointer-events: none; background: rgba(6, 6, 12, 0.75);
}
[data-dg="mini"] #dg-labels, [data-dg="mini"] #dg-hint { display: none; }

/* hero: full-screen behind the home page intro */
[data-dg="hero"] #dg-canvas { opacity: var(--dg-fade); }
[data-dg="hero"] #dg-toggle { display: none; }
[data-dg="hero"] #dg-hint { opacity: calc(var(--dg-fade) * 0.9); }

/* open: full-screen overlay menu */
[data-dg="open"] #dg-canvas { z-index: 100; }
[data-dg="open"] #dg-backdrop { opacity: 1; pointer-events: auto; }
[data-dg="open"] #dg-labels { z-index: 105; --dg-fade: 1; }
[data-dg="open"] #dg-hint { z-index: 105; opacity: 0.9; }
[data-dg="open"] #dg-toggle { width: 64px; height: 64px; place-items: center; background: rgba(8, 8, 16, 0.7); }
[data-dg="open"] #dg-toggle span { padding: 0; }
[data-dg="open"] body { overflow: hidden; }

/* no WebGL: the menu becomes a plain bar */
.no-webgl #dg-canvas, .no-webgl #dg-toggle, .no-webgl #dg-hint, .no-webgl #dg-backdrop { display: none; }
.no-webgl #dg-labels {
  display: flex !important; flex-wrap: wrap; gap: 0.4rem; justify-content: center;
  position: static; width: auto; height: auto; padding: 4rem 1rem 0;
}
.no-webgl .dg-label { position: static; opacity: 1; transform: none !important; }

/* ---------- layout ---------- */
main { position: relative; z-index: 1; }
.hero {
  min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; justify-content: flex-end;
  padding: 0 clamp(1.2rem, 5vw, 4rem) 4.2rem; pointer-events: none;
  opacity: var(--dg-fade);
}
.hero h1 {
  margin: 0; font: 700 clamp(2.4rem, 7vw, 5.6rem)/0.98 var(--serif); letter-spacing: -0.01em; max-width: 9ch;
}
.hero p { margin: 1rem 0 0; max-width: 34ch; color: var(--dim); font-size: 1.05rem; }

.wrap { width: min(1120px, 100% - 2.4rem); margin-inline: auto; }
.page-head { padding: 8.5rem 0 1.5rem; }
.page-head h1 { margin: 0; font: 700 clamp(2.3rem, 6vw, 4.4rem)/1.02 var(--serif); }
.page-head .lede { margin: 1.1rem 0 0; max-width: 62ch; font-size: 1.2rem; color: #d6d5e6; }
.kicker { font-size: 0.78rem; letter-spacing: 0.22em; text-transform: uppercase; color: var(--dim); margin: 0 0 0.8rem; }

section { padding: 2.6rem 0; }
h2 { font: 700 clamp(1.6rem, 3.4vw, 2.3rem)/1.15 var(--serif); margin: 0 0 1rem; }
h3 { font: 700 1.2rem/1.3 var(--serif); margin: 1.6rem 0 0.5rem; }
.prose { max-width: 70ch; }
.prose p, .prose li { color: #dddcea; }
.prose strong { color: #fff; }
.grid { display: grid; gap: 1.2rem; }
.g2 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.g3 { grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); }
.glass h3:first-child { margin-top: 0; }
.glass p:last-child, .glass ul:last-child { margin-bottom: 0; }
.big-num { font: 700 2.4rem/1 var(--serif); display: block; margin-bottom: 0.3rem; }
.note { font-size: 0.9rem; color: var(--dim); }
.tag {
  display: inline-block; font-size: 0.72rem; letter-spacing: 0.14em; text-transform: uppercase;
  padding: 0.25rem 0.6rem; border-radius: 999px; border: 1px solid var(--line); color: var(--dim); margin-right: 0.3rem;
}

/* numbered process */
.steps { counter-reset: step; list-style: none; padding: 0; margin: 0; display: grid; gap: 1.1rem; }
.steps > li { counter-increment: step; padding-left: 4.4rem; min-height: 3.2rem; }
.steps > li::before {
  content: counter(step, decimal-leading-zero);
  position: absolute; left: 1.4rem; top: 1.25rem; z-index: 1;
  font: 700 1.7rem/1 var(--serif); color: var(--dim);
}
.steps h3 { margin: 0 0 0.3rem; }
.steps p { margin: 0.3rem 0 0; color: #dddcea; }

/* timeline */
.timeline { list-style: none; margin: 0; padding: 0 0 0 1.6rem; border-left: 2px solid transparent;
  border-image: linear-gradient(to bottom, var(--c1), var(--c2), var(--c3), var(--c4)) 1; }
.timeline li { position: relative; padding: 0 0 1.7rem 1.2rem; }
.timeline li::before {
  content: ""; position: absolute; left: -2.05rem; top: 0.5rem; width: 12px; height: 12px; border-radius: 50%;
  background: var(--c2); box-shadow: 0 0 14px var(--c2);
}
.timeline time { display: block; font: 700 1.25rem/1.2 var(--serif); }
.timeline p { margin: 0.3rem 0 0; color: #dddcea; max-width: 66ch; }

/* tables */
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 0.95rem; }
th, td { text-align: left; padding: 0.7rem 0.8rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 0.76rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--dim); }

/* figures and gallery */
figure { margin: 0; }
.fig img { width: 100%; border-radius: 14px; background: #0d0d16; }
figcaption { font-size: 0.86rem; color: var(--dim); margin-top: 0.55rem; line-height: 1.5; }
figcaption a { color: var(--dim); }
.gallery { columns: 3 300px; column-gap: 1.1rem; }
.gallery figure { break-inside: avoid; margin: 0 0 1.1rem; padding: 0.6rem; }
.gallery img { border-radius: 12px; width: 100%; cursor: zoom-in; background: #0d0d16; }
.gallery figcaption { padding: 0 0.3rem 0.2rem; }
#lightbox {
  position: fixed; inset: 0; z-index: 200; display: none; place-items: center; padding: 2rem;
  background: rgba(3, 3, 8, 0.94); cursor: zoom-out;
}
#lightbox.on { display: grid; }
#lightbox img { max-width: 100%; max-height: 86vh; border-radius: 10px; }
#lightbox p { margin: 0.8rem 0 0; color: var(--dim); font-size: 0.9rem; text-align: center; }

/* thin-film lab */
.lab { display: grid; gap: 1.4rem; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); align-items: center; }
.lab label { display: block; font-size: 0.82rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--dim); margin-top: 1rem; }
.lab input[type="range"] { width: 100%; accent-color: var(--c1); }
.swatches { display: grid; grid-template-columns: 1fr 1fr; gap: 0.9rem; }
.swatch { border-radius: 14px; aspect-ratio: 1.15; display: grid; place-items: end start; padding: 0.7rem; border: 1px solid var(--line); }
.swatch span { font-size: 0.72rem; letter-spacing: 0.14em; text-transform: uppercase; background: rgba(0, 0, 0, 0.55); padding: 0.25rem 0.5rem; border-radius: 6px; }
#spectrum { width: 100%; height: 150px; border-radius: 12px; background: #0b0b14; border: 1px solid var(--line); }
svg.diagram { width: 100%; height: auto; }
svg.diagram text { fill: var(--ink); font: 13px var(--sans); }
svg.diagram .dimtxt { fill: var(--dim); font-size: 11.5px; }

.cta-row { display: flex; flex-wrap: wrap; gap: 0.7rem; margin-top: 1.2rem; }
.btn {
  display: inline-block; padding: 0.7rem 1.2rem; border-radius: 999px; text-decoration: none; font-weight: 600;
  color: #08080f; background: linear-gradient(calc(var(--ang) * 1deg), var(--c1), var(--c2), var(--c3));
}
.btn:hover { color: #08080f; filter: brightness(1.12); }
.btn.ghost { background: none; color: var(--ink); border: 1px solid var(--line); }

footer { position: relative; z-index: 1; margin-top: 3rem; padding: 2.4rem 0 3rem; border-top: 1px solid var(--line); color: var(--dim); font-size: 0.9rem; }
footer nav { display: flex; flex-wrap: wrap; gap: 0.4rem 1.3rem; margin-bottom: 1rem; }
footer a { color: var(--ink); text-decoration: none; }
footer a:hover { text-decoration: underline; }

/* ---------- Ask the glass: transparent chat over a dichroic cube ---------- */
#ask-btn {
  position: fixed; right: 1.1rem; bottom: 1.1rem; z-index: 80;
  padding: 0.8rem 1.25rem; border-radius: 999px; cursor: pointer;
  font: 600 0.9rem/1 var(--sans); letter-spacing: 0.06em; color: #fff;
  background: rgba(10, 10, 20, 0.72); border: 1px solid rgba(255, 255, 255, 0.35);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  box-shadow: 0 0 24px hsl(calc(var(--h)) 100% 60% / 0.45), 0 0 50px hsl(calc(var(--h) + 180) 100% 60% / 0.25);
}
#ask-btn:hover, #ask-btn:focus-visible { outline: none; border-color: #fff; }
#ask {
  position: fixed; right: 1.1rem; bottom: 4.6rem; z-index: 80;
  width: min(440px, calc(100vw - 2.2rem)); height: min(640px, calc(100dvh - 11.5rem));   /* stays clear of the menu button above it */
  border-radius: 22px; overflow: hidden;
  background: rgba(6, 6, 14, 0.42);
  -webkit-backdrop-filter: blur(16px) saturate(1.2); backdrop-filter: blur(16px) saturate(1.2);
  border: 1px solid rgba(255, 255, 255, 0.22);
  box-shadow: 0 20px 70px rgba(0, 0, 0, 0.6), 0 0 40px hsl(calc(var(--h)) 100% 60% / 0.2);
}
#ask[hidden], #ask-btn[hidden] { display: none; }
#ask-cube { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.ask-ui { position: absolute; inset: 0; display: flex; flex-direction: column; }
.ask-ui header { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: 0.9rem 1rem 0.7rem; }
.ask-ui header strong { display: block; font: 700 1.1rem/1.2 var(--serif); }
.ask-ui header span { font-size: 0.74rem; color: var(--dim); }
#ask-close { background: none; border: 1px solid var(--line); color: #fff; border-radius: 999px; padding: 0.35rem 0.8rem; font-size: 0.78rem; cursor: pointer; }
#ask-log { flex: 1; overflow-y: auto; padding: 0.4rem 1rem 0.8rem; display: flex; flex-direction: column; gap: 0.6rem; scrollbar-width: thin; }
.ask-msg {
  max-width: 86%; padding: 0.6rem 0.85rem; border-radius: 14px; font-size: 0.93rem; line-height: 1.5;
  background: rgba(8, 8, 18, 0.5); border: 1px solid rgba(255, 255, 255, 0.14);
  -webkit-backdrop-filter: blur(5px); backdrop-filter: blur(5px);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9);
}
.ask-msg p { margin: 0; white-space: pre-wrap; }
.ask-msg.user { align-self: flex-end; background: rgba(255, 255, 255, 0.14); }
.ask-msg.bot { align-self: flex-start; }
.ask-msg.thinking p { color: var(--dim); font-style: italic; }
.ask-src-h { display: block; margin-top: 0.6rem; font-size: 0.68rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--dim); }
.ask-src { margin: 0.2rem 0 0; padding-left: 1.1rem; font-size: 0.8rem; color: #d0cfdf; }
#ask-form { display: flex; gap: 0.5rem; padding: 0.7rem; align-items: flex-end; }
#ask-in {
  flex: 1; resize: none; overflow: hidden; border-radius: 14px; padding: 0.65rem 0.8rem; color: #fff; font: inherit; font-size: 0.95rem;
  background: rgba(8, 8, 18, 0.55); border: 1px solid rgba(255, 255, 255, 0.25);
}
#ask-in:focus { outline: none; border-color: #fff; }
#ask-form button { border-radius: 14px; padding: 0.65rem 1rem; font: 600 0.9rem var(--sans); cursor: pointer; color: #08080f; background: #fff; border: 0; }
[data-dg="open"] #ask-btn, [data-dg="open"] #ask { display: none; }

@media (max-aspect-ratio: 5/4) {
  /* tall screens: a smaller headline, tucked under the glass */
  .hero { padding-bottom: 3.6rem; }
  .hero h1 { font-size: clamp(1.9rem, 8vw, 3rem); max-width: 12ch; }
  .hero p { font-size: 0.95rem; max-width: 30ch; }
}
@media (max-width: 640px) {
  body { font-size: 16px; }
  .dg-label { font-size: 0.74rem; padding: 0.42rem 0.7rem; }
  .steps > li { padding-left: 3.6rem; }
  .steps > li::before { left: 1.1rem; font-size: 1.4rem; }
}
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
