/* ============================================================
   Base styles: reset, defaults, typography baseline.
   Loads after tokens.css.
   ============================================================ */

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

/* Ensure [hidden] always wins — CSS classes can override UA stylesheet otherwise */
[hidden] { display: none !important; }

html, body, h1, h2, h3, h4, h5, h6, p, ul, ol, li, figure, blockquote {
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  scroll-behavior: smooth;
  text-rendering: optimizeLegibility;
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  font-family: var(--font-body);
  font-weight: var(--fw-regular);
  font-size: var(--fs-base);
  line-height: var(--lh-normal);
  color: var(--c-text);
  background: var(--c-bg);
  display: flex;
  flex-direction: column;
}

img, picture, video, canvas, svg { display: block; max-width: 100%; height: auto; }

input, button, textarea, select { font: inherit; color: inherit; }

button { background: none; border: 0; cursor: pointer; padding: 0; }

a { color: var(--c-text); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }

ul, ol { list-style: none; }

/* ----- Headings ----- */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  font-weight: var(--fw-bold);
  line-height: var(--lh-tight);
  letter-spacing: var(--ls-tight);
  color: var(--c-text);
}
h1 { font-size: var(--fs-3xl); }
h2 { font-size: var(--fs-2xl); }
h3 { font-size: var(--fs-xl); }
h4 { font-size: var(--fs-lg); }
h5 { font-size: var(--fs-md); }
h6 { font-size: var(--fs-base); }

/* ----- Paragraphs / inline ----- */
p { line-height: var(--lh-normal); }
small { font-size: var(--fs-sm); color: var(--c-text-muted); }
strong, b { font-weight: var(--fw-bold); }
em, i { font-style: italic; }

/* ----- Focus visible ----- */
:focus { outline: none; }
:focus-visible {
  outline: 2px solid var(--c-primary-strong);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

/* ----- Selection ----- */
::selection {
  background: var(--c-primary);
  color: var(--c-text-on-primary);
}

/* ----- Scrollbar (subtle, warm) ----- */
* { scrollbar-width: thin; scrollbar-color: var(--c-border-strong) transparent; }
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: var(--c-border-strong); border-radius: var(--r-pill); }
*::-webkit-scrollbar-thumb:hover { background: var(--c-text-soft); }

/* ----- Layout helpers ----- */
.container {
  width: 100%;
  max-width: var(--container-xl);
  margin-inline: auto;
  padding-inline: var(--sp-4);
}
@media (min-width: 768px) {
  .container { padding-inline: var(--sp-6); }
}

.app-shell {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}
.app-main {
  flex: 1 0 auto;
  padding-block: var(--sp-5);
}
.app-main--with-tabbar { padding-bottom: calc(var(--tabbar-h) + var(--sp-5)); }
@media (min-width: 768px) {
  .app-main--with-tabbar { padding-bottom: var(--sp-5); }
}

/* ----- Visually hidden (accessible) ----- */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

/* ----- Skeleton loading ----- */
.skeleton {
  background: linear-gradient(
    90deg,
    var(--c-surface-2) 0%,
    var(--c-border) 50%,
    var(--c-surface-2) 100%
  );
  background-size: 200% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
  border-radius: var(--r-md);
  display: block;
}
@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ----- Page-loading bar (top of page) ----- */
.page-progress {
  position: fixed;
  top: 0; left: 0;
  height: 3px; width: 0%;
  background: linear-gradient(90deg, var(--c-primary-strong), var(--c-secondary-strong));
  z-index: var(--z-toast);
  transition: width var(--t-base) var(--ease-out), opacity var(--t-fast) var(--ease-out);
  pointer-events: none;
}
.page-progress.is-visible { opacity: 1; }
.page-progress.is-done { width: 100% !important; opacity: 0; }
