/* Cube Design's own light look (07-visual.md), with dark for the night. */
:root {
  --ground: #f1f3ee;
  --card: #ffffff;
  --soft: #f6f8f5;
  --ink: #1f2a26;
  --quiet: #5d6a64;
  --line: #dae0d9;
  --circle: #e2e9e2;
  --pale: #e3e7e1;
  --pale-ink: #87938c;
  --cube-top: #f9fbf8;
  --cube-left: #e9eee9;
  --cube-right: #dfe6e0;
  --cube-edge: #cdd8d0;
  --sticker-edge: rgba(31, 45, 39, 0.28);
  --accent: #c8693f;
  --focus: #5f9a80;
  --font: 'Nunito', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, monospace;
  --turn: 380ms cubic-bezier(0.3, 0.7, 0.2, 1);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --ground: #171b19;
    --card: #212623;
    --soft: #1c211e;
    --ink: #e9eee9;
    --quiet: #a2aea7;
    --line: #323a35;
    --circle: #232b27;
    --pale: #3a423e;
    --pale-ink: #8e9b94;
    --cube-top: #3b443f;
    --cube-left: #323a36;
    --cube-right: #2b322e;
    --cube-edge: #48524c;
    --sticker-edge: rgba(0, 0, 0, 0.35);
    --accent: #f0a27a;
    color-scheme: dark;
  }
}
:root[data-theme='dark'] {
  --ground: #171b19;
  --card: #212623;
  --soft: #1c211e;
  --ink: #e9eee9;
  --quiet: #a2aea7;
  --line: #323a35;
  --circle: #232b27;
  --pale: #3a423e;
  --pale-ink: #8e9b94;
  --cube-top: #3b443f;
  --cube-left: #323a36;
  --cube-right: #2b322e;
  --cube-edge: #48524c;
  --sticker-edge: rgba(0, 0, 0, 0.35);
  --accent: #f0a27a;
  color-scheme: dark;
}

@view-transition {
  navigation: auto;
}
::view-transition-group(*) {
  animation-duration: 380ms;
  animation-timing-function: cubic-bezier(0.3, 0.7, 0.2, 1);
}

* {
  box-sizing: border-box;
}
html {
  -webkit-text-size-adjust: 100%;
}
body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.55;
  -webkit-tap-highlight-color: transparent;
  touch-action: pan-x pan-y;
}
a {
  color: inherit;
}
a:focus-visible,
button:focus-visible,
select:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  border-radius: 8px;
}
.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.page {
  max-width: 760px;
  margin: 0 auto;
  padding: max(14px, env(safe-area-inset-top, 0px)) 16px 40px;
}

/* ---- head ---- */
.head {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
}
.head .grow {
  flex: 1;
}
.brand,
.back {
  text-decoration: none;
  font-weight: 800;
}
.back {
  font-size: 22px;
  color: var(--quiet);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 6px 4px 0;
}
.back span {
  font-size: 15px;
}

/* ---- hero: the cube on top, in its circle ---- */
.hero {
  display: grid;
  justify-items: center;
  text-align: center;
  padding: 18px 0 8px;
}
.circle {
  width: 210px;
  height: 210px;
  border-radius: 50%;
  background: var(--circle);
  display: grid;
  place-items: center;
  touch-action: pan-y;
}
.hero.small .circle {
  width: 160px;
  height: 160px;
}
.hero h1 {
  margin: 16px 0 4px;
  font-size: 34px;
  line-height: 1.15;
  font-weight: 800;
  letter-spacing: -0.01em;
}
.hero.close h1 {
  font-size: 26px;
  max-width: 560px;
}
.hero .sub {
  margin: 0;
  color: var(--quiet);
}
.intro {
  max-width: 560px;
  color: var(--quiet);
}
.intro p {
  margin: 8px 0;
}
.note {
  text-align: center;
  color: var(--quiet);
  font-size: 15px;
  max-width: 520px;
  margin: 12px auto 18px;
}

/* ---- cubes ---- */
svg.cube {
  overflow: visible;
  display: block;
}
svg.cube .side {
  stroke: var(--cube-edge);
  stroke-width: 0.6;
}
svg.cube .side.top {
  fill: var(--cube-top);
}
svg.cube .side.left {
  fill: var(--cube-left);
}
svg.cube .side.right {
  fill: var(--cube-right);
}
svg.cube .sticker {
  stroke: var(--sticker-edge);
  stroke-width: 1;
  transition: fill var(--turn);
}
svg.cube .sticker.pale {
  fill: var(--pale);
  stroke: none;
}
svg.cube .hint {
  fill: none;
  stroke: var(--pale-ink);
  stroke-dasharray: 3 3;
  opacity: 0.5;
}


/* ---- tiles: a complete square (principle 24); app.js sets how many across ---- */
.square {
  display: grid;
  grid-template-columns: repeat(var(--cols, 2), minmax(0, 1fr));
  gap: 12px;
}
.square > .tile,
.square > .place {
  aspect-ratio: 1;
  min-width: 0;
}
.square > .tile {
  align-content: center;
}
.place {
  border: 2px dashed var(--line);
  border-radius: 20px;
}
.tile {
  text-decoration: none;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 12px 10px;
  display: grid;
  justify-items: center;
  align-content: start;
  gap: 6px;
  text-align: center;
  overflow: hidden;
}
.tile:hover {
  border-color: var(--pale-ink);
}
.tile .pic {
  min-height: 52px;
  display: grid;
  place-items: center;
}
.tile .t {
  font-size: 16px;
  font-weight: 800;
  line-height: 1.2;
}
.tile .m {
  font-size: 13px;
  line-height: 1.35;
  color: var(--quiet);
}
.tile .t,
.tile .m {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
  overflow-wrap: anywhere;
}
.tile.pale {
  background: transparent;
  border: 2px dashed var(--line);
  color: var(--quiet);
}
.tile.pale .t {
  font-weight: 600;
}

/* ---- one piece, opened ---- */
.chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  margin-top: 12px;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--card);
  border: 1px solid var(--line);
}
.chip i {
  width: 10px;
  height: 10px;
  border-radius: 3px;
}
a.chip {
  text-decoration: none;
}
.chip i.ring {
  border: 2px solid var(--accent);
}
.chip.unknown {
  color: var(--quiet);
  border-style: dashed;
}
.chip.unknown i {
  border: 1.5px dashed var(--pale-ink);
}
.square + .text {
  margin-top: 24px;
}
.text {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 6px 20px 14px;
  margin-top: 18px;
  overflow-wrap: anywhere;
}
.text h2 {
  font-size: 22px;
  margin: 26px 0 6px;
}
.text h3 {
  font-size: 18px;
  margin: 20px 0 6px;
}
.text li {
  margin: 6px 0;
}
.text code {
  font-family: var(--mono);
  font-size: 0.85em;
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 1px 5px;
}
.text a {
  color: var(--accent);
  text-underline-offset: 3px;
}
.text em:only-child {
  color: var(--quiet);
}
.table {
  overflow-x: auto;
  margin: 14px -20px;
  padding: 0 20px;
}
.text table {
  border-collapse: collapse;
  font-size: 15px;
  width: max-content;
  min-width: 100%;
}
.text th,
.text td {
  text-align: left;
  vertical-align: top;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
}
.text th {
  font-size: 12px;
  color: var(--quiet);
}
.text th,
.text td {
  min-width: 6.5em;
  max-width: 17em;
}
.text td:first-child {
  font-weight: 700;
}
.near {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 16px;
  font-weight: 700;
  font-size: 15px;
}
.near a {
  text-decoration: none;
  color: var(--quiet);
}

/* ---- figures ---- */
.strip {
  margin: 18px 0;
  padding: 16px 8px;
  background: var(--soft);
  border-radius: 16px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 14px;
}
.strip div {
  display: grid;
  justify-items: center;
  gap: 8px;
  max-width: 150px;
  text-align: center;
  font-size: 13px;
  color: var(--quiet);
}
.strip i {
  font-style: normal;
  font-size: 22px;
  color: var(--pale-ink);
}

/* ---- how it grew ---- */
.vers {
  list-style: none;
  padding: 0;
  margin: 18px 0 0;
  display: grid;
  gap: 12px;
}
.ver {
  display: flex;
  gap: 16px;
  align-items: center;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 14px 16px;
}
.ver .pic {
  flex: none;
}
.ver h2 {
  margin: 0;
  font-size: 22px;
}
.ver h2 a {
  text-decoration: none;
}
.ver h2 span {
  font-size: 14px;
  font-weight: 700;
  color: var(--quiet);
}
.ver p {
  margin: 4px 0;
  font-size: 14px;
  color: var(--quiet);
}
.ver p a {
  color: var(--accent);
}

.foot {
  margin-top: 40px;
  text-align: center;
  font-size: 13px;
  color: var(--quiet);
}
.foot p {
  margin: 4px 0;
}

@media (max-width: 420px) {
  .ver {
    flex-direction: column;
    align-items: flex-start;
  }
}
@media (prefers-reduced-motion: reduce) {
  ::view-transition-group(*) {
    animation: none;
  }
  svg.cube .sticker {
    transition: none;
  }
}

.updated {
  font-size: 13px;
  color: var(--quiet);
}
.hero .updated {
  margin: 0 0 6px;
}

/* Pictures in a piece's text (a violation's screen), never wider than the text. */
.text img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 1rem 0;
  border-radius: 14px;
  border: 1px solid var(--line);
}

/* A title alone on its tile may take more lines. */
.tile .t:last-child {
  -webkit-line-clamp: 4;
  line-clamp: 4;
}
/* A folded corner: the piece has a cube inside (05-patterns.md). */
.tile.folded {
  position: relative;
}
.tile.folded::after {
  content: '';
  position: absolute;
  top: -1px;
  right: -1px;
  width: 22px;
  height: 22px;
  background: linear-gradient(225deg, var(--ground) 50%, var(--pale) 50%);
  border-bottom-left-radius: 8px;
}
