/*
 * The page is built like the cube: black plastic, coloured stickers.
 * Every case is a white sticker that takes its step's colour once you
 * mark it Confident.
 */

:root {
  --mat: #e9ebee;
  --plastic: #000;
  --white: #fff;
  --yellow: #ffd500;
  --green: #009b48;
  --orange: #ff5800;
  --red: #b71234;
  --blue: #0046ad;
  --blank: #50555c;
  --any: #26292d;

  --font: 'Rubik', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'Red Hat Mono', ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
}

/* One colour per step; --on-stage is the text colour that reads on it. */
.tone-f2l { --stage: var(--green); --on-stage: #000; }
.tone-eo { --stage: var(--yellow); --on-stage: #000; }
.tone-co { --stage: var(--orange); --on-stage: #000; }
.tone-cp { --stage: var(--red); --on-stage: #fff; }
.tone-ep { --stage: var(--blue); --on-stage: #fff; }

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--mat);
  color: #000;
  font: 400 1rem/1.5 var(--font);
  -webkit-text-size-adjust: 100%;
}

.wrap {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 20px;
}

:focus-visible {
  outline: 3px solid currentColor;
  outline-offset: 3px;
}

/* ---------- Top of the page ---------- */

.top {
  padding: 56px 0 8px;
}

h1 {
  margin: 0 0 20px;
  font-size: clamp(2.75rem, 10vw, 5.5rem);
  font-weight: 800;
  line-height: 0.92;
  letter-spacing: -0.035em;
}

.lede {
  max-width: 36em;
  margin: 0 0 36px;
  font-size: 1.1875rem;
  line-height: 1.45;
}

.map {
  display: flex;
  flex-wrap: wrap;
  gap: 16px 18px;
}

.map-group {
  display: grid;
  gap: 6px;
  justify-items: start;
  min-width: 0;
}

.map-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  max-width: 100%;
  padding: 3px;
  border-radius: 8px;
  background: var(--plastic);
}

.map-bar a {
  width: 28px;
  height: 28px;
  border-radius: 5px;
  background: var(--white);
  transition: background-color 0.25s;
}

.map-bar a.is-confident {
  background: var(--stage);
}

.map-bar a:focus-visible {
  outline-color: #000;
  outline-offset: 4px;
}

.map-label {
  font-size: 0.8125rem;
  font-weight: 500;
}

.status {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 28px;
  margin-top: 22px;
}

.summary {
  margin: 0;
  font-size: 1.0625rem;
  font-weight: 500;
}

.summary strong {
  font-weight: 800;
}

.switch {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.switch input {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: #000;
}

.notation {
  max-width: 44em;
  margin-top: 22px;
}

.notation summary {
  width: max-content;
  padding: 6px 0;
  font-weight: 700;
  cursor: pointer;
}

.notation dl {
  display: grid;
  gap: 10px;
  margin: 8px 0 0;
}

.notation dl > div {
  display: grid;
  grid-template-columns: 8.5em 1fr;
  gap: 16px;
  align-items: baseline;
}

.notation dt {
  font: 600 1rem var(--mono);
}

.notation dd {
  margin: 0;
}

@media (max-width: 520px) {
  .notation dl > div {
    grid-template-columns: 1fr;
    gap: 2px;
  }
}

/* ---------- Steps ---------- */

.stage {
  padding: 44px 0 4px;
}

.stage-head {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 16px;
  align-items: start;
  margin-bottom: 20px;
}

/* A single cubie: black body, sticker in the step's colour. */
.stage-num {
  display: grid;
  width: 48px;
  height: 48px;
  padding: 4px;
  border-radius: 11px;
  background: var(--plastic);
}

.stage-num span {
  display: grid;
  place-items: center;
  border-radius: 7px;
  background: var(--stage);
  color: var(--on-stage);
  font-size: 1.375rem;
  font-weight: 800;
}

h2 {
  margin: 0;
  padding-top: 6px;
  font-size: clamp(1.5rem, 4.5vw, 2rem);
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.02em;
}

.jargon {
  font-size: 1rem;
  font-weight: 500;
  letter-spacing: 0;
  white-space: nowrap;
}

.intro {
  max-width: 40em;
  margin: 8px 0 0;
}

.all-done {
  margin: 0 0 0 64px;
  font-weight: 500;
}

.subhead {
  max-width: 44em;
  margin: 32px 0 18px 64px;
}

.subhead h3 {
  margin-bottom: 6px;
  font-size: 1.3125rem;
}

.subhead p {
  margin: 0 0 8px;
}

.moves {
  font: 600 0.95em var(--mono);
  white-space: nowrap;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 330px), 1fr));
  gap: 3px;
}

/* ---------- A case ---------- */

.cubie {
  display: flex;
  padding: 5px;
  border-radius: 17px;
  background: var(--plastic);
  scroll-margin-top: 20px;
}

.cubie:target {
  outline: 4px solid var(--stage);
  outline-offset: 2px;
}

.only-learning .cubie.is-confident {
  display: none;
}

.sticker {
  position: relative;
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
  padding: 16px;
  overflow: hidden;
  border-radius: 12px;
  background: var(--white);
  color: #000;
  transition: color 0.2s 0.1s;
}

/* The colour that floods in from the Confident box. */
.sticker::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--stage);
  clip-path: circle(0% at calc(100% - 30px) calc(100% - 38px));
  transition: clip-path 0.5s cubic-bezier(0.3, 0.7, 0.2, 1);
}

.is-confident .sticker {
  color: var(--on-stage);
}

.is-confident .sticker::before {
  clip-path: circle(150% at calc(100% - 30px) calc(100% - 38px));
}

.sticker > * {
  position: relative;
}

.case-top {
  display: grid;
  grid-template-columns: 112px 1fr;
  gap: 14px;
  align-items: start;
}

.tile {
  aspect-ratio: 1;
  padding: 6px;
  border-radius: 11px;
  background: var(--plastic);
}

h3 {
  margin: 0 0 5px;
  font-size: 1.1875rem;
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: -0.01em;
}

.aka {
  font-size: 0.9375rem;
  font-weight: 500;
  letter-spacing: 0;
  white-space: nowrap;
}

.tip {
  margin: 0;
  font-size: 0.9375rem;
  line-height: 1.4;
}

.alg {
  display: flex;
  flex-wrap: wrap;
  gap: 4px calc(1ch + 0.3em);
  margin: 0;
  font: 600 1.125rem/1.5 var(--mono);
}

/* A bracketed chunk. Ones with a reference can be hovered or tapped. */
.grp {
  word-spacing: 0.3em;
  white-space: nowrap;
}

.grp[data-chunk] {
  border-radius: 5px;
  cursor: help;
}

.grp[data-chunk]:hover,
.grp[data-chunk]:focus {
  background: color-mix(in srgb, currentColor 14%, transparent);
  box-shadow: 0 0 0 3px color-mix(in srgb, currentColor 14%, transparent);
}

.ref {
  position: fixed;
  z-index: 20;
  display: grid;
  gap: 3px;
  max-width: min(290px, calc(100vw - 16px));
  padding: 10px 13px 11px;
  border-radius: 11px;
  outline: 2px solid #fff;
  background: #000;
  color: #fff;
  font-size: 0.875rem;
  line-height: 1.4;
  pointer-events: none;
}

.ref[hidden] {
  display: none;
}

.ref strong {
  font-size: 1rem;
  font-weight: 800;
}

.alt {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 10px;
  align-items: baseline;
  margin: -6px 0 0;
  font-size: 0.875rem;
}

.alt .alg {
  font-size: 0.9375rem;
  font-weight: 500;
}

/*
 * On a wide page the middle-layer cards sit on the side their edge goes to:
 * "to the left" in the left column, "to the right" in the next one.
 * 663px is two 330px columns plus the gap.
 */
.stage.tone-f2l {
  container-type: inline-size;
}

@container (min-width: 663px) {
  .grid {
    grid-auto-flow: row dense;
  }

  .cubie[data-side='left'] {
    grid-column: 1;
  }

  .cubie[data-side='right'] {
    grid-column: 2;
  }
}

/* ---------- Marking it off ---------- */

.track {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 10px;
  margin-top: auto;
  padding-top: 14px;
  border-top: 2px solid color-mix(in srgb, currentColor 22%, transparent);
}

.plus {
  min-width: 60px;
  height: 44px;
  padding: 0 18px;
  border: 0;
  border-radius: 999px;
  background: #000;
  color: #fff;
  font: 700 1.0625rem var(--font);
  cursor: pointer;
}

.plus:active {
  transform: scale(0.94);
}

.uses {
  display: flex;
  gap: 5px;
  align-items: baseline;
  margin: 0;
  font-size: 0.9375rem;
}

.count {
  display: inline-block;
  font-size: 1.375rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.count.bump {
  animation: bump 0.22s ease-out;
}

@keyframes bump {
  from { transform: scale(1.45); }
}

.quiet {
  padding: 8px 4px;
  border: 0;
  background: none;
  color: inherit;
  font: 500 0.875rem var(--font);
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

.confident {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  margin-left: auto;
  font-weight: 700;
  cursor: pointer;
}

.confident input {
  display: grid;
  place-content: center;
  width: 30px;
  height: 30px;
  margin: 0;
  border: 2.5px solid currentColor;
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
  appearance: none;
}

.confident input:checked {
  border-color: #000;
  background: #000;
}

.confident input:checked::after {
  content: '';
  width: 14px;
  height: 8px;
  border-bottom: 3px solid #fff;
  border-left: 3px solid #fff;
  transform: translateY(-2px) rotate(-45deg);
}

/* ---------- Cube pictures ---------- */

.cube {
  display: block;
  width: 100%;
  height: 100%;
}

.st { fill: var(--c); }
.st-U { --c: var(--yellow); }
.st-D { --c: var(--white); }
.st-F { --c: var(--green); }
.st-B { --c: var(--blue); }
.st-R { --c: var(--orange); }
.st-L { --c: var(--red); }
.st-blank { --c: var(--blank); }
.st-any { --c: var(--any); }

.cube-iso .st {
  stroke: var(--c);
  stroke-width: 0.8;
  stroke-linejoin: round;
}

/* The white line around the gap an edge is going into. */
.cube-outline {
  fill: none;
  stroke: #fff;
  stroke-width: 1.8;
  stroke-linejoin: round;
}

.cube-body {
  fill: #000;
}

.arrow-line {
  stroke: #000;
  stroke-width: 2.8;
  stroke-linecap: round;
}

.arrow-head {
  fill: #000;
}

/* ---------- Foot ---------- */

.foot {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 24px;
  align-items: center;
  margin-top: 56px;
  padding: 20px 0 48px;
  border-top: 2px solid #000;
  font-size: 0.9375rem;
}

.foot p {
  margin: 0;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition: none !important;
    animation: none !important;
  }
}
