/* =========================================================
   BarryMade — a dark room with things in it.
   Cards behave like objects on a table. A lamp follows you.
   ========================================================= */

.workshop {
  max-width: 1500px;
  margin: 0 auto;
  padding: 0 var(--gutter) 2rem;
}

.workshop__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  padding-bottom: 1rem;
}

.workshop__hint {
  margin: 0;
  font-size: var(--t-sm);
  color: var(--ivory-dim);
  max-width: 48ch;
}

.tidy {
  font: inherit;
  font-size: var(--t-sm);
  color: var(--ivory);
  background: linear-gradient(158deg, var(--button-hi), var(--button-base));
  border: 1px solid var(--hairline);
  border-radius: 3px;
  padding: .55rem 1.05rem;
  cursor: pointer;
  box-shadow: var(--bevel), var(--lift-1);
  transition: transform .35s var(--ease-settle), border-color .3s, box-shadow .35s;
}
.tidy:hover { border-color: var(--accent-edge); transform: translateY(-1px); box-shadow: var(--bevel), var(--lift-2); }
.tidy:active { transform: translateY(1px); }

/* --- the table ---------------------------------------------------- */

.stage {
  --mx: 50%;
  --my: 50%;
  position: relative;
  height: clamp(560px, 76vh, 820px);
  border: 1px solid var(--hairline);
  border-radius: 5px;
  background:
    radial-gradient(90% 120% at 8% -20%, rgba(var(--light-rgb),.055), transparent 60%),
    linear-gradient(var(--graphite), var(--workspace-low));
  box-shadow: var(--bevel), inset 0 -60px 90px -60px rgba(var(--shadow-rgb),var(--shadow-strength));
  overflow: hidden;
  perspective: 1200px;
  touch-action: pan-y;
}

/* the lamp: a soft pool of light that follows the cursor */
.stage__lamp {
  position: absolute;
  inset: 0;
  z-index: 40;
  pointer-events: none;
  opacity: 0;
  transition: opacity .7s var(--ease-out);
  background: radial-gradient(
    circle 300px at var(--mx) var(--my),
    rgba(var(--shade-rgb),0) 0%,
    rgba(var(--shade-rgb),.34) 46%,
    rgba(var(--shade-rgb),.82) 78%,
    rgba(var(--shade-rgb),.9) 100%);
}
.stage.is-lit .stage__lamp { opacity: 1; }

/* a faint mineral bloom right at the cursor, under the cards */
.stage__pool {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity .7s var(--ease-out);
  background: radial-gradient(circle 240px at var(--mx) var(--my), rgba(var(--light-rgb),.10), transparent 70%);
}
.stage.is-lit .stage__pool { opacity: 1; }

/* --- a made thing -------------------------------------------------- */

.chip {
  --lit: 1;
  position: absolute;
  top: 0; left: 0;
  width: 244px;
  z-index: 5;
  display: block;
  text-decoration: none;
  color: inherit;
  cursor: grab;
  touch-action: none;
  transform-style: preserve-3d;
  will-change: transform;
  -webkit-user-select: none;
  user-select: none;
}
.chip.is-held { cursor: grabbing; z-index: 30; }

.chip__face {
  position: relative;
  overflow: hidden;
  border-radius: 4px;
  padding: 1.15rem 1.25rem 1.3rem;
  background:
    url("../img/card-grain.svg") repeat,
    linear-gradient(158deg, var(--card-base), var(--card-low));
  border: 1px solid rgba(var(--light-rgb), calc(0.05 + 0.10 * var(--lit)));
  box-shadow:
    inset 0 1px 0 rgba(var(--rim-rgb), calc(0.02 + 0.08 * var(--lit))),
    0 2px 4px rgba(var(--shadow-rgb), calc(0.22 * var(--shadow-strength))),
    0 calc(4px + 20px * var(--lit)) calc(12px + 40px * var(--lit)) calc(-6px - 12px * var(--lit)) rgba(var(--shadow-rgb), calc((0.5 + 0.45 * var(--lit)) * var(--shadow-strength)));
}

/* the lit face, cross-faded in by proximity to the lamp */
.chip__face::before {
  content: "";
  position: absolute;
  inset: 0;
  opacity: var(--lit);
  background:
    url("../img/card-grain.svg") repeat,
    radial-gradient(85% 100% at 8% -10%, rgba(var(--light-rgb),.04), transparent 72%),
    linear-gradient(158deg, var(--card-hi) 0%, var(--card-base) 55%, var(--card-low) 100%);
}
/* Fine bevels and a mineral reflection use the existing lamp intensity. */
.chip__face::after {
  content: "";
  position: absolute;
  inset: 0;
  opacity: var(--lit);
  background: linear-gradient(152deg, rgba(var(--light-rgb),.08), transparent 42%);
  box-shadow:
    inset 0 1px 0 rgba(var(--rim-rgb),.12),
    inset 1px 0 0 rgba(var(--rim-rgb),.04),
    inset 0 -1px 0 rgba(var(--shadow-rgb), calc(0.28 * var(--shadow-strength)));
}

.chip__inner {
  position: relative;
  z-index: 1;
  opacity: calc(0.42 + 0.58 * var(--lit));
}

.chip__meta {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  font-size: var(--t-xs);
  color: var(--ivory-dim);
  margin-bottom: .55rem;
}
.chip__kind { color: var(--accent); }

.chip__title {
  font-family: var(--serif);
  font-size: 1.28rem;
  font-variation-settings: "opsz" 24;
  font-weight: 400;
  line-height: 1.2;
  margin: 0 0 .4rem;
  color: var(--ivory);
}

.chip__note {
  margin: 0;
  font-size: var(--t-sm);
  line-height: 1.5;
  color: var(--ivory-mid);
}

.chip__tools {
  margin: .75rem 0 0;
  font-size: var(--t-xs);
  color: var(--ivory-dim);
}

/* --- one footprint for every card -----------------------------------
   Tidy up lays the grid out from the first card's size, so a card that
   grows with its text overlaps the row below. Every card gets the same
   minimum height (a two-line title plus a one-line note fits), with a
   capped line count so copy can't push a card past it. */
.chip__face {
  display: flex;
  flex-direction: column;
  min-height: 11.25rem;
}
.chip__inner {
  flex: 1;
  display: flex;
  flex-direction: column;
}
.chip__title,
.chip__note {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
}
.chip__tools {
  margin-top: auto;
  padding-top: .75rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* --- keyboard users get the lamp too ------------------------------- */
.chip:focus-visible { --lit: 1; z-index: 35; }

/* --- static fallback: no pointer, reduced motion, or narrow screen -- */

.stage.is-static {
  height: auto;
  overflow: visible;
  border: 0;
  background: none;
  box-shadow: none;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(238px, 1fr));
  gap: 1rem;
  perspective: none;
}
.stage.is-static .stage__lamp,
.stage.is-static .stage__pool { display: none; }
.stage.is-static .chip {
  position: relative;
  width: auto;
  transform: none !important;
  --lit: 1;
  cursor: pointer;
}
.stage.is-static .chip__face { height: 100%; }

@media (max-width: 620px) {
  .workshop { padding-inline: var(--gutter); }
}

/* Concept A: editorial index and tactile image cards. Shared palette stays intact. */
.barrymade-page { --bm-ink: #cfad86; }
[data-theme="light"] .barrymade-page { --bm-ink: #805334; }
.bm-skip { position: fixed; top: -6rem; left: 1rem; z-index: 210; padding: .7rem 1rem; background: var(--ivory); color: var(--void); }
.bm-skip:focus { top: 1rem; }
.bm-head { padding-top: 9rem; padding-bottom: 2.5rem; }
.bm-eyebrow { font: .7rem/1.5 var(--mono); text-transform: uppercase; letter-spacing: .13em; color: var(--bm-ink); margin-bottom: .8rem; }
.bm-head__row { display: flex; align-items: center; justify-content: space-between; gap: 2rem; }
.bm-head h1 { font-size: clamp(3.5rem, 8.8vw, 8rem); letter-spacing: -.055em; }
.bm-head h1 span { display: inline-block; vertical-align: top; font: 2rem var(--sans); color: var(--bm-ink); margin: .7rem 0 0 .4rem; }
.bm-head .page-head__note { font-size: 1.25rem; margin: 0; }
.bm-index { display: flex; flex-wrap: wrap; gap: 1rem 3rem; border-top: 1px solid var(--hairline); padding-top: 1rem; margin-top: 1.8rem; }
.bm-index a { text-decoration: none; font-size: .85rem; }
.bm-index span { color: var(--bm-ink); font: .7rem var(--mono); margin-right: .5rem; }
.bm-index a:hover, .bm-text-link:hover { color: var(--bm-ink); }
#workbench, #archive, #technical-studies { scroll-margin-top: 7.5rem; }
.workshop__bar { align-items: end; padding: 1.5rem 0; }
.workshop__bar h2 { font-size: 2rem; }
.workshop__bar .bm-eyebrow { margin-bottom: .45rem; }
.workshop__hint { margin-left: auto; font-size: .8rem; }
.tidy { border-radius: 0; background: var(--card-base); box-shadow: none; min-height: 44px; }
.tidy:disabled { opacity: .4; cursor: default; transform: none; }
.stage { border: 0; outline: 1px solid var(--hairline); border-radius: 2px; background: radial-gradient(circle, var(--hairline-lit) .7px, transparent .9px) 0 0 / 24px 24px, var(--graphite); }
.stage__lamp { opacity: 0; z-index: 1; } /* Light the table without dimming card text. */
.stage.is-lit .stage__lamp { opacity: .52; }
.chip { width: 220px; }
.chip__face { height: auto; min-height: 248px; padding: 10px 12px 12px; border-radius: 2px; }
.chip__inner { min-height: 0; opacity: 1; }
.chip__image, .chip__specimen { width: 100%; height: 94px; flex: 0 0 94px; margin-bottom: 10px; object-fit: cover; pointer-events: none; }
.chip__specimen { display: flex; align-items: center; justify-content: space-around; background: var(--workspace-low); color: var(--bm-ink); border: 1px solid var(--hairline); font: 1.6rem var(--serif); }
.chip__specimen span:first-child { font: 2.5rem var(--serif); }
.chip__meta { font-size: .75rem; gap: .4rem; margin-bottom: .35rem; flex-wrap: wrap; }
.chip__meta, .chip__tools { color: var(--ivory-mid); }
#stage .chip__kind { color: var(--accent-lit); }
.chip__title { font-size: 1.25rem; }
.chip__note { font-size: .875rem; line-height: 1.5; }
.chip__title, .chip__note { display: block; overflow: visible; -webkit-line-clamp: unset; line-clamp: unset; }
.chip__tools { font-size: .75rem; line-height: 1.5; padding-top: .5rem; white-space: normal; overflow: visible; }
.stage.is-static { outline: 0; grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr)); }
.stage.is-static .chip { touch-action: pan-y; }
.stage.is-static .chip__face { height: 100%; }
.bm-archive, .bm-studies { max-width: 1500px; margin: 4rem auto 0; padding: 0 var(--gutter); }
.bm-section-head { display: flex; justify-content: space-between; align-items: end; gap: 2rem; border-top: 1px solid var(--hairline-lit); padding-top: 2rem; }
.bm-section-head h2 { font-size: clamp(2.8rem, 5vw, 4.5rem); }
.bm-section-head > p { color: var(--ivory-mid); font-size: .9rem; margin: 0; }
.archive-controls { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin: 2rem 0 1rem; }
.archive-controls[hidden], .archive-row[hidden] { display: none; }
.archive-filters { display: flex; flex-wrap: wrap; gap: .45rem; }
.archive-filters button { font: .78rem var(--sans); color: var(--ivory-mid); background: transparent; border: 1px solid var(--hairline); padding: .65rem .9rem; min-height: 44px; border-radius: 2px; cursor: pointer; }
.archive-filters button:hover { border-color: var(--bm-ink); color: var(--ivory); }
.archive-filters button[aria-pressed="true"] { color: var(--void); background: var(--ivory); border-color: var(--ivory); }
#archive-count { flex-shrink: 0; font: .7rem var(--mono); color: var(--ivory-dim); margin: 0; }
.archive-row { display: grid; grid-template-columns: 2rem 86px minmax(0, 1fr) 160px 1.2rem; align-items: center; gap: 1.5rem; padding: 1rem .5rem; border-bottom: 1px solid var(--hairline); text-decoration: none; transition: background .2s; }
.archive-row:hover, .archive-row:focus-visible { background: var(--graphite); }
.archive-number { color: var(--bm-ink); font: .7rem var(--mono); }
.archive-preview { height: 58px; display: grid; place-items: center; background: var(--graphite); color: var(--bm-ink); font: .8rem var(--mono); overflow: hidden; }
.archive-preview img { width: 100%; height: 100%; object-fit: cover; }
.archive-title { display: block; font: 1.45rem/1.25 var(--serif); }
.archive-detail { display: block; color: var(--ivory-mid); font-size: var(--t-sm); margin-top: .25rem; }
.archive-kind { font-size: var(--t-xs); color: var(--ivory-mid); }
.archive-arrow { color: var(--bm-ink); }
.bm-studies { display: grid; grid-template-columns: 1fr 1.5fr; gap: 4rem; margin-top: 5rem; padding-top: 3rem; padding-bottom: 2rem; }
.bm-study-intro h2 { font-size: clamp(2.7rem, 5vw, 4.8rem); margin-bottom: 1.5rem; }
.bm-study-intro h2 em { color: var(--bm-ink); font-weight: 400; }
.bm-study-intro > p:not(.bm-eyebrow) { color: var(--ivory-mid); font-size: .9rem; }
.bm-text-link { font-size: .85rem; text-underline-offset: 6px; }
.bm-study-links { align-self: center; }
.study-entry { display: grid; grid-template-columns: 100px 1fr 1rem; align-items: center; gap: 1.4rem; padding: 1.5rem 0; border-top: 1px solid var(--hairline); text-decoration: none; }
.study-entry img { width: 100px; height: 100px; object-fit: cover; border-radius: 50%; border: 8px solid var(--graphite); }
.study-entry .chip__kind { font: .65rem var(--mono); }
.study-entry .chip__title { margin-top: .6rem; font-size: 1.4rem; }
.study-entry:hover .chip__title { color: var(--bm-ink); }
@media (max-width: 900px) {
  .bm-head__row { align-items: start; flex-direction: column; gap: .25rem; }
  .archive-controls { align-items: start; flex-direction: column; }
  .workshop__hint { margin-left: 0; }
  .bm-studies { gap: 2rem; }
}
@media (max-width: 600px) {
  .bm-head { padding-top: 9rem; }
  .bm-head h1 span { font-size: 1.3rem; }
  .bm-index { gap: .8rem 1.4rem; }
  .bm-index a { font-size: .75rem; }
  .workshop__bar { gap: 1rem; }
  .workshop__bar > div { width: 100%; }
  .workshop__hint { flex: 1; }
  .bm-section-head { flex-direction: column; align-items: start; gap: 1rem; }
  .archive-row { grid-template-columns: 22px 52px minmax(0,1fr) 12px; gap: .7rem; padding-inline: 0; }
  .archive-preview { height: 48px; }
  .archive-title { font-size: 1.25rem; }
  .archive-kind { display: none; }
  .bm-studies { grid-template-columns: 1fr; }
  .study-entry { grid-template-columns: 72px 1fr 12px; gap: 1rem; }
  .study-entry img { width: 72px; height: 72px; border-width: 5px; }
}
