@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:ital,wght@0,400;0,500;1,400&family=Lora:ital,wght@0,400;0,500;1,400&display=swap');

/* Same brand world as the memorial pages: warm paper, candlelight gold. */
:root {
  --bg:        oklch(0.97 0.010 78);
  --surface:   oklch(0.99 0.006 76);
  --surface-2: oklch(0.945 0.012 74);
  --border:    oklch(0.87 0.014 70);
  --ink:       oklch(0.23 0.018 52);
  --muted:     oklch(0.46 0.020 56);
  --navy:      oklch(0.19 0.024 52);
  --navy-mid:  oklch(0.26 0.028 52);
  --gold:      oklch(0.74 0.115 72);
  --gold-dim:  oklch(0.52 0.095 62);
  --gold-glow: oklch(0.74 0.115 72 / 0.20);
  --hero-text: oklch(0.97 0.008 76);
  --ok:        oklch(0.52 0.10 155);
  --warn:      oklch(0.50 0.11 55);

  --font-display: 'Playfair Display', Georgia, serif;
  --font-body:    'Lora', Georgia, serif;
  --font-ui:      system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body.form-page {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 1.0125rem;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

a:focus-visible, button:focus-visible, input:focus-visible,
textarea:focus-visible, select:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--gold-dim);
  outline-offset: 3px;
  border-radius: 6px;
}

/* ── Header ──────────────────────────────────────────────────────────────── */
.form-header {
  background: var(--navy);
  color: var(--hero-text);
  padding: 2.5rem 1.5rem 2.75rem;
  text-align: center;
}
.form-header .logo-row { display: flex; align-items: center; justify-content: center; gap: 0.55rem; margin-bottom: 1.5rem; }
.form-header .logo-text { font-family: var(--font-ui); font-size: 0.68rem; letter-spacing: 0.14em; text-transform: uppercase; color: oklch(0.84 0.014 74); }
.form-header h1 { font-family: var(--font-display); font-weight: 400; font-size: clamp(1.7rem, 4.4vw, 2.4rem); line-height: 1.2; margin-bottom: 0.75rem; text-wrap: balance; }
.form-header p { color: oklch(0.86 0.014 74); font-style: italic; max-width: 46ch; margin: 0 auto; text-wrap: pretty; }

/* ── Save indicator (fixed, reassuring) ──────────────────────────────────── */
.save-bar {
  position: sticky; top: 0; z-index: 50;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0.6rem 1.25rem;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  font-family: var(--font-ui); font-size: 0.8rem;
}
.save-state { display: flex; align-items: center; gap: 0.45rem; color: var(--muted); }
.save-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); flex-shrink: 0; }
.save-state.saving .save-dot { background: var(--gold); }
.btn-preview-toggle {
  font-family: var(--font-ui); font-size: 0.8rem;
  background: none; border: 1px solid var(--border); color: var(--ink);
  padding: 0.35rem 0.85rem; border-radius: 999px; cursor: pointer;
  transition: background 0.2s;
}
.btn-preview-toggle:hover { background: var(--surface-2); }

/* ── Layout ──────────────────────────────────────────────────────────────── */
.form-layout {
  max-width: 1240px; margin: 0 auto;
  display: grid; grid-template-columns: minmax(0,1fr) 380px;
  gap: 3rem; padding: 2.5rem 1.5rem 5rem;
  align-items: start;
}
@media (max-width: 1040px) {
  .form-layout { grid-template-columns: minmax(0,1fr); gap: 2rem; }
  .preview-col { display: none; }
  .preview-col.open { display: block; position: fixed; inset: 60px 0 0; z-index: 60; background: var(--bg); padding: 1.25rem; overflow: auto; }
}

/* ── Sections ────────────────────────────────────────────────────────────── */
.form-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.75rem;
  margin-bottom: 1.25rem;
}
.section-head { margin-bottom: 1.5rem; }
.section-num { font-family: var(--font-ui); font-size: 0.7rem; letter-spacing: 0.16em; text-transform: uppercase; color: var(--gold-dim); display: block; margin-bottom: 0.4rem; }
.form-section h2 { font-family: var(--font-display); font-weight: 400; font-size: 1.45rem; margin-bottom: 0.35rem; }
.section-note { color: var(--muted); font-size: 0.92rem; font-style: italic; text-wrap: pretty; }

.field { margin-bottom: 1.35rem; }
.field:last-child { margin-bottom: 0; }
.field label, .field .q {
  display: block;
  font-family: var(--font-body);
  font-size: 1.02rem;
  margin-bottom: 0.5rem;
  color: var(--ink);
}
.field .hint { display: block; font-family: var(--font-ui); font-size: 0.82rem; color: var(--muted); margin-top: 0.4rem; }
.optional { font-family: var(--font-ui); font-size: 0.72rem; color: var(--muted); letter-spacing: 0.04em; }

input[type="text"], input[type="date"], input[type="email"],
input[type="tel"], input[type="number"], textarea, select {
  width: 100%;
  font-family: var(--font-body);
  font-size: 1rem;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem 0.95rem;
  transition: border-color 0.2s, box-shadow 0.2s;
}
textarea { resize: vertical; min-height: 92px; line-height: 1.65; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--gold-dim); box-shadow: 0 0 0 3px var(--gold-glow); }
input::placeholder, textarea::placeholder { color: oklch(0.62 0.015 60); }

.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.85rem; }
@media (max-width: 560px) { .field-row { grid-template-columns: 1fr; } }

/* ── Timeline rows ───────────────────────────────────────────────────────── */
.tl-row { display: grid; grid-template-columns: 110px minmax(0,1fr) 40px; gap: 0.6rem; margin-bottom: 0.6rem; align-items: start; }
.tl-remove, .photo-remove {
  background: none; border: 1px solid var(--border); color: var(--muted);
  border-radius: 8px; cursor: pointer; height: 44px; font-size: 1.1rem;
  transition: background 0.2s, color 0.2s;
}
.tl-remove:hover, .photo-remove:hover { background: var(--surface-2); color: var(--ink); }
.btn-add {
  font-family: var(--font-ui); font-size: 0.86rem;
  background: none; border: 1px dashed var(--border); color: var(--gold-dim);
  padding: 0.65rem 1.1rem; border-radius: 8px; cursor: pointer; width: 100%;
  transition: background 0.2s, border-color 0.2s;
}
.btn-add:hover { background: var(--surface-2); border-color: var(--gold-dim); }
@media (max-width: 560px) { .tl-row { grid-template-columns: 90px minmax(0,1fr) 40px; } }

/* ── Photo upload ────────────────────────────────────────────────────────── */
.dropzone {
  border: 2px dashed var(--border);
  border-radius: 12px;
  padding: 2.25rem 1.5rem;
  text-align: center;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
  background: var(--bg);
}
.dropzone:hover, .dropzone.drag { background: var(--surface-2); border-color: var(--gold-dim); }
.dropzone-icon { font-size: 1.6rem; color: var(--gold-dim); display: block; margin-bottom: 0.6rem; }
.dropzone strong { font-family: var(--font-body); font-weight: 500; display: block; margin-bottom: 0.25rem; }
.dropzone span { font-family: var(--font-ui); font-size: 0.84rem; color: var(--muted); }

.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 1rem; margin-top: 1.25rem; }
.photo-card { border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: var(--bg); }
.photo-thumb-wrap { position: relative; aspect-ratio: 3/4; background: var(--surface-2); }
.photo-thumb-wrap img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-badge {
  position: absolute; top: 6px; left: 6px;
  font-family: var(--font-ui); font-size: 0.62rem; letter-spacing: 0.06em; text-transform: uppercase;
  background: var(--navy); color: var(--hero-text);
  padding: 0.2rem 0.45rem; border-radius: 4px;
}
.photo-fallback {
  width: 100%; height: 100%; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 0.4rem;
  color: var(--muted); font-family: var(--font-ui); font-size: 0.72rem; text-align: center; padding: 0.5rem;
}
.photo-meta { padding: 0.6rem; }
.photo-meta input { font-size: 0.85rem; padding: 0.45rem 0.6rem; }
.photo-actions { display: flex; gap: 0.35rem; margin-top: 0.45rem; }
.photo-actions button {
  flex: 1; font-family: var(--font-ui); font-size: 0.75rem;
  background: none; border: 1px solid var(--border); color: var(--muted);
  border-radius: 6px; padding: 0.35rem; cursor: pointer; transition: background 0.2s, color 0.2s;
}
.photo-actions button:hover:not(:disabled) { background: var(--surface-2); color: var(--ink); }
.photo-actions button:disabled { opacity: 0.35; cursor: not-allowed; }
.photo-size { font-family: var(--font-ui); font-size: 0.7rem; color: var(--muted); margin-top: 0.35rem; }

.notice {
  border-radius: 9px; padding: 0.85rem 1rem; margin-top: 1rem;
  font-family: var(--font-ui); font-size: 0.85rem; line-height: 1.55;
}
.notice.warn { background: oklch(0.95 0.03 70); color: oklch(0.38 0.09 55); border: 1px solid oklch(0.85 0.06 68); }
.notice.info { background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }

/* ── Radio cards (privacy) ───────────────────────────────────────────────── */
.radio-cards { display: grid; gap: 0.75rem; }
.radio-card {
  display: flex; gap: 0.85rem; align-items: flex-start;
  border: 1px solid var(--border); border-radius: 10px;
  padding: 1rem; cursor: pointer; background: var(--bg);
  transition: border-color 0.2s, background 0.2s;
}
.radio-card:hover { background: var(--surface-2); }
.radio-card input { margin-top: 0.3rem; accent-color: var(--gold-dim); flex-shrink: 0; }
.radio-card:has(input:checked) { border-color: var(--gold-dim); background: var(--surface-2); }
.radio-card strong { display: block; font-family: var(--font-body); font-weight: 500; margin-bottom: 0.15rem; }
.radio-card span { font-family: var(--font-ui); font-size: 0.83rem; color: var(--muted); }

/* ── Submit ──────────────────────────────────────────────────────────────── */
.submit-block { text-align: center; padding: 1rem 0 0; }
.btn-submit {
  background: var(--navy); color: var(--hero-text);
  font-family: var(--font-ui); font-size: 0.95rem;
  border: none; border-radius: 999px;
  padding: 1rem 2.5rem; cursor: pointer;
  transition: background 0.2s, transform 0.15s;
}
.btn-submit:hover:not(:disabled) { background: var(--navy-mid); transform: translateY(-1px); }
.btn-submit:disabled { opacity: 0.55; cursor: not-allowed; }
.submit-note { font-family: var(--font-ui); font-size: 0.83rem; color: var(--muted); margin-top: 0.9rem; }

.form-error {
  background: oklch(0.95 0.04 25); border: 1px solid oklch(0.85 0.08 25);
  color: oklch(0.42 0.13 25); border-radius: 9px; padding: 0.85rem 1rem;
  font-family: var(--font-ui); font-size: 0.86rem; margin-bottom: 1rem;
}

/* ── Live preview ────────────────────────────────────────────────────────── */
.preview-col { position: sticky; top: 78px; }
.preview-card { border: 1px solid var(--border); border-radius: 14px; overflow: hidden; background: var(--surface); }
.preview-head {
  padding: 0.8rem 1rem; border-bottom: 1px solid var(--border);
  font-family: var(--font-ui); font-size: 0.74rem; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--muted);
  display: flex; align-items: center; gap: 0.5rem;
}
.preview-body { padding: 0; }

.pv-hero { background: var(--navy); color: var(--hero-text); padding: 1.75rem 1.25rem; text-align: center; position: relative; }
.pv-photo {
  width: 92px; height: 92px; border-radius: 50%; object-fit: cover;
  margin: 0 auto 0.9rem; display: block;
  border: 2px solid var(--gold); background: var(--navy-mid);
}
.pv-photo-empty {
  width: 92px; height: 92px; border-radius: 50%;
  margin: 0 auto 0.9rem; display: flex; align-items: center; justify-content: center;
  border: 2px dashed oklch(0.45 0.02 55); color: oklch(0.55 0.02 55);
  font-family: var(--font-display); font-size: 1.6rem;
}
.pv-name { font-family: var(--font-display); font-size: 1.5rem; line-height: 1.2; margin-bottom: 0.35rem; text-wrap: balance; }
.pv-nick { font-family: var(--font-body); font-style: italic; font-size: 0.86rem; color: oklch(0.85 0.10 78); margin-bottom: 0.3rem; }
.pv-dates { font-family: var(--font-body); font-style: italic; font-size: 0.84rem; color: oklch(0.85 0.10 78); }
.pv-epitaph { font-family: var(--font-body); font-style: italic; font-size: 0.88rem; color: oklch(0.86 0.014 74); margin-top: 0.85rem; line-height: 1.55; text-wrap: pretty; }

.pv-body { padding: 1.25rem; }
.pv-block { margin-bottom: 1.25rem; }
.pv-block:last-child { margin-bottom: 0; }
.pv-label { font-family: var(--font-ui); font-size: 0.64rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--gold-dim); display: block; margin-bottom: 0.45rem; }
.pv-text { font-size: 0.88rem; line-height: 1.65; color: var(--ink); }
.pv-muted { color: var(--muted); font-style: italic; font-size: 0.85rem; }

.pv-timeline { list-style: none; }
.pv-timeline li { display: grid; grid-template-columns: 48px 1fr; gap: 0.6rem; font-size: 0.82rem; margin-bottom: 0.45rem; }
.pv-timeline .y { font-family: var(--font-display); color: var(--gold-dim); }
.pv-timeline .e { color: var(--muted); }

.pv-photos { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.35rem; }
.pv-photos img { width: 100%; aspect-ratio: 3/4; object-fit: cover; border-radius: 4px; display: block; filter: saturate(0.88) sepia(0.12); }

/* ── Success ─────────────────────────────────────────────────────────────── */
.success-wrap { max-width: 620px; margin: 0 auto; padding: 4rem 1.5rem; text-align: center; }
.success-wrap h2 { font-family: var(--font-display); font-weight: 400; font-size: 2rem; margin-bottom: 0.85rem; }
.success-wrap p { color: var(--muted); margin-bottom: 1.5rem; text-wrap: pretty; }
.success-mark { font-size: 2.5rem; color: var(--gold); display: block; margin-bottom: 1rem; }

footer.form-footer {
  background: var(--navy); color: oklch(0.84 0.014 74);
  text-align: center; padding: 2rem 1.5rem;
  font-family: var(--font-ui); font-size: 0.78rem;
}
footer.form-footer a { color: inherit; }

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