/* ==========================================================================
   Base — reset, typography, focus, motion preferences
   ========================================================================== */

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100dvh;
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: 1.55;
  color: var(--ink);
  background-color: var(--page);
  background-image:
    radial-gradient(1100px 620px at 12% -8%, var(--page-wash-1), transparent 62%),
    radial-gradient(900px 560px at 92% 4%, var(--page-wash-2), transparent 58%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

h1,
h2,
h3,
h4 {
  margin: 0;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.2;
  color: var(--ink);
}
h1 {
  font-size: var(--text-2xl);
}
h2 {
  font-size: var(--text-xl);
}
h3 {
  font-size: var(--text-lg);
}
h4 {
  font-size: var(--text-md);
}

p {
  margin: 0;
}

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

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

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

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

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

hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: var(--sp-5) 0;
}

/* ---- Focus ------------------------------------------------------------- */
:focus {
  outline: none;
}
:focus-visible {
  outline: 3px solid var(--accent-ring);
  outline-offset: 2px;
  border-radius: var(--r-xs);
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 200;
  padding: 12px 18px;
  background: var(--surface);
  color: var(--ink);
  border-radius: 0 0 var(--r-sm) 0;
  box-shadow: var(--shadow-md);
  font-weight: 700;
}
.skip-link:focus {
  left: 0;
}

/* ---- Utility ----------------------------------------------------------- */
.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;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
}
.row {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}
.row-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
}
.wrap {
  flex-wrap: wrap;
}
.grow {
  flex: 1 1 auto;
  min-width: 0;
}
.muted {
  color: var(--ink-2);
}
.dim {
  color: var(--ink-3);
}
.tiny {
  font-size: var(--text-xs);
}
.small {
  font-size: var(--text-sm);
}
.bold {
  font-weight: 700;
}
.center {
  text-align: center;
}
.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.nowrap {
  white-space: nowrap;
}
.mono {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}
.tnum {
  font-variant-numeric: tabular-nums;
}

/* ---- Boot splash ------------------------------------------------------- */
.boot {
  min-height: 100dvh;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: var(--sp-4);
  color: var(--ink-2);
}
.boot-mark {
  width: 56px;
  height: 56px;
  border-radius: var(--r-md);
  display: grid;
  place-items: center;
  font-weight: 900;
  font-size: 24px;
  color: var(--on-accent);
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  animation: boot-pulse 1.4s var(--ease) infinite;
}
@keyframes boot-pulse {
  0%,
  100% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(0.92);
    opacity: 0.7;
  }
}

/* ---- Animation primitives ---------------------------------------------- */
@keyframes fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}
@keyframes rise-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
@keyframes pop-in {
  from {
    opacity: 0;
    transform: scale(0.96) translateY(8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
@keyframes sheet-up {
  from {
    transform: translateY(100%);
  }
  to {
    transform: none;
  }
}
@keyframes shimmer {
  from {
    background-position: -320px 0;
  }
  to {
    background-position: 320px 0;
  }
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.anim-rise {
  animation: rise-in var(--dur-3) var(--ease-out) both;
}
.anim-fade {
  animation: fade-in var(--dur-2) var(--ease) both;
}

/* Respect the user's system setting and the in-app "reduce motion" switch. */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}
:root[data-reduced-motion] *,
:root[data-reduced-motion] *::before,
:root[data-reduced-motion] *::after {
  animation-duration: 0.001ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.001ms !important;
}

/* ---- Scrollbars -------------------------------------------------------- */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}
*::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
*::-webkit-scrollbar-thumb {
  background: var(--line-strong);
  border-radius: var(--r-pill);
  border: 3px solid transparent;
  background-clip: content-box;
}
*::-webkit-scrollbar-track {
  background: transparent;
}

::selection {
  background: var(--accent-soft);
  color: var(--ink);
}
