/* ==========================================================================
   TATTOUH — reset, base typography, layout primitives, utilities
   ========================================================================== */

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

* {
  margin: 0;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--nav-h) + 1.5rem);
}

body {
  min-height: 100dvh;
  font-family: var(--font-body);
  font-size: var(--fs-body);
  font-weight: var(--fw-body);
  line-height: var(--lh-body);
  letter-spacing: var(--ls-normal);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  font-feature-settings: 'cv02', 'cv03', 'cv04', 'ss01';
  overflow-x: hidden;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}

/* Ambient page backdrop: a faint technical grid plus two soft aurora washes.
   Fixed and inert so it never affects layout or interaction. */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image: linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: 64px 64px;
  mask-image: radial-gradient(ellipse 100% 60% at 50% 0%, #000 30%, transparent 75%);
  -webkit-mask-image: radial-gradient(ellipse 100% 60% at 50% 0%, #000 30%, transparent 75%);
}

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

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

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

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

a {
  color: var(--primary);
  text-decoration: none;
  text-underline-offset: 0.22em;
  transition: color var(--dur-fast) var(--ease);
}

a:hover {
  color: var(--primary-hover);
}

hr {
  border: 0;
  border-top: 1px solid var(--rule);
}

::selection {
  background: var(--primary);
  color: var(--text-on-primary);
}

:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 3px;
  border-radius: var(--r-xs);
}

/* Scrollbar, dark and light aware */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}
*::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
*::-webkit-scrollbar-track {
  background: transparent;
}
*::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: var(--r-pill);
  border: 2px solid var(--bg);
}
*::-webkit-scrollbar-thumb:hover {
  background: var(--text-dim);
}

/* --------------------------------------------------------------------------
   Headings
   -------------------------------------------------------------------------- */

h1,
h2,
h3,
h4,
h5,
h6 {
  font-family: var(--font-display);
  font-weight: var(--fw-bold);
  line-height: var(--lh-heading);
  letter-spacing: var(--ls-tight);
  color: var(--text-strong);
  text-wrap: balance;
}

.t-display-xl {
  font-size: var(--fs-display-xl);
  font-weight: var(--fw-black);
  line-height: var(--lh-tight);
  letter-spacing: var(--ls-tighter);
}
.t-display {
  font-size: var(--fs-display);
  font-weight: var(--fw-black);
  line-height: var(--lh-tight);
  letter-spacing: var(--ls-tighter);
}
.t-h1 {
  font-size: var(--fs-h1);
  font-weight: var(--fw-bold);
}
.t-h2 {
  font-size: var(--fs-h2);
  font-weight: var(--fw-bold);
}
.t-h3 {
  font-size: var(--fs-h3);
  font-weight: var(--fw-semi);
}
.t-h4 {
  font-size: var(--fs-h4);
  font-weight: var(--fw-semi);
  letter-spacing: var(--ls-normal);
}

.t-lead {
  font-size: var(--fs-lead);
  line-height: var(--lh-snug);
  color: var(--text-muted);
  text-wrap: pretty;
}

.t-body {
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  color: var(--text-muted);
  text-wrap: pretty;
}

.t-sm {
  font-size: var(--fs-sm);
  line-height: var(--lh-snug);
  color: var(--text-muted);
}

.t-mono {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  letter-spacing: var(--ls-wide);
  font-variant-numeric: tabular-nums;
}

.t-strong {
  color: var(--text-strong);
}
.t-muted {
  color: var(--text-muted);
}
.t-dim {
  color: var(--text-dim);
}
.t-primary {
  color: var(--primary);
}
.t-accent {
  color: var(--accent);
}

/* Gradient headline treatment, used sparingly on hero words. */
.t-gradient {
  background: linear-gradient(105deg, var(--primary) 0%, var(--primary-deep) 55%, var(--accent) 130%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  /* Descenders get clipped without this on some engines. */
  padding-bottom: 0.08em;
}

.measure {
  max-width: 64ch;
}
.measure-sm {
  max-width: 52ch;
}
.measure-lg {
  max-width: 74ch;
}

/* --------------------------------------------------------------------------
   Layout
   -------------------------------------------------------------------------- */

.container {
  width: 100%;
  max-width: var(--container);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.container-wide {
  width: 100%;
  max-width: var(--container-wide);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.container-narrow {
  width: 100%;
  max-width: var(--container-narrow);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.section {
  position: relative;
  z-index: var(--z-base);
  padding-block: var(--section-y);
}

.section-sm {
  position: relative;
  z-index: var(--z-base);
  padding-block: var(--section-y-sm);
}

/* For the first section after a page hero. The hero already supplies its own
   bottom padding, so a full --section-y on top would double up; but zeroing it
   (as this used to do inline) left the content visibly squeezed against the
   hero compared with every other section boundary on the site. */
.section-after-hero {
  position: relative;
  z-index: var(--z-base);
  padding-top: var(--section-y-sm);
  padding-bottom: var(--section-y);
}

.section-tint {
  background: var(--bg-deep);
}

/* A hairline that fades out at both ends, used between major blocks. */
.rule-fade {
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--border-strong) 22%, var(--border-strong) 78%, transparent);
}

.grid {
  display: grid;
  gap: var(--sp-5);
}
.grid-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.grid-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.grid-4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

/* Auto-fit grids so wide and ultrawide screens fill rows instead of stretching
   a fixed column count into over-wide cards. */
.grid-auto {
  grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr));
}
.grid-auto-sm {
  grid-template-columns: repeat(auto-fit, minmax(min(240px, 100%), 1fr));
}
.grid-auto-lg {
  grid-template-columns: repeat(auto-fit, minmax(min(380px, 100%), 1fr));
}

.split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: clamp(2rem, 1rem + 4vw, 5rem);
  align-items: center;
}

.split-lead {
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr);
}

.stack {
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
}
/* Self-sufficient rather than modifiers on .stack. They read as standalone
   utilities and were used that way at every call site, where a bare gap on a
   block container does nothing at all. */
.stack-lg,
.stack-xl {
  display: flex;
  flex-direction: column;
}
.stack-lg {
  gap: var(--sp-6);
}
.stack-xl {
  gap: var(--sp-8);
}

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

.center {
  text-align: center;
  margin-inline: auto;
}

.sticky-aside {
  position: sticky;
  top: calc(var(--nav-h) + 2rem);
}

/* --------------------------------------------------------------------------
   Utilities
   -------------------------------------------------------------------------- */

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

.skip-link {
  position: absolute;
  top: -100px;
  left: var(--sp-4);
  z-index: var(--z-toast);
  padding: var(--sp-3) var(--sp-5);
  border-radius: var(--r-sm);
  background: var(--primary);
  color: var(--text-on-primary);
  font-weight: var(--fw-semi);
  transition: top var(--dur-fast) var(--ease);
}
.skip-link:focus {
  top: var(--sp-4);
  color: var(--text-on-primary);
}

.no-scroll {
  overflow: hidden;
}

/* --------------------------------------------------------------------------
   Responsive — mobile, tablet, wide, ultrawide
   -------------------------------------------------------------------------- */

/* Ultrawide: hold the content column, let the gutters grow. */
@media (min-width: 1800px) {
  :root {
    --container: 1360px;
    --container-wide: 1660px;
  }
}

@media (min-width: 2400px) {
  :root {
    --container: 1480px;
    --container-wide: 1840px;
  }
  body {
    font-size: 1.125rem;
  }
}

/* Tablet */
@media (max-width: 1024px) {
  .grid-4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .split-lead {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }
}

@media (max-width: 900px) {
  .grid-3 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .split,
  .split-lead {
    grid-template-columns: minmax(0, 1fr);
    gap: var(--sp-7);
  }
  .sticky-aside {
    position: static;
  }
}

/* Mobile */
@media (max-width: 640px) {
  .grid-2,
  .grid-3,
  .grid-4 {
    grid-template-columns: minmax(0, 1fr);
  }
  html {
    scroll-padding-top: calc(var(--nav-h) + 0.75rem);
  }
}

/* --------------------------------------------------------------------------
   Reduced motion — kill transforms and reveals, keep everything legible
   -------------------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  html {
    scroll-behavior: auto;
  }
}

/* --------------------------------------------------------------------------
   Print
   -------------------------------------------------------------------------- */

@media print {
  body::before,
  .site-nav,
  .site-footer,
  .theme-toggle,
  .cta-band {
    display: none !important;
  }
  body {
    background: #fff;
    color: #000;
  }
}
