/* Slice 0 holding page.
   The palette here is a first move in the direction the brief fixes — a cool, slightly grey
   paper ground rather than a warm cream — not the final call. That call belongs in the slice
   where real artwork is on screen to judge it against. */

:root {
  --paper: #f0f0ec;
  --ink: #1f1e1c;
  --muted: #5f5d58;
  --rule: #d8d7d1;
}

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

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

body {
  margin: 0;
  padding: clamp(1.5rem, 6vw, 4rem) clamp(1.25rem, 6vw, 3rem) 4rem;
  background: var(--paper);
  color: var(--ink);
  font: 400 1rem/1.6 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  max-width: 46rem;
  margin-inline: auto;
}

.masthead { margin-bottom: clamp(2rem, 8vw, 3.5rem); }

.lockup {
  display: block;
  width: 100%;
  max-width: 20rem;
  height: auto;
}

.lede {
  margin: 0 0 0.5rem;
  font-size: clamp(1.25rem, 5vw, 1.6rem);
  line-height: 1.3;
  text-wrap: balance;
}

.note { margin: 0 0 3rem; color: var(--muted); }

.stamp { border-top: 1px solid var(--rule); padding-top: 1.25rem; }

.stamp h2 {
  margin: 0 0 0.75rem;
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--muted);
}

.stamp dl {
  margin: 0;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.35rem 1rem;
  font-size: 0.8125rem;
}

.stamp dt { color: var(--muted); }
.stamp dd { margin: 0; }

.stamp code {
  font: 400 0.8125rem/1.5 ui-monospace, SFMono-Regular, Menlo, monospace;
  overflow-wrap: anywhere;
}

.stamp dd[data-mismatch] code { color: #8a2b1f; }

:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

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

/* ---- Gallery (slice 2) ---- */

.masthead a { display: inline-block; }

.page-title {
  font-size: 1.375rem;
  margin: 0 0 1.5rem;
}

.gallery-state {
  color: var(--muted);
  padding: 2rem 0;
}

/* Two columns on a phone, real aspect ratios — no crop-to-square. A CSS multi-column layout
   was tried first and rejected: it reads top-to-bottom within one column before starting the
   next, so a phone visitor scrolls through half the gallery, then has to scroll back up to see
   the other column. A plain two-up grid keeps reading order sane; each row's height follows its
   taller piece, which is enough variation without a JS masonry pass this content doesn't need. */
.gallery {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  align-items: start;
  gap: clamp(0.5rem, 2vw, 1rem);
}

@media (min-width: 720px) {
  .gallery { grid-template-columns: repeat(3, 1fr); }
}

.gallery-item {
  display: block;
  width: 100%;
  min-width: 0; /* grid items default to min-width:auto, which lets a large intrinsic image
                   size (from its width/height attributes) blow the column out to its own width
                   instead of shrinking to the track — this overrides that. */
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
}

.gallery-item img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 0; /* the paper is the frame; no rounded-card treatment */
}

.gallery-item:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 3px;
}

/* Full-screen detail viewer. Native <dialog> gives focus trapping and Escape-to-close for free. */
.detail {
  border: 0;
  padding: 0;
  margin: 0;
  max-width: 100vw;
  max-height: 100vh;
  width: 100%;
  height: 100%;
  background: var(--paper);
  color: var(--ink);
}

.detail::backdrop {
  background: var(--paper);
}

.detail[open] {
  display: flex;
  align-items: center;
  justify-content: center;
}

.detail figure {
  margin: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: clamp(1rem, 4vw, 2rem);
  gap: 1rem;
}

.detail img {
  max-width: 100%;
  max-height: 75vh;
  width: auto;
  height: auto;
  object-fit: contain;
}

.detail figcaption { text-align: center; }
.detail figcaption h2 { margin: 0 0 0.25rem; font-size: 1.0625rem; }
.detail-meta { margin: 0; color: var(--muted); font-size: 0.875rem; }

.detail-close,
.detail-nav {
  position: absolute;
  background: none;
  border: 0;
  color: var(--ink);
  font-size: 1.75rem;
  line-height: 1;
  padding: 0.75rem;
  cursor: pointer;
}

.detail-close { top: 0.5rem; right: 0.5rem; }
.detail-prev { left: 0.25rem; top: 50%; transform: translateY(-50%); }
.detail-next { right: 0.25rem; top: 50%; transform: translateY(-50%); }

@media (prefers-reduced-motion: no-preference) {
  .detail[open] {
    animation: detail-in 180ms ease-out;
  }
}

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

/* ---- Admin (slice 2) ---- */

.admin-body { max-width: 40rem; }

.admin-masthead {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}

.panel {
  border-top: 1px solid var(--rule);
  padding-top: 1.25rem;
  margin-bottom: 2rem;
}

.panel h2 { font-size: 1rem; margin: 0 0 1rem; }

.muted { color: var(--muted); font-weight: 400; }

.artwork-form,
#login-form {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-width: 28rem;
}

.artwork-form label,
#login-form label {
  font-size: 0.8125rem;
  color: var(--muted);
  margin-top: 0.5rem;
}

.artwork-form input,
.artwork-form textarea,
#login-form input {
  font: inherit;
  font-size: 1rem; /* 16px minimum — iOS zooms on focus below that */
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--rule);
  border-radius: 0;
  background: #fff;
  color: var(--ink);
  width: 100%;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.9375rem;
  color: var(--ink);
}

.checkbox-row input { width: auto; }

.btn {
  font: inherit;
  font-size: 1rem;
  font-weight: 600;
  padding: 0.75rem 1.25rem;
  margin-top: 0.75rem;
  border: 1px solid var(--ink);
  background: var(--ink);
  color: var(--paper);
  cursor: pointer;
  width: 100%;
}

.btn-quiet {
  width: auto;
  background: none;
  color: var(--ink);
  border-color: var(--rule);
  font-weight: 400;
  padding: 0.4rem 0.75rem;
}

.btn-small {
  width: auto;
  margin-top: 0;
  padding: 0.4rem 0.7rem;
  font-size: 0.8125rem;
}

.btn-file { display: inline-block; text-align: center; }

.btn-danger {
  background: var(--paper);
  color: #8a2b1f;
  border-color: #8a2b1f;
}

.form-error {
  color: #8a2b1f;
  font-size: 0.875rem;
  margin: 0.5rem 0 0;
}

.artwork-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.artwork-row {
  display: grid;
  grid-template-columns: 4.5rem 1fr;
  gap: 0.75rem;
  border-top: 1px solid var(--rule);
  padding-top: 1rem;
}

.artwork-thumb {
  width: 4.5rem;
  height: 4.5rem;
  object-fit: cover;
}

.artwork-fields {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.artwork-fields input,
.artwork-fields textarea {
  font: inherit;
  font-size: 0.9375rem;
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--rule);
  background: #fff;
  color: var(--ink);
  width: 100%;
}

.artwork-actions {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
