/*
 * TANTALOS — machine face.
 *
 * Filter 14, neobrutalism, taken further than the first pass took it.
 *
 * WHAT CHANGED AND WHY
 *
 * The first version was a dark machine on a beige page: near-black board,
 * near-black slots, one accent colour. It was tidy, and tidy is the opposite of
 * what this style is. Neobrutalism is loud flat colour cut hard by a heavy
 * border, with a shadow that is a solid offset block rather than a blur.
 *
 * So there are no black FIELDS anywhere now. Every surface is saturated and the
 * sections deliberately clash. The borders stay very dark, because the border
 * is the thing doing the cutting - without a heavy edge, bright panels smear
 * into each other. They are deep indigo (#1A1130) rather than #000, which reads
 * as ink rather than as a hole in the screen.
 *
 * The slots went light too, and that fixed a real bug and not only a mood:
 * every item palette has a near-black OUTLINE by design, so against a near-black
 * slot the VOID palette had no silhouette at all. On cream, all twelve read.
 *
 * Mobile first. The base styles ARE the phone layout; 620px+ is the override.
 */

:root {
  --ink: #1A1130;       /* the dark that is not black. every border, all type */
  --paper: #FFE500;     /* the page itself. loud on purpose */
  --card: #FFF9E3;      /* panels that hold reading matter */
  --pink: #FF4FA3;
  --cyan: #35E0F0;
  --lime: #B9F227;
  --orange: #FF7A1A;
  --red: #FF2E2E;
  --slot: #FFF9E3;      /* slot interior. light, so every item outline reads */
  --slot-dead: #E3D9F5; /* an empty slot: drained, not switched off */

  --border: 4px solid var(--ink);
  --hard: 8px 8px 0 var(--ink);
  --hard-sm: 5px 5px 0 var(--ink);

  color-scheme: light;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  font: 14px/1.35 ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  -webkit-text-size-adjust: 100%;
}

body { padding: 14px; }
.wrap { max-width: 780px; margin: 0 auto; }

/* ------------------------------- masthead ------------------------------- */

.masthead {
  border: var(--border);
  background: var(--pink);
  color: var(--ink);
  padding: 16px 14px;
  box-shadow: var(--hard);
}

.masthead h1 {
  margin: 0;
  font-size: clamp(30px, 12vw, 60px);
  letter-spacing: 0.12em;
  line-height: 0.92;
}

.tagline {
  margin: 8px 0 0;
  font-size: 11px;
  letter-spacing: 0.18em;
  font-weight: 700;
}

/* --------------------------------- hero --------------------------------- */

.hero {
  margin-top: 14px;
  border: var(--border);
  background: var(--orange);
  color: var(--ink);
  padding: 14px;
  font-size: clamp(13px, 4.2vw, 20px);
  letter-spacing: 0.04em;
  font-weight: 700;
  box-shadow: var(--hard);
  word-break: break-word;
}

.hero.calm { background: var(--lime); }

/* ------------------------------- countdown ------------------------------ */

.strip {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 14px;
}

.panel {
  border: var(--border);
  background: var(--card);
  padding: 11px;
  box-shadow: var(--hard-sm);
}

/* Each tile a different colour. Uniform tiles read as a dashboard, and a
   dashboard is the one thing Filter 10 says this must never look like. */
.panel:nth-child(1) { background: var(--cyan); }
.panel:nth-child(2) { background: var(--lime); }
.panel:nth-child(3) { background: var(--card); }

.panel .k { font-size: 10px; letter-spacing: 0.16em; font-weight: 700; }

.panel .v {
  font-size: clamp(28px, 9.5vw, 46px);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.03em;
  line-height: 1.05;
  font-weight: 700;
}

.panel .sub { font-size: 10px; letter-spacing: 0.1em; opacity: 0.75; }

/* --------------------------------- board -------------------------------- */

.board {
  margin-top: 14px;
  border: var(--border);
  background: var(--cyan);
  padding: 10px;
  box-shadow: var(--hard);
}

.rowlabel {
  display: flex;
  align-items: baseline;
  gap: 9px;
  font-size: 10px;
  letter-spacing: 0.16em;
  margin: 10px 2px 5px;
  font-weight: 700;
}

.rowlabel b { font-size: 15px; letter-spacing: 0.08em; }
.rowlabel span { opacity: 0.7; }

.row { display: grid; grid-template-columns: repeat(5, 1fr); gap: 7px; }

.slot {
  position: relative;
  aspect-ratio: 3 / 4;
  border: 3px solid var(--ink);
  background: var(--slot);
  display: grid;
  place-items: center;
  overflow: hidden;
}

.slot svg { width: 84%; height: 84%; display: block; image-rendering: pixelated; }

/* STUCK: the item hangs tilted against the glass. It never falls. */
.slot.stuck { background: var(--pink); }
.slot.stuck svg { transform: rotate(-13deg) translateY(9%); }
.slot.stuck::after {
  content: "";
  position: absolute;
  inset: 0;
  border: 3px solid var(--ink);
}

.slot.empty { background: var(--slot-dead); }

.soldout {
  color: var(--ink);
  background: var(--red);
  padding: 3px 5px;
  font-size: clamp(7px, 2.1vw, 10px);
  letter-spacing: 0.08em;
  font-weight: 700;
  text-align: center;
  line-height: 1.15;
  border: 2px solid var(--ink);
}

.tag {
  position: absolute;
  left: 3px;
  bottom: 2px;
  font-size: 8px;
  letter-spacing: 0.08em;
  font-weight: 700;
  opacity: 0.55;
}

.marks {
  position: absolute;
  right: 2px;
  top: 2px;
  font-size: 8px;
  letter-spacing: 0.04em;
  font-weight: 700;
  background: var(--ink);
  color: var(--paper);
  padding: 1px 3px;
}

/* -------------------------- tray / rules / legend ------------------------ */

.tray, .rules, .legend {
  margin-top: 14px;
  border: var(--border);
  background: var(--card);
  box-shadow: var(--hard);
}

.tray h2, .rules h2, .legend h2 {
  margin: 0;
  padding: 10px 12px;
  border-bottom: var(--border);
  font-size: 11px;
  letter-spacing: 0.18em;
  font-weight: 700;
}

.tray h2 { background: var(--lime); }
.rules h2 { background: var(--cyan); }
.legend h2 { background: var(--pink); }

.trayitems {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(92px, 1fr));
  gap: 10px;
  padding: 12px;
}

.trayitem {
  border: 3px solid var(--ink);
  padding: 6px;
  background: var(--slot);
  box-shadow: 4px 4px 0 var(--ink);
}
.trayitem svg { width: 100%; aspect-ratio: 1; display: block; image-rendering: pixelated; }
.trayitem .n { font-size: 9px; margin-top: 5px; word-break: break-word;
               line-height: 1.25; font-weight: 700; }
.trayitem .c { font-size: 8px; letter-spacing: 0.05em; opacity: 0.65; }
.trayitem .m { font-size: 8px; background: var(--orange); display: inline-block;
               padding: 0 3px; margin-top: 3px; border: 1px solid var(--ink); }

.empty-note { padding: 16px 12px; font-size: 11px; letter-spacing: 0.06em;
              font-weight: 700; }

/* -------------------------------- rules --------------------------------- */

table { width: 100%; border-collapse: collapse; font-size: 11px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 2px solid var(--ink); }
th { font-size: 9px; letter-spacing: 0.14em; background: var(--lime); }
td b { font-size: 14px; }

.fee { padding: 12px; border-top: var(--border); font-size: 11px; line-height: 1.55; }
.fee b { background: var(--orange); padding: 1px 4px; border: 2px solid var(--ink); }

/* ------------------------------- legend --------------------------------- */

.legend dl { margin: 0; padding: 0; }
.legend dt { font-size: 11px; letter-spacing: 0.12em; padding: 10px 12px 0;
             font-weight: 700; }
.legend dd { margin: 0; padding: 3px 12px 10px; font-size: 11px;
             border-bottom: 2px solid var(--ink); line-height: 1.45; }
.legend dd:last-child { border-bottom: 0; }

/* ------------------------------ no wallet -------------------------------- */

.nowallet {
  margin-top: 14px;
  border: var(--border);
  background: var(--lime);
  padding: 14px;
  font-size: 11px;
  letter-spacing: 0.04em;
  line-height: 1.55;
  box-shadow: var(--hard);
}

.nowallet b { background: var(--ink); color: var(--paper); padding: 2px 5px; }

/* ------------------------------ nav buttons ------------------------------ */

.navrow { margin-top: 14px; }

.navbtn {
  display: block;
  border: var(--border);
  background: var(--card);
  color: var(--ink);
  padding: 14px 10px;
  font: inherit;
  font-size: 11px;
  letter-spacing: 0.16em;
  font-weight: 700;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  box-shadow: var(--hard-sm);
}

/* The press is a hard displacement, not a fade. Filter 14 all the way down. */
.navbtn:active { transform: translate(4px, 4px); box-shadow: 1px 1px 0 var(--ink); }
.navbtn[aria-pressed="true"] { background: var(--orange); }

footer {
  margin: 16px 0 28px;
  font-size: 10px;
  letter-spacing: 0.08em;
  line-height: 1.7;
  opacity: 0.8;
}

.err {
  border: var(--border);
  background: var(--red);
  color: var(--ink);
  padding: 13px;
  margin-top: 14px;
  font-size: 12px;
  font-weight: 700;
  box-shadow: var(--hard);
}

/* ------------------------------- wider ---------------------------------- */

@media (min-width: 620px) {
  body { padding: 26px; }
  .strip { grid-template-columns: repeat(3, 1fr); }
  .row { gap: 9px; }
  .board { padding: 14px; }
}

/* ------------------------- PHASE 6: shake & marks -------------------------
 *
 * CSS transforms only, no physics library (build doc, Phase 6). Every keyframe
 * animates transform or opacity and nothing else, so none of it triggers
 * layout.
 *
 * All of it is opt-in via prefers-reduced-motion: a vending machine that jerks
 * on its own is exactly the kind of motion people switch off, and the board
 * still reads correctly with every animation disabled.
 */

@media (prefers-reduced-motion: no-preference) {

  /* The row judders as one. A shake is a whole-row event, and five boxes
     shaking independently reads as five faults rather than as one shake. */
  @keyframes row-shake {
    0%, 100% { transform: translate3d(0, 0, 0); }
    10%      { transform: translate3d(-6px, 1px, 0); }
    22%      { transform: translate3d(5px, -2px, 0); }
    36%      { transform: translate3d(-5px, 2px, 0); }
    50%      { transform: translate3d(4px, -1px, 0); }
    64%      { transform: translate3d(-3px, 1px, 0); }
    80%      { transform: translate3d(2px, 0, 0); }
  }
  .row.shaken { animation: row-shake 620ms cubic-bezier(.36,.07,.19,.97) both; }

  /* It jammed. A jolt, then it settles into the tilt and stays there - the
     tilt is state, not animation, so it must not spring back. */
  @keyframes jam {
    0%   { transform: rotate(0deg) translateY(0); }
    30%  { transform: rotate(-20deg) translateY(-6%); }
    60%  { transform: rotate(-8deg)  translateY(4%); }
    100% { transform: rotate(-13deg) translateY(9%); }
  }
  .slot.fx-stuck svg { animation: jam 460ms steps(8, end) both; }

  @keyframes fall {
    0%   { transform: rotate(-13deg) translateY(9%); opacity: 1; }
    55%  { transform: rotate(-4deg)  translateY(60%); opacity: 1; }
    100% { transform: rotate(0deg)   translateY(130%); opacity: 0; }
  }
  .slot.fx-fell svg { animation: fall 400ms steps(6, end) both; }

  @keyframes drop {
    0%   { transform: translateY(0); opacity: 1; }
    100% { transform: translateY(120%); opacity: 0; }
  }
  .slot.fx-dispensed svg { animation: drop 320ms steps(5, end) both; }

  @keyframes load {
    0%   { transform: translateY(-130%); }
    70%  { transform: translateY(6%); }
    100% { transform: translateY(0); }
  }
  .slot.fx-reloaded svg { animation: load 380ms steps(6, end) both; }

  @keyframes arrive {
    0%   { transform: translateY(-16px); }
    100% { transform: translateY(0); }
  }
  .trayitem.fresh { animation: arrive 300ms steps(4, end) both; }

  .slot.stuck svg { transition: transform 240ms steps(3, end); }
}

/* The jam highlight is state, not motion, so it lives outside the query. */
.slot.fx-stuck { background: var(--pink); }

/* ------------------------------- token bar ------------------------------- */

.tokenbar {
  margin-top: 14px;
  border: var(--border);
  background: var(--card);
  box-shadow: var(--hard);
}
.tokenbar h2 {
  margin: 0;
  padding: 10px 12px;
  border-bottom: var(--border);
  background: var(--orange);
  font-size: 11px;
  letter-spacing: 0.18em;
  font-weight: 700;
}
.tokenbody { padding: 12px; }

/* Full address, wrapping rather than truncating. A shortened CA hides the very
   characters somebody checking a lookalike needs to see. */
.ca {
  font-size: clamp(10px, 3.1vw, 13px);
  letter-spacing: 0.02em;
  font-weight: 700;
  word-break: break-all;
  background: var(--paper);
  border: 3px solid var(--ink);
  padding: 9px 10px;
  user-select: all;
}

.calinks { display: grid; gap: 10px; margin-top: 12px; }
@media (min-width: 620px) { .calinks { grid-template-columns: repeat(3, 1fr); } }
