/* ============================================================================
   rohit.vision — BASE
   Reset + element defaults. Depends on tokens.css. Contains no component
   classes and no raw values — every declaration resolves through a token.

   Load order:  tokens.css  ->  base.css  ->  viz.css  ->  <surface>.css
   ========================================================================= */

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

html {
  /* 1rem = 16px. The scale is rem-based so a reader's browser zoom and
     font-size preference both work. Never set a px font-size here. */
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-h) + var(--space-5));
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  background: var(--surface);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: var(--text-md);
  line-height: var(--leading-normal);
  font-weight: var(--weight-regular);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* --------------------------------------------------------------------------
   HEADINGS — mono is NOT used for headings. Prose hierarchy is sans; mono
   is reserved for machine-authored text (see § LABEL). Tight leading, and
   negative tracking only at display sizes where default tracking looks loose.
   ----------------------------------------------------------------------- */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-sans);
  font-weight: var(--weight-semibold);
  line-height: var(--leading-tight);
  color: var(--ink);
  text-wrap: balance;   /* keeps short headings off a lonely last line */
}

h1 { font-size: var(--text-3xl); letter-spacing: var(--tracking-tight); }
h2 { font-size: var(--text-2xl); letter-spacing: var(--tracking-tight); }
h3 { font-size: var(--text-xl); }
h4 { font-size: var(--text-lg); }
h5 { font-size: var(--text-md); }
h6 { font-size: var(--text-base); font-weight: var(--weight-medium); color: var(--ink-secondary); }

/* --------------------------------------------------------------------------
   PROSE
   `.prose` is the long-form reading context: posts, notes, docs. It sets the
   reading size, the loose leading, and — the important one — the MEASURE.
   Everything inside inherits; nothing inside re-declares a font-size in px.
   ----------------------------------------------------------------------- */
.prose {
  font-size: var(--text-read);
  line-height: var(--leading-read);
  color: var(--ink);
  max-width: var(--measure);
  text-wrap: pretty;   /* avoids orphans/rivers where supported */
}

.prose > * + * { margin-top: var(--flow); }

.prose h1, .prose h2, .prose h3, .prose h4 { margin-top: var(--space-7); }
.prose h1 + *, .prose h2 + *, .prose h3 + *, .prose h4 + * { margin-top: var(--space-4); }

/* Figures, tables, code and diagrams are allowed to break the prose measure —
   they carry structure, not running text, and read better wider. */
.prose figure,
.prose table,
.prose pre,
.prose .viz,
.prose .full-bleed {
  max-width: var(--measure-wide);
  width: 100%;
}

/* --------------------------------------------------------------------------
   LINKS — accent for content links. Underline is present but recessive, so
   a paragraph with several links does not turn into a fence.
   ----------------------------------------------------------------------- */
a {
  color: var(--ink-accent);
  text-decoration: none;
  transition: color var(--dur-fast) var(--ease);
}
a:hover { color: var(--ink); }

.prose a {
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, var(--ink-accent) 40%, transparent);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
}
.prose a:hover { text-decoration-color: var(--ink-accent); }

/* --------------------------------------------------------------------------
   FOCUS — visible, always. Two-tone ring so it reads on any surface.
   ----------------------------------------------------------------------- */
:focus-visible {
  outline: none;
  box-shadow: var(--ring-focus);
  border-radius: var(--radius-tight);
}

.skip-link {
  position: absolute;
  left: var(--space-4);
  top: calc(-1 * var(--space-10));
  z-index: var(--z-toast);
  padding: var(--space-2) var(--space-4);
  background: var(--surface-raised);
  color: var(--ink);
  border: var(--border-width) solid var(--border-control);
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  transition: top var(--dur) var(--ease);
}
.skip-link:focus { top: var(--space-4); }

/* --------------------------------------------------------------------------
   LABEL — the mono voice. Eyebrows, nav, meta, section numbers, timestamps,
   axis ticks, entity IDs. Uppercase + tracked. This is the single class that
   carries the system's terminal character; use it instead of re-declaring
   font-family + size + tracking on every component.
   ----------------------------------------------------------------------- */
.label {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
  color: var(--ink-muted);
}
.label--accent { color: var(--ink-accent); }
.label--plain  { text-transform: none; letter-spacing: 0; }

/* Numeric data: IDs, timestamps, metrics. Tabular so columns align, and
   never centred — mono data is always left- or right-aligned. */
.mono,
time, code, kbd, samp, var {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-feature-settings: 'zero' 1;   /* slashed zero where the face has it */
}

/* --------------------------------------------------------------------------
   CODE
   ----------------------------------------------------------------------- */
code {
  font-size: var(--text-code);
  background: var(--surface-inset);
  border: var(--border-width) solid var(--border);
  border-radius: var(--radius-tight);
  padding: 0.15em 0.4em;
  color: var(--ink);
  word-break: break-word;
}

pre {
  background: var(--surface-inset);
  border: var(--border-width) solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-4);
  overflow-x: auto;      /* the block scrolls; the PAGE never does */
  line-height: var(--leading-normal);
  font-size: var(--text-base);
  tab-size: 2;
}
pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: inherit;
}

kbd {
  font-size: var(--text-xs);
  background: var(--surface-raised);
  border: var(--border-width) solid var(--border-control);
  border-bottom-width: 2px;
  border-radius: var(--radius-tight);
  padding: 0.1em 0.4em;
  color: var(--ink-secondary);
}

/* --------------------------------------------------------------------------
   LISTS — hanging markers so the text edge stays flush with the paragraph
   above it. Nested lists tighten rather than compound their spacing.
   ----------------------------------------------------------------------- */
.prose ul, .prose ol { padding-left: var(--space-5); }
.prose li + li { margin-top: var(--space-2); }
.prose li > ul, .prose li > ol { margin-top: var(--space-2); }
.prose ::marker { color: var(--ink-muted); }

/* --------------------------------------------------------------------------
   QUOTES — a rule, not a glyph. Accent-tinted left border.
   ----------------------------------------------------------------------- */
blockquote {
  border-left: 2px solid var(--border-accent);
  padding-left: var(--space-4);
  color: var(--ink-secondary);
  font-style: normal;   /* italic hurts legibility at reading size */
}

hr {
  border: none;
  border-top: var(--border-width) solid var(--border);
  margin-block: var(--space-7);
}

/* --------------------------------------------------------------------------
   TABLES — dense, left-aligned, hairline rules. Numbers right-aligned and
   tabular. The wrapper scrolls, never the page.
   ----------------------------------------------------------------------- */
.table-wrap { overflow-x: auto; max-width: 100%; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-base);
  line-height: var(--leading-snug);
}
th {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
  color: var(--ink-muted);
  text-align: left;
  padding: var(--space-2) var(--space-3);
  border-bottom: var(--border-width) solid var(--border-strong);
  white-space: nowrap;
}
td {
  padding: var(--space-3);
  border-bottom: var(--border-width) solid var(--border);
  color: var(--ink-secondary);
  vertical-align: top;
}
td:first-child { color: var(--ink); }
th.num, td.num { text-align: right; font-variant-numeric: tabular-nums; }
tbody tr { transition: background var(--dur-fast) var(--ease); }
tbody tr:hover { background: var(--surface-hover); }

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

figure { margin: 0; }
figcaption {
  margin-top: var(--space-2);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  line-height: var(--leading-snug);
  color: var(--ink-muted);
}

/* --------------------------------------------------------------------------
   FORM CONTROLS — every focusable control uses --border-control, the only
   border step that clears 3:1. Controls inherit the page font.
   ----------------------------------------------------------------------- */
input, textarea, select, button {
  font-family: inherit;
  font-size: var(--text-base);
  color: inherit;
}

input[type='text'], input[type='search'], input[type='email'], textarea, select {
  width: 100%;
  background: var(--surface-inset);
  border: var(--border-width) solid var(--border-control);
  border-radius: var(--radius);
  padding: var(--space-2) var(--space-3);
  transition: border-color var(--dur-fast) var(--ease);
}
input::placeholder, textarea::placeholder { color: var(--ink-muted); }
input:hover, textarea:hover, select:hover { border-color: var(--ink-muted); }
input:focus-visible, textarea:focus-visible, select:focus-visible {
  border-color: var(--border-accent);
}

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

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

/* --------------------------------------------------------------------------
   LAYOUT HELPERS — the gutter is applied here and nowhere else.
   ----------------------------------------------------------------------- */
.wrap        { width: 100%; margin-inline: auto; padding-inline: var(--gutter); }
.wrap--wide  { max-width: var(--max-wide); }
.wrap--ultra { max-width: var(--max-ultra); }
.wrap--read  { max-width: var(--max-content); }

.stack > * + * { margin-top: var(--flow); }
.visually-hidden {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip-path: inset(50%); white-space: nowrap;
}

/* --------------------------------------------------------------------------
   MOTION PREFERENCE — honoured, not negotiated.
   ----------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* --------------------------------------------------------------------------
   FORCED COLORS — keep structure when the OS overrides colour.
   ----------------------------------------------------------------------- */
@media (forced-colors: active) {
  * { border-color: CanvasText; }
  .label, figcaption, th { color: CanvasText; }
}
