/* ============================================================
   Layout — the app shell that surrounds every screen:
   blue header, step bar, fixed frame (head / body / foot).

   Mobile-first: the default rules below are the phone layout.
   Media queries add the wider layouts on top, so a small screen
   never has to undo desktop sizing.
   ============================================================ */

/* ---------------- App shell (phones) ----------------
   The page itself never scrolls: header and footer buttons stay put and
   only .frame__body scrolls. That is what makes it feel like an app
   rather than a long web page, and it keeps Continue always reachable.
   100dvh (not 100vh) so the browser's collapsing address bar is handled. */
html, body { height: 100%; }
body {
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ---------------- App header ---------------- */
.app-header {
  flex: none;
  background: var(--color-brand);
  color: #fff;
  padding: var(--space-3) 0;
}
.app-header__inner {
  width: var(--shell-w);
  max-width: calc(100% - 2 * var(--shell-gutter));
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}
.app-header__title {
  font-size: var(--fs-md);
  font-weight: var(--fw-semibold);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.app-header__sub {
  font-size: var(--fs-sm);
  opacity: .85;
  display: none;              /* subtitle is noise on a phone */
}
.app-header__logo {
  height: 32px;
  width: auto;
  flex: none;
  cursor: pointer;
}

/* ---------------- Shell ---------------- */
.shell {
  flex: 1;
  min-height: 0;                 /* lets the frame shrink instead of overflowing */
  display: flex;
  flex-direction: column;
  width: var(--shell-w);
  max-width: calc(100% - 2 * var(--shell-gutter));
  margin: var(--space-3) auto;
}
.app-credit {
  display: none;                 /* decoration — the phone needs the pixels */
  text-align: center;
  margin-top: var(--space-4);
  font-size: var(--fs-sm);
  color: var(--color-muted);
  letter-spacing: .02em;
}

/* ---------------- Step bar ----------------
   On phones the full list of steps cannot fit, so the individual
   steps are hidden and a single compact line is shown instead. */
.stepbar {
  flex: none;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}
.stepbar__step,
.stepbar__line { display: none; }
.stepbar__compact {
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  color: var(--color-text-2);
}

/* ---------------- Frame ---------------- */
.frame {
  flex: 1;                      /* fills whatever the shell leaves */
  min-height: 0;
  width: 100%;
  height: var(--frame-h);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.frame__head {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-height: 44px;
  padding: var(--space-2) var(--frame-pad);
  background: var(--color-surface-2);
  border-bottom: 1px solid var(--color-border-light);
  flex: none;
}
.frame__dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--color-accent);
  flex: none;
}
.frame__title {
  font-size: var(--fs-md);
  font-weight: var(--fw-bold);
  letter-spacing: .06em;
  text-transform: uppercase;
}
.frame__body {
  flex: 1;
  min-height: 0;
  padding: var(--frame-pad);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.frame__foot {
  flex: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--frame-pad);
  /* clear of the iPhone home indicator */
  padding-bottom: calc(var(--space-3) + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--color-border-light);
}
.frame__count {
  font-size: var(--fs-md);
  color: var(--color-muted);
  text-align: center;
  flex: 1;
}
/* footer buttons must stay thumb-sized on a phone */
.frame__foot .btn {
  min-height: var(--tap-target);
  flex: none;
}

/* ============================================================
   Tablet and up
   ============================================================ */
@media (min-width: 768px) {
  :root {
    --shell-gutter: var(--space-5);
    --frame-pad: 20px;
  }
  .app-header { padding: var(--space-4) 0; }
  .app-header__inner { height: 50px; padding-right: 10px; }
  .app-header__title { font-size: var(--fs-lg); }
  .app-header__sub { display: block; }
  .app-header__logo { height: 48px; }

  .shell { margin: var(--space-5) auto var(--space-8); }

  /* full step list replaces the compact line */
  .stepbar { margin-bottom: var(--space-4); }
  .stepbar__compact { display: none; }
  .stepbar__step {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    font-size: var(--fs-md);
    color: var(--color-muted);
    white-space: nowrap;
  }
  .stepbar__num {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    font-size: var(--fs-sm);
    font-weight: var(--fw-bold);
    background: var(--color-border-light);
    color: var(--color-muted);
    flex: none;
  }
  .stepbar__step.active { color: var(--color-text); font-weight: var(--fw-semibold); }
  .stepbar__step.active .stepbar__num { background: var(--color-accent); color: #fff; }
  .stepbar__step.done .stepbar__num { background: var(--color-success); color: #fff; }
  .stepbar__line { display: block; flex: 1; height: 2px; background: var(--color-border-light); }

  .frame { border-radius: 0 0 var(--radius-lg) var(--radius-lg); }
  .frame__head { height: 52px; min-height: 0; padding: 0 var(--space-5); }
  .frame__foot { height: 75px; align-items: flex-end; padding: 0; }
  .frame__foot > * { align-self: center; }
  .frame__foot {
    /* the divider sits above the buttons, 13px all round */
    padding: 13px;
    border-top: 1px solid var(--color-border-light);
  }
}

/* ============================================================
   Desktop — the original fixed canvas
   ============================================================ */
/* ============================================================
   Desktop — the app shell stays, but the frame now grows to fit
   whatever height the screen has instead of a hard 500px canvas.
   The clamp keeps it sane: never cramped on a laptop, never
   absurdly tall on a large monitor; leftover space centres it.
   ============================================================ */
@media (min-width: 1024px) {
  :root {
    --frame-pad: var(--space-5);   /* 24px around the body content */
  }
  .shell {
    justify-content: center;
    margin: var(--space-5) auto;
  }
  .frame {
    flex: 1;
    min-height: 420px;
    max-height: 820px;
  }
  .frame__body { scrollbar-width: none; -ms-overflow-style: none; }
  .frame__body::-webkit-scrollbar { display: none; width: 0; height: 0; }
  .frame__foot { padding-bottom: 13px; }
  .app-credit { display: block; flex: none; }
}
