/* Artwork and category pages. Loaded after style.css for its tokens and type; these
   are ordinary scrolling pages, so the homepage's scroll lock is undone first. */

html, body {
  height: auto;
  overflow: visible;
  overscroll-behavior: auto;
}

/* ---------- Gallery wall: each category has its own painted wall ---------- */
/* Wall tokens live in style.css (shared with the homepage). pages.js sets
   body[data-cat]; cream --wall-ink passes 4.5:1 on every wall for the small caps. */

body {
  min-height: 100vh;
  color: var(--wall-ink);
  background: var(--wall-light), var(--wall);   /* --wall resolves per body[data-cat] */
  background-attachment: fixed;
  transition: background-color 400ms ease;
}

body[data-cat="fine"]    { --wall: #3d5244; }   /* forest sage */
body[data-cat="pen"]     { --wall: #27364a; }   /* ink navy */
body[data-cat="acrylic"] { --wall: #8f4a34; }   /* terracotta */
body[data-cat="nails"]   { --wall: #8a4f57; }   /* dusty rose */
body[data-cat="jewelry"] { --wall: #52304a; }   /* plum */

/* Thin black frame + hanging shadow, no mat (client, 2026-12-05). For a mat, set --mat-w
   on .piece-img-link / .cat-grid a, e.g. 6px - the image sizing already accounts for it. */
.framed {
  display: block;
  padding: var(--mat-w, 0px);
  background: var(--mat);
  border: var(--frame-w, 6px) solid var(--frame);
  box-shadow: var(--hang-shadow);
}

/* ---------- Header: name -> home, category links ---------- */

.page-bar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 32px;
  padding: 18px clamp(15px, 4vw, 48px);
  background: color-mix(in srgb, var(--wall) 88%, transparent);
  backdrop-filter: blur(8px);
}

.page-bar a,
.piece-nav a,
.piece-cat a {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 160ms ease;
}

.page-bar a:hover, .page-bar a:focus-visible,
.piece-nav a:hover, .piece-nav a:focus-visible,
.piece-cat a:hover, .piece-cat a:focus-visible,
.page-bar a[aria-current="page"] { border-bottom-color: currentColor; }

.page-home { font-size: 16px; letter-spacing: 0.18em; }

.page-cats {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 24px;
  font-size: 12px;
  letter-spacing: 0.22em;
}

.page-cats a { padding: 4px 0; }

/* ABOUT sits after the categories, set apart by a hairline. */
.page-about { position: relative; margin-left: 12px; }
.page-about::before {
  content: '';
  position: absolute;
  left: -19px;
  top: 50%;
  height: 1em;
  border-left: 1px solid currentColor;
  opacity: 0.4;
  transform: translateY(-50%);
}

/* ---------- Artwork page ---------- */

#piece {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr);
  align-items: center;
  gap: clamp(28px, 5vw, 80px);
  max-width: 1320px;
  min-height: calc(100vh - 150px);
  margin: 0 auto;
  padding: clamp(20px, 3vw, 40px) clamp(15px, 4vw, 48px);
}

.piece-img-link {
  --mat-w: 0px;
  --frame-w: clamp(5px, 0.6vw, 9px);
  justify-self: center;
  max-width: 100%;
  cursor: zoom-in;
}

/* The image box is exactly the picture's shape, sized so picture + mat + frame fit the
   screen height; the morph from a tile lands on the picture, then the mat is around it. */
#piece-img {
  display: block;
  width: calc((100vh - 210px - 2 * (var(--mat-w) + var(--frame-w))) * var(--r));
  max-width: 100%;
  height: auto;
}

/* Museum wall label: cream card, dark ink - long notes stay easy to read on any wall. */
.piece-meta {
  justify-self: start;
  max-width: 440px;
  padding: clamp(22px, 2.6vw, 34px);
  background: var(--mat);
  color: var(--frame);   /* dark ink on the cream card */
  box-shadow: 0 2px 3px rgba(0, 0, 0, 0.25), 0 18px 36px -14px rgba(0, 0, 0, 0.5);
}

.piece-cat {
  margin: 0 0 1.4em;
  font-size: 12px;
  letter-spacing: 0.22em;
}

#piece-name {
  margin: 0;
  font-size: clamp(20px, 2.2vw, 30px);
  font-weight: 400;
  letter-spacing: 0.14em;
}

#piece-medium {
  margin: 0.6em 0 0;
  font-size: 13px;
  letter-spacing: 0.16em;
}

.piece-label {
  margin: 2.6em 0 0.8em;
  font-size: 12px;
  font-weight: 400;
  letter-spacing: 0.22em;
}

#piece-thoughts {
  max-width: 46ch;
  margin: 0;
  font-size: 15px;
  line-height: 1.75;
  letter-spacing: 0.02em;
}

.piece-cat span { margin-left: 1.2em; opacity: 0.55; }
.piece-cat a { color: inherit; }

.piece-nav {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  max-width: 1320px;
  margin: 0 auto;
  padding: 8px clamp(15px, 4vw, 48px) 48px;
  font-size: 12px;
  letter-spacing: 0.22em;
}

.piece-nav [rel="next"] { margin-left: auto; }   /* stays right when there is no PREVIOUS */

/* ---------- Artwork transitions (data-enter set in piece.html <head>, data-leave by pages.js) ---------- */

/* Opening: the clicked tile and this image share a name, so the browser morphs one into the other. */
[data-enter="morph"] #piece-img { view-transition-name: piece-img; }


/* Opening without view transitions (e.g. Firefox): zoom in instead. */
[data-enter="open"] .piece-img-link { animation: piece-zoom 560ms var(--ease-out) both; }

/* Next/previous: the old piece leaves toward the side it came from... */
[data-leave] .piece-img-link,
[data-leave] .piece-meta { transition: opacity 200ms ease, transform 200ms ease; }
[data-leave] .piece-meta { opacity: 0; transform: translateY(8px); }
[data-leave="next"] .piece-img-link { opacity: 0; transform: translateX(-48px); }
[data-leave="prev"] .piece-img-link { opacity: 0; transform: translateX(48px); }

/* ...and the new one arrives from the other side. */
[data-enter="next"] .piece-img-link { animation: piece-from-right 520ms var(--ease-out) both; }
[data-enter="prev"] .piece-img-link { animation: piece-from-left 520ms var(--ease-out) both; }

/* Caption follows the picture in every case. */
[data-enter] .piece-meta { animation: piece-rise 560ms 140ms var(--ease-out) both; }

@keyframes piece-zoom       { from { opacity: 0; transform: scale(0.94); } }
@keyframes piece-from-right { from { opacity: 0; transform: translateX(56px); } }
@keyframes piece-from-left  { from { opacity: 0; transform: translateX(-56px); } }
@keyframes piece-rise       { from { opacity: 0; transform: translateY(16px); } }

.page-missing {
  padding: 20vh 24px;
  text-align: center;
  letter-spacing: 0.14em;
}

/* ---------- Category page ---------- */

.cat-head {
  max-width: 1320px;
  margin: 0 auto;
  padding: clamp(20px, 4vw, 48px) clamp(15px, 4vw, 48px) 8px;
}

.cat-head h1 {
  margin: 0;
  font-size: clamp(22px, 2.6vw, 34px);
  font-weight: 400;
  letter-spacing: 0.18em;
}

.cat-head p {
  margin: 0.6em 0 0;
  font-size: 12px;
  letter-spacing: 0.22em;
}

/* ponytail: CSS columns masonry - order runs down each column, not across. Fine for a
   handful of pieces; switch to grid-template-rows: masonry when browsers ship it. */
.cat-grid {
  columns: 3 260px;
  column-gap: 26px;
  max-width: 1320px;
  margin: 0 auto;
  padding: 24px clamp(15px, 4vw, 48px) 64px;
}

.cat-grid a {
  --mat-w: 0px;
  --frame-w: 5px;
  display: block;
  margin-bottom: 38px;
  color: inherit;
  text-decoration: none;
  break-inside: avoid;
}

.cat-grid img {
  display: block;
  width: 100%;
  height: auto;
  background: #e9e3d8;   /* placeholder while it loads */
}

.cat-grid .framed { transition: transform 220ms ease, box-shadow 220ms ease; }

@media (hover: hover) and (pointer: fine) {
  /* Lifts off the wall: the frame rises, the shadow spreads. */
  .cat-grid a:hover .framed {
    transform: translateY(-4px);
    box-shadow:
      0 4px 6px rgba(0, 0, 0, 0.3),
      0 34px 60px -14px rgba(0, 0, 0, 0.6);
  }
}

.cat-grid a:focus-visible { outline: 2px solid currentColor; outline-offset: 6px; }

.cat-grid .t {
  display: block;
  margin-top: 12px;
  font-size: 13px;
  letter-spacing: 0.16em;
}

.cat-grid .m {
  display: block;
  margin-top: 4px;
  font-size: 11px;
  letter-spacing: 0.16em;
  opacity: 0.75;
}

/* ---------- Narrow ---------- */

@media (max-width: 760px) {
  .page-bar { justify-content: center; text-align: center; }
  .page-cats { justify-content: center; gap: 4px 16px; }
  #piece { grid-template-columns: 1fr; min-height: 0; }
  #piece-img { width: calc((72vh - 2 * (var(--mat-w) + var(--frame-w))) * var(--r)); }
  .piece-meta { justify-self: stretch; max-width: none; }
}

@media (prefers-reduced-motion: reduce) {
  .cat-grid .framed { transition: none; }
  body { transition: none; }
}
