/* cube.css — Cube Coach. Rubik (OFL, Hubert & Fischer — drawn for Chrome Cube Lab)
   is the app face; Rubik Mono One for big numerals. Latin subsets, self-hosted. */
@font-face {
  font-family: "Rubik";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("/learn/puzzles/cube/fonts/rubik-latin-var.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+2000-206F, U+2192, U+2032;
}
@font-face {
  font-family: "Rubik Mono One";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/learn/puzzles/cube/fonts/rubik-mono-one-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF;
}

.cube-page {
  --cc-ink: #eef1f8; --cc-dim: #98a2bd; --cc-line: rgba(148, 163, 205, .18);
  /* own solid dark base (chem-page precedent): the body's fixed-attachment
     gradient stops painting on long mobile pages */
  background: #070a14;
  color: var(--cc-ink);
  min-height: 100vh;
}
.cube-page .cc-panel h2, .cube-page .cc-hero h1 { color: var(--cc-ink); }
.cube-page .cc-hero p, .cube-page .cc-panel p, .cube-page .cc-panel li { color: #b6c0d9; }
.cube-page h1 .glow { color: #6ea8ff; }
.cc-hero p { max-width: 62ch; }

#cube-app {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(280px, 1fr);
  grid-template-areas: "stage side" "deck side";
  gap: 18px;
  margin-top: 18px;
  font-family: "Rubik", -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
}
.cc-stage {
  grid-area: stage;
  position: relative;
  min-height: 380px;
  height: clamp(380px, 52vh, 560px);
  border-radius: 18px;
  overflow: hidden;
  background:
    radial-gradient(120% 90% at 50% 12%, #232a3f 0%, #141827 52%, #0a0d18 100%);
  border: 1px solid var(--cc-line);
  touch-action: none;
}
.cc-stage canvas { width: 100%; height: 100%; display: block; }
.cc-nogl {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  padding: 24px; color: var(--cc-dim); text-align: center; font-size: 15px;
}

/* ---- deck ---- */
.cc-deck { grid-area: deck; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.cc-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.cc-btn {
  font: 500 14px/1 "Rubik", sans-serif;
  color: var(--cc-ink);
  background: rgba(120, 138, 190, .13);
  border: 1px solid var(--cc-line);
  border-radius: 10px;
  padding: 10px 14px;
  cursor: pointer;
  transition: background .15s, transform .06s;
}
.cc-btn:hover { background: rgba(120, 138, 190, .24); }
.cc-btn:active { transform: scale(.97); }
.cc-btn:disabled { opacity: .45; cursor: default; }
.cc-primary { background: #2e63d8; border-color: #2e63d8; }
.cc-primary:hover { background: #3a72ea; }
.cc-warm { font-size: 11px; opacity: .75; margin-left: 6px; }
.cc-btn.ready .cc-warm { display: none; }
.cc-ic { padding: 10px 12px; min-width: 42px; }
.cc-playbtn { font-size: 15px; }

.cc-algrow { flex-wrap: nowrap; }
.cc-alg {
  flex: 1; min-width: 0;
  font: 500 14px/1.2 ui-monospace, SFMono-Regular, Menlo, monospace;
  color: var(--cc-ink);
  letter-spacing: .06em;
  background: rgba(10, 13, 24, .6);
  border: 1px solid var(--cc-line);
  border-radius: 10px;
  padding: 11px 12px;
}
.cc-alg.bad { border-color: #e0475f; animation: cc-shake .3s; }
@keyframes cc-shake { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }

.cc-playrow { gap: 6px; }
.cc-scrub { flex: 1; min-width: 90px; accent-color: #2e63d8; }
.cc-speed { width: 84px; accent-color: #2e63d8; }
.cc-speedic { font-size: 12px; opacity: .7; }
.cc-counter {
  font: 400 12px "Rubik Mono One", "Rubik", monospace;
  color: var(--cc-dim);
  white-space: nowrap;
  min-width: 9ch;
  text-align: center;
}

.cc-seq {
  display: flex; gap: 5px; align-items: center;
  overflow-x: auto;
  padding: 4px 2px 8px;
  scrollbar-width: thin;
  min-height: 14px;
}
.cc-chip {
  font: 500 13px/1 ui-monospace, Menlo, monospace;
  color: var(--cc-ink);
  background: rgba(120, 138, 190, .12);
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 7px 8px;
  cursor: pointer;
  flex: 0 0 auto;
}
.cc-chip.cur { background: #2e63d8; border-color: #6ea8ff; box-shadow: 0 0 10px rgba(70, 120, 230, .45); }
.cc-stagechip {
  font: 500 11px "Rubik", sans-serif;
  color: #8fb4ff;
  border-left: 2px solid #2e63d8;
  padding: 4px 6px 4px 8px;
  margin-left: 6px;
  white-space: nowrap;
  flex: 0 0 auto;
}
.cc-stagecard {
  display: none;
  background: rgba(46, 99, 216, .1);
  border: 1px solid rgba(110, 168, 255, .25);
  border-radius: 14px;
  padding: 14px 16px;
}
.cc-stagecard.on { display: block; }
.cc-stagecard h3 { margin: 2px 0 6px; font: 700 17px "Rubik", sans-serif; color: var(--cc-ink); }
.cc-stagecard p { margin: 0; color: var(--cc-dim); font-size: 14px; line-height: 1.55; }
.cc-stgn { font: 400 10px "Rubik Mono One", monospace; color: #6ea8ff; letter-spacing: .08em; }

/* ---- side: flat map ---- */
.cc-side { grid-area: side; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.cc-nettitle { font: 500 13px "Rubik", sans-serif; color: var(--cc-dim); letter-spacing: .04em; text-transform: uppercase; }
.cc-net {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  grid-template-rows: repeat(9, 1fr);
  gap: 2px;
  aspect-ratio: 12 / 9;
  background: rgba(10, 13, 24, .5);
  border: 1px solid var(--cc-line);
  border-radius: 12px;
  padding: 8px;
}
.cc-cell {
  border: none;
  border-radius: 3px;
  padding: 0;
  font: 700 min(2.2vw, 11px)/1 "Rubik", sans-serif;
  cursor: default;
  transition: transform .08s;
}
.cc-editing .cc-cell:not(:disabled) { cursor: pointer; }
.cc-editing .cc-cell:not(:disabled):hover { transform: scale(1.12); }
.cc-cell.center { box-shadow: inset 0 0 0 2px rgba(8, 10, 18, .5); }
.cc-cell.warn { outline: 2px solid #ffb02e; outline-offset: 1px; animation: cc-pulse 1.2s infinite; }
@keyframes cc-pulse { 50% { outline-color: rgba(255, 176, 46, .25); } }
.cc-palrow { display: flex; gap: 8px; flex-wrap: wrap; }
.cc-pal {
  width: 44px; height: 40px;
  border-radius: 10px;
  border: 2px solid transparent;
  cursor: pointer;
  position: relative;
}
.cc-pal.sel { border-color: #fff; box-shadow: 0 0 0 3px rgba(110, 168, 255, .5); }
.cc-pal span {
  position: absolute; right: 3px; bottom: 2px;
  font: 700 10px "Rubik", sans-serif; color: rgba(10, 12, 20, .65);
  background: rgba(255, 255, 255, .65);
  border-radius: 6px; padding: 1px 4px;
}
.cc-editbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.cc-edithint { flex-basis: 100%; color: var(--cc-dim); font-size: 13px; line-height: 1.5; }
.cc-edithint.bad { color: #ff9aa8; }
.cc-cbrow { color: var(--cc-dim); font-size: 13px; display: flex; align-items: center; gap: 6px; cursor: pointer; }
.cc-cbrow input { accent-color: #2e63d8; }

/* ---- scan modal ---- */
.cc-scanov {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(5, 7, 14, .82);
  backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center;
  padding: 14px;
  overflow-y: auto;
}
.cc-scanbox {
  position: relative;
  width: min(520px, 100%);
  max-height: 100%;
  overflow-y: auto;
  background: #10141f;
  border: 1px solid var(--cc-line);
  border-radius: 18px;
  padding: 18px;
  color: var(--cc-ink);
}
.cc-scanhead h3 { margin: 0 0 6px; font: 700 19px "Rubik", sans-serif; }
.cc-scanhead p { margin: 0 0 12px; color: var(--cc-dim); font-size: 13px; line-height: 1.5; }
.cc-scanstep { font-size: 14px; line-height: 1.5; margin-bottom: 10px; color: var(--cc-ink); min-height: 3em; }
.cc-scanstep b { color: #8fb4ff; }
.cc-camwrap {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: 14px;
  overflow: hidden;
  background: #05070e;
}
.cc-camwrap video { width: 100%; height: 100%; object-fit: cover; display: block; }
.cc-camwrap.nocam video { display: none; }
.cc-camwrap.nocam::after {
  content: "📷"; position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 44px; opacity: .3;
}
.cc-camgrid {
  position: absolute; left: 50%; top: 50%;
  width: 68%; height: 68%;
  transform: translate(-50%, -50%);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  border: 2px solid rgba(255, 255, 255, .8);
  border-radius: 10px;
  pointer-events: none;
}
.cc-camgrid i { border: 1px dashed rgba(255, 255, 255, .35); }
.cc-scanchips { display: flex; gap: 4px; margin: 10px 0; min-height: 26px; flex-wrap: wrap; }
.cc-scanchip { width: 24px; height: 24px; border-radius: 6px; border: 1px solid rgba(255,255,255,.25); }
.cc-scanctl { display: flex; gap: 8px; flex-wrap: wrap; }
.cc-upload { position: relative; overflow: hidden; }
.cc-upload input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.cc-scanclose { position: absolute; top: 12px; right: 12px; padding: 8px 10px; }

/* ---- toast ---- */
.cc-toast {
  position: fixed; left: 50%; bottom: 26px; z-index: 70;
  transform: translate(-50%, 20px);
  max-width: min(480px, 88vw);
  background: #1a2032;
  color: #eef1f8;
  border: 1px solid rgba(110, 168, 255, .35);
  border-radius: 12px;
  padding: 12px 16px;
  font: 500 14px/1.45 "Rubik", -apple-system, "PingFang SC", sans-serif;
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s, transform .25s;
}
.cc-toast.on { opacity: 1; transform: translate(-50%, 0); }

/* ---- notation reference ---- */
.cc-notation { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 12px; margin-top: 14px; }
.cc-note-card {
  background: rgba(120, 138, 190, .08);
  border: 1px solid var(--cc-line);
  border-radius: 12px;
  padding: 12px;
  text-align: center;
}
.cc-note-card svg { width: 74px; height: 74px; }
.cc-note-card .nm { font: 700 16px "Rubik", sans-serif; color: var(--cc-ink); margin: 6px 0 2px; }
.cc-note-card .ds { font-size: 12px; color: var(--cc-dim); line-height: 1.4; }

/* ---- prose panels ---- */
.cc-panel {
  background: rgba(120, 138, 190, .07);
  border: 1px solid var(--cc-line);
  border-radius: 16px;
  padding: 18px 20px;
  margin-top: 26px;
}
.cc-panel h2 { margin-top: 0; }
.cc-panel ul { padding-left: 20px; }
.cc-panel li { margin: 6px 0; line-height: 1.55; }
.cc-cred { font-size: 12.5px; color: var(--cc-dim); margin-top: 26px; line-height: 1.6; }
.cc-cred a { color: #8fb4ff; }

/* ---- responsive ---- */
@media (max-width: 900px) {
  #cube-app {
    grid-template-columns: 1fr;
    grid-template-areas: "stage" "deck" "side";
  }
  .cc-stage { height: clamp(300px, 46vh, 420px); min-height: 300px; }
  .cc-actions .cc-btn { flex: 1 1 auto; text-align: center; }
  .cc-counter { display: none; }
}
@media (max-width: 480px) {
  .cc-btn { padding: 10px 10px; font-size: 13px; }
  .cc-net { padding: 5px; gap: 1px; }
}
.cc-fallback .cc-stage { height: auto; min-height: 120px; }
