/* fredie web onboarding PoC — mobile-first, brand colours from the design manual. */

/* Parkinsans is served from ./fonts (copies of charisme/assets/fonts): no
   Google Fonts request, so no visitor IP leaves the page before consent. */
@font-face { font-family: 'Parkinsans'; font-weight: 400; font-style: normal; font-display: swap; src: url('./fonts/Parkinsans-Regular.ttf') format('truetype'); }
@font-face { font-family: 'Parkinsans'; font-weight: 600; font-style: normal; font-display: swap; src: url('./fonts/Parkinsans-SemiBold.ttf') format('truetype'); }
@font-face { font-family: 'Parkinsans'; font-weight: 700; font-style: normal; font-display: swap; src: url('./fonts/Parkinsans-Bold.ttf') format('truetype'); }
@font-face { font-family: 'Parkinsans'; font-weight: 800; font-style: normal; font-display: swap; src: url('./fonts/Parkinsans-ExtraBold.ttf') format('truetype'); }

:root {
  --moonlight: #788ca0;
  --moonlight-soft: #e6ebf1;
  --citrus: #d7ff9b;
  --orchid: #5f2dff;
  --orchid-dark: #4a1fd6;
  --orchid-soft: #efe9ff;
  --ink: #1c1a2e;
  --ink-muted: #5b5f73;
  --bg: #f7f6fb;
  --card: #ffffff;
  --danger-bg: #fdecec;
  --danger: #b3261e;
  --radius: 16px;
  --shadow: 0 10px 30px rgba(28, 26, 46, 0.08);
  --font: 'Parkinsans', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

* { box-sizing: border-box; }

/* Our display:flex rules must not beat the hidden attribute. */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  color: var(--ink);
  background:
    radial-gradient(60% 40% at 100% 0%, rgba(215, 255, 155, 0.35), transparent 70%),
    radial-gradient(50% 35% at 0% 100%, rgba(95, 45, 255, 0.10), transparent 70%),
    var(--bg);
  min-height: 100dvh;
}

.app {
  max-width: 480px;
  margin: 0 auto;
  padding: 12px 20px calc(24px + env(safe-area-inset-bottom));
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* Header / progress ------------------------------------------------------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 44px;
}

.brand {
  font-weight: 800;
  font-size: 22px;
  letter-spacing: -0.02em;
  color: var(--orchid);
}

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}

.badge-mock {
  background: var(--citrus);
  color: var(--ink);
}

.progress {
  height: 4px;
  border-radius: 999px;
  background: var(--moonlight-soft);
  overflow: hidden;
  margin: 8px 0 20px;
}

.progress__bar {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--orchid), var(--citrus));
  transition: width 320ms ease;
}

/* Screens ----------------------------------------------------------------- */

#screens { flex: 1; }

.screen {
  animation: rise 260ms ease both;
}

.screen--center { text-align: center; }

@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  .screen { animation: none; }
  .progress__bar { transition: none; }
  /* The ring sits on a full-screen overlay at every network step and is the
     only sign that something is running, so it keeps turning — at a third of
     the speed, instead of a fast loop nobody asked for. */
  .spinner__ring { animation-duration: 2400ms; }
}

h1, h2 {
  margin: 0 0 12px;
  letter-spacing: -0.02em;
  line-height: 1.15;
  font-weight: 700;
}

h1 { font-size: 30px; }
h2 { font-size: 24px; }

/* User- or backend-provided text (the name in the success headline, chapter and
   package titles) must wrap, never widen the page. */
h1, h2, .lead, .muted, .chapter__title, .package__title { overflow-wrap: anywhere; }

p { margin: 0 0 12px; }

.lead { font-size: 17px; color: var(--ink); }
.muted { color: var(--ink-muted); }
.small { font-size: 13px; }

.eyebrow {
  margin: 0 0 8px;
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--moonlight);
}

.hero {
  position: relative;
  padding: 28px 0 8px;
}

.hero__glow {
  position: absolute;
  inset: -10px auto auto -50px;
  width: 200px;
  height: 200px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(215, 255, 155, 0.9), rgba(215, 255, 155, 0));
  z-index: -1;
}

/* The otter (assets/otter/happy.svg) sits on the glow, above the headline. */
.hero__otter {
  display: block;
  height: 150px;
  width: auto;
  margin: 0 0 18px 4px;
}

.back {
  display: inline-block;
  margin: 0 0 16px;
  padding: 4px 0;
  border: 0;
  background: none;
  color: var(--moonlight);
  font: inherit;
  font-size: 14px;
  cursor: pointer;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* Buttons ----------------------------------------------------------------- */

.actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 28px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 52px;
  padding: 12px 20px;
  border-radius: 14px;
  border: 2px solid transparent;
  font: inherit;
  font-weight: 600;
  font-size: 16px;
  text-decoration: none;
  cursor: pointer;
  /* No double-tap zoom / 300 ms delay on iOS Safari. */
  touch-action: manipulation;
  transition: transform 120ms ease, background 120ms ease, opacity 120ms ease;
}

.btn:active { transform: scale(0.985); }

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

.btn-primary {
  background: var(--orchid);
  color: #fff;
  box-shadow: 0 8px 20px rgba(95, 45, 255, 0.25);
}

.btn-primary:hover:not(:disabled) { background: var(--orchid-dark); }

.btn-secondary {
  background: var(--card);
  color: var(--orchid);
  border-color: var(--orchid);
}

.btn-link {
  min-height: 40px;
  background: none;
  color: var(--orchid);
  box-shadow: none;
}

/* 600 like every other button (no Medium face is shipped). */
.btn-link.small { font-size: 13px; color: var(--moonlight); font-weight: 600; }

/* Forms ------------------------------------------------------------------- */

.form { margin-top: 8px; }

.input {
  width: 100%;
  min-height: 54px;
  padding: 12px 16px;
  border-radius: 14px;
  border: 2px solid var(--moonlight-soft);
  background: var(--card);
  font: inherit;
  font-size: 18px;
  color: var(--ink);
  outline: none;
  transition: border-color 120ms ease;
}

/* Six digits, read back at a glance: wide tracking and a tabular figure so
   the code lines up with the one in the mail. */
.input--code {
  font-size: 1.5rem;
  letter-spacing: 0.35em;
  text-align: center;
  font-variant-numeric: tabular-nums;
}


.input:focus { border-color: var(--orchid); }

.label {
  display: block;
  margin: 14px 0 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-muted);
}

.label:first-child { margin-top: 0; }

.field-hint {
  margin: 6px 0 0;
  font-size: 13px;
  color: var(--ink-muted);
}

.field-error {
  margin: 8px 0 0;
  color: var(--danger);
  font-size: 14px;
}

/* Persistent notice on the account card (the server rejects the tokens it issues); unlike the banner it survives re-renders. */
.config-error {
  margin: 0 0 16px;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--danger-bg);
  color: var(--danger);
  font-size: 14px;
}

/* "oder" between the form and the optional social login. */
.divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 20px 0 12px;
  font-size: 13px;
  color: var(--ink-muted);
}

.divider::before,
.divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--moonlight-soft);
}

/* Question slider --------------------------------------------------------- */

.dots {
  display: flex;
  gap: 8px;
  margin: 0 0 20px;
}

.dots span {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--moonlight-soft);
  transition: background 160ms ease, transform 160ms ease;
}

.dots span.is-done { background: var(--moonlight); }
.dots span.is-active { background: var(--orchid); transform: scale(1.25); }

.slider {
  margin-top: 36px;
  padding: 24px 16px 18px;
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow);
}

.slider__labels {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 14px;
  font-size: 13px;
  color: var(--ink-muted);
}

.slider__labels span:last-child { text-align: right; }

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 32px;
  margin: 0;
  background: transparent;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-runnable-track {
  height: 8px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--moonlight-soft), var(--citrus));
}

input[type="range"]::-moz-range-track {
  height: 8px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--moonlight-soft), var(--citrus));
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 30px;
  height: 30px;
  margin-top: -11px;
  border-radius: 50%;
  border: 4px solid #fff;
  background: var(--orchid);
  box-shadow: 0 4px 12px rgba(95, 45, 255, 0.35);
}

input[type="range"]::-moz-range-thumb {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 4px solid #fff;
  background: var(--orchid);
  box-shadow: 0 4px 12px rgba(95, 45, 255, 0.35);
}

input[type="range"]:focus-visible { outline: 3px solid var(--orchid-soft); border-radius: 999px; }

/* Account checklist ------------------------------------------------------- */

.checklist {
  list-style: none;
  padding: 0;
  margin: 12px 0 0;
}

.checklist li {
  position: relative;
  padding: 6px 0 6px 32px;
}

.checklist li::before {
  content: '✓';
  position: absolute;
  left: 0;
  top: 5px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--citrus);
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Plan / chapters --------------------------------------------------------- */

.chapters {
  list-style: none;
  padding: 0;
  margin: 20px 0 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.chapter {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 14px;
  border-radius: var(--radius);
  border: 2px solid transparent;
  background: var(--card);
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: border-color 120ms ease;
}

.chapter.is-selected { border-color: var(--orchid); }

/* Cap reached (3 picks): the remaining chapters are visibly off. */
.chapter.is-disabled { opacity: 0.55; cursor: not-allowed; }

.chapter input[type="checkbox"] {
  width: 22px;
  height: 22px;
  margin: 0;
  accent-color: var(--orchid);
  flex: none;
}

/* Fixed box for the chapter otter (the app's chapter.imageUrl), tinted with the chapter colour. */
.chapter__figure {
  width: 56px;
  height: 56px;
  flex: none;
  border-radius: 12px;
  background: var(--moonlight-soft);
  overflow: hidden;
}

.chapter__image {
  display: block;
  width: 100%;
  height: 100%;
  padding: 5px;
  object-fit: contain;
}

.chapter__body { flex: 1; min-width: 0; }

.chapter__title {
  font-weight: 600;
  line-height: 1.25;
}

.chapter__meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
  font-size: 13px;
  color: var(--ink-muted);
}

.match {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--citrus);
  color: var(--ink);
  font-weight: 600;
  font-size: 12px;
}

/* Checkout ---------------------------------------------------------------- */

.packages {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 20px 0 16px;
}

.package {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  padding: 16px;
  border-radius: var(--radius);
  border: 2px solid transparent;
  background: var(--card);
  box-shadow: var(--shadow);
  font: inherit;
  text-align: left;
  color: var(--ink);
  cursor: pointer;
  transition: border-color 120ms ease;
}

.package:hover:not(:disabled) { border-color: var(--moonlight); }
.package.is-selected { border-color: var(--orchid); }
.package:disabled { opacity: 0.6; cursor: not-allowed; }
/* While the inline checkout is open all packages are disabled; the chosen one must still read as chosen. */
.package.is-selected:disabled { opacity: 1; }

.package__title { font-weight: 600; }
.package__period { font-size: 13px; color: var(--ink-muted); }

.package__price {
  font-weight: 700;
  font-size: 18px;
  color: var(--orchid);
  white-space: nowrap;
}

.checkout-container { margin-top: 8px; }

.mock-checkout {
  padding: 18px 16px;
  border-radius: var(--radius);
  border: 2px dashed var(--moonlight);
  background: var(--card);
}

.mock-checkout__label {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--moonlight);
}

.mock-checkout .btn { margin-top: 8px; }

/* Success ----------------------------------------------------------------- */

.success__otter {
  display: block;
  height: 180px;
  width: auto;
  margin: 16px auto 20px;
  filter: drop-shadow(0 14px 24px rgba(95, 45, 255, 0.18));
}

/* Error banner / spinner -------------------------------------------------- */

.error {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin: 0 0 16px;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--danger-bg);
  color: var(--danger);
  font-size: 14px;
}

.error__close {
  margin-left: auto;
  border: 0;
  background: none;
  color: inherit;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  flex: none;
}

.spinner {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: rgba(247, 246, 251, 0.82);
  backdrop-filter: blur(3px);
}

.spinner__ring {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 4px solid var(--moonlight-soft);
  border-top-color: var(--orchid);
  animation: spin 800ms linear infinite;
}

.spinner__text { margin: 0; color: var(--ink-muted); font-size: 14px; }

@keyframes spin { to { transform: rotate(360deg); } }

.actions + .muted { margin-top: 18px; }

.footer {
  margin-top: 24px;
  text-align: center;
}

/* Desktop: keep it a phone-width card, just breathe a bit more. */
@media (min-width: 640px) {
  body { padding: 24px 0; }
  .app {
    min-height: auto;
    padding: 20px 32px 32px;
    background: rgba(255, 255, 255, 0.55);
    border-radius: 24px;
    box-shadow: var(--shadow);
  }
  .chapter__figure {
    width: 64px;
    height: 64px;
  }
}
