/* base.css — reset, typography, layout primitives, utilities, reduced-motion rules */

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

* {
  margin: 0;
}

html {
  color-scheme: dark light;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
}

html[data-theme="light"] {
  color-scheme: light;
}

html[data-theme="dark"] {
  color-scheme: dark;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  background-color: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: var(--fs-2);
  line-height: var(--lh-base);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
  transition: background-color var(--d-base) var(--ease-out), color var(--d-base) var(--ease-out);
}

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

svg {
  fill: none;
}

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

button {
  cursor: pointer;
  border: 0;
  background: none;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

a {
  color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

ul,
ol {
  padding: 0;
  list-style: none;
}

/* ---- Typography ---- */
h1,
h2,
h3,
h4 {
  font-family: var(--font-mono);
  line-height: var(--lh-tight);
  font-weight: 700;
  letter-spacing: -0.01em;
  overflow-wrap: anywhere;
}

h1 {
  font-size: var(--fs-hero);
}

h2 {
  font-size: var(--fs-5);
}

h3 {
  font-size: var(--fs-4);
}

h4 {
  font-size: var(--fs-3);
}

p {
  overflow-wrap: anywhere;
}

.mono {
  font-family: var(--font-mono);
}

.muted {
  color: var(--muted);
}

.small {
  font-size: var(--fs-1);
}

.text-p1 {
  color: var(--p1);
}

.text-p2 {
  color: var(--p2);
}

.text-gradient {
  background: linear-gradient(90deg, var(--p1), var(--p2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* ---- Focus ---- */
:focus {
  outline: none;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--r-1);
}

/* ---- Layout primitives ---- */
.container {
  width: 100%;
  max-width: var(--container-max);
  margin-inline: auto;
  padding-inline: max(16px, env(safe-area-inset-left)) max(16px, env(safe-area-inset-right));
}

.stack {
  display: flex;
  flex-direction: column;
  gap: var(--s-4);
}

.cluster {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s-3);
}

.center {
  display: grid;
  place-items: center;
}

/* ---- Utilities ---- */
.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.no-select {
  user-select: none;
  -webkit-user-select: none;
}

[hidden] {
  display: none !important;
}

/* ---- Reduced motion ----
   Both the OS preference and the in-app override (html[data-motion="reduced"]) collapse
   every animation and transition to ~0, except for opacity fades marked with .allow-fade. */
@media (prefers-reduced-motion: reduce) {
  *:not(.allow-fade),
  *:not(.allow-fade)::before,
  *:not(.allow-fade)::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

html[data-motion="reduced"] *:not(.allow-fade),
html[data-motion="reduced"] *:not(.allow-fade)::before,
html[data-motion="reduced"] *:not(.allow-fade)::after {
  animation-duration: 0.001ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.001ms !important;
  scroll-behavior: auto !important;
}
