@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Poppins:wght@600;700;800&display=swap');

:root {
  --bg: #f5f5f4;
  --panel: #ffffff;
  --panel-2: #fafafa;
  --border: #e2e2df;
  --text: #1c1c1a;
  --muted: #6b6b66;
  --muted-2: #9a9a94;

  /* Rubik's cube palette - used only for the literal cube visuals (3D cube, color picker) */
  --cube-white: #f8f9fa;
  --cube-yellow: #ffd500;
  --cube-red: #e8291c;
  --cube-orange: #ff8c00;
  --cube-blue: #0051ba;
  --cube-green: #00a552;

  /* site accent system: one accent color, used consistently */
  --accent: #2f5d50;
  --accent-hover: #244a40;
  --accent-soft: #e8efec;

  --error-bg: #fdf2f2;
  --error-border: #f2d5d5;
  --error-text: #9a3232;
  --ok-bg: #eff4f0;
  --ok-border: #cfdfd3;
  --ok-text: #2f5d50;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 2px rgba(28, 28, 26, 0.06);
  --shadow-md: 0 4px 12px rgba(28, 28, 26, 0.08);
  --shadow-lg: 0 8px 24px rgba(28, 28, 26, 0.1);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  overflow-x: hidden;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { font-family: 'Poppins', 'Inter', sans-serif; letter-spacing: -0.01em; }

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

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
}

header {
  padding: 28px 20px 14px;
  text-align: center;
}
header h1 { margin: 0 0 6px; font-size: 1.9rem; }
.subtitle { color: var(--muted); margin: 0; }

main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 20px 70px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

section {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px 24px;
  box-shadow: var(--shadow-sm);
}
section h2 { margin-top: 0; font-size: 1.2rem; }
.hint { color: var(--muted); font-size: 0.92rem; margin-top: -6px; }

/* ---------- pill selector groups (puzzle type, algo filters) ---------- */

.puzzle-selector, .algo-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.puzzle-btn, .algo-filter-btn {
  padding: 9px 16px;
  border-radius: 999px;
  border: 1.5px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  cursor: pointer;
  font-size: 0.92rem;
  font-weight: 500;
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease, color 0.15s ease;
}
.puzzle-btn:hover, .algo-filter-btn:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}
.puzzle-btn.selected, .algo-filter-btn.selected {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.palette {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 16px;
}
.swatch {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-sm);
  border: 2px solid rgba(23, 25, 35, 0.1);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.swatch:hover { transform: translateY(-2px); }
.swatch.selected {
  border-color: var(--text);
  box-shadow: 0 0 0 3px var(--accent-soft);
  transform: scale(1.06);
}

.net-container {
  display: flex;
  justify-content: center;
  padding: 10px 0 4px;
  overflow: visible;
}

.puzzle3d-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: 100%;
}

.drag-hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
  text-align: center;
  user-select: none;
}

/* ---------- cube family + pyraminx: real WebGL (Three.js) scenes ---------- */

.three-canvas-host {
  display: flex;
  justify-content: center;
  touch-action: none;
}
.three-canvas-host canvas {
  cursor: grab;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
}
.three-canvas-host canvas:active {
  cursor: grabbing;
}

.actions {
  margin-top: 18px;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}
.primary-btn, .secondary-btn {
  padding: 11px 22px;
  border-radius: 999px;
  border: 1.5px solid transparent;
  font-size: 1rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.primary-btn {
  background: var(--accent);
  color: white;
}
.primary-btn:hover { background: var(--accent-hover); }
.primary-btn:active { transform: translateY(1px); }
.primary-btn:disabled {
  background: var(--muted-2);
  cursor: not-allowed;
  transform: none;
}
.secondary-btn {
  background: var(--panel);
  border-color: var(--border);
  color: var(--text);
}
.secondary-btn:hover { border-color: var(--accent); color: var(--accent); }

.note {
  margin-top: 10px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  background: #fffbeb;
  border: 1px solid #fde68a;
  color: #92400e;
}

#validation-messages { margin-top: 14px; }
.error-box, .ok-box {
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 0.95rem;
}
.error-box {
  background: var(--error-bg);
  border: 1px solid var(--error-border);
  color: var(--error-text);
}
.error-box ul { margin: 6px 0 0; padding-left: 20px; }
.ok-box {
  background: var(--ok-bg);
  border: 1px solid var(--ok-border);
  color: var(--ok-text);
}

#results-section:empty { display: none; }
.stage {
  border-top: 1px solid var(--border);
  padding: 14px 0;
}
.stage:first-of-type { border-top: none; }
.stage h3 { margin: 0 0 4px; font-size: 1.02rem; }
.stage-desc { color: var(--muted); margin: 0 0 8px; font-size: 0.92rem; }
.stage-moves { margin: 0; }
.move {
  display: inline-block;
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 3px 9px;
  margin: 2px 2px 0 0;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-weight: 700;
}

/* ---------- animated step-by-step cube solve player ---------- */

.cube-player {
  display: flex;
  gap: 22px;
  align-items: flex-start;
  flex-wrap: wrap;
}
.player-stage {
  flex: 1 1 340px;
  min-width: 280px;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.player-3d-mount { width: 100%; display: flex; justify-content: center; }
.player-controls {
  margin-top: 10px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}
.player-controls .primary-btn,
.player-controls .secondary-btn {
  padding: 8px 14px;
  font-size: 0.9rem;
}
.player-controls button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.player-progress {
  margin: 12px 0 2px;
  font-weight: 600;
  text-align: center;
}
.player-current-move {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  text-align: center;
  min-height: 1.4em;
}

.player-steps {
  flex: 1 1 300px;
  min-width: 260px;
  max-height: 520px;
  overflow-y: auto;
  border-left: 1px solid var(--border);
  padding-left: 20px;
}
.player-stage-block {
  border-radius: var(--radius-sm);
  padding: 10px 10px 12px;
  margin-bottom: 4px;
  transition: background 0.15s ease;
}
.player-stage-block.current { background: var(--accent-soft); }
.player-stage-block h4 { margin: 0 0 4px; font-size: 0.96rem; }
.player-move-list { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 6px; }
.player-move-badge {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-weight: 700;
  font-size: 0.88rem;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  border-radius: 6px;
  padding: 3px 9px;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.player-move-badge:hover { border-color: var(--accent); }
.player-move-badge.done { background: var(--ok-bg); border-color: var(--ok-border); color: var(--ok-text); }
.player-move-badge.current { background: var(--accent); border-color: var(--accent); color: #fff; }

@media (max-width: 720px) {
  .player-steps {
    border-left: none;
    border-top: 1px solid var(--border);
    padding-left: 0;
    padding-top: 16px;
    max-height: 360px;
  }
}

/* ---------- site-wide header / nav / footer (js/ui/layout.js) ---------- */

.site-header-bar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(255, 255, 255, 0.78);
  backdrop-filter: blur(12px) saturate(160%);
  -webkit-backdrop-filter: blur(12px) saturate(160%);
  border-bottom: 1px solid var(--border);
}

.site-header-inner {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding: 12px 20px;
}

.site-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: 'Poppins', sans-serif;
  font-weight: 800;
  font-size: 1.2rem;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -0.02em;
}
.brand-cube {
  display: block;
  width: 30px;
  height: 30px;
  transition: transform 0.4s ease;
}
.site-brand:hover .brand-cube { transform: rotate(18deg) scale(1.08); }

.site-nav-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  background: var(--panel);
  cursor: pointer;
  flex-direction: column;
  gap: 4px;
}
.site-nav-toggle span {
  display: block;
  width: 18px;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
  transition: transform 0.2s ease, opacity 0.2s ease;
}
.site-nav-toggle.open span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.site-nav-toggle.open span:nth-child(2) { opacity: 0; }
.site-nav-toggle.open span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

.site-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.site-nav-link {
  padding: 7px 14px;
  border-radius: 999px;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.95rem;
  font-weight: 500;
  transition: background 0.15s ease, color 0.15s ease;
}
.site-nav-link:hover { background: var(--accent-soft); color: var(--text); }
.site-nav-link.selected {
  background: var(--accent);
  color: white;
}

@media (max-width: 720px) {
  .site-nav-toggle { display: inline-flex; }
  .site-nav {
    order: 3;
    flex-basis: 100%;
    flex-direction: column;
    gap: 2px;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.25s ease;
  }
  .site-nav.open { max-height: 400px; padding-top: 6px; }
  .site-nav-link { padding: 10px 14px; }
}

#site-footer {
  margin-top: 40px;
  background: var(--text);
}
.site-footer-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 34px 20px 28px;
  text-align: center;
  color: #b5b5b0;
  font-size: 0.85rem;
}
.site-footer-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 18px;
  margin-bottom: 16px;
}
.site-footer-nav a { color: #e4e4e0; text-decoration: none; font-weight: 500; }
.site-footer-nav a:hover { color: #ffffff; text-decoration: underline; }
.site-footer-desc { max-width: 640px; margin: 0 auto 10px; }
.site-footer-legal { margin: 0; color: #85857e; }

/* ---------- ad slots (ads/adsterra.js) ---------- */

.ad-slot {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 16px 0;
  overflow: hidden;
}
.ad-slot-banner { min-height: 90px; }
.ad-slot-native-banner { min-height: 250px; }

/* ---------- home page hero + feature cards ---------- */

.hero {
  width: 100vw;
  margin-left: 50%;
  transform: translateX(-50%);
  padding: 72px 28px;
  margin-top: 0;
  margin-bottom: 24px;
  background: url('/content/hero-bg.svg') center/cover no-repeat, linear-gradient(135deg, #16302a, #0a1512);
  border: none;
  border-radius: 0;
  color: #fff;
}
.hero-inner {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 48px;
  flex-wrap: wrap;
  text-align: center;
}
.hero-text { max-width: 600px; }
.hero-eyebrow {
  display: inline-block;
  padding: 5px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: #fff;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  margin-bottom: 16px;
}
.hero h1 { margin: 0 0 12px; font-size: 2.5rem; line-height: 1.15; color: #fff; }
.grad-text { color: #7fd9b8; }
.hero p { color: rgba(255, 255, 255, 0.78); max-width: 560px; margin: 0 auto; font-size: 1.05rem; }
.hero-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-top: 22px;
  flex-wrap: wrap;
}
.hero-actions .secondary-btn {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.3);
  color: #fff;
}
.hero-actions .secondary-btn:hover { border-color: #fff; color: #fff; background: rgba(255, 255, 255, 0.12); }

/* decorative spinning CSS 3D cube */
.hero-cube { flex-shrink: 0; }
.cube3d-scene {
  width: 130px;
  height: 130px;
  perspective: 1000px;
  filter: drop-shadow(0 20px 18px rgba(0, 0, 0, 0.4));
}
.cube3d {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  animation: cube3d-spin 18s linear infinite;
}
@keyframes cube3d-spin {
  from { transform: rotateX(-24deg) rotateY(0deg); }
  to { transform: rotateX(-24deg) rotateY(360deg); }
}
.cube3d-face {
  position: absolute;
  inset: 0;
  border-radius: 14px;
  box-shadow: inset 0 0 0 3px rgba(0, 0, 0, 0.2);
  background-image:
    radial-gradient(130% 100% at 26% 16%, rgba(255, 255, 255, 0.32), rgba(255, 255, 255, 0) 55%),
    repeating-linear-gradient(to right, rgba(0, 0, 0, 0.26) 0 2px, transparent 2px 43.33px),
    repeating-linear-gradient(to bottom, rgba(0, 0, 0, 0.26) 0 2px, transparent 2px 43.33px);
}
.cube3d-front  { background-color: var(--cube-red);    transform: translateZ(65px); }
.cube3d-back   { background-color: var(--cube-orange); transform: rotateY(180deg) translateZ(65px); filter: brightness(0.82); }
.cube3d-right  { background-color: var(--cube-blue);   transform: rotateY(90deg) translateZ(65px); filter: brightness(0.9); }
.cube3d-left   { background-color: var(--cube-green);  transform: rotateY(-90deg) translateZ(65px); filter: brightness(0.9); }
.cube3d-top    { background-color: var(--cube-white);  transform: rotateX(90deg) translateZ(65px); }
.cube3d-bottom { background-color: var(--cube-yellow); transform: rotateX(-90deg) translateZ(65px); filter: brightness(0.85); }

@media (max-width: 720px) {
  .hero h1 { font-size: 2rem; }
  .cube3d-scene { width: 96px; height: 96px; }
  .cube3d-front, .cube3d-back, .cube3d-right, .cube3d-left, .cube3d-top, .cube3d-bottom { transform-origin: center; }
  .cube3d-front  { transform: translateZ(48px); }
  .cube3d-back   { transform: rotateY(180deg) translateZ(48px); }
  .cube3d-right  { transform: rotateY(90deg) translateZ(48px); }
  .cube3d-left   { transform: rotateY(-90deg) translateZ(48px); }
  .cube3d-top    { transform: rotateX(90deg) translateZ(48px); }
  .cube3d-bottom { transform: rotateX(-90deg) translateZ(48px); }
}

.feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 18px;
}
.feature-card {
  display: block;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px 22px 20px;
  text-decoration: none;
  color: inherit;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.2s ease, border-color 0.2s ease;
}
.feature-card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--muted-2);
}
.feature-card h3 { margin: 0 0 6px; font-size: 1.08rem; color: var(--text); }
.feature-card p { margin: 0; color: var(--muted); font-size: 0.92rem; }
.feature-card .badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 999px;
  padding: 4px 10px;
  margin-bottom: 10px;
}

/* ---------- long-form content (tutorials, history, blog posts) ---------- */

.prose { max-width: 720px; margin: 0 auto; }
.prose h2 { margin-top: 30px; font-size: 1.3rem; }
.prose h2:first-child { margin-top: 0; }
.prose h3 { margin-top: 22px; font-size: 1.08rem; }
.prose p { margin: 12px 0; }
.prose ul, .prose ol { padding-left: 22px; margin: 12px 0; }
.prose li { margin: 5px 0; }
.prose a { text-decoration-color: var(--muted-2); text-underline-offset: 2px; }
.prose a:hover { text-decoration-color: var(--accent); }
.prose .move {
  display: inline-block;
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 3px 9px;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-weight: 700;
}
.page-meta { color: var(--muted); font-size: 0.85rem; margin: -8px 0 8px; }

/* ---------- FAQ (details/summary, also used for FAQPage schema) ---------- */

.faq { max-width: 720px; margin: 28px auto 0; }
.faq h2 { margin: 0 0 14px; font-size: 1.3rem; }
.faq details {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 18px;
  margin-bottom: 10px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.faq details:hover { border-color: var(--accent); box-shadow: var(--shadow-sm); }
.faq summary {
  cursor: pointer;
  font-weight: 600;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 10px;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::before {
  content: '+';
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700;
  transition: transform 0.2s ease, background 0.2s ease, color 0.2s ease;
}
.faq details[open] summary::before {
  content: '\2212';
  background: var(--accent);
  color: white;
  transform: rotate(180deg);
}
.faq details p { margin: 10px 0 2px; color: var(--text); padding-left: 32px; }

/* ---------- algorithm library ---------- */

.algo-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.algo-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  background: var(--panel);
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.15s ease, border-color 0.15s ease;
}
.algo-card:hover { box-shadow: var(--shadow-md); border-color: var(--muted-2); }
.algo-card h3 { margin: 0 0 4px; font-size: 1.02rem; }
.algo-card .algo-meta { color: var(--muted); font-size: 0.8rem; margin-bottom: 8px; }
.algo-card .algo-notation {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 7px;
  padding: 7px 11px;
  display: inline-block;
  margin-bottom: 8px;
  font-weight: 700;
}
.algo-card p { margin: 0; color: var(--text); font-size: 0.92rem; }

/* ---------- blog ---------- */

.blog-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.blog-card {
  display: block;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px 20px;
  background: var(--panel);
  text-decoration: none;
  color: inherit;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.15s ease, border-color 0.15s ease;
}
.blog-card:hover { box-shadow: var(--shadow-md); border-color: var(--muted-2); }
.blog-card h3 { margin: 0 0 4px; }
.blog-card .blog-date { color: var(--muted); font-size: 0.8rem; margin-bottom: 6px; }
.blog-card p { margin: 0; color: var(--text); font-size: 0.92rem; }
