/* ==========================================================================
   Ruan Sonder — photo portfolio
   Monospace-minimal. Photos carry the page; the chrome stays quiet.
   ========================================================================== */

:root {
  --bg:          #fbfaf8;
  --surface:     #ffffff;
  --text:        #171714;
  --muted:       #6d6a62;
  --border:      #e6e2da;
  --accent:      #171714;
  --accent-text: #fbfaf8;
  --shadow:      0 1px 2px rgba(23,23,20,.05), 0 8px 24px rgba(23,23,20,.06);
  --shadow-lg:   0 2px 4px rgba(23,23,20,.06), 0 18px 48px rgba(23,23,20,.12);
  --radius:      3px;
  --maxw:        1320px;
  --gap:         clamp(.75rem, 1.6vw, 1.5rem);
  --ease:        cubic-bezier(.22,.61,.36,1);
  --font:        'Source Code Pro', ui-monospace, SFMono-Regular, Menlo, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:          #0e0e0c;
    --surface:     #171714;
    --text:        #ecE8e0;
    --muted:       #969186;
    --border:      #2a2925;
    --accent:      #ecE8e0;
    --accent-text: #0e0e0c;
    --shadow:      0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.35);
    --shadow-lg:   0 2px 4px rgba(0,0,0,.5), 0 18px 48px rgba(0,0,0,.55);
  }
}

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

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
  }
}

body {
  font-family: var(--font);
  font-size: .9375rem;
  line-height: 1.65;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}

img { display: block; max-width: 100%; height: auto; }
a { color: inherit; }

/* The `hidden` attribute must beat any component's own display rule --
   .btn sets display:inline-flex, which otherwise silently outranks the
   browser default of [hidden]{display:none} and leaks hidden controls. */
[hidden] { display: none !important; }

:focus-visible {
  outline: 2px solid var(--text);
  outline-offset: 3px;
  border-radius: 2px;
}

.container { width: 100%; max-width: var(--maxw); margin-inline: auto; padding-inline: clamp(1rem, 4vw, 2.5rem); }
.container--narrow { max-width: 760px; }

.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 200;
  background: var(--accent); color: var(--accent-text);
  padding: .75rem 1.25rem; text-decoration: none;
}
.skip-link:focus { left: 0; }

.visually-hidden {
  position: absolute !important; width: 1px; height: 1px;
  padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* --- Header ------------------------------------------------------------ */

.site-header {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
}

.site-header__inner {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; min-height: 4rem; flex-wrap: wrap;
}

.logo {
  font-weight: 600; font-size: 1rem; letter-spacing: .14em;
  text-transform: uppercase; text-decoration: none; white-space: nowrap;
}

.nav { display: flex; align-items: center; gap: clamp(.9rem, 2.4vw, 2rem); list-style: none; padding: 0; }
.nav a {
  text-decoration: none; color: var(--muted); font-size: .8125rem;
  letter-spacing: .1em; text-transform: uppercase;
  padding: .35rem 0; position: relative; transition: color .2s var(--ease);
}
.nav a::after {
  content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 1px;
  background: currentColor; transform: scaleX(0); transform-origin: left;
  transition: transform .28s var(--ease);
}
.nav a:hover, .nav a[aria-current='page'] { color: var(--text); }
.nav a:hover::after, .nav a[aria-current='page']::after { transform: scaleX(1); }
.nav a.is-admin { color: var(--muted); opacity: .7; }

/* --- Layout ------------------------------------------------------------ */

main { flex: 1; padding-block: clamp(2rem, 5vw, 4rem); }
.container > * + .section { margin-top: clamp(3rem, 8vw, 6rem); }

.section-head { margin-bottom: clamp(1.25rem, 3vw, 2rem); }
.section-head__label {
  font-size: .75rem; letter-spacing: .18em; text-transform: uppercase;
  color: var(--muted); margin-bottom: .5rem;
}
h1, h2, h3 { font-weight: 600; line-height: 1.2; letter-spacing: -.01em; }
h1 { font-size: clamp(1.6rem, 4vw, 2.5rem); }
h2 { font-size: clamp(1.25rem, 2.6vw, 1.75rem); }
h3 { font-size: 1rem; }
.lede { color: var(--muted); max-width: 60ch; margin-top: .75rem; }

/* --- Carousel ----------------------------------------------------------
   Scroll-snap rather than transform arithmetic. The previous version
   translated by exactly N*100% while the track carried a 2rem gap and 1rem
   padding, so every slide drifted a further ~32px out of frame. Native
   scrolling also gives correct touch momentum and keyboard support for free.
   ---------------------------------------------------------------------- */

.carousel { position: relative; margin-bottom: clamp(3rem, 7vw, 5rem); }

.carousel__track {
  display: flex;
  align-items: center;
  gap: var(--gap);
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.carousel__track::-webkit-scrollbar { display: none; }
@media (prefers-reduced-motion: reduce) { .carousel__track { scroll-behavior: auto; } }

/* Leading/trailing space so the first and last photo can still reach the
   centre of the scrollport. Not snap points themselves, so the carousel
   always comes to rest on a photo. */
.carousel__track::before,
.carousel__track::after { content: ''; flex: 0 0 50%; }

/* Slides take the width of their photo rather than the full container.
   Portrait shots used to letterbox into a 1920px-wide void; now the
   neighbouring frames fill that space instead. */
.carousel__slide {
  flex: 0 0 auto;
  scroll-snap-align: center;
  scroll-snap-stop: always;
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  opacity: .5;
  transition: opacity .5s var(--ease);
}
.carousel__slide.is-active { opacity: 1; }
@media (prefers-reduced-motion: reduce) { .carousel__slide { opacity: 1; } }

.carousel__slide img {
  height: clamp(300px, 64vh, 700px);
  width: auto;
  max-width: min(92vw, 1100px);
  object-fit: contain;
}

.carousel__btn {
  position: absolute; top: 50%; translate: 0 -50%;
  display: grid; place-items: center;
  width: 44px; height: 44px;           /* real 44px touch target, not a bullet glyph */
  border: 1px solid var(--border);
  border-radius: 50%;
  background: color-mix(in srgb, var(--surface) 85%, transparent);
  backdrop-filter: blur(8px);
  color: var(--text);
  cursor: pointer;
  transition: opacity .2s var(--ease), scale .2s var(--ease);
  z-index: 2;
}
.carousel__btn:hover { scale: 1.08; }
.carousel__btn[disabled] { opacity: .25; cursor: default; scale: 1; }
.carousel__btn--prev { left: clamp(.5rem, 2vw, 1.25rem); }
.carousel__btn--next { right: clamp(.5rem, 2vw, 1.25rem); }
.carousel__btn svg { width: 18px; height: 18px; }

.carousel__dots { display: flex; justify-content: center; gap: .5rem; margin-top: 1rem; }
.carousel__dot {
  width: 6px; height: 6px; padding: 0; border: 0; border-radius: 50%;
  background: var(--border); cursor: pointer;
  transition: background .25s var(--ease), width .25s var(--ease);
}
.carousel__dot[aria-current='true'] { background: var(--text); width: 22px; border-radius: 3px; }

/* --- Gallery cards (navigation — uniform by design) -------------------- */

.cards {
  display: grid;
  gap: var(--gap);
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr));
}

.card { display: block; text-decoration: none; }
.card__frame {
  position: relative; overflow: hidden; border-radius: var(--radius);
  aspect-ratio: 4 / 3; background: var(--border); box-shadow: var(--shadow);
  transition: box-shadow .35s var(--ease);
}
.card__frame img {
  width: 100%; height: 100%; object-fit: cover;
  transition: scale .6s var(--ease), filter .35s var(--ease);
}
.card:hover .card__frame { box-shadow: var(--shadow-lg); }
.card:hover .card__frame img { scale: 1.04; }

.card__body { padding-top: .75rem; display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; }
.card__title { font-size: .9375rem; font-weight: 600; }
.card__meta { font-size: .75rem; color: var(--muted); letter-spacing: .06em; white-space: nowrap; }
.card__empty { display: grid; place-items: center; height: 100%; color: var(--muted); font-size: .8125rem; }

/* --- Photo grid (masonry columns) -------------------------------------
   Photographs are never cropped here -- each tile is the image's own shape.
   The column count is capped at the number of photos via --c2/--c3/--c4, so
   a three-photo gallery doesn't render two empty columns.
   ---------------------------------------------------------------------- */

.photo-grid { column-count: 1; column-gap: var(--gap); }
@media (min-width: 640px)  { .photo-grid { column-count: var(--c2, 2); } }
@media (min-width: 1040px) { .photo-grid { column-count: var(--c3, 3); } }
@media (min-width: 1500px) { .photo-grid { column-count: var(--c4, 4); } }

.photo {
  break-inside: avoid;
  -webkit-column-break-inside: avoid;
  margin: 0 0 var(--gap);
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--border);
  box-shadow: var(--shadow);
  transition: box-shadow .35s var(--ease);
}
.photo:hover { box-shadow: var(--shadow-lg); }
.photo img {
  width: 100%; height: auto;
  transition: scale .6s var(--ease);
}
.photo:hover img { scale: 1.03; }

/* Full-tile hit area. Sits under the caption so the Save link stays clickable. */
.photo__open {
  position: absolute; inset: 0;
  border: 0; padding: 0; margin: 0;
  background: transparent;
  cursor: zoom-in;
  z-index: 1;
}

.photo__overlay {
  position: absolute; inset: auto 0 0 0; z-index: 2;
  display: flex; align-items: center; justify-content: space-between; gap: .75rem;
  padding: 2.5rem .875rem .75rem;
  background: linear-gradient(to top, rgba(0,0,0,.72), transparent);
  color: #fff; font-size: .75rem; letter-spacing: .04em;
  opacity: 0; transition: opacity .3s var(--ease);
  pointer-events: none;           /* clicks fall through to .photo__open ... */
}
.photo__overlay a { pointer-events: auto; }   /* ... except the Save link */
.photo__overlay .btn--ghost { color: #fff; border-color: rgba(255,255,255,.45); }
.photo__overlay .btn--ghost:hover { border-color: #fff; background: rgba(255,255,255,.14); }
.photo:hover .photo__overlay, .photo:focus-within .photo__overlay { opacity: 1; }
.photo__name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* --- Buttons ----------------------------------------------------------- */

.btn {
  display: inline-flex; align-items: center; gap: .5rem;
  padding: .7rem 1.35rem;
  font: inherit; font-size: .8125rem; letter-spacing: .1em; text-transform: uppercase;
  text-decoration: none; cursor: pointer;
  border: 1px solid var(--accent); border-radius: var(--radius);
  background: var(--accent); color: var(--accent-text);
  transition: opacity .2s var(--ease), background .2s var(--ease), color .2s var(--ease);
}
.btn:hover { opacity: .82; }
.btn--ghost { background: transparent; color: var(--text); border-color: var(--border); }
.btn--ghost:hover { border-color: var(--text); opacity: 1; }
.btn--sm { padding: .45rem .85rem; font-size: .6875rem; }
.btn svg { width: 15px; height: 15px; flex: none; }

.btn-row { display: flex; flex-wrap: wrap; gap: .75rem; }

/* --- Lightbox ---------------------------------------------------------- */

.lightbox {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(8,8,7,.97);
  display: grid;
  /* minmax(0,1fr), not 1fr: a bare 1fr track has an automatic minimum of the
     item's min-content size, so the row would stretch to the photo's natural
     height and push it off screen, leaving max-height:100% nothing to bite on. */
  grid-template-rows: auto minmax(0, 1fr) auto;
  opacity: 0; pointer-events: none;
  transition: opacity .28s var(--ease);
}
.lightbox[open], .lightbox.is-open { opacity: 1; pointer-events: auto; }
body.is-locked { overflow: hidden; }

.lightbox__bar {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 1rem clamp(1rem, 3vw, 2rem); color: #f2efe9;
}
.lightbox__count { font-size: .75rem; letter-spacing: .14em; color: #8f8a80; }

.lightbox__stage {
  position: relative;
  display: flex; align-items: center; justify-content: center;
  padding-inline: clamp(.5rem, 6vw, 5rem);
  min-height: 0; min-width: 0;
}
/* One image on screen at a time. The old modal never set overflow on its
   container, so all slides sat side by side across the viewport. */
.lightbox__stage img {
  max-width: 100%; max-height: 100%;
  width: auto; height: auto;
  object-fit: contain;
  border-radius: 2px;
}

.lightbox__btn {
  display: grid; place-items: center;
  width: 44px; height: 44px; flex: none;
  border: 1px solid rgba(255,255,255,.18); border-radius: 50%;
  background: rgba(255,255,255,.06); color: #f2efe9;
  cursor: pointer; transition: background .2s var(--ease), scale .2s var(--ease);
}
.lightbox__btn:hover { background: rgba(255,255,255,.16); scale: 1.08; }
.lightbox__btn:focus-visible { outline-color: #f2efe9; }
.lightbox__btn svg { width: 18px; height: 18px; }
.lightbox__nav { position: absolute; top: 50%; translate: 0 -50%; z-index: 2; }
.lightbox__nav--prev { left: clamp(.25rem, 2vw, 1.5rem); }
.lightbox__nav--next { right: clamp(.25rem, 2vw, 1.5rem); }

.lightbox__footer {
  display: flex; align-items: center; justify-content: center; gap: 1rem;
  padding: 1rem clamp(1rem, 3vw, 2rem) clamp(1.25rem, 3vw, 2rem);
  color: #8f8a80; font-size: .75rem; letter-spacing: .05em;
  text-align: center; flex-wrap: wrap;
}
.lightbox__footer .btn { border-color: rgba(255,255,255,.25); color: #f2efe9; background: transparent; }
.lightbox__footer .btn:hover { background: rgba(255,255,255,.12); }

/* --- Notices, tables, footer ------------------------------------------- */

.notice {
  border: 1px solid var(--border); border-left-width: 2px; border-left-color: var(--text);
  background: var(--surface); padding: 1rem 1.25rem; border-radius: var(--radius);
  font-size: .875rem; margin-bottom: 1.5rem;
}
.notice--warn { border-left-color: #b4741f; }

.empty { text-align: center; padding: clamp(3rem, 12vw, 7rem) 1rem; color: var(--muted); }
.empty h2 { color: var(--text); margin-bottom: .5rem; }

.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
table { width: 100%; border-collapse: collapse; font-size: .8125rem; }
th, td { padding: .75rem 1rem; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { font-size: .6875rem; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); font-weight: 600; white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
td.is-numeric { text-align: right; font-variant-numeric: tabular-nums; }

.field {
  font: inherit; font-size: .75rem;
  padding: .45rem .6rem; width: 100%; min-width: 15rem;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--bg); color: var(--text);
}

.pill {
  display: inline-block; padding: .15rem .5rem; border-radius: 999px;
  font-size: .6875rem; letter-spacing: .08em; text-transform: uppercase;
  border: 1px solid var(--border); color: var(--muted);
}
.pill--on { border-color: currentColor; color: #2f7d4f; }
.pill--off { border-color: currentColor; color: #a8442f; }

.site-footer {
  border-top: 1px solid var(--border);
  padding-block: 2rem;
  color: var(--muted); font-size: .75rem; letter-spacing: .06em;
}
.site-footer__inner { display: flex; flex-wrap: wrap; gap: .75rem 1.5rem; justify-content: space-between; align-items: center; }
.site-footer a { text-decoration: none; }
.site-footer a:hover { color: var(--text); }

/* Two real columns, centred as a unit.
   The previous version centred each row independently with a 7rem min-width
   right-aligned label, which left phantom space to the left of every label
   and none to the right of the value -- the block read as shifted right on a
   phone, and the labels never lined up with each other either. */
.meta-list {
  display: grid;
  grid-template-columns: max-content max-content;
  justify-content: center;
  gap: .55rem 1rem;
  margin-top: 2.5rem;
  list-style: none;
  padding: 0;
}
/* Keeps the semantic dl > div > dt+dd markup while letting dt/dd be the
   actual grid items. */
.meta-list > div { display: contents; }
.meta-list dt { color: var(--muted); text-align: right; }
.meta-list dd { margin: 0; text-align: left; }

/* Below this the two columns no longer fit side by side on the narrowest
   handsets, so stack label over value rather than overflow. */
@media (max-width: 430px) {
  .meta-list { grid-template-columns: 1fr; justify-items: center; gap: 0; }
  .meta-list dt { text-align: center; font-size: .75rem; letter-spacing: .1em; text-transform: uppercase; }
  .meta-list dd { text-align: center; margin-bottom: .9rem; }
}

/* --- Billing screens ---------------------------------------------------- */
/* Additions only: the tables, pills, buttons and fields these screens use
   are the same components the album admin uses. */

.messages { list-style: none; padding: 0; margin: 0 0 2rem; display: grid; gap: .75rem; }

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
  gap: 1.25rem 1.5rem;
  align-items: start;
}
.form-field--wide { grid-column: 1 / -1; }
.form-field { display: grid; gap: .4rem; }
.form-field label {
  font-size: .6875rem; letter-spacing: .12em; text-transform: uppercase;
  color: var(--muted); font-weight: 600;
}
.form-field .field { min-width: 0; }
.form-field input[type='checkbox'] { width: auto; min-width: 0; justify-self: start; }
.form-help { font-size: .75rem; color: var(--muted); margin: 0; }
.form-error { font-size: .75rem; color: #a8442f; margin: 0; }
.form-field.is-invalid .field { border-color: #a8442f; }

.filters { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; margin-bottom: 1.5rem; }
.filters .field { width: auto; min-width: 10rem; }

/* Line items share the table component; only the column widths and the
   in-cell inputs are particular to this screen. */
.line-items .field { min-width: 0; }
.line-items td { vertical-align: top; }
.line-items th:nth-child(2), .line-items td:nth-child(2) { width: 6.5rem; }
.line-items th:nth-child(3), .line-items td:nth-child(3) { width: 8.5rem; }
.line-items th:nth-child(4), .line-items td:nth-child(4) { width: 8rem; }
.line-items th:last-child,  .line-items td:last-child  { width: 5.5rem; }
.line-items textarea.field { resize: vertical; min-height: 2.4rem; }

.line-remove {
  display: inline-flex; align-items: center; gap: .4rem;
  font-size: .6875rem; letter-spacing: .06em; text-transform: uppercase; color: var(--muted);
  cursor: pointer;
}
.line-remove input { accent-color: #a8442f; }
tr.is-removed { opacity: .4; }
tr.is-removed .field { text-decoration: line-through; }

tfoot td { border-bottom: 0; padding-top: .6rem; padding-bottom: .6rem; }
tfoot .is-total td { font-weight: 600; font-size: .9375rem; border-top: 1px solid var(--border); }

.detail-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(17rem, 1fr));
  gap: 1.5rem 3rem;
}
.detail-list { display: grid; gap: .7rem; margin: 0; }
.detail-list > div { display: grid; grid-template-columns: 8rem 1fr; gap: 1rem; align-items: baseline; }
.detail-list dt {
  font-size: .6875rem; letter-spacing: .1em; text-transform: uppercase; color: var(--muted);
}
.detail-list dd { margin: 0; font-size: .875rem; }
@media (max-width: 520px) {
  .detail-list > div { grid-template-columns: 1fr; gap: .2rem; }
}

.is-muted { color: var(--muted); }
.is-mono { font-variant-numeric: tabular-nums; }
