/* The Heads page (/heads/): a live 3D head to play with, and how it is made. The head and its controls are the hero:
   stage on the left and the controls on the right on a desktop, the intro, the stage and the controls one under another
   on a phone. No inline styles: the script sets anything dynamic through the CSSOM. */

/* --- the hero: intro, stage, controls ----------------------------------------------------------------------------- */
.hd-hero { padding: 40px 0 72px; overflow: visible; }      /* the stage sticks while the controls scroll: not inside a clipped box */
.hd-hero .wrap { grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); grid-template-areas: "stage intro" "stage panel";
  grid-template-rows: auto 1fr; gap: 20px 56px; align-items: start; }
.hd-intro { grid-area: intro; align-self: end; }
.hd-intro .lede { margin-top: 1.1rem; }
.hd-intro h1 { font-size: clamp(2.2rem, 4.2vw, 3.4rem); }
.hd-stage { grid-area: stage; }
.hd-panel { grid-area: panel; }

.hd-stage { position: sticky; top: 88px; align-self: start; margin: 0; width: min(100%, calc((100vh - 120px) * 5 / 6)); min-width: min(100%, 320px);
  aspect-ratio: 5 / 6; justify-self: center;
  border-radius: 22px; overflow: hidden; border: 1px solid var(--line);
  background: radial-gradient(70% 55% at 50% 38%, rgba(99, 102, 241, .22), transparent 72%), var(--night-2);
  box-shadow: 0 40px 90px -40px rgba(99, 102, 241, .55); touch-action: pan-y; container-type: inline-size; }
.hd-stage canvas, .hd-stage .hd-poster { position: absolute; inset: 0; display: block; width: 100%; height: 100%; }
.hd-poster { object-fit: cover; transition: opacity .7s ease; }
.hd-stage canvas { opacity: 0; transition: opacity .7s ease; cursor: grab; touch-action: pan-y; }
.hd-stage.live canvas { opacity: 1; }
.hd-stage.live .hd-poster { opacity: 0; }
.hd-stage.dragging canvas { cursor: grabbing; }
.hd-who { position: absolute; left: 14px; top: 14px; z-index: 2; display: flex; align-items: center; gap: 8px; padding: 6px 12px;
  border-radius: 999px; background: rgba(10, 18, 38, .8); border: 1px solid var(--line-2); font: 600 0.92rem var(--display);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.hd-badge { font: 500 0.72rem/1 var(--mono); letter-spacing: .1em; text-transform: uppercase; color: var(--cyan); padding: 4px 7px;
  border-radius: 999px; background: rgba(34, 211, 238, .12); }
.hd-badge:empty { display: none; }
.hd-hint { position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); z-index: 2; margin: 0; padding: 6px 12px;
  border-radius: 999px; background: rgba(10, 18, 38, .8); border: 1px solid var(--line-2); color: var(--muted); font-size: 0.82rem;
  white-space: nowrap; pointer-events: none; transition: opacity .5s; backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.hd-hint.gone { opacity: 0; }
.hd-hint[hidden], .hd-who[hidden] { display: none; }
/* the message over the stage: loading, or no WebGL */
.hd-note { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 2; margin: 0; width: max-content; max-width: calc(100% - 40px);
  padding: 10px 16px; border-radius: 14px; background: rgba(10, 18, 38, .88); border: 1px solid var(--line-2); text-align: center;
  font-size: 0.95rem; line-height: 1.45; color: var(--text); }
.hd-note:empty { display: none; }

/* --- the panel -------------------------------------------------------------------------------------------------------- */
.hd-panel { display: grid; gap: 0; padding: 6px 20px; border-radius: 18px; border: 1px solid var(--line-2); background: rgba(13, 22, 48, .6); min-width: 0; }
.hd-group { display: grid; gap: 10px; padding: 14px 0; min-width: 0; }
.hd-group + .hd-group, .hd-group + .hd-more { border-top: 1px solid var(--line); }
.hd-label { margin: 0; font: 500 0.72rem/1.2 var(--mono); letter-spacing: .14em; text-transform: uppercase; color: var(--dim); }
.hd-row { display: flex; align-items: center; justify-content: space-between; gap: 10px 14px; flex-wrap: wrap; }

/* the heads to pick from */
.hd-pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(52px, 1fr)); gap: 8px; }
.hd-pick button { display: grid; justify-items: center; gap: 5px; padding: 0; border: 0; background: none; color: var(--muted); cursor: pointer; font: 500 0.78rem var(--body); }
.hd-pick img { display: block; width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 14px; border: 2px solid transparent;
  outline: 1px solid var(--line-2); outline-offset: -1px; transition: transform .15s ease, border-color .15s ease, filter .15s ease; filter: saturate(.85) brightness(.85); }
.hd-pick button:hover img { transform: translateY(-2px); filter: none; }
.hd-pick button[aria-pressed="true"] { color: var(--text); }
.hd-pick button[aria-pressed="true"] img { border-color: var(--cyan); filter: none; box-shadow: 0 8px 24px -10px rgba(34, 211, 238, .6); }

/* chips: the views and the reactions */
.hd-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.hd-chip { display: inline-flex; align-items: center; gap: 7px; border: 1px solid var(--line-2); background: rgba(13, 22, 48, .55); color: var(--muted);
  border-radius: 999px; padding: 7px 14px; font: 500 0.88rem/1.2 var(--body); cursor: pointer; transition: color .15s, border-color .15s, background .15s; }
.hd-chip:hover { color: var(--text); border-color: rgba(34, 211, 238, .5); }
.hd-chip[aria-pressed="true"] { color: var(--text); border-color: rgba(34, 211, 238, .8); background: rgba(34, 211, 238, .12); }
.hd-chip svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.hd-talk { color: var(--text); border-color: rgba(99, 102, 241, .6); background: rgba(99, 102, 241, .16); }
.hd-chip:disabled { opacity: .55; cursor: default; }

/* sliders */
.hd-range { display: flex; align-items: center; gap: 12px; min-width: 0; }
.hd-range output { flex: none; min-width: 3.4em; text-align: right; font: 0.82rem var(--mono); color: var(--muted); }
.hd-range input { flex: 1; min-width: 0; }
.hd-range input:disabled { opacity: 0.4; }
.hd-hero input[type="range"] { -webkit-appearance: none; appearance: none; height: 28px; background: transparent; cursor: pointer; margin: 0; }
.hd-hero input[type="range"]::-webkit-slider-runnable-track { height: 4px; border-radius: 4px; background: var(--line-2); }
.hd-hero input[type="range"]::-moz-range-track { height: 4px; border-radius: 4px; background: var(--line-2); }
.hd-hero input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 20px; height: 20px; margin-top: -8px; border-radius: 50%;
  border: 2px solid var(--night); background: var(--cyan); box-shadow: 0 0 0 1px rgba(34, 211, 238, .6), 0 4px 12px rgba(34, 211, 238, .35); }
.hd-hero input[type="range"]::-moz-range-thumb { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--night); background: var(--cyan);
  box-shadow: 0 0 0 1px rgba(34, 211, 238, .6); }

/* switches */
.hd-switches { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.hd-switch { display: flex; align-items: flex-start; gap: 12px; padding: 12px; border: 1px solid var(--line); border-radius: 12px; cursor: pointer;
  background: rgba(6, 11, 24, .35); transition: border-color .15s; }
.hd-switch:hover { border-color: var(--line-2); }
.hd-switch input { -webkit-appearance: none; appearance: none; flex: none; position: relative; width: 38px; height: 22px; margin: 2px 0 0; border-radius: 999px;
  background: #18213f; border: 1px solid var(--line-2); cursor: pointer; transition: background .2s, border-color .2s; }
.hd-switch input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: var(--muted);
  transition: transform .2s, background .2s; }
.hd-switch input:checked { background: var(--grad); border-color: transparent; }
.hd-switch input:checked::after { transform: translateX(16px); background: #050914; }
.hd-switch b { display: block; font: 600 0.92rem/1.3 var(--display); }
.hd-switch small { display: block; margin-top: 2px; color: var(--dim); font-size: 0.8rem; line-height: 1.4; }

/* the look: a segmented control */
.hd-seg { display: grid; grid-template-columns: repeat(3, 1fr); padding: 3px; border-radius: 12px; border: 1px solid var(--line-2); background: rgba(6, 11, 24, .5); }
.hd-seg label { position: relative; display: block; }
.hd-seg input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.hd-seg span { display: block; padding: 8px 6px; border-radius: 9px; text-align: center; color: var(--muted); font: 500 0.9rem var(--body); transition: background .15s, color .15s; }
.hd-seg input:checked + span { background: rgba(34, 211, 238, .14); color: var(--text); box-shadow: inset 0 0 0 1px rgba(34, 211, 238, .55); }
.hd-seg input:focus-visible + span { outline: 2px solid var(--cyan); outline-offset: 2px; }

/* the rest: dress and place */
.hd-more { padding: 4px 0 8px; }
.hd-more summary { list-style: none; display: flex; align-items: center; justify-content: space-between; padding: 12px 0; cursor: pointer; color: var(--muted);
  font: 500 0.95rem var(--body); }
.hd-more summary::-webkit-details-marker { display: none; }
.hd-more summary::after { content: ""; width: 7px; height: 7px; border: solid currentColor; border-width: 0 1.5px 1.5px 0; transform: rotate(45deg); transition: transform .15s; margin-right: 4px; }
.hd-more[open] summary::after { transform: rotate(225deg); }
.hd-more summary:hover { color: var(--text); }
.hd-more-body { display: grid; gap: 14px; padding: 4px 0 8px; }
.hd-field { display: grid; grid-template-columns: 5.5rem minmax(0, 1fr); align-items: center; gap: 12px; color: var(--muted); font-size: 0.9rem; }
.hd-field select { width: 100%; min-width: 0; padding: 9px 12px; border-radius: 10px; border: 1px solid var(--line-2); background: var(--night-2); color: var(--text); font: 0.92rem var(--body); }
.hd-colour { grid-template-columns: 5.5rem auto auto; justify-content: start; }
.hd-colour input { width: 44px; height: 34px; padding: 2px; border-radius: 8px; border: 1px solid var(--line-2); background: var(--night-2); cursor: pointer; }
.hd-checks { display: flex; flex-wrap: wrap; gap: 8px 20px; color: var(--muted); font-size: 0.9rem; }
.hd-checks label { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.hd-hero input[type="checkbox"]:not([role="switch"]) { accent-color: var(--cyan); width: 16px; height: 16px; margin: 0; }
.hd-hero select:focus-visible, .hd-hero input:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }

/* --- below the hero ------------------------------------------------------------------------------------------------ */
.hd-cards .card { min-width: 0; }
.hd-steps { list-style: none; margin: 2.2rem 0 0; padding: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; counter-reset: none; }
.hd-steps li { position: relative; padding: 20px 20px 22px; border-radius: var(--radius); border: 1px solid var(--line); background: rgba(13, 22, 48, .6); }
.hd-steps p { color: var(--muted); font-size: 0.93rem; }
.hd-n { display: inline-grid; place-items: center; width: 30px; height: 30px; margin-bottom: 12px; border-radius: 50%; font: 600 0.9rem var(--mono); color: #050914; background: var(--grad); }
.hd-sheet { margin: 20px 0 0; border-radius: 18px; overflow: hidden; border: 1px solid var(--line); background: #cfd2d6;
  box-shadow: 0 40px 90px -50px rgba(99, 102, 241, .6); }
.hd-sheet-scroll { overflow-x: auto; }
.hd-sheet img { display: block; width: 100%; height: auto; }
.hd-sheet figcaption { padding: 12px 18px; color: var(--muted); font-size: 0.9rem; background: var(--night-2); border-top: 1px solid var(--line); }
.hd-inside { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); gap: 40px; align-items: center; }
.hd-inside h2 { max-width: 18ch; }

.hd .cta-band .eyebrow { margin-inline: auto; }
.hd .cta-band .fine { margin-top: 1.8rem; }

/* --- smaller screens ----------------------------------------------------------------------------------------------- */
@media (max-width: 1060px) { .hd-hero .wrap { gap: 20px 36px; } }
@media (max-width: 900px) {
  .hd-hero { padding: 24px 0 48px; }
  .hd-hero .wrap { grid-template-columns: minmax(0, 1fr); grid-template-areas: "intro" "stage" "panel"; grid-template-rows: none; gap: 22px; }
  .hd-intro { align-self: start; }
  .hd-stage { position: relative; top: auto; width: min(100%, 560px, calc(72vh * 5 / 6)); }
  .hd-panel { max-width: 640px; width: 100%; justify-self: center; }
  .hd-steps { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hd-inside { grid-template-columns: minmax(0, 1fr); gap: 24px; }
}
@media (max-width: 560px) {
  .hd-hero .wrap { gap: 18px; }
  .hd-stage { border-radius: 18px; }
  .hd-panel { padding: 4px 14px; border-radius: 16px; }
  .hd-pick { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .hd-switches { grid-template-columns: minmax(0, 1fr); }
  .hd-field, .hd-colour { grid-template-columns: 4.6rem minmax(0, 1fr); }
  .hd-colour { grid-template-columns: 4.6rem auto auto; }
  .hd-steps { grid-template-columns: minmax(0, 1fr); }
  .hd-steps li { padding: 16px 18px 18px; }
  /* four views in a phone's width are tiny: the sheet scrolls sideways instead */
  .hd-sheet img { width: 760px; max-width: none; }
}
@container (max-width: 380px) { .hd-hint { display: none; } }

/* fingers: bigger targets */
@media (pointer: coarse) {
  .hd-chip { min-height: 40px; padding-inline: 16px; }
  .hd-more summary { min-height: 44px; }
  .hd-field select { min-height: 42px; }
}
@media (prefers-reduced-motion: reduce) {
  .hd-poster, .hd-stage canvas, .hd-pick img, .hd-hint { transition: none; }
}
