/* The scanner's own components, shared by the local page (index.html) and the
 * public one (public.html, zhouer.org/rubik). Colours are zhouer.org's token
 * names (--ink, --dim, --line, --accent, --danger …): the public page gets
 * their values from the site's theme.css, the local page defines its own. */

.stage { position: relative; background: #000; border-radius: 10px; overflow: hidden; aspect-ratio: 4 / 3; display: grid; place-items: center; }
.stage canvas#view { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; display: block; }
.stage canvas.mirror { transform: scaleX(-1); }
#placeholder { position: absolute; color: #c9c9c9; padding: 24px; text-align: center; line-height: 1.6; }
#video { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }

/* the cube as it grows, over the camera picture: on a narrow screen the result
 * is below, out of sight while scanning */
.mini3d { display: none; position: absolute; right: 6px; bottom: 6px; width: 34%; aspect-ratio: 1; pointer-events: none; }
body.scanning .mini3d { display: block; }
@media (min-width: 960px) { body.scanning .mini3d { display: none; } }

.status-line { margin: 10px 0 6px; min-height: 1.6em; font-size: 15px; }
.status-line .sw { margin: 0 2px; }

.counts { display: flex; gap: 14px; flex-wrap: wrap; font-size: 13px; color: var(--dim, #666); margin: 2px 0 6px; }
.counts b { color: var(--ink, #222); font-variant-numeric: tabular-nums; }

.progress { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.slot { position: relative; border: 1px solid var(--line, #ddd); border-radius: 8px; padding: 6px; text-align: center; font-size: 12px; color: var(--dim, #666); }
.slot.empty { border-style: dashed; min-height: 74px; display: grid; place-items: center; font-size: 18px; color: var(--faint, #999); }
.slot .tick { position: absolute; top: -7px; right: -7px; width: 18px; height: 18px; border-radius: 50%; background: var(--success, #2f7d4f); color: #fff; font-size: 12px; line-height: 18px; text-align: center; }
.thumb { display: grid; grid-template-columns: repeat(3, 1fr); gap: 2px; aspect-ratio: 1; background: #111; padding: 2px; border-radius: 4px; margin-bottom: 4px; }
.thumb i { border-radius: 2px; }

.edges { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 10px; font-size: 13px; color: var(--dim, #666); }
.edge { display: inline-flex; width: 30px; height: 18px; border-radius: 4px; overflow: hidden; border: 1px solid rgba(0, 0, 0, .35); opacity: .28; }
.edge i { flex: 1; }
.edge.seen { opacity: 1; }
.edge.ask { opacity: 1; outline: 3px solid var(--accent, #2f6fde); outline-offset: 2px; animation: rubik-pulse 1s ease-in-out infinite alternate; }
@keyframes rubik-pulse { from { outline-color: var(--accent, #2f6fde); } to { outline-color: transparent; } }

.vprog { display: flex; gap: 10px; align-items: center; margin-top: 10px; font-size: 13px; color: var(--dim, #666); }
.vprog progress { flex: 1; height: 8px; accent-color: var(--accent, #2f6fde); }

.cube3d { display: block; width: 100%; aspect-ratio: 4 / 3; max-height: 380px; margin: 0 auto; touch-action: none; }
.cube3d.mirror { transform: scaleX(-1); }

.note { color: var(--dim, #666); font-size: 13px; }

.msg { border-radius: 8px; padding: 8px 12px; margin: 8px 0; }
.msg.ok { background: color-mix(in srgb, var(--success, #1f9d55) 14%, transparent); }
.msg.bad { background: color-mix(in srgb, var(--danger, #e0342b) 14%, transparent); }
.msg.wait { background: color-mix(in srgb, var(--warning, #c27c00) 14%, transparent); }
.msg ul { margin: 4px 0; padding-left: 20px; }
.msg p { margin: 6px 0 0; }

.sw { display: inline-block; width: 14px; height: 14px; border-radius: 3px; border: 1px solid rgba(0, 0, 0, .35); vertical-align: -2px; margin: 0 3px; }

.checklist { margin: 4px 0 0; font-size: 14px; text-align: center; }
.checklist p { margin: 4px 0; }
.checklist button { font-size: 13px; padding: 3px 10px; margin-left: 4px; }
/* the outlines on the 3D cube, as a key (cube3d.js draws them) */
.flagkey { white-space: nowrap; margin-left: 6px; color: var(--dim, #666); font-size: 13px; }
.flag { display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: -1px; margin-right: 5px; background: #7a7a80; outline-offset: 1px; }
.flag.unsure { outline: 2px dotted rgb(255, 190, 40); }
.flag.fixed { outline: 2px dashed rgb(90, 150, 255); }
.flag.bad { outline: 2px solid rgb(255, 45, 149); }
.flag.missing { background: #46464a; }

#moves { font: 600 18px/1.7 var(--font-mono, ui-monospace, monospace); display: flex; flex-wrap: wrap; gap: 2px 4px; align-items: baseline; margin: 8px 0; }
#moves .mv { font: inherit; border: 0; background: none; color: var(--ink, #222); padding: 0 4px; border-radius: 4px; box-shadow: none; }
#moves .mv:hover { background: color-mix(in srgb, var(--accent, #2f6fde) 15%, transparent); }
#moves .mv.done { color: var(--dim, #666); opacity: .6; }
#moves .mv.now { background: var(--accent, #2f6fde); color: var(--accent-ink, #fff); }
#moves .count { font: 14px var(--font-ui, system-ui, sans-serif); color: var(--dim, #666); margin-left: 6px; }

.player .scrub { width: 100%; margin: 6px 0 2px; }
.player .controls { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 8px; }
.step-now { display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: 16px; align-items: center; margin: 10px 0 4px; }
.step-count { grid-column: 1 / 3; color: var(--dim, #666); font-size: 13px; }
.step-move { font: 700 48px/1.1 var(--font-mono, ui-monospace, monospace); min-width: 2.2em; }
.step-desc { font-size: 18px; }

.palette { position: absolute; z-index: 10; display: flex; gap: 6px; padding: 6px; background: var(--surface, #fff); border: 1px solid var(--line, #ddd); border-radius: 10px; box-shadow: 0 6px 20px rgba(0, 0, 0, .25); }
.palette button { width: 32px; height: 32px; padding: 0; border-radius: 6px; border: 1px solid rgba(0, 0, 0, .35); }
.palette button.current { outline: 3px solid var(--accent, #2f6fde); outline-offset: 1px; }


/* two ways in, as tabs over the page: the camera (the main one) and entering
 * the colours by hand on the result's own cube */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line, #ddd); }
.tabs .tab { border: 0; background: none; box-shadow: none; border-radius: 0; padding: 8px 14px; margin-bottom: -1px; font: inherit; font-weight: 600; color: var(--dim, #666); border-bottom: 3px solid transparent; cursor: pointer; }
.tabs .tab:hover { color: var(--ink, #222); background: none; }
.tabs .tab[aria-selected="true"] { color: var(--ink, #222); border-bottom-color: var(--accent, #2f6fde); }
.hand-tools .toolbar.center, .paint.center { justify-content: center; }
.turns { flex-wrap: nowrap; }
.turns button { flex: 1 1 0; max-width: 9em; min-width: 0; white-space: nowrap; }
@media (max-width: 600px) { .tabs .tab { padding: 8px 10px; } }
body.manual #cube3d { cursor: crosshair; }
.paint { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 8px 0; }
.paint button { width: 40px; height: 40px; padding: 0; border-radius: 8px; border: 1px solid rgba(0, 0, 0, .35); font: 600 12px/1 var(--font-mono, ui-monospace, monospace); color: rgba(0, 0, 0, .55); }
.paint button.on { outline: 3px solid var(--accent, #2f6fde); outline-offset: 2px; }

/* the result: the cube beside its solution once the scan is done */
.result-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 4px 20px; align-items: start; }
/* the colours of a sticker open over the cube */
.cube-col { position: relative; }

/* solving: the scan is done, so the result takes the page and the camera
 * folds away (its card keeps the buttons to scan again) */
body.solving #result { order: -1; }
body.solving .stage, body.solving #progress, body.solving #edges, body.solving .counts, body.solving .vprog { display: none; }
@media (min-width: 960px) {
  body.solving .scanner-layout { grid-template-columns: minmax(0, 1fr); }
  body.solving .result-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); }
  body.solving .cube3d { max-height: 460px; }
  body.solving .result-grid .cube-col { position: sticky; top: 12px; }
}

[hidden] { display: none !important; }
