/* ================================================================
   Solo - Base Styles
   Reset, typography, layout primitives
   ================================================================ */

/* ── Reset ──────────────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
  touch-action: manipulation;
  /* Paint the html itself so iOS's rounded screen mask can't reveal a non-cream colour
     at the device corners or behind the status bar in standalone PWA mode. */
  background: var(--bg);
  /* Reserve scrollbar gutter on both sides so the page content stays centered.
     Falls back to no-op on browsers that don't support `both-edges`; the
     `padding-left` trick on body below picks up the slack on those. */
  scrollbar-gutter: stable both-edges;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  letter-spacing: -0.05px;
  min-height: 100vh;
  line-height: var(--leading-normal);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  overscroll-behavior-y: contain;
  -webkit-overflow-scrolling: touch;
  /* Clip (not hidden) horizontal overflow. `overflow-x: hidden` forces
     overflow-y to compute as `auto`, turning <body> into a momentum
     scroll container - and on iOS WebKit a `position: fixed` descendant
     of a touch-scroll container (here the bottom tab bar) detaches from
     the viewport and drifts into the middle of the page while scrolling.
     `clip` clips the same way (no horizontal scrollbar) but does NOT make
     <body> a scroll container, so overflow-y stays `visible`, the page
     scrolls on the viewport, and the fixed tab bar stays pinned. */
  overflow-x: hidden; /* fallback for pre-2022 engines without overflow:clip */
  overflow-x: clip;
  /* Scrollbar compensation: when a vertical scrollbar is present, body shrinks
     by the scrollbar's width on the right, leaving the layout off-centre. We
     mirror that gap on the left so cards/top-bar/tab-bar all read as
     symmetric to the eye. `100vw` is viewport including scrollbar; `100%` is
     body width excluding it; the difference is the scrollbar width.
     Browsers that already honoured `scrollbar-gutter: stable both-edges` on
     html will compute 0 here, so this is additive-safe. */
  padding-left: calc(100vw - 100%);
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

button, a, .tab-item, .bill-card, .quick-add-item, .provider-item, .chip, .freq-chip {
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

input, select, textarea {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}

img, svg { display: block; max-width: 100%; }
ul, ol { list-style: none; }
hr.divider { border: none; border-top: 1px solid var(--border); margin: 16px 0; }

/* ── Typography ─────────────────────────────────────────────── */
h1, h2, h3, h4 {
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: var(--leading-tight);
}

h1 { font-size: var(--text-2xl); }
h2 { font-size: var(--text-xl); }
h3 { font-size: var(--text-lg); font-weight: 600; }
h4 { font-size: var(--text-base); font-weight: 600; }

.green { color: var(--green) !important; }
.freq { font-size: .5em; font-weight: 400; color: var(--text-dim); }

/* ── App Shell ──────────────────────────────────────────────── */
.app-shell {
  min-height: 100vh;
  min-height: 100dvh;
  padding-bottom: calc(56px + 32px + var(--safe-bottom));
  display: flex;
  flex-direction: column;
}

.screen-content {
  flex: 1;
  width: 100%;
  max-width: var(--content-max-w);
  margin: 0 auto;
  padding: var(--content-pad);
  padding-top: var(--space-6);
}

/* ── Screen Transitions (one quiet 200ms fade between screens) ── */
.screen-content.transitioning {
  opacity: 0;
  transform: translateY(4px);
}

.screen-content.visible {
  opacity: 1;
  transform: translateY(0);
  transition: opacity 200ms ease-out,
              transform 200ms ease-out;
}

@media (prefers-reduced-motion: reduce) {
  .screen-content.transitioning { opacity: 1; transform: none; }
  .screen-content.visible { transition: none; }
}

/* ── Utility Classes ────────────────────────────────────────── */
.hidden { display: none !important; }
.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0, 0, 0, 0); border: 0;
}

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.gap-1 { gap: var(--space-1); }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.gap-6 { gap: var(--space-6); }

.mt-2 { margin-top: var(--space-2); }
.mt-4 { margin-top: var(--space-4); }
.mt-6 { margin-top: var(--space-6); }
.mt-8 { margin-top: var(--space-8); }
.mb-2 { margin-bottom: var(--space-2); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-6 { margin-bottom: var(--space-6); }

.w-full { width: 100%; }
.text-center { text-align: center; }
.text-dim { color: var(--text-dim); }
.text-muted { color: var(--text-muted); }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }

/* ── Scrollbar (subtle) ─────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-light); }
