/* "What is an SDLC — in eight frames": the pixel-art explainer strip.
   Used full size on /sdlc (under #always) and compact on the homepage (#whatis).
   Sprites: site/assets/sdlc/*.png from tools/make_sdlc_strip.py — a 64x40 game-pixel grid
   exported at 6x (384x240). They are shown at 4x (256x160), 3x (192x120) or 2x (128x80):
   integer multiples of the grid, so every game pixel stays square and crisp.
   Frames with a "-b" image flip between before and after; reduced motion shows the after state.
   Tokens come from the page (stories.css on /sdlc, the inline :root on the homepage);
   fonts are named here because the two pages define --mono differently. */

.sx {
  --sx-bg: var(--bg, #0E0E14);
  --sx-panel: var(--panel, #17171F);
  --sx-line: var(--line, #2C2C3A);
  --sx-white: var(--white, #F4F4F8);
  --sx-muted: var(--muted, #A9A9BA);
  --sx-blue: var(--blue, #0098EB);
  --sx-yellow: var(--yellow, #FFD166);
  --sx-head: 'Space Grotesk', system-ui, sans-serif;
  --sx-body: 'Outfit', system-ui, sans-serif;
  --sx-pixel: 'Press Start 2P', monospace;
  --sx-pic: 256px;             /* on-screen sprite width, always a multiple of 64 */
  /* full-bleed: out of the narrow column to the viewport edges */
  width: 100vw;
  margin: 44px calc(50% - 50vw) 8px;
  padding: 34px 0 30px;
  background: var(--sx-bg);
  border-top: 4px solid var(--sx-line);
  border-bottom: 4px solid var(--sx-line);
  color: var(--sx-white);
}
.sx *, .sx *::before, .sx *::after { box-sizing: border-box; }

.sx-in { width: min(100% - 32px, 1180px); margin-inline: auto; }

.sx .sx-eye {
  font-family: var(--sx-pixel);
  font-size: 10px;
  line-height: 1.8;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--sx-blue);
  margin: 0 0 18px;
}

/* the row: a snap-scrolling strip on phones and tablets, a 4x2 grid on desktop */
.sx .sx-row {
  list-style: none;
  margin: 0;
  padding: 0 0 12px;
  display: flex;
  gap: 12px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: var(--sx-line) transparent;
}
.sx .sx-f {
  margin: 0;
  padding: 0;
  flex: 0 0 auto;
  scroll-snap-align: start;
  counter-increment: none;
}
.sx .sx-f::marker { content: none; }

.sx-tile {
  display: flex;
  flex-direction: column;
  height: 100%;
  width: calc(var(--sx-pic) + 22px);
  margin: 0;
  padding: 8px 8px 14px;
  border: 3px solid var(--sx-line);
  background: var(--sx-panel);
  color: inherit;
  text-decoration: none;
}
a.sx-tile:hover { border-color: var(--sx-blue); text-decoration: none; color: inherit; }
a.sx-tile:focus-visible { outline: 3px solid var(--sx-yellow); outline-offset: 3px; }

.sx-pic {
  position: relative;
  width: var(--sx-pic);
  aspect-ratio: 64 / 40;
  background: var(--sx-bg);
  overflow: hidden;
}
.sx .sx-pic img {
  display: block;
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  margin: 0;
  border: 0;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}
/* before -> after, like a two-frame GIF */
.sx .sx-pic img.sx-b { opacity: 0; animation: sx-flip 3.6s step-end infinite; }
.sx .sx-f:nth-child(4) img.sx-b { animation-delay: .5s; }
.sx .sx-f:nth-child(5) img.sx-b { animation-delay: 1s; }
.sx .sx-f:nth-child(6) img.sx-b { animation-delay: 1.5s; }
.sx .sx-f:nth-child(7) img.sx-b { animation-delay: 2s; }
@keyframes sx-flip { 0% { opacity: 0; } 45% { opacity: 1; } 100% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  .sx .sx-pic img.sx-b { animation: none; opacity: 1; }
}

.sx figcaption, .sx .sx-cap {
  display: block;
  font-family: var(--sx-body);
  margin: 12px 2px 0;
  padding: 0;
  letter-spacing: 0;
  color: var(--sx-muted);
}
.sx-n {
  display: block;
  font-family: var(--sx-pixel);
  font-size: 9px;
  line-height: 1;
  letter-spacing: .06em;
  color: var(--sx-blue);
  margin-bottom: 8px;
}
.sx-t {
  display: block;
  font-family: var(--sx-head);
  font-weight: 700;
  font-size: 18px;
  line-height: 1.2;
  letter-spacing: -.01em;
  color: var(--sx-white);
}
.sx-c {
  display: block;
  font-size: 15px;
  font-weight: 400;
  line-height: 1.45;
  color: var(--sx-muted);
  margin-top: 6px;
}

.sx .sx-more {
  margin: 14px 0 0;
  font-family: var(--sx-body);
  font-size: 16px;
  line-height: 1.5;
  color: var(--sx-muted);
}
.sx-hint { display: inline; }

/* phones and small tablets: tiles run edge to edge, the first one aligned with the text column */
@media (max-width: 959px) {
  .sx-in { width: 100%; }
  .sx .sx-eye, .sx .sx-more { padding-inline: 16px; }
  .sx .sx-row { padding-inline: 16px; scroll-padding-inline: 16px; }
  .sx .sx-row::after { content: ""; flex: 0 0 4px; }
}

/* desktop: 4x2 grid; 3x sprites (192px) from 960px, 4x (256px) from 1200px */
@media (min-width: 960px) {
  .sx { --sx-pic: 192px; }
  .sx .sx-row {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    overflow: visible;
    padding-bottom: 0;
  }
  .sx-tile { width: 100%; align-items: center; }
  .sx figcaption { align-self: stretch; }
  .sx-hint { display: none; }
}
@media (min-width: 1200px) {
  .sx { --sx-pic: 256px; }
  .sx .sx-row { grid-template-columns: repeat(4, calc(var(--sx-pic) + 22px)); justify-content: space-between; }
}

/* ---------- compact version (homepage): smaller tiles, titles only, each tile links to /sdlc ---------- */
.sx.sx-mini {
  --sx-pic: 192px;
  margin: 34px 0 0;
  width: auto;
  padding: 0;
  background: none;
  border: 0;
}
.sx-mini .sx-in { width: 100%; }
.sx-mini .sx-tile { padding: 6px 6px 12px; }
.sx-mini .sx-t { font-size: 15px; line-height: 1.25; }
.sx-mini .sx-n { font-size: 9px; margin-bottom: 6px; }
.sx-mini .sx-cap { margin-top: 10px; }
@media (max-width: 899px) {
  .sx.sx-mini { margin-inline: calc(50% - 50vw); width: 100vw; }
}
@media (min-width: 900px) {
  .sx-mini .sx-hint { display: none; }
  .sx-mini .sx-eye, .sx-mini .sx-more { padding-inline: 0; }
  .sx-mini .sx-row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; overflow: visible; padding: 0; }
  .sx-mini .sx-row::after { content: none; }
  .sx-mini .sx-tile { width: 100%; align-items: center; }
  .sx-mini .sx-cap { align-self: stretch; }
  .sx-mini .sx-pic { width: var(--sx-pic); }
}
@media (min-width: 1280px) {
  .sx.sx-mini { --sx-pic: 128px; }
  .sx-mini .sx-row { grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 4px; }
  .sx-mini .sx-tile { width: 100%; padding: 3px 3px 10px; align-items: center; }
  .sx-mini .sx-cap { margin: 8px 2px 0; align-self: stretch; }
  .sx-mini .sx-t { font-size: 14px; }
}

/* ---------- "A tour of the dashboard, module by module" (/sdlc #modules) ----------
   Screens: site/assets/sdlc/screens/*.png from tools/make_sdlc_screens.py — a 320x200 grid
   exported at 3x (960x600). On desktop the image sits in a 968px monitor frame (4px border),
   so it shows at exactly 960x600: three screen pixels per game pixel. Phones get it full width.
   The tour leaves the 900px reading column: modules alternate screen-left / screen-right,
   and the first module of each group runs full width with its text below. */
.modules {
  --md-line: var(--line, #2C2C3A);
  --md-panel: var(--panel, #17171F);
  --md-panel2: var(--panel2, #1F1F2A);
  --md-ink: var(--ink, #12101A);
  --md-bg: var(--bg, #0E0E14);
  --md-white: var(--white, #F4F4F8);
  --md-muted: var(--muted, #A9A9BA);
  --md-c: var(--blue, #0098EB);
  --md-pixel: 'Press Start 2P', monospace;
  width: min(1400px, calc(100vw - 32px));
  position: relative;
  left: 50%;
  transform: translateX(-50%);
  margin: 64px 0 48px;
}
.modules *, .modules *::before, .modules *::after { box-sizing: border-box; }

/* intro: back in the reading measure */
.modules .mods-hd { max-width: 900px; margin: 0 auto 8px; }
article.post .modules .mods-hd h3 { font-size: clamp(26px, 1.6vw + 14px, 36px); line-height: 1.12; letter-spacing: -.015em; margin: 0 0 18px; }
article.post .modules .mods-hd p:last-child { margin: 0; }
.modules .mods-hd code {
  font-family: var(--mono, ui-monospace, monospace);
  font-size: .82em;
  color: var(--md-white);
  background: var(--md-panel);
  border: 2px solid var(--md-line);
  padding: 1px 6px;
  overflow-wrap: anywhere;
}

/* group = sub-chapter */
.modules .mods-grp { margin-top: 96px; }
.modules .g-blue { --md-c: var(--blue, #0098EB); }
.modules .g-green { --md-c: var(--green, #22C58E); }
.modules .g-yellow { --md-c: var(--yellow, #FFD166); }
.modules .mods-div {
  height: 16px;
  margin: 0 0 26px;
  border-bottom: 4px solid var(--md-line);
  background:
    linear-gradient(var(--md-c), var(--md-c)) left bottom / 120px 12px no-repeat,
    repeating-linear-gradient(90deg, var(--md-line) 0 8px, transparent 8px 16px) 136px 4px / calc(100% - 136px) 4px no-repeat;
}
article.post .modules .mods-k {
  display: flex;
  align-items: baseline;
  gap: 14px;
  font-family: var(--md-pixel);
  font-size: 10px;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--md-c);
  margin: 0 0 16px;
}
.modules .mods-k b { font-size: 26px; line-height: 1; font-weight: 400; }
article.post .modules h3.mods-g { font-size: clamp(32px, 2.4vw + 16px, 52px); line-height: 1.04; letter-spacing: -.02em; margin: 0 0 14px; }
article.post .modules .mods-gi { font-size: clamp(18px, .5vw + 15px, 21px); color: var(--md-muted); max-width: 60ch; margin: 0 0 8px; }

/* one module */
.modules .mod { margin: 72px 0 0; }
.modules .mon {
  margin: 0;
  border: 4px solid var(--md-line);
  background: var(--md-bg);
  box-shadow: 0 0 0 4px var(--md-ink), 10px 10px 0 4px var(--md-ink);
  min-width: 0;
}
.modules .mon-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  padding: 8px 10px;
  background: var(--md-panel2);
  border-bottom: 4px solid var(--md-line);
}
.modules .mon-bar i { flex: none; width: 8px; height: 8px; background: #FF5C7A; }
.modules .mon-bar i:nth-child(2) { background: #FFD166; }
.modules .mon-bar i:nth-child(3) { background: #22C58E; margin-right: 8px; }
.modules .mon-bar .t {
  font-family: var(--md-pixel);
  font-size: 9px;
  line-height: 1.4;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--md-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.modules .mon-bar .u {
  margin-left: auto;
  flex: none;
  font-family: var(--mono, ui-monospace, monospace);
  font-size: 11px;
  color: var(--md-muted);
  opacity: .7;
}
.modules .mon img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 8 / 5;
  max-width: none;
  margin: 0;
  border: 0;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.modules .mod-txt { margin-top: 30px; max-width: 640px; }
article.post .modules .mod-k {
  font-family: var(--md-pixel);
  font-size: 10px;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--md-c);
  margin: 0 0 14px;
}
.modules .mod-txt h4 {
  font-family: var(--head, 'Space Grotesk', system-ui, sans-serif);
  font-weight: 700;
  font-size: clamp(26px, 1.6vw + 14px, 36px);
  line-height: 1.12;
  letter-spacing: -.015em;
  color: var(--md-white);
  margin: 0 0 14px;
}
article.post .modules .mod-txt p:not(.mod-k):not(.stamp) { color: var(--md-muted); margin: 0 0 22px; }
article.post .modules .stamp {
  display: inline-flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 10px;
  margin: 0;
  padding: 10px 12px 9px;
  border: 3px solid var(--md-c);
  background: var(--md-bg);
  box-shadow: 4px 4px 0 var(--md-ink);
  font-family: var(--md-pixel);
  font-size: 10px;
  line-height: 1.6;
  letter-spacing: .03em;
  text-transform: uppercase;
  color: var(--md-c);
  transform: rotate(-1.5deg);
  transform-origin: left center;
}
.modules .stamp span { color: var(--md-muted); font-size: 8px; }

/* desktop: side by side, alternating; the group opener runs full width */
@media (min-width: 1100px) {
  .modules .mod:not(.full) {
    display: grid;
    grid-template-columns: minmax(0, 968px) minmax(300px, 1fr);
    gap: 56px;
    align-items: center;
  }
  .modules .mod.flip { grid-template-columns: minmax(300px, 1fr) minmax(0, 968px); }
  .modules .mod.flip .mon { order: 2; }
  .modules .mod:not(.full) .mod-txt { margin-top: 0; }
  .modules .mod.full .mon { max-width: 1188px; margin-inline: auto; }
  .modules .mod.full .mod-txt {
    max-width: 1188px;
    margin: 36px auto 0;
    display: grid;
    grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
    column-gap: 56px;
    align-items: start;
  }
  .modules .mod.full .mod-k, .modules .mod.full h4 { grid-column: 1; }
  .modules .mod.full .mod-txt p:not(.mod-k) { grid-column: 2; }
  .modules .mod.full .mod-txt h4 { grid-row: 2; }
  .modules .mod.full .mod-txt p:not(.mod-k):not(.stamp) { grid-row: 1 / span 2; }
  .modules .mod.full .stamp { grid-row: 3; justify-self: start; }
  .modules .mod { margin-top: 88px; }
}
@media (max-width: 599px) {
  .modules .mon { box-shadow: 0 0 0 3px var(--md-ink), 6px 6px 0 3px var(--md-ink); }
  .modules .mon-bar .u { display: none; }
  .modules .mods-grp { margin-top: 72px; }
  .modules .mod { margin-top: 56px; }
  .modules .mod-txt { margin-top: 24px; }
}
