/* ==========================================================================
   NZOTO — base
   Purpose : reset, document defaults, typography, focus, icons, boot/enter
             states and CMS prose. No component classes live here.
   Depends : tokens.css
   ========================================================================== */

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

html {
  font-size: 100%;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--topbar-height) + var(--space-4));
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: var(--font-sans);
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-regular);
  line-height: var(--line-height-normal);
  color: var(--color-text);
  background: var(--color-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

/* Boot: nothing paints until the guard has passed and the layout is mounted,
   so protected content never flashes. app.js removes .is-booting (with a
   fail-safe timeout) and adds .is-ready to run the enter transition. */
html.is-booting body { visibility: hidden; }
html.is-ready main { animation: page-enter var(--duration-slow) var(--ease-out) both; }

@keyframes page-enter {
  from { opacity: 0; transform: translateY(var(--enter-offset)); }
  to { opacity: 1; transform: none; }
}

h1, h2, h3, h4, h5, h6 {
  margin: 0;
  color: var(--color-heading);
  font-weight: var(--font-weight-semibold);
  line-height: var(--line-height-snug);
  letter-spacing: var(--letter-spacing-tight);
  text-wrap: balance;
}
h1 { font-size: var(--font-size-2xl); }
h2 { font-size: var(--font-size-xl); }
h3 { font-size: var(--font-size-lg); }
h4 { font-size: var(--font-size-md); }
h5, h6 { font-size: var(--font-size-base); }

p { margin: 0; text-wrap: pretty; }
ul, ol { margin: 0; padding: 0; list-style: none; }
dl, dd { margin: 0; }
figure { margin: 0; }
img, svg, video, canvas { display: block; max-width: 100%; }
img { height: auto; }
hr { border: 0; border-top: var(--border-width) solid var(--color-border); margin: var(--space-6) 0; }
small { font-size: var(--font-size-xs); }
strong, b { font-weight: var(--font-weight-semibold); }
address { font-style: normal; }
table { border-collapse: collapse; width: 100%; }
th { text-align: left; font-weight: var(--font-weight-medium); }

a {
  color: var(--color-link);
  text-decoration: none;
  text-underline-offset: 0.2em;
  transition: color var(--duration-fast) var(--ease-out);
}
a:hover { text-decoration: underline; }

button, input, select, textarea { font: inherit; color: inherit; margin: 0; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
button:disabled, [aria-disabled="true"] { cursor: not-allowed; }
textarea { resize: vertical; }
fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
legend { padding: 0; }
summary { cursor: pointer; }
[hidden] { display: none !important; }

::selection { background: color-mix(in srgb, var(--brand-accent) 28%, transparent); }
::placeholder { color: var(--color-text-muted); opacity: 1; }

/* Focus — always visible for keyboard users, never for mouse clicks */
:focus { outline: none; }
:focus-visible {
  outline: var(--border-width-thick) solid var(--color-accent);
  outline-offset: var(--ring-offset);
  border-radius: var(--radius-xs);
}

/* Icons — one stroke set, sized and coloured by the parent */
.icon {
  width: var(--icon-md);
  height: var(--icon-md);
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: var(--icon-stroke);
  stroke-linecap: round;
  stroke-linejoin: round;
}
.icon--xs { width: var(--icon-xs); height: var(--icon-xs); }
.icon--sm { width: var(--icon-sm); height: var(--icon-sm); }
.icon--lg { width: var(--icon-lg); height: var(--icon-lg); }
.icon--xl { width: var(--icon-xl); height: var(--icon-xl); }
.icon--2xl { width: var(--icon-2xl); height: var(--icon-2xl); }
.icon--filled { fill: currentColor; }
.icon--spin { animation: spin var(--duration-counter) linear infinite; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop-in { from { opacity: 0; transform: translateY(var(--enter-offset)) scale(0.98); } to { opacity: 1; transform: none; } }
@keyframes slide-up { from { opacity: 0; transform: translateY(100%); } to { opacity: 1; transform: none; } }
@keyframes slide-in-left { from { transform: translateX(-100%); } to { transform: none; } }
@keyframes toast-in { from { opacity: 0; transform: translateY(var(--space-4)) scale(0.96); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateY(var(--space-2)) scale(0.96); } }
@keyframes pulse-ring { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--color-success) 45%, transparent); } 100% { box-shadow: 0 0 0 var(--space-2) transparent; } }

/* Skip link */
.skip-link {
  position: absolute;
  left: var(--space-4);
  top: var(--space-4);
  z-index: var(--z-palette);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-md);
  background: var(--color-primary);
  color: var(--color-on-primary);
  font-weight: var(--font-weight-medium);
  transform: translateY(-200%);
  transition: transform var(--duration-fast) var(--ease-out);
}
.skip-link:focus-visible { transform: none; text-decoration: none; }

/* Prose — admin-edited CMS content (About, Terms, …) */
.prose { max-width: var(--measure); color: var(--color-text-secondary); font-size: var(--font-size-md); line-height: var(--line-height-relaxed); }
.prose > * + * { margin-top: var(--space-4); }
.prose h2 { margin-top: var(--space-10); font-size: var(--font-size-xl); }
.prose h3 { margin-top: var(--space-8); font-size: var(--font-size-lg); }
.prose ul, .prose ol { padding-left: var(--space-6); }
.prose ul { list-style: disc; }
.prose ol { list-style: decimal; }
.prose li + li { margin-top: var(--space-2); }
.prose li::marker { color: var(--color-accent); }
.prose a { text-decoration: underline; }
.prose strong { color: var(--color-text); }
.prose blockquote {
  margin: 0;
  padding: var(--space-4) var(--space-6);
  border-radius: var(--radius-lg);
  background: var(--color-bg-muted);
  color: var(--color-text);
}

/* Thin, unobtrusive scrollbars inside scroll containers */
.scroll-area { scrollbar-width: thin; scrollbar-color: var(--color-border-strong) transparent; }

@media print {
  body { background: var(--neutral-0); color: var(--neutral-950); }
  [data-no-print], .devbar, .sidebar, .topbar, .bottom-nav, .site-header, .site-footer, .toast-region { display: none !important; }
}
