/* tinymoon — fonts and base element styles: the sharp-corner reset,
   native-control elimination, grain overlay, custom scrollbars, and focus
   rings. All fonts are vendored: IBM Plex Sans (UI), IBM Plex Mono (data),
   Space Grotesk (brand/headings). Requires tokens.css. */

/* ---------- fonts ---------- */

@font-face {
  font-family: "Plex";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("../fonts/ibm-plex-sans-latin.woff2") format("woff2");
}
@font-face {
  font-family: "Plex Mono";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("../fonts/ibm-plex-mono-latin-400.woff2") format("woff2");
}
@font-face {
  font-family: "Plex Mono";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("../fonts/ibm-plex-mono-latin-500.woff2") format("woff2");
}
@font-face {
  font-family: "Grotesk";
  font-style: normal;
  font-weight: 300 700;
  font-display: swap;
  src: url("../fonts/space-grotesk-latin.woff2") format("woff2");
}

/* ---------- base ---------- */

* { box-sizing: border-box; border-radius: 0 !important; }

/* Structural native-UI elimination: every form control drops its OS/browser
   appearance and is rebuilt by the design system. Native checkboxes, radios,
   selects, file inputs, and dialogs are banned outright — custom widgets
   (toggleWidget, Select, segmented) replace them. */
button, input, textarea, select {
  appearance: none;
  -webkit-appearance: none;
  border-radius: 0;
  font-family: inherit;
}
input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
input::-webkit-search-decoration,
input::-webkit-search-cancel-button { -webkit-appearance: none; }
input::-webkit-calendar-picker-indicator { display: none; }
input:-webkit-autofill {
  -webkit-box-shadow: 0 0 0 100px var(--input-bg) inset;
  -webkit-text-fill-color: var(--text);
}
textarea {
  background: var(--input-bg);
  border: 1px solid var(--border-2);
  color: var(--text);
  font-weight: var(--weight-normal);
  font-size: var(--text-xs);
  font-family: var(--font-ui);
  padding: var(--space-10);
  resize: vertical;
  user-select: text;
}
textarea:hover { border-color: var(--hover-border); }
textarea:focus { border-color: var(--accent); box-shadow: 0 0 10px var(--accent-a18); }
textarea::placeholder { color: var(--text-faint); }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-weight: var(--weight-normal);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  font-family: var(--font-ui);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  user-select: none;
}
/* Wiki/doc prose is the one content carve-out: selectable text so users can
   highlight and copy passages. Everything else (chrome, nav, controls) stays
   unselectable via body's user-select: none. */
.doc-body { user-select: text; }
::selection { background: var(--accent-soft); color: var(--text); }
.mono { font-family: var(--font-mono); }
.hidden { display: none !important; }
h1, h2, h3 { font-family: var(--font-brand); font-weight: var(--weight-medium); margin: 0; }
h4 { font-family: var(--font-brand); font-weight: var(--weight-medium); font-size: var(--text-base); margin: 0; }
h5 { font-family: var(--font-brand); font-weight: var(--weight-medium); font-size: var(--text-sm); margin: 0; }
h6 { font-family: var(--font-brand); font-weight: var(--weight-medium); font-size: var(--text-xs); text-transform: uppercase; letter-spacing: 0.04em; margin: 0; }

a { color: var(--accent-hi); text-decoration: none; transition: color var(--dur-base) ease; }
a:hover { color: var(--accent); }

/* ---------- semantic prose elements ---------- */

ul, ol {
  margin: var(--space-10) 0;
  padding-inline-start: var(--space-24);
  color: var(--text-dim);
  font-size: var(--text-xs);
  line-height: var(--leading-relaxed);
}
ul ul, ul ol, ol ul, ol ol { margin: var(--space-4) 0; }
li { margin-bottom: var(--space-4); }

blockquote {
  margin: var(--space-16) 0;
  padding: var(--space-12) var(--space-20);
  border-inline-start: 2px solid var(--accent);
  background: var(--surface);
  color: var(--text-dim);
  font-size: var(--text-xs);
  line-height: var(--leading-relaxed);
}

pre {
  margin: var(--space-12) 0;
  padding: var(--space-14);
  background: var(--surface);
  border: 1px solid var(--border);
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: var(--text-2xs);
  line-height: var(--leading-relaxed);
  color: var(--text);
}
pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: inherit;
}
code {
  font-family: var(--font-mono);
  font-size: var(--text-3xs);
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: var(--space-1) var(--space-4);
  color: var(--text);
}

table {
  border-collapse: collapse;
  width: 100%;
  font-size: var(--text-xs);
  line-height: var(--leading-normal);
  margin: var(--space-12) 0;
}
table th {
  text-align: start;
  font-weight: var(--weight-medium);
  font-size: var(--text-2xs);
  color: var(--text);
  padding: var(--space-8) var(--space-10);
  border-bottom: 1px solid var(--border-2);
}
table td {
  padding: var(--space-6) var(--space-10);
  border-bottom: 1px solid var(--border);
  color: var(--text-dim);
}

dl { margin: var(--space-12) 0; }
dt {
  font-weight: var(--weight-medium);
  font-size: var(--text-xs);
  color: var(--text);
  margin-top: var(--space-10);
}
dd {
  margin: var(--space-4) 0 0 var(--space-24);
  font-size: var(--text-xs);
  color: var(--text-dim);
  line-height: var(--leading-relaxed);
}

hr {
  border: none;
  border-top: 1px solid var(--border-2);
  margin: var(--space-24) 0;
}

figure {
  margin: var(--space-16) 0;
  padding: 0;
}
figcaption {
  margin-top: var(--space-8);
  font-family: var(--font-mono);
  font-size: var(--text-2xs);
  color: var(--text-faint);
}

/* grain overlay */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: var(--z-grain);
  pointer-events: none;
  opacity: var(--grain-opacity);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)' opacity='0.55'/%3E%3C/svg%3E");
}

/* custom scrollbars */
* { scrollbar-width: thin; scrollbar-color: var(--border-2) transparent; }
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: var(--scroll-thumb); border: 2px solid var(--bg); }
*::-webkit-scrollbar-thumb:hover { background: var(--accent); }

/* focus rings */
:focus { outline: none; }
:focus-visible {
  outline: 1px solid var(--accent);
  outline-offset: 2px;
  box-shadow: 0 0 12px var(--accent-glow);
}

/* ---------- reduced motion ---------- */
/* Blanket motion suppression: near-instant durations disable visible
   animation/transition without breaking layout-dependent transforms.
   The spinner (.spin) keeps rotating but completes instantly per cycle. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  /* The spinner must still rotate continuously (infinite), but with no
     visible motion: near-instant duration + restored iteration. */
  .spin {
    animation-iteration-count: infinite !important;
  }
  #tm-content {
    scroll-behavior: auto !important;
  }
}

/* ---------- print ---------- */
/* Counters the Firefox first-page-only bug with overflow:hidden shells:
   everything becomes static and visible so the full content area prints.
   Sidebar, topbar, and footer are hidden — only the main content prints. */
@media print {
  body {
    overflow: visible !important;
    user-select: text !important;
  }
  #tm-content {
    overflow: visible !important;
    height: auto !important;
    max-height: none !important;
    position: static !important;
  }
  #tm-sidebar,
  #tm-topbar,
  .gallery-footer,
  #tm-toast-root,
  #tm-ctx-root {
    display: none !important;
  }
  /* Remove fixed/absolute positioning from shell chrome so content flows */
  #tm-app {
    display: block !important;
    height: auto !important;
    overflow: visible !important;
  }
  /* Grain overlay must not print */
  body::after {
    display: none !important;
  }
}
