/* ==================================================================
   Gallery — public site
   The art is the loudest thing on the page. Everything here stays quiet.
   ================================================================== */

:root {
  --serif: ui-serif, "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
  --sans: ui-sans-serif, -apple-system, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;

  --accent: #8a6a4b;
  --radius: 2px;

  --measure: 34rem;
  --page-x: clamp(1.25rem, 5vw, 5rem);
  --shell: 1600px;

  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
}

/* ---- themes ------------------------------------------------------ */
/* Plain attribute selectors, not :root — the Studio applies a theme to its
   preview pane, which is a div, not the document element. */

[data-theme="light"] {
  --bg: #fbfaf8;
  --surface: #ffffff;
  --mat: #f2f0ec;
  --ink: #16150f;
  --ink-soft: #5c584f;
  --ink-faint: #96918a;
  --line: #e3e0d9;
  --shadow: 0 18px 44px -22px rgb(30 26 18 / 0.32);
}

[data-theme="dark"] {
  --bg: #0d0d0e;
  --surface: #141416;
  --mat: #1b1b1e;
  --ink: #f1efeb;
  --ink-soft: #a5a29c;
  --ink-faint: #6d6a65;
  --line: #26262a;
  --shadow: 0 22px 50px -24px rgb(0 0 0 / 0.85);
}

[data-theme="warm"] {
  --bg: #f5efe4;
  --surface: #fbf7f0;
  --mat: #ece4d5;
  --ink: #2c2417;
  --ink-soft: #6b5c46;
  --ink-faint: #a1917a;
  --line: #ddd2bd;
  --shadow: 0 18px 44px -22px rgb(80 60 30 / 0.28);
}

[data-theme="ink"] {
  --bg: #ffffff;
  --surface: #ffffff;
  --mat: #f4f4f4;
  --ink: #000000;
  --ink-soft: #4a4a4a;
  --ink-faint: #8c8c8c;
  --line: #000000;
  --shadow: none;
}

/* ---- base -------------------------------------------------------- */

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

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  opacity: 0;
  transition: opacity 0.5s var(--ease);
}
body.is-ready { opacity: 1; }
body.lightbox-open { overflow: hidden; }

img { display: block; max-width: 100%; }
button { font: inherit; color: inherit; }

a { color: inherit; text-decoration-color: color-mix(in srgb, var(--ink) 30%, transparent); text-underline-offset: 3px; }
a:hover { text-decoration-color: var(--accent); }

:where(a, button, [tabindex]):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 100;
  padding: 0.75rem 1.25rem;
  background: var(--surface);
  border: 1px solid var(--line);
}
.skip-link:focus { left: 1rem; top: 1rem; }

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

.masthead {
  max-width: var(--shell);
  margin: 0 auto;
  padding: clamp(3.5rem, 9vw, 7.5rem) var(--page-x) clamp(2.5rem, 5vw, 4rem);
  text-align: center;
}

.site-title {
  margin: 0;
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(2.1rem, 5.5vw, 3.6rem);
  line-height: 1.1;
  letter-spacing: 0.005em;
}

.site-tagline {
  margin: 1.1rem auto 0;
  max-width: var(--measure);
  color: var(--ink-soft);
  font-size: 0.98rem;
  letter-spacing: 0.055em;
  text-transform: lowercase;
  font-variant: small-caps;
}

.collections {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.35rem 1.6rem;
  margin-top: clamp(1.75rem, 4vw, 2.75rem);
}

.collection-link {
  padding: 0.3rem 0;
  border: 0;
  background: none;
  cursor: pointer;
  color: var(--ink-faint);
  font-size: 0.78rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  border-bottom: 1px solid transparent;
  transition: color 0.25s var(--ease), border-color 0.25s var(--ease);
}
.collection-link:hover { color: var(--ink); }
.collection-link[aria-pressed="true"] {
  color: var(--ink);
  border-bottom-color: var(--accent);
}

/* ---- gallery shell ----------------------------------------------- */

main {
  max-width: var(--shell);
  margin: 0 auto;
  padding: 0 var(--page-x) clamp(4rem, 10vw, 8rem);
}

.gallery { position: relative; width: 100%; }

/* ---- a single work ----------------------------------------------- */

.piece { margin: 0; }

.piece-frame {
  position: relative;
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: var(--mat);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: zoom-in;
  aspect-ratio: var(--ar, 1);
  transition: transform 0.5s var(--ease), box-shadow 0.5s var(--ease);
}

.piece-frame img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transform: scale(1.015);
  transition: opacity 0.7s var(--ease), transform 0.7s var(--ease);
}
.piece.is-loaded .piece-frame img { opacity: 1; transform: none; }

@media (hover: hover) {
  .piece-frame:hover { transform: translateY(-3px); }
}

/* Presentation styles for the frame itself. */
[data-frame="hairline"] .piece-frame { outline: 1px solid var(--line); outline-offset: 0; }
[data-frame="mat"] .piece-frame {
  padding: clamp(10px, 2.2vw, 26px);
  background: var(--surface);
  outline: 1px solid var(--line);
}
[data-frame="mat"] .piece-frame img { object-fit: contain; }
[data-frame="shadow"] .piece-frame { box-shadow: var(--shadow); }
@media (hover: hover) {
  [data-frame="shadow"] .piece-frame:hover { box-shadow: 0 26px 56px -22px rgb(20 16 10 / 0.42); }
}

/* ---- captions ----------------------------------------------------- */

.piece-caption { padding: 0.85rem 0.1rem 0; }

.piece-title {
  margin: 0;
  font-family: var(--serif);
  font-weight: 400;
  font-size: 1.02rem;
  line-height: 1.35;
}

.piece-meta,
.piece-status {
  margin: 0.2rem 0 0;
  color: var(--ink-faint);
  font-size: 0.8rem;
  letter-spacing: 0.02em;
}

.piece-status { color: var(--ink-soft); }
.piece-status[data-status="sold"] { color: var(--ink-faint); font-style: italic; }
.piece-status[data-status="available"] { color: var(--accent); }

.piece-overlay {
  position: absolute;
  inset: auto 0 0 0;
  display: grid;
  gap: 0.15rem;
  padding: 2.75rem 1.1rem 1.05rem;
  background: linear-gradient(to top, rgb(8 7 5 / 0.72), transparent);
  color: #fff;
  text-align: left;
  opacity: 0;
  transition: opacity 0.35s var(--ease);
  pointer-events: none;
}
.piece-overlay-title { font-family: var(--serif); font-size: 1rem; }
.piece-overlay-meta { font-size: 0.76rem; opacity: 0.82; }

/* Caption mode switches which of the two is used. */
[data-captions="below"] .piece-overlay { display: none; }
[data-captions="hover"] .piece-caption { display: none; }
[data-captions="none"] .piece-caption,
[data-captions="none"] .piece-overlay { display: none; }

@media (hover: hover) {
  [data-captions="hover"] .piece-frame:hover .piece-overlay { opacity: 1; }
}
@media (hover: none) {
  [data-captions="hover"] .piece-overlay { opacity: 1; }
}

/* ---- layout: uniform grid ---------------------------------------- */

.gallery[data-layout="grid"] {
  display: grid;
  grid-template-columns: repeat(var(--columns, 3), 1fr);
  gap: var(--gap, 22px);
  align-items: start;
}
.gallery[data-layout="grid"] .piece-frame {
  aspect-ratio: 1;
  background: var(--mat);
}
/* Nothing is cropped in grid mode — works are matted, not trimmed. */
.gallery[data-layout="grid"] .piece-frame img {
  object-fit: contain;
  padding: clamp(6px, 1.4vw, 18px);
}

/* ---- layout: single column --------------------------------------- */

.gallery[data-layout="column"] {
  display: flex;
  flex-direction: column;
  /* stretch, not center: centring makes each item shrink to its image's
     intrinsic width instead of taking the column width. Centre with the
     auto margins below instead. */
  align-items: stretch;
  gap: clamp(3.5rem, 9vw, 7rem);
}
.gallery[data-layout="column"] .piece {
  width: 100%;
  max-width: 1080px;
  margin-inline: auto;
}
.gallery[data-layout="column"] .piece-caption {
  padding-top: 1.25rem;
  text-align: center;
}
.gallery[data-layout="column"] .piece-title { font-size: 1.35rem; }
.gallery[data-layout="column"] .piece-meta { font-size: 0.85rem; }

/* ---- layout: masonry / salon / justified ------------------------- */
/* These are positioned from JavaScript; the container just needs to be a
   positioning context, which .gallery already is. */

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

.empty-state {
  padding: clamp(4rem, 14vw, 9rem) 1rem;
  text-align: center;
  color: var(--ink-faint);
}
.empty-mark { margin: 0 0 1.25rem; font-size: 2.5rem; line-height: 1; color: var(--line); }
.empty-title { margin: 0; font-family: var(--serif); font-size: 1.25rem; color: var(--ink-soft); }
.empty-hint { margin: 0.5rem 0 0; font-size: 0.88rem; }

/* ---- about -------------------------------------------------------- */

.about {
  border-top: 1px solid var(--line);
  padding: clamp(3.5rem, 8vw, 6rem) var(--page-x);
}
.about-inner {
  max-width: var(--measure);
  margin: 0 auto;
  text-align: center;
}
.about-text {
  margin: 0;
  font-family: var(--serif);
  font-size: 1.06rem;
  line-height: 1.85;
  color: var(--ink-soft);
  white-space: pre-wrap;
}
/* ---- contact ------------------------------------------------------ */

.contact {
  border-top: 1px solid var(--line);
  padding: clamp(3.5rem, 8vw, 6rem) var(--page-x);
  text-align: center;
}
.contact[hidden] { display: none; }

.contact-inner { max-width: var(--measure); margin: 0 auto; }

.contact-title {
  margin: 0;
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(1.5rem, 3.5vw, 2rem);
  letter-spacing: 0.01em;
}

.contact-lead {
  margin: 0.9rem auto 2rem;
  max-width: 28rem;
  color: var(--ink-soft);
  font-size: 1rem;
  line-height: 1.7;
}

/* The address itself is the call to action, so it is sized like one. */
.contact-email {
  display: inline-block;
  padding: 0.75rem 1.6rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink);
  font-family: var(--serif);
  font-size: clamp(1rem, 2.4vw, 1.2rem);
  text-decoration: none;
  transition: border-color 0.3s var(--ease), background 0.3s var(--ease), color 0.3s var(--ease);
}
.contact-email:hover,
.contact-email:focus-visible {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 8%, transparent);
  color: var(--accent);
}
.contact-email[hidden] { display: none; }

.contact-social {
  margin: 1.5rem 0 0;
  font-size: 0.86rem;
  letter-spacing: 0.06em;
  color: var(--ink-faint);
}
.contact-social[hidden] { display: none; }

/* ---- footer ------------------------------------------------------- */

.site-footer {
  border-top: 1px solid var(--line);
  padding: 2.5rem var(--page-x) 3rem;
}
.footer-inner {
  max-width: var(--shell);
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: center;
  gap: 0.4rem 1.5rem;
  text-align: center;
  font-size: 0.78rem;
  letter-spacing: 0.07em;
  color: var(--ink-faint);
}
.footer-note { margin: 0; flex-basis: 100%; }
.footer-legal { margin: 0; }

/* The owner's entrance: present, unremarkable, findable if you know. */
.studio-link {
  color: var(--ink-faint);
  opacity: 0.55;
  text-decoration: none;
  transition: opacity 0.3s var(--ease), color 0.3s var(--ease);
}
.studio-link:hover,
.studio-link:focus-visible {
  opacity: 1;
  color: var(--accent);
}

/* ---- lightbox ----------------------------------------------------- */

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  grid-template-rows: 1fr auto;
  background: color-mix(in srgb, var(--bg) 94%, #000);
  animation: lb-in 0.3s var(--ease);
}
.lightbox[hidden] { display: none; }

@keyframes lb-in { from { opacity: 0; } to { opacity: 1; } }

.lb-stage {
  display: grid;
  place-items: center;
  padding: clamp(1rem, 4vw, 3rem) clamp(1rem, 8vw, 6rem);
  min-height: 0;
}

.lb-image {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  opacity: 0;
  transition: opacity 0.4s var(--ease);
}
.lb-image.is-ready { opacity: 1; }

.lb-details {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 2rem;
  padding: 1rem clamp(1rem, 5vw, 3rem) clamp(1.25rem, 3vw, 2.25rem);
}
.lightbox.details-hidden .lb-details { display: none; }

.lb-details-inner { max-width: 46rem; }
.lb-title { margin: 0; font-family: var(--serif); font-weight: 400; font-size: 1.35rem; }
.lb-meta { margin: 0.3rem 0 0; color: var(--ink-faint); font-size: 0.85rem; }
.lb-description {
  margin: 0.85rem 0 0;
  max-width: var(--measure);
  color: var(--ink-soft);
  font-size: 0.92rem;
  line-height: 1.7;
  white-space: pre-wrap;
}
.lb-description:empty, .lb-meta:empty, .lb-price:empty { display: none; }
.lb-price { margin: 0.7rem 0 0; color: var(--accent); font-size: 0.88rem; letter-spacing: 0.05em; }
.lb-count { color: var(--ink-faint); font-size: 0.78rem; letter-spacing: 0.12em; white-space: nowrap; }

.lb-close, .lb-nav {
  position: absolute;
  z-index: 2;
  display: grid;
  place-items: center;
  border: 0;
  background: none;
  color: var(--ink-soft);
  cursor: pointer;
  border-radius: 50%;
  transition: color 0.25s var(--ease), background 0.25s var(--ease);
}
.lb-close:hover, .lb-nav:hover { color: var(--ink); background: color-mix(in srgb, var(--ink) 8%, transparent); }

.lb-close { top: clamp(0.75rem, 2vw, 1.5rem); right: clamp(0.75rem, 2vw, 1.5rem); width: 44px; height: 44px; font-size: 1.9rem; line-height: 1; }
.lb-nav { top: 50%; transform: translateY(-50%); width: 56px; height: 56px; font-size: 2.6rem; line-height: 1; }
.lb-prev { left: clamp(0.25rem, 1.5vw, 1.25rem); }
.lb-next { right: clamp(0.25rem, 1.5vw, 1.25rem); }
.lb-nav[hidden] { display: none; }

@media (max-width: 620px) {
  .lb-details { flex-direction: column; align-items: flex-start; gap: 0.75rem; }
  .lb-nav { width: 44px; height: 44px; font-size: 2rem; }
}

/* ---- motion preferences ------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
  .piece-frame:hover { transform: none; }
}

/* ---- print --------------------------------------------------------- */

@media print {
  .collections, .site-footer, .lightbox { display: none; }
  .piece { break-inside: avoid; }
}
