/* ============================================================
 * File: css/base.css
 * Module: Base Styles
 * Purpose: Sora + JetBrains Mono @font-face, CSS reset, typography defaults,
 *          scrollbars, focus states, reduced-motion support.
 * Depends on: variables.css (tokens), themes.css (colors)
 * ============================================================ */

/* ------------------------------------------------------------
 * 1. Fonts: local files only (assets/fonts/)
 *    Sora: variable font, weights 300 to 800 (UI text)
 *    JetBrains Mono: variable font, weights 400 to 700 (code/data)
 * ------------------------------------------------------------ */

@font-face {
  font-family: 'Sora';
  src: url('../assets/fonts/Sora-Variable.woff2') format('woff2');
  font-weight: 300 800;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'JetBrains Mono';
  src: url('../assets/fonts/JetBrainsMono-Variable.woff2') format('woff2');
  font-weight: 400 700;
  font-style: normal;
  font-display: swap;
}

/* ------------------------------------------------------------
 * 2. Reset
 * ------------------------------------------------------------ */

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

html,
body,
h1,
h2,
h3,
h4,
h5,
h6,
p,
figure,
blockquote,
dl,
dd,
ol,
ul {
  margin: 0;
  padding: 0;
}

ol[role='list'],
ul[role='list'] {
  list-style: none;
}

/* ------------------------------------------------------------
 * 3. Document
 * ------------------------------------------------------------ */

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

body {
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  font-weight: var(--fw-regular);
  line-height: var(--lh-normal);
  letter-spacing: var(--ls-normal);

  background-color: var(--color-bg);
  color: var(--color-text);

  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;

  overflow: hidden;
  /* popup scrolls inside regions */
  transition: background-color var(--duration-base) var(--ease-standard),
    color var(--duration-base) var(--ease-standard);
}

/* ------------------------------------------------------------
 * 4. Typography defaults
 * ------------------------------------------------------------ */

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

h1 {
  font-size: var(--fs-2xl);
}

h2 {
  font-size: var(--fs-xl);
}

h3 {
  font-size: var(--fs-lg);
}

h4 {
  font-size: var(--fs-md);
}

h5 {
  font-size: var(--fs-base);
}

h6 {
  font-size: var(--fs-sm);
}

p {
  line-height: var(--lh-normal);
}

small {
  font-size: var(--fs-sm);
  color: var(--color-text-muted);
}

strong,
b {
  font-weight: var(--fw-semibold);
}

code,
kbd,
samp,
pre {
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
}

pre {
  overflow: auto;
  white-space: pre;
}

a {
  color: var(--color-accent);
  text-decoration: none;
  transition: color var(--duration-fast) var(--ease-standard);
}

a:hover {
  color: var(--color-accent-hover);
  text-decoration: underline;
}

hr {
  border: 0;
  border-top: var(--border-thin) solid var(--color-border);
  margin: var(--space-4) 0;
}

/* ------------------------------------------------------------
 * 5. Form elements inherit typography
 * ------------------------------------------------------------ */

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

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

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

textarea {
  resize: vertical;
}

/* ------------------------------------------------------------
 * 6. Media
 * ------------------------------------------------------------ */

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

/* Note: DO NOT add a global `svg { fill: ... }` rule.
   It overrides fill="none" presentation attributes on our icons
   and makes stroke-only SVGs render as solid shapes.
   Icons that need a fill (like the GitHub logo) set it inline
   with fill="currentColor". */

/* ------------------------------------------------------------
 * 7. Focus — visible ring for keyboard users only
 * ------------------------------------------------------------ */

:focus {
  outline: none;
}

:focus-visible {
  outline: var(--border-thick) solid var(--color-focus-ring);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* ------------------------------------------------------------
 * 8. Selection
 * ------------------------------------------------------------ */

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

/* ------------------------------------------------------------
 * 9. Scrollbars (WebKit) — slim, theme-aware
 * ------------------------------------------------------------ */

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: var(--color-scrollbar-track);
}

::-webkit-scrollbar-thumb {
  background-color: var(--color-scrollbar-thumb);
  border-radius: var(--radius-full);
  border: 3px solid transparent;
  background-clip: padding-box;
}

::-webkit-scrollbar-thumb:hover {
  background-color: var(--color-scrollbar-thumb-hover);
  background-clip: padding-box;
}

::-webkit-scrollbar-corner {
  background: transparent;
}

/* ------------------------------------------------------------
 * 10. Accessibility helpers
 * ------------------------------------------------------------ */

.dt-visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ------------------------------------------------------------
 * 11. 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;
  }
}