/* Kubiks Rube, drawn as a 1970s technical drawing: paper, ink and a grid.
   The cube's six colours are the only colours, and each one means something.
   Type: IBM Plex Sans for words, IBM Plex Mono for labels and moves (fonts.css). */
:root {
  --paper: #f3efe6; --sheet: #f8f5ee; --ink: #1b1b1b; --soft: #6d675c; --off: #e6e0d3;
  --grid: #dcd6c8; --grid2: #cbc4b3;
  --W: #fbfaf6; --Y: #f2c200; --R: #c62a2a; --G: #108a4c; --B: #1d56a8; --O: #e8721c;
  --l1: var(--B); --l2: var(--R); --l3: var(--O);
  --line: 1.5px;
  --sans: "IBM Plex Sans", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  font-family: var(--sans);
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  color: var(--ink); background-color: var(--paper); overflow: hidden;
  background-image:
    linear-gradient(var(--grid2) 1px, transparent 1px), linear-gradient(90deg, var(--grid2) 1px, transparent 1px),
    linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 120px 120px, 120px 120px, 24px 24px, 24px 24px;
}
b { font-weight: 600; }
.hidden { display: none !important; }
.small { font-size: 13px; color: var(--soft); }
.mono, .lbl { font-family: var(--mono); font-size: 12px; font-weight: 500; letter-spacing: .08em; text-transform: uppercase; }
.lbl { display: inline-block; margin-right: 8px; color: var(--soft); }
button { font-family: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--Y); outline-offset: 2px; }

/* shared cube canvas holder is moved around the DOM */
#cubeStage { width: 100%; height: 100%; }
.cube-holder { width: 100%; min-height: 280px; flex: 1; }
#cubeStage canvas { display: block; width: 100% !important; height: 100% !important; cursor: grab; }
#cubeStage canvas:active { cursor: grabbing; }

.screen { position: absolute; inset: 0; display: none; flex-direction: column; padding: 14px 24px 18px; }
.screen.active { display: flex; }

/* colour chips used inside texts */
.chip { display: inline-block; width: 14px; height: 14px; border: 1px solid var(--ink);
  vertical-align: -2px; margin: 0 3px 0 1px; }
.c0 { background: var(--W); } .c1 { background: var(--R); } .c2 { background: var(--G); }
.c3 { background: var(--Y); } .c4 { background: var(--O); } .c5 { background: var(--B); }
.piece { display: inline-flex; gap: 0; background: var(--ink); padding: 2px 3px; vertical-align: -3px; }
.piece .chip { margin: 0 1px; border-color: var(--ink); }

/* ---------- PANELS, BARS, BUTTONS ---------- */
.panel, .net-wrap, .preview-wrap, .g-side, .learn-side, .next-move, .learn-under {
  background: var(--sheet); border: var(--line) solid var(--ink);
}
.bar { display: flex; align-items: center; gap: 16px; padding-bottom: 12px; margin-bottom: 14px; border-bottom: var(--line) solid var(--ink); }
.bar h2 { margin: 0; font-size: clamp(20px, 2.4vw, 26px); font-weight: 600; letter-spacing: -.01em; }
.bar-spacer { flex: 1; }
.btn, .icon-btn, .info-btn {
  border: var(--line) solid var(--ink); background: var(--sheet); color: var(--ink); cursor: pointer;
  font-weight: 500; font-size: clamp(15px, 1.6vw, 17px); padding: 11px 18px; border-radius: 0;
  transition: background .12s, transform .08s;
}
.btn:hover, .icon-btn:hover, .info-btn:hover { background: #fff; }
.btn:active, .icon-btn:active, .info-btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .35; cursor: default; transform: none; background: var(--sheet); }
.btn-primary { background: var(--ink); color: var(--paper); }
.btn-primary:hover { background: #000; }
.btn-primary:disabled { background: var(--ink); }
.btn-big { font-size: clamp(18px, 2.1vw, 21px); padding: 14px 30px; font-weight: 600; }
.btn-wide { min-width: 230px; }
.btn-sm, .info-btn, .icon-btn { font-size: 14px; padding: 8px 13px; }
.row { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 12px; }
.row.left { justify-content: flex-start; }
.hint { font-size: 14px; color: var(--soft); text-align: center; margin: 10px 4px 0; }

/* ---------- LANDING ---------- */
.screen.landing { display: none; padding: 0; overflow-y: auto; overflow-x: hidden; }
.screen.landing.active { display: block; }
.landing > * { max-width: 1180px; margin-left: auto; margin-right: auto; }
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 16px;
  padding: 18px 40px 16px; border-bottom: var(--line) solid var(--ink); }
.topbar .wordmark { height: 40px; width: auto; display: block; }
.hero { position: relative; display: grid; grid-template-columns: minmax(0, 470px) minmax(0, 1fr); gap: 28px;
  padding: 52px 40px 96px; align-items: start; }
.hero h1 { font-size: clamp(40px, 5.6vw, 62px); line-height: 1.02; font-weight: 600; letter-spacing: -.02em; margin: 14px 0 20px; }
.lead { font-size: clamp(18px, 1.8vw, 20px); line-height: 1.45; margin: 0 0 34px; }
.choices { display: grid; gap: 14px; }
.choice { display: grid; grid-template-columns: 66px 1fr auto; align-items: center; gap: 18px; width: 100%;
  padding: 18px 20px; text-align: left; cursor: pointer; border: 2px solid var(--ink); background: var(--sheet);
  transition: background .12s, transform .08s; }
.choice:hover { background: #fff; }
.choice:active { transform: translateY(1px); }
.choice.primary { background: var(--ink); color: var(--paper); }
.choice.primary:hover { background: #000; }
.choice-pic svg { width: 62px; height: auto; display: block; }
.choice-t { display: block; font-size: clamp(22px, 2.4vw, 26px); font-weight: 600; }
.choice-s { display: block; font-size: 15px; opacity: .78; margin-top: 2px; }
.choice-n { font-family: var(--mono); font-size: 13px; align-self: start; }
.hero-drawing { margin: 0; }
.hero-drawing svg { width: 100%; height: auto; display: block; }
.hero-drawing figcaption { display: none; text-align: center; margin-top: 10px; }
.dl { font-family: var(--mono); font-size: .2px; letter-spacing: .02px; text-transform: uppercase; fill: var(--ink); }
.dl-b { font-weight: 500; font-size: .22px; }
.titleblock { position: absolute; right: 40px; bottom: 30px; margin: 0; display: grid; grid-template-columns: repeat(4, auto);
  border: var(--line) solid var(--ink); background: var(--sheet); }
.titleblock div { padding: 7px 14px; border-left: 1px solid var(--ink); }
.titleblock div:first-child { border-left: none; }
.titleblock dt { font-family: var(--mono); font-size: 10px; letter-spacing: .1em; text-transform: uppercase; color: var(--soft); }
.titleblock dd { margin: 0; font-size: 14px; font-weight: 500; }

.story { border-top: var(--line) solid var(--ink); padding: 54px 40px 30px; }
.story h2 { font-size: clamp(30px, 3.6vw, 40px); font-weight: 600; letter-spacing: -.01em; margin: 10px 0 32px; }
.timeline { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(4, 1fr);
  border: var(--line) solid var(--ink); background: var(--sheet); }
.timeline li { padding: 22px; border-left: 1px solid var(--ink); }
.timeline li:first-child { border-left: none; }
.yr { font-family: var(--mono); font-size: 30px; font-weight: 500; }
.tl-pic svg { width: 140px; height: auto; display: block; margin: 18px auto; }
.timeline h3 { font-size: 19px; font-weight: 600; margin: 0 0 8px; }
.timeline p { font-size: 16px; line-height: 1.45; margin: 0; }
.number { margin: 40px 0 10px; padding: 34px 30px; background: var(--ink); color: var(--paper);
  display: grid; grid-template-columns: 1fr minmax(200px, 300px); gap: 30px; align-items: center; }
.number .mono { opacity: .65; margin-bottom: 10px; }
.number .big { font-family: var(--mono); font-size: clamp(22px, 3.7vw, 44px); letter-spacing: -.02em; }
.number p { font-size: 18px; line-height: 1.45; margin: 0; }
.foot { display: flex; justify-content: space-between; gap: 20px; flex-wrap: wrap; padding: 18px 40px 34px; color: var(--soft); }
.foot a { color: var(--ink); }

/* ---------- PAINT ---------- */
.solve-stage { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.paint-grid { flex: 1; display: grid; grid-template-columns: 1fr 1fr; gap: 18px; min-height: 0; }
.net-wrap, .preview-wrap { padding: 16px; display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 0; }
.preview-wrap { background: transparent; }
#net { display: grid; grid-template-columns: repeat(12, 1fr); grid-template-rows: repeat(9, 1fr);
  gap: 3px; width: min(100%, 460px); aspect-ratio: 12 / 9; }
.facecell { border: 1px solid var(--ink); cursor: pointer; }
.facecell:hover { outline: 2px solid var(--ink); outline-offset: -4px; }
.facecell.center { cursor: default; border-width: 3px; }
.facecell.center:hover { outline: none; }
.palette { display: flex; gap: 10px; margin-top: 18px; flex-wrap: wrap; justify-content: center; }
.swatch { width: 46px; height: 46px; border: var(--line) solid var(--ink); cursor: pointer; }
.swatch.sel { outline: 3px solid var(--ink); outline-offset: 3px; }
.solve-footer { display: flex; align-items: center; justify-content: center; gap: 18px; margin-top: 14px; }
.msg { min-height: 22px; margin: 0; font-weight: 600; }
.msg.err { color: var(--R); }

/* ---------- GUIDED PLAYER ---------- */
.guided { flex: 1; display: grid; grid-template-columns: 1.2fr 1fr; gap: 18px; min-height: 0; }
.g-left { display: flex; flex-direction: column; min-height: 0; }
.next-move { display: flex; align-items: center; gap: 16px; padding: 10px 16px; margin-top: 8px; min-height: 96px; }
.nm-card .mcard { width: 64px; height: auto; display: block; }
.nm-text { display: flex; flex-direction: column; gap: 2px; }
.nm-text > b { font-size: clamp(18px, 2.2vw, 24px); }
.nm-text small { color: var(--soft); font-size: 14px; }
.nm-label { font-family: var(--mono); font-size: 12px; font-weight: 500; letter-spacing: .08em; text-transform: uppercase; color: var(--soft); }
.nm-label.hold { color: var(--paper); background: var(--ink); align-self: flex-start; padding: 2px 7px; }

.g-side { padding: 16px 18px; display: flex; flex-direction: column; min-height: 0; overflow: auto; }
/* the eight steps as a scale: one group per layer, its colour along the top */
.rail { display: flex; gap: 0; margin-bottom: 14px; border: 1px solid var(--ink); align-self: flex-start; }
.rail-group { display: flex; flex-direction: column; gap: 4px; padding: 6px 8px 8px; border-left: 1px solid var(--ink);
  border-top: 5px solid var(--lc); }
.rail-group:first-child { border-left: none; }
.rail-name { font-family: var(--mono); font-size: 10px; font-weight: 500; letter-spacing: .08em; text-transform: uppercase; color: var(--soft); }
.rail-steps { display: flex; gap: 4px; }
.rail-step { width: 32px; height: 32px; border: 1px solid var(--ink); background: var(--sheet); color: var(--ink);
  font-family: var(--mono); font-size: 14px; font-weight: 500; cursor: pointer; padding: 0; }
.rail-step:hover { background: #fff; }
.rail-step.done { background: var(--off); color: var(--soft); }
.rail-step.on { background: var(--lc); color: var(--paper); border-width: 2px; }
.rail.locked .rail-step { cursor: default; }
.g-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.step-chip { display: inline-block; background: var(--l1); color: var(--paper); font-family: var(--mono); font-weight: 500;
  font-size: 12px; letter-spacing: .08em; text-transform: uppercase; padding: 4px 9px; }
.g-title { font-size: clamp(24px, 2.8vw, 32px); font-weight: 600; letter-spacing: -.01em; margin: 10px 0 10px; }
.chunk { background: var(--W); border: var(--line) solid var(--ink); padding: 12px 14px 14px; }
.kind { display: inline-block; font-family: var(--mono); font-weight: 500; font-size: 11px; letter-spacing: .08em;
  text-transform: uppercase; padding: 3px 7px; color: var(--paper); margin-bottom: 4px; }
.kind.hold { background: var(--ink); } .kind.turn { background: var(--soft); }
.kind.alg { background: var(--R); padding: 3px 7px; margin: 0 0 4px; border: 0; } /* not the .alg box */
.chunk-text { font-size: clamp(16px, 1.8vw, 19px); line-height: 1.45; margin: 4px 0 10px; }
.chunk .note { margin: 8px 0 0; font-weight: 600; }
.g-count { font-family: var(--mono); font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--soft); margin: 10px 2px 0; }
.controls { display: flex; gap: 10px; justify-content: center; align-items: center; margin-top: 14px; flex-wrap: wrap; }

/* move cards */
.cards { display: flex; flex-wrap: wrap; gap: 6px; align-items: flex-start; }
.cardwrap { display: flex; flex-direction: column; align-items: center; width: 54px; position: relative; transition: transform .15s, opacity .15s; }
.cardwrap .mcard { width: 54px; height: auto; display: block; }
.alg .cardwrap, .practice .cardwrap { width: 60px; }
.alg .cardwrap .mcard, .practice .cardwrap .mcard { width: 60px; }
.cardwrap.done { opacity: .35; }
.cardwrap.on { transform: translateY(-5px); }
.cardwrap.on::after { content: ""; position: absolute; left: 4px; right: 4px; bottom: -7px; height: 4px; background: var(--Y); border: 1px solid var(--ink); }
.cardwrap.click { cursor: pointer; }
.cardwrap.click:hover { transform: translateY(-3px); }
.chant { font-family: var(--mono); font-size: 10px; font-weight: 500; text-align: center; line-height: 1.1; margin-top: 3px; color: var(--R); text-transform: uppercase; letter-spacing: .04em; }

/* ---------- MODAL ---------- */
.overlay { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center;
  background: rgba(27, 27, 27, .45); padding: 20px; }
.modal-card { background: var(--paper); color: var(--ink); border: var(--line) solid var(--ink); padding: 0 26px 22px;
  max-width: 720px; width: 100%; max-height: 92vh; overflow: auto; box-shadow: 8px 8px 0 rgba(27, 27, 27, .35); }
.m-band { margin: 0 -26px 6px; background: var(--lc); color: var(--paper); padding: 7px 26px; font-family: var(--mono);
  font-weight: 500; font-size: 12px; text-transform: uppercase; letter-spacing: .1em; border-bottom: var(--line) solid var(--ink); }
.m-title { margin: 14px 0 14px; font-size: clamp(24px, 3vw, 32px); font-weight: 600; letter-spacing: -.01em; display: flex; align-items: center; gap: 12px; }
.m-num { font-family: var(--mono); font-weight: 500; font-size: .7em; width: 1.6em; height: 1.6em; display: inline-flex;
  align-items: center; justify-content: center; border: var(--line) solid var(--ink); background: var(--lc); color: var(--paper); flex: none; }
.m-ok { border-left: 5px solid var(--G); background: rgba(16, 138, 76, .1); padding: 8px 12px; font-weight: 600; }
.m-buttons { display: flex; gap: 12px; justify-content: flex-end; align-items: center; margin-top: 18px; flex-wrap: wrap; }
.check { display: flex; gap: 20px; align-items: center; }
.check figure { margin: 0; text-align: center; background: var(--sheet); border: 1px solid var(--ink); padding: 10px; }
.check figcaption, .lesson-pic figcaption { font-family: var(--mono); font-size: 10px; letter-spacing: .08em; text-transform: uppercase; color: var(--soft); }
.big-q { font-size: 22px; font-weight: 600; margin: 0 0 6px; }

/* lesson content (shared by the intro pop-up and the Learn course) */
.lesson-top { display: flex; gap: 16px; align-items: center; margin-bottom: 8px; }
.lesson-pic { margin: 0; text-align: center; background: var(--sheet); border: 1px solid var(--ink); padding: 8px; flex: none; }
.goal { font-size: 19px; font-weight: 600; margin: 0 0 6px; line-height: 1.35; }
.holdtxt { font-size: 16px; margin: 0; }
.cases { display: flex; gap: 0; flex-wrap: wrap; margin: 10px 0; border: 1px solid var(--ink); }
.case { flex: 1 1 150px; background: var(--sheet); padding: 8px; text-align: center; font-size: 14px; border-left: 1px solid var(--ink); }
.case:first-child { border-left: none; }
.case p { margin: 4px 0 0; }
.actions { margin: 10px 0; padding-left: 24px; font-size: 16px; line-height: 1.45; }
.actions li { margin-bottom: 4px; }
.actions li::marker { font-family: var(--mono); font-size: 13px; color: var(--soft); }
.alg { background: var(--sheet); border: 1px solid var(--ink); padding: 10px 12px 14px; margin: 10px 0; }
.alg-name { font-family: var(--mono); font-weight: 500; font-size: 12px; letter-spacing: .08em; text-transform: uppercase; margin-bottom: 10px; }
.tip { border-left: 5px solid var(--Y); background: rgba(242, 194, 0, .14); padding: 8px 12px; margin: 8px 0; font-size: 15px; line-height: 1.4; }

/* ---------- LEARN ---------- */
.course-nav { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.course-chip { border: 1px solid var(--ink); border-top: 4px solid var(--lc, var(--ink)); cursor: pointer; background: var(--sheet);
  font-weight: 500; font-size: 14px; padding: 6px 11px 7px; }
.course-chip:hover { background: #fff; }
.course-chip.on { background: var(--lc, var(--ink)); color: var(--paper); }
.course-chip .num { font-family: var(--mono); font-size: 12px; margin-right: 7px; opacity: .75; }
.learn-grid { flex: 1; display: grid; grid-template-columns: 1.1fr 1fr; gap: 18px; min-height: 0; }
.learn-left { display: flex; flex-direction: column; min-height: 0; }
.learn-under { padding: 10px 16px; margin-top: 8px; min-height: 76px; }
.lu-text { margin: 4px 0; font-size: 16px; line-height: 1.4; }
.lu-big { font-family: var(--mono); font-size: 34px; font-weight: 500; margin: 0; line-height: 1.1; }
.lu-big.ok { color: var(--G); }
.score { display: flex; gap: 6px; margin: 4px 0 6px; }
.score i { width: 22px; height: 22px; border: var(--line) solid var(--ink); background: var(--sheet); }
.score i.hit { background: var(--Y); }
.lu-move { display: flex; align-items: center; gap: 12px; font-size: 18px; }
.lu-move .mcard { width: 58px; height: auto; }
.learn-under .cards .mcard { width: 46px; }
.learn-under .cardwrap { width: 46px; }
.learn-side { padding: 14px 18px; min-height: 0; overflow: auto; }
.l-head h3 { margin: 8px 0 8px; font-size: clamp(24px, 2.8vw, 32px); font-weight: 600; letter-spacing: -.01em; }
.sec { border-top: 1px solid var(--ink); padding: 10px 0 12px; margin: 8px 0 0; }
.sec h4 { margin: 2px 0 4px; font-size: 18px; font-weight: 600; }
.sec p { margin: 4px 0 8px; line-height: 1.45; }
.motion { font-weight: 600; }
.rules { padding-left: 20px; line-height: 1.5; font-size: 16px; }
.sticky-actions { position: sticky; bottom: -14px; background: linear-gradient(180deg, rgba(248, 245, 238, 0), var(--sheet) 35%); padding: 16px 0 12px; margin-top: 4px; }
.practice { background: var(--W); border: var(--line) solid var(--ink); padding: 10px 12px 12px; margin-top: 8px; }
.practice h4 { margin: 2px 0 4px; font-size: 18px; font-weight: 600; }
.learn-nav { display: flex; gap: 12px; justify-content: center; align-items: center; margin-top: 12px; }
.lesson-progress { font-family: var(--mono); font-weight: 500; font-size: 14px; }

@media (max-width: 960px) {
  .hero { grid-template-columns: 1fr; padding-bottom: 40px; }
  .hero-drawing { max-width: 560px; margin: 0 auto; width: 100%; }
  .titleblock { position: static; justify-self: start; }
  .timeline { grid-template-columns: 1fr 1fr; }
  .timeline li:nth-child(3) { border-left: none; }
  .timeline li:nth-child(n+3) { border-top: 1px solid var(--ink); }
}
@media (max-width: 860px) {
  .paint-grid, .guided, .learn-grid { grid-template-columns: 1fr; }
  body { overflow: auto; }
  .screen { position: static; min-height: 100%; }
  .screen.landing { overflow: visible; }
  .cube-holder { min-height: 320px; }
  .check, .lesson-top { flex-direction: column; }
}
@media (max-width: 560px) {
  .topbar, .hero, .story, .foot { padding-left: 16px; padding-right: 16px; }
  .topbar .mono { display: none; }
  .topbar .wordmark { height: 32px; }
  .hero { padding-top: 30px; }
  .choice { grid-template-columns: 48px 1fr; gap: 14px; padding: 14px; }
  .choice-pic svg { width: 46px; }
  .choice-n { display: none; }
  .titleblock { grid-template-columns: repeat(2, auto); }
  .titleblock div:nth-child(3) { border-left: none; }
  .titleblock div:nth-child(n+3) { border-top: 1px solid var(--ink); }
  .timeline { grid-template-columns: 1fr; }
  .timeline li { border-left: none; }
  .timeline li + li { border-top: 1px solid var(--ink); }
  .number { grid-template-columns: 1fr; padding: 26px 20px; }
  .screen { padding: 12px 16px 16px; }
  .hero-drawing .ann { display: none; }
  .hero-drawing figcaption { display: block; }
  .swatch { width: 40px; height: 40px; }
  .palette { gap: 8px; }
  .rail-group { padding: 5px 5px 6px; }
  .rail-step { width: 28px; height: 28px; font-size: 13px; }
}
