/* ---------------------------------------------------------------------------
   layout.css — the app frame, the screen scaffold and the safe-area plumbing.
   --------------------------------------------------------------------------- */

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--text-base);
  font-weight: 500;
  color: var(--ink);
  background: var(--cream);
  /* Scrolling happens inside a screen, never on the document: that keeps the
     bottom navigation pinned and stops rubber-banding the whole app. */
  overflow: hidden;
  overscroll-behavior: none;
}

.skip-link {
  position: fixed;
  top: calc(var(--safe-top) + 8px);
  left: 50%;
  transform: translate(-50%, -220%);
  z-index: 200;
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 20px;
  border-radius: var(--radius-pill);
  background: var(--moss-900);
  color: var(--cream-raised);
  font-weight: 700;
  text-decoration: none;
  transition: transform 180ms var(--ease-out);
}

.skip-link:focus-visible {
  transform: translate(-50%, 0);
}

.route-announcer {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* The router moves focus to each screen's heading so screen-reader and
   keyboard users land in the right place. The heading is not interactive, so
   it takes the focus silently rather than drawing a ring around a paragraph
   of text. Interactive controls keep their ring — see reset.css. */
[data-autofocus]:focus,
[data-autofocus]:focus-visible {
  outline: none;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* --- Device stage -------------------------------------------------------- */
/* On phones the shell fills the viewport. On tablet/desktop we show a single
   centred app surface rather than every screen at once. */

/* A *definite* height is what makes the internal flex chain resolve: without
   it the scroll area sizes to its content and the bottom navigation is pushed
   below the fold. */
.device-stage {
  height: 100vh;
  height: 100dvh;
  display: flex;
  justify-content: center;
  align-items: stretch;
  background: var(--cream);
}

.app-shell {
  position: relative;
  width: 100%;
  max-width: var(--app-max-width);
  height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--cream);
  isolation: isolate;
  overflow: hidden;
}

/* Warm ambient wash + grain, shared by every screen. */
.app-shell::before {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(120% 55% at 50% -8%, rgba(255, 252, 240, 0.95), rgba(255, 252, 240, 0) 62%),
    radial-gradient(80% 40% at 12% 8%, rgba(222, 208, 245, 0.32), rgba(222, 208, 245, 0) 70%),
    radial-gradient(90% 45% at 96% 22%, rgba(183, 201, 144, 0.26), rgba(183, 201, 144, 0) 70%);
}

.app-shell::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  background-image: var(--grain);
  background-size: var(--grain-size) var(--grain-size);
  opacity: 0.12;
  mix-blend-mode: multiply;
}

@media (min-width: 560px) and (min-height: 720px) {
  .device-stage {
    align-items: center;
    padding: 28px 20px;
    background:
      radial-gradient(100% 80% at 50% 0%, #fdf6e8, #f1e7d3 70%, #e9dcc4 100%);
  }

  .app-shell {
    height: min(920px, calc(100dvh - 56px));
    border-radius: 44px;
    box-shadow:
      0 40px 80px -30px rgba(58, 68, 44, 0.42),
      0 0 0 10px rgba(255, 255, 255, 0.55),
      0 0 0 11px rgba(41, 69, 44, 0.1);
  }
}

/* --- Screen host --------------------------------------------------------- */

.screen-host {
  position: relative;
  z-index: 2;
  flex: 1;
  display: flex;
  min-height: 0;
}

.screen {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  width: 100%;
}

/* The scrolling body of a screen. Padding accounts for notches and for the
   floating bottom navigation so nothing important hides under either. */
.screen__scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
  scrollbar-width: none;
  padding-inline: calc(var(--app-gutter) + var(--safe-left)) calc(var(--app-gutter) + var(--safe-right));
  padding-top: calc(var(--safe-top) + var(--space-3));
  padding-bottom: var(--space-5);
}

.screen__scroll::-webkit-scrollbar {
  display: none;
}

/* When a screen lays its scroll area out as a flex column, its blocks must
   never be squeezed below their content height — that silently clips text. */
.screen__scroll > * {
  flex-shrink: 0;
}

.screen--has-nav .screen__scroll {
  padding-bottom: calc(var(--nav-height) + var(--safe-bottom) + var(--space-6));
}

.screen--has-nav.screen--has-dock .screen__scroll {
  padding-bottom: calc(var(--nav-height) + var(--safe-bottom) + 96px);
}

.stack {
  display: flex;
  flex-direction: column;
}

.stack-2 > * + * {
  margin-top: var(--space-2);
}
.stack-3 > * + * {
  margin-top: var(--space-3);
}
.stack-4 > * + * {
  margin-top: var(--space-4);
}
.stack-5 > * + * {
  margin-top: var(--space-5);
}
.stack-6 > * + * {
  margin-top: var(--space-6);
}

.row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.row--between {
  justify-content: space-between;
}

.spacer {
  flex: 1;
}

/* Full-bleed inside a gutter-padded scroll area. */
.bleed {
  margin-inline: calc(-1 * var(--app-gutter));
  padding-inline: var(--app-gutter);
}

.noscript-note {
  padding: 48px 24px;
  text-align: center;
}
