/* ==========================================================================
   Gallery — a deliberately single-theme dark presentation.
   Photographs read best against a quiet ground, so the page commits to one
   look rather than following the viewer's system theme. Every colour is
   painted explicitly for that reason.
   ========================================================================== */

:root {
  --ground:      #0C0B0A;
  --ground-2:    #14120F;
  --ground-3:    #1C1916;
  --ink:         #F3F0EA;
  --ink-mid:     #A9A29A;
  --ink-muted:   #6F6862;
  --accent:      #C2A67D;
  --accent-dim:  #8C7757;
  --rule:        rgba(243, 240, 234, 0.11);
  --rule-strong: rgba(243, 240, 234, 0.22);

  --display: "Fraunces", Georgia, "Times New Roman", serif;
  --ui: "Karla", "Helvetica Neue", Arial, sans-serif;

  --bar-h: 3.75rem;
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);

  color-scheme: dark;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font-family: var(--ui);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

img { display: block; max-width: 100%; }

/* Several components set their own display, which would otherwise win. */
[hidden] { display: none !important; }

button {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
}

a { color: inherit; }

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

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

/* ==========================================================================
   Login
   ========================================================================== */

.login {
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: 2rem 1.5rem;
  position: relative;
  overflow: hidden;
}

/* A slow, barely-there warmth behind the door. */
.login::before {
  content: "";
  position: absolute;
  inset: -20%;
  background:
    radial-gradient(60% 50% at 50% 40%, rgba(194, 166, 125, 0.10), transparent 70%),
    radial-gradient(40% 40% at 75% 80%, rgba(194, 166, 125, 0.05), transparent 70%);
  pointer-events: none;
}

.login-card {
  position: relative;
  width: 100%;
  max-width: 24rem;
  text-align: center;
}

.login-mark {
  font-family: var(--ui);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink-muted);
  margin: 0 0 2.25rem;
}

.login-title {
  font-family: var(--display);
  font-optical-sizing: auto;
  font-weight: 300;
  font-size: clamp(2.1rem, 8vw, 2.9rem);
  line-height: 1.08;
  letter-spacing: -0.02em;
  margin: 0 0 0.7rem;
  text-wrap: balance;
}

.login-sub {
  color: var(--ink-mid);
  font-size: 0.95rem;
  margin: 0 0 2.5rem;
  text-wrap: balance;
}

.field {
  position: relative;
  display: grid;
  gap: 0.75rem;
}

.field input {
  width: 100%;
  font: inherit;
  font-size: 1rem;
  letter-spacing: 0.06em;
  text-align: center;
  color: var(--ink);
  background: var(--ground-2);
  border: 1px solid var(--rule);
  border-radius: 3px;
  padding: 0.95rem 1rem;
  transition: border-color 0.2s var(--ease), background 0.2s var(--ease);
}

.field input::placeholder { color: var(--ink-muted); letter-spacing: 0.02em; }
.field input:focus {
  outline: none;
  border-color: var(--accent-dim);
  background: var(--ground-3);
}

.btn {
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  padding: 0.9rem 1rem;
  border-radius: 3px;
  background: var(--ink);
  color: var(--ground);
  transition: opacity 0.2s var(--ease), transform 0.2s var(--ease);
}
.btn:hover { opacity: 0.88; }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: 0.4; cursor: default; }

.login-error {
  min-height: 1.4rem;
  margin: 1rem 0 0;
  font-size: 0.88rem;
  color: #D98A7A;
  opacity: 0;
  transition: opacity 0.25s var(--ease);
}
.login-error.is-shown { opacity: 1; }

@keyframes shake {
  10%, 90% { transform: translateX(-2px); }
  20%, 80% { transform: translateX(3px); }
  30%, 50%, 70% { transform: translateX(-5px); }
  40%, 60% { transform: translateX(5px); }
}
.login-card.is-wrong { animation: shake 0.5s var(--ease); }

/* ==========================================================================
   Cover
   ========================================================================== */

.cover {
  position: relative;
  height: min(78svh, 46rem);
  min-height: 24rem;
  display: grid;
  align-items: end;
  overflow: hidden;
}

.cover-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 1.2s var(--ease);
}
.cover-img.is-loaded { opacity: 1; }

.cover::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to bottom,
    rgba(12, 11, 10, 0.45) 0%,
    rgba(12, 11, 10, 0.12) 35%,
    rgba(12, 11, 10, 0.72) 82%,
    var(--ground) 100%
  );
  pointer-events: none;
}

.cover-inner {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 78rem;
  margin: 0 auto;
  padding: 0 clamp(1.25rem, 4vw, 3rem) clamp(2.5rem, 6vw, 4.5rem);
}

.cover-eyebrow {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 1rem;
}

.cover-title {
  font-family: var(--display);
  font-optical-sizing: auto;
  font-weight: 300;
  font-size: clamp(2.6rem, 9vw, 5.5rem);
  line-height: 1;
  letter-spacing: -0.03em;
  margin: 0 0 0.8rem;
  text-wrap: balance;
}

.cover-meta a.credit-link {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px solid var(--rule-strong);
  padding-bottom: 1px;
  transition: color 0.2s var(--ease), border-color 0.2s var(--ease);
}
.cover-meta a.credit-link:hover { color: var(--ink); border-bottom-color: var(--accent); }

.cover-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1.5rem;
  font-size: 0.92rem;
  color: var(--ink-mid);
  margin: 0;
}

/* ==========================================================================
   Bar
   ========================================================================== */

.bar {
  position: sticky;
  top: 0;
  z-index: 40;
  height: var(--bar-h);
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0 clamp(1rem, 4vw, 3rem);
  background: rgba(12, 11, 10, 0.82);
  backdrop-filter: blur(14px) saturate(1.4);
  -webkit-backdrop-filter: blur(14px) saturate(1.4);
  border-bottom: 1px solid transparent;
  transition: border-color 0.3s var(--ease);
}
.bar.is-stuck { border-bottom-color: var(--rule); }

.bar-count {
  font-size: 0.8rem;
  letter-spacing: 0.06em;
  color: var(--ink-mid);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.bar-count strong { color: var(--ink); font-weight: 600; }

.bar-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.76rem;
  font-weight: 500;
  letter-spacing: 0.05em;
  color: var(--ink-mid);
  padding: 0.5rem 0.85rem;
  border: 1px solid var(--rule);
  border-radius: 999px;
  white-space: nowrap;
  transition: color 0.2s var(--ease), border-color 0.2s var(--ease), background 0.2s var(--ease);
}
.chip:hover { color: var(--ink); border-color: var(--rule-strong); }
.chip[aria-pressed="true"] {
  color: var(--ground);
  background: var(--accent);
  border-color: var(--accent);
}
.chip svg { width: 0.95rem; height: 0.95rem; flex: none; }

/* The one call to action that changes state on the client's own files. */
.chip--primary {
  color: var(--ground);
  background: var(--ink);
  border-color: var(--ink);
  font-weight: 600;
}
.chip--primary:hover { color: var(--ground); background: #fff; border-color: #fff; }
.chip-num { font-variant-numeric: tabular-nums; opacity: 0.75; }

/* Four chips plus a count will not fit one line on a phone. Rather than
   hiding the labels — which left two download buttons looking identical —
   the bar wraps onto a second row and everything stays legible. */
@media (max-width: 760px) {
  .bar {
    height: auto;
    min-height: var(--bar-h);
    flex-wrap: wrap;
    align-items: center;
    padding-top: 0.6rem;
    padding-bottom: 0.6rem;
    gap: 0.55rem;
  }
  /* The heart chip already carries the count that matters while
     scrolling, so the total comes out and the bar stays two rows. */
  .bar-count { display: none; }
  .bar-actions {
    margin-left: 0;
    width: 100%;
    flex-wrap: wrap;
    gap: 0.4rem;
  }
  .chip { font-size: 0.72rem; padding: 0.5rem 0.75rem; }
}

/* ==========================================================================
   Grid — justified rows, sized in JS from each photo's aspect ratio
   ========================================================================== */

.grid {
  max-width: 100rem;
  margin: 0 auto;
  padding: clamp(1rem, 3vw, 2rem) clamp(0.5rem, 2vw, 1.5rem) 6rem;
  display: flex;
  flex-direction: column;
  gap: var(--gap, 8px);
}

.row {
  display: flex;
  gap: var(--gap, 8px);
}

.tile {
  position: relative;
  display: block;
  overflow: hidden;
  background: var(--ground-2);
  border-radius: 2px;
  flex: none;
  cursor: zoom-in;
}

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

.tile::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(12, 11, 10, 0.5), transparent 45%);
  opacity: 0;
  transition: opacity 0.3s var(--ease);
  pointer-events: none;
}
.tile:hover::after,
.tile:focus-visible::after { opacity: 1; }

.tile-fav {
  position: absolute;
  right: 0.5rem;
  bottom: 0.5rem;
  width: 2rem;
  height: 2rem;
  display: grid;
  place-items: center;
  border-radius: 999px;
  color: var(--ink);
  background: rgba(12, 11, 10, 0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.25s var(--ease), transform 0.25s var(--ease), color 0.2s var(--ease);
}
.tile:hover .tile-fav,
.tile:focus-within .tile-fav,
.tile-fav[aria-pressed="true"] { opacity: 1; transform: none; }
.tile-fav[aria-pressed="true"] { color: var(--accent); }
.tile-fav svg { width: 1.05rem; height: 1.05rem; }

.empty {
  padding: 6rem 1.5rem;
  text-align: center;
  color: var(--ink-mid);
}
.empty h2 {
  font-family: var(--display);
  font-weight: 300;
  font-size: 1.6rem;
  color: var(--ink);
  margin: 0 0 0.5rem;
}

/* ==========================================================================
   Lightbox
   ========================================================================== */

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(8, 7, 6, 0.97);
  display: grid;
  grid-template-rows: 1fr auto;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s var(--ease), visibility 0.3s var(--ease);
}
.lightbox.is-open { opacity: 1; visibility: visible; }

.lb-stage {
  position: relative;
  display: grid;
  place-items: center;
  overflow: hidden;
  padding: clamp(1rem, 3vw, 2.5rem);
  padding-bottom: 0;
}

/* Fills the stage in both directions rather than sitting at natural size,
   so a preview file doesn't float small in the middle of a large display. */
.lb-img {
  width: 100%;
  height: 100%;
  min-height: 0;
  object-fit: contain;
  opacity: 0;
  transition: opacity 0.35s var(--ease);
  user-select: none;
  -webkit-user-drag: none;
}
.lb-img.is-loaded { opacity: 1; }

.lb-spinner {
  position: absolute;
  width: 1.5rem;
  height: 1.5rem;
  border: 2px solid var(--rule-strong);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  opacity: 0;
  transition: opacity 0.2s var(--ease);
}
.lb-spinner.is-shown { opacity: 1; }
@keyframes spin { to { transform: rotate(360deg); } }

.lb-nav {
  position: absolute;
  top: 0;
  bottom: 0;
  width: clamp(3.5rem, 12vw, 7rem);
  display: grid;
  place-items: center;
  color: var(--ink);
  opacity: 0.45;
  transition: opacity 0.2s var(--ease);
}
.lb-nav:hover { opacity: 1; }
.lb-nav[disabled] { opacity: 0.12; cursor: default; }
.lb-prev { left: 0; }
.lb-next { right: 0; }
.lb-nav svg { width: 1.6rem; height: 1.6rem; }

.lb-close {
  position: absolute;
  top: clamp(0.75rem, 2vw, 1.5rem);
  right: clamp(0.75rem, 2vw, 1.5rem);
  width: 2.75rem;
  height: 2.75rem;
  display: grid;
  place-items: center;
  border-radius: 999px;
  color: var(--ink);
  opacity: 0.6;
  transition: opacity 0.2s var(--ease), background 0.2s var(--ease);
  z-index: 2;
}
.lb-close:hover { opacity: 1; background: rgba(243, 240, 234, 0.08); }
.lb-close svg { width: 1.15rem; height: 1.15rem; }

.lb-bar {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem clamp(1rem, 3vw, 2.5rem);
  padding-bottom: max(1rem, env(safe-area-inset-bottom));
  border-top: 1px solid var(--rule);
}

.lb-index {
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  color: var(--ink-muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.lb-actions { margin-left: auto; display: flex; gap: 0.4rem; }

@media (max-width: 560px) {
  .lb-nav { width: 22vw; }
  .lb-index { font-size: 0.72rem; }
  .lb-bar { gap: 0.6rem; }
}

/* ==========================================================================
   Toast
   ========================================================================== */

.toast {
  position: fixed;
  left: 50%;
  bottom: 2rem;
  transform: translate(-50%, 1rem);
  z-index: 200;
  font-size: 0.85rem;
  color: var(--ground);
  background: var(--ink);
  padding: 0.7rem 1.15rem;
  border-radius: 999px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s var(--ease), transform 0.25s var(--ease);
  max-width: calc(100vw - 2rem);
  text-align: center;
}
.toast.is-shown { opacity: 1; transform: translate(-50%, 0); }

/* ==========================================================================
   Footer
   ========================================================================== */

.foot {
  line-height: 1.6;
  padding: 3rem clamp(1.25rem, 4vw, 3rem) 4rem;
  border-top: 1px solid var(--rule);
  display: flex;
  flex-wrap: wrap;
  gap: 1rem 2rem;
  align-items: baseline;
  font-size: 0.85rem;
  color: var(--ink-muted);
}
.foot a { color: var(--ink-mid); text-decoration-color: var(--rule-strong); text-underline-offset: 3px; }
.foot a:hover { color: var(--ink); }
.foot-credit { margin-left: auto; }

/* A saved photograph reads as filled, not merely outlined. */
.tile-fav[aria-pressed="true"] svg,
.chip[aria-pressed="true"] svg { fill: currentColor; }

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