/* ==========================================================================
   Base — reset, the no-scroll page shell, type utilities, a11y helpers,
   page transitions.
   ========================================================================== */

*, *::before, *::after { box-sizing: border-box; }

html, body { height: 100%; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;   /* no grey/blue flash when tapping buttons and links on phones */
  overflow: hidden;
  overscroll-behavior: none;   /* no rubber-band bounce on the page (macOS trackpads, iOS) */
}

body {
  margin: 0;
  font-family: var(--font-family);
  font-weight: var(--font-weight);
  font-style: normal;
  font-synthesis: none;              /* never fake bold/italic */
  font-variant-numeric: normal;
  font-size: var(--type-body-size);
  line-height: var(--type-body-lh);
  letter-spacing: var(--type-body-ls);
  color: var(--color-text-secondary);
  background: var(--color-surface);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  /* The page itself never scrolls — panels scroll internally. */
  overflow: hidden;
  overscroll-behavior: none;
}

h1, h2, h3, p, ul, ol, dl, dd, figure { margin: 0; padding: 0; }
ul, ol { list-style: none; }
h1, h2, h3 { font-weight: inherit; font-size: inherit; line-height: inherit; }
dt, dd { margin: 0; }
img, video, svg { display: block; max-width: 100%; }
/* Every element uses the site font (SF Pro) — form controls don't inherit fonts by default */
button, input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
a { color: inherit; text-decoration: none; }

/* Full-viewport shell. dvh keeps mobile browser chrome from causing a scroll. */
.page {
  position: relative;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* Scrollable component frames */
/* scroll only when the content actually overflows, and never rubber-band */
.scroll-y {
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: none;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.scroll-x {
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior: none;
  scrollbar-width: none;
}
.scroll-y::-webkit-scrollbar, .scroll-x::-webkit-scrollbar { display: none; }

/* ---- Type utilities (map 1:1 to Figma text styles) ----------------------- */
.t-headline {
  font-size: var(--type-headline-size);
  line-height: var(--type-headline-lh);
  letter-spacing: var(--type-headline-ls);
  color: var(--color-text-primary);
}
.t-body { font-size: var(--type-body-size); line-height: var(--type-body-lh); letter-spacing: var(--type-body-ls); }
.t-label { color: var(--color-text-primary); }
.t-muted { color: var(--color-text-secondary); }

/* ---- Accessibility ------------------------------------------------------- */
.visually-hidden {
  position: absolute !important;
  width: 0.1rem; height: 0.1rem;
  margin: -0.1rem; padding: 0; border: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.skip-link {
  position: absolute;
  top: 0.8rem; left: 0.8rem;
  z-index: 100;
  padding: var(--button-pad);
  border-radius: var(--radius-button);
  background: var(--color-surface);
  color: var(--color-text-primary);
  transform: translateY(-150%);
  transition: transform var(--dur-fast) var(--ease-out);
}
.skip-link:focus { transform: none; }

:focus { outline: none; }
:focus-visible {
  outline: 0.15rem solid var(--color-focus);
  outline-offset: 0.2rem;
}

/* ---- Theme switch: brief color crossfade while toggling ------------------- */
.theme-changing *, .theme-changing *::before, .theme-changing *::after {
  transition: background-color 600ms var(--ease-out), color 600ms var(--ease-out),
              border-color 600ms var(--ease-out), stroke 600ms var(--ease-out) !important;
}

/* ---- Media fade-in (Porto Rocha–style soft load) -------------------------- */
.media-fade { opacity: 0; transition: opacity var(--dur-slow) var(--ease-out); }
.media-fade.is-loaded { opacity: 1; }

/* ---- Page transitions ----------------------------------------------------
   A slow fade through white on every page change, in every browser.
   app.js adds .is-leaving before following an internal link. */
.page { animation: page-fade-in var(--dur-page) var(--ease-out) both; }
.page.is-leaving {
  opacity: 0;
  transition: opacity calc(var(--dur-page) * 0.6) var(--ease-in-out);
  pointer-events: none;
}
@keyframes page-fade-in { from { opacity: 0; } }

/* ---- Reduced motion ------------------------------------------------------ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 1ms !important;
    animation-delay: 0ms !important;
    transition-duration: 1ms !important;
    transition-delay: 0ms !important;
  }
}
