/* ==========================================================================
   CODIRISE — Base
   Reset, document rhythm, typography, layout primitives.
   Rule: element selectors set defaults only. Layout lives in .classes.
   ========================================================================== */

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

* {
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: 96px;
  -webkit-text-size-adjust: 100%;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}

body {
  background: var(--canvas);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: var(--fs-body);
  font-weight: 400;
  line-height: var(--lh-body);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "cv11", "ss01";
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

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

a {
  color: inherit;
  text-decoration: none;
}

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

button {
  cursor: pointer;
}

ul,
ol {
  list-style: none;
}

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

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

/* Custom scrollbar — desktop only, never on touch */
@media (hover: hover) and (min-width: 900px) {
  ::-webkit-scrollbar {
    width: 10px;
  }
  ::-webkit-scrollbar-track {
    background: var(--canvas-deep);
  }
  ::-webkit-scrollbar-thumb {
    background: var(--surface-3);
    border-radius: var(--r-pill);
    border: 3px solid var(--canvas-deep);
  }
  ::-webkit-scrollbar-thumb:hover {
    background: var(--blue-primary);
  }
}

/* --------------------------------------------------------------------------
   Typography
   -------------------------------------------------------------------------- */

.t-hero {
  font-size: var(--fs-hero);
  font-weight: 700;
  letter-spacing: var(--ls-hero);
  line-height: var(--lh-tight);
  color: var(--ink-strong);
  text-wrap: balance;
}

.t-display {
  font-size: var(--fs-display);
  font-weight: 700;
  letter-spacing: var(--ls-hero);
  line-height: var(--lh-heading);
  color: var(--ink-strong);
  text-wrap: balance;
}

.t-h2 {
  font-size: var(--fs-h2);
  font-weight: 700;
  letter-spacing: var(--ls-h2);
  line-height: var(--lh-heading);
  color: var(--ink-strong);
  text-wrap: balance;
}

.t-h3 {
  font-size: var(--fs-h3);
  font-weight: 600;
  letter-spacing: var(--ls-h3);
  line-height: 1.3;
  color: var(--ink-strong);
}

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

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

.t-small {
  font-size: var(--fs-small);
  line-height: 1.7;
  color: var(--ink-muted);
}

/* The utility face. Used for anything the machine knows: labels, counts,
   stack names, timestamps, IDs. Never for prose. */
.t-mono {
  font-family: var(--font-mono);
  font-size: var(--fs-micro);
  font-weight: 500;
  letter-spacing: var(--ls-mono);
  text-transform: uppercase;
  color: var(--ink-faint);
}

.t-gradient {
  color: var(--ink-strong);
  background: none;
  -webkit-background-clip: unset;
  background-clip: unset;
}

.t-accent {
  color: var(--blue-accent);
}

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

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

.container--narrow {
  max-width: var(--container-narrow);
}

/* .section owns vertical rhythm and nothing else. Section-specific classes
   must never re-declare padding-block — that is the collision that breaks
   every large stylesheet. */
.section {
  position: relative;
  padding-block: var(--section-y);
  z-index: var(--z-content);
}

.section--tight {
  padding-block: clamp(56px, 7vw, 96px);
}

.section--flush-top {
  padding-block-start: 0;
}

/* Horizontal hairline that terminates in crosshairs on the layout rails.
   This is the page's structural signature: every section is bolted to the
   same grid, visibly. */
.rule {
  position: relative;
  height: 1px;
  background: var(--line);
  max-width: var(--container);
  margin-inline: auto;
}

.rule::before,
.rule::after {
  content: "";
  position: absolute;
  top: 50%;
  width: 9px;
  height: 9px;
  transform: translateY(-50%);
  background: linear-gradient(var(--line-strong), var(--line-strong)) center /
      9px 1px no-repeat,
    linear-gradient(var(--line-strong), var(--line-strong)) center / 1px 9px
      no-repeat;
}

.rule::before {
  left: calc(var(--gutter) - 4px);
}
.rule::after {
  right: calc(var(--gutter) - 4px);
}

/* Fixed vertical rails. Ambient, not decorative — they mark the container
   edge so every section visibly shares one measure. */
.rails {
  position: fixed;
  inset: 0;
  z-index: var(--z-rails);
  pointer-events: none;
  display: flex;
  justify-content: center;
}

.rails__inner {
  position: relative;
  width: 100%;
  max-width: var(--container);
  padding-inline: var(--gutter);
  height: 100%;
}

.rails__inner::before,
.rails__inner::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  width: 1px;
  background: var(--line-faint);
}

.rails__inner::before {
  left: var(--gutter);
}
.rails__inner::after {
  right: var(--gutter);
}

@media (max-width: 900px) {
  .rails {
    display: none;
  }
}

/* Grids */
.grid {
  display: grid;
  gap: var(--s-3);
}

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

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

@media (max-width: 640px) {
  .grid--2,
  .grid--3,
  .grid--4 {
    grid-template-columns: minmax(0, 1fr);
  }
}

.stack > * + * {
  margin-block-start: var(--s-2);
}

.flow > * + * {
  margin-block-start: var(--s-3);
}

/* Accessibility helpers */
.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(--s-3);
  z-index: 999;
  padding: var(--s-1) var(--s-3);
  background: var(--blue-accent);
  color: #0b0f18;
  border-radius: var(--r-pill);
  font-size: var(--fs-small);
  font-weight: 600;
  transition: top var(--t-base) var(--ease);
}

.skip-link:focus {
  top: var(--s-2);
}

[hidden] {
  display: none !important;
}
