/* ----------------------------------------------------------------
   App frame: centered column with vertical rails on both sides.
   All pages (welcome + form pages) use this as their outer wrapper.
---------------------------------------------------------------- */
.app-frame {
  max-width: var(--app-frame);
  margin: 0 auto;
  min-height: 100dvh;
  background: transparent;
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}

/* ----------------------------------------------------------------
   Page header, back arrow on left, logo centered, 48px tall.
   Uses a 3-column grid (1fr | auto | 1fr) so logo stays perfectly
   centered regardless of back-arrow presence.
---------------------------------------------------------------- */
.page-header {
  flex-shrink: 0;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 8px;
  height: 64px;
  padding: 10px 20px;
  margin-top: 0;
}

@media (min-width: 768px) {
  .page-header { height: 94px; padding: 19px 24px; }
}

.page-header__back {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  justify-self: start;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  color: var(--text-strong);
  background: transparent;
  border: 0;
  cursor: pointer;
  text-decoration: none;
}

.page-header__back:hover { background: var(--bg-page); text-decoration: none; }
.page-header__back svg { width: 22px; height: 22px; }

.page-header__logo {
  height: 32px;
  width: auto;
  max-width: 140px;
  object-fit: contain;
  justify-self: center;
}

@media (min-width: 768px) {
  .page-header__logo { height: 40px; max-width: 180px; }
}

.page-header__spacer {
  /* Reserves the right column so the logo stays centered. */
  display: block;
}

/* ----------------------------------------------------------------
   Stepper, sits just below the header, full width with horizontal
   padding matching the header.
---------------------------------------------------------------- */
.page-stepper {
  flex-shrink: 0;
  padding: 8px 20px 0;
}

@media (min-width: 768px) {
  .page-stepper { padding: 16px 24px 0; }
}

/* ----------------------------------------------------------------
   Page flow, flex column that fills the rest of the frame.
   Form (or div) wrapping page-top / page-fields / page-bottom.
---------------------------------------------------------------- */
.page-flow {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* ----------------------------------------------------------------
   Page top, title block at the top of the content area.
---------------------------------------------------------------- */
.page-top {
  flex-shrink: 0;
  padding: 24px 30px 0;
}

/* ----------------------------------------------------------------
   Page fields, scrollable area between title and bottom button.
   Holds form fields (gap 14px), tip cards, illustrations, etc.
---------------------------------------------------------------- */
.page-fields {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 0 24px;
  margin: 12px 0 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.page-fields--centered {
  align-items: center;
  justify-content: center;
  text-align: center;
}

/* ----------------------------------------------------------------
   Page bottom, bottom button area (sticks to bottom of frame).
---------------------------------------------------------------- */
.page-bottom {
  flex-shrink: 0;
  padding: 8px 24px max(20px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Capture screens (DNI frente/dorso), bottom padding más compacto. */
.page-bottom--capture { padding-bottom: max(20px, env(safe-area-inset-bottom)); }

/* ----------------------------------------------------------------
   Responsive paddings, match CIEE reference exactly.
---------------------------------------------------------------- */
@media (min-width: 768px) {
  .page-header  { padding: 0 60px; }
  .page-stepper { padding: 16px 60px 0; }
  .page-top     { padding: 40px 60px 0; }
  .page-fields  { padding: 0 60px; margin: 24px 0 16px; gap: 14px; }
  .page-bottom  { padding: 8px 60px max(40px, env(safe-area-inset-bottom)); }
  .page-bottom--capture { padding-bottom: 45px; }
}

@media (min-width: 1024px) {
  .page-top     { padding: 40px 70px 0; }
  .page-fields  { padding: 0 70px; }
  .page-bottom  { padding: 8px 60px max(44px, env(safe-area-inset-bottom)); }
}

/* ----------------------------------------------------------------
   Layout helpers (kept for utility usage)
---------------------------------------------------------------- */
.stack > * + * { margin-top: var(--sp-4); }
.stack-sm > * + * { margin-top: var(--sp-2); }
.stack-lg > * + * { margin-top: var(--sp-6); }

.cluster {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-3);
  align-items: center;
}

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

@media (max-width: 540px) {
  .app-frame {
    border-left: 0;
    border-right: 0;
  }
}
