/* =============================================================
   Base — modern reset + typographic defaults
   ============================================================= */

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

* {
  margin: 0;
}

html {
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  scroll-behavior: smooth;
  font-family: var(--font-sans);
  font-size: 15px;            /* 1rem = 15px */
  line-height: var(--lh-base);
  color: var(--color-text);
  background-color: var(--color-bg);
}

body {
  min-height: 100dvh;
  font-family: inherit;
  font-size: var(--fs-base);
  line-height: inherit;
  color: var(--color-text);
  background-color: var(--color-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  transition: background-color var(--dur-normal) var(--ease-standard),
              color var(--dur-normal) var(--ease-standard);
}

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

svg {
  fill: currentColor;
  stroke-width: inherit;
}

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

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

button:disabled,
[aria-disabled="true"] {
  cursor: not-allowed;
}

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

a:hover {
  color: var(--color-primary-hover);
  text-decoration: underline;
  text-underline-offset: 3px;
}

p,
li {
  overflow-wrap: break-word;
}

ul,
ol {
  padding: 0;
  list-style: none;
}

/* ---- Headings ---- */
h1, h2, h3, h4, h5, h6 {
  font-family: inherit;
  font-weight: var(--fw-semibold);
  line-height: var(--lh-snug);
  color: var(--color-text);
}

h1 { font-size: var(--fs-h2); font-weight: var(--fw-bold); line-height: var(--lh-tight); }
h2 { font-size: var(--fs-h3); }
h3 { font-size: var(--fs-h4); }
h4 { font-size: var(--fs-h5); }
h5 { font-size: var(--fs-h6); }
h6 { font-size: var(--fs-sm); text-transform: uppercase; letter-spacing: 0.04em; color: var(--color-muted); }

@media (min-width: 1024px) {
  h1 { font-size: var(--fs-h1); }
}

/* ---- Small / code ---- */
small {
  font-size: var(--fs-sm);
  color: var(--color-muted);
}

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

code {
  background: var(--color-surface-2);
  padding: 0.1em 0.35em;
  border-radius: var(--radius-sm);
}

pre {
  background: var(--color-surface-2);
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--radius-md);
  overflow-x: auto;
}

hr {
  border: 0;
  border-top: 1px solid var(--color-divider);
  margin: var(--sp-5) 0;
}

/* ---- Focus ring ---- */
:focus {
  outline: none;
}

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

/* Interactive controls get the full glow */
.btn:focus-visible,
.input:focus-visible,
.select:focus-visible,
.textarea:focus-visible,
.chip:focus-visible,
.tab:focus-visible,
.page-btn:focus-visible,
[data-theme-toggle]:focus-visible,
[role="button"]:focus-visible {
  outline: none;
  box-shadow: var(--shadow-focus);
}

/* ---- Selection ---- */
::selection {
  background: var(--brand-tint-20);
  color: var(--color-text);
}

/* ---- Scrollbars (subtle, themed) ---- */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--color-border-strong) transparent;
}

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

*::-webkit-scrollbar-thumb {
  background: var(--color-border-strong);
  border-radius: var(--radius-pill);
  border: 2px solid transparent;
  background-clip: padding-box;
}

*::-webkit-scrollbar-thumb:hover {
  background: var(--color-muted);
  background-clip: padding-box;
  border: 2px solid transparent;
}

/* ---- 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-muted); }
.text-soft  { color: var(--color-text-soft); }
.text-primary { color: var(--color-primary); }
.text-success { color: var(--color-success); }
.text-warning { color: var(--color-warning); }
.text-danger  { color: var(--color-danger); }
.text-info    { color: var(--color-info); }
.text-sm { font-size: var(--fs-sm); }
.text-xs { font-size: var(--fs-xs); }
.text-lg { font-size: var(--fs-lg); }
.text-bold    { font-weight: var(--fw-semibold); }
.text-center  { text-align: center; }
.text-right   { text-align: right; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.hidden { display: none !important; }
.visible-md { display: none; }
@media (min-width: 768px) {
  .visible-md { display: revert; }
  .hidden-md  { display: none !important; }
}
.visible-lg { display: none; }
@media (min-width: 1024px) {
  .visible-lg { display: revert; }
  .hidden-lg  { display: none !important; }
}

.mt-1 { margin-top: var(--sp-1); }
.mt-2 { margin-top: var(--sp-2); }
.mt-3 { margin-top: var(--sp-3); }
.mt-4 { margin-top: var(--sp-4); }
.mt-5 { margin-top: var(--sp-5); }
.mt-6 { margin-top: var(--sp-6); }
.mb-1 { margin-bottom: var(--sp-1); }
.mb-2 { margin-bottom: var(--sp-2); }
.mb-3 { margin-bottom: var(--sp-3); }
.mb-4 { margin-bottom: var(--sp-4); }
.mb-5 { margin-bottom: var(--sp-5); }
.mb-6 { margin-bottom: var(--sp-6); }
.gap-1 { gap: var(--sp-1); }
.gap-2 { gap: var(--sp-2); }
.gap-3 { gap: var(--sp-3); }
.gap-4 { gap: var(--sp-4); }
.gap-5 { gap: var(--sp-5); }

.flex { display: flex; }
.inline-flex { display: inline-flex; }
.flex-col { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.items-start  { align-items: flex-start; }
.items-end    { align-items: flex-end; }
.justify-between { justify-content: space-between; }
.justify-center  { justify-content: center; }
.justify-end     { justify-content: flex-end; }
.flex-1 { flex: 1 1 0%; }

.w-full  { width: 100%; }
.max-w-content { max-width: var(--content-max); margin-inline: auto; }

/* ---- Icon helper ---- */
.icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  display: inline-block;
  stroke-width: 2;
}

.icon-sm { width: 16px; height: 16px; }
.icon-lg { width: 24px; height: 24px; }
.icon-xl { width: 32px; height: 32px; }
