/* ==========================================================================
   Base — reset, typography, forms, focus
   ========================================================================== */

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

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

body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  color: var(--ink-1);
  background: var(--canvas);
  font-synthesis: none;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* Aurora wash — gives the dark canvas depth without costing contrast. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(
      900px 520px at 18% -8%,
      var(--aurora-1),
      transparent 62%
    ),
    radial-gradient(
      760px 440px at 92% 4%,
      var(--aurora-2),
      transparent 60%
    );
}

h1,
h2,
h3,
h4 {
  margin: 0;
  font-weight: 640;
  line-height: var(--leading-tight);
  letter-spacing: var(--tracking-tight);
  color: var(--ink-1);
}

/* Paper editorial: headlines and card titles wear the display serif;
   h4 stays the sans face for small uppercase section labels. */
h1,
h2,
h3 {
  font-family: var(--font-display);
  font-weight: 600;
}

h1 {
  font-size: var(--text-2xl);
  letter-spacing: var(--tracking-tighter);
}
h2 {
  font-size: var(--text-lg);
}
h3 {
  font-size: var(--text-base);
}

p {
  margin: 0 0 var(--s-3);
  color: var(--ink-2);
}
p:last-child {
  margin-bottom: 0;
}

small {
  font-size: var(--text-xs);
  color: var(--ink-3);
  line-height: var(--leading-snug);
}

strong {
  font-weight: 620;
  color: var(--ink-1);
}

a {
  color: var(--brand);
  text-decoration: none;
  text-underline-offset: 3px;
  transition: color var(--t-fast) var(--ease-out);
}
a:hover {
  color: var(--brand-hover);
  text-decoration: underline;
}

hr,
.divider {
  border: 0;
  border-top: 1px solid var(--line-1);
  margin: var(--s-4) 0;
  height: 0;
}

code,
pre,
.mono {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-variant-ligatures: none;
}

.code {
  display: block;
  margin: var(--s-3) 0 0;
  padding: var(--s-3) var(--s-4);
  background: var(--surface-inset);
  border: 1px solid var(--line-1);
  border-radius: var(--r-md);
  color: var(--ink-2);
  overflow: auto;
  max-height: 420px;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.6;
  scrollbar-width: thin;
}

/* --- icons --------------------------------------------------------------- */
/* Every icon gets a sane default size and never stretches; context rules
   below (buttons, nav, tiles) override it. Without this an icon dropped into
   a flex or grid child with no explicit sizing expands to fill it. */
.icon {
  width: 16px;
  height: 16px;
  flex: none;
  display: inline-block;
  vertical-align: -0.16em;
}

/* --- numerals ----------------------------------------------------------- */
.tnum,
td,
th,
.metric-value,
.stat-value {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}

/* Figures read as data: metric and stat values in the mono face. */
.metric-value,
.stat-value {
  font-family: var(--font-mono);
  letter-spacing: -0.01em;
}

/* --- forms -------------------------------------------------------------- */
button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button,
a,
summary,
label,
[role="tab"] {
  touch-action: manipulation;
}

input,
select,
textarea {
  width: 100%;
  padding: 0.5rem 0.7rem;
  background: var(--surface-3);
  border: 1px solid var(--line-1);
  border-radius: var(--r-sm);
  color: var(--ink-1);
  font-size: var(--text-sm);
  transition:
    border-color var(--t-fast) var(--ease-out),
    background var(--t-fast) var(--ease-out),
    box-shadow var(--t-fast) var(--ease-out);
}

input::placeholder,
textarea::placeholder {
  color: var(--ink-4);
}

input:hover,
select:hover,
textarea:hover {
  border-color: var(--line-2);
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--brand);
  background: var(--surface-2);
  box-shadow: 0 0 0 3px var(--brand-soft);
}

textarea {
  min-height: 84px;
  resize: vertical;
  line-height: var(--leading-normal);
}

select {
  appearance: none;
  padding-right: 2rem;
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%),
    linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position:
    calc(100% - 1rem) calc(50% + 1px),
    calc(100% - 0.7rem) calc(50% + 1px);
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  cursor: pointer;
}

input[type="checkbox"],
input[type="radio"] {
  width: 15px;
  height: 15px;
  padding: 0;
  margin: 0;
  flex: none;
  accent-color: var(--brand);
  cursor: pointer;
}

input[type="file"] {
  padding: var(--s-2);
  background: var(--surface-inset);
  cursor: pointer;
}

label {
  display: block;
  font-size: var(--text-xs);
  font-weight: 560;
  color: var(--ink-2);
  margin-bottom: var(--s-3);
}

label > input,
label > select,
label > textarea {
  margin-top: 0.3rem;
}

/* --- focus -------------------------------------------------------------- */
:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
  border-radius: var(--r-xs);
}
button:focus-visible,
a:focus-visible,
[role="tab"]:focus-visible {
  outline-offset: 3px;
}

.skip-link {
  position: fixed;
  top: var(--s-3);
  left: var(--s-3);
  z-index: 200;
  padding: var(--s-2) var(--s-4);
  background: var(--brand);
  color: var(--brand-ink);
  border-radius: var(--r-sm);
  font-weight: 600;
  transform: translateY(-200%);
  transition: transform var(--t-base) var(--ease-out);
}
.skip-link:focus {
  transform: none;
  text-decoration: none;
}

.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;
}

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

/* --- reduced motion ------------------------------------------------------ */
@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;
  }
}
