/* Funeral guest book — kiosk styles: calm, high-contrast, large touch targets,
   readable at 80–90, system fonts only (offline). Themeable per tenant via the
   --tokens below, set through the CSSOM (kiosk.js applyTheme); defaults = "Sage". */

:root {
  --cream: #f3efe7;
  --card: #fbf9f5;
  --ink: #2b2a28;
  --ink-soft: #57534c;
  --line: #d8d0c2;          /* decorative dividers only (not a UI-component boundary) */
  --field-border: #867c6c;  /* interactive input borders — >=3:1 vs #fff/card/cream (WCAG 1.4.11) */
  --accent: #5c6f5a;        /* muted sage — calm, natural */
  --accent-dark: #46583f;
  --danger: #7a5a3a;

  --radius: 16px;
  --field-h: 4.6rem;        /* generous, finger-friendly */
  --touch: 4.2rem;

  --serif: Georgia, "Times New Roman", "Iowan Old Style", serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

/* The `hidden` attribute must always win over our display rules. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
}

body {
  font-family: var(--sans);
  color: var(--ink);
  background: var(--cream);
  font-size: 20px;
  line-height: 1.4;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

/* Prevent long-press selection/copy on a shared kiosk. Inputs stay editable. */
body { user-select: none; }
input, textarea, select { user-select: text; }

.stage {
  min-height: 100%;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: clamp(1rem, 3vw, 3rem);
}

.screen { display: none; width: 100%; max-width: 780px; }
.screen.is-active { display: block; }

/* ---------------- Masthead ---------------- */
.masthead { text-align: center; margin: 0.5rem 0 1.75rem; }
.honoree {
  font-family: var(--serif);
  font-weight: 600;
  font-size: clamp(2.1rem, 6vw, 3.1rem);
  letter-spacing: 0.01em;
  margin: 0 0 0.25rem;
  color: var(--ink);
}
.dates {
  font-family: var(--serif);
  font-size: 1.35rem;
  color: var(--ink-soft);
  margin: 0 0 0.4rem;
}
.dates:empty { display: none; }
.subtitle {
  font-size: 1.4rem;
  color: var(--ink-soft);
  margin: 0.2rem 0 0;
}
.subtitle:empty { display: none; }

/* ---------------- Form ---------------- */
form { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: clamp(1.25rem, 3vw, 2.25rem); box-shadow: 0 1px 3px rgba(0,0,0,0.04); }

.field { margin-bottom: 1.3rem; }
.field-row { display: flex; gap: 1rem; }
.field-row .field { flex: 1; }
.field-city { flex: 2 1 auto; }
.field-state { flex: 0 0 8.5rem; }
.field-zip { flex: 0 0 8rem; }

label {
  display: block;
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 0.5rem;
}
.optional { font-weight: 400; color: var(--ink-soft); font-size: 1rem; }

input, select, textarea {
  width: 100%;
  min-height: var(--field-h);
  font-family: var(--sans);
  font-size: 1.55rem;
  color: var(--ink);
  background: #fff;
  border: 2px solid var(--field-border);
  border-radius: 12px;
  padding: 0.4rem 1rem;
}
textarea { min-height: 5.5rem; padding-top: 0.8rem; line-height: 1.35; resize: none; }
select { appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16'%3E%3Cpath fill='%2357534c' d='M4 6l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 1rem center; padding-right: 2.6rem; }

/* Visible focus (WCAG 2.4.11): a solid, opaque 3:1 outline on the white field and cream page. */
input:focus-visible, select:focus-visible, textarea:focus-visible,
.btn:focus-visible {
  outline: 3px solid var(--accent-dark);
  outline-offset: 2px;
  border-color: var(--accent-dark);
}
/* Fallback for engines without :focus-visible (old kiosk WebViews); .btn:focus keeps
   the button's ring, the gap inputs already covered. */
input:focus, select:focus, textarea:focus, .btn:focus {
  outline: 3px solid var(--accent-dark);
  outline-offset: 2px;
  border-color: var(--accent-dark);
}

.section-hint {
  font-size: 1.05rem;
  color: var(--ink-soft);
  margin: 1.6rem 0 0.9rem;
  padding-top: 1.2rem;
  border-top: 1px solid var(--line);
}
.section-tip { display: block; margin-top: 0.3rem; font-size: 0.95rem; color: var(--accent-dark); }

/* ---------------- Companions ("came together" group sign-in) ---------------- */
.companions-legend {
  font-size: 1.15rem; font-weight: 600; color: var(--ink);
  margin: 1.6rem 0 0; padding-top: 1.2rem; border-top: 1px solid var(--line);
}
.companions-hint { margin: 0.4rem 0 0.9rem; padding-top: 0; border-top: 0; }
.companion { display: flex; gap: 0.8rem; align-items: center; margin-bottom: 0.9rem; }
.companion-name { flex: 1; }
.btn-remove {
  flex: 0 0 auto; min-width: var(--touch); min-height: var(--field-h);
  border: 2px solid var(--field-border); border-radius: 12px;
  background: transparent; color: var(--danger);
  font-size: 2rem; line-height: 1; cursor: pointer; padding: 0;
}
.btn-remove:hover { background: #efe9df; }
.btn-remove:focus-visible, .btn-remove:focus {
  outline: 3px solid var(--accent-dark); outline-offset: 2px; border-color: var(--accent-dark);
}
.btn-add { font-size: 1.15rem; }
.btn-add[disabled] { opacity: 0.55; cursor: default; }

.zip-status { min-height: 1.3rem; margin: 0.35rem 0 0; font-size: 1rem; font-weight: 600; }
.zip-status:empty { min-height: 0; }
.zip-status.ok { color: var(--accent-dark); }
.zip-status.warn { color: var(--danger); font-weight: 500; }

.form-note {
  min-height: 1.4rem;
  margin: 0.4rem 0 0;
  color: var(--danger);
  font-size: 1.15rem;
  font-weight: 600;
}
.form-note:empty { min-height: 0; }

/* ---------------- Buttons ---------------- */
.actions { display: flex; gap: 1rem; margin-top: 1.4rem; align-items: stretch; }
.btn {
  font-family: var(--sans);
  font-size: 1.4rem;
  font-weight: 600;
  min-height: var(--touch);
  border-radius: 12px;
  border: 2px solid transparent;
  cursor: pointer;
  padding: 0.6rem 1.6rem;
  transition: transform 0.04s ease, background 0.15s ease;
}
.btn:active { transform: translateY(1px); }
.btn-primary { flex: 1; background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); }
.btn-quiet { background: transparent; color: var(--ink-soft); border-color: var(--field-border); flex: 0 0 auto; }
.btn-quiet:hover { background: #efe9df; }
.btn-next { margin-top: 1.5rem; min-width: 18rem; }

/* ---------------- Thank-you screen ---------------- */
#screen-thanks.is-active { display: flex; }
.screen#screen-thanks { align-items: center; justify-content: center; min-height: 70vh; }
.thanks-card { text-align: center; padding: 2rem; }
/* Focused only programmatically (tabindex=-1) to announce the confirmation to
   screen readers; it is not Tab-reachable, so no focus ring is shown. */
.thanks-card:focus { outline: none; }
.thanks-check { color: var(--accent); margin-bottom: 0.5rem; }
.thanks-card h2 {
  font-family: var(--serif);
  font-size: clamp(2.4rem, 7vw, 3.4rem);
  margin: 0.3rem 0 0.6rem;
  color: var(--ink);
}
.thanks-name { font-size: 1.7rem; color: var(--ink); margin: 0 0 0.3rem; min-height: 1.7rem; }
.thanks-party { font-size: 1.3rem; color: var(--ink-soft); margin: 0 0 0.35rem; }
.thanks-sub { font-size: 1.3rem; color: var(--ink-soft); margin: 0; }
.thanks-actions { display: flex; flex-direction: column; align-items: center; gap: 0.9rem; margin-top: 1.6rem; }
.btn-same { min-width: 18rem; font-size: 1.15rem; }

/* ---------------- Status dot ---------------- */
.status {
  position: fixed;
  top: 0.7rem; right: 0.9rem;
  display: flex; align-items: center; gap: 0.4rem;
  font-size: 0.85rem; color: var(--ink-soft);
  z-index: 10;
}
/* RTL kiosk (config.dir="rtl"): the browser mirrors text/inline layout itself; these
   mirror the few physically-positioned bits (status corner, select arrow). */
[dir="rtl"] .status { right: auto; left: 0.9rem; }
[dir="rtl"] select { background-position: left 1rem center; padding-right: 0.9rem; padding-left: 2.6rem; }
/* Shape + colour convey state (WCAG 1.4.1); each colour meets 3:1 on the cream page. */
.status-dot {
  width: 0.7rem; height: 0.7rem; border-radius: 50%;
  background: var(--accent-dark);
}
.status.pending .status-dot { background: #8a6d1e; border-radius: 2px; }   /* amber square = sending */
.status.offline .status-dot { background: #6f665a; border-radius: 0; transform: rotate(45deg); } /* grey diamond = offline */
.status-text:empty { display: none; }

@media (max-width: 560px) {
  body { font-size: 18px; }
  .field-row { flex-wrap: wrap; }
  .field-state, .field-zip { flex: 1 1 45%; }
  .actions { flex-direction: column-reverse; }
  .btn-quiet { width: 100%; }
}

/* Respect a guest's reduced-motion preference (WCAG 2.3.3). */
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
  .btn:active { transform: none; }
}

/* Forced-colors / Windows High Contrast (a common elderly a11y setting) drops the
   SVG dropdown arrow (a background-image); hand it back so the State field keeps a
   visible affordance in the user's own system colours. */
@media (forced-colors: active) {
  select {
    appearance: auto;
    -webkit-appearance: auto;
    background-image: none;
    padding-right: 1rem;
  }
}
