/**
 * base.css
 * Reset, typography, global utilities, accessibility helpers.
 * Depends on: tokens.css
 */

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

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

body {
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: 1.6;
  color: var(--c-text-primary);
  background-color: var(--c-bg);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

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

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

a {
  color: inherit;
  text-decoration: none;
}

ul, ol {
  list-style: none;
}

/* ── Accessibility: skip nav ──────────────────── */
.skip-nav {
  position: absolute;
  top: -100%;
  left: var(--space-4);
  z-index: var(--z-toast);
  padding: var(--space-3) var(--space-5);
  background: var(--c-red);
  color: var(--c-white);
  font-size: var(--text-sm);
  font-weight: 700;
  border-radius: 0 0 var(--radius-md) var(--radius-md);
  transition: top var(--duration-sm) var(--ease);
}
.skip-nav:focus {
  top: 0;
  outline: 3px solid var(--c-gold);
  outline-offset: 2px;
}

/* ── Focus ring ───────────────────────────────── */
:focus-visible {
  outline: 3px solid var(--c-gold);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}
:focus:not(:focus-visible) {
  outline: none;
}

/* ── Typography scale ─────────────────────────── */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  font-weight: 700;
  line-height: 1.25;
  color: var(--c-text-primary);
}

h1 { font-size: clamp(1.75rem, 4vw, 2.75rem); font-weight: 800; }
h2 { font-size: clamp(1.375rem, 2.5vw, 1.875rem); font-weight: 700; }
h3 { font-size: var(--text-xl); }
h4 { font-size: var(--text-lg); }
h5 { font-size: var(--text-base); font-weight: 700; }
h6 { font-size: var(--text-sm); font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; }

p {
  color: var(--c-text-secondary);
  line-height: 1.7;
}

small {
  font-size: var(--text-xs);
  color: var(--c-text-muted);
}

strong {
  font-weight: 600;
  color: var(--c-text-primary);
}

/* ── Utility classes ──────────────────────────── */

/* Display */
.d-none    { display: none !important; }
.d-block   { display: block !important; }
.d-flex    { display: flex !important; }
.d-grid    { display: grid !important; }
.d-inline  { display: inline !important; }
.d-inline-flex { display: inline-flex !important; }

/* Flex helpers */
.flex-col      { flex-direction: column; }
.flex-wrap     { flex-wrap: wrap; }
.flex-1        { flex: 1; }
.items-center  { align-items: center; }
.items-start   { align-items: flex-start; }
.justify-between { justify-content: space-between; }
.justify-center  { justify-content: center; }
.gap-1  { gap: var(--space-1); }
.gap-2  { gap: var(--space-2); }
.gap-3  { gap: var(--space-3); }
.gap-4  { gap: var(--space-4); }
.gap-6  { gap: var(--space-6); }
.gap-8  { gap: var(--space-8); }

/* Spacing */
.mt-0  { margin-top: 0; }
.mt-2  { margin-top: var(--space-2); }
.mt-4  { margin-top: var(--space-4); }
.mt-6  { margin-top: var(--space-6); }
.mt-8  { margin-top: var(--space-8); }
.mb-2  { margin-bottom: var(--space-2); }
.mb-4  { margin-bottom: var(--space-4); }
.mb-6  { margin-bottom: var(--space-6); }
.mb-8  { margin-bottom: var(--space-8); }
.p-4   { padding: var(--space-4); }
.px-4  { padding-inline: var(--space-4); }
.py-4  { padding-block: var(--space-4); }

/* Text */
.text-center  { text-align: center; }
.text-right   { text-align: right; }
.text-xs      { font-size: var(--text-xs); }
.text-sm      { font-size: var(--text-sm); }
.text-base    { font-size: var(--text-base); }
.text-lg      { font-size: var(--text-lg); }
.text-xl      { font-size: var(--text-xl); }
.text-muted   { color: var(--c-text-muted); }
.text-faint   { color: var(--c-text-faint); }
.text-red     { color: var(--c-red); }
.text-gold    { color: var(--c-gold); }
.text-white   { color: var(--c-white); }
.font-display { font-family: var(--font-display); }
.font-700     { font-weight: 700; }
.font-800     { font-weight: 800; }
.uppercase    { text-transform: uppercase; }
.tracking-wide { letter-spacing: 0.1em; }

/* Truncation */
.line-clamp-1 { display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }
.line-clamp-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.line-clamp-3 { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }

/* Misc */
.w-full   { width: 100%; }
.h-full   { height: 100%; }
.min-h-0  { min-height: 0; }
.overflow-hidden { overflow: hidden; }
.relative { position: relative; }
.pointer  { cursor: pointer; }
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* ── Skeleton loaders ──────────────────────────── */
.skeleton {
  background: linear-gradient(
    90deg,
    var(--c-border) 25%,
    var(--c-surface-alt) 50%,
    var(--c-border) 75%
  );
  background-size: 200% 100%;
  animation: skeleton-sweep 1.4s ease infinite;
  border-radius: var(--radius-sm);
}
@keyframes skeleton-sweep {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ── Toast notification ────────────────────────── */
#toast-region {
  position: fixed;
  bottom: var(--space-6);
  right: var(--space-6);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-5);
  background: var(--c-charcoal);
  color: var(--c-white);
  font-size: var(--text-sm);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  pointer-events: all;
  transform: translateX(110%);
  opacity: 0;
  transition: transform var(--duration-md) var(--ease), opacity var(--duration-md) var(--ease);
  max-width: 320px;
}
.toast[data-visible="true"] {
  transform: translateX(0);
  opacity: 1;
}
.toast--success { border-left: 3px solid #22C55E; }
.toast--error   { border-left: 3px solid var(--c-red); }
.toast--info    { border-left: 3px solid var(--c-gold); }
.toast__icon { font-size: 1rem; flex-shrink: 0; }
.toast__close {
  margin-left: auto;
  background: none;
  border: none;
  color: rgba(255,255,255,0.5);
  cursor: pointer;
  padding: 0 var(--space-1);
  font-size: 1rem;
  flex-shrink: 0;
}
.toast__close:hover { color: var(--c-white); }

/* ── Back to top ───────────────────────────────── */
#back-to-top {
  position: fixed;
  bottom: calc(var(--space-6) + 48px + var(--space-2));
  right: var(--space-6);
  z-index: var(--z-toast);
  width: 42px;
  height: 42px;
  border-radius: var(--radius-md);
  background: var(--c-red);
  color: var(--c-white);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  box-shadow: var(--shadow-red);
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition:
    opacity var(--duration-sm) var(--ease),
    transform var(--duration-sm) var(--ease),
    background var(--duration-xs) var(--ease);
}
#back-to-top[data-visible="true"] {
  opacity: 1;
  pointer-events: all;
  transform: translateY(0);
}
#back-to-top:hover { background: var(--c-red-dark); }

/* ── Reduced motion ────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  html { scroll-behavior: auto; }
}

/* ── Print ─────────────────────────────────────── */
@media print {
  .skip-nav,
  #toast-region,
  #back-to-top,
  nav,
  aside,
  footer,
  .ticker-bar,
  .topbar,
  .site-header__ad,
  .share-bar,
  .widget--newsletter,
  .no-print { display: none !important; }
  body { background: #fff; color: #000; font-size: 12pt; }
  a::after { content: " (" attr(href) ")"; font-size: 0.8em; color: #666; }
  h1, h2, h3 { page-break-after: avoid; }
  p, blockquote { orphans: 3; widows: 3; }
}
