/* ============================================================
   FORMA — the studio day-chart
   Shelf rails are dates. A workshop is a piece resting on its
   rail: left edge = start hour, width = duration, across an
   08:00–18:00 studio day.
   ============================================================ */

:root {
  --paper:        #efe7d9;
  --paper-deep:   #e5dac7;
  --paper-card:   #f7f2e8;
  --ink:          #16150f;
  --ink-soft:     #4a4639;
  --ink-faint:    #8c846f;
  --rule:         #16150f;
  --stamp:        #d8431e;
  --brass:        #a77c2e;

  --cat-ceramics:  #7a6a9c;
  --cat-painting:  #2f6ea8;
  --cat-floristry: #c9802b;
  --cat-baking:    #9a5327;

  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, "Times New Roman", serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;

  --gutter: clamp(18px, 4vw, 56px);
  --maxw: 1280px;
  --head-w: 104px;
  --ease: cubic-bezier(.2, .8, .25, 1);
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 17px;
  line-height: 1.5;
  overflow-x: hidden;
}

/* paper grain, drawn locally as an SVG data URI */
.grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 60;
  opacity: .32;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='180' height='180' filter='url(%23n)' opacity='.22'/%3E%3C/svg%3E");
}

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

.skip-link {
  position: absolute; left: 12px; top: -200px; z-index: 80;
  background: var(--ink); color: var(--paper);
  padding: 10px 16px; font-family: var(--mono); font-size: 12px;
  text-transform: uppercase; letter-spacing: .12em; text-decoration: none;
}
.skip-link:focus { top: 12px; }

:focus-visible {
  outline: 3px solid var(--stamp);
  outline-offset: 3px;
}

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

.masthead {
  border-bottom: 2px solid var(--rule);
  background:
    linear-gradient(104deg, rgba(141,168,196,.26) 0%, rgba(239,231,217,0) 42%),
    linear-gradient(255deg, rgba(229,154,79,.3) 0%, rgba(239,231,217,0) 46%);
}

.masthead-inner {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: clamp(26px, 5vw, 56px) var(--gutter) clamp(24px, 4vw, 40px);
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(220px, 300px);
  gap: clamp(24px, 4vw, 64px);
  align-items: end;
}

.eyebrow {
  margin: 0 0 .4em;
  font-family: var(--mono);
  font-size: 11.5px;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.wordmark {
  margin: 0 0 .25em;
  font-size: clamp(76px, 15vw, 188px);
  line-height: .82;
  letter-spacing: -.02em;
  font-weight: 400;
  display: flex;
  gap: .01em;
}
/* set by hand, so the letters never quite sit straight */
.wordmark span {
  display: inline-block;
  transform: rotate(var(--r)) translateY(var(--y, 0));
  transform-origin: 50% 85%;
}
.wordmark span:nth-child(3) { color: var(--stamp); }

.lede {
  margin: 0;
  max-width: 54ch;
  font-size: clamp(16px, 1.4vw, 19px);
  line-height: 1.55;
  color: var(--ink-soft);
}
.lede em { color: var(--ink); font-style: italic; }

.masthead-side { display: grid; gap: 16px; }

.bench { margin: 0; }
.bench img {
  display: block;
  width: 100%;
  height: clamp(130px, 14vw, 190px);
  object-fit: cover;
  border: 2px solid var(--rule);
  background: var(--paper-deep);
  box-shadow: 5px 5px 0 rgba(22,21,15,.14);
}
.bench figcaption {
  margin-top: 7px;
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

/* tray readout */
.tray-readout {
  border: 2px solid var(--rule);
  background: var(--paper-card);
  padding: 14px 16px 15px;
  box-shadow: 5px 5px 0 rgba(22,21,15,.14);
}
.tray-head {
  margin: 0 0 8px;
  font-family: var(--mono);
  font-size: 11.5px;
  letter-spacing: .18em;
  text-transform: uppercase;
  display: flex; align-items: center; gap: 8px;
}
.tray-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--paper-deep);
  border: 2px solid var(--rule);
}
body.has-tray .tray-dot { background: var(--stamp); }
.tray-figures {
  margin: 0 0 6px;
  font-size: 18px;
  line-height: 1.35;
}
.tray-figures b { font-weight: 400; font-family: var(--mono); font-size: .92em; }
.tray-note {
  margin: 0;
  font-size: 12.5px;
  color: var(--ink-faint);
  font-style: italic;
}

/* ---------------------------------------------------- controls */

.controls {
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--paper);
  border-bottom: 2px solid var(--rule);
  box-shadow: 0 10px 22px -18px rgba(22,21,15,.8);
}

.controls-inner {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 12px var(--gutter);
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 14px 20px;
}

.field { display: flex; flex-direction: column; gap: 5px; }
.field label, .field-label {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.field-slip { flex: 1 1 260px; min-width: 200px; }

.slip {
  display: flex; align-items: center; gap: 9px;
  border: 2px solid var(--rule);
  background: var(--paper-card);
  padding: 0 12px;
  height: 44px;
}
/* the input has no outline of its own, so the slip wears it */
.slip:focus-within {
  outline: 3px solid var(--stamp);
  outline-offset: 2px;
}
.slip-icon {
  width: 17px; height: 17px; flex: none;
  fill: none; stroke: var(--ink-soft); stroke-width: 2; stroke-linecap: round;
}
.slip input {
  flex: 1; min-width: 0;
  border: 0; background: transparent;
  font: inherit; font-size: 16px;
  color: var(--ink);
  padding: 0;
  height: 100%;
}
.slip input:focus { outline: none; }
.slip input::placeholder { color: var(--ink-faint); font-style: italic; }
.slip input::-webkit-search-cancel-button { -webkit-appearance: none; }

.field-plate { flex: 0 1 200px; }
.plate { position: relative; display: flex; }
.plate select {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  height: 44px;
  border: 2px solid var(--rule);
  background: var(--ink);
  color: var(--paper);
  font-family: var(--mono);
  font-size: 13px;
  letter-spacing: .06em;
  padding: 0 38px 0 12px;
  border-radius: 0;
}
.plate select:focus-visible { outline-offset: 2px; }
.plate-chev {
  position: absolute; right: 12px; top: 50%;
  width: 16px; height: 16px; margin-top: -8px;
  pointer-events: none;
  fill: none; stroke: var(--paper); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round;
}

.field-tray button {
  display: flex; align-items: center; gap: 10px;
  height: 44px;
  padding: 0 14px;
  border: 2px solid var(--rule);
  background: var(--paper-card);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 12.5px;
  letter-spacing: .06em;
  cursor: pointer;
  transition: background .18s var(--ease), color .18s var(--ease), box-shadow .18s var(--ease);
}
.field-tray button:hover { box-shadow: 4px 4px 0 rgba(22,21,15,.2); }
.field-tray button[aria-pressed="true"] {
  background: var(--stamp);
  border-color: var(--stamp);
  color: #fff6ee;
  box-shadow: 4px 4px 0 rgba(22,21,15,.3);
}
.tag-mark {
  width: 14px; height: 16px; flex: none;
  background: currentColor;
  clip-path: polygon(0 28%, 50% 0, 100% 28%, 100% 100%, 0 100%);
  opacity: .75;
}
.tray-count {
  font-variant-numeric: tabular-nums;
  border-left: 1.5px solid currentColor;
  padding-left: 9px;
  opacity: .8;
}

.tally {
  margin: 0 0 4px auto;
  font-family: var(--mono);
  font-size: 11.5px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

/* ---------------------------------------------------- rack */

.rack { padding: clamp(26px, 4vw, 48px) 0 clamp(50px, 7vw, 92px); }
.rack-inner { max-width: var(--maxw); margin: 0 auto; padding: 0 var(--gutter); }

.ruler {
  display: flex;
  align-items: flex-end;
  gap: 16px;
  margin-bottom: 10px;
  padding-left: 0;
}
.ruler-cap {
  width: var(--head-w);
  flex: none;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--ink-faint);
  padding-bottom: 2px;
}
.ruler-track {
  position: relative;
  flex: 1;
  height: 26px;
}
.tick {
  position: absolute;
  left: var(--t);
  bottom: 0;
  transform: translateX(-50%);
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: .08em;
  color: var(--ink-faint);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}
.tick i { display: block; width: 1.5px; height: 9px; background: var(--ink-faint); }
.tick:first-child { transform: translateX(0); align-items: flex-start; }
.tick-end { transform: translateX(-100%); align-items: flex-end; }

.shelves { list-style: none; margin: 0; padding: 0; }

.shelf {
  display: flex;
  gap: 16px;
  align-items: stretch;
  padding-bottom: 30px;
  scroll-margin-top: 110px; /* clear the sticky control bar */
}

.shelf-head {
  width: var(--head-w);
  flex: none;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-end;
  padding-bottom: 12px;
  line-height: 1;
}
.shelf-dow {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin-bottom: 7px;
}
.shelf-dom {
  font-size: 44px;
  letter-spacing: -.03em;
  font-variant-numeric: tabular-nums;
}
.shelf-mon {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin-top: 6px;
}

.track {
  position: relative;
  flex: 1;
  min-width: 0;
  padding-bottom: 12px;
  /* two-hourly gridlines, matching the ruler above */
  background-image: repeating-linear-gradient(
    to right,
    rgba(22,21,15,.14) 0 1px,
    transparent 1px 20%
  );
}
/* the rail the pieces rest on */
.track::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: 6px;
  height: 6px;
  background: var(--ink);
  box-shadow: 0 7px 14px -6px rgba(22,21,15,.55);
}

.pieces {
  list-style: none;
  margin: 0;
  padding: 0;
  position: relative;
  min-height: calc(96px + (var(--lanes, 1) - 1) * 92px);
}

/* ---------------------------------------------------- a piece */

.piece {
  position: absolute;
  bottom: var(--bottom, 0px);
  left: var(--start);
  width: var(--span);
  min-width: 212px;
  scroll-margin-top: 110px;
}

/* the stretch of rail this piece occupies, inked in its craft colour,
   so the bare rail reads as a chart of the day's crafts */
.piece.on-rail::before {
  content: "";
  position: absolute;
  left: 0; right: 0;
  bottom: -6px;
  height: 6px;
  background: var(--cat);
  transition: bottom .2s var(--ease), height .2s var(--ease);
}
.piece.on-rail:hover::before,
.piece.on-rail:focus-within::before {
  bottom: -9px;
  height: 9px;
}

.piece-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: left;
  padding: 10px 14px 10px 10px;
  border: 2px solid var(--rule);
  border-radius: 2px;
  background-color: var(--paper-card);
  /* the light in the room at that hour, washed over the piece */
  background-image:
    linear-gradient(180deg, color-mix(in srgb, var(--light) 26%, var(--paper-card)) 0%, var(--paper-card) 70%);
  color: var(--ink);
  font: inherit;
  cursor: pointer;
  box-shadow: 4px 5px 0 rgba(22,21,15,.18);
  transition: transform .2s var(--ease), box-shadow .2s var(--ease);
}
.piece-btn:hover {
  transform: translateY(-3px);
  box-shadow: 5px 9px 0 rgba(22,21,15,.22);
}
.piece-btn:active { transform: translateY(-1px); }

/* every piece is thrown slightly differently */
.thumb {
  flex: none;
  width: 58px; height: 58px;
  border-radius: var(--blob, 50%);
  overflow: hidden;
  border: 2px solid var(--rule);
  background: var(--paper-deep);
}
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }

.piece-text { min-width: 0; flex: 1; display: block; }
.piece-title {
  display: block;
  font-size: 19px;
  line-height: 1.15;
  letter-spacing: -.01em;
  margin-bottom: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.piece-meta {
  display: block;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: .04em;
  color: var(--ink-soft);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cat-dot {
  display: inline-block;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--cat);
  margin-right: 5px;
  vertical-align: 1px;
}
.piece-price {
  flex: none;
  font-family: var(--mono);
  font-size: 15px;
  font-variant-numeric: tabular-nums;
  padding-left: 10px;
  border-left: 1.5px solid rgba(22,21,15,.2);
  align-self: stretch;
  display: flex;
  align-items: center;
}

/* mini day-bar: only shown when rails are not time-positioned (mobile) */
.span-bar { display: none; }

/* the paper tag, tied on when saved */
.piece-tag {
  position: absolute;
  top: -28px;
  right: 14px;
  width: 2px;
  height: 16px;
  background: var(--brass);
  transform-origin: 50% 0;
  pointer-events: none;
  z-index: 2;
}
.piece-tag::after {
  content: "SAVED";
  position: absolute;
  top: 12px; left: 50%;
  transform: translateX(-50%) rotate(-5deg);
  background: var(--stamp);
  color: #fff6ee;
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: .16em;
  padding: 7px 8px 4px;
  clip-path: polygon(0 32%, 50% 0, 100% 32%, 100% 100%, 0 100%);
  white-space: nowrap;
}
.piece.is-saved .piece-btn {
  border-color: var(--stamp);
  box-shadow: 4px 5px 0 rgba(216,67,30,.3);
}
.piece.just-tagged .piece-tag { animation: swing .9s var(--ease); }
@keyframes swing {
  0% { transform: rotate(14deg); }
  35% { transform: rotate(-8deg); }
  65% { transform: rotate(4deg); }
  100% { transform: rotate(0deg); }
}

/* a piece arriving on the rail after a filter change */
.piece.is-new { animation: settle .34s var(--ease) both; }
@keyframes settle {
  from { opacity: 0; transform: translateY(-10px); }
  to   { opacity: 1; transform: none; }
}

/* ---------------------------------------------------- empty */

.empty {
  position: relative;
  padding: 44px 0 10px;
  max-width: 44ch;
}
.empty-rail {
  height: 6px;
  background: var(--ink);
  opacity: .25;
  margin-bottom: 26px;
  box-shadow: 0 7px 14px -6px rgba(22,21,15,.4);
}
.empty h2 {
  margin: 0 0 .3em;
  font-size: clamp(34px, 5vw, 54px);
  letter-spacing: -.02em;
  line-height: 1;
}
.empty p { margin: 0 0 20px; color: var(--ink-soft); }

.btn-ink {
  border: 2px solid var(--rule);
  background: var(--ink);
  color: var(--paper);
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: .1em;
  text-transform: uppercase;
  padding: 12px 18px;
  cursor: pointer;
  box-shadow: 4px 4px 0 rgba(22,21,15,.2);
  transition: transform .18s var(--ease), box-shadow .18s var(--ease);
}
.btn-ink:hover { transform: translate(-2px, -2px); box-shadow: 6px 6px 0 rgba(22,21,15,.26); }

.load-error {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--stamp);
  border: 2px solid var(--stamp);
  padding: 14px;
}

/* ---------------------------------------------------- colophon */

.colophon {
  border-top: 2px solid var(--rule);
  background: var(--paper-deep);
}
.colophon-inner {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: clamp(28px, 4vw, 48px) var(--gutter);
  display: grid;
  grid-template-columns: minmax(0, 200px) minmax(0, 1fr);
  gap: clamp(20px, 4vw, 48px);
  align-items: start;
}
.colophon-brand { display: grid; gap: 14px; }
.colophon-mark {
  margin: 0;
  font-size: clamp(34px, 4vw, 52px);
  letter-spacing: .06em;
  line-height: .9;
  color: var(--ink);
}
.colophon-img {
  display: block;
  width: 100%;
  max-width: 200px;
  height: 120px;
  object-fit: cover;
  border: 2px solid var(--rule);
  filter: grayscale(.35) contrast(1.05);
}
.colophon-cols {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 18px 32px;
}
.colophon-cols p { margin: 0; font-size: 13.5px; line-height: 1.55; color: var(--ink-soft); }
.colophon-cols strong {
  display: block;
  font-family: var(--mono);
  font-weight: 400;
  font-size: 10.5px;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--ink);
  margin-bottom: 5px;
}

/* ---------------------------------------------------- spec card (detail) */

.spec {
  border: 2px solid var(--rule);
  border-radius: 2px;
  padding: 0;
  background: var(--paper-card);
  color: var(--ink);
  width: min(620px, calc(100vw - 32px));
  max-width: none;
  max-height: calc(100dvh - 48px);
  box-shadow: 14px 16px 0 rgba(22,21,15,.26);
  overflow: visible;
}
.spec::backdrop {
  background: rgba(22,21,15,.56);
  backdrop-filter: blur(2px);
}
.spec[open] { animation: specIn .3s var(--ease); }
@keyframes specIn {
  from { opacity: 0; transform: translateY(16px) rotate(-.6deg); }
  to   { opacity: 1; transform: none; }
}

.spec-card {
  max-height: calc(100dvh - 52px);
  overflow-y: auto;
  padding: 18px clamp(18px, 3.4vw, 34px) clamp(20px, 3vw, 30px);
}

.spec-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 12px;
  border-bottom: 1.5px solid rgba(22,21,15,.2);
  position: sticky;
  top: 0;
  background: var(--paper-card);
  z-index: 2;
  padding-top: 2px;
}
.spec-ref {
  margin: 0;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: .18em;
  text-transform: uppercase;
  display: flex; align-items: center; gap: 10px;
}
.spec-ref-no { color: var(--ink-faint); }
#spec-cat { display: inline-flex; align-items: center; gap: 7px; }

.spec-close {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 2px solid var(--rule);
  background: var(--paper-card);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: .1em;
  text-transform: uppercase;
  padding: 8px 12px;
  cursor: pointer;
  flex: none;
  transition: background .16s var(--ease), color .16s var(--ease);
}
.spec-close:hover { background: var(--ink); color: var(--paper); }
.spec-close:hover svg { stroke: var(--paper); }
.spec-close svg { width: 13px; height: 13px; fill: none; stroke: var(--ink); stroke-width: 2.4; stroke-linecap: round; }

.spec-figure {
  margin: 18px 0 20px;
  position: relative;
}
.spec-figure img {
  display: block;
  width: 100%;
  height: clamp(170px, 26vh, 260px);
  object-fit: cover;
  border: 2px solid var(--rule);
  background: var(--paper-deep);
}
.spec-figure figcaption {
  margin-top: 7px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.spec-title {
  margin: 0 0 .3em;
  font-size: clamp(32px, 5.4vw, 50px);
  line-height: .98;
  letter-spacing: -.025em;
  font-weight: 400;
}
.spec-body {
  margin: 0 0 22px;
  font-size: 18px;
  line-height: 1.5;
  color: var(--ink-soft);
  max-width: 44ch;
}

.spec-when { margin: 0 0 20px; }
.spec-when-track {
  position: relative;
  height: 14px;
  border: 1.5px solid rgba(22,21,15,.3);
  background: repeating-linear-gradient(to right, rgba(22,21,15,.1) 0 1px, transparent 1px 10%);
}
.spec-when-bar {
  position: absolute;
  top: -1.5px; bottom: -1.5px;
  left: var(--start, 0%);
  width: var(--span, 20%);
  background: var(--stamp);
  border: 1.5px solid var(--rule);
}
.spec-when-ends {
  display: flex;
  justify-content: space-between;
  margin-top: 5px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.spec-table {
  margin: 0 0 24px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0;
  border-top: 1.5px solid rgba(22,21,15,.22);
}
.spec-table > div {
  padding: 11px 0 11px;
  border-bottom: 1.5px solid rgba(22,21,15,.22);
  padding-right: 14px;
}
.spec-table dt {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin-bottom: 4px;
}
.spec-table dd { margin: 0; font-size: 16.5px; }

.spec-save {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  justify-content: center;
  border: 2px solid var(--rule);
  background: var(--ink);
  color: var(--paper);
  font-family: var(--mono);
  font-size: 13px;
  letter-spacing: .1em;
  text-transform: uppercase;
  padding: 15px 18px;
  cursor: pointer;
  box-shadow: 5px 5px 0 rgba(22,21,15,.22);
  transition: transform .18s var(--ease), box-shadow .18s var(--ease), background .18s var(--ease);
}
.spec-save:hover { transform: translate(-2px, -2px); box-shadow: 7px 7px 0 rgba(22,21,15,.26); }
.spec-save[aria-pressed="true"] {
  background: var(--stamp);
  border-color: var(--rule);
  color: #fff6ee;
}
.spec-save-tag {
  width: 15px; height: 17px; flex: none;
  background: currentColor;
  clip-path: polygon(0 28%, 50% 0, 100% 28%, 100% 100%, 0 100%);
  opacity: .8;
}

/* ---------------------------------------------------- mobile / stacked rails */

@media (max-width: 879px) {
  .ruler { display: none; }

  .masthead-inner {
    grid-template-columns: minmax(0, 1fr);
    align-items: start;
    gap: 22px;
  }
  .masthead-side { max-width: 460px; gap: 14px; }
  .bench img { height: 118px; }

  /* the bar wraps to two rows here — pinning it would eat the screen */
  .controls { position: static; box-shadow: none; }
  .controls-inner { gap: 10px 14px; }
  .field-slip { flex: 1 1 100%; }
  .field-plate { flex: 1 1 150px; }
  .field-tray { flex: 1 1 180px; }
  .field-tray button { width: 100%; }
  .tray-toggle-text { flex: 1; }
  .tally { flex: 1 1 100%; margin: 2px 0 0; }

  .shelf {
    display: block;
    padding-bottom: 26px;
  }
  .shelf-head {
    width: auto;
    flex-direction: row;
    align-items: baseline;
    gap: 9px;
    padding: 0 0 8px;
    border-bottom: 3px solid var(--ink);
    margin-bottom: 14px;
  }
  .shelf-dom { font-size: 30px; }
  .shelf-dow, .shelf-mon { margin: 0; }
  .shelf-mon { margin-right: auto; }

  .track { background-image: none; padding-bottom: 0; }
  .track::after { display: none; }
  .piece.on-rail::before { display: none; }

  .pieces { min-height: 0; display: grid; gap: 12px; }

  .piece {
    position: relative;
    inset: auto;
    width: auto;
    min-width: 0;
  }
  .piece-btn {
    flex-wrap: wrap;
    padding: 12px;
    box-shadow: 3px 4px 0 rgba(22,21,15,.18);
  }
  .piece-title { white-space: normal; font-size: 20px; }
  .piece-meta { white-space: normal; }
  .piece-price {
    border-left: 0;
    padding-left: 0;
    font-size: 17px;
  }

  /* the day-chart idea survives as a miniature inside each card */
  .span-bar {
    display: block;
    position: relative;
    flex: 1 1 100%;
    height: 10px;
    margin-top: 2px;
    border: 1.5px solid rgba(22,21,15,.28);
    background: repeating-linear-gradient(to right, rgba(22,21,15,.12) 0 1px, transparent 1px 20%);
  }
  .span-bar i {
    position: absolute;
    top: -1.5px; bottom: -1.5px;
    left: var(--start);
    width: var(--span);
    min-width: 8px;
    background: var(--stamp);
    border: 1.5px solid var(--rule);
  }

  /* no room above the card here, so the tag hangs underneath */
  .piece-tag { top: auto; bottom: -18px; right: 14px; height: 12px; }
  .piece-tag::after { top: 8px; }
  .piece.is-saved { margin-bottom: 30px; }

  .colophon-inner { grid-template-columns: minmax(0, 1fr); }

  .spec {
    width: 100vw;
    max-width: 100vw;
    max-height: 100dvh;
    height: 100dvh;
    margin: 0;
    border-width: 0;
    box-shadow: none;
  }
  .spec-card { max-height: 100dvh; padding-bottom: 36px; }
  /* keep the label for assistive tech, drop it from the layout */
  .spec-close span {
    position: absolute; width: 1px; height: 1px;
    padding: 0; margin: -1px; overflow: hidden;
    clip-path: inset(50%); white-space: nowrap;
  }
  .spec-close {
    padding: 0;
    min-width: 46px;
    min-height: 46px;
    justify-content: center;
  }
  .spec-close svg { width: 16px; height: 16px; }
  .spec-figure img { height: 180px; }
}

@media (max-width: 420px) {
  .wordmark { font-size: 21vw; }
}

/* ---------------------------------------------------- reduced motion */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
  .piece-btn:hover, .btn-ink:hover, .spec-save:hover { transform: none; }
}

@media (prefers-contrast: more) {
  :root { --ink-faint: #5d5748; --ink-soft: #2a2821; }
}
