/* ============================================================
   Delass 3D Gallery
   Two views live in one document: the gallery index and a single
   piece. body[data-view] decides which one is on screen — the piece
   is a real page, not a modal over the grid.
   ============================================================ */

:root {
  color-scheme: dark;

  --bg: #0a0a0b;
  --ink: #f2f0ed;
  --ink-dim: #a5a19b;
  --ink-faint: #8b867f;
  --accent: #c2a06a;
  --line: rgba(242, 240, 237, 0.11);
  --line-strong: rgba(242, 240, 237, 0.22);

  --serif: "Instrument Serif", Charter, "Bitstream Charter", Georgia,
    "Liberation Serif", "Times New Roman", serif;
  --sans: Inter, system-ui, -apple-system, "Segoe UI", "Liberation Sans",
    sans-serif;

  --wrap: 1180px;
  --gutter: 28px;
}

* { box-sizing: border-box; }

/* The hidden attribute must beat any display rule set below. */
[hidden] { display: none !important; }

html {
  /* No base font-size override: 1rem stays whatever the reader has set
     in their browser or in iOS text-size settings, and every type size
     below is relative to it. */
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 1rem/1.65 var(--sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* height:auto is required alongside the width/height attributes on the
   images — without it the attribute height would be taken literally. */
img { max-width: 100%; height: auto; display: block; }

.wrap {
  width: 100%;
  max-width: var(--wrap);
  margin: 0 auto;
  /* Keep clear of the notch and rounded corners in landscape. */
  padding-left: max(var(--gutter), env(safe-area-inset-left));
  padding-right: max(var(--gutter), env(safe-area-inset-right));
}

.skip {
  position: absolute;
  left: -9999px;
  background: var(--ink);
  color: var(--bg);
  padding: 10px 16px;
  z-index: 100;
}
.skip:focus { left: 12px; top: 12px; }

:focus-visible {
  outline: 1px solid var(--accent);
  outline-offset: 4px;
}

/* small caps label, used for every piece of metadata on the site */
.kicker,
.index-label,
.piece-num,
.specs dt,
.foot {
  font-family: var(--sans);
  font-weight: 400;
  font-size: 0.75rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

/* ============================================================
   masthead
   ============================================================ */

.masthead { padding-block: clamp(72px, 14vh, 140px) 0; }

.kicker {
  margin: 0 0 24px;
  color: var(--accent);
}

.masthead h1 {
  margin: 0;
  font: 400 clamp(3.5rem, 13vw, 9.25rem)/0.92 var(--serif);
  letter-spacing: -0.015em;
}

.lede {
  max-width: 38ch;
  margin: 32px 0 0;
  color: var(--ink-dim);
  font-size: 1.0625rem;
}

/* ============================================================
   gallery index
   ============================================================ */

#gallery { padding-block: clamp(64px, 12vh, 120px) 0; }

.index-label {
  margin: 0 0 20px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
  color: var(--ink-faint);
}

.grid {
  list-style: none;
  margin: 0;
  padding: 0 0 clamp(72px, 14vh, 132px);
  display: grid;
  gap: clamp(36px, 5vw, 64px) clamp(28px, 4vw, 48px);
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
}

.card { margin: 0; }

.card-btn {
  display: block;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  width: 100%;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.thumb {
  position: relative;
  aspect-ratio: 3 / 4;
  max-width: 100%;
  overflow: hidden;
  background: #060607;
}

.thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.7s cubic-bezier(0.2, 0.6, 0.2, 1),
    filter 0.5s ease;
}

/* a hairline that sits over the image edge, so the photo is framed
   without the card looking like a bordered box */
.thumb::after {
  content: "";
  position: absolute;
  inset: 0;
  border: 1px solid var(--line);
  pointer-events: none;
  transition: border-color 0.4s ease;
}

.card-btn:hover .thumb img,
.card-btn:focus-visible .thumb img { transform: scale(1.035); }

.card-btn:hover .thumb::after,
.card-btn:focus-visible .thumb::after { border-color: var(--line-strong); }

/* A lone piece would look stranded in a multi-column grid, so it gets
   laid out as a single plate with its label set beside it. */
.grid[data-count="1"] { grid-template-columns: minmax(0, 1fr); }

.grid[data-count="1"] .card-btn {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
  gap: clamp(32px, 5vw, 72px);
  align-items: end;
}

.grid[data-count="1"] .card-caption { padding-bottom: 8px; }

.grid[data-count="1"] .card-meta { margin-top: 0; }

.grid[data-count="1"] .card-title {
  font-size: clamp(1.625rem, 3.2vw, 2.375rem);
}

.card-meta {
  display: flex;
  align-items: baseline;
  gap: 14px;
  margin-top: 20px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
  transition: border-color 0.4s ease;
}

.card-btn:hover .card-meta { border-color: var(--line-strong); }

.card-num {
  flex: none;
  font-size: 0.75rem;
  letter-spacing: 0.2em;
  color: var(--accent);
}

.card-title {
  margin: 0;
  font: 400 clamp(1.3125rem, 2.3vw, 1.625rem)/1.25 var(--serif);
  letter-spacing: 0.003em;
}

.card-sub {
  margin: 12px 0 0;
  color: var(--ink-faint);
  font-size: 0.9375rem;
  font-style: italic;
  font-family: var(--serif);
}

/* ============================================================
   single piece
   ============================================================ */

.piece { padding-block: 32px clamp(56px, 9vh, 104px); }

.piece-nav {
  padding-bottom: clamp(40px, 7vh, 72px);
  border-bottom: 1px solid var(--line);
  margin-bottom: clamp(40px, 7vh, 72px);
}

.back,
.step {
  display: inline-flex;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  align-items: center;
  gap: 12px;
  min-height: 44px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--ink-dim);
  font: 400 0.75rem/1 var(--sans);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  cursor: pointer;
  transition: color 0.3s ease;
}

.back:hover,
.step:hover,
.back:active,
.step:active { color: var(--ink); }

.card-btn:active .thumb::after { border-color: var(--line-strong); }

.back-arrow {
  display: inline-block;
  transition: transform 0.3s ease;
}

.back:hover .back-arrow { transform: translateX(-5px); }

.piece-body {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
  gap: clamp(40px, 6vw, 88px);
  align-items: start;
}

.piece-figure { margin: 0; }

.piece-figure img {
  width: 100%;
  border: 1px solid var(--line);
}

.piece-num {
  margin: 0 0 20px;
  color: var(--accent);
}

.piece-title {
  margin: 0;
  font: 400 clamp(2rem, 4.4vw, 3.25rem)/1.12 var(--serif);
  letter-spacing: -0.005em;
  outline: none;
}

.piece-translit {
  margin: 18px 0 0;
  font: italic 400 clamp(1.125rem, 2vw, 1.3125rem)/1.45 var(--serif);
  color: var(--accent);
}

.piece-blurb {
  margin: 32px 0 0;
  max-width: 46ch;
  color: var(--ink-dim);
  font-size: 1rem;
}

.specs {
  margin: clamp(40px, 6vh, 60px) 0 0;
  display: grid;
  grid-template-columns: minmax(88px, auto) 1fr;
  gap: 0 28px;
}

.specs dt,
.specs dd {
  padding: 15px 0;
  border-top: 1px solid var(--line);
}

.specs dt { color: var(--ink-faint); padding-top: 18px; }

.specs dd {
  margin: 0;
  color: var(--ink);
  font-size: 0.9375rem;
}

.piece-steps {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  margin-top: clamp(64px, 10vh, 112px);
  padding-top: 28px;
  border-top: 1px solid var(--line);
}

/* ============================================================
   footer
   ============================================================ */

.foot {
  padding-block: clamp(48px, 8vh, 88px)
    calc(56px + env(safe-area-inset-bottom));
  color: var(--ink-faint);
}

.foot p { margin: 0; }

body[data-view="piece"] .foot { border-top: 1px solid var(--line); }

/* ============================================================
   narrow screens
   ============================================================ */

@media (max-width: 860px) {
  :root { --gutter: 20px; }

  .grid[data-count="1"] .card-btn {
    grid-template-columns: 1fr;
    gap: 0;
  }

  .grid[data-count="1"] .card-caption { padding-bottom: 0; }

  .grid[data-count="1"] .card-meta { margin-top: 20px; }

  .piece-body { grid-template-columns: 1fr; }

  .piece-text { padding-top: 4px; }

  .grid { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
}

@media (max-width: 520px) {
  .lede { font-size: 1rem; }
  .piece-steps { flex-direction: column; align-items: flex-start; gap: 4px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::after { transition: none !important; }
}
