/* ===== AccessPass brand foundation — Clean Indigo (see DESIGN.md) =====
   Shared by landing, login, dashboard and the card builder. Page files add
   their own layout; everything a visitor touches twice (buttons, fields,
   chips, segmented toggles, the wordmark, toasts, focus and selection) lives
   here so it looks and behaves the same on every screen.

   Contrast notes: white text sits on --indigo-600 (5.4:1), not the brighter
   #6366F1 (4.5:1, fails for button-size text). --text-dim is for large or
   decorative text only; small secondary copy uses --text-muted. */

:root {
  --bg: #F5F6FB;
  --bg-2: #EEF0F8;
  --surface: #FFFFFF;
  --surface-2: #FAFBFF;
  --border: #E6E8F0;
  --border-strong: #D6DAE8;

  --text: #15162B;
  --text-body: #4B4E68;
  --text-muted: #62667E;
  --text-dim: #8A8FA6;
  --placeholder: #71758C;

  --indigo: #6366F1;
  --indigo-600: #5457E6;
  --indigo-700: #4F46E5;
  --indigo-800: #4338CA;
  --indigo-50: #EEF0FE;
  --indigo-100: #E0E1FD;

  --success: #15803D;
  --success-50: #EAF7EE;
  --danger: #C62828;
  --danger-50: #FDECEC;
  --warn: #B45309;
  --warn-50: #FEF4E6;

  --font-display: "Sora", system-ui, sans-serif;
  --font-body: "Hanken Grotesk", system-ui, sans-serif;

  --r-xs: .6rem;
  --r-sm: 1rem;
  --r-md: 1.2rem;
  --r-lg: 1.8rem;
  --r-xl: 2.4rem;
  --r-pill: 99rem;

  --shadow-sm: 0 1px 2px rgba(20, 22, 43, .05), 0 4px 14px rgba(20, 22, 43, .06);
  --shadow: 0 1px 2px rgba(20, 22, 43, .04), 0 10px 30px rgba(20, 22, 43, .08);
  --shadow-lg: 0 2px 6px rgba(20, 22, 43, .06), 0 24px 60px rgba(20, 22, 43, .14);

  --ease-out: cubic-bezier(.16, 1, .3, 1);
  --dur: .18s;

  font-size: 62.5%;
}

*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  scrollbar-color: var(--border-strong) transparent;
}

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 1.6rem;
  line-height: 1.55;
  color: var(--text-body);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  caret-color: var(--indigo-600);
}

h1, h2, h3, h4 {
  font-family: var(--font-display);
  color: var(--text);
  margin: 0;
  line-height: 1.08;
  letter-spacing: -.02em;
  text-wrap: balance;
}

p { margin: 0; text-wrap: pretty; }
a { color: var(--indigo-700); text-underline-offset: .22em; text-decoration-thickness: .1em; }
button, input, select, textarea { font: inherit; color: inherit; }
img { max-width: 100%; }

::selection { background: var(--indigo-100); color: var(--text); }
:focus-visible { outline: 2px solid var(--indigo-600); outline-offset: 2px; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 10px; border: 3px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-track { background: transparent; }

/* Component display rules must never un-hide something marked hidden. */
[hidden] { display: none !important; }

.num { font-variant-numeric: tabular-nums; }
.sr-only {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

/* ---------- Wordmark ---------- */
.ap-logo {
  display: inline-flex; align-items: center; gap: .9rem;
  font-family: var(--font-display); font-weight: 800; font-size: 1.9rem;
  letter-spacing: -.025em; color: var(--text); text-decoration: none;
}
.ap-logo b { color: var(--indigo-600); font-weight: 800; }
.ap-logo__mark {
  width: 3rem; height: 3rem; border-radius: .9rem; flex: none;
  background: var(--indigo-600); color: #fff;
  display: grid; place-items: center;
}
.ap-logo__mark svg { width: 1.8rem; height: 1.8rem; display: block; }

/* ---------- Buttons ---------- */
.btn {
  --bh: 4.4rem;
  display: inline-flex; align-items: center; justify-content: center; gap: .8rem;
  min-height: var(--bh); padding: 0 2rem;
  border-radius: var(--r-md); border: 1px solid transparent;
  font-weight: 600; font-size: 1.5rem; line-height: 1;
  cursor: pointer; text-decoration: none; white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
  transition: background var(--dur), border-color var(--dur), color var(--dur),
    box-shadow var(--dur), transform var(--dur) var(--ease-out);
  position: relative;
}
.btn svg { width: 1.8rem; height: 1.8rem; flex: none; display: block; }
.btn:active { transform: translateY(1px); }

.btn--primary { background: var(--indigo-600); color: #fff; box-shadow: 0 1px 2px rgba(20, 22, 43, .14), 0 6px 16px rgba(20, 22, 43, .12); }
.btn--primary:hover { background: var(--indigo-700); }

.btn--secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn--secondary:hover { border-color: var(--text-dim); background: var(--surface-2); }

.btn--quiet { background: transparent; color: var(--text-body); }
.btn--quiet:hover { background: var(--indigo-50); color: var(--indigo-800); }

.btn--lg { --bh: 5.2rem; padding: 0 2.6rem; font-size: 1.6rem; border-radius: var(--r-lg); }
.btn--sm { --bh: 3.6rem; padding: 0 1.4rem; font-size: 1.4rem; border-radius: var(--r-sm); }
.btn--block { width: 100%; }

.btn[disabled], .btn[aria-disabled="true"] { opacity: .45; cursor: not-allowed; transform: none; }

.btn.is-loading { color: transparent !important; pointer-events: none; }
.btn.is-loading svg { opacity: 0; }
.btn.is-loading::after {
  content: ""; position: absolute; width: 1.8rem; height: 1.8rem; border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, .45); border-top-color: #fff;
  animation: ap-spin .7s linear infinite;
}
.btn--secondary.is-loading::after, .btn--quiet.is-loading::after { border-color: var(--border-strong); border-top-color: var(--indigo-600); }
@keyframes ap-spin { to { transform: rotate(360deg); } }

/* ---------- Fields ---------- */
.field { display: grid; gap: .7rem; }
.field__label { font-size: 1.4rem; font-weight: 600; color: var(--text); }
.field__hint { font-size: 1.3rem; color: var(--text-muted); }
.field__error { font-size: 1.3rem; color: var(--danger); display: none; }
.field.is-invalid .field__error { display: block; }

.input {
  width: 100%; min-height: 4.8rem; padding: 1.1rem 1.4rem;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--r-md);
  font-size: 1.6rem; color: var(--text);
  transition: border-color var(--dur), box-shadow var(--dur);
}
.input::placeholder { color: var(--placeholder); }
.input:hover { border-color: var(--text-dim); }
.input:focus { outline: none; border-color: var(--indigo-600); box-shadow: 0 0 0 4px var(--indigo-100); }
.field.is-invalid .input { border-color: var(--danger); box-shadow: 0 0 0 4px var(--danger-50); }
textarea.input { min-height: 8.8rem; resize: vertical; line-height: 1.45; }
select.input {
  appearance: none; padding-right: 3.8rem; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%234B4E68' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 1.3rem center;
}

/* ---------- Chips (selectable, untaken = dashed, taken = solid) ---------- */
.chip {
  display: inline-flex; align-items: center; gap: .7rem;
  min-height: 4.4rem; padding: 0 1.5rem;
  border-radius: var(--r-pill); border: 1px dashed var(--border-strong);
  background: var(--surface); color: var(--text-body);
  font-size: 1.45rem; font-weight: 600; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: border-color var(--dur), background var(--dur), color var(--dur);
}
.chip svg { width: 1.9rem; height: 1.9rem; flex: none; display: block; }
.chip:hover { border-style: solid; border-color: var(--text-dim); color: var(--text); }
.chip[aria-pressed="true"] { border: 1px solid var(--indigo-600); background: var(--indigo-50); color: var(--indigo-800); }

/* ---------- Segmented toggle ---------- */
.seg { display: inline-flex; padding: .3rem; gap: .2rem; background: var(--bg-2); border-radius: var(--r-pill); }
.seg button {
  border: 0; background: transparent; min-height: 3.4rem; padding: 0 1.3rem;
  border-radius: var(--r-pill); font-size: 1.35rem; font-weight: 600; color: var(--text-muted);
  cursor: pointer; display: inline-flex; align-items: center; gap: .6rem;
  transition: background var(--dur), color var(--dur), box-shadow var(--dur);
}
.seg button:hover { color: var(--text); }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.seg button svg { width: 1.6rem; height: 1.6rem; display: block; }

/* ---------- Toast ---------- */
.ap-toast {
  position: fixed; left: 50%; bottom: 2.4rem; z-index: 9999;
  transform: translate(-50%, 1.6rem); opacity: 0; pointer-events: none;
  max-width: calc(100vw - 3.2rem);
  background: var(--text); color: #fff; padding: 1.2rem 1.8rem; border-radius: var(--r-md);
  font-size: 1.45rem; font-weight: 500; box-shadow: var(--shadow-lg);
  transition: opacity .25s var(--ease-out), transform .25s var(--ease-out);
}
.ap-toast.is-in { opacity: 1; transform: translate(-50%, 0); }
.ap-toast--error { background: var(--danger); }

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

/* ---------- Motion: navigation continuity ----------
   Cross-document view transitions make moving between AccessPass pages feel
   like one app instead of a reload: the page crossfades, the wordmark and the
   pass hold their place. Browsers without support just navigate. */
@view-transition { navigation: auto; }
::view-transition-old(root) { animation: ap-vt-out .16s cubic-bezier(.4, 0, 1, 1) both; }
::view-transition-new(root) { animation: ap-vt-in .34s var(--ease-out) both; }
@keyframes ap-vt-out { to { opacity: 0; transform: scale(.99); } }
@keyframes ap-vt-in { from { opacity: 0; transform: scale(1.01); } }
.vt-logo { view-transition-name: ap-logo; }
/* The app rail stays put while the page beside it changes. */
.rail { view-transition-name: ap-rail; }
::view-transition-group(ap-rail) { animation: none; }
::view-transition-old(ap-rail) { display: none; }
::view-transition-new(ap-rail) { animation: none; }
.vt-pass { view-transition-name: ap-pass; }
::view-transition-group(ap-pass) { animation-duration: .5s; animation-timing-function: var(--ease-out); }

/* Same-document stage changes (builder): content travels with the step. */
::view-transition-old(ap-stage) { animation: ap-stage-out .16s cubic-bezier(.4, 0, 1, 1) both; }
::view-transition-new(ap-stage) { animation: ap-stage-in .36s var(--ease-out) both; }
html[data-dir="back"]::view-transition-old(ap-stage) { animation-name: ap-stage-out-back; }
html[data-dir="back"]::view-transition-new(ap-stage) { animation-name: ap-stage-in-back; }
@keyframes ap-stage-out { to { opacity: 0; transform: translateX(-2.4rem); } }
@keyframes ap-stage-in { from { opacity: 0; transform: translateX(3.2rem); } }
@keyframes ap-stage-out-back { to { opacity: 0; transform: translateX(2.4rem); } }
@keyframes ap-stage-in-back { from { opacity: 0; transform: translateX(-3.2rem); } }

/* Lists that arrive as lists: short stagger, capped at 5 steps. */
.ap-stagger > * { animation: ap-rise .5s var(--ease-out) both; }
.ap-stagger > *:nth-child(2) { animation-delay: .05s; }
.ap-stagger > *:nth-child(3) { animation-delay: .1s; }
.ap-stagger > *:nth-child(4) { animation-delay: .15s; }
.ap-stagger > *:nth-child(n+5) { animation-delay: .2s; }
@keyframes ap-rise { from { opacity: 0; transform: translateY(1.2rem); } }

@media (prefers-reduced-motion: reduce) {
  ::view-transition-old(root), ::view-transition-new(root),
  ::view-transition-old(ap-stage), ::view-transition-new(ap-stage) { animation: ap-fade .2s ease both; }
  ::view-transition-group(ap-pass) { animation-duration: .01s; }
  @keyframes ap-fade { from { opacity: 0; } }
}

/* ---------- Phone with country code (APPhone in app.js) ---------- */
.phone { position: relative; display: flex; gap: .8rem; }
.phone .phone__num { flex: 1; min-width: 0; }
.phone__cc { flex: none; width: auto; display: inline-flex; align-items: center; gap: .6rem; padding: 0 1.1rem; cursor: pointer; font-variant-numeric: tabular-nums; color: var(--text); white-space: nowrap; }
.phone__cc svg { width: 1.4rem; height: 1.4rem; color: var(--text-muted); }
.phone__flag { font-size: 2rem; line-height: 1; }
.phone__menu { position: absolute; top: calc(100% + .6rem); left: 0; z-index: 60; width: min(34rem, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-lg); padding: .8rem; display: grid; gap: .6rem; }
.phone__list { list-style: none; margin: 0; padding: 0; max-height: 26rem; overflow-y: auto; overscroll-behavior: contain; }
.phone__list button { width: 100%; display: flex; align-items: center; gap: 1rem; padding: .9rem 1rem; border: 0; border-radius: var(--r-md); background: none; color: var(--text); font: inherit; font-size: 1.5rem; text-align: left; cursor: pointer; }
.phone__list button:hover, .phone__list button:focus-visible { background: var(--bg); outline: none; }
.phone__list button[aria-selected="true"] { background: var(--indigo-50); color: var(--indigo-800); }
.phone__list button span:nth-child(2) { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.phone__list button span:last-child { color: var(--text-muted); font-variant-numeric: tabular-nums; }
.phone__none { padding: 1rem; color: var(--text-muted); font-size: 1.4rem; }

/* ---------- Account status banner (auth.js) ---------- */
.ap-account { display: flex; align-items: center; justify-content: space-between; gap: 1.2rem 2rem; flex-wrap: wrap; margin: 0 0 2.4rem; padding: 1.4rem 1.8rem; border-radius: var(--r-lg); background: var(--warn-50); border: 1px solid var(--border); }
.ap-account b { display: block; font-size: 1.6rem; font-weight: 700; color: var(--text); }
.ap-account span { display: block; margin-top: .2rem; font-size: 1.45rem; color: var(--text-body); max-width: 64rem; }
.ap-account__cta { display: flex; gap: .8rem; flex-wrap: wrap; }
.ap-account .btn { flex: none; }
.ap-account--off { background: var(--danger-50); }

/* ---------- Status badges ---------- */
.ap-badge { display: inline-flex; align-items: center; gap: .5rem; padding: .3rem .9rem; border-radius: var(--r-pill); font-size: 1.25rem; font-weight: 600; white-space: nowrap; }
.ap-badge::before { content: ""; width: .7rem; height: .7rem; border-radius: 50%; background: currentColor; }
.ap-badge--active { background: var(--success-50); color: var(--success); }
.ap-badge--pending { background: var(--warn-50); color: var(--warn); }
.ap-badge--expired, .ap-badge--suspended { background: var(--danger-50); color: var(--danger); }
