:root {
  --bg: #f7f7f9;
  --surface: #ffffff;
  --text: #1a1a1e;
  --text-muted: #5b5b66;
  --border: #e2e2e8;
  --accent: #2f6fed;
  --accent-contrast: #ffffff;
  --code-bg: #eef0f6;
  --radius: 10px;
  --partial: #8a6408;
  --partial-contrast: #ffffff;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14151a;
    --surface: #1d1e25;
    --text: #eeeef2;
    --text-muted: #a3a3ad;
    --border: #2c2d36;
    --accent: #6c9bff;
    --accent-contrast: #0c1220;
    --code-bg: #262733;
    --partial: #f0c14b;
    --partial-contrast: #1a1a1e;
  }
}

* {
  box-sizing: border-box;
}

/* Components set their own display, which would otherwise beat `hidden`. */
[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.5;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

main {
  max-width: 960px;
  margin: 0 auto;
  padding: 2rem 1rem 4rem;
}

h1 {
  font-size: 1.9rem;
  margin-bottom: 0.25rem;
}

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

.method-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin-top: 1.5rem;
}

.method-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
}

/* The whole card is the link: the card's link stretches over it. Cards
   without a link ("Coming soon") are left alone. */
.method-card a::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: var(--radius);
}

.method-card:has(a) {
  cursor: pointer;
  transition: border-color 0.12s, box-shadow 0.12s;
}

.method-card:has(a):hover {
  border-color: var(--accent);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
}

.method-card a:focus-visible {
  outline: none;
}

.method-card a:focus-visible::after {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.method-card h3 {
  margin: 0 0 0.35rem;
}

.method-card p {
  color: var(--text-muted);
  margin: 0 0 0.75rem;
  font-size: 0.92rem;
}

.badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  background: var(--code-bg);
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.badge.ready {
  background: var(--accent);
  color: var(--accent-contrast);
}

.badge.partial {
  background: var(--partial);
  color: var(--partial-contrast);
}

.case-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.25rem;
  margin-top: 1.5rem;
}

.case-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.case-header h3 {
  margin: 0;
  font-size: 1.15rem;
}

.case-orientation {
  margin: 0.15rem 0 0;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.case-visual {
  display: flex;
  justify-content: center;
}

.case-viewer {
  width: 100%;
  aspect-ratio: 1 / 1;
  max-height: 220px;
}

.case-diagram {
  display: flex;
  justify-content: center;
  gap: 1rem;
}

.case-diagram figure {
  margin: 0;
  text-align: center;
}

.case-diagram svg {
  display: block;
  width: 140px;
  max-width: 100%;
  height: auto;
}

.case-diagram figure:only-child svg {
  width: 160px;
}

.case-diagram figcaption {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

:root[data-view="3d"] .case-diagram,
:root:not([data-view="3d"]) .case-viewer {
  display: none;
}

.case-then {
  margin: 0;
  font-size: 0.9rem;
}

.case-card:target {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.source-note {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  margin-top: 1rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.source-note p {
  margin: 0.25rem 0;
}

.finder {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.finder-search {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.finder-search input,
.finder-search select {
  font: inherit;
  font-size: 0.95rem;
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  min-width: 0;
}

.finder-search input {
  flex: 1 1 260px;
}

.finder-search select {
  flex: 0 1 260px;
}

.finder-row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.4rem 0.75rem;
}

.finder-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  min-width: 11rem;
}

.finder-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.chip {
  font: inherit;
  font-size: 0.85rem;
  padding: 0.3rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
}

.chip[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-contrast);
}

.chip:disabled {
  opacity: 0.4;
  cursor: default;
}

.chip-count {
  opacity: 0.7;
  font-size: 0.8em;
}

.finder-hint {
  margin: 0;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.finder-status {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.9rem;
}

.finder-clear {
  font: inherit;
  font-size: 0.85rem;
  border: 0;
  background: none;
  color: var(--accent);
  cursor: pointer;
  padding: 0;
}

.f2l-map {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.f2l-map section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
}

.f2l-map h3 {
  margin: 0 0 0.5rem;
  font-size: 1rem;
}

.f2l-map ul {
  list-style: none;
  margin: 0;
  padding-left: 1.1rem;
  border-left: 1px solid var(--border);
}

.f2l-map > section > ul {
  padding-left: 0;
  border-left: 0;
}

.f2l-map li {
  margin: 0.2rem 0;
  font-size: 0.88rem;
}

.f2l-map li code {
  background: var(--code-bg);
  padding: 0.05rem 0.35rem;
  border-radius: 4px;
  font-size: 0.85rem;
}

.f2l-map .f2l-desc {
  color: var(--text-muted);
}

.view-toggle {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
  margin-top: 1rem;
  font-size: 0.9rem;
}

.view-toggle-label {
  color: var(--text-muted);
}

.view-toggle-buttons {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 999px;
  overflow: hidden;
  background: var(--surface);
}

.view-toggle-buttons button {
  font: inherit;
  border: 0;
  background: transparent;
  color: var(--text);
  padding: 0.3rem 0.9rem;
  cursor: pointer;
}

.view-toggle-buttons button[aria-pressed="true"] {
  background: var(--accent);
  color: var(--accent-contrast);
}

.view-toggle-status {
  color: var(--text-muted);
  font-size: 0.85rem;
}

.case-alg code,
.case-alt code {
  display: block;
  background: var(--code-bg);
  padding: 0.5rem 0.65rem;
  border-radius: 6px;
  font-size: 0.95rem;
  white-space: pre-wrap;
  word-break: break-word;
}

.case-mnemonic strong {
  font-size: 1rem;
}

.case-mnemonic-letters {
  color: var(--text-muted);
  font-size: 0.85rem;
}

.case-breakdown {
  margin: 0.25rem 0 0;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.case-turns-into {
  margin: 0;
  font-size: 0.9rem;
}

.case-alt-label {
  margin: 0 0 0.25rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
}

.case-alt-note,
.case-story,
.case-note {
  margin: 0;
  font-size: 0.85rem;
  color: var(--text-muted);
  font-style: italic;
}

.section-heading {
  margin-top: 2.5rem;
}

.coming-soon {
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  text-align: center;
  color: var(--text-muted);
  margin-top: 1.5rem;
}

footer.site-footer {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.8rem;
  padding: 2rem 1rem;
}

/* Filtered F2L results: keep cards card-sized when only a few are left. */
#f2l-cases .case-grid {
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}

@media (max-width: 600px) {
  .finder-label {
    min-width: 0;
    width: 100%;
  }
}

/* Blindfolded page */
.bld-order,
.bld-tips {
  margin: 0.5rem 0 0;
  padding-left: 1.3rem;
}

.bld-order li,
.bld-tips li {
  margin: 0.3rem 0;
}

.bld-nets {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1rem;
  margin-top: 0.75rem;
}

.bld-nets figure {
  margin: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem;
  text-align: center;
}

.bld-nets figcaption {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 0.4rem;
}

.bld-net {
  width: 100%;
  height: auto;
  display: block;
}

.net-cell {
  fill: var(--code-bg);
  stroke: var(--border);
  stroke-width: 0.3;
}

rect.net-buffer {
  fill: var(--accent);
}

rect.net-marked {
  fill: #b8860b;
}

.net-face,
.net-letter {
  text-anchor: middle;
  dominant-baseline: central;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.net-face {
  font-size: 4px;
  fill: var(--text-muted);
}

.net-letter {
  font-size: 5px;
  font-weight: 700;
  fill: var(--text);
}

text.net-buffer,
text.net-marked {
  fill: #ffffff;
}

.bld-legend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem 0.6rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.swatch {
  display: inline-block;
  width: 0.9rem;
  height: 0.9rem;
  border-radius: 3px;
}

.swatch.net-buffer {
  background: var(--accent);
}

.swatch.net-marked {
  background: #b8860b;
}

.table-wrap {
  overflow-x: auto;
  margin-top: 0.75rem;
}

.bld-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.9rem;
}

.bld-table th,
.bld-table td {
  text-align: left;
  vertical-align: top;
  padding: 0.45rem 0.6rem;
  border-bottom: 1px solid var(--border);
}

.bld-table thead th {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 600;
}

.bld-table code {
  background: var(--code-bg);
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  white-space: nowrap;
}

.bld-letter {
  font-size: 1.05rem;
  width: 3rem;
}

.bld-piece {
  color: var(--text-muted);
  width: 3.5rem;
}

.bld-muted {
  color: var(--text-muted);
}

.bld-tag {
  font-size: 0.75rem;
  font-weight: 600;
  color: #b8860b;
}

.bld-note {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

.bld-buffer-row {
  opacity: 0.6;
}

.bld-table tr:target {
  outline: 2px solid var(--accent);
}

/* Beginner's method: numbered steps with a sticky step bar */
.step-bar {
  position: sticky;
  top: var(--header-h, 0);
  z-index: 5;
  display: flex;
  gap: 0.4rem;
  overflow-x: auto;
  scrollbar-width: thin;
  margin: 1rem -1rem 0;
  padding: 0.5rem 1rem;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.step-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  flex: none;
  padding: 0.25rem 0.7rem 0.25rem 0.3rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font-size: 0.88rem;
  white-space: nowrap;
}

.step-pill:hover {
  text-decoration: none;
  border-color: var(--accent);
}

.step-pill-num,
.step-num {
  display: inline-grid;
  place-items: center;
  border-radius: 50%;
  background: var(--code-bg);
  color: var(--text-muted);
  font-weight: 700;
}

.step-pill-num {
  width: 1.5rem;
  height: 1.5rem;
  font-size: 0.8rem;
}

.step-pill.active {
  border-color: var(--accent);
  color: var(--accent);
}

.step-pill.active .step-pill-num {
  background: var(--accent);
  color: var(--accent-contrast);
}

#top,
.step,
.step .case-card {
  scroll-margin-top: var(--step-offset, 1rem);
}

.step {
  margin-top: 2.5rem;
}

.step-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
}

.step-head h2 {
  margin: 0;
}

.step-num {
  width: 2.1rem;
  height: 2.1rem;
  background: var(--accent);
  color: var(--accent-contrast);
  font-size: 1.05rem;
}

.step-source {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  background: var(--code-bg);
  color: var(--text-muted);
}

.step-source.yours {
  background: var(--accent);
  color: var(--accent-contrast);
}

.step-goal {
  margin: 0.75rem 0 0.25rem;
}

.step-how {
  margin: 0 0 1rem;
  padding-left: 1.3rem;
  color: var(--text-muted);
}

.step-how li {
  margin: 0.2rem 0;
}

.step-foot {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
  font-size: 0.92rem;
}

.step-foot .step-up {
  color: var(--text-muted);
}

.step-foot .step-next {
  font-weight: 600;
}

.step-foot .step-done {
  font-weight: 600;
  color: var(--text-muted);
}


/* Tabs between pages of one section (Blind: Reference / Practice) */
.tabs {
  display: flex;
  gap: 0.25rem;
  margin: 1rem 0 0.5rem;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  white-space: nowrap;
  scrollbar-width: thin;
}

.tabs a {
  padding: 0.45rem 1rem;
  margin-bottom: -1px;
  border: 1px solid transparent;
  border-radius: var(--radius) var(--radius) 0 0;
  color: var(--text-muted);
  font-weight: 600;
}

.tabs a:hover {
  text-decoration: none;
  color: var(--accent);
}

.tabs a.active {
  background: var(--surface);
  border-color: var(--border);
  border-bottom-color: var(--surface);
  color: var(--accent);
}

.btn {
  font: inherit;
  font-size: 0.9rem;
  padding: 0.4rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}

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

.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-contrast);
}

/* Blindfolded practice */
.practice-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 300px);
  gap: 1rem;
  align-items: start;
  margin-top: 1rem;
}

.practice-scramble,
.practice-net,
.memo-block {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  margin: 0;
}

#scramble {
  display: block;
  font-size: 1.25rem;
  line-height: 1.6;
  word-spacing: 0.2em;
  white-space: pre-wrap;
  word-break: break-word;
}

.practice-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.9rem;
}

.practice-own {
  margin-top: 0.9rem;
  font-size: 0.9rem;
}

.practice-own label {
  color: var(--text-muted);
}

.practice-own-row {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.3rem;
}

.practice-own input {
  flex: 1;
  min-width: 0;
  font: inherit;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
}

.practice-error {
  color: #c0392b;
  margin: 0.4rem 0 0;
}

.practice-net figcaption {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.5rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.practice-net select {
  font: inherit;
  padding: 0.2rem 0.3rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
}

.net-sticker {
  stroke: #1f2937;
  stroke-width: 0.4;
}

.practice-memo-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
}

.practice-memo {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1rem;
  margin-top: 0.75rem;
}

.memo-block h3 {
  margin: 0 0 0.5rem;
  font-size: 1rem;
}

.memo-count {
  font-weight: 400;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.memo-letters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0;
}

.memo-pair {
  display: inline-flex;
  gap: 0.1rem;
  padding: 0.2rem 0.55rem;
  border-radius: 8px;
  background: var(--code-bg);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: 0.05em;
}

.memo-letter.cycle-break {
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
  text-decoration-color: var(--accent);
}

.memo-legend {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.memo-legend .memo-letter {
  font-weight: 700;
  color: var(--text);
}

.letters-hidden .memo-letter {
  color: transparent;
  text-decoration-color: transparent;
}

.memo-none {
  color: var(--text-muted);
}

.memo-parity {
  margin: 0.75rem 0 0;
  font-size: 0.88rem;
  color: var(--text-muted);
}

.memo-parity.has-parity {
  color: var(--text);
  font-weight: 600;
}

.practice-moves {
  margin-top: 1.5rem;
}

.practice-moves summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 1.1rem;
}

.bld-swapped {
  white-space: nowrap;
}

.bld-table caption {
  text-align: left;
  font-weight: 600;
  padding: 0 0 0.4rem;
}

@media (max-width: 700px) {
  .practice-panel {
    grid-template-columns: 1fr;
  }
}

.practice-kept {
  margin: 0.6rem 0 0;
  font-size: 0.82rem;
  color: var(--text-muted);
}

/* Method pages: facts box, clarifying notes, extra sections */
.facts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.6rem;
  margin: 1rem 0 0;
}

.fact {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.6rem 0.9rem;
}

.fact dt {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-muted);
}

.fact dd {
  margin: 0.15rem 0 0;
  font-size: 0.92rem;
}

.step-note {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius);
  padding: 0.6rem 0.9rem;
  margin: 0.75rem 0;
  font-size: 0.88rem;
  color: var(--text-muted);
}

.step-note code {
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text);
}

.step-num.extra {
  background: var(--code-bg);
  color: var(--text-muted);
  font-size: 0.95rem;
}

.faster-tips {
  margin: 1rem 0 0;
  padding-left: 1.3rem;
}

.faster-tips li {
  margin: 0.3rem 0;
}

/* Step-by-step picture strips (js/alg-filmstrip.js) */
.case-card.wide {
  grid-column: 1 / -1;
}

.filmstrip {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.film {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 0.75rem;
}

.film-frame {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.6rem;
}

.film-label {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-weight: 700;
  font-size: 0.9rem;
}

.film-diagram {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
}

.film-diagram figure {
  margin: 0;
  text-align: center;
}

.film-diagram svg {
  display: block;
  width: 105px;
  max-width: 100%;
  height: auto;
}

.film-diagram figcaption {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.film-caption {
  margin: 0;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.film-legend {
  margin: 0;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.film-swatch {
  display: inline-block;
  width: 0.9rem;
  height: 0.9rem;
  border: 3px solid;
  border-radius: 3px;
  vertical-align: -0.15rem;
  background: transparent;
}

.film-every {
  margin-top: 0.25rem;
}

.film-every summary {
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
}

.film-every .film {
  margin-top: 0.6rem;
}

/* Exercise cards: setup scramble and a hidden solution */
.case-setup {
  margin: 0;
  font-size: 0.9rem;
}

.case-setup code {
  white-space: pre-wrap;
  word-break: break-word;
}

.case-solution summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 0.9rem;
}

.case-solution > * {
  margin-top: 0.5rem;
}

/* Libby's notation line under each algorithm (2-look OLL / PLL) */
.case-libby {
  margin: 0;
  font-size: 0.9rem;
}

.case-libby code {
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.95rem;
  letter-spacing: 0.04em;
}

.libby-key {
  margin: 0.75rem 0 0;
  font-size: 0.88rem;
  color: var(--text-muted);
}

/* "Then →" on an F2L card: a picture of the case it turns into */
.case-next {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
  padding: 0.4rem;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: 0.8rem;
}

.case-next:hover {
  text-decoration: none;
  border-color: var(--accent);
}

.case-next-diagram {
  display: flex;
  justify-content: center;
}

.case-next-diagram figure {
  margin: 0;
}

.case-next-diagram svg {
  display: block;
  width: 96px;
  height: auto;
}

/* Sub-headings and tables inside a numbered step (Roux LSE, DFDB). */
.step-sub {
  margin: 1.25rem 0 0.25rem;
  font-size: 1.05rem;
}

.step .table-wrap {
  margin: 0.75rem 0;
}

/* ===== Mobile redesign (2026-10-06) ===== */

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Header: one line on phones, with a Menu button; the inline nav on wide screens. */
.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.header-bar {
  display: flex;
  align-items: center;
  gap: 0.25rem 1rem;
  max-width: 960px;
  height: 56px;
  margin: 0 auto;
  padding: 0 1rem;
}

.site-header .brand,
.menu-panel .brand {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  min-height: 44px;
  font-weight: 700;
  color: var(--text);
}

.site-header .brand:hover,
.menu-panel .brand:hover {
  text-decoration: none;
}

.brand-logo {
  width: 28px;
  height: 28px;
  flex: none;
  border-radius: 6px;
}

.menu-button {
  margin-left: auto;
  font: inherit;
  font-weight: 600;
  min-height: 44px;
  padding: 0 1.1rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
}

.menu-button:hover {
  border-color: var(--accent);
}

.site-nav {
  display: none;
}

.menu-badge {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  background: var(--partial);
  color: var(--partial-contrast);
  vertical-align: middle;
}

@media (min-width: 1280px) {
  .header-bar {
    max-width: none;
    height: auto;
    min-height: 56px;
    flex-wrap: wrap;
    padding-top: 0.35rem;
    padding-bottom: 0.35rem;
  }

  .menu-open-button {
    display: none;
  }

  .site-nav {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.1rem 0.6rem;
    margin-left: auto;
  }

  .nav-group {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.1rem 0.55rem;
    padding-left: 0.6rem;
    border-left: 1px solid var(--border);
  }

  .nav-group-label {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
  }

  .nav-link {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    min-height: 32px;
    color: var(--text-muted);
    font-size: 0.88rem;
  }

  .nav-sub {
    font-size: 0.8rem;
  }

  .site-nav .menu-badge {
    padding: 0 0.35rem;
    font-size: 0.6rem;
  }

  .site-nav > .nav-link {
    display: none; /* Home: the brand already links there */
  }

  .nav-link:hover,
  .nav-link[aria-current="page"] {
    color: var(--accent);
  }

  .nav-link[aria-current="page"] {
    font-weight: 600;
  }
}

/* Full-screen menu panel (phones) */
html.menu-open {
  overflow: hidden;
}

.menu-panel {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  background: var(--bg);
}

.menu-panel-bar {
  position: sticky;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
  flex: none;
  padding: 0 1rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.menu-list {
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  padding: 0.5rem 1rem 3rem;
}

.menu-group-label {
  margin: 1.25rem 0 0.25rem;
  padding-left: 0.75rem;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.menu-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 48px;
  padding: 0 0.75rem;
  border-radius: 8px;
  color: var(--text);
  font-size: 1.05rem;
}

.menu-row:hover {
  background: var(--surface);
  text-decoration: none;
}

.menu-row[aria-current="page"] {
  background: var(--surface);
  color: var(--accent);
  font-weight: 600;
  box-shadow: inset 3px 0 0 var(--accent);
}

.menu-sub {
  margin: 0 0 0.25rem 1.1rem;
  padding-left: 0.5rem;
  border-left: 2px solid var(--border);
}

.menu-sub .menu-row {
  font-size: 1rem;
  color: var(--text-muted);
}

.menu-sub .menu-row[aria-current="page"] {
  color: var(--accent);
}

/* Breadcrumbs */
.breadcrumbs {
  margin: -1.25rem 0 0.25rem;
}

.breadcrumbs ol {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.breadcrumbs li + li::before {
  content: '›';
  margin: 0 0.45rem;
}

.breadcrumbs a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
}

.breadcrumbs [aria-current="page"] {
  color: var(--text);
  font-weight: 600;
}

/* "About this page": source and attribution notes, collapsed at the bottom */
.about-page {
  margin-top: 2.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.about-page > summary {
  padding: 0.75rem 1rem;
  font-weight: 600;
  cursor: pointer;
}

.about-page .source-note {
  margin: 0;
  border: 0;
  border-top: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: 0;
}

/* Home: grouped by puzzle, one row per method */
.puzzle-label {
  margin: 1.5rem 0 0.5rem;
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.row-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.row-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color 0.12s, box-shadow 0.12s;
}

.row-card:hover {
  border-color: var(--accent);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
}

.row-main {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  min-height: 64px;
  padding: 0.7rem 0.9rem;
  color: var(--text);
}

.row-main:hover {
  text-decoration: none;
}

.row-main:focus-visible,
.quick-link:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.row-icon {
  flex: none;
  width: 40px;
  height: 40px;
  color: var(--accent);
}

.row-text {
  flex: 1;
  min-width: 0;
}

.row-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
  font-size: 1.02rem;
}

.row-desc {
  display: block;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  color: var(--text-muted);
  font-size: 0.88rem;
}

.row-chevron {
  flex: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  line-height: 1;
}

.row-quick {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  padding: 0 0.9rem 0.8rem;
}

.quick-link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 0.8rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg);
  color: var(--accent);
  font-weight: 600;
  font-size: 0.92rem;
}

.quick-link:hover {
  border-color: var(--accent);
  text-decoration: none;
}

/* Picture index at the top of case pages */
.picture-index {
  margin-top: 1.25rem;
  scroll-margin-top: calc(var(--header-h, 56px) + 0.5rem);
}

.index-heading {
  margin: 0.9rem 0 0.4rem;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-muted);
}

.index-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.4rem;
}

.index-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  gap: 0.2rem;
  min-height: 44px;
  padding: 0.35rem 0.15rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 0.7rem;
  line-height: 1.15;
  text-align: center;
}

.index-item:hover {
  border-color: var(--accent);
  text-decoration: none;
}

.index-item svg {
  display: block;
  width: 100%;
  max-width: 64px;
  height: auto;
}

@media (min-width: 600px) {
  .index-grid {
    grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
  }
}

/* Case cards: picture left, name and mnemonic right, algorithm full width */
.case-card,
.step .case-card {
  scroll-margin-top: calc(var(--header-h, 56px) + 0.75rem);
}

.case-top {
  display: grid;
  grid-template-columns: minmax(0, 150px) minmax(0, 1fr);
  gap: 0.9rem;
  align-items: center;
}

.case-top.no-visual,
.case-top.stack {
  grid-template-columns: minmax(0, 1fr);
}

.case-top .case-visual {
  min-width: 0;
}

.case-top:not(.stack) .case-diagram svg,
.case-top:not(.stack) .case-diagram figure:only-child svg {
  width: 100%;
}

.case-mnemonic-line {
  margin: 0.3rem 0 0;
  font-weight: 600;
  color: var(--accent);
}

.case-alg code,
.case-alt code {
  font: 600 19px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  letter-spacing: 0.02em;
  word-spacing: 0.2em;
}

.case-libby code {
  font: 600 16px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  letter-spacing: 0.04em;
}

.case-more > summary {
  padding: 0.75rem 0;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--accent);
  cursor: pointer;
}

.case-more[open] > *:not(summary) {
  margin-top: 0.5rem;
}

.case-index-link {
  align-self: flex-end;
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  margin-top: -0.4rem;
  font-size: 0.85rem;
}

/* Keep screen on */
.awake-toggle {
  font: inherit;
  min-height: 44px;
  padding: 0 1rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}

.awake-toggle[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-contrast);
}

/* Touch targets: at least 44 px tall */
.btn,
.chip,
.view-toggle-buttons button,
.tabs a,
.step-pill,
.finder-clear {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
}

.chip,
.btn,
.view-toggle-buttons button {
  justify-content: center;
}

.finder-search input,
.finder-search select {
  min-height: 44px;
}

.case-solution summary,
.film-every summary,
.practice-moves summary {
  padding: 0.75rem 0;
}

.step-foot a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
}

.index-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.index-link {
  display: flex;
  align-items: center;
  min-height: 44px;
  padding: 0 0.9rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 0.95rem;
}

.index-link:hover {
  border-color: var(--accent);
  text-decoration: none;
}

.puzzle-label {
  scroll-margin-top: calc(var(--header-h, 56px) + 0.5rem);
}

/* Blindfolded cycles tabs (corner-cycles.html, edge-cycles.html) */
.scramble-text {
  display: block;
  overflow-wrap: anywhere;
  white-space: normal;
}

.bld-example {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1rem;
  align-items: start;
}

.bld-example > * {
  min-width: 0;
}

.bld-cheapest {
  font-weight: 700;
  color: var(--accent);
}

.lookup-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.25rem;
  margin: 0.75rem 0;
}

.lookup-row label {
  display: grid;
  gap: 0.25rem;
  font-weight: 600;
}

.lookup-row select {
  min-height: 44px;
  min-width: 6rem;
  font: inherit;
  padding: 0.25rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
}

.pair-result h3 {
  margin: 0.5rem 0;
}

.pair-facts {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.25rem 1rem;
  margin: 0.5rem 0;
}

.pair-facts dt {
  color: var(--text-muted);
}

.pair-facts dd {
  margin: 0;
  overflow-wrap: anywhere;
}

@media (min-width: 720px) {
  .bld-example {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }
}

.bld-example-net {
  width: 100%;
  max-width: 24rem;
}
