/* Photo Drop — guest page
   Phone-first, one column. The couple's names are the only display type.
   --accent is the event's colour (set on <body> by the script).
   The slot row (one dot per photo the guest may share) is the one bold element. */

:root {
  --bg:       #fcfcfa;
  --surface:  #ffffff;
  --ink:      #261a2e;
  --ink-soft: #6e6276;
  --line:     #e7e2ea;
  --error:    #b3261e;
  --ok:       #2e6b3c;

  --accent: #9a6b3f;               /* overridden per event */
  --on-accent: #ffffff;
  --accent-ink: var(--accent);     /* accent used as text; darkened for light accents */

  --radius: 12px;
  --font: "Schibsted Grotesk", system-ui, sans-serif;
  --display: "Marcellus", Georgia, serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:       #17121b;
    --surface:  #211a27;
    --ink:      #f4eff6;
    --ink-soft: #b5a9bd;
    --line:     #362c3e;
    --error:    #ef6b62;
    --ok:       #5fae70;
  }
}

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

[hidden] { display: none !important; }

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

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.5;
}

h1, h2, p, ul, blockquote { margin: 0; }
ul { padding: 0; list-style: none; }

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

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

/* ---------- Shell ---------- */

.shell {
  max-width: 480px;
  margin: 0 auto;
  padding: max(40px, env(safe-area-inset-top)) 20px max(96px, env(safe-area-inset-bottom));
}

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

.couple {
  text-align: center;
  padding-bottom: 28px;
  margin-bottom: 32px;
  border-bottom: 1px solid var(--line);
}

.couple-intro {
  color: var(--ink-soft);
  font-size: 0.9375rem;
}

.couple h1 {
  margin: 10px 0 12px;
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(2.5rem, 12vw, 3.5rem);
  line-height: 1.05;
  letter-spacing: 0.01em;
}

.couple h1 > span { display: block; }

.couple .amp {
  font-size: 0.55em;
  line-height: 1.4;
  color: var(--ink-soft);
}

.couple-date {
  color: var(--ink-soft);
  font-size: 0.9375rem;
}

/* ---------- States ---------- */

.state {
  display: grid;
  gap: 16px;
  text-align: center;
}

.state h2 {
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.25;
}

.state > p { color: var(--ink-soft); text-wrap: pretty; }

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

.button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 54px;
  padding: 12px 20px;
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  background: var(--accent);
  color: var(--on-accent);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.button:active { transform: translateY(1px); }
.button:disabled { opacity: 0.6; cursor: default; }

.button.secondary {
  background: transparent;
  color: var(--ink);
  border-color: var(--line);
}

.button-stack {
  display: grid;
  gap: 10px;
  margin-top: 8px;
}

/* ---------- Name form ---------- */

.name-form {
  display: grid;
  gap: 10px;
  margin-top: 8px;
  text-align: left;
}

.name-form label {
  font-size: 0.9375rem;
  font-weight: 600;
}

.name-form input {
  width: 100%;
  min-height: 54px;
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 1.0625rem;   /* ≥16px so iOS doesn't zoom */
}

.name-form input::placeholder { color: var(--ink-soft); opacity: 0.7; }

.name-form input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 0;
  border-color: var(--accent);
}

.name-form .button { margin-top: 8px; }

.error,
.state > .error {
  color: var(--error);
  font-size: 0.9375rem;
}
.error:empty { display: none; }

/* ---------- Slot row: one dot per photo the guest may share ----------
   --cap, --used and --picked are set by the script.
   Filled = uploaded, ring = chosen and waiting, faint = still free. */

.slots {
  --cell: calc(100% / var(--cap));
  position: relative;
  width: 100%;
  max-width: calc(var(--cap) * 18px);
  height: 18px;
  margin: 4px auto 0;
  background:
    radial-gradient(circle, var(--line) 0 4px, transparent 4.5px)
    0 0 / var(--cell) 100% repeat-x;
}

.slots::before,
.slots::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
}

.slots::before {
  left: 0;
  width: calc(100% * var(--used) / var(--cap));
  background:
    radial-gradient(circle, var(--accent) 0 5px, transparent 5.5px)
    0 0 / calc(100% / var(--used)) 100% repeat-x;
}

.slots::after {
  left: calc(100% * var(--used) / var(--cap));
  width: calc(100% * var(--picked) / var(--cap));
  background:
    radial-gradient(circle, transparent 0 3px, var(--accent) 3.5px 5px, transparent 5.5px)
    0 0 / calc(100% / var(--picked)) 100% repeat-x;
}

.count {
  color: var(--ink-soft);
  font-size: 0.9375rem;
  font-variant-numeric: tabular-nums;
}

/* ---------- Picker ---------- */

.picker {
  display: grid;
  gap: 2px;
  place-items: center;
  margin-top: 8px;
  padding: 28px 20px;
  border: 1.5px dashed color-mix(in srgb, var(--accent) 55%, var(--line));
  border-radius: 16px;
  background: color-mix(in srgb, var(--accent) 6%, var(--surface));
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.picker:active { background: color-mix(in srgb, var(--accent) 12%, var(--surface)); }

.picker:has(+ #photo-input:focus-visible) {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}

.picker-title {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--accent-ink);
}

/* On the dark background a light accent already reads well. */
@media (prefers-color-scheme: dark) {
  .picker-title { color: var(--accent); }
}

.picker-sub {
  color: var(--ink-soft);
  font-size: 0.9375rem;
}

.notice {
  font-size: 0.875rem;
  color: var(--ink-soft);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 14px;
}
.notice:empty { display: none; }

/* ---------- Tiles ---------- */

.tiles {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  text-align: left;
}

.tile {
  position: relative;
  display: grid;
  gap: 4px;
  align-content: start;
  font-size: 0.75rem;
}

.thumb {
  position: relative;
  aspect-ratio: 1;
  border-radius: 10px;
  overflow: hidden;
  background: color-mix(in srgb, var(--ink) 8%, var(--surface));
}

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

.tile-name {
  color: var(--ink-soft);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* The queue shows pictures only, unless the browser couldn't draw the photo (HEIC, DNG). */
[data-list="queue"] .tile:not(.no-preview) .tile-name { display: none; }
.tile.no-preview .tile-name { color: var(--ink); font-weight: 500; }

.tile-status {
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}

.tile-action {
  justify-self: start;
  padding: 2px 0;
  border: 0;
  background: none;
  color: var(--ink-soft);
  font: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}

.tile progress {
  width: 100%;
  height: 4px;
  appearance: none;
  border: 0;
  border-radius: 999px;
  background: var(--line);
  overflow: hidden;
}
.tile progress::-webkit-progress-bar { background: var(--line); }
.tile progress::-webkit-progress-value { background: var(--accent); }
.tile progress::-moz-progress-bar { background: var(--accent); }

/* Status-specific */
.tile[data-status="waiting"] .thumb { opacity: 0.85; }
.tile[data-status="uploading"] .thumb { opacity: 0.7; }

.tile[data-status="done"] .thumb::after {
  content: "✓";
  position: absolute;
  right: 6px;
  bottom: 6px;
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--ok);
  color: #fff;
  font-size: 0.8125rem;
  font-weight: 700;
}
.tile[data-status="done"] .tile-status { color: var(--ok); }

.tile[data-status="failed"] .thumb,
.tile[data-status="rejected"] .thumb {
  opacity: 0.45;
  outline: 2px solid var(--error);
  outline-offset: -2px;
}
.tile[data-status="failed"] .tile-action,
.tile[data-status="rejected"] .tile-status { color: var(--error); }

/* Template clones carry every part; hide the ones a state doesn't use. */
.tile:not([data-status="uploading"]) progress { display: none; }

/* ---------- Uploading ---------- */

.overall {
  height: 8px;
  border-radius: 999px;
  background: var(--line);
  overflow: hidden;
}
.overall > span {
  display: block;
  width: 0;
  height: 100%;
  transition: width 0.2s;
  border-radius: inherit;
  background: var(--accent);
}

.keep-open {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--ink) !important;
}

/* ---------- Thank you ---------- */

.thank-you {
  font-family: var(--display);
  font-size: 1.3125rem;
  line-height: 1.55;
  color: var(--ink);
  white-space: pre-line;   /* keep the couple's line breaks */
  text-wrap: pretty;
  padding: 8px 4px;
}

@media (prefers-reduced-motion: reduce) {
  .button:active { transform: none; }
  .overall > span { transition: none; }
}
