/**
 * base.css
 * Global reset, typography defaults, and utility helpers.
 * Depends on: variables.css
 */

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

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

body {
  font-family: var(--font-sans);
  font-size: 0.9375rem; /* 15px */
  line-height: 1.6;
  color: var(--color-text);
  background-color: var(--color-bg);
  transition: background-color var(--transition-slow), color var(--transition-slow);
}

img, svg { display: block; max-width: 100%; }
button, input, select, textarea { font-family: inherit; font-size: inherit; }
a { color: var(--color-primary); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--color-accent); }
ul, ol { list-style: none; }
hr { border: none; border-top: 1px solid var(--color-border); }

/* ── Typography ──────────────────────────────────────────────────────────── */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-serif);
  font-weight: 600;
  color: var(--color-text);
  line-height: 1.2;
}

h1 { font-size: 2.25rem; }
h2 { font-size: 1.75rem; }
h3 { font-size: 1.35rem; }
h4 { font-size: 1.1rem;  }
h5 { font-size: 0.95rem; font-family: var(--font-sans); font-weight: 600; }
h6 { font-size: 0.85rem; font-family: var(--font-sans); font-weight: 600; }

p { margin-bottom: 0.5rem; }
p:last-child { margin-bottom: 0; }

small { font-size: 0.8rem; }
strong { font-weight: 600; }
code { font-family: var(--font-mono); font-size: 0.85em; background: var(--color-accent-soft); padding: 0.1em 0.35em; border-radius: var(--radius-xs); }

/* ── Focus ───────────────────────────────────────────────────────────────── */
:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
  border-radius: var(--radius-xs);
}

/* ── Selection ───────────────────────────────────────────────────────────── */
::selection { background: var(--color-accent-soft); color: var(--color-text); }

/* ── Scrollbar ───────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--color-border-mid); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--color-primary); }

/* ── Utility helpers ─────────────────────────────────────────────────────── */
.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

.text-muted   { color: var(--color-text-muted); }
.text-success { color: var(--color-success); }
.text-danger  { color: var(--color-danger); }
.text-accent  { color: var(--color-accent); }
.text-right   { text-align: right; }
.text-center  { text-align: center; }
.text-small   { font-size: 0.8rem; }
.text-xs      { font-size: 0.75rem; }
.text-mono    { font-family: var(--font-mono); }

.fw-medium    { font-weight: 500; }
.fw-semibold  { font-weight: 600; }
.fw-bold      { font-weight: 700; }

.d-flex        { display: flex; }
.align-center  { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 0.25rem; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }
.gap-4 { gap: 1rem; }

.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 0.75rem; }
.mt-4 { margin-top: 1rem; }
.mt-6 { margin-top: 1.5rem; }
.mt-8 { margin-top: 2rem; }

.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 0.75rem; }
.mb-4 { margin-bottom: 1rem; }
.mb-6 { margin-bottom: 1.5rem; }

.p-2 { padding: 0.5rem; }
.p-4 { padding: 1rem; }
.p-6 { padding: 1.5rem; }

.w-full    { width: 100%; }
.max-w-md  { max-width: 440px; }
.max-w-lg  { max-width: 640px; }
.max-w-xl  { max-width: 800px; }
.mx-auto   { margin-left: auto; margin-right: auto; }

.truncate { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }

/* ── Grid helpers ────────────────────────────────────────────────────────── */
.grid { display: grid; }
.grid-cols-1 { grid-template-columns: 1fr; }
.grid-cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid-cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid-cols-4 { grid-template-columns: repeat(4, 1fr); }

@media (max-width: 1200px) {
  .grid-cols-4 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 768px) {
  .grid-cols-2,
  .grid-cols-3,
  .grid-cols-4 { grid-template-columns: 1fr; }
}
