/* ============================================================
   Base layout — mobile-first, centred on desktop
   ============================================================ */

/* Global web fonts.
   tokens.css --font-sans was previously -apple-system only, which
   fell back to Helvetica/Arial/Segoe on non-Apple browsers and made
   the whole app read Word-ish. Load DM Sans for UI and Fraunces for
   display so every screen — calendar cards, invoice, totals — renders
   with the intended Bullet type system regardless of OS. */
@import url('https://fonts.googleapis.com/css2?family=Manrope:wght@400;500;600;700;800&family=Fraunces:opsz,wght,SOFT,WONK@9..144,100..900,0..100,0..1&display=swap');

html, body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: var(--fs-md);
  line-height: 1.45;
  letter-spacing: -0.005em;
}

body {
  /* dvh recalculates as Safari/Chrome's URL bar collapses — svh is the
     "always-small" fallback that assumes chrome is visible. dvh feels
     more native because the viewport grows when the browser chrome slides
     away. Fallback to svh for older browsers. */
  min-height: 100svh;
  min-height: 100dvh;
  display: flex;
  justify-content: center;
  /* On desktop the .app is capped at 932px tall (see below) — centre it
     vertically in the viewport so the cap reads as a phone-frame, not
     a top-aligned column.
     `safe` is critical: when the .app is TALLER than the viewport (short
     mobile Safari with the address bar showing), plain `center` overflows
     equally top AND bottom — but the page only scrolls down, so the top
     (the headline) is clipped and unreachable. `safe center` falls back to
     start-alignment whenever the content overflows, so the headline is
     never cut off and the page scrolls normally from the top. */
  align-items: safe center;
}

.app {
  width: 100%;
  max-width: var(--app-max);
  min-height: 100svh;
  min-height: 100dvh;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  position: relative;
  /* Confetti spans drift ±220px from their start, which can extend past
     the viewport edge and create a horizontal scrollbar. Clip horizontally
     at the .app boundary so nothing forces a sideways scroll. */
  overflow-x: hidden;
  /* Bottom safe-area is handled by the fixed .cta-area itself — removing
     it here prevents double padding on pages with a CTA. */
  padding: env(safe-area-inset-top) 0 0 0;
}

/* ---- Header (back + progress) ---- */
.top {
  padding: 16px var(--gutter) 8px;
  display: flex;
  align-items: center;
  gap: 14px;
}

.top__back {
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  border-radius: 50%;
  background: var(--surface);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--ink);
  transition: background var(--dur-fast) var(--ease-out);
}
.top__back:active { background: var(--hairline); }
.top__back svg { width: 18px; height: 18px; stroke-width: 2.2; }

.top__back--hidden { visibility: hidden; }

.top__login {
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--ink-muted);
  padding: 8px 4px;
}
.top__login:active { color: var(--ink); }

.progress {
  flex: 1;
  height: 4px;
  background: var(--hairline);
  border-radius: var(--r-pill);
  overflow: hidden;
}
.progress__fill {
  height: 100%;
  background: var(--accent);
  border-radius: var(--r-pill);
  width: 0%;
  transition: width var(--dur-slow) var(--ease-out);
}

/* ---- Main content ---- */
.screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  /* Extra bottom padding clears the fixed .cta-area so the last content
     element isn't hidden behind it. Roughly: button (52) + cta top pad
     (12) + cta bottom pad (20) + breathing room. Screen-specific layouts
     (e.g. .screen--splash) override this. */
  /* 32px top to match the v7.css interior screens (.app padding-top: 32px) —
     the image-led base screens were 24px, so their headline sat higher. */
  padding: 32px var(--gutter) calc(110px + env(safe-area-inset-bottom));
}

/* ---- Typography ---- */
.h1 {
  font-family: var(--font-display);
  font-size: var(--fs-3xl);
  line-height: 1.1;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--ink);
}
.h1--tight { font-size: var(--fs-2xl); }
.h1--big   { font-size: var(--fs-4xl); }

.h2 {
  font-family: var(--font-display);
  font-size: var(--fs-xl);
  line-height: 1.2;
  font-weight: 700;
  letter-spacing: -0.015em;
  color: var(--ink);
}

.subline {
  font-size: var(--fs-md);
  line-height: 1.45;
  color: var(--ink-muted);
  margin-top: 10px;
}

.eyebrow {
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-muted);
  font-weight: 600;
}

/* Yellow-marker highlight: dark text, yellow wash behind */
.highlight {
  color: var(--ink);
  font-weight: 700;
  background: linear-gradient(180deg, transparent 55%, var(--accent) 55%, var(--accent) 92%, transparent 92%);
  padding: 0 2px;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}

/* ---- CTA area ----
   Pinned to the bottom of the app column (fixed) so it's always visible
   regardless of browser chrome height or page length — Cal AI pattern.
   Centred to match the .app column's max-width. */
.cta-area {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: 100%;
  max-width: var(--app-max);
  padding: 12px var(--gutter) calc(var(--cta-pad) + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--bg);
  z-index: 10;
}

.cta-area--gradient {
  /* Fade content out behind the CTA instead of a hard edge. */
  background: linear-gradient(to top, var(--bg) 70%, rgba(255,255,255,0));
  padding-top: 32px;
  /* The fade zone is visual only — don't eat taps on content behind it
     (pills, cards). The button inside re-enables pointer-events below. */
  pointer-events: none;
}
.cta-area--gradient > * {
  pointer-events: auto;
}

/* Reveal-on-selection variant (multi-select questionnaires).
   Hidden by default, slides up + fades in when JS adds `is-revealed`. The
   gradient fade zone and button itself translate together so the whole strip
   feels like one element rising from the bottom. */
.cta-area--reveal {
  transform: translateX(-50%) translateY(18px);
  opacity: 0;
  transition:
    transform 320ms cubic-bezier(0.2, 0.8, 0.2, 1),
    opacity 240ms ease-out;
  pointer-events: none;
}
.cta-area--reveal > * {
  /* Disable the button until the area is revealed so keyboard focus can't
     land on it in its hidden state. */
  pointer-events: none;
}
.cta-area--reveal.is-revealed {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
  pointer-events: none; /* container stays click-through; button re-enables below */
}
.cta-area--reveal.is-revealed > * {
  pointer-events: auto;
}
@media (prefers-reduced-motion: reduce) {
  .cta-area--reveal { transition: opacity 160ms ease-out; transform: translateX(-50%); }
  .cta-area--reveal.is-revealed { transform: translateX(-50%); }
}

/* ---- Desktop phone-frame cap ----
   Placed AFTER all .cta-area* rules so its overrides win in the cascade
   without needing !important. Caps the .app at 932px (iPhone 14 Pro Max),
   centres it in the viewport (body has `align-items: center`), and pins
   the CTA strip inside the frame instead of the viewport. */
@media (min-width: 431px) {
  .app {
    min-height: 0;
    height: 932px;
    max-height: calc(100dvh - 48px);
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.08);
  }
  /* Wave footer pinned to this (non-scrolling) frame's bottom and cropped by it,
     instead of the injected waves detaching to the browser bottom. .app is
     position:relative, so absolute bottom:0 lands at the frame's bottom edge. */
  .bg-waves {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
  }
  .cta-area,
  .cta-area--reveal,
  .cta-area--reveal.is-revealed {
    position: absolute;
    left: 0;
    right: 0;
    width: auto;
    max-width: none;
  }
  /* Reveal animation on desktop — translateY only, no horizontal shift
     because the strip is already pinned full-width by left:0/right:0. */
  .cta-area--reveal { transform: translateY(18px); }
  .cta-area--reveal.is-revealed { transform: translateY(0); }
  .cta-area:not(.cta-area--reveal) { transform: none; }
}

/* ---- Logo stack (wordmark + 'your accountant' tag) ---- */
.wordmark {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.wordmark__logo {
  height: 32px;
  width: auto;
}
.wordmark__tag {
  font-size: 11px;
  font-weight: 500;
  color: var(--ink-muted);
  letter-spacing: 0.02em;
}
.wordmark__tag strong {
  color: var(--ink);
  font-weight: 600;
}

/* Small inline wordmark for top bar */
.brand-inline {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.brand-inline__logo { height: 20px; }
.brand-inline__tag {
  font-size: 11px;
  color: var(--ink-muted);
}

/* ---- Spacer helper ---- */
.spacer { flex: 1; }
.gap-8 { height: 8px; } .gap-12 { height: 12px; } .gap-16 { height: 16px; }
.gap-20 { height: 20px; } .gap-24 { height: 24px; } .gap-32 { height: 32px; } .gap-40 { height: 40px; }
