/* ==========================================================================
   Forma — the making table
   A dark workbench ground, warm paper specimen sheets, four category inks.
   ========================================================================== */

/* --- tokens ------------------------------------------------------------- */
:root {
  --ground: #14231b;
  --ground-lift: #1c3327;
  --ground-deep: #0e1913;
  --paper: #f3e9d6;
  --paper-2: #e8dabf;
  --paper-edge: #cbb894;
  --ink: #171309;
  --ink-soft: #565040;
  --ink-faint: #6f6852;
  --chalk: #dbe6d3;
  --chalk-dim: #94ab9b;
  --rule: rgba(219, 230, 211, 0.18);

  --baking: #e4572e;
  --ceramics: #2e6be6;
  --floristry: #d6336c;
  --painting: #e9b60e;

  --baking-t: #9c3413;
  --ceramics-t: #1b4bb0;
  --floristry-t: #a01f4d;
  --painting-t: #8a6500;

  --display: "Bricolage Grotesque", "Avenir Next Condensed", "Arial Narrow", sans-serif;
  --body: "Hanken Grotesk", "Avenir Next", system-ui, sans-serif;
  --mono: "Spline Sans Mono", "SF Mono", ui-monospace, monospace;

  --shadow-sheet: 0 22px 34px -22px rgba(0, 0, 0, 0.85), 0 3px 0 rgba(0, 0, 0, 0.22);
  --shadow-sheet-hover: 0 34px 46px -26px rgba(0, 0, 0, 0.9), 0 4px 0 rgba(0, 0, 0, 0.24);
  --ease-out: cubic-bezier(0.18, 0.86, 0.24, 1);
  --pad: clamp(1rem, 3.4vw, 3rem);
}

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

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

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--body);
  font-size: 1rem;
  line-height: 1.55;
  color: var(--chalk);
  background-color: var(--ground);
  background-image:
    radial-gradient(1100px 720px at 14% -8%, rgba(94, 140, 106, 0.34), transparent 62%),
    radial-gradient(900px 620px at 100% 0%, rgba(78, 120, 128, 0.18), transparent 58%),
    linear-gradient(180deg, #172a20 0%, var(--ground) 42%, var(--ground-deep) 100%);
  background-attachment: fixed;
  caret-color: var(--painting);
  overflow-x: hidden;
}

/* paper grain + halftone over the whole bench */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.5;
  mix-blend-mode: soft-light;
  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='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='180' height='180' filter='url(%23n)' opacity='0.6'/%3E%3C/svg%3E");
}

/* faint bench halftone */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.4;
  background-image: radial-gradient(rgba(219, 230, 211, 0.1) 0.6px, transparent 0.7px);
  background-size: 7px 7px;
}

body > * {
  position: relative;
  z-index: 1;
}

img {
  display: block;
  max-width: 100%;
}

[hidden] {
  display: none !important;
}

button,
input,
select {
  font: inherit;
  color: inherit;
}

h1,
h2,
h3,
p,
ul,
dl {
  margin: 0;
}

ul {
  list-style: none;
  padding: 0;
}

svg {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* --- browser surfaces --------------------------------------------------- */
::selection {
  background: var(--painting);
  color: var(--ink);
}

:focus-visible {
  outline: 3px solid var(--paper);
  outline-offset: 3px;
  border-radius: 2px;
}

/* on the dark ground, ink outlines vanish — paper outline instead */
.card__link:focus-visible,
.btn:focus-visible,
.rail-toggle:focus-visible {
  outline-color: var(--painting);
}

* {
  scrollbar-color: rgba(219, 230, 211, 0.32) transparent;
  scrollbar-width: thin;
}

*::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

*::-webkit-scrollbar-thumb {
  background: rgba(219, 230, 211, 0.26);
  border: 3px solid transparent;
  background-clip: padding-box;
  border-radius: 999px;
}

*::-webkit-scrollbar-thumb:hover {
  background: rgba(219, 230, 211, 0.45);
  background-clip: padding-box;
}

.skip-link {
  position: absolute;
  left: 1rem;
  top: -4rem;
  z-index: 60;
  padding: 0.7rem 1.1rem;
  background: var(--paper);
  color: var(--ink);
  font-weight: 700;
  text-decoration: none;
  border-radius: 3px;
  transition: top 0.2s var(--ease-out);
}

.skip-link:focus {
  top: 1rem;
}

/* --- masthead ----------------------------------------------------------- */
.masthead {
  position: sticky;
  top: 0;
  z-index: 40;
  background: linear-gradient(180deg, rgba(14, 25, 19, 0.96), rgba(14, 25, 19, 0.82));
  backdrop-filter: blur(7px);
  border-bottom: 1px solid var(--rule);
}

.masthead__inner {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: clamp(0.75rem, 2vw, 2rem);
  padding: 0.65rem var(--pad);
}

.brand {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  text-decoration: none;
  color: var(--paper);
}

.brand__name {
  font-family: var(--display);
  font-weight: 800;
  font-size: clamp(1.5rem, 2.4vw, 2.1rem);
  letter-spacing: -0.035em;
  line-height: 0.9;
}

.brand__tag {
  font-family: var(--mono);
  font-size: 0.62rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--chalk-dim);
}

.brand:hover .brand__name {
  color: var(--painting);
}

/* search */
.search {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  min-width: 0;
}

.search__label {
  font-family: var(--mono);
  font-size: 0.62rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--chalk-dim);
  white-space: nowrap;
}

.search__field {
  position: relative;
  display: flex;
  align-items: center;
  flex: 1 1 auto;
  min-width: 0;
  max-width: 30rem;
}

.search__icon {
  position: absolute;
  left: 0.75rem;
  width: 1.05rem;
  height: 1.05rem;
  color: var(--chalk-dim);
  pointer-events: none;
}

.search input {
  width: 100%;
  padding: 0.62rem 0.9rem 0.62rem 2.35rem;
  color: var(--paper);
  background: rgba(243, 233, 214, 0.07);
  border: 1.5px solid rgba(219, 230, 211, 0.3);
  border-radius: 3px;
  font-size: 0.96rem;
  transition: border-color 0.2s, background 0.2s;
}

.search input::placeholder {
  color: var(--chalk-dim);
}

.search input:hover {
  border-color: rgba(219, 230, 211, 0.5);
}

.search input:focus {
  outline: none;
  border-color: var(--painting);
  background: rgba(243, 233, 214, 0.11);
}

.search input:focus-visible {
  outline: 3px solid var(--painting);
  outline-offset: 2px;
}

/* rail toggle */
.rail-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.58rem 0.9rem;
  color: var(--paper);
  background: rgba(243, 233, 214, 0.06);
  border: 1.5px solid rgba(219, 230, 211, 0.3);
  border-radius: 3px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 0.2s, background 0.2s, color 0.2s;
}

.rail-toggle:hover {
  border-color: var(--painting);
}

.rail-toggle__icon {
  width: 1.1rem;
  height: 1.1rem;
}

.rail-toggle__count {
  display: inline-grid;
  place-items: center;
  min-width: 1.5rem;
  height: 1.5rem;
  padding: 0 0.35rem;
  font-family: var(--mono);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--ink);
  background: var(--chalk-dim);
  border-radius: 999px;
  transition: background 0.2s, color 0.2s;
}

.rail-toggle[aria-pressed="true"] {
  color: var(--ink);
  background: var(--painting);
  border-color: var(--painting);
}

.rail-toggle[aria-pressed="true"] .rail-toggle__count {
  background: var(--ink);
  color: var(--painting);
}

.rail-toggle[aria-pressed="true"] .rail-toggle__icon {
  color: var(--ink);
}

/* --- peg rail ----------------------------------------------------------- */
.peg-rail {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.5rem var(--pad) 0.75rem;
  border-top: 1px dashed var(--rule);
  overflow-x: auto;
  overflow-y: hidden;
}

.peg-rail__label {
  flex: 0 0 auto;
  font-family: var(--mono);
  font-size: 0.6rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--chalk-dim);
  writing-mode: horizontal-tb;
}

.peg-rail__list {
  display: flex;
  gap: 0.6rem;
  align-items: center;
}

.peg {
  position: relative;
  flex: 0 0 auto;
  animation: peg-drop 0.45s var(--ease-out) both;
}

.peg__btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.3rem 0.7rem 0.3rem 0.3rem;
  color: var(--paper);
  background: rgba(243, 233, 214, 0.08);
  border: 1px solid rgba(219, 230, 211, 0.28);
  border-radius: 3px;
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 600;
  transition: background 0.2s, border-color 0.2s;
}

.peg__btn:hover {
  background: rgba(243, 233, 214, 0.16);
  border-color: var(--painting);
}

.peg__thumb {
  width: 2.1rem;
  height: 2.1rem;
  object-fit: cover;
  border-radius: 2px;
  filter: grayscale(0.35);
}

.peg__dot {
  width: 0.6rem;
  height: 0.6rem;
  border-radius: 999px;
  background: var(--cat, var(--chalk));
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.3);
}

@keyframes peg-drop {
  from {
    transform: translateY(-8px) rotate(-4deg);
  }
  to {
    transform: none;
  }
}

/* --- chalk band --------------------------------------------------------- */
.chalk-band {
  display: grid;
  gap: 1.1rem;
  grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr);
  align-items: end;
  padding: clamp(1.8rem, 5vw, 4.2rem) var(--pad) clamp(1rem, 3vw, 2rem);
}

.chalk-band__title {
  font-family: var(--display);
  font-weight: 700;
  font-size: clamp(2.3rem, 5.4vw, 4.6rem);
  line-height: 0.94;
  letter-spacing: -0.035em;
  color: var(--paper);
  text-wrap: balance;
}

.chalk-band__note {
  max-width: 34ch;
  color: var(--chalk-dim);
  font-size: clamp(0.95rem, 1.2vw, 1.08rem);
  border-top: 2px solid var(--painting);
  padding-top: 0.65rem;
}

/* --- tools -------------------------------------------------------------- */
.tools {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  justify-content: space-between;
  gap: 1rem;
  padding: 0 var(--pad) 0.9rem;
}

.tools__drawer {
  display: flex;
  align-items: center;
  gap: 0.7rem;
}

.tools__label {
  font-family: var(--mono);
  font-size: 0.66rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--chalk-dim);
}

.select {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.select select {
  appearance: none;
  -webkit-appearance: none;
  padding: 0.55rem 2.3rem 0.55rem 0.9rem;
  color: var(--paper);
  background: rgba(243, 233, 214, 0.06);
  border: 1.5px solid rgba(219, 230, 211, 0.3);
  border-radius: 3px;
  font-weight: 700;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}

.select select:hover {
  border-color: var(--painting);
}

.select select:focus-visible {
  outline: 3px solid var(--painting);
  outline-offset: 2px;
}

.select option {
  color: var(--ink);
  background: var(--paper);
}

.select__chevron {
  position: absolute;
  right: 0.75rem;
  width: 1rem;
  height: 1rem;
  color: var(--chalk-dim);
  pointer-events: none;
}

.tools__count {
  font-family: var(--mono);
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  color: var(--chalk-dim);
}

.tools__right {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}

.table-rule {
  height: 14px;
  margin: 0 var(--pad);
  background-image: repeating-linear-gradient(
    90deg,
    var(--rule) 0,
    var(--rule) 1px,
    transparent 1px,
    transparent 11px
  );
  background-position: bottom;
  background-size: 100% 7px;
  background-repeat: repeat-x;
  border-top: 1px solid var(--rule);
}

/* --- table grid --------------------------------------------------------- */
.table {
  padding: clamp(1.2rem, 3vw, 2.4rem) var(--pad) 3rem;
}

.grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: clamp(1rem, 2.2vw, 2rem);
  align-items: start;
}

.cell {
  display: flex;
  min-width: 0;
  /* rotate the whole sheet slightly, deterministic by position */
}

/* after the first paint the sheets stay put while filtering */
.grid.no-settle .cell {
  animation: none !important;
}

/* mosaic spans — recalculated for whichever cards are visible */
.grid > .cell:nth-child(6n + 1) {
  grid-column: span 5;
}
.grid > .cell:nth-child(6n + 2) {
  grid-column: span 4;
}
.grid > .cell:nth-child(6n + 3) {
  grid-column: span 3;
}
.grid > .cell:nth-child(6n + 4) {
  grid-column: span 3;
}
.grid > .cell:nth-child(6n + 5) {
  grid-column: span 4;
}
.grid > .cell:nth-child(6n) {
  grid-column: span 5;
}

.grid > .cell:nth-child(4n + 1) {
  --rot: -0.7deg;
}
.grid > .cell:nth-child(4n + 2) {
  --rot: 0.5deg;
}
.grid > .cell:nth-child(4n + 3) {
  --rot: 0.9deg;
}
.grid > .cell:nth-child(4n) {
  --rot: -0.45deg;
}

/* --- card --------------------------------------------------------------- */
.card {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  transform: rotate(var(--rot, 0deg));
  transition: transform 0.4s var(--ease-out);
}

.card:hover,
.card:focus-within {
  transform: rotate(0deg) translateY(-4px);
  z-index: 2;
}

.card__link {
  display: flex;
  flex-direction: column;
  height: 100%;
  text-decoration: none;
  color: var(--ink);
  background: linear-gradient(160deg, var(--paper) 0%, var(--paper-2) 100%);
  border-radius: 3px;
  box-shadow: var(--shadow-sheet);
  overflow: hidden;
  transition: box-shadow 0.4s var(--ease-out);
}

.card:hover .card__link,
.card:focus-within .card__link {
  box-shadow: var(--shadow-sheet-hover);
}

.card__media {
  position: relative;
  display: block;
  overflow: hidden;
  isolation: isolate;
  aspect-ratio: 4 / 3;
  background: var(--ground-lift);
}

.card__img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: grayscale(1) contrast(1.08) brightness(0.97);
  transform: scale(1.02);
  transition: filter 0.55s var(--ease-out), transform 0.9s var(--ease-out);
}

.card__media::before {
  /* halftone dots pressed into the photo */
  content: "";
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  opacity: 0.28;
  mix-blend-mode: multiply;
  background-image: radial-gradient(rgba(23, 19, 9, 0.65) 0.7px, transparent 0.8px);
  background-size: 5px 5px;
}

.card__media::after {
  /* category duotone */
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  background: var(--cat, var(--chalk));
  mix-blend-mode: color;
  opacity: 0.62;
  transition: opacity 0.55s var(--ease-out);
}

.card:hover .card__img,
.card:focus-within .card__img {
  filter: grayscale(0) contrast(1.02);
  transform: scale(1.06);
}

.card:hover .card__media::after,
.card:focus-within .card__media::after {
  opacity: 0.14;
}

.card__tape {
  position: absolute;
  z-index: 3;
  top: 0.45rem;
  left: 1.1rem;
  width: 5.4rem;
  height: 1.5rem;
  transform: rotate(-4deg);
  background: color-mix(in srgb, var(--cat, var(--chalk)) 62%, var(--paper));
  opacity: 0.9;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.28);
  -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 5%, #000 95%, transparent 100%);
  mask-image: linear-gradient(90deg, transparent 0, #000 5%, #000 95%, transparent 100%);
}

.card__mark {
  position: absolute;
  z-index: 3;
  right: 0.7rem;
  bottom: 0.7rem;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.28rem 0.6rem;
  font-family: var(--mono);
  font-size: 0.62rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--paper);
  background: rgba(14, 25, 19, 0.86);
  border-radius: 999px;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.3s, transform 0.3s;
}

.card__mark svg {
  width: 0.85rem;
  height: 0.85rem;
  stroke-width: 2.6;
}

.card.is-saved .card__mark {
  opacity: 1;
  transform: none;
}

.card.is-saved .card__link {
  box-shadow: var(--shadow-sheet-hover), inset 0 0 0 2px var(--cat, var(--painting));
}

.card__sheet {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  padding: 1rem 1.05rem 1.1rem;
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  align-self: flex-start;
  font-family: var(--mono);
  font-size: 0.63rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink);
}

.tag__dot {
  width: 0.62rem;
  height: 0.62rem;
  border-radius: 999px;
  background: var(--cat, var(--chalk));
  box-shadow: 0 0 0 1.5px rgba(23, 19, 9, 0.35);
}

.card__title {
  font-family: var(--display);
  font-weight: 700;
  font-size: clamp(1.35rem, 2vw, 1.85rem);
  line-height: 1.02;
  letter-spacing: -0.025em;
  text-wrap: balance;
}

.card__desc {
  color: var(--ink-soft);
  font-size: 0.92rem;
  line-height: 1.45;
}

.specs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.35rem 1rem;
  margin-top: 0.25rem;
  padding-top: 0.7rem;
  border-top: 1px solid rgba(23, 19, 9, 0.18);
}

.spec {
  display: flex;
  flex-direction: column;
  gap: 0.05rem;
  min-width: 0;
}

.spec__k {
  font-family: var(--mono);
  font-size: 0.58rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.spec__v {
  font-size: 0.9rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}

.card__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  margin-top: 0.35rem;
}

.card__cta {
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink);
  border-bottom: 2px solid var(--cat, var(--painting));
  padding-bottom: 0.1rem;
  transition: border-color 0.2s;
}

.card__scarce {
  font-family: var(--mono);
  font-size: 0.62rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--baking-t);
}

/* media aspect by mosaic position, to give the table depth */
.grid > .cell:nth-child(6n + 1) .card__media,
.grid > .cell:nth-child(6n) .card__media {
  aspect-ratio: 16 / 11;
}
.grid > .cell:nth-child(6n + 3) .card__media,
.grid > .cell:nth-child(6n + 4) .card__media {
  aspect-ratio: 1 / 1;
}

/* stagger the settle of sheets onto the table */
.cell {
  animation: settle 0.6s var(--ease-out) both;
}
.grid > .cell:nth-child(1) { animation-delay: 0.02s; }
.grid > .cell:nth-child(2) { animation-delay: 0.05s; }
.grid > .cell:nth-child(3) { animation-delay: 0.08s; }
.grid > .cell:nth-child(4) { animation-delay: 0.11s; }
.grid > .cell:nth-child(5) { animation-delay: 0.14s; }
.grid > .cell:nth-child(6) { animation-delay: 0.17s; }
.grid > .cell:nth-child(n + 7) { animation-delay: 0.2s; }

@keyframes settle {
  from {
    transform: translateY(-14px) rotate(var(--rot, 0deg)) scale(0.99);
  }
  to {
    transform: rotate(var(--rot, 0deg)) scale(1);
  }
}

/* --- empty state -------------------------------------------------------- */
.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.9rem;
  max-width: 34rem;
  margin: 3rem auto;
  padding: clamp(1.6rem, 4vw, 3rem);
  text-align: center;
  color: var(--chalk);
  border: 1.5px dashed var(--rule);
  border-radius: 4px;
  background: rgba(243, 233, 214, 0.03);
}

.empty__art {
  width: 11rem;
  height: auto;
  color: var(--chalk-dim);
  opacity: 0.7;
}

.empty__title {
  font-family: var(--display);
  font-weight: 700;
  font-size: clamp(1.6rem, 3vw, 2.2rem);
  letter-spacing: -0.03em;
  color: var(--paper);
}

.empty__text {
  max-width: 34ch;
  color: var(--chalk-dim);
}

/* --- buttons ------------------------------------------------------------ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.7rem 1.15rem;
  font-weight: 700;
  border-radius: 3px;
  cursor: pointer;
  border: 1.5px solid transparent;
  transition: transform 0.2s var(--ease-out), background 0.2s, color 0.2s, border-color 0.2s;
}

.btn:active {
  transform: translateY(1px);
}

.btn--ink {
  color: var(--paper);
  background: rgba(243, 233, 214, 0.08);
  border-color: rgba(219, 230, 211, 0.4);
}

.btn--ink:hover {
  background: var(--paper);
  color: var(--ink);
}

.btn--ghost {
  padding: 0.55rem 0.9rem;
  color: var(--chalk-dim);
  background: transparent;
  border-color: rgba(219, 230, 211, 0.28);
  font-size: 0.85rem;
}

.btn--ghost:hover {
  color: var(--ink);
  background: var(--painting);
  border-color: var(--painting);
}

.btn__icon {
  width: 0.95rem;
  height: 0.95rem;
  stroke-width: 2;
}

/* --- detail dialog ------------------------------------------------------ */
.detail {
  width: min(64rem, calc(100vw - 2rem));
  max-height: calc(100vh - 2rem);
  padding: 0;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--ink);
  overflow: hidden;
  box-shadow: 0 40px 80px -30px rgba(0, 0, 0, 0.9);
}

.detail::backdrop {
  background: rgba(7, 14, 10, 0.72);
  backdrop-filter: blur(4px);
}

html:has(dialog.detail[open]) {
  overflow: hidden;
}

.detail__shell {
  position: relative;
  max-height: calc(100vh - 2rem);
  overflow-y: auto;
  background: linear-gradient(165deg, var(--paper) 0%, var(--paper-2) 100%);
  border-top: 10px solid var(--cat, var(--painting));
}

.detail__close {
  position: sticky;
  top: 0.9rem;
  margin: 0.9rem 0.9rem -3.2rem auto;
  display: grid;
  place-items: center;
  width: 2.6rem;
  height: 2.6rem;
  color: var(--paper);
  background: rgba(14, 25, 19, 0.9);
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  z-index: 5;
  transition: background 0.2s, transform 0.2s;
}

.detail__close:hover {
  background: var(--baking);
  transform: rotate(90deg);
}

.detail__close svg {
  width: 1.15rem;
  height: 1.15rem;
  stroke-width: 2.4;
}

.detail__grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr);
  gap: 0;
}

.detail__media {
  position: relative;
  min-height: 100%;
  isolation: isolate;
  overflow: hidden;
}

.detail__img {
  width: 100%;
  height: 100%;
  min-height: 22rem;
  object-fit: cover;
  filter: grayscale(0.15) contrast(1.03);
}

.detail__media::after {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--cat, var(--painting));
  mix-blend-mode: color;
  opacity: 0.24;
  pointer-events: none;
}

.detail__body {
  padding: clamp(1.4rem, 3vw, 2.6rem);
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.detail__tag {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-family: var(--mono);
  font-size: 0.66rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.detail__title {
  font-family: var(--display);
  font-weight: 700;
  font-size: clamp(2rem, 4vw, 3.1rem);
  line-height: 0.98;
  letter-spacing: -0.035em;
  text-wrap: balance;
}

.detail__lede {
  font-size: 1.06rem;
  line-height: 1.5;
  color: var(--ink-soft);
}

.detail__facts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.8rem 1.2rem;
  padding-top: 1rem;
  border-top: 1px solid rgba(23, 19, 9, 0.2);
}

.fact {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.fact__k {
  font-family: var(--mono);
  font-size: 0.6rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.fact__v {
  font-size: 1.02rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.detail__body p.detail__long {
  font-size: 1rem;
  line-height: 1.6;
  max-width: 62ch;
}

.detail__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.8rem;
  margin-top: auto;
  padding-top: 1.2rem;
  border-top: 1px solid rgba(23, 19, 9, 0.2);
}

/* the rubber stamp */
.stampbtn {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.85rem 1.2rem;
  font-family: var(--display);
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: -0.01em;
  color: var(--ink);
  background: transparent;
  border: 2.5px solid var(--ink);
  border-radius: 4px;
  cursor: pointer;
  transition: transform 0.18s var(--ease-out), background 0.2s, color 0.2s, border-color 0.2s;
}

.stampbtn svg {
  width: 1.1rem;
  height: 1.1rem;
  stroke-width: 2.4;
}

.stampbtn:hover {
  background: var(--ink);
  color: var(--paper);
}

.stampbtn[aria-pressed="true"] {
  color: var(--floristry-t);
  border-color: var(--floristry);
  background: color-mix(in srgb, var(--floristry) 12%, transparent);
  transform: rotate(-3deg);
}

.stampbtn.just-pressed {
  animation: stamp-press 0.4s var(--ease-out);
}

@keyframes stamp-press {
  0% {
    transform: rotate(-3deg) scale(1.35);
    opacity: 0.35;
  }
  55% {
    transform: rotate(-3deg) scale(0.95);
    opacity: 1;
  }
  100% {
    transform: rotate(-3deg) scale(1);
  }
}

.detail__hint {
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.detail__note {
  font-size: 0.78rem;
  color: var(--ink-faint);
  max-width: 46ch;
}

/* --- colophon ----------------------------------------------------------- */
.colophon {
  padding: 2rem var(--pad) 3rem;
  border-top: 1px solid var(--rule);
  color: var(--chalk-dim);
  font-size: 0.82rem;
  max-width: 70ch;
}

/* --- responsive --------------------------------------------------------- */
@media (max-width: 1000px) {
  .grid {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }
  .grid > .cell:nth-child(6n + 1),
  .grid > .cell:nth-child(6n),
  .grid > .cell:nth-child(6n + 5) {
    grid-column: span 3;
  }
  .grid > .cell:nth-child(6n + 2),
  .grid > .cell:nth-child(6n + 3),
  .grid > .cell:nth-child(6n + 4) {
    grid-column: span 3;
  }
  .chalk-band {
    grid-template-columns: 1fr;
    align-items: start;
  }
}

@media (max-width: 720px) {
  .masthead__inner {
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "brand rail"
      "search search";
    row-gap: 0.55rem;
  }
  .brand {
    grid-area: brand;
  }
  .rail-toggle {
    grid-area: rail;
  }
  .search {
    grid-area: search;
  }
  .search__label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }
  .search__field {
    max-width: none;
  }

  .grid {
    grid-template-columns: 1fr;
  }
  .grid > .cell:nth-child(n) {
    grid-column: span 1;
  }
  .grid > .cell:nth-child(n) .card__media {
    aspect-ratio: 4 / 3;
  }
  .chalk-band {
    padding-top: 1.6rem;
  }
  .chalk-band__title {
    font-size: clamp(2.1rem, 11vw, 3rem);
  }
  .chalk-band__note {
    border-top: 2px solid var(--painting);
    padding-top: 0.6rem;
  }

  .detail__grid {
    grid-template-columns: 1fr;
  }
  .detail {
    width: 100vw;
    max-width: 100vw;
    height: 100dvh;
    max-height: 100dvh;
    margin: 0;
    border-radius: 0;
  }
  .detail__shell {
    max-height: 100dvh;
  }
  .detail__img {
    min-height: 15rem;
    max-height: 40vh;
  }
  .detail__close {
    position: fixed;
    top: max(1.1rem, env(safe-area-inset-top));
    right: 1.1rem;
    margin: 0;
  }
}

@media (max-width: 420px) {
  .specs,
  .detail__facts {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .card__desc {
    font-size: 0.88rem;
  }
}

/* --- reduced motion ----------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
  .card,
  .cell {
    animation: none !important;
  }
}
