/* ==========================================================================
   Lazy Boot Release — waiver.css
   One mobile-first stylesheet for the guest waiver page, the admin editor,
   the admin login card, and error pages (all server-rendered by src/routes).

   Palette: warm ranch — saddle browns on cream/parchment, rust accent.
   Fonts:   system stacks only, except 'Great Vibes' (local file), used
            exclusively for the typed-signature preview.
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Signature font (only ever applied to #sig-typed-preview)
   -------------------------------------------------------------------------- */
@font-face {
  font-family: "Great Vibes";
  src: url("/fonts/GreatVibes-Regular.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

/* --------------------------------------------------------------------------
   2. Design tokens
   -------------------------------------------------------------------------- */
:root {
  --cream: #f4ecdd;        /* page background (parchment)         */
  --paper: #fffdf8;        /* card surface                        */
  --ink: #33271a;          /* primary text                        */
  --ink-soft: #6e5d48;     /* secondary / meta text               */
  --saddle: #7d4a21;       /* brand brown, primary actions        */
  --saddle-deep: #5c3513;  /* hover / headings                    */
  --accent: #b0541f;       /* rust — focus rings, small flourishes */
  --line: #ddceb0;         /* soft borders                        */
  --line-strong: #c2aa82;  /* input borders                       */
  --danger: #9c2b1d;

  --font-body: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-display: Georgia, "Iowan Old Style", "Times New Roman", serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

/* --------------------------------------------------------------------------
   3. Reset & page base
   -------------------------------------------------------------------------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  /* No pull-to-refresh: an over-scroll at the top of a half-filled form must
     not reload the page and wipe the guest's progress. */
  overscroll-behavior-y: contain;
}

body {
  margin: 0;
  padding: 0 16px 48px;
  overscroll-behavior-y: contain;
  border-top: 6px solid var(--saddle); /* small ranch-brand flourish */
  background: var(--cream);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.55;
  -webkit-text-size-adjust: 100%;
}

[hidden] {
  display: none !important;
}

code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  background: rgba(125, 74, 33, 0.09);
  padding: 1px 5px;
  border-radius: 4px;
}

/* --------------------------------------------------------------------------
   4. Typography & header / footer chrome
   -------------------------------------------------------------------------- */
h1,
h2 {
  font-family: var(--font-display);
  color: var(--ink);
  line-height: 1.2;
}

h1 {
  font-size: clamp(1.7rem, 5vw, 2.3rem);
  font-weight: 700;
  margin: 0.3em 0 0.15em;
}

h2 {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--saddle-deep);
  margin: 1.4em 0 0.5em;
}

.site-head {
  position: relative; /* anchors .logout-form top right */
  max-width: 880px;
  margin: 0 auto;
  padding: 26px 0 4px;
  text-align: center;
}

.brand {
  font-family: var(--font-display);
  font-size: 1.02rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--saddle);
}

.meta-line {
  font-size: 0.9rem;
  color: var(--ink-soft);
  margin: 0.5em 0;
}

.site-foot {
  max-width: 880px;
  margin: 36px auto 0;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  text-align: center;
  font-size: 0.85rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

/* --------------------------------------------------------------------------
   5. Cards (guest waiver, admin editor, login & error variants)
   -------------------------------------------------------------------------- */
.card {
  max-width: 720px;
  margin: 18px auto 0;
  padding: clamp(20px, 4.5vw, 40px);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(51, 39, 26, 0.07);
}

.card.narrow { max-width: 460px; margin-top: 10vh; }
.card.center { text-align: center; }
.card.center .btn { margin-top: 18px; }
.card.admin  { max-width: 880px; }

/* --------------------------------------------------------------------------
   6. Statutory warning & waiver legal text
   -------------------------------------------------------------------------- */
/* Texas Chapter 87 warning: must be conspicuous — heavy border, bold, caps. */
.warning-box {
  border: 3px solid var(--ink);
  border-radius: 4px;
  background: #fbf2d7;
  padding: 14px 16px;
  margin: 4px 0 20px;
  font-weight: 700;
  font-size: 0.9rem;
  line-height: 1.5;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.waiver-text {
  font-size: 1rem;
  line-height: 1.7;
}

.waiver-text p { margin: 0 0 1em; }

.waiver-text h2 {
  font-size: 1.12rem;
  margin: 1.6em 0 0.5em;
}

/* --------------------------------------------------------------------------
   7. Forms — sections, grid, fields
   -------------------------------------------------------------------------- */
h2.form-section {
  border-top: 1px solid var(--line);
  padding-top: 22px;
  margin: 30px 0 14px;
}

form .grid {
  display: grid;
  grid-template-columns: 1fr; /* phones: single column */
  gap: 16px;
  margin: 4px 0 10px;
}

@media (min-width: 700px) {
  form .grid { grid-template-columns: 1fr 1fr; gap: 16px 20px; }
}

label {
  display: block;
  font-weight: 600;
  font-size: 0.95rem;
  line-height: 1.4;
  color: var(--ink);
}

label > input,
label > select {
  display: block;
  margin-top: 6px;
}

/* 1rem = 16px: keeps mobile Safari from auto-zooming focused fields. */
input:not([type="checkbox"]),
select,
textarea {
  width: 100%;
  min-height: 48px;
  padding: 11px 14px;
  font-family: inherit;
  font-size: 1rem;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--saddle);
}

.check-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin: 12px 0;
  font-weight: 500;
  font-size: 1rem;
  line-height: 1.5;
  cursor: pointer;
}

.check-row input[type="checkbox"] {
  flex: 0 0 auto;
  width: 24px;
  height: 24px;
  margin: 1px 0 0;
  accent-color: var(--saddle);
}

/* Minor-children sub-form (rows are added by waiver-form.js) */
#minors-section {
  margin: 6px 0 10px;
  padding: 14px 16px;
  border-left: 3px solid var(--line-strong);
  border-radius: 0 8px 8px 0;
  background: rgba(125, 74, 33, 0.05);
}

#minors-rows {
  display: grid;
  gap: 12px;
  margin-bottom: 12px;
}

#add-minor { margin-bottom: 12px; }

/* --------------------------------------------------------------------------
   8. Signature (draw / type)
   -------------------------------------------------------------------------- */
.sig-tabs {
  display: inline-flex;
  border: 1.5px solid var(--saddle);
  border-radius: 10px;
  overflow: hidden;
  background: #fff;
}

.sig-tab {
  min-height: 48px;
  min-width: 96px;
  padding: 10px 24px;
  border: 0;
  background: transparent;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  color: var(--saddle-deep);
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.sig-tab + .sig-tab { border-left: 1.5px solid var(--saddle); }

.sig-tab.active {
  background: var(--saddle);
  color: #fff;
}

.sig-panel { margin: 14px 0 4px; }

#sig-canvas {
  display: block;
  width: 100%;
  height: 180px;
  margin-bottom: 10px;
  background: #fff;
  border: 2px dashed var(--line-strong);
  border-radius: 10px;
  touch-action: none; /* the pad owns touch gestures — no page scroll */
  cursor: crosshair;
}

#sig-typed-input { margin-bottom: 10px; }

#sig-typed-preview {
  font-family: "Great Vibes", cursive;
  font-size: 34px;
  line-height: 1.3;
  min-height: 72px; /* reserve space so the layout never jumps */
  padding: 10px 16px 4px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-bottom: 2px solid var(--line-strong);
  border-radius: 10px 10px 4px 4px;
  overflow-wrap: anywhere;
}

/* --------------------------------------------------------------------------
   9. Buttons & notices
   -------------------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px; /* comfortable touch target */
  min-width: 48px;
  padding: 11px 22px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: #fff;
  color: var(--saddle-deep);
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.btn:hover { background: var(--cream); }

.btn.primary {
  background: var(--saddle);
  border-color: var(--saddle-deep);
  color: #fff;
}

.btn.primary:hover { background: var(--saddle-deep); }

.btn.subtle {
  background: transparent;
  border-color: transparent;
  color: var(--saddle);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.btn.subtle:hover { background: rgba(125, 74, 33, 0.08); }

.btn.danger { color: var(--danger); border-color: #cf9384; }
.btn.danger:hover { background: #faeae5; }

.btn-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin: 18px 0;
}

#submit-btn {
  width: 100%;
  margin-top: 10px;
  font-size: 1.1rem;
}

/* Captcha row: compact centered panel, shrink-wrapped to the widget */
.captcha-row {
  width: fit-content;
  max-width: 100%;
  margin: 22px auto 8px;
  padding: 12px 16px 14px;
  background: var(--cream);
  border: 1.5px solid var(--saddle-deep);
  border-radius: 10px;
  box-shadow: 0 1px 3px rgba(51, 39, 26, 0.14);
  text-align: center;
}
.cf-turnstile {
  display: flex;
  justify-content: center;
  min-height: 65px; /* reserve space so the form doesn't jump when it loads */
}
.cf-turnstile iframe {
  max-width: 100%;
}

.error-box {
  margin: 18px 0;
  padding: 12px 16px;
  background: #faeae5;
  border: 1px solid #d9a08e;
  border-left: 4px solid var(--danger);
  border-radius: 8px;
  color: #862c10;
  font-weight: 600;
}

.success-box {
  margin: 18px 0;
  padding: 30px 26px;
  background: #eef4e6;
  border: 1px solid #b7cba0;
  border-radius: 12px;
  color: #2f511b;
}

.success-box h2 {
  margin-top: 0;
  color: #2f511b;
}

/* --------------------------------------------------------------------------
   10. Admin editor page
   -------------------------------------------------------------------------- */
.logout-form {
  position: absolute; /* pinned to the right edge of .site-head */
  top: 26px;
  right: 0;
  margin: 0;
}

.admin-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 28px;
  padding: 12px 16px;
  background: var(--cream);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 0.92rem;
  color: var(--ink-soft);
}

.admin-meta strong { color: var(--ink); }
.admin-meta .sha code { background: #fff; }

#waiver-text {
  width: 100%;
  height: 420px;
  margin: 6px 0 14px;
  padding: 14px 16px;
  font-family: var(--font-mono);
  font-size: 14px;
  line-height: 1.55;
  resize: vertical;
}

.card.admin label { margin: 12px 0 4px; }

#admin-status { min-height: 1.5em; } /* status text appears without reflow */

#preview-frame {
  display: block;
  width: 100%;
  height: 520px;
  margin: 16px 0;
  background: #fff;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
}

.link-row {
  display: flex;
  gap: 10px;
  margin: 10px 0 16px;
}

.link-row input {
  flex: 1 1 auto;
  min-width: 0;
  font-family: var(--font-mono);
  background: var(--cream);
}

#qr-holder { margin: 8px 0 16px; }

#qr-holder img,
#qr-holder canvas {
  display: block;
  width: 180px;
  height: 180px;
  box-sizing: content-box; /* keep the code itself a crisp 180px */
  padding: 12px;           /* white quiet zone for reliable scanning */
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
}

/* --------------------------------------------------------------------------
   11. Accessibility
   -------------------------------------------------------------------------- */
:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}

/* ---- Version history table ---------------------------------------------- */
.version-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
  margin: 0.5rem 0 1rem;
}
.version-table th,
.version-table td {
  text-align: left;
  padding: 0.45rem 0.6rem;
  border-bottom: 1px solid rgba(93, 78, 63, 0.18);
}
.version-table th {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #7a6a58;
}
.version-table .current-version td {
  font-weight: 600;
  background: rgba(93, 78, 63, 0.06);
}
.version-table .btn {
  min-height: 34px;
  padding: 0.25rem 0.8rem;
}
@media (max-width: 560px) {
  .version-table th:nth-child(3),
  .version-table td:nth-child(3) {
    display: none; /* hide note column on narrow phones */
  }
}

/* ---- Version history pager ------------------------------------------------ */
.version-pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin: 0.25rem 0 1rem;
}
.version-pager .btn {
  min-height: 36px;
  padding: 0.3rem 0.9rem;
}

/* ---- Modal dialog (rotate confirmation) ----------------------------------- */
.modal {
  border: none;
  border-radius: 14px;
  padding: 1.6rem 1.75rem;
  max-width: 27rem;
  width: calc(100vw - 2.5rem);
  box-shadow: 0 18px 50px rgba(30, 24, 18, 0.35);
  background: #fffdf9;
  color: #2b241d;
}
.modal::backdrop {
  background: rgba(30, 24, 18, 0.55);
}
.modal h2 {
  margin: 0 0 0.75rem;
  font-size: 1.15rem;
}
.modal p {
  margin: 0 0 0.6rem;
  line-height: 1.5;
}
.modal-actions {
  justify-content: flex-end;
  margin-top: 1.25rem;
}

/* ============================================================================
   WIZARD — multi-step mobile signing flow (guest form)
   ============================================================================ */

/* Language switch (header) */
.lang-switch {
  display: inline-flex;
  gap: 2px;
  margin-top: 10px;
  padding: 3px;
  background: rgba(125, 74, 33, 0.08);
  border-radius: 999px;
}
.lang-btn {
  min-height: 34px;
  padding: 4px 16px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--saddle-deep);
  cursor: pointer;
}
.lang-btn.active {
  background: var(--paper);
  box-shadow: 0 1px 2px rgba(51, 39, 26, 0.14);
}

/* Step indicator + progress bar */
.wizard-steps {
  display: flex;
  gap: 6px;
  margin: 0 0 10px;
  padding: 0;
  list-style: none;
  counter-reset: step;
}
.wizard-steps li {
  flex: 1 1 0;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--ink-soft);
}
.wizard-steps li::before {
  counter-increment: step;
  content: counter(step);
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--cream);
  border: 1.5px solid var(--line-strong);
  font-size: 0.8rem;
}
.wizard-steps li.active { color: var(--saddle-deep); }
.wizard-steps li.active::before {
  background: var(--saddle);
  border-color: var(--saddle-deep);
  color: #fff;
}
.wizard-steps li.done::before {
  content: "\2713";
  background: #5f7d3f;
  border-color: #4c6633;
  color: #fff;
}
.wizard-steps li span { white-space: nowrap; }
@media (max-width: 460px) {
  .wizard-steps li:not(.active) span { display: none; } /* keep only the current label on tiny screens */
}

.wizard-bar {
  height: 6px;
  margin: 0 0 22px;
  border-radius: 999px;
  background: var(--line);
  overflow: hidden;
}
.wizard-bar span {
  display: block;
  height: 100%;
  background: var(--saddle);
  border-radius: 999px;
  transition: width 0.3s ease;
}

/* Scrollable waiver text with a read gate */
.waiver-scroll {
  max-height: 44vh;
  overflow-y: auto;
  padding: 4px 16px;
  margin: 0 0 6px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fffefb;
  -webkit-overflow-scrolling: touch;
}
.waiver-scroll:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
#ack-row.locked { opacity: 0.55; }
#ack-row.locked::after {
  content: "\2014 scroll to the end first";
  font-weight: 500;
  font-size: 0.85rem;
  color: var(--ink-soft);
}

/* Guided signature pad */
.sig-pad { position: relative; }
.sig-hint {
  position: absolute;
  left: 18px;
  bottom: 34px;
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: #b9a888;
  pointer-events: none;
}
.sig-pad::after {
  content: "";
  position: absolute;
  left: 18px;
  right: 18px;
  bottom: 30px;
  border-bottom: 1.5px solid var(--line-strong);
  pointer-events: none;
}

/* Inline field errors */
input.invalid,
select.invalid { border-color: var(--danger); background: #fdf3f0; }
.field-err {
  display: block;
  margin-top: 5px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--danger);
}

/* Sticky action bar */
.wizard-actions {
  position: sticky;
  bottom: 0;
  display: flex;
  gap: 12px;
  align-items: center;
  margin: 22px -20px -8px;
  padding: 14px 20px calc(14px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--paper) 72%, rgba(255, 253, 248, 0));
}
.wizard-actions #wizard-back { margin-right: auto; }
.wizard-actions #wizard-next,
.wizard-actions #submit-btn { flex: 1 1 auto; max-width: 60%; font-size: 1.05rem; }

/* Success flourish + download */
.success-box { text-align: center; }
.success-check {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  margin: 0 auto 8px;
  border-radius: 50%;
  background: #5f7d3f;
  color: #fff;
  font-size: 1.6rem;
  font-weight: 700;
}
#download-copy { margin: 10px auto 6px; }

/* Sub-section heading (e.g. the address block) */
.sub-section {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--saddle-deep);
  margin: 24px 0 10px;
}

/* Grid item spanning the full row */
form .grid .full { grid-column: 1 / -1; }

/* Step tracker doubles as back-navigation */
.wizard-steps li { cursor: default; }
.wizard-steps li.done { cursor: pointer; }
.wizard-steps li.done:hover span { text-decoration: underline; text-underline-offset: 3px; }
.wizard-steps li.done:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; border-radius: 6px; }

/* Minor child cards — each with its own labeled name / DOB / relationship */
#minors-rows { display: grid; gap: 12px; margin-bottom: 12px; }
.minor-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 14px;
  padding: 14px 16px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: #fff;
}
.minor-row .minor-field { margin: 0; font-size: 0.9rem; }
.minor-row .minor-field:first-of-type { grid-column: 1 / -1; } /* name spans the row */
.minor-row .minor-field > span { display: block; margin-bottom: 4px; font-weight: 600; }
.minor-row .minor-remove {
  grid-column: 1 / -1;
  justify-self: start;
  min-height: 40px;
  padding: 6px 14px;
}
@media (max-width: 480px) {
  .minor-row { grid-template-columns: 1fr; }
}

/* Footer credit / company watermark */
.site-foot .foot-ranch { font-weight: 700; }
.site-foot .foot-credit {
  margin-top: 7px;
  font-size: 0.72rem;
  letter-spacing: 0.05em;
  text-transform: none;
  color: var(--ink-soft);
}
.site-foot .foot-credit a { color: var(--saddle); font-weight: 600; text-decoration: none; }
.site-foot .foot-credit a:hover { text-decoration: underline; }

/* Statutory warning: keep it conspicuous but far tighter on small screens */
@media (max-width: 560px) {
  .warning-box {
    padding: 10px 12px;
    margin: 2px 0 16px;
    font-size: 0.8rem;
    line-height: 1.45;
    letter-spacing: 0;
    border-width: 2px;
  }
}

/* ============================================================================
   RANCH THEME — longhorn emblem + barbed-wire dividers
   Revert: `git checkout -- public/css/waiver.css && git clean -f public/img/`
   (baseline commit ad6896e predates the theme)
   ========================================================================== */

/* Western boot emblem crowning the page header ("lazy" = tilted, in brand-speak).
   Swap back to the longhorn: url("/img/horns.svg"), width 230px, height 56px. */
.site-head::before {
  content: "";
  display: block;
  width: 76px;
  height: 76px;
  margin: 0 auto 4px;
  background: url("/img/boot.svg") center / contain no-repeat;
}

/* Barbed-wire divider between header and content */
.site-head::after {
  content: "";
  display: block;
  height: 16px;
  margin: 16px auto 0;
  background: url("/img/barbed-wire.svg") left center / 64px 16px repeat-x;
  opacity: 0.75;
}

/* Barbed-wire strand above the footer */
.site-foot::before {
  content: "";
  display: block;
  height: 16px;
  margin: 0 auto 14px;
  background: url("/img/barbed-wire.svg") left center / 64px 16px repeat-x;
  opacity: 0.6;
}

/* Smaller emblem on standalone cards (sign-in, landing, error pages) */
.card.center::before {
  content: "";
  display: block;
  width: 54px;
  height: 54px;
  margin: 0 auto 10px;
  background: url("/img/boot.svg") center / contain no-repeat;
  opacity: 0.9;
}
