/* ==========================================================
   Quiet Modern — memorial submission form
   Light palette lives on bare :root so the un-stamped
   "system" default resolves correctly.
   ========================================================== */
:root {
  --bg:      #FBFBFC;
  --fg:      #191C20;
  --muted:   #6E747C;
  --field:   #F1F2F4;
  --line:    #E3E5E9;
  --accent:  #4E7194;
  --onacc:   #FFFFFF;
  --danger:  #A4443C;
  --card:    #FFFFFF;

  --ui: "Instrument Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:     #141619;
    --fg:     #E8EAED;
    --muted:  #8E959D;
    --field:  #1E2126;
    --line:   #2A2E34;
    --accent: #8FB0CD;
    --onacc:  #12161A;
    --danger: #E08D84;
    --card:   #141619;
  }
}

:root[data-theme="dark"] {
  --bg:     #141619;
  --fg:     #E8EAED;
  --muted:  #8E959D;
  --field:  #1E2126;
  --line:   #2A2E34;
  --accent: #8FB0CD;
  --onacc:  #12161A;
  --danger: #E08D84;
  --card:   #141619;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--ui);
  font-size: 0.9375rem;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.shell {
  max-width: 30rem;
  margin: 0 auto;
  padding: clamp(2rem, 7vw, 4.5rem) clamp(1.1rem, 5vw, 1.75rem) 4rem;
}

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

/* ---------- fields ---------- */
.field { margin-bottom: 1.4rem; }

.label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--fg);
  margin-bottom: 0.45rem;
}
.label span { color: var(--muted); font-weight: 400; }

.input {
  display: block;
  width: 100%;
  background: var(--field);
  color: var(--fg);
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 0.72rem 0.9rem;
  font-family: inherit;
  font-size: 1rem; /* >=16px stops iOS Safari zooming on focus */
  line-height: 1.6;
  min-height: 2.75rem;
}
.input:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--bg);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}
.input.invalid { border-color: var(--danger); }

.textarea {
  resize: vertical;
  min-height: 9rem;
  border-color: var(--line);
}

.meta {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 0.4rem;
  font-size: 0.75rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* ---------- photos ---------- */
.thumbs {
  list-style: none;
  margin: 0 0 0.85rem;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
}
.thumbs:empty { margin-bottom: 0; }

.thumb {
  position: relative;
  width: 76px;
  height: 76px;
  border-radius: 8px;
  overflow: visible;
  background: var(--field);
  flex: none;
}
.thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 8px;
  display: block;
}
/* HEIC and anything else the browser can't decode: show the extension instead */
.thumb .fallback {
  width: 100%;
  height: 100%;
  border-radius: 8px;
  display: grid;
  place-items: center;
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--muted);
  border: 1px solid var(--line);
  text-transform: uppercase;
}
.thumb .x {
  position: absolute;
  top: -7px;
  right: -7px;
  width: 21px;
  height: 21px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--bg);
  color: var(--fg);
  border: 1px solid var(--line);
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
}
.thumb .x:hover { border-color: var(--danger); color: var(--danger); }

.drop {
  display: block;
  border: 1.5px dashed var(--line);
  border-radius: 10px;
  padding: 1.05rem;
  text-align: center;
  font-size: 0.8125rem;
  color: var(--muted);
  cursor: pointer;
}
.drop b { color: var(--accent); font-weight: 500; }
.drop.over { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 7%, transparent); }

/* ---------- send ---------- */
.send {
  width: 100%;
  appearance: none;
  border: 0;
  margin-top: 0.35rem;
  background: var(--accent);
  color: var(--onacc);
  font-family: inherit;
  font-size: 0.9375rem;
  font-weight: 600;
  padding: 0.85rem;
  border-radius: 10px;
  cursor: pointer;
}
.send:hover:not(:disabled) { filter: brightness(1.06); }
.send:disabled { opacity: 0.55; cursor: default; }

/* ---------- progress ---------- */
.progress { margin-top: 1rem; }
.bar {
  height: 4px;
  background: var(--field);
  border-radius: 999px;
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  border-radius: 999px;
  transition: width 0.25s ease;
}
.progress-text {
  margin: 0.5rem 0 0;
  font-size: 0.75rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* ---------- errors ---------- */
.err {
  margin: 0.4rem 0 0;
  font-size: 0.8125rem;
  color: var(--danger);
}
.form-err {
  margin-top: 0.9rem;
  padding: 0.7rem 0.85rem;
  border: 1px solid color-mix(in srgb, var(--danger) 40%, transparent);
  border-radius: 8px;
  background: color-mix(in srgb, var(--danger) 8%, transparent);
}

/* ---------- thank you ---------- */
.sent { text-align: center; padding: 2.5rem 0 1rem; }
.check {
  width: 46px;
  height: 46px;
  margin: 0 auto 1.2rem;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: color-mix(in srgb, var(--accent) 15%, transparent);
  color: var(--accent);
}
.sent h1 {
  margin: 0 0 0.5rem;
  font-size: 1.3125rem;
  font-weight: 600;
  letter-spacing: -0.012em;
}
.sent p { margin: 0; color: var(--muted); }
.again {
  appearance: none;
  margin-top: 1.6rem;
  background: transparent;
  border: 1px solid var(--line);
  color: var(--fg);
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  padding: 0.6rem 1.15rem;
  border-radius: 8px;
  cursor: pointer;
}
.again:hover { border-color: var(--accent); color: var(--accent); }

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