/* ==========================================================================
   CUBE — Rubik's Cube for Meta Display Glasses (600x600 additive waveguide)
   Black (#000) is transparent on-glass. UI surfaces use dark grays so they
   read as opaque. White/high-contrast for legibility. Cyan = focus.
   ========================================================================== */

:root {
  --bg:            #000000;   /* transparent on the additive display */
  --surface:       #0a0a0f;   /* faintly visible UI surface */
  --surface-2:     #14141f;
  --surface-3:     #1c1e21;
  --text:          #ffffff;
  --text-2:        #e4e6eb;
  --text-muted:    #b0b3b8;
  --accent:        #00e5ff;   /* focus / active cyan */
  --accent-dim:    rgba(0, 229, 255, 0.35);
  --gold:          #ffd166;
  --danger:        #ff4466;

  --safe:          8px;

  /* Animation curves from the display guidelines */
  --focus-on:  475ms cubic-bezier(0.6, 0, 0.4, 1);
  --focus-off: 625ms cubic-bezier(0.24, 0.24, 0.6, 1);
  --color-on:  300ms cubic-bezier(0.4, 0.04, 0.5, 1);
  --press:     100ms cubic-bezier(0.68, 0, 0.29, 1);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  width: 600px;
  height: 600px;
  overflow: hidden;
  background: var(--bg);            /* transparent on-glass */
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  user-select: none;
  -webkit-user-select: none;
}

#app {
  position: relative;
  width: 600px;
  height: 600px;
}

/* ==================== SCREENS ==================== */
.screen {
  position: absolute;
  inset: 0;
  width: 600px;
  height: 600px;
  padding: var(--safe);
  display: flex;
  flex-direction: column;
}
.screen.hidden { display: none; }
.hidden { display: none !important; }

/* ==================== HEADER ==================== */
.header {
  display: flex;
  align-items: center;
  gap: 16px;
  height: 64px;
  padding: 0 16px;
  flex-shrink: 0;
}
.header h1 {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: 0.5px;
}
.header-meta {
  margin-left: auto;
  font-size: 14px;
  color: var(--text-muted);
}

.back-btn {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  background: var(--surface-3);
  color: var(--text);
  border: 2px solid transparent;
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
}

/* ==================== CONTENT ==================== */
.content {
  flex: 1;
  min-height: 0;
  padding: 8px 16px;
  display: flex;
  flex-direction: column;
}
.list-container {
  overflow-y: auto;
  gap: 12px;
}

/* ==================== NAV BAR ==================== */
.nav-bar {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 8px 16px 12px;
  flex-shrink: 0;
}
.nav-item {
  height: 88px;                 /* mandated tap target */
  border-radius: 20px;
  background: var(--surface-3);
  color: var(--text);
  border: 2px solid transparent;
  font-size: 20px;
  font-weight: 600;
  cursor: pointer;
}
.nav-item.primary {
  background: linear-gradient(135deg, #0a2a30, #0a1418);
  border-color: var(--accent-dim);
  color: var(--accent);
}

/* ==================== FOCUS STATES ==================== */
/* Container scales on focus; content legibility preserved. Cyan glow ring. */
.focusable {
  outline: none;
  transition:
    transform var(--focus-on),
    box-shadow var(--color-on),
    border-color var(--color-on),
    background var(--color-on);
}
.focusable:focus,
.focusable:focus-visible {
  border-color: var(--accent);
  box-shadow:
    0 0 0 2px var(--accent),
    0 0 18px var(--accent-dim);
  transform: scale(0.955);       /* -8dp on an 88dp target */
}
.focusable:active {
  transition: transform var(--press);
  transform: scale(0.93);
}

/* ==================== HOME ==================== */
.home-content {
  align-items: center;
  justify-content: center;
  gap: 28px;
}
.cube-mark {
  position: relative;
  width: 132px;
  height: 132px;
  transform: rotateX(-24deg) rotateY(-32deg);
  transform-style: preserve-3d;
}
.mark-face {
  position: absolute;
  border-radius: 12px;
}
/* Mini cube mark — mirrors the in-game palette: white top, red left, steel-blue right. */
.mark-face.f0 { /* top */
  inset: 0 0 auto 0; height: 66px;
  background: linear-gradient(135deg, #ffffff, #dfe5e8);
  transform: skewX(-32deg) translateX(18px);
  opacity: 0.92;
}
.mark-face.f1 { /* left */
  inset: 40px auto 0 0; width: 66px;
  background: linear-gradient(160deg, #e6604e, #c9432f);
  transform: skewY(-32deg) translateY(12px);
  opacity: 0.92;
}
.mark-face.f2 { /* right */
  inset: 40px 0 0 auto; width: 66px;
  background: linear-gradient(200deg, #6b9cb8, #4a7791);
  transform: skewY(32deg) translateY(12px);
  opacity: 0.92;
}
.tagline {
  text-align: center;
  font-size: 20px;
  font-weight: 600;
  line-height: 1.5;
}
.tagline .dim { color: var(--text-muted); font-size: 15px; font-weight: 400; }

/* ==================== GAME SCREEN ==================== */
#game { padding: 0; }
#cube-canvas {
  position: absolute;
  inset: 0;
  width: 600px;
  height: 600px;
  display: block;
}

/* HUD overlay (non-interactive, sits above canvas) */
.hud {
  position: absolute;
  inset: 0;
  padding: var(--safe);
  pointer-events: none;
  display: flex;
  flex-direction: column;
}
.hud-top {
  display: flex;
  gap: 10px;
  padding: 12px 16px;
}
.hud-chip {
  background: rgba(20, 20, 31, 0.82);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 14px;
  padding: 8px 14px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-2);
}
.solved-chip {
  color: #0a1418;
  background: var(--accent);
  border-color: var(--accent);
}

/* ---- Rotation arrow buttons framing the cube ---- */
.rot-arrow {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  font-size: 24px;
  color: var(--text-2);
  background: rgba(10, 10, 15, 0.6);
  border: 1.5px solid rgba(255,255,255,0.14);
  border-radius: 16px;
  pointer-events: none; /* purely indicators; the D-pad drives them */
}
.rot-up    { top: 84px;  left: 50%; transform: translateX(-50%); }
.rot-down  { bottom: 132px; left: 50%; transform: translateX(-50%); }
.rot-left  { left: 16px; top: 50%; transform: translateY(-50%); }
.rot-right { right: 16px; top: 50%; transform: translateY(-50%); }
/* The framing arrows only mean "rotate the cube" — fade them out while a
   slice mode is active (arrows then pick/turn the highlighted slice). */
.rot-arrow { transition: opacity var(--color-on); }
.hud[data-mode="row"] .rot-arrow,
.hud[data-mode="col"] .rot-arrow { opacity: 0; }
/* Flash cyan when the matching direction is pressed. */
.rot-arrow.flash {
  animation: rotFlash 360ms ease-out;
}
@keyframes rotFlash {
  0%   { color: #0a1418; background: var(--accent); border-color: var(--accent);
         box-shadow: 0 0 22px var(--accent-dim); transform-origin: center; }
  100% { color: var(--text-2); background: rgba(10,10,15,0.6);
         border-color: rgba(255,255,255,0.14); box-shadow: none; }
}
.rot-up.flash    { animation-name: rotFlashX; }
.rot-down.flash  { animation-name: rotFlashX; }
/* keep the translate offset while flashing (X-centered arrows) */
@keyframes rotFlashX {
  0%   { color: #0a1418; background: var(--accent); border-color: var(--accent); box-shadow: 0 0 22px var(--accent-dim); }
  100% { color: var(--text-2); background: rgba(10,10,15,0.6); border-color: rgba(255,255,255,0.14); box-shadow: none; }
}

/* Armed-slice readout */
.selector-readout {
  position: absolute;
  bottom: 78px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(10, 10, 15, 0.88);
  border: 1.5px solid var(--accent-dim);
  border-radius: 18px;
  padding: 10px 18px;
  box-shadow: 0 0 18px rgba(0,229,255,0.15);
}
.sel-mode {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 1px;
  color: #0a1418;
  background: var(--accent);
  border-radius: 8px;
  padding: 3px 8px;
  transition: background var(--color-on), color var(--color-on);
}
/* MOVE (whole-cube) mode reads neutral; TURN modes read cyan/active. */
.hud[data-mode="cube"] .sel-mode {
  background: var(--surface-3);
  color: var(--text-2);
}
.sel-layer {
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
}
/* brief pop when the armed slice changes (Select) */
.selector-readout.pulse { animation: selPulse 260ms ease-out; }
@keyframes selPulse {
  0%   { box-shadow: 0 0 26px var(--accent); border-color: var(--accent); }
  100% { box-shadow: 0 0 18px rgba(0,229,255,0.15); border-color: var(--accent-dim); }
}

.hud-hint {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 7px 16px;
  font-size: 12.5px;
  color: var(--text-muted);
  background: rgba(10,10,15,0.6);
  border-radius: 14px;
  text-align: center;
  white-space: nowrap;
}
.hud-hint b { color: var(--text-2); font-weight: 700; }

/* Invisible focus surface that captures the D-pad while playing */
.play-surface {
  position: absolute;
  inset: 0;
  width: 600px;
  height: 600px;
  background: transparent;
  border: none;
  cursor: default;
  /* no visible focus ring — the cube's own highlight is the indicator */
}
.play-surface:focus,
.play-surface:focus-visible {
  outline: none;
  box-shadow: none;
  transform: none;
  border: none;
}

/* ==================== MENUS / OVERLAYS ==================== */
.game-menu,
.solved-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.55);
  padding: var(--safe);
  z-index: 20;
}
.menu-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface-2);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 28px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.menu-card h2 {
  font-size: 24px;
  font-weight: 700;
  text-align: center;
  margin-bottom: 6px;
}
.menu-item {
  height: 72px;
  border-radius: 18px;
  background: var(--surface-3);
  color: var(--text);
  border: 2px solid transparent;
  font-size: 18px;
  font-weight: 600;
  cursor: pointer;
}
.menu-item.primary {
  background: linear-gradient(135deg, #0a2a30, #0a1418);
  border-color: var(--accent-dim);
  color: var(--accent);
}
.win-title {
  color: var(--accent);
  font-size: 30px;
}
.win-stats {
  text-align: center;
  color: var(--text-muted);
  font-size: 16px;
  margin-bottom: 8px;
}

/* ==================== HOW TO / STATS ==================== */
.howto-section {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 6px 4px 2px;
}
.howto-row {
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--surface);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 16px;
  padding: 14px 16px;
}
.howto-row.highlight-row {
  border-color: var(--accent-dim);
  background: linear-gradient(135deg, #0a2a30, #0a1418);
}
.howto-key {
  flex-shrink: 0;
  min-width: 78px;
  text-align: center;
  font-size: 17px;
  font-weight: 700;
  color: var(--accent);
}
.howto-desc { font-size: 15px; color: var(--text-2); line-height: 1.4; }
.howto-desc b { color: var(--text); }
.howto-note {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.5;
  padding: 12px 4px;
}

.stat-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 16px;
  padding: 16px 18px;
}
.stat-label { font-size: 15px; color: var(--text-muted); }
.stat-value { font-size: 20px; font-weight: 700; color: var(--text); }
.stat-value.accent { color: var(--accent); }
.empty-state {
  text-align: center;
  color: var(--text-muted);
  font-size: 15px;
  padding: 40px 20px;
}

/* Scrim for scroll containers */
.list-container::after {
  content: '';
  position: absolute;
  bottom: 96px; left: 0; right: 0;
  height: 40px;
  background: linear-gradient(to top, var(--bg) 0%, transparent 100%);
  pointer-events: none;
}
