/**
 * base.css
 * Reset, typography base, global utilities
 */

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

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

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

/* ─── Scrollbar ─────────────────────────────────────────────────────────────── */
::-webkit-scrollbar {
  width: 6px;
}

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

::-webkit-scrollbar-thumb {
  background: var(--bg-surface);
  border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* ─── Selection ─────────────────────────────────────────────────────────────── */
::selection {
  background: rgba(56, 189, 248, 0.25);
  color: var(--text-primary);
}

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

/* ─── Typography Base ───────────────────────────────────────────────────────── */
h1, h2, h3, h4, h5, h6 {
  font-weight: var(--font-bold);
  line-height: var(--leading-tight);
  color: var(--text-primary);
}

h1 { font-size: clamp(var(--text-4xl), 6vw, var(--text-6xl)); font-weight: var(--font-extrabold); }
h2 { font-size: clamp(var(--text-3xl), 4vw, var(--text-4xl)); }
h3 { font-size: clamp(var(--text-xl), 3vw, var(--text-2xl)); }
h4 { font-size: var(--text-xl); }
h5 { font-size: var(--text-lg); }
h6 { font-size: var(--text-base); }

p {
  color: var(--text-secondary);
  line-height: var(--leading-relaxed);
}

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

a:hover {
  color: var(--color-primary-hover);
}

ul, ol {
  list-style: none;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

button {
  cursor: pointer;
  font-family: inherit;
  border: none;
  background: none;
}

/* ─── Layout Utilities ──────────────────────────────────────────────────────── */
.container {
  width: 100%;
  max-width: var(--container-xl);
  margin-inline: auto;
  padding-inline: var(--space-lg);
}

@media (max-width: 768px) {
  .container {
    padding-inline: var(--space-md);
  }
}

.section {
  padding-block: var(--space-4xl);
}

@media (max-width: 768px) {
  .section {
    padding-block: var(--space-3xl);
  }
}

.section-header {
  text-align: center;
  margin-bottom: var(--space-3xl);
}

.section-label {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: var(--font-medium);
  color: var(--color-primary);
  text-transform: uppercase;
  letter-spacing: 0.15em;
  margin-bottom: var(--space-md);
}

.section-label::before {
  content: '';
  display: block;
  width: 20px;
  height: 1px;
  background: var(--color-primary);
}

.section-title {
  font-size: clamp(var(--text-2xl), 3.5vw, var(--text-4xl));
  font-weight: var(--font-bold);
  color: var(--text-primary);
  margin-bottom: var(--space-md);
}

.section-subtitle {
  font-size: var(--text-lg);
  color: var(--text-secondary);
  max-width: 560px;
  margin-inline: auto;
  line-height: var(--leading-relaxed);
}

/* ─── Divider ───────────────────────────────────────────────────────────────── */
.divider {
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--border-color), transparent);
}

/* ─── Monospace / Code Text ─────────────────────────────────────────────────── */
.mono {
  font-family: var(--font-mono);
}

/* ─── Gradient Text ─────────────────────────────────────────────────────────── */
.gradient-text {
  background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-accent) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

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

/* ─── Skip Navigation ───────────────────────────────────────────────────────── */
.skip-nav {
  position: absolute;
  top: -100%;
  left: var(--space-md);
  padding: var(--space-sm) var(--space-md);
  background: var(--color-primary);
  color: var(--btn-primary-text);
  font-weight: var(--font-semibold);
  border-radius: var(--radius-md);
  z-index: var(--z-modal);
  transition: top var(--transition-fast);
}

.skip-nav:focus {
  top: var(--space-sm);
}

/* ─── Visually Hidden (for screen readers) ──────────────────────────────────── */
.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;
}

/* ─── Fade-up / Fade-in scroll reveal (Progressive Enhancement) ────────────── */
/* Default: visible — fallback if JS fails or is blocked */
.fade-up {
  opacity: 1;
  transform: none;
  transition: opacity 0.55s cubic-bezier(0.22, 1, 0.36, 1),
              transform 0.55s cubic-bezier(0.22, 1, 0.36, 1);
}

.fade-in {
  opacity: 1;
  transition: opacity 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}

/* Only hide when JS has confirmed it loaded (html.js-ready class) */
html.js-ready .fade-up {
  opacity: 0;
  transform: translateY(28px);
}

html.js-ready .fade-up.visible {
  opacity: 1;
  transform: translateY(0);
}

html.js-ready .fade-in {
  opacity: 0;
}

html.js-ready .fade-in.visible {
  opacity: 1;
}

/* Respect reduced-motion preference */
@media (prefers-reduced-motion: reduce) {
  html.js-ready .fade-up,
  html.js-ready .fade-in {
    opacity: 1;
    transform: none;
    transition: none;
  }
}

