/* LOOT RubikSolver — reusable component styles */

.rk-stage {
  position: relative;
  width: 100%;
  background: #ffffff;
  color: #111111;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  user-select: none;
  -webkit-user-select: none;
  outline: none;
  --rk-s: 54px;   /* 3D cubie size */
  --rk-t: 19px;   /* net sticker size */
}

@media (max-width: 600px) {
  .rk-stage { --rk-s: 44px; --rk-t: 14px; }
}

/* ---------------- top bar ---------------- */

.rk-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 2px 2px 14px;
}

.rk-btn {
  appearance: none;
  cursor: pointer;
  padding: 6px 12px;
  border-radius: 999px;
  background: #ffffff;
  color: #111111;
  border: 1.5px solid #111111;
  box-shadow: 0 2px 0 #111111;
  font: 700 11px ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  letter-spacing: 0.04em;
  transition: transform 0.1s;
}

.rk-btn:hover { transform: translateY(-1px); }
.rk-btn:active { transform: translateY(1px); box-shadow: 0 1px 0 #111111; }
.rk-btn:disabled { opacity: 0.35; cursor: default; transform: none; }

.rk-btn.rk-primary {
  background: #d21f33;
  border-color: #d21f33;
  color: #ffffff;
  box-shadow: 0 2px 0 #9c0f1c;
}

.rk-btn.rk-primary:active { box-shadow: 0 1px 0 #9c0f1c; }

.rk-btn.rk-play {
  background: #16a04c;
  border-color: #16a04c;
  color: #ffffff;
  box-shadow: 0 2px 0 #0d6b32;
}

.rk-btn.rk-play:active { box-shadow: 0 1px 0 #0d6b32; }

.rk-btn.rk-dark {
  background: #111111;
  border-color: #111111;
  color: #ffffff;
  box-shadow: 0 2px 0 #000000;
}

/* speed pills toggle dark when active */
.rk-btn.rk-on {
  background: #111111;
  border-color: #111111;
  color: #ffffff;
  box-shadow: 0 2px 0 #000000;
}

.rk-status {
  margin-left: auto;
  font: 700 10px ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  letter-spacing: 0.14em;
  white-space: nowrap;
}

.rk-status.rk-loading { color: #c9930a; }
.rk-status.rk-ready { color: #16a04c; }
.rk-status.rk-solving { color: #1f3a8f; }
.rk-status.rk-failed { color: #d21f33; }

/* ---------------- main row: net editor + 3D cube ---------------- */

.rk-main {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
}

.rk-left { flex: 0 0 auto; }

.rk-net {
  display: grid;
  grid-template-columns: repeat(12, var(--rk-t));
  grid-auto-rows: var(--rk-t);
  gap: 2px;
  width: fit-content;
}

.rk-st {
  appearance: none;
  padding: 0;
  border: 1.5px solid #111111;
  border-radius: 4px;
  background: #ffffff;
  cursor: pointer;
  transition: transform 0.08s;
}

.rk-st:hover { transform: scale(1.14); }
.rk-st.rk-center { cursor: default; }
.rk-st.rk-center:hover { transform: none; }

/* stickers that form impossible pieces */
.rk-st.rk-bad {
  position: relative;
  z-index: 1;
  box-shadow: 0 0 0 2.5px #d21f33;
  animation: rkBadPulse 0.85s ease-in-out infinite alternate;
}

@keyframes rkBadPulse {
  from { transform: scale(1); }
  to { transform: scale(1.22); }
}

.rk-note {
  margin-top: 10px;
  max-width: calc(var(--rk-t) * 12 + 22px);
  min-height: 28px;
  font: 600 10px/1.55 ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  letter-spacing: 0.02em;
  color: #1f3a8f;
}

.rk-note.rk-ok { color: #16a04c; }
.rk-note.rk-err { color: #d21f33; }

/* ---------------- 3D scene ---------------- */

.rk-scene {
  flex: 1 1 240px;
  min-width: 230px;
  height: calc(var(--rk-s) * 4.9);
  position: relative;
  overflow: hidden;
  perspective: 900px;
  border: 2px solid #111111;
  border-radius: 14px;
  box-shadow: 0 3px 0 #111111;
  background: #ffffff;
  cursor: grab;
  touch-action: none;   /* orbit drags never fight page scroll */
}

.rk-scene:active { cursor: grabbing; }

.rk-cube3d {
  position: absolute;
  left: 50%;
  top: 50%;
  transform-style: preserve-3d;
}

.rk-cubie {
  position: absolute;
  left: 0;
  top: 0;
  width: var(--rk-s);
  height: var(--rk-s);
  margin: calc(var(--rk-s) / -2);
  transform-style: preserve-3d;
  will-change: transform;
}

.rk-face {
  position: absolute;
  inset: 0;
  background: #111111;
  border-radius: 3px;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.rk-fs {
  position: absolute;
  inset: 2px;
  border-radius: 4px;
  background: #161616;   /* interior plastic; exterior stickers get inline colors */
}

/* fixed per-face shading stands in for lighting */
.rk-f-U .rk-fs { filter: brightness(1.04); }
.rk-f-L .rk-fs { filter: brightness(0.93); }
.rk-f-R .rk-fs { filter: brightness(0.85); }
.rk-f-B .rk-fs { filter: brightness(0.8); }
.rk-f-D .rk-fs { filter: brightness(0.72); }

/* ---------------- solution panel ---------------- */

.rk-sol {
  display: none;
  margin-top: 16px;
}

.rk-sol.rk-show { display: block; }

.rk-sol-head {
  font: 700 13px -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  margin-bottom: 9px;
}

.rk-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.rk-chip {
  font: 700 11px ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  padding: 4px 8px;
  border: 1.5px solid #111111;
  border-radius: 8px;
  background: #ffffff;
  min-width: 30px;
  text-align: center;
}

.rk-chip.rk-cur {
  background: #1f3a8f;
  border-color: #1f3a8f;
  color: #ffffff;
  box-shadow: 0 2px 0 #14265e;
}

.rk-chip.rk-done {
  border-color: #16a04c;
  color: #16a04c;
}

.rk-ctl {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.rk-move {
  font: 600 11px ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  letter-spacing: 0.02em;
}

.rk-speed {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
}

.rk-speed-label {
  font: 700 10px ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  letter-spacing: 0.14em;
}

.rk-tip {
  margin-top: 8px;
  font: 600 9.5px ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  letter-spacing: 0.04em;
  color: #1f3a8f;
}

/* ---------------- camera scan overlay ---------------- */

/* the overlay replaces the card UI while scanning (also hides hard shadows
   that poke past the stage bounds) */
.rk-stage.rk-scanning .rk-bar,
.rk-stage.rk-scanning .rk-main,
.rk-stage.rk-scanning .rk-sol { visibility: hidden; }

.rk-scan {
  position: absolute;
  inset: 0;
  z-index: 50;
  background: #ffffff;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.rk-scan-step {
  font: 700 10px ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  letter-spacing: 0.14em;
  color: #c9930a;
}

.rk-scan-head {
  font: 700 13px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: #111111;
  min-height: 36px;
}

/* per-shot verdict: error blocks the step, green confirms it */
.rk-scan-err {
  min-height: 16px;
  font: 700 10px/1.5 ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  letter-spacing: 0.04em;
  color: #d21f33;
}

.rk-scan-err.rk-good { color: #16a04c; }

.rk-scan-view {
  position: relative;
  flex: 1;
  min-height: 200px;
  background: #111111;
  border: 2px solid #111111;
  border-radius: 14px;
  box-shadow: 0 3px 0 #111111;
  overflow: hidden;
}

.rk-scan-video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.rk-scan-msg {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 0 26px;
  color: #f2c40f;
  font: 700 11px/1.6 ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  letter-spacing: 0.04em;
  pointer-events: none;
}

.rk-grid {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  border: 2px solid #ffffff;
  border-radius: 8px;
  box-shadow: 0 0 0 1px rgba(17, 17, 17, 0.5), inset 0 0 0 1px rgba(17, 17, 17, 0.5);
  pointer-events: none;
}

.rk-gl {
  position: absolute;
  background: #ffffff;
  box-shadow: 0 0 0 0.5px rgba(17, 17, 17, 0.5);
}

.rk-gl-v1 { left: 33.33%; top: 0; bottom: 0; width: 2px; }
.rk-gl-v2 { left: 66.66%; top: 0; bottom: 0; width: 2px; }
.rk-gl-h1 { top: 33.33%; left: 0; right: 0; height: 2px; }
.rk-gl-h2 { top: 66.66%; left: 0; right: 0; height: 2px; }

/* raw colors read from the last shot */
.rk-scan-swatches {
  position: absolute;
  right: 10px;
  bottom: 10px;
  display: grid;
  grid-template-columns: repeat(3, 15px);
  grid-auto-rows: 15px;
  gap: 2px;
}

.rk-sw {
  border: 1.5px solid #111111;
  border-radius: 3px;
  background: #ffffff;
}

.rk-scan-ctl {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
