/* ---------------------------------------------------------------------------
   Wedding gallery — warm, quiet, and readable on a phone in a dark room.
   No web fonts on purpose: the venue wifi has better things to do.
   --------------------------------------------------------------------------- */

:root {
  --bg: #faf7f2;
  --bg-sunk: #f2ece3;
  --surface: #ffffff;
  --ink: #2b2724;
  --ink-soft: #6d655c;
  --muted: #948a7e;
  --accent: #9c7c4f;
  --accent-ink: #ffffff;
  --line: rgba(43, 39, 36, 0.12);
  --shadow-sm: 0 1px 2px rgba(43, 39, 36, 0.06), 0 4px 14px rgba(43, 39, 36, 0.05);
  --shadow-lg: 0 10px 40px rgba(43, 39, 36, 0.16);
  --danger: #a8412f;
  --ok: #4b7a52;

  --serif: ui-serif, Georgia, "Iowan Old Style", "Palatino Linotype", "Times New Roman", serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --radius: 14px;
  --radius-sm: 10px;
  --page: 1140px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141210;
    --bg-sunk: #100e0c;
    --surface: #1e1b18;
    --ink: #f1eae0;
    --ink-soft: #b9b0a4;
    --muted: #8d8478;
    --accent: #d4b483;
    --accent-ink: #241d13;
    --line: rgba(241, 234, 224, 0.14);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4), 0 4px 14px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 40px rgba(0, 0, 0, 0.55);
    --danger: #e08573;
    --ok: #86bb8f;
  }
}

* {
  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.5;
  -webkit-font-smoothing: antialiased;
  overflow-wrap: break-word;
}

body.no-scroll {
  overflow: hidden;
}

h1,
h2 {
  font-family: var(--serif);
  font-weight: 400;
  margin: 0;
  letter-spacing: 0.01em;
}

[hidden] {
  display: none !important;
}

/* --- buttons ---------------------------------------------------------- */

.btn {
  appearance: none;
  border: 1px solid transparent;
  border-radius: 999px;
  font: inherit;
  font-size: 0.95rem;
  padding: 0.7rem 1.4rem;
  cursor: pointer;
  transition: transform 0.12s ease, background-color 0.15s ease, opacity 0.15s ease;
  color: var(--ink);
  background: transparent;
  min-height: 44px; /* thumb-sized */
}

.btn:active {
  transform: scale(0.97);
}

.btn:disabled {
  opacity: 0.5;
  cursor: default;
}

.btn-primary {
  background: var(--accent);
  color: var(--accent-ink);
  box-shadow: var(--shadow-sm);
}

.btn-ghost {
  border-color: var(--line);
  background: var(--surface);
}

.btn-danger {
  border-color: color-mix(in srgb, var(--danger) 45%, transparent);
  color: var(--danger);
  background: transparent;
}

.btn-lg {
  font-size: 1.05rem;
  padding: 0.9rem 2rem;
}

.btn-sm {
  font-size: 0.85rem;
  padding: 0.45rem 0.95rem;
  min-height: 36px;
}

.btn-block {
  display: block;
  width: 100%;
}

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

/* --- lock screen ------------------------------------------------------ */

.lock {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
}

.lock-card {
  width: min(26rem, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 2.5rem 1.75rem;
  text-align: center;
}

.lock-mark {
  color: var(--accent);
  font-size: 1.6rem;
  margin: 0 0 1rem;
}

.lock-couple {
  font-size: 1.9rem;
  margin-bottom: 1.5rem;
}

.lock-title {
  font-size: 1.25rem;
  margin-bottom: 0.6rem;
}

.lock-body {
  color: var(--ink-soft);
  margin: 0;
}

.lock-bad {
  margin: 1rem 0 0;
  color: var(--danger);
  font-size: 0.9rem;
}

.lock-card input[type="password"],
.lock-card input[type="text"] {
  width: 100%;
  margin: 1.25rem 0 0.75rem;
}

/* --- header ----------------------------------------------------------- */

.site-header {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 1.25rem 1rem 0.5rem;
  max-width: var(--page);
  margin: 0 auto;
}

.site-names {
  text-align: center;
}

.site-names h1 {
  font-size: clamp(1.6rem, 6vw, 2.4rem);
}

.site-names p {
  margin: 0.15rem 0 0;
  color: var(--muted);
  font-size: 0.85rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.lang-btn,
.admin-link {
  position: absolute;
  top: 1.1rem;
  font-size: 0.8rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.35rem 0.8rem;
  cursor: pointer;
  text-decoration: none;
  font-family: inherit;
}

.lang-btn {
  left: 1rem;
}

.admin-link {
  right: 1rem;
}

/* --- hero ------------------------------------------------------------- */

.hero {
  text-align: center;
  padding: 1.25rem 1rem 1.75rem;
}

.hero-lead {
  color: var(--ink-soft);
  margin: 0 0 1.1rem;
}

.count {
  margin: 0.9rem 0 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.new-banner {
  display: block;
  margin: 0 auto 1rem;
  background: var(--accent);
  color: var(--accent-ink);
  border: none;
  border-radius: 999px;
  padding: 0.55rem 1.2rem;
  font: inherit;
  font-size: 0.9rem;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
}

/* --- grid ------------------------------------------------------------- */

.grid {
  max-width: var(--page);
  margin: 0 auto;
  padding: 0 0.5rem 6rem;
  columns: 2;
  column-gap: 0.5rem;
}

@media (min-width: 640px) {
  .grid {
    columns: 3;
    column-gap: 0.75rem;
    padding: 0 1rem 6rem;
  }
}

@media (min-width: 1000px) {
  .grid {
    columns: 4;
  }
}

.tile {
  display: block;
  width: 100%;
  break-inside: avoid;
  margin: 0 0 0.5rem;
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  position: relative;
  border-radius: var(--radius-sm);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: transform 0.18s ease;
}

@media (min-width: 640px) {
  .tile {
    margin-bottom: 0.75rem;
  }
  .tile:hover {
    transform: translateY(-2px);
  }
}

.tile-frame {
  display: block;
  position: relative;
  width: 100%;
  background: var(--bg-sunk);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.tile-frame img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 0.35s ease;
}

.tile-frame.loaded img {
  opacity: 1;
}

.tile-frame.broken {
  background: var(--bg-sunk);
}

.tile-video {
  position: absolute;
  right: 0.5rem;
  bottom: 0.5rem;
  width: 1.9rem;
  height: 1.9rem;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: rgba(20, 18, 16, 0.6);
  backdrop-filter: blur(4px);
}

.tile-video svg {
  width: 0.95rem;
  height: 0.95rem;
  fill: #fff;
}

.tile-label {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 1.6rem 0.6rem 0.5rem;
  font-size: 0.78rem;
  color: #fff;
  text-align: left;
  background: linear-gradient(to top, rgba(20, 18, 16, 0.7), transparent);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
}

.empty,
.loading {
  text-align: center;
  color: var(--muted);
  padding: 2rem 1rem;
  margin: 0;
}

.sentinel {
  height: 1px;
}

.site-footer {
  text-align: center;
  color: var(--accent);
  padding: 0 1rem 5rem;
}

/* --- floating action button ------------------------------------------ */

.fab {
  position: fixed;
  right: 1rem;
  bottom: calc(1rem + env(safe-area-inset-bottom));
  width: 3.5rem;
  height: 3.5rem;
  border-radius: 999px;
  border: none;
  background: var(--accent);
  color: var(--accent-ink);
  box-shadow: var(--shadow-lg);
  cursor: pointer;
  display: grid;
  place-items: center;
  z-index: 40;
}

.fab svg {
  width: 1.5rem;
  height: 1.5rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
}

/* --- upload sheet ----------------------------------------------------- */

.sheet {
  border: none;
  padding: 0;
  background: transparent;
  max-width: 100%;
  max-height: 100%;
  width: 100%;
  color: var(--ink);
}

.sheet::backdrop {
  background: rgba(20, 18, 16, 0.55);
  backdrop-filter: blur(2px);
}

.sheet-inner {
  background: var(--surface);
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 1.5rem 1.25rem calc(1.5rem + env(safe-area-inset-bottom));
  max-height: 88dvh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.sheet {
  margin: auto auto 0;
}

@media (min-width: 640px) {
  .sheet {
    margin: auto;
    width: min(32rem, 100%);
  }
  .sheet-inner {
    border-radius: var(--radius);
  }
}

.sheet-head h2 {
  font-size: 1.35rem;
}

.sheet-head p {
  margin: 0.35rem 0 1.1rem;
  color: var(--ink-soft);
  font-size: 0.92rem;
}

.sheet-fields {
  display: grid;
  gap: 0.6rem;
  margin-bottom: 1rem;
}

input[type="text"],
input[type="password"] {
  font: inherit;
  width: 100%;
  padding: 0.75rem 0.9rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--ink);
  min-height: 44px;
}

input::placeholder {
  color: var(--muted);
}

.queue {
  list-style: none;
  margin: 1rem 0 0;
  padding: 0;
  display: grid;
  gap: 0.6rem;
}

.queue-row {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

.queue-thumb {
  flex: 0 0 auto;
  width: 3rem;
  height: 3rem;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--bg-sunk);
  display: grid;
  place-items: center;
}

.queue-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.queue-thumb.is-video svg {
  width: 1.1rem;
  height: 1.1rem;
  fill: var(--muted);
}

.queue-body {
  flex: 1 1 auto;
  min-width: 0;
  display: grid;
  gap: 0.25rem;
}

.queue-name {
  font-size: 0.85rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--ink-soft);
}

.queue-status {
  font-size: 0.78rem;
  color: var(--muted);
}

.queue-row[data-state="done"] .queue-status,
.queue-row[data-state="duplicate"] .queue-status {
  color: var(--ok);
}

.queue-row[data-state="error"] .queue-status {
  color: var(--danger);
}

.queue-track {
  height: 3px;
  border-radius: 999px;
  background: var(--bg-sunk);
  overflow: hidden;
}

.queue-bar {
  display: block;
  height: 100%;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform 0.2s ease;
}

.queue-row[data-state="error"] .queue-bar {
  background: var(--danger);
}

.sheet-summary {
  margin: 1rem 0 0;
  text-align: center;
  color: var(--ok);
  font-size: 0.92rem;
}

.sheet-inner .btn-block + .queue {
  margin-top: 1.1rem;
}

.sheet-inner > .btn-ghost {
  margin-top: 1rem;
}

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

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 60;
  /* Solid, not translucent: photos read best against true black, and the
     header bleeding through at 4% was just visual noise. */
  background: #0c0b0a;
  display: grid;
  grid-template-rows: 1fr auto;
  touch-action: pan-y;
}

.lb-stage {
  /* Flex, not grid: as a grid item a replaced element ignores max-height:100%
     and lays out at its intrinsic size, so a 1920x1080 video overflowed the
     stage and pushed its own playback controls below the fold. */
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 3.5rem 0.5rem 0.5rem;
  min-height: 0;
  overflow: hidden;
}

.lb-media {
  display: block;
  max-width: 100%;
  max-height: 100%;
  min-height: 0;
  object-fit: contain;
  border-radius: 6px;
}

/* Video fills the stage and letterboxes itself. The poster attribute pins the
   element's intrinsic size to the poster image, so without this a 1080p clip
   renders at 512px. Images deliberately keep only max-width/max-height, so a
   small photo is shown at its own size rather than upscaled into blur. */
video.lb-media {
  width: 100%;
  height: 100%;
}

.lb-bar {
  padding: 0.75rem 1rem calc(1rem + env(safe-area-inset-bottom));
  text-align: center;
  color: rgba(255, 255, 255, 0.9);
}

.lb-caption {
  margin: 0;
  font-size: 0.95rem;
}

.lb-counter {
  margin: 0.3rem 0 0;
  font-size: 0.78rem;
  color: rgba(255, 255, 255, 0.55);
}

.lb-close,
.lb-nav {
  position: absolute;
  z-index: 2;
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 999px;
  border: none;
  background: rgba(255, 255, 255, 0.12);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: opacity 0.15s ease;
}

.lb-close svg,
.lb-nav svg {
  width: 1.3rem;
  height: 1.3rem;
  fill: none;
  stroke: #fff;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.lb-close {
  top: calc(0.75rem + env(safe-area-inset-top));
  right: 0.75rem;
}

.lb-nav {
  top: 50%;
  transform: translateY(-50%);
}

.lb-prev {
  left: 0.6rem;
}

.lb-next {
  right: 0.6rem;
}

.lb-nav:disabled {
  opacity: 0;
  pointer-events: none;
}

@media (max-width: 639px) {
  .lb-nav {
    display: none; /* swiping is the gesture here */
  }
}

/* --- admin ------------------------------------------------------------ */

.stats {
  max-width: var(--page);
  margin: 0 auto;
  padding: 0.5rem 1rem 0;
  display: grid;
  /* Two clean rows on a phone beats three-then-one. */
  grid-template-columns: repeat(2, 1fr);
  gap: 0.6rem;
}

@media (min-width: 640px) {
  .stats {
    grid-template-columns: repeat(4, 1fr);
  }
}

.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0.8rem 0.9rem;
}

.stat-value {
  display: block;
  font-family: var(--serif);
  font-size: 1.5rem;
}

.stat-label {
  display: block;
  font-size: 0.75rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.guest-link {
  max-width: var(--page);
  margin: 1.25rem auto 0;
  padding: 0 1rem;
}

.guest-link label {
  display: block;
  font-size: 0.75rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 0.35rem;
}

.guest-link-row {
  display: flex;
  gap: 0.5rem;
}

.guest-link-row input {
  flex: 1 1 auto;
  font-size: 0.85rem;
}

.tabs {
  max-width: var(--page);
  margin: 1.5rem auto 0.75rem;
  padding: 0 1rem;
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.tab {
  font: inherit;
  font-size: 0.9rem;
  padding: 0.45rem 1rem;
  min-height: 40px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink-soft);
  cursor: pointer;
}

.tab[aria-selected="true"] {
  background: var(--ink);
  color: var(--bg);
  border-color: var(--ink);
}

.tabs .btn-danger {
  margin-left: auto;
}

.admin-grid {
  max-width: var(--page);
  margin: 0 auto;
  padding: 0 1rem 2rem;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(9.5rem, 1fr));
  gap: 0.75rem;
}

.admin-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.admin-card img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  display: block;
  background: var(--bg-sunk);
}

.admin-card.is-deleted img {
  filter: grayscale(1);
  opacity: 0.55;
}

.admin-meta {
  padding: 0.5rem 0.6rem;
  font-size: 0.72rem;
  color: var(--muted);
  display: grid;
  gap: 0.1rem;
  flex: 1 1 auto;
}

.admin-meta strong {
  color: var(--ink-soft);
  font-weight: 500;
  font-size: 0.78rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-warn {
  color: var(--danger);
}

.admin-noimage {
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  background: var(--bg-sunk);
  color: var(--muted);
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.admin-actions {
  display: flex;
  gap: 0.35rem;
  padding: 0 0.5rem 0.5rem;
}

.admin-actions .btn {
  flex: 1 1 auto;
  padding: 0.4rem 0.5rem;
  min-height: 34px;
  font-size: 0.78rem;
  border-radius: var(--radius-sm);
}

.admin-open {
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  display: block;
}

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