/* ============================================================
   Base Styles — CSS Reset, Global Defaults & Utility Classes
   ============================================================ */

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

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

body {
  font-family: var(--font-family-primary);
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-regular);
  line-height: var(--line-height-normal);
  color: var(--color-text-primary);
  background-color: var(--color-bg-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
  min-height: 100vh;
  min-height: 100dvh;
  animation: pageLoad 0.4s ease both;
}

/* Subtle page entrance — entire viewport fades from near-black */
@keyframes pageLoad {
  from { opacity: 0; }
  to   { opacity: 1; }
}

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

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

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

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

ul,
ol {
  list-style: none;
}

h1, h2, h3, h4, h5, h6 {
  font-weight: var(--font-weight-semibold);
  line-height: var(--line-height-tight);
  overflow-wrap: break-word;
}

p {
  overflow-wrap: break-word;
}

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

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

::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.15);
  border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, 0.25);
}

/* Firefox scrollbar */
* {
  scrollbar-width: thin;
  scrollbar-color: rgba(0, 0, 0, 0.15) transparent;
}

/* ---- Selection Styling ---- */
::selection {
  background: rgba(0, 113, 227, 0.4);
  color: var(--color-text-primary);
}

::-moz-selection {
  background: rgba(0, 113, 227, 0.4);
  color: var(--color-text-primary);
}

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

/* ---- Utility Classes ---- */

/* Container */
.container {
  width: 100%;
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 0 var(--spacing-lg);
}

.container--wide {
  max-width: var(--container-wide);
}

.container--narrow {
  max-width: var(--container-narrow);
}

/* Section */
.section {
  padding: var(--spacing-4xl) 0;
}

.section--sm {
  padding: var(--spacing-2xl) 0;
}

.section--lg {
  padding: var(--spacing-5xl) 0;
}

/* Glass morphism */
.glass {
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow-glass);
}

.glass--strong {
  background: var(--glass-bg-strong);
  backdrop-filter: var(--glass-blur-strong);
  -webkit-backdrop-filter: var(--glass-blur-strong);
}

.glass--hoverable:hover {
  background: var(--color-surface-glass-hover);
  border-color: var(--glass-border-hover);
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

/* Gradient text */
.gradient-text {
  background: var(--color-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--spacing-sm);
  padding: var(--spacing-sm) var(--spacing-xl);
  border-radius: var(--radius-full);
  font-weight: var(--font-weight-medium);
  font-size: var(--font-size-base);
  transition: all var(--transition-base);
  white-space: nowrap;
  user-select: none;
  -webkit-user-select: none;
}

.btn--primary {
  background: var(--color-gradient);
  color: var(--color-text-primary);
  box-shadow: var(--shadow-glow);
}

.btn--primary:hover {
  transform: scale(1.05);
  box-shadow: var(--shadow-glow-strong);
}

.btn--primary:active {
  transform: scale(0.98);
}

.btn--secondary {
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border);
  color: var(--color-text-primary);
}

.btn--secondary:hover {
  background: var(--color-surface-glass-hover);
  border-color: var(--glass-border-hover);
  transform: translateY(-1px);
}

.btn--ghost {
  color: var(--color-text-secondary);
}

.btn--ghost:hover {
  color: var(--color-text-primary);
  background: rgba(0, 0, 0, 0.04);
}

.btn--sm {
  padding: var(--spacing-xs) var(--spacing-md);
  font-size: var(--font-size-sm);
}

.btn--lg {
  padding: var(--spacing-md) var(--spacing-2xl);
  font-size: var(--font-size-lg);
}

/* Section titles */
.section__title {
  font-size: var(--font-size-3xl);
  font-weight: var(--font-weight-bold);
  text-align: center;
  margin-bottom: var(--spacing-sm);
}

.section__subtitle {
  font-size: var(--font-size-lg);
  color: var(--color-text-secondary);
  text-align: center;
  max-width: 600px;
  margin: 0 auto var(--spacing-2xl);
  line-height: var(--line-height-relaxed);
}

/* Visually hidden (accessible) */
.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;
}

/* Skeleton loading */
.skeleton {
  background: linear-gradient(
    90deg,
    var(--color-bg-tertiary) 25%,
    var(--color-bg-secondary) 50%,
    var(--color-bg-tertiary) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
  border-radius: var(--radius-sm);
}

@keyframes shimmer {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

/* Responsive text alignment */
.text-center {
  text-align: center;
}

.text-left {
  text-align: left;
}

/* Spacing helpers */
.mt-md { margin-top: var(--spacing-md); }
.mt-lg { margin-top: var(--spacing-lg); }
.mt-xl { margin-top: var(--spacing-xl); }
.mb-md { margin-bottom: var(--spacing-md); }
.mb-lg { margin-bottom: var(--spacing-lg); }
.mb-xl { margin-bottom: var(--spacing-xl); }

/* ---- Container Widths ---- */
.container {
  width: 100%;
  max-width: 1200px;
  margin-left: auto;
  margin-right: auto;
  padding-left: var(--spacing-md);
  padding-right: var(--spacing-md);
}

.container--narrow {
  max-width: 800px;
}

.container--wide {
  max-width: 1400px;
}

/* ---- Responsive Images ---- */
img {
  max-width: 100%;
  height: auto;
  display: block;
}

/* Responsive images within content */
.content img,
.article img,
.post img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-md);
}

/* ---- Responsive Typography ---- */
@media (max-width: 479px) {
  html {
    font-size: 14px;
  }
}

@media (min-width: 1920px) {
  html {
    font-size: 18px;
  }
}

/* ---- Touch-friendly targets ---- */
@media (pointer: coarse) {
  button,
  a,
  input,
  select,
  textarea,
  [role="button"] {
    min-height: 44px;
    min-width: 44px;
  }
  
  /* Larger touch targets for small screens */
  @media (max-width: 767px) {
    button,
    a,
    input,
    select,
    textarea,
    [role="button"] {
      min-height: 48px;
    }
  }
}

/* ---- Safe Area Insets for notched devices ---- */
@supports (padding: max(0px)) {
  .navbar__inner,
  .container,
  .footer__inner {
    padding-left: max(var(--spacing-md), env(safe-area-inset-left));
    padding-right: max(var(--spacing-md), env(safe-area-inset-right));
  }
  
  body {
    padding-bottom: max(0px, env(safe-area-inset-bottom));
  }
}

/* ---- Print Styles ---- */
@media print {
  .no-print {
    display: none !important;
  }
  
  body {
    background: white;
    color: black;
  }
  
  a {
    text-decoration: underline;
  }
  
  a[href]::after {
    content: " (" attr(href) ")";
  }
}

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

/* ---- High Contrast Mode ---- */
@media (prefers-contrast: high) {
  :root {
    --color-border: rgba(0, 0, 0, 0.3);
    --color-text-secondary: #333333;
  }
  
  .btn,
  button,
  input,
  select,
  textarea {
    border-width: 2px;
  }
}

/* ---- Dark Mode Support (for future use) ---- */
@media (prefers-color-scheme: dark) {
  /* Dark mode styles can be added here when needed */
}
