/* mintmark: tokens + shell + shared components.
   Page styles live in /pages/<route>.css, scoped under .page-<route>. */

:root {
  --ink: #000;
  --ink-2: #0b0b0b;
  --ink-3: #141414;
  --line: #2a2a2a;
  --line-2: #5c5c5c;
  --paper: #fff;
  --mute: #8a8a8a;
  --lime: #C6F24E;
  --lime-ink: #000;

  --px: 4px;
  --font-display: 'Silkscreen', ui-monospace, monospace;
  --font-body: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace;

  --topbar-h: 64px;
  --nav-h: 0px;               /* mobile bottom nav height, set in the media query below */
  --safe-b: env(safe-area-inset-bottom, 0px);
  --page-max: 1120px;
  --gutter: 20px;

  /* 1-bit dither tiles */
  --dither-50: repeating-conic-gradient(var(--paper) 0 25%, transparent 0 50%) 0 0 / 4px 4px;
  --dither-dim: repeating-conic-gradient(#333 0 25%, transparent 0 50%) 0 0 / 4px 4px;

  color-scheme: dark;
}

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

html { background: var(--ink); -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  min-height: 100dvh;
  background: transparent;   /* html paints the black, so the fixed .sky layer shows through */
  color: var(--paper);
  font: 400 15px/1.6 var(--font-body);
  -webkit-font-smoothing: antialiased;
}
img { display: block; max-width: 100%; }
img[src$=".png"] { image-rendering: pixelated; }
a { color: inherit; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3, h4, p { margin: 0; }
::selection { background: var(--lime); color: var(--lime-ink); }

:focus-visible { outline: 2px solid var(--lime); outline-offset: 2px; }
#page:focus { outline: none; }

.skip {
  position: absolute; left: 8px; top: -60px; z-index: 100;
  background: var(--lime); color: var(--lime-ink);
  font: 400 12px/1 var(--font-display); padding: 10px 12px; text-decoration: none;
}
.skip:focus { top: 8px; }
.sr-only {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ==========================================================================
   Shell
   ========================================================================== */

/* sky: fixed plus-sign star layer behind everything */
.sky { position: fixed; inset: 0; z-index: -1; pointer-events: none; }

.topbar {
  position: sticky; top: 0; z-index: 20;
  background: var(--ink);
}
.topbar__inner {
  max-width: var(--page-max);
  margin: 0 auto;
  height: var(--topbar-h);
  padding: 0 var(--gutter);
  display: flex; align-items: center; justify-content: space-between; gap: 24px;
}

/* logo + wordmark. The source PNGs have generous transparent padding,
   so each sits in a fixed window and is offset to the drawn part. */
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; flex: none; }
.brand__logo { width: 38px; height: 38px; overflow: hidden; position: relative; flex: none; }
.brand__logo img {
  position: absolute; width: 64px; max-width: none; height: auto;
  left: -14px; top: -12px;
}
.brand__word { width: 136px; height: 22px; overflow: hidden; position: relative; flex: none; }
.brand__word img {
  position: absolute; width: 160px; max-width: none; height: auto;
  left: -16px; top: -22px;
}
/* the brand PNGs are drawn large and shown small; smooth downscaling keeps the thin strokes and the lime dot */
.brand img { image-rendering: auto; }
.brand:hover .brand__logo img { animation: brand-hop .4s steps(2) 1; }
@keyframes brand-hop { 50% { transform: translateY(-2px); } }

/* 5-step nav (desktop: inline in the top bar) */
.steps { display: flex; align-items: stretch; gap: 2px; }
.step {
  position: relative;
  display: flex; align-items: baseline; gap: 8px;
  padding: 10px 12px 10px 22px;
  text-decoration: none;
  color: var(--mute);
  font: 400 13px/1 var(--font-display);
  letter-spacing: .1em;
  text-transform: lowercase;
  transition: color .12s steps(2);
}
.step__num { font-size: 10px; color: var(--line-2); letter-spacing: .08em; }
.step::before {               /* the pixel slot: empty square, lime when active */
  content: ''; position: absolute; left: 8px; top: 50%;
  width: 6px; height: 6px; margin-top: -4px;
  box-shadow: inset 0 0 0 1px var(--line-2);
}
.step:hover { color: var(--paper); }
.step:hover::before { box-shadow: inset 0 0 0 1px var(--paper); }
.step[aria-current] { color: var(--paper); }
.step[aria-current] .step__num { color: var(--mute); }
.step[aria-current]::before { background: var(--lime); box-shadow: none; }
.step[aria-current]::after {  /* 2px pixel underline under the active label */
  content: ''; position: absolute; left: 22px; right: 12px; bottom: 2px; height: 2px;
  background: var(--paper);
}

/* page frame */
.page {
  display: block;
  max-width: var(--page-max);
  margin: 0 auto;
  padding: 40px var(--gutter) calc(64px + var(--nav-h) + var(--safe-b));
  min-height: calc(100vh - var(--topbar-h));
}
.page.is-entering > * { animation: page-in .28s steps(4) both; }
@keyframes page-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ==========================================================================
   Atmosphere
   ========================================================================== */

/* .stars: sparse plus-sign star layer. Two tiles of different sizes so the repeat is hard to see. */
.stars {
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='360' height='300' shape-rendering='crispEdges'%3E%3Cg fill='%23707070'%3E%3Cpath d='M58 40h2v6h-2zM56 42h6v2h-6z'/%3E%3Cpath d='M290 196h2v10h-2zM286 200h10v2h-10z'/%3E%3C/g%3E%3Cg fill='%235a5a5a'%3E%3Cpath d='M210 90h2v6h-2zM208 92h6v2h-6z'/%3E%3Crect x='140' y='250' width='2' height='2'/%3E%3Crect x='330' y='60' width='2' height='2'/%3E%3Crect x='20' y='170' width='2' height='2'/%3E%3C/g%3E%3C/svg%3E"),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='530' height='470' shape-rendering='crispEdges'%3E%3Cg fill='%23444444'%3E%3Cpath d='M400 120h2v6h-2zM398 122h6v2h-6z'/%3E%3Cpath d='M110 360h2v6h-2zM108 362h6v2h-6z'/%3E%3Crect x='260' y='30' width='2' height='2'/%3E%3Crect x='480' y='410' width='2' height='2'/%3E%3Crect x='60' y='240' width='2' height='2'/%3E%3C/g%3E%3Cg fill='%23bbbbbb'%3E%3Crect x='330' y='300' width='2' height='2'/%3E%3C/g%3E%3C/svg%3E");
  background-repeat: repeat, repeat;
  background-position: 0 0, 170px 90px;
}
.sky.stars::after {             /* a few stars that blink, stepped */
  content: ''; position: absolute; inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='610' height='420' shape-rendering='crispEdges'%3E%3Cg fill='%23909090'%3E%3Cpath d='M480 70h2v6h-2zM478 72h6v2h-6z'/%3E%3Crect x='150' y='310' width='2' height='2'/%3E%3C/g%3E%3C/svg%3E");
  animation: twinkle 3.2s steps(1) infinite;
}
@keyframes twinkle { 0%, 70% { opacity: 1; } 71%, 100% { opacity: 0; } }

/* .dither: 1-bit checker texture utility */
.dither { background: var(--dither-50); }
.dither--dim { background: var(--dither-dim); }

/* .dither-rule: a 12px divider that fades from 50% checker to sparse dots, like the banner's dithered sky */
.dither-rule {
  height: 10px;
  background:
    repeating-conic-gradient(var(--paper) 0 25%, transparent 0 50%) 0 0 / 4px 4px repeat-x,
    conic-gradient(from 270deg at 2px 2px, var(--paper) 25%, transparent 0) 0 4px / 4px 4px repeat-x,
    conic-gradient(from 270deg at 2px 2px, var(--paper) 25%, transparent 0) 2px 8px / 8px 4px repeat-x;
  opacity: .9;
}
.topbar .dither-rule { opacity: .35; }

/* .pixel-dot: the inline lime square */
.pixel-dot {
  display: inline-block; flex: none;
  width: 8px; height: 8px;
  background: var(--lime);
  vertical-align: baseline;
}

/* .caret: blinking block cursor (extra) */
.caret {
  display: inline-block; width: .55em; height: .9em; margin-left: .12em;
  background: var(--paper); vertical-align: -0.05em;
  animation: blink 1s steps(1) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

/* ==========================================================================
   Type
   ========================================================================== */

.label {
  display: flex; align-items: center; gap: 8px;
  font: 400 11px/1.3 var(--font-display);
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--mute);
}
.title {
  font: 400 clamp(28px, 7.4vw, 52px)/1.05 var(--font-display);
  letter-spacing: .04em;
  text-transform: lowercase;
  color: var(--paper);
  text-wrap: balance;
}
.lede {
  font: 400 15px/1.6 var(--font-body);
  color: var(--mute);
  max-width: 58ch;
}

/* page header + bottom "next" bar */
.page-head { display: grid; gap: 14px; margin-bottom: 36px; }
.page-head .label { margin-bottom: 2px; }

.page-next {
  position: relative;
  margin-top: 56px;
  padding-top: 26px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.page-next::before {
  content: ''; position: absolute; left: 0; right: 0; top: 0; height: 10px;
  background:
    repeating-conic-gradient(var(--paper) 0 25%, transparent 0 50%) 0 0 / 4px 4px repeat-x,
    conic-gradient(from 270deg at 2px 2px, var(--paper) 25%, transparent 0) 0 4px / 4px 4px repeat-x,
    conic-gradient(from 270deg at 2px 2px, var(--paper) 25%, transparent 0) 2px 8px / 8px 4px repeat-x;
  opacity: .3;
}
.page-next__hint { font-size: 13px; color: var(--mute); }
.page-next__hint:empty { display: none; }
.page-next .btn--primary { margin-left: auto; }

/* ==========================================================================
   Buttons
   ========================================================================== */

.btn {
  --btn-bg: transparent; --btn-fg: var(--paper); --btn-bd: var(--paper);
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 44px;
  padding: 0 18px;
  border: 2px solid var(--btn-bd);
  background: var(--btn-bg);
  color: var(--btn-fg);
  font: 400 13px/1 var(--font-display);
  letter-spacing: .1em;
  text-transform: lowercase;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.btn:hover { --btn-bg: var(--paper); --btn-fg: var(--ink); }
.btn:active { transform: translate(0, 2px); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .4; cursor: not-allowed; transform: none; }
.btn--primary { --btn-bg: var(--lime); --btn-fg: var(--lime-ink); --btn-bd: var(--lime); }
.btn--primary:hover { --btn-bg: var(--paper); --btn-fg: var(--ink); --btn-bd: var(--paper); }
.btn--ghost { --btn-bd: transparent; color: var(--mute); padding: 0 10px; }
.btn--ghost:hover { --btn-bg: transparent; --btn-fg: var(--paper); --btn-bd: var(--line-2); }
.btn--sm { min-height: 34px; padding: 0 12px; font-size: 11px; }           /* extra */
.btn--block { display: flex; width: 100%; }                                /* extra */
.btn > span[aria-hidden] { transition: transform .15s steps(2); }
.btn:hover > span[aria-hidden] { transform: translateX(3px); }

/* ==========================================================================
   Stamp: perforated postage-stamp card
   The perforated paper rim is drawn on ::before (masked), so the selected
   lime pixel on ::after can sit outside the edge without being clipped.
   ========================================================================== */

.stamp {
  --rim: var(--paper);          /* colour of the perforated edge */
  --face: var(--ink-2);         /* card fill */
  --edge: 4px;                  /* rim thickness */
  --hole: 4px;                  /* perforation size (square) */
  --perf: 11px;                 /* perforation spacing */
  position: relative;
  isolation: isolate;
  display: block;
  padding: calc(var(--edge) + 18px);
  color: var(--paper);
  background: none;
  border: 0;
  text-align: left;
}
.stamp::before {
  content: '';
  position: absolute; inset: 0; z-index: -1;
  background:
    linear-gradient(var(--face) 0 0) center / calc(100% - 2 * var(--edge)) calc(100% - 2 * var(--edge)) no-repeat,
    var(--rim);
  /* square holes centred on the edge line: two crossed strips per tile leave a square hole,
     and a solid inner rectangle covers the holes that would land inside the card */
  -webkit-mask:
    linear-gradient(90deg, #000 calc(50% - var(--hole) / 2), transparent 0 calc(50% + var(--hole) / 2), #000 0) calc(var(--perf) / -2) calc(var(--perf) / -2) / var(--perf) var(--perf) round,
    linear-gradient(#000 calc(50% - var(--hole) / 2), transparent 0 calc(50% + var(--hole) / 2), #000 0) calc(var(--perf) / -2) calc(var(--perf) / -2) / var(--perf) var(--perf) round,
    linear-gradient(#000 0 0) center / calc(100% - var(--hole)) calc(100% - var(--hole)) no-repeat;
          mask:
    linear-gradient(90deg, #000 calc(50% - var(--hole) / 2), transparent 0 calc(50% + var(--hole) / 2), #000 0) calc(var(--perf) / -2) calc(var(--perf) / -2) / var(--perf) var(--perf) round,
    linear-gradient(#000 calc(50% - var(--hole) / 2), transparent 0 calc(50% + var(--hole) / 2), #000 0) calc(var(--perf) / -2) calc(var(--perf) / -2) / var(--perf) var(--perf) round,
    linear-gradient(#000 0 0) center / calc(100% - var(--hole)) calc(100% - var(--hole)) no-repeat;
}
/* the lime corner pixel, just off the top-right, like the logo */
.stamp::after {
  content: '';
  position: absolute; top: -14px; right: -14px;
  width: 10px; height: 10px;
  background: var(--lime);
  opacity: 0;
  transform: scale(0);
  transition: transform .18s steps(3), opacity .18s steps(3);
}
.stamp.is-selected::after { opacity: 1; transform: none; }

/* inverted: white stamp, black text */
.stamp--paper { --rim: var(--paper); --face: var(--paper); color: var(--ink); }
.stamp--paper .label, .stamp--paper .lede { color: #555; }

/* clickable stamps (button.stamp / a.stamp) */
button.stamp, a.stamp { cursor: pointer; text-decoration: none; font: inherit; width: 100%; -webkit-tap-highlight-color: transparent; }
button.stamp:hover, a.stamp:hover { --face: var(--ink-3); }
button.stamp--paper:hover, a.stamp--paper:hover { --face: #f1f1f1; }
button.stamp:not(.is-selected), a.stamp:not(.is-selected) { --rim: var(--line-2); }
button.stamp:not(.is-selected):hover, a.stamp:not(.is-selected):hover { --rim: #9a9a9a; }
button.stamp:active, a.stamp:active { transform: translateY(2px); }
.stamp--muted { --rim: var(--line-2); }                                     /* extra */

/* ==========================================================================
   Form fields
   ========================================================================== */

.field { display: grid; gap: 8px; min-width: 0; }
.field > .label { justify-content: space-between; }
.field__hint { font-size: 12px; color: var(--mute); }                       /* extra */

.input, .textarea {
  width: 100%;
  background: var(--ink);
  color: var(--paper);
  border: 1px solid #9a9a9a;
  padding: 11px 12px;
  font: 400 16px/1.5 var(--font-body);   /* 16px stops iOS zooming on focus */
  caret-color: var(--lime);
  -webkit-appearance: none;
  appearance: none;
}
.input:hover, .textarea:hover { border-color: var(--paper); }
.input:focus, .textarea:focus { outline: 2px solid var(--lime); outline-offset: 2px; border-color: var(--paper); }
.input::placeholder, .textarea::placeholder { color: #5f5f5f; }
.textarea { min-height: 120px; resize: vertical; }

/* range: square thumb, lime filled part, dithered track. --fill is kept in sync by app.js. */
.range {
  --fill: 50%;
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 28px; margin: 0;
  background: transparent;
  cursor: pointer;
  touch-action: pan-y;
}
.range:focus { outline: none; }
.range::-webkit-slider-runnable-track {
  height: 12px;
  border: 0;
  background:
    linear-gradient(var(--lime) 0 0) 0 0 / var(--fill) 100% no-repeat,
    repeating-conic-gradient(#3d3d3d 0 25%, var(--ink) 0 50%) 0 0 / 4px 4px;
  box-shadow: 0 0 0 2px var(--paper);
}
.range::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 20px; height: 24px;
  margin-top: -6px;
  background: var(--paper);
  border: 4px solid var(--ink);
  box-shadow: 0 0 0 2px var(--paper);
}
.range:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 2px var(--lime); }
.range::-moz-range-track {
  height: 12px; border: 0;
  background: repeating-conic-gradient(#3d3d3d 0 25%, var(--ink) 0 50%) 0 0 / 4px 4px;
  box-shadow: 0 0 0 2px var(--paper);
}
.range::-moz-range-progress { height: 12px; background: var(--lime); }
.range::-moz-range-thumb {
  width: 12px; height: 16px;
  background: var(--paper);
  border: 4px solid var(--ink);
  border-radius: 0;
  box-shadow: 0 0 0 2px var(--paper);
}
.range:focus-visible::-moz-range-thumb { box-shadow: 0 0 0 2px var(--lime); }

/* ==========================================================================
   Chips
   ========================================================================== */

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 7px 3px;
  border: 1px solid var(--line-2);
  font: 400 10px/1.2 var(--font-display);
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--paper);
  white-space: nowrap;
}
.chip--lime { background: var(--lime); border-color: var(--lime); color: var(--lime-ink); }
.chip--paper { background: var(--paper); border-color: var(--paper); color: var(--ink); }  /* extra */

/* ==========================================================================
   Toast
   ========================================================================== */

.toast {
  position: fixed; z-index: 60;
  left: 50%; bottom: calc(20px + var(--nav-h) + var(--safe-b));
  max-width: min(420px, calc(100vw - 32px));
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px;
  background: var(--ink);
  color: var(--paper);
  border: 2px solid var(--paper);
  font: 400 13px/1.4 var(--font-body);
  transform: translate(-50%, 12px);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: transform .2s steps(3), opacity .2s steps(3), visibility 0s linear .2s;
}
.toast::before { content: ''; flex: none; width: 8px; height: 8px; background: var(--lime); }
.toast:empty { display: none; }
.toast.show { transform: translate(-50%, 0); opacity: 1; visibility: visible; transition-delay: 0s; }

/* ==========================================================================
   Dialog base (extra): square, black, paper border
   ========================================================================== */

dialog {
  width: min(460px, calc(100vw - 32px));
  padding: 0;
  border: 2px solid var(--paper);
  background: var(--ink);
  color: var(--paper);
}
dialog::backdrop { background: var(--dither-dim), rgba(0, 0, 0, .8); }

/* ==========================================================================
   Error state for a step that failed to load
   ========================================================================== */
.page-error .lede { margin-top: 8px; }

/* ==========================================================================
   Mobile: compact fixed bottom nav
   ========================================================================== */

@media (max-width: 760px) {
  :root { --nav-h: 64px; --gutter: 16px; --topbar-h: 56px; }

  .topbar__inner { justify-content: center; }

  .steps {
    position: fixed; z-index: 30;
    left: 0; right: 0; bottom: 0;
    height: calc(var(--nav-h) + var(--safe-b));
    padding-bottom: var(--safe-b);
    display: grid; grid-template-columns: repeat(5, 1fr); gap: 0;
    background: var(--ink);
    border-top: 2px solid var(--paper);
  }
  .step {
    flex-direction: column; align-items: center; justify-content: center; gap: 6px;
    padding: 14px 2px 8px;
    font-size: 11px;
    -webkit-tap-highlight-color: transparent;
  }
  .step + .step { box-shadow: inset 1px 0 0 var(--line); }
  .step::before { left: 50%; top: 8px; margin: 0 0 0 -3px; }
  .step__num { font-size: 9px; }
  .step[aria-current] { background: var(--ink-2); }
  .step[aria-current]::after { left: 30%; right: 30%; bottom: 6px; }
  .step__num { order: 0; }

  .page { padding-top: 28px; }
  .page-head { margin-bottom: 28px; }
  .page-next { flex-direction: column; align-items: stretch; }
  .page-next .btn--primary { margin-left: 0; width: 100%; min-height: 52px; }
}

/* ==========================================================================
   Reduced motion
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    transition-delay: 0s !important;
  }
  .sky.stars::after { animation: none; }
  .caret { animation: none; }
}
