/* Base layer: reset, cross-browser fixes, layout helpers, motion.
   Site-specific tokens and sections live in index.html <style>. */

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  scroll-behavior: smooth;
  scrollbar-gutter: stable;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  font-family: var(--font-body, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif);
  font-size: var(--text-base, 1.0625rem);
  line-height: 1.6;
  color: var(--fg, #1c1b1a);
  background: var(--bg, #faf9f7);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-x: clip;
}

@supports not (overflow-x: clip) {
  body { overflow-x: hidden; }
}

img, picture, video, svg { display: block; max-width: 100%; height: auto; }
img { object-fit: cover; }
input, button, textarea, select { font: inherit; color: inherit; }
input, textarea, select { font-size: max(16px, 1em); } /* stops iOS zoom on focus */
button { cursor: pointer; background: none; border: 0; }
a { color: inherit; text-decoration-thickness: 1px; text-underline-offset: 0.2em; }
h1, h2, h3, h4 { font-family: var(--font-display, inherit); line-height: 1.1; text-wrap: balance; overflow-wrap: break-word; }
p { text-wrap: pretty; overflow-wrap: break-word; }

:focus-visible { outline: 2px solid var(--accent, currentColor); outline-offset: 3px; }

/* Layout helpers */
.container {
  width: min(100% - 2 * var(--gutter, 1.25rem), var(--max-w, 72rem));
  margin-inline: auto;
}
.section { padding-block: var(--section-y, clamp(4rem, 9vw, 8rem)); }
.stack > * + * { margin-top: var(--stack, 1rem); }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* iPhone notch / home bar */
.safe-x { padding-left: max(var(--gutter, 1.25rem), env(safe-area-inset-left)); padding-right: max(var(--gutter, 1.25rem), env(safe-area-inset-right)); }
.safe-bottom { padding-bottom: max(1rem, env(safe-area-inset-bottom)); }

/* Tap targets */
.btn, .nav-toggle { min-height: 44px; min-width: 44px; display: inline-flex; align-items: center; justify-content: center; }

/* Frosted surfaces need the prefix for Safari */
.frost { -webkit-backdrop-filter: blur(14px) saturate(140%); backdrop-filter: blur(14px) saturate(140%); }

/* Mobile nav: site.js toggles .nav-open on <body>.
   The header must be positioned (sticky or relative) so the panel drops below it.
   Desktop nav styles go in @media (min-width: 768px) to match this breakpoint. */
.nav-toggle { display: none; background: none; border: 1px solid var(--line, #ddd); border-radius: 10px; color: var(--fg, #222); font-size: 1.4rem; cursor: pointer; }
@media (max-width: 767px) {
  .nav-toggle { display: inline-flex; }
  .nav-links { display: none; }
  .nav-open .nav-links { display: flex; position: absolute; top: 100%; left: 0; right: 0; z-index: 50; flex-direction: column; align-items: stretch; gap: 0; padding: 0.5rem var(--gutter, 1.25rem) 1.25rem; background: var(--bg, #fff); border-bottom: 1px solid var(--line, #ddd); box-shadow: 0 16px 30px rgba(0, 0, 0, 0.08); }
  .nav-links a:not(.btn) { display: flex; align-items: center; min-height: 48px; font-size: 1.1rem; border-bottom: 1px solid var(--line, #ddd); text-decoration: none; }
  .nav-links .btn { margin-top: 1rem; justify-content: center; }
}

/* Hover effects only on devices that hover (stops sticky hover on touch) */
@media (hover: hover) {
  .lift { transition: transform .25s ease, box-shadow .25s ease; }
  .lift:hover { transform: translateY(-3px); }
}
a, .btn { transition: color .2s ease, background-color .2s ease, border-color .2s ease, opacity .2s ease; }

/* Reveal on scroll: content visible by default, hidden only once JS confirms support */
.js .reveal { opacity: 0; transform: translateY(16px); transition: opacity .6s ease, transform .6s ease; }
.js .reveal.in { opacity: 1; transform: none; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
  .js .reveal { opacity: 1; transform: none; }
}

@media print {
  .js .reveal { opacity: 1 !important; transform: none !important; }
  .nav-toggle { display: none !important; }
}
