/* journey.css — the SHARED journey component layer (DESIGN.md S1/S6/K4/K6).
 *
 * Built ONCE, re-skinned by [data-brand] (banks.css) with ZERO markup change.
 * Every component below references ONLY --j-* tokens (colour, radius, font,
 * shadow) and the contract --spacing-* scale — never a primitive, never a
 * literal colour or radius. Font-size/line-height/border-width are plain px:
 * the --j-* contract has no type scale (only --j-font-display/--j-font-body),
 * and swatches.html already sets this precedent (S1 governs COLOUR + RADIUS
 * literals; a 4px spacing rhythm is kept via --spacing-* per K3).
 *
 * Load order (S2, this build): tokens.contract.css → tokens.lloyds.css →
 * components.css → banks.css → proto.css → THIS FILE. Loading after proto.css
 * lets journey rules win focus-ring ties against proto.css's .ot-screen
 * button:focus-visible rule (same specificity, later source wins); the
 * component-class focus rules below also out-specify it outright, so the
 * ring is guaranteed to resolve to the ACTIVE SKIN's --j-accent, not
 * trainline's --t-rail leftover in proto.css.
 *
 * Two families live here:
 *   1. THE PHONE — .j-app and everything inside it. --j-* tokens only.
 *   2. THE BRAND SWITCHER — sits in the studio-chrome exhibit frame, above
 *      the phone. It is NOT journey content, so per the task brief it is
 *      styled in CONTRACT tokens (--color-x / --font-x), same as the rest of
 *      the exhibit frame (.ot-topbar, .ot-notes, …). Its brand-preview DOTS
 *      are the one exception: each chip carries its own [data-brand], so
 *      var(--j-accent) resolves locally to that brand's swatch colour —
 *      still zero literals, just scoped differently.
 */

/* ============================================================
   0. Generic a11y utility (no brand tokens involved — nothing to theme)
   ============================================================ */

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* AI-use disclosure (C7): second line under the B3 legal line on the journey
   and compare shells — .proto-legal lives in proto.css (a read-only mirror),
   so its extra line is styled here. Contract tokens only; inherits the muted
   ink of .proto-legal. */
.proto-legal-ai { display: block; margin-top: var(--spacing-xs); }

/* ============================================================
   1. .j-app — the phone-screen root
   ============================================================ */

.j-app {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: var(--j-bg);
  color: var(--j-ink);
  font-family: var(--j-font-body);
  font-size: 16px;
  line-height: 1.5;
  position: relative;
  overflow: hidden;
}
.j-app * { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

/* ---------- appbar: back affordance + step progress ---------- */

.j-appbar {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  padding: var(--spacing-md) var(--spacing-md) var(--spacing-sm);
  flex: none;
}

.j-back {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  flex: none;
  border-radius: var(--j-radius);
  border: 1.5px solid var(--j-border);
  background: var(--j-surface);
  color: var(--j-ink);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  transition: background-color 160ms ease, border-color 160ms ease;
}
.j-back:hover { background: var(--j-border); }
.j-back:disabled { visibility: hidden; cursor: default; }

.j-appbar-title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--j-font-display);
  font-size: 14px;
  letter-spacing: 0.04em;
  color: var(--j-muted);
}

.j-progress { display: flex; align-items: center; gap: 6px; flex: none; }
.j-progress i {
  display: block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--j-border);
  transition: background-color 200ms ease, transform 200ms ease;
}
.j-progress i.is-done { background: var(--j-accent); }
.j-progress i.is-active { background: var(--j-accent); transform: scale(1.3); }

/* ---------- step container ---------- */

.j-step {
  flex: 1;
  overflow-y: auto;
  padding: var(--spacing-sm) var(--spacing-lg) var(--spacing-xl);
  display: flex;
  flex-direction: column;
  gap: var(--spacing-md);
  scrollbar-width: none;
  animation: j-step-in 220ms ease;
}
.j-step::-webkit-scrollbar { display: none; }

@keyframes j-step-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
@media (prefers-reduced-motion: reduce) {
  .j-step { animation: none; }
}

.j-h {
  font-family: var(--j-font-display);
  font-size: 26px;
  line-height: 1.18;
  letter-spacing: -0.01em;
  margin: 0;
  color: var(--j-ink);
}

.j-lede {
  margin: 0;
  font-size: 15px;
  line-height: 1.55;
  color: var(--j-ink);
}
.j-help {
  margin: 0;
  font-size: 13px;
  line-height: 1.5;
  color: var(--j-muted);
}
.j-err {
  margin: 0;
  font-size: 13px;
  line-height: 1.45;
  color: var(--j-caution);
  display: flex;
  align-items: flex-start;
  gap: 6px;
}

/* ============================================================
   2. Buttons
   ============================================================ */

.j-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 44px;
  padding: 0 var(--spacing-lg);
  border-radius: var(--j-radius);
  border: 1.5px solid transparent;
  font-family: var(--j-font-display);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 160ms ease, border-color 160ms ease, color 160ms ease, transform 80ms ease;
}
.j-btn:active { transform: scale(0.985); }
@media (prefers-reduced-motion: reduce) {
  .j-btn:active { transform: none; }
}

.j-btn--primary {
  background: var(--j-accent);
  color: var(--j-accent-fg);
}
.j-btn--primary:hover { background: var(--j-accent-hover); }

.j-btn--secondary {
  background: transparent;
  color: var(--j-ink);
  border-color: var(--j-ink);
}
.j-btn--secondary:hover { border-color: var(--j-accent-hover); color: var(--j-accent-hover); }

.j-btn--ghost {
  background: transparent;
  color: var(--j-muted);
  width: auto;
  padding: 0 var(--spacing-sm);
  font-family: var(--j-font-body);
  font-weight: 500;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.j-btn--ghost:hover { color: var(--j-ink); }

/* considered disabled state — muted-on-surface is the pairing already tuned
   for AA across all five skins (banks.css), so disabled buttons stay
   readable rather than fading to an unverifiable low-opacity grey (A1: AA
   holds in the disabled state too, not just default/hover/focus). */
.j-btn:disabled,
.j-btn[aria-disabled="true"] {
  background: var(--j-surface);
  color: var(--j-muted);
  border-color: var(--j-border);
  cursor: not-allowed;
  text-decoration: none;
}

.j-btn-row { display: flex; flex-direction: column; gap: var(--spacing-sm); }
/* anchor the primary action to the bottom of the step on short screens
   (entry, confirm) instead of leaving a dead gap under short content;
   has no effect once content already fills/overflows the step. */
.j-step > .j-btn-row:last-child { margin-top: auto; }

.j-inline-link {
  color: var(--j-accent);
  text-decoration: underline;
  text-underline-offset: 2px;
  font-weight: 600;
}
.j-inline-link:hover { color: var(--j-accent-hover); }

/* ============================================================
   3. Chips — single-select triage
   ============================================================ */

.j-chip-group {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-sm);
}

.j-chip {
  display: flex;
  align-items: center;
  min-height: 44px;
  width: 100%;
  padding: 0 var(--spacing-md);
  border-radius: var(--j-radius);
  border: 1.5px solid var(--j-border);
  background: var(--j-surface);
  color: var(--j-ink);
  font-family: var(--j-font-body);
  font-size: 15px;
  text-align: left;
  cursor: pointer;
  transition: background-color 160ms ease, border-color 160ms ease, color 160ms ease;
}
.j-chip:hover { border-color: var(--j-accent); }
.j-chip[aria-pressed="true"] {
  background: var(--j-accent);
  border-color: var(--j-accent);
  color: var(--j-accent-fg);
  font-weight: 600;
}

/* ============================================================
   4. Field (shared with Journey 2)
   ============================================================ */

.j-field { display: flex; flex-direction: column; gap: var(--spacing-xs); }
.j-field label {
  font-family: var(--j-font-body);
  font-size: 13px;
  font-weight: 600;
  color: var(--j-ink);
}
.j-field input {
  min-height: 44px;
  padding: 0 var(--spacing-md);
  border-radius: var(--j-radius);
  border: 1.5px solid var(--j-border);
  background: var(--j-bg);
  color: var(--j-ink);
  font-family: var(--j-font-body);
  font-size: 16px;
}
.j-field.has-error input { border-color: var(--j-caution); }

/* ============================================================
   5. Option card + disclosure + list row
   ============================================================ */

.j-option { display: flex; flex-direction: column; gap: var(--spacing-xs); }

.j-card {
  display: block;
  width: 100%;
  text-align: left;
  background: var(--j-surface);
  border: 1.5px solid var(--j-border);
  border-radius: var(--j-radius);
  padding: var(--spacing-lg);
  font-family: inherit;
  color: var(--j-ink);
  cursor: pointer;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}
.j-card:hover { border-color: var(--j-accent); }
.j-card[aria-pressed="true"] {
  border-color: var(--j-accent);
  box-shadow: 0 0 0 1.5px var(--j-accent);
}
.j-card-title {
  display: block;
  font-family: var(--j-font-display);
  font-size: 18px;
  line-height: 1.25;
  margin-bottom: 4px;
}
.j-card-desc {
  display: block;
  font-size: 14px;
  line-height: 1.5;
  color: var(--j-muted);
}
[aria-pressed="true"] .j-card-desc { color: var(--j-ink); }

.j-disclosure { border: 0; }
.j-disclosure summary {
  list-style: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  min-height: 44px;              /* A4: 44px tap target inside the journey */
  padding: var(--spacing-xs) 0;
  font-family: var(--j-font-display);
  font-size: 13px;
  font-weight: 600;
  color: var(--j-accent);
}
.j-disclosure summary::-webkit-details-marker { display: none; }
.j-disclosure summary:hover { color: var(--j-accent-hover); }
.j-disclosure[open] summary { color: var(--j-accent-hover); }
.j-disclosure-body {
  margin: 0 0 var(--spacing-xs);
  font-size: 13px;
  line-height: 1.5;
  color: var(--j-muted);
}

.j-row {
  display: flex;
  gap: var(--spacing-md);
  align-items: flex-start;
  padding: var(--spacing-sm) 0;
}
.j-row + .j-row { border-top: 1px solid var(--j-border); }
.j-row-num {
  flex: none;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--j-accent);
  color: var(--j-accent-fg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--j-font-display);
  font-size: 12px;
  font-weight: 700;
}
.j-row-text { flex: 1; font-size: 15px; line-height: 1.5; padding-top: 2px; }
.j-row-text strong { color: var(--j-ink); font-weight: 700; }

/* ============================================================
   6. States (K1) — loading, empty, error, success
   ============================================================ */

/* -- loading: calm, greyed content + a slim moving bar, never a bare spinner */
.j-loading-bar {
  height: 3px;
  border-radius: 999px;
  background: var(--j-border);
  overflow: hidden;
  position: relative;
}
.j-loading-bar::after {
  content: "";
  position: absolute;
  inset: 0;
  width: 40%;
  border-radius: inherit;
  background: var(--j-accent);
  animation: j-bar-slide 1.1s ease-in-out infinite;
}
@keyframes j-bar-slide {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(350%); }
}
@media (prefers-reduced-motion: reduce) {
  .j-loading-bar::after { animation: none; width: 60%; transform: none; }
}
.is-loading .j-row { opacity: 0.55; }

/* skeleton fill, available to either journey for a content placeholder */
.j-skel {
  border-radius: var(--j-radius);
  background: linear-gradient(90deg, var(--j-border) 25%, var(--j-surface) 50%, var(--j-border) 75%);
  background-size: 200% 100%;
  animation: j-shimmer 1.6s ease-in-out infinite;
}
@keyframes j-shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
@media (prefers-reduced-motion: reduce) {
  .j-skel { animation: none; opacity: 0.7; }
}

/* -- empty: warm zero-state, one clear CTA (shared layer; J2 uses this) -- */
.j-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: var(--spacing-sm);
  padding: var(--spacing-2xl) var(--spacing-lg);
}
.j-empty-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 1.5px dashed var(--j-border);
  color: var(--j-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  margin-bottom: var(--spacing-xs);
}
.j-empty-title { font-family: var(--j-font-display); font-size: 17px; margin: 0; color: var(--j-ink); }
.j-empty-body { font-size: 14px; line-height: 1.5; color: var(--j-muted); margin: 0; max-width: 32ch; }

/* -- error: named, bordered, always an escape route -- */
.j-error {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--spacing-sm);
  background: var(--j-surface);
  border: 1.5px solid var(--j-caution);
  border-radius: var(--j-radius);
  padding: var(--spacing-lg);
}
.j-error-icon {
  width: 36px;
  height: 36px;
  flex: none;
  border-radius: 50%;
  border: 2px solid var(--j-caution);
  color: var(--j-caution);
  background: var(--j-surface);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--j-font-display);
  font-weight: 700;
  font-size: 16px;
}
.j-error-title { font-family: var(--j-font-display); font-size: 16px; margin: 0; color: var(--j-ink); }
.j-error-body { font-size: 14px; line-height: 1.55; margin: 0; color: var(--j-ink); }

/* -- success: calm confirmation -- */
.j-success {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: var(--spacing-sm);
  padding-top: var(--spacing-xl);
}
.j-success-icon {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 2px solid var(--j-positive);
  color: var(--j-positive);
  background: var(--j-surface);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  margin-bottom: var(--spacing-xs);
}
.j-success-title { font-family: var(--j-font-display); font-size: 22px; margin: 0; color: var(--j-ink); }
.j-success-ref { font-size: 13px; color: var(--j-muted); margin: 0; }
.j-success-ref b { color: var(--j-ink); letter-spacing: 0.04em; }
.j-success-body { font-size: 15px; line-height: 1.55; margin: var(--spacing-xs) 0 0; max-width: 34ch; color: var(--j-ink); }

/* ============================================================
   7. Toast — quiet acknowledgement (e.g. "Not now")
   ============================================================ */

.j-toast {
  position: absolute;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%) translateY(8px);
  max-width: calc(100% - var(--spacing-xl));
  background: var(--j-ink);
  color: var(--j-bg);
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  padding: 10px 18px;
  border-radius: var(--j-radius);
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms ease, transform 200ms ease;
  z-index: 5;
}
.j-toast.is-shown { opacity: 1; transform: translateX(-50%) translateY(0); }
@media (prefers-reduced-motion: reduce) {
  .j-toast { transition: opacity 200ms ease; transform: translateX(-50%); }
  .j-toast.is-shown { transform: translateX(-50%); }
}

/* ============================================================
   8. Focus rings — must beat proto.css's leftover .ot-screen rule
   ============================================================ */

.j-app button:focus-visible,
.j-app a:focus-visible,
.j-app input:focus-visible,
.j-app summary:focus-visible,
.j-app .j-btn:focus-visible,
.j-app .j-chip:focus-visible,
.j-app .j-card:focus-visible,
.j-app .j-back:focus-visible,
.j-app .j-inline-link:focus-visible {
  outline: 2px solid var(--j-accent);
  outline-offset: 2px;
}

/* ============================================================
   9. Brand switcher — studio chrome, CONTRACT tokens (not --j-*)
   ============================================================ */

.j-switcher {
  display: flex;
  flex-wrap: wrap;
  gap: var(--spacing-sm);
  justify-content: center;
}

.j-switch-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 var(--spacing-md);
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--color-border);
  background: var(--color-bg-surface);
  color: var(--color-fg);
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 160ms ease, border-color 160ms ease, color 160ms ease;
}
.j-switch-chip:hover { border-color: var(--color-border-strong); }
.j-switch-chip[aria-pressed="true"] {
  background: var(--color-bg-inverse);
  border-color: var(--color-bg-inverse);
  color: var(--color-fg-on-inverse-strong);
}
.j-switch-chip:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

.j-switch-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--j-accent);
  flex: none;
}

.j-switch-hero {
  font-family: var(--font-display);
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--color-accent);
  color: var(--color-accent-fg);
}

@media (max-width: 480px) {
  .j-switch-chip { font-size: 12px; padding: 0 var(--spacing-sm); }
}

/* ============================================================
   10. Notes-panel state-preview control — lets the error state (K1) be
   demonstrated without putting meta/prototype language inside the phone
   (DESIGN.md C6: in-journey copy is product copy only). Reuses proto.css's
   .ot-notes-link typography (contract tokens); this just resets native
   <button> chrome so it reads identically to the existing <a> version.
   ============================================================ */

button.ot-notes-link {
  background: none;
  border: 0;
  border-bottom: 2px solid var(--color-accent);
  padding: 0 0 2px;
  cursor: pointer;
}

/* ============================================================
   11. Journey 2 — savings projection + round-ups toggle
   (goals/app.js). --j-* tokens only, same family as sections 1-8;
   K2: fill width transition is 200ms, prefers-reduced-motion drops it.
   ============================================================ */

.j-projection { display: flex; flex-direction: column; gap: var(--spacing-xs); }

.j-projection-headline {
  margin: 0;
  font-size: 15px;
  line-height: 1.5;
  color: var(--j-ink);
}
.j-projection-headline strong {
  font-family: var(--j-font-display);
  font-weight: 700;
}

.j-projection-bar {
  height: 8px;
  border-radius: 999px;
  background: var(--j-border);
  overflow: hidden;
}
.j-projection-fill {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--j-accent);
  width: 0%;
  transition: width 200ms ease;
}
@media (prefers-reduced-motion: reduce) {
  .j-projection-fill { transition: none; }
}

.j-projection-caption {
  margin: 0;
  font-size: 13px;
  line-height: 1.5;
  color: var(--j-muted);
}

/* ---------- round-ups toggle: label + a real switch, 44px target ---------- */

.j-toggle {
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
  padding: var(--spacing-sm) 0;
}
.j-toggle-text { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.j-toggle-label {
  font-family: var(--j-font-body);
  font-size: 15px;
  font-weight: 600;
  color: var(--j-ink);
}
.j-toggle-help {
  font-size: 13px;
  line-height: 1.4;
  color: var(--j-muted);
}

/* the button is the full 44px hit target; the visible pill sits centred
   inside it so the track can stay a slim, considered size */
.j-toggle-switch {
  flex: none;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 0;
  background: transparent;
  padding: 0;
  cursor: pointer;
}
.j-toggle-track {
  position: relative;
  display: block;
  width: 44px;
  height: 26px;
  border-radius: 999px;
  /* fill carries the on/off state (--j-border / --j-accent, as specified);
     the --j-muted boundary is what keeps the OFF track perceivable at
     WCAG 1.4.11's 3:1 non-text floor — --j-border alone on --j-bg reads
     far below that in every skin, since borders are tuned as quiet
     hairlines, not state indicators. */
  border: 1.5px solid var(--j-muted);
  background: var(--j-border);
  transition: background-color 160ms ease, border-color 160ms ease;
}
.j-toggle-switch[aria-checked="true"] .j-toggle-track {
  background: var(--j-accent);
  border-color: var(--j-accent);
}
.j-toggle-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--j-bg);
  border: 1.5px solid var(--j-muted);
  transition: transform 160ms ease;
}
.j-toggle-switch[aria-checked="true"] .j-toggle-thumb { transform: translateX(18px); }
@media (prefers-reduced-motion: reduce) {
  .j-toggle-track, .j-toggle-thumb { transition: none; }
}

