/* Bones. Second Grade Studios house style: slate base, Arial, sparing accent colours. */
:root {
  --slate: #22272E;
  --raised: #2E343C;
  --line: rgba(255, 255, 255, 0.12);
  --text: #FFFFFF;
  --muted: rgba(255, 255, 255, 0.65);
  --earth: #BD4B37;     /* primary action */
  --yellow: #FCD93B;    /* selected / on */
  --blue: #5D88BF;      /* links, info */
  --pink: #EF8B81;
  --green: #CFE2D6;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: #05070A;
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
canvas#view, canvas#debug { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
canvas#debug { pointer-events: none; }
canvas#debug.mirrored { transform: scaleX(-1); }
[hidden] { display: none !important; }

/* ---- brand and status ---- */
.top {
  position: fixed; top: 0; left: 0; right: 0;
  display: flex; justify-content: space-between; align-items: flex-start;
  padding: 18px 22px; pointer-events: none;
  transition: opacity 0.5s;
}
.brand .name { font-size: 15px; font-weight: bold; letter-spacing: 0.32em; }
.brand .by { font-size: 12px; color: var(--muted); margin-top: 4px; letter-spacing: 0.04em; }
.status {
  font-size: 12px; color: var(--muted); background: rgba(34, 39, 46, 0.72);
  border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px;
  font-variant-numeric: tabular-nums;
}

/* ---- intro card ---- */
.card {
  position: fixed; left: 50%; bottom: 7vh; transform: translateX(-50%);
  width: min(460px, calc(100vw - 32px));
  background: rgba(34, 39, 46, 0.86); border: 1px solid var(--line); border-radius: 14px;
  padding: 26px 28px 22px; text-align: center;
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.card h1 { font-size: 24px; margin: 0 0 10px; }
.card p { font-size: 15px; line-height: 1.5; color: var(--muted); margin: 0 0 18px; }
.card .note { font-size: 12px; margin: 14px 0 0; }
.card .note.error { color: var(--pink); }
.go {
  font: inherit; font-size: 16px; font-weight: bold; color: #fff; background: var(--earth);
  border: 0; border-radius: 10px; padding: 14px 30px; cursor: pointer; min-width: 220px;
  transition: filter 0.15s, transform 0.1s;
}
.go:hover { filter: brightness(1.12); }
.go:active { transform: translateY(1px); }
.go:disabled { opacity: 0.7; cursor: progress; }

/* ---- dock ---- */
.dock {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%);
  display: flex; gap: 18px; align-items: center; flex-wrap: wrap; justify-content: center;
  max-width: calc(100vw - 24px);
  background: rgba(34, 39, 46, 0.86); border: 1px solid var(--line); border-radius: 14px;
  padding: 10px 14px;
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  transition: opacity 0.5s;
}
.group { display: flex; align-items: center; gap: 6px; }
.label { font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); margin-right: 4px; }
.chip, .tool {
  font: inherit; font-size: 13px; color: var(--text); background: var(--raised);
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.chip:hover, .tool:hover { border-color: rgba(255, 255, 255, 0.35); }
.chip.on { background: var(--yellow); color: #111111; border-color: var(--yellow); font-weight: bold; }
.tool { color: var(--text); }
.tool.wide { width: 100%; margin-top: 8px; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }

/* ---- settings panel ---- */
.panel {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(320px, 100vw);
  background: rgba(34, 39, 46, 0.95); border-left: 1px solid var(--line);
  padding: 18px 20px; overflow-y: auto;
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
}
.panel-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.panel h2 { font-size: 17px; margin: 0; }
.close { font: inherit; font-size: 24px; line-height: 1; color: var(--muted); background: none; border: 0; cursor: pointer; padding: 2px 6px; }
.row { display: block; font-size: 13px; color: var(--muted); margin: 14px 0; }
.row select, .row input[type=range] { display: block; width: 100%; margin-top: 7px; }
.row select {
  font: inherit; font-size: 14px; color: var(--text); background: var(--raised);
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px;
}
.row input[type=range] { accent-color: var(--yellow); }
.row.check { display: flex; align-items: center; gap: 10px; color: var(--text); font-size: 14px; cursor: pointer; }
.row.check input { width: 18px; height: 18px; accent-color: var(--yellow); margin: 0; }
.keys, .fine { font-size: 12px; line-height: 1.5; color: var(--muted); margin: 16px 0 0; }

/* ---- film labels (the little lead letters and the plate text on a real radiograph) ---- */
.film { position: fixed; inset: 0; pointer-events: none; transition: opacity 0.4s; }
.film.off { opacity: 0; }
.marker {
  position: absolute; top: 76px; left: 26px; width: 40px; height: 40px;
  border: 2px solid rgba(255, 255, 255, 0.75); border-radius: 6px;
  display: grid; place-items: center; font-size: 22px; font-weight: bold; color: rgba(255, 255, 255, 0.85);
}
.plate {
  position: absolute; left: 26px; bottom: 22px; text-align: left; white-space: pre-line;
  font-size: 11px; line-height: 1.6; letter-spacing: 0.14em; color: rgba(255, 255, 255, 0.6);
  font-variant-numeric: tabular-nums;
}
body.light .marker { border-color: rgba(17, 17, 17, 0.7); color: rgba(17, 17, 17, 0.8); }
body.light .plate, body.light .brand .by { color: rgba(17, 17, 17, 0.65); }
body.light .brand .name { color: #111111; }

/* controls fade away when nobody touches the mouse, so the mirror is just the mirror */
body.idle .dock, body.idle .top { opacity: 0; pointer-events: none; }
body.idle { cursor: none; }
body.intro .film { opacity: 0; }

@media (max-width: 720px) {
  .label { display: none; }
  .dock { gap: 8px; bottom: 10px; }
  .chip, .tool { padding: 8px 9px; font-size: 12px; }
  .plate { display: none; }
}

/* ---- anatomy layers, labels, panel sections ---- */
canvas#labelsCanvas { position: fixed; inset: 0; width: 100%; height: 100%; display: block; pointer-events: none; }
.panel h3 {
  font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted);
  margin: 22px 0 4px; padding-top: 14px; border-top: 1px solid var(--line);
}
.panel h3:first-of-type { border-top: 0; padding-top: 0; margin-top: 10px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }
.grid2 .row { margin: 8px 0; font-size: 13px; }
.row.check i { width: 9px; height: 9px; border-radius: 50%; flex: none; margin-right: -4px; }
.row b { float: right; font-weight: normal; color: var(--text); font-variant-numeric: tabular-nums; }
@media (max-width: 1100px) { .dock .label { display: none; } .dock { gap: 10px; } }

/* ---- brand mark ---- */
.brand { display: flex; align-items: center; gap: 12px; }
.brand .logo { width: 46px; height: 44px; object-fit: contain; mix-blend-mode: screen; }
body.light .brand .logo { filter: invert(1); mix-blend-mode: multiply; }

/* ---- the wheel (the studio's circle menu, as in IMERA and Arena) ---- */
.hubwrap { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); display: grid; justify-items: center; gap: 6px; transition: opacity 0.5s; z-index: 6; }
.hub {
  width: 68px; height: 68px; border-radius: 50%; padding: 0; cursor: pointer;
  background: rgba(34, 39, 46, 0.88); border: 1px solid var(--line);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.45); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  transition: transform 0.18s, border-color 0.18s;
}
.hub:hover { transform: scale(1.06); border-color: rgba(255, 255, 255, 0.4); }
.hub svg { width: 48px; height: 48px; display: block; margin: auto; }
.hub svg circle { fill: none; stroke: #fff; stroke-width: 2.5; stroke-dasharray: 9.2 4.15; }
.hub svg .dot { fill: var(--earth); stroke: none; }
.hubhint { font-size: 11px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--muted); text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8); }
body.menu .hubhint { visibility: hidden; }
body.idle .hubwrap { opacity: 0; pointer-events: none; }

.wheel {
  position: fixed; inset: 0; display: none; place-items: center; z-index: 5;
  background: rgba(22, 25, 29, 0); transition: background 0.25s;
}
.wheel.showing { display: grid; }
.wheel.open { background: rgba(22, 25, 29, 0.55); }
.wheel-svg { width: min(86vmin, 760px); height: min(86vmin, 760px); overflow: visible; touch-action: none; user-select: none; }
.wheel-face { fill: #1B1F24; opacity: 0; transition: opacity 0.25s; filter: drop-shadow(0 10px 30px rgba(0, 0, 0, 0.5)); }
.wheel.open .wheel-face { opacity: 0.94; }
.wheel-slice { cursor: pointer; }
.wheel-slice .base { stroke-width: 14; stroke-linejoin: round; }
.wheel-slice text { font: bold 19px Arial, Helvetica, sans-serif; letter-spacing: 2px; pointer-events: none; }
.wheel-ic { fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; pointer-events: none; }
.wheel-ind { fill: none; stroke: #fff; stroke-width: 6; stroke-linecap: round; pointer-events: none; }
.wheel-hub { pointer-events: none; opacity: 0; transition: opacity 0.2s; }
.wheel.open .wheel-hub { opacity: 1; }
.wheel-title { font: bold 58px Arial, Helvetica, sans-serif; fill: #fff; letter-spacing: -1.2px; }
.wheel-title.small { font-size: 34px; letter-spacing: -0.5px; }
.wheel-hint { font: 22px Arial, Helvetica, sans-serif; fill: rgba(255, 255, 255, 0.62); }
.wheel-chip { cursor: pointer; transform-box: fill-box; transform-origin: center; animation: chipIn 0.3s cubic-bezier(0.2, 0.9, 0.3, 1.25) both; }
.wheel-chip rect { fill: rgba(255, 255, 255, 0.15); }
.wheel-chip:hover rect { fill: rgba(255, 255, 255, 0.26); }
.wheel-chip text { fill: #fff; font: bold 22px Arial, Helvetica, sans-serif; pointer-events: none; }
.wheel-chip.on rect { fill: var(--c); }
.wheel-chip.on text { fill: var(--k); }
@keyframes chipIn { from { opacity: 0; transform: scale(0.8); } to { opacity: 1; transform: scale(1); } }
@media (prefers-reduced-motion: reduce) { .wheel-chip { animation: none; } }
.panel { z-index: 7; }

/* ---- credits ---- */
.card .credit { font-size: 11px; line-height: 1.5; margin: 12px 0 0; padding-top: 12px; border-top: 1px solid var(--line); }
.card a, .panel a, .page a { color: #9DB9DD; }
.card a:focus-visible, .panel a:focus-visible, .page a:focus-visible { outline: 2px solid var(--yellow); outline-offset: 2px; }
body.page-body { overflow: auto; background: var(--slate); }
.page { max-width: 720px; margin: 0 auto; padding: 40px 24px 60px; }
.page .brand { display: flex; align-items: center; gap: 12px; margin-bottom: 34px; }
.page h1 { font-size: 28px; margin: 0 0 12px; }
.page h2 { font-size: 17px; margin: 30px 0 8px; }
.page p, .page li { font-size: 15px; line-height: 1.6; color: rgba(255, 255, 255, 0.82); }
.page ul { padding-left: 20px; }
.page .back { display: inline-block; margin-top: 28px; font-weight: bold; }
.page .fineprint { font-size: 12px; color: var(--muted); margin-top: 34px; }

/* The camera video is kept on the page but out of sight: Safari stops feeding frames from a video that is display:none. */
video.offstage { position: fixed; left: 0; top: 0; width: 2px; height: 2px; opacity: 0; pointer-events: none; }

/* ---- heart bar: rate and size sliders either side of the menu button ---- */
.heartbar { position: fixed; left: 0; right: 0; bottom: 30px; display: flex; justify-content: center; gap: 116px; pointer-events: none; z-index: 5; }
.hb {
  pointer-events: auto; display: flex; align-items: center; gap: 10px; height: 52px; padding: 0 16px;
  width: min(430px, calc(50vw - 74px)); background: rgba(34, 39, 46, 0.86); border: 1px solid var(--line); border-radius: 999px;
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); font-size: 13px; color: var(--muted); white-space: nowrap;
}
.hb label { flex: none; }
.hb input[type=range] { flex: 1 1 60px; min-width: 50px; accent-color: var(--earth); }
.hb b { flex: none; min-width: 58px; text-align: right; color: var(--text); font-variant-numeric: tabular-nums; }
.hb svg { flex: none; width: 22px; height: 22px; fill: var(--earth); transform-origin: 50% 60%; }
.hb canvas { flex: none; width: 100px; height: 40px; }
.hb-state { flex: 0 1 auto; overflow: hidden; text-overflow: ellipsis; font-size: 12px; }
#intro:not([hidden]) ~ .heartbar { display: none; }
@media (max-width: 900px) {
  .heartbar { flex-direction: column; align-items: center; gap: 8px; bottom: 122px; }
  .hb { width: min(430px, calc(100vw - 24px)); }
  .hb-state { display: none; }
}

/* ---- phones and tablets ---- */
html, body { overscroll-behavior: none; -webkit-tap-highlight-color: transparent; -webkit-text-size-adjust: 100%; }
body { position: fixed; inset: 0; touch-action: manipulation; -webkit-user-select: none; user-select: none; }
body.page-body { position: static; touch-action: auto; -webkit-user-select: text; user-select: text; }
.panel, .card { -webkit-overflow-scrolling: touch; }
.card { max-height: calc(100% - 96px); overflow-y: auto; }
.top { padding-top: calc(18px + env(safe-area-inset-top)); padding-left: calc(22px + env(safe-area-inset-left)); padding-right: calc(22px + env(safe-area-inset-right)); }
.hubwrap { bottom: calc(22px + env(safe-area-inset-bottom)); }
.heartbar { bottom: calc(30px + env(safe-area-inset-bottom)); }
.panel { padding-bottom: calc(18px + env(safe-area-inset-bottom)); padding-right: calc(20px + env(safe-area-inset-right)); }
@media (max-width: 900px) { .heartbar { bottom: calc(122px + env(safe-area-inset-bottom)); } }
@media (max-width: 480px) { .hb canvas { display: none; } .hb { gap: 8px; padding: 0 14px; } .card { padding: 20px 18px 16px; } .card h1 { font-size: 21px; } }
/* a phone held sideways: little height, so the two sliders sit either side of the menu button */
@media (max-height: 520px) {
  .heartbar { flex-direction: row; align-items: center; gap: 92px; bottom: calc(14px + env(safe-area-inset-bottom)); }
  .hb { width: calc(50vw - 62px); height: 44px; }
  .hb canvas, .hb-state { display: none; }
  .hubwrap { bottom: calc(8px + env(safe-area-inset-bottom)); }
  .hubhint { display: none; }
  .card { bottom: 8px; }
}
@media (pointer: coarse) {
  .hb input[type=range], .panel input[type=range] { min-height: 32px; }
  .panel .row.check { padding: 5px 0; }
}

/* the heart sliders are out of sight until the screen is tapped, and leave again a moment later */
.heartbar { transition: opacity 0.35s, transform 0.35s; }
.heartbar.away { opacity: 0; transform: translateY(14px); }
.heartbar.away .hb { pointer-events: none; }
