/* ==========================================================================
   Public pages (index.php, apply.php) — page-level additions only.
   Uses design tokens so it works on dark glass and inside the pearl .scroll
   (components.css §23), where tokens switch to dark ink automatically.
   ========================================================================== */

.page--lux { padding-top: var(--sp-6); }

.fieldset-reset { min-width: 0; margin: 0; padding: 0; border: 0; }
.break-all { word-break: break-all; }
.alert__para { margin: var(--sp-1) 0 0; }

/* ---------- Welcome letter (index) ---------- */
.letter__body { display: flex; flex-direction: column; gap: var(--sp-4); }
.letter__body > p { margin: 0; line-height: 1.85; color: var(--text-muted); }
.letter__body strong { color: var(--heading); }
.letter__head { display: flex; flex-direction: column; align-items: center; gap: var(--sp-1); text-align: center; }
.letter__eyebrow { color: var(--primary-text); }
.letter__crest { margin: 0; font-size: var(--fs-2xl); letter-spacing: 0.1em; color: var(--heading); }
.letter__from { margin: 0; font-size: var(--fs-xs); letter-spacing: 0.04em; color: var(--text-muted); }
.letter__greeting { margin: 0; font-size: var(--fs-xl); font-weight: var(--fw-regular); }
.letter__signrow { display: flex; align-items: center; justify-content: flex-end; gap: var(--sp-4); margin-top: var(--sp-2); }
.letter__sign { display: flex; flex-direction: column; gap: 0.125rem; margin: 0; text-align: end; font-size: var(--fs-sm); color: var(--text-muted); }
.letter__signer { font-family: var(--font-display); font-size: var(--fs-md); font-weight: var(--fw-medium); letter-spacing: 0.03em; color: var(--heading); }
.letter__role { font-size: var(--fs-sm); }
.letter__seal {                         /* amethyst wax seal (hexagon) */
  flex-shrink: 0;
  display: grid;
  place-items: center;
  width: 3.375rem;
  height: 3.75rem;
  clip-path: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%);
  background: var(--seal-amethyst);
  color: var(--on-primary);
  font: 600 1.5rem/1 var(--font-display);
  text-shadow: 0 1px 2px rgba(30, 10, 80, 0.5);
}
.letter__cta {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-3);
  margin-top: var(--sp-8);
  padding-top: var(--sp-6);
  border-top: 1px solid var(--hairline);
  text-align: center;
}
.letter__note { margin: 0; font-size: var(--fs-xs); color: var(--text-muted); }
@media (max-width: 39.99rem) {
  .letter__login,
  .letter__guide { width: 100%; }
  .letter__seal { width: 2.875rem; height: 3.25rem; font-size: 1.25rem; }
}

.how__title { margin-bottom: var(--sp-5); font-size: var(--fs-md); text-align: center; color: var(--text-muted); }

/* ---------- Page intro (apply) ---------- */
.page-intro { text-align: center; }
.page-intro__eyebrow {
  margin: 0 0 var(--sp-1);
  font-family: var(--font-display);       /* English only */
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--gold-text);
}
.page-intro__title { margin: 0 0 var(--sp-2); font-size: var(--fs-2xl); }
.page-intro__lead { margin: 0; color: var(--text-muted); }
.scroll__paper .page-intro { padding-bottom: var(--sp-5); border-bottom: 1px solid var(--hairline); }
.scroll__paper .page-intro__eyebrow { letter-spacing: 0.3em; font-weight: var(--fw-medium); color: var(--primary-text); }
.scroll__paper .page-intro__title { font-weight: var(--fw-regular); }

/* ---------- Apply form ---------- */
.apply-step { display: flex; flex-direction: column; gap: var(--sp-4); }
.apply-step + .apply-step { padding-top: var(--sp-6); border-top: 1px solid var(--border); }
.apply-form.is-enhanced .apply-step + .apply-step { padding-top: 0; border-top: 0; }
.apply-step__num { margin: 0; font-size: var(--fs-xs); font-weight: var(--fw-semibold); color: var(--gold-text); }
.apply-step__title { margin: 0; font-size: var(--fs-xl); }
.apply-step__title:focus { outline: none; }
.apply-step__desc { margin: var(--sp-1) 0 0; font-size: var(--fs-sm); color: var(--text-muted); }
.req-mark { color: var(--danger-text); }

.apply-choices { --min: 15rem; --gap: var(--sp-3); }
.role-group { display: flex; flex-direction: column; gap: var(--sp-3); }
.role-group + .role-group { margin-top: var(--sp-4); }
.role-group__legend { margin-bottom: var(--sp-3); padding: 0; font-size: var(--fs-sm); font-weight: var(--fw-semibold); color: var(--text-muted); }
.apply-form.is-enhanced .role-group__legend { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Phase 16: only one open role → fixed "สมัครเป็น: นักเดินทาง" line instead of the group / role steps */
.apply-role-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-2);
  min-height: var(--tap);
  padding-bottom: var(--sp-4);
  border-bottom: 1px solid var(--border);
}
.apply-role-line__label { font-weight: var(--fw-semibold); color: var(--text); }
.apply-role-line__badge { font-size: var(--fs-sm); }

.q-group__title {
  width: 100%;
  margin-bottom: var(--sp-4);
  padding: 0 0 var(--sp-2);
  border-bottom: 1px solid var(--border);
  font-family: var(--font-serif);
  font-size: var(--fs-md);
  font-weight: var(--fw-semibold);
  color: var(--text);
}
.q-group + .q-group { margin-top: var(--sp-8); }
.apply-form.is-enhanced .q-group + .q-group { margin-top: 0; }
fieldset.q-item > legend { margin-bottom: var(--sp-2); padding: 0; }
.q-item__desc { white-space: normal; }
.q-item__img { display: block; max-height: 16rem; width: auto; border: 1px solid var(--border); border-radius: var(--r-md); }
.q-item__options { display: flex; flex-direction: column; }
.q-item.is-invalid .q-item__options { padding-inline-start: var(--sp-3); border-inline-start: 2px solid var(--danger); }
.twin-block .check { min-height: 0; }

/* keep toasts and the floating music toggle (ambience.css) above the sticky action bar */
body:has(.apply-actions) { --toast-offset: 5rem; --ambience-offset: 5.5rem; }
/* Dark glass bar (data-theme="dark") floating over the pearl paper, stuck to the viewport bottom */
.apply-actions {
  margin: var(--sp-6) 0 0;
  border-radius: var(--r-xl);
  box-shadow: 0 -10px 30px -12px rgba(8, 7, 12, 0.55), 0 0 0 1px rgba(203, 179, 122, 0.12);
}
@media (max-width: 39.99rem) {
  /* one row on phones so the bar stays ~68px and the music toggle (--ambience-offset) clears it;
     the step counter stays for screen readers (the stepper shows it visually) */
  .apply-actions { flex-wrap: nowrap; margin-inline: -0.5rem; padding-inline: var(--sp-3); border-radius: var(--r-lg); }
  .apply-actions .action-bar__info { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .apply-actions .btn { flex: 1 1 auto; min-width: 0; padding-inline: var(--sp-3); white-space: normal; line-height: 1.25; }
  .apply-actions #apply-back { flex: 0 0 auto; white-space: nowrap; }
}
@media (max-width: 24.99rem) {
  .apply-actions .btn { font-size: var(--fs-sm); gap: var(--sp-1); }
}

/* ---------- Status ---------- */
.status-card__subhead { margin: 0 0 var(--sp-3); font-size: var(--fs-sm); color: var(--text-muted); }
.status-card__footer { justify-content: flex-end; }
.status-card__request { min-height: var(--control-h-sm); padding-inline: var(--sp-3); }
@media (max-width: 39.99rem) { .status-card__footer > .btn { flex: 1 1 auto; } }

.result-card {
  --result: var(--primary-text);
  --result-soft: var(--primary-soft);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-6) var(--sp-5);
  border: 1px solid color-mix(in srgb, var(--result) 30%, transparent);
  border-top: 4px solid var(--result);
  border-radius: var(--r-lg);
  background: linear-gradient(180deg, var(--result-soft), var(--surface));
  text-align: center;
}
.result-card__crest {
  display: grid;
  place-items: center;
  width: 3.25rem;
  height: 3.25rem;
  border-radius: 50%;
  background: var(--surface);
  color: var(--result);
  box-shadow: 0 0 0 3px var(--result-soft), 0 0 0 4px var(--result);
}
.result-card__crest svg.lucide { width: 1.5rem; height: 1.5rem; }
.result-card__eyebrow { margin: var(--sp-2) 0 0; font-size: var(--fs-sm); color: var(--text-muted); }
.result-card__name { margin: 0; font-size: var(--fs-2xl); line-height: var(--lh-tight); color: var(--result); }
.result-card__name--th { font-family: var(--font-serif); font-weight: var(--fw-bold); font-size: var(--fs-xl); }
.result-card__text { max-width: 30rem; margin: var(--sp-1) 0 0; font-size: var(--fs-sm); color: var(--text-muted); }

/* ---------- Misc ---------- */
.split-start { display: flex; align-items: flex-start; gap: var(--sp-3); }
.icon-tile {
  flex-shrink: 0;
  display: grid;
  place-items: center;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: var(--r-md);
  background: var(--danger-soft);
  color: var(--danger-text);
}

/* ---------- Phase 14: duplicate surname → reference person (apply form, fix form, status card) ---------- */
.surname-ref { gap: var(--sp-3); }
.surname-ref__callout { margin: 0; }
.surname-ref__pick { display: flex; flex-direction: column; gap: var(--sp-2); }
.surname-ref__pick > legend { margin-bottom: var(--sp-2); padding: 0; }
.surname-ref__list {
  display: flex;
  flex-direction: column;
  max-height: 18rem;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: var(--sp-1) var(--sp-3);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
}
.surname-ref__item { flex-shrink: 0; min-height: var(--tap); border-bottom: 1px solid var(--hairline); }  /* no shrinking inside the scrolling column */
.surname-ref__item:last-child { border-bottom: 0; }
.surname-ref__name { display: block; overflow-wrap: anywhere; font-weight: var(--fw-medium); color: var(--text); }
.surname-ref__note { margin: 0; }
.surname-ref.is-invalid .surname-ref__list { border-color: var(--danger); }
.surname-ref .select { width: 100%; }

.surname-status__line { display: block; overflow-wrap: anywhere; }
.surname-status__reason { white-space: pre-line; overflow-wrap: anywhere; }
.surname-status__fix { min-height: var(--tap); }

.fix-form__footer { justify-content: flex-end; flex-wrap: wrap; gap: var(--sp-2); }
@media (max-width: 39.99rem) { .fix-form__footer > .btn { flex: 1 1 auto; min-height: var(--tap); } }

/* ---------- Phase 14: consent page (consent.php) ---------- */
.consent-request__lead { margin: 0; line-height: 1.85; overflow-wrap: anywhere; }
.consent-request__kv dd { overflow-wrap: anywhere; }
.consent-choice {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 16rem), 1fr));
  gap: var(--sp-4);
  align-items: start;
}
.consent-choice__item { margin: 0; }
.consent-choice__title {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  margin: 0;
  font-size: var(--fs-md);
}
.consent-choice__title svg.lucide { width: 1.25rem; height: 1.25rem; color: var(--text-muted); }
.consent-choice__item p { margin: 0; }
.consent-choice .btn { min-height: var(--tap); }
.consent-reason { white-space: pre-line; overflow-wrap: anywhere; }
.consent-empty .empty__actions .btn { min-height: var(--tap); }
