/* Cathedrix page shell and overlay. Quiet by design: small type, dark glass, nothing that competes
   with the cube. Geist: a neutral grotesk that stays crisp at 12 px on dark glass, with tabular
   figures for the depth digits; it recedes behind the ornate glass where a serif would echo it. */

:root {
  --bg: #060606;
  --ink: rgba(242, 236, 226, 0.88);
  --ink-dim: rgba(242, 236, 226, 0.5);
  --glass: rgba(13, 12, 11, 0.44);
  --edge: rgba(255, 244, 228, 0.09);
  --lift: rgba(255, 240, 220, 0.09);
  --warm: rgb(255, 214, 162);
  --focus: rgba(255, 226, 186, 0.7);
  --h: 30px;
  --r: 9px;
  --gap: 6px;
  --inset: 18px;
  --font: 'Geist', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
  color-scheme: dark;
}

@media (max-width: 640px), (pointer: coarse) {
  :root { --h: 36px; --r: 10px; --inset: 14px; }
}

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

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--bg);
}

body {
  position: fixed;
  inset: 0;
  font: 400 12px/1 var(--font);
  letter-spacing: 0.01em;
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

/* ---------------------------------------------------------------- stage */

#stage {
  position: fixed;
  inset: 0;
  touch-action: none;
}
#stage canvas { display: block; width: 100%; height: 100%; outline: none; }

/* ---------------------------------------------------------------- overlay */

.ui {
  position: fixed;
  inset: 0;
  pointer-events: none;          /* drags on empty overlay space reach the canvas */
  opacity: 0;
  transition: opacity 0.9s ease 0.2s;
}
.ui.on { opacity: 1; }

.ui .cluster {
  position: absolute;
  display: flex;
  align-items: center;
  gap: var(--gap);
  pointer-events: auto;
}
.ui .tl { top: calc(env(safe-area-inset-top, 0px) + var(--inset)); left: calc(env(safe-area-inset-left, 0px) + var(--inset)); }
.ui .tr { top: calc(env(safe-area-inset-top, 0px) + var(--inset)); right: calc(env(safe-area-inset-right, 0px) + var(--inset)); }
.ui .bc {
  bottom: calc(env(safe-area-inset-bottom, 0px) + var(--inset) + 4px);
  left: 50%;
  transform: translateX(-50%);
}

.ui button {
  appearance: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  letter-spacing: inherit;
  color: inherit;
  cursor: pointer;
  touch-action: manipulation;
}
.ui button:focus { outline: none; }
.ui button:focus-visible { outline: 1px solid var(--focus); outline-offset: 2px; }

/* dark glass: one rounded pane, segments inside it */
.ui .glass {
  background: var(--glass);
  border: 1px solid var(--edge);
  border-radius: var(--r);
  -webkit-backdrop-filter: blur(14px) saturate(1.25);
  backdrop-filter: blur(14px) saturate(1.25);
  transition: border-color 0.6s ease, opacity 0.35s ease;
}

.ui .seg {
  display: flex;
  align-items: center;
  height: var(--h);
  padding: 2px;
}

.ui .chip {
  height: 100%;
  padding: 0 11px;
  border-radius: calc(var(--r) - 3px);
  color: var(--ink-dim);
  white-space: nowrap;
  transition: color 0.2s ease, background-color 0.25s ease;
}
.ui .chip[aria-pressed='true'] { color: var(--ink); background: var(--lift); font-weight: 500; }

.ui .rule {
  width: 1px;
  height: 40%;
  margin: 0 3px;
  background: var(--edge);
}

.ui .depths { display: flex; height: 100%; }
.ui .depths .chip {
  min-width: 26px;
  padding: 0 6px;
  font-variant-numeric: tabular-nums;
}

.ui .go { color: var(--ink); padding: 0 12px; }

.ui .icon {
  display: grid;
  place-items: center;
  width: var(--h);
  height: var(--h);
  color: var(--ink-dim);
  transition: color 0.2s ease, opacity 0.35s ease, border-color 0.6s ease;
}
.ui .ichip {
  display: grid;
  place-items: center;
  width: calc(var(--h) - 2px);
  padding: 0;
}
.ui .icon svg, .ui .ichip svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.3;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.ui .icon .off { display: none; }
.ui .icon[aria-pressed='false'] .on { display: none; }
.ui .icon[aria-pressed='false'] .off { display: inline; }

@media (hover: hover) {
  .ui .chip:hover, .ui .icon:hover { color: var(--ink); }
}

/* unavailable: the control dims, its glass stays (dimming the pane would let the floor glare through);
   still focusable, so keyboard focus is never lost */
.ui [aria-disabled='true'] { cursor: default; opacity: 0.3; }
@media (hover: hover) {
  .ui [aria-disabled='true']:hover { color: var(--ink-dim); }
}

/* the action that holds the lock breathes while it runs */
.ui .running, .ui .running:hover { color: var(--ink); animation: breathe 1.6s ease-in-out infinite; }
@keyframes breathe { 0%, 100% { opacity: 0.95; } 50% { opacity: 0.4; } }

/* solved: the scramble pane warms a little, nothing more */
.ui.solved .scramble { border-color: rgba(255, 222, 182, 0.2); }
.ui.solved .go { color: rgb(255, 242, 226); text-shadow: 0 0 14px rgba(255, 196, 132, 0.35); }

/* ---------------------------------------------------------------- loading veil */

#veil {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  background: var(--bg);
  transition: opacity 0.9s ease;
}
#veil.gone { opacity: 0; pointer-events: none; }

#veil .panes {
  display: grid;
  grid-template-columns: repeat(3, 7px);
  gap: 3px;
}
#veil .panes i {
  position: relative;
  width: 7px;
  height: 7px;
  border-radius: 1px;
  background: rgba(255, 240, 220, 0.07);
}
#veil .panes i::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: var(--warm);
  box-shadow: 0 0 9px rgba(255, 178, 104, 0.45);
  opacity: var(--o, 0);
  transition: opacity 0.35s ease;
}

@media (prefers-reduced-motion: reduce) {
  .ui, #veil, .ui .chip, .ui .icon, .ui .glass { transition-duration: 0.01s; }
  .ui .running { animation: none; opacity: 0.6; }
}
