/* Page chrome for the Rubik's Cube solver + hub pages.
   Mobile-first: base rules target small screens, larger layouts are added
   in min-width media queries. src/render.js computes cubie spacing in
   fixed pixels (see styles/cube.css), so the cube scene is scaled down
   with a plain transform rather than by overriding --cubie-size. */

:root {
  --bg: #f5f7ff;
  --surface: #ffffff;
  --border: #cdd1f0;
  --text: #0f0f2e;
  --muted: #5a5f7a;
  --accent: #6366f1;
  --accent-h: #4f46e5;
  --accent-bg: #eef2ff;
  --accent-fg: #3730a3;
  --radius: 10px;
  --radius-lg: 14px;
  --shadow: 0 1px 3px rgba(20, 21, 46, 0.08);
  --shadow-lg: 0 8px 24px rgba(20, 21, 46, 0.12);
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}

a { color: var(--accent-h); }

a:focus-visible,
.nav-link:focus-visible,
.hub-card:focus-visible,
.related-tool-card:focus-visible {
  outline: 2px solid var(--accent-h);
  outline-offset: 2px;
  border-radius: var(--radius);
}

h1, h2, h3 { line-height: 1.25; }

main {
  max-width: 1000px;
  margin: 0 auto;
  padding: 0 16px 48px;
}

/* --- header --- */

.site-header {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  padding: 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.site-logo {
  font-weight: 800;
  font-size: 1.05rem;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -0.01em;
}

.site-logo span { color: var(--accent-h); }

.site-nav {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-left: auto;
}

.nav-link {
  padding: 6px 12px;
  border-radius: var(--radius);
  border: 1.5px solid var(--border);
  color: var(--text);
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 600;
}

.nav-link:hover,
.nav-link.active {
  background: var(--accent-h);
  border-color: var(--accent-h);
  color: #fff;
}

/* --- hero --- */

.hero {
  max-width: 640px;
  margin: 32px auto 24px;
  text-align: center;
}

.hero h1 {
  font-size: 1.8rem;
  font-weight: 800;
  margin: 0 0 10px;
}

.subtitle {
  color: var(--muted);
  margin: 0;
}

/* --- solver panel layout (mobile-first: single column) --- */

.solver-panel {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
  margin-bottom: 40px;
}

.cube-column,
.solution-column {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

@media (min-width: 760px) {
  .solver-panel {
    grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr);
    align-items: start;
  }
}

/* --- cube stage ---
   mountCube() renders the 3D scene into #cube-root, and attachInput()
   then appends a face-button bar and a color-legend as further children
   of the same container. This wrapper stacks all three vertically. */

.cube-stage {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 0 16px;
}

/* Scale the 3D scene down on narrow viewports so the stage takes less
   vertical space, without ever clipping it: the reduced min-height is
   sized to comfortably fit the already-scaled cube, so overflow is left
   at its default (visible) and nothing gets cut off. render.js's cubie
   translate3d offsets are fixed px, so the scene is scaled with a
   transform rather than by overriding --cubie-size (which would only
   resize the sticker boxes, not the spacing between them). */
@media (max-width: 480px) {
  .cube-stage .scene {
    min-height: 190px;
    transform: scale(0.6);
  }
}

@media (min-width: 481px) and (max-width: 759px) {
  .cube-stage .scene {
    min-height: 250px;
    transform: scale(0.78);
  }
}

/* --- toolbar + buttons --- */

.toolbar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}

.btn {
  font: inherit;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text);
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 16px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s, opacity 0.15s;
}

.btn:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent-h);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent-h);
  border-color: var(--accent-h);
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: #453ed1;
  color: #fff;
}

/* --- status banner --- */

.status-banner {
  min-height: 1.4em;
  padding: 10px 14px;
  border-radius: var(--radius);
  background: var(--accent-bg);
  color: var(--accent-fg);
  font-size: 0.9rem;
  font-weight: 600;
}

.status-banner:empty { display: none; }

.status-banner.status-error {
  background: #fdecec;
  color: #b42318;
}

.status-banner.status-success {
  background: #e7f8ef;
  color: #14804a;
}

.noscript-banner {
  max-width: 640px;
  margin: 0 auto 20px;
  padding: 12px 16px;
  border-radius: var(--radius);
  background: #fdecec;
  color: #b42318;
  font-size: 0.9rem;
  font-weight: 600;
  text-align: center;
}

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

.solution-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 18px;
}

.solution-panel h2 {
  margin: 0 0 12px;
  font-size: 1.05rem;
}

.playback-controls {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 12px;
}

.speed-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
  color: var(--muted);
  margin-left: auto;
}

.move-list {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  min-height: 32px;
  max-height: 200px;
  overflow-y: auto;
  font-family: "SFMono-Regular", ui-monospace, Menlo, monospace;
  font-size: 0.85rem;
}

.move-chip {
  padding: 3px 8px;
  border-radius: 6px;
  background: var(--accent-bg);
  color: var(--accent-fg);
}

.move-chip.done {
  background: var(--border);
  color: var(--muted);
}

.move-chip.current {
  background: var(--accent-h);
  color: #fff;
}

/* --- how-to + faq --- */

.howto,
.faq {
  max-width: 720px;
  margin: 0 auto 32px;
}

.howto h2,
.faq h2 {
  font-size: 1.3rem;
  margin: 0 0 14px;
}

.howto ol {
  margin: 0;
  padding-left: 1.2em;
  color: var(--text);
}

.howto li {
  margin-bottom: 8px;
}

.faq-item {
  border-top: 1px solid var(--border);
  padding: 16px 0;
}

.faq-item:first-of-type {
  border-top: none;
}

.faq-item h3 {
  font-size: 1rem;
  margin: 0 0 6px;
}

.faq-item p {
  margin: 0;
  color: var(--muted);
}

/* --- footer --- */

.page-footer {
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
  padding: 24px 16px 40px;
}

.page-footer nav a {
  color: var(--muted);
}

.page-footer nav a:hover {
  color: var(--accent-h);
}

/* --- hub page cards (index.html) --- */

.hub-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  margin-bottom: 24px;
}

@media (min-width: 620px) {
  .hub-grid { grid-template-columns: repeat(2, 1fr); }
}

.hub-card {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 22px;
  text-decoration: none;
  color: var(--text);
  transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
}

.hub-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
  border-color: var(--accent);
}

.hub-tag {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--accent-fg);
  background: var(--accent-bg);
  padding: 3px 9px;
  border-radius: 999px;
  margin-bottom: 10px;
}

.hub-card h2 {
  font-size: 1.15rem;
  margin: 0 0 6px;
}

.hub-card p {
  color: var(--muted);
  font-size: 0.9rem;
  margin: 0 0 10px;
}

.hub-open {
  font-weight: 700;
  color: var(--accent-h);
  font-size: 0.88rem;
}

.hub-note {
  color: var(--muted);
  font-size: 0.88rem;
  text-align: center;
  margin: 0 0 32px;
}

.section {
  max-width: 720px;
  margin: 0 auto 32px;
}

.section h2 {
  font-size: 1.2rem;
  margin: 0 0 10px;
}

.section p {
  color: var(--muted);
  margin: 0;
}

.related-tools {
  max-width: 900px;
  margin: 0 auto 32px;
}

.related-tools h2 {
  font-size: 1.2rem;
  margin: 0 0 16px;
}

.related-tools-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

@media (min-width: 560px) {
  .related-tools-grid { grid-template-columns: repeat(2, 1fr); }
}

.related-tool-card {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  box-shadow: var(--shadow);
  text-decoration: none;
  transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
}

.related-tool-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
  border-color: var(--accent);
}

.related-tool-card h3 {
  font-size: 0.95rem;
  margin: 0 0 6px;
  color: var(--text);
}

.related-tool-card p {
  font-size: 0.85rem;
  color: var(--muted);
  margin: 0;
}

.related-tool-card .rc-arrow {
  flex-shrink: 0;
  color: var(--accent-h);
  font-size: 1.1rem;
}
