/* input.css — the "enter your cube" widgets: NetEditor (.ne-*), Scanner (.sc-*)
 * and CubeInput (.ci-*). Load after rubiks.css. Chrome colours are site tokens;
 * sticker colours are the --st-* tokens from rubiks.css.
 */

/* ── net editor ──────────────────────────────────────────────────────────── */
.ne { display: flex; flex-direction: column; gap: 12px; min-width: 0; }

.ne-palette {
  display: grid; gap: 6px;
  grid-template-columns: repeat(auto-fit, minmax(76px, 1fr));
}
.ne-pal {
  display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto;
  column-gap: 8px; align-items: center; text-align: left;
  min-block-size: 48px; padding: 6px 8px;
  font: inherit; font-size: 0.85rem; line-height: 1.15;
  color: var(--ink); background: var(--surface-hi);
  border: 1px solid var(--line); border-radius: var(--radius);
  cursor: pointer;
}
.ne-pal .swatch { grid-row: 1 / 3; width: 26px; height: 26px; border-radius: 7px; }
.ne-pal .swatch[data-c="6"] {
  background: repeating-linear-gradient(45deg, var(--st-unknown) 0 4px, color-mix(in srgb, var(--st-unknown) 60%, var(--surface)) 4px 7px);
}
.ne-pal-name { font-weight: 600; }
.ne-count { font-family: var(--font-mono); font-size: 0.78rem; color: var(--ink-dim); }
.ne-pal:hover { border-color: var(--line-strong); }
.ne-pal[aria-pressed="true"] {
  border-color: var(--accent); background: var(--accent-soft);
  box-shadow: inset 0 0 0 1px var(--accent);
}
.ne-pal.is-done .ne-count { color: var(--safe-text); }
.ne-pal.is-off { border-color: color-mix(in srgb, var(--warn) 70%, transparent); }
.ne-pal.is-off .ne-count { color: var(--warn); font-weight: 700; }
.ne-pal.is-off .ne-count::after { content: " !"; }

.ne-stage {
  position: relative;
  padding: 8px;
  background: var(--surface-sunken);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  touch-action: none;
  user-select: none; -webkit-user-select: none;
  outline: none;
}
.ne-stage:focus-visible { box-shadow: 0 0 0 3px var(--focus-ring); }
.ne-svg { display: block; width: 100%; height: auto; max-height: 560px; margin: 0 auto; }
.ne.is-face .ne-svg { max-width: min(100%, 520px); }

.ne-plastic { fill: var(--cube-plastic); stroke: var(--line); stroke-width: 0.3; }
.ne-st { cursor: crosshair; transition: fill 0.12s; }
.ne-st[data-c="0"] { fill: var(--st-w); }
.ne-st[data-c="1"] { fill: var(--st-r); }
.ne-st[data-c="2"] { fill: var(--st-g); }
.ne-st[data-c="3"] { fill: var(--st-y); }
.ne-st[data-c="4"] { fill: var(--st-o); }
.ne-st[data-c="5"] { fill: var(--st-b); }
.ne-st[data-c="6"] { fill: var(--ne-hatch, var(--st-unknown)); }
.ne-hatch-bg { fill: var(--st-unknown); }
.ne-hatch-line { fill: rgb(255 255 255 / 0.14); }
.ne-face { transition: opacity 0.2s; }
.ne-face.is-dim { opacity: 0.32; }
.ne-face.is-dim .ne-st { cursor: pointer; }

/* centre sticker on odd cubes: a small badge with the face letter */
.ne-centre { pointer-events: none; }
.ne-centre circle { fill: rgb(255 255 255 / 0.88); stroke: rgb(0 0 0 / 0.55); stroke-width: 0.35; }
.ne-centre text { fill: #16131A; font-weight: 800; font-family: var(--font-sans); }
.ne-facelabel {
  pointer-events: none; font-weight: 800; font-family: var(--font-sans);
  fill: rgb(255 255 255 / 0.55); stroke: rgb(0 0 0 / 0.45); stroke-width: 0.35; paint-order: stroke;
}

.ne-rings, .ne-cursor { pointer-events: none; }
.ne-hl { fill: none; stroke: var(--danger); stroke-width: 1.5; animation: ne-pulse 1.1s ease-in-out infinite; }
.ne-mark { fill: none; stroke: var(--warn); stroke-width: 1.2; stroke-dasharray: 1.8 1.1; }
.ne-flash { fill: none; stroke: var(--accent); stroke-width: 1.4; animation: ne-fade 2.6s ease-out forwards; }
.ne-cursor { fill: none; stroke: var(--focus-ring); stroke-width: 1.4; opacity: 0; }
.ne-stage:focus-visible .ne-cursor { opacity: 1; }
@keyframes ne-pulse { 50% { stroke-opacity: 0.35; } }
@keyframes ne-fade { 0%, 70% { stroke-opacity: 1; } 100% { stroke-opacity: 0; } }

.ne-faces { display: flex; flex-wrap: wrap; gap: 6px; }
.ne-facebtn {
  display: inline-flex; align-items: center; gap: 6px;
  min-block-size: 44px; padding: 4px 10px 4px 6px;
  font: inherit; font-size: 0.85rem; font-weight: 600;
  color: var(--ink-dim); background: var(--surface-hi);
  border: 1px solid var(--line); border-radius: var(--radius); cursor: pointer;
}
.ne-facebtn:hover { color: var(--ink); border-color: var(--line-strong); }
.ne-facebtn[aria-pressed="true"] { color: var(--ink); border-color: var(--accent); background: var(--accent-soft); }
.ne-facethumb, .sc-c3g {
  display: grid; grid-template-columns: repeat(var(--n, 3), 1fr); gap: 1px;
  padding: 1px; background: var(--cube-plastic); border-radius: 4px;
}
.ne-facethumb { width: 24px; height: 24px; }
.ne-facethumb i, .sc-c3g i { display: block; border-radius: 1px; min-width: 0; min-height: 0; }
.ne-facethumb i[data-c="0"] { background: var(--st-w); }
.ne-facethumb i[data-c="1"] { background: var(--st-r); }
.ne-facethumb i[data-c="2"] { background: var(--st-g); }
.ne-facethumb i[data-c="3"] { background: var(--st-y); }
.ne-facethumb i[data-c="4"] { background: var(--st-o); }
.ne-facethumb i[data-c="5"] { background: var(--st-b); }
.ne-facethumb i[data-c="6"] { background: var(--st-unknown); }

.ne-tools { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; }
.ne-facetools { display: flex; flex-wrap: wrap; gap: 8px; }

/* ── scanner ─────────────────────────────────────────────────────────────── */
.sc { display: flex; flex-direction: column; gap: 12px; }
.sc section { display: flex; flex-direction: column; gap: 12px; }
.sc h3 { margin: 0; }
.sc.is-review .sc-top { display: none; }
.sc-top { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; }
.sc-toggle { display: inline-flex; align-items: center; gap: 8px; min-block-size: 44px; font-weight: 600; font-size: 0.9rem; cursor: pointer; }
.sc .sc-check { width: 20px; height: 20px; min-block-size: 0; min-inline-size: 0; padding: 0; flex: none; accent-color: var(--accent); margin: 0; }
.sc-sizenote { font-weight: 600; }
.sc-privacy {
  display: flex; gap: 8px; align-items: flex-start;
  font-size: var(--fs-small); color: var(--ink-dim); margin: 0;
}
.sc-lock { color: var(--safe-text); flex: none; margin-top: 2px; display: inline-flex; }
.sc-tips { margin: 0; }

/* live layout: stage, then tray (side by side when there's room) */
.sc .sc-live { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; align-items: start; }
@media (min-width: 900px), (orientation: landscape) and (min-width: 600px) {
  .sc .sc-live { grid-template-columns: minmax(0, 1.6fr) minmax(220px, 1fr); }
}
.sc-stagecol, .sc-sidecol { display: flex; flex-direction: column; gap: 10px; min-width: 0; }

.sc-guide { display: flex; gap: 16px; align-items: center; }
.sc-guide-pic { display: flex; flex-direction: column; align-items: center; gap: 2px; flex: none; }
.sc-guide-title { font-size: 1rem; margin: 0 0 4px; }
.sc-guide-text { margin: 0; color: var(--ink-dim); }
.sc-replay { font-size: 0.78rem; min-block-size: 32px; }

/* the little 3-D cube that shows how to turn the real one (guided mode) */
.sc-c3wrap { --s: 64px; width: calc(var(--s) * 1.5); height: calc(var(--s) * 1.5); perspective: 520px; display: grid; place-items: center; }
.sc-c3 {
  position: relative; width: var(--s); height: var(--s);
  transform-style: preserve-3d;
  transform: rotateX(-24deg) rotateY(-34deg) rotateX(var(--ax, 0deg)) rotateY(var(--ay, 0deg));
  transition: transform 0.7s cubic-bezier(0.45, 0.05, 0.25, 1);
}
.sc-c3f {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  background: var(--surface-hi);
  border: 2px solid var(--line-strong); border-radius: 8px;
  color: var(--ink-dim); font-weight: 800; font-size: 1.1rem;
  backface-visibility: hidden;
}
.sc-c3f.is-current { background: color-mix(in srgb, var(--accent) 30%, var(--surface-hi)); border-color: var(--accent); color: var(--ink); }
.sc-c3f.is-done .sc-c3n { display: none; }
.sc-c3f:not(.is-done) .sc-c3g { display: none; }
.sc-c3g { position: absolute; inset: 3px; border-radius: 5px; }
.sc-c3-front  { transform: translateZ(calc(var(--s) / 2)); }
.sc-c3-right  { transform: rotateY(90deg) translateZ(calc(var(--s) / 2)); }
.sc-c3-back   { transform: rotateY(180deg) translateZ(calc(var(--s) / 2)); }
.sc-c3-left   { transform: rotateY(-90deg) translateZ(calc(var(--s) / 2)); }
.sc-c3-top    { transform: rotateX(90deg) translateZ(calc(var(--s) / 2)); }
.sc-c3-bottom { transform: rotateX(-90deg) translateZ(calc(var(--s) / 2)); }

/* the camera / photo stage (its width is set from the picture's shape in JS) */
.sc-view {
  position: relative; width: 100%; max-width: 100%; margin: 0 auto;
  background: var(--cube-plastic); border-radius: var(--radius-lg); overflow: hidden;
  touch-action: none; outline: none;
}
.sc-view.is-off { aspect-ratio: 4 / 3; }
.sc-video, .sc-photo { display: block; width: 100%; height: auto; }
.sc-view.is-off .sc-video { display: none; }
.sc-view.is-mirror .sc-video, .sc-view.is-mirror .sc-overlay { transform: scaleX(-1); }
.sc-overlay { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.sc-shade { fill: rgb(0 0 0 / 0.32); }
.sc-grid { fill: none; stroke: #FFFFFF; stroke-opacity: 0.85; }
.sc-grid-halo { fill: none; stroke: rgb(0 0 0 / 0.45); }
.sc-frame { fill: none; stroke: var(--accent); stroke-linejoin: round; }
.sc-ov.is-seen .sc-frame { stroke: var(--warn); }
.sc-ov.is-steady .sc-frame { stroke: var(--safe); }
.sc-ov.is-dup .sc-frame, .sc-ov.is-warn .sc-frame { stroke: var(--danger); stroke-dasharray: 12 8; }
.sc-ov.is-dup .sc-shade { fill: rgb(0 0 0 / 0.5); }
.sc-status {
  position: absolute; top: 10px; left: 50%; transform: translateX(-50%);
  max-width: calc(100% - 20px); width: max-content;
  padding: 6px 14px; border-radius: var(--radius-pill);
  background: rgb(10 8 14 / 0.72); color: #FFFFFF;
  font-weight: 600; font-size: 0.9rem; text-align: center; line-height: 1.3;
  pointer-events: none;
}
.sc-status:empty { display: none; }
.sc-status.is-ok { background: color-mix(in srgb, var(--safe) 35%, rgb(10 8 14 / 0.85)); }
.sc-status.is-dup, .sc-status.is-warn { background: color-mix(in srgb, var(--warn) 40%, rgb(10 8 14 / 0.85)); }
.sc-progress { position: absolute; left: 0; right: 0; bottom: 0; height: 6px; background: rgb(0 0 0 / 0.35); pointer-events: none; }
.sc-progress i { display: block; height: 100%; background: var(--safe); transform-origin: left center; transform: scaleX(0); transition: transform 0.12s linear; }
.sc-gate {
  position: absolute; inset: 0; display: grid; place-items: center; align-content: center; gap: 12px;
  padding: 16px; text-align: center; background: var(--surface-sunken); color: var(--ink);
}
.sc-gate[hidden] { display: none; }
.sc-gate p { margin: 0; max-width: 42ch; }
.sc-gate .row { justify-content: center; }
.sc-handle {
  position: absolute; width: 44px; height: 44px; margin: 0; padding: 0;
  transform: translate(-50%, -50%);
  border-radius: 50%; border: 3px solid #FFFFFF;
  background: color-mix(in srgb, var(--accent) 45%, transparent);
  box-shadow: 0 1px 6px rgb(0 0 0 / 0.5);
  cursor: grab; touch-action: none;
}
.sc-handle::after { content: ""; position: absolute; left: 50%; top: 50%; width: 6px; height: 6px; margin: -3px; border-radius: 50%; background: #FFFFFF; }
.sc-handle:focus-visible { outline: 3px solid var(--focus-ring); outline-offset: 2px; }
.sc-view.flash::after { content: ""; position: absolute; inset: 0; background: #FFFFFF; animation: sc-flash 0.35s ease-out forwards; pointer-events: none; }
@keyframes sc-flash { from { opacity: 0.75; } to { opacity: 0; } }
.sc-hint { margin: 0; }
.sc-actions { gap: 6px; }

/* the tray of captured faces */
.sc-traywrap { padding: 10px; background: var(--surface-sunken); border: 1px solid var(--line); border-radius: var(--radius-lg); }
.sc-tray { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 6px; list-style: none; margin: 0; padding: 0; }
.sc-slot {
  position: relative; display: block; width: 100%; aspect-ratio: 1; padding: 0; overflow: hidden;
  border: 2px dashed var(--line-strong); border-radius: var(--radius); background: var(--surface);
  cursor: pointer; min-block-size: 40px;
}
.sc-slot:disabled { cursor: default; }
.sc-slot canvas { display: block; width: 100%; height: 100%; }
.sc-slot-n { position: absolute; top: 3px; left: 4px; font-size: 0.72rem; font-weight: 800; color: var(--ink-faint); line-height: 1; padding: 2px 4px; border-radius: 5px; }
.sc-slot.is-filled { border-style: solid; border-color: var(--line); }
.sc-slot.is-filled .sc-slot-n { background: rgb(10 8 14 / 0.65); color: #FFFFFF; }
.sc-slot.is-current { border-color: var(--accent); }
.sc-slot:focus-visible { outline: 3px solid var(--focus-ring); outline-offset: 2px; }
.sc-slot.is-pulse { animation: sc-pulse 0.9s ease-out; }
@keyframes sc-pulse { 0% { box-shadow: 0 0 0 0 var(--warn); } 40% { box-shadow: 0 0 0 5px var(--warn); } 100% { box-shadow: 0 0 0 0 transparent; } }
.sc-tray-note { margin: 8px 0 0; font-weight: 600; font-size: 0.92rem; }
.sc-fly {
  position: fixed; left: 0; top: 0; width: 192px; height: 192px; z-index: 200;
  transform-origin: 0 0; border-radius: 10px; box-shadow: var(--shadow-2); pointer-events: none;
}

/* review */
.sc-sizeask {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  padding: 10px 12px; border-radius: var(--radius);
  background: var(--accent-soft); border: 1px solid var(--accent-line);
}
.sc-sizeask select { min-block-size: 40px; padding: 4px 10px; }
.sc-dialog-pics { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin-bottom: 8px; }
.sc-bigcrop { width: min(240px, 100%); height: auto; border-radius: var(--radius); }
.sc-step-grid { display: grid; grid-template-columns: repeat(var(--n, 3), 1fr); gap: 1px; padding: 1px; background: var(--cube-plastic); border-radius: 4px; }
.sc-step-grid i { display: block; border-radius: 1px; }
.sc-biggrid { width: 150px; height: 150px; gap: 2px; padding: 2px; }


/* ── cube input ──────────────────────────────────────────────────────────── */
.ci { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.ci-head { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; }
.ci-tabs button[aria-selected="true"] { background: var(--accent); color: var(--accent-ink); }
.ci-tabs button { min-inline-size: 72px; }
.ci-body { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); align-items: start; }
@media (min-width: 900px) {
  .ci-body { grid-template-columns: minmax(0, 1fr) 280px; }
}
.ci-main { min-width: 0; }
.ci-side { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.ci-preview { display: flex; flex-direction: column; gap: 8px; }
.ci-stage { max-height: 300px; }
.ci-flat { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.ci-flat figure { margin: 0; text-align: center; }
.ci-flat svg { display: block; width: 100%; height: auto; max-width: 140px; margin: 0 auto; }
.ci-flat figcaption { font-size: 0.78rem; color: var(--ink-faint); }
.ci-check .panel-title { margin-bottom: 6px; }
.ci-verdict { margin: 0 0 8px; color: var(--ink-dim); font-size: 0.92rem; }
.ci-problems { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.ci-problem {
  width: 100%; text-align: left; min-block-size: 44px; padding: 8px 10px;
  font: inherit; font-size: 0.9rem; color: var(--ink);
  background: var(--surface-hi); border: 1px solid var(--line);
  border-left: 4px solid var(--danger); border-radius: var(--radius-sm); cursor: pointer;
}
.ci-problem[data-code="unpainted"] { border-left-color: var(--warn); }
.ci-problem:hover, .ci-problem:focus-visible { border-color: var(--line-strong); background: var(--surface); }
.ci-problem:focus-visible { outline: 3px solid var(--focus-ring); outline-offset: 1px; }

.ci-actions {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between;
  padding-top: 12px; border-top: 1px solid var(--line);
}
.ci-confirm-row { justify-content: flex-end; margin-left: auto; }
.ci-confirm[aria-disabled="true"] { opacity: 0.5; cursor: not-allowed; }
.ci-why { max-width: 32ch; text-align: right; }
.ci-why.nudge { color: var(--warn); animation: ci-nudge 0.4s; }
@keyframes ci-nudge { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }

.ci-type { width: 100%; font-family: var(--font-mono); letter-spacing: 0.12em; line-height: 1.6; }
.ci-type-msg { margin: 8px 0; min-height: 1.5em; font-size: var(--fs-small); color: var(--ink-dim); }
.ci-type-msg.is-ok { color: var(--safe-text); }
.ci-type-msg.is-warn { color: var(--warn); }
.ci-type-msg.is-bad { color: var(--danger); }
.ci-type-help p { margin: 0 0 6px; }
.ci-panel-type, .ci-panel-scan { display: flex; flex-direction: column; gap: 8px; }

@media (max-width: 520px) {
  .ci-stage { max-height: 240px; }
  .sc-guide { flex-direction: column; text-align: center; }
  .ci-why { text-align: left; max-width: none; }
  .ci-confirm-row { width: 100%; justify-content: space-between; margin-left: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .ne-hl, .ne-flash, .sc-view.flash::after, .ci-why.nudge { animation: none; }
  .sc-c3, .ne-st, .ne-face, .sc-progress i { transition: none; }
  .sc-slot.is-pulse { animation: none; outline: 3px solid var(--warn); }
}

/* While scanning, the scanner has its own review and buttons: hide the cube's. */
.ci[data-mode="scan"] .ci-side,
.ci[data-mode="scan"] .ci-actions,
.ci[data-mode="scan"] .ci-status { display: none; }
.ci[data-mode="scan"] .ci-body { grid-template-columns: minmax(0, 1fr); }
.ci[data-mode="scan"] .sc { max-width: 1100px; }

/* Scrolled to the top of the screen when a mode tab is tapped: clear the sticky app
   bar, which wraps to two rows (brand, then nav) on phones. */
.ci { scroll-margin-top: calc(var(--bar-h) + 16px); }
@media (max-width: 860px) { .ci { scroll-margin-top: 112px; } }
