/* ============================================
   BASE STYLES
   Reset, typography, global foundation
   ============================================ */

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

html {
  scroll-behavior: smooth;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body {
  font-family: var(--font-body);
  font-size: var(--text-base);
  font-weight: var(--weight-normal);
  line-height: var(--leading-relaxed);
  color: var(--text-primary);
  background: var(--bg-primary);
  overflow-x: hidden;
  min-height: 100vh;
  position: relative;
}

/* ===== NOISE TEXTURE OVERLAY ===== */
body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  opacity: var(--noise-opacity);
  background-image: var(--noise-pattern);
  background-repeat: repeat;
  z-index: var(--z-max);
  mix-blend-mode: overlay;
}

/* ===== TYPOGRAPHY ===== */
/* Headings - Bold, distinctive display font */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  font-weight: var(--weight-bold);
  line-height: var(--leading-tight);
  letter-spacing: var(--tracking-wide);
  text-transform: var(--heading-transform, uppercase);
  color: var(--heading-color, var(--accent));
  margin-bottom: var(--space-4);
}

h1 {
  font-size: clamp(var(--text-5xl), 10vw, var(--text-8xl));
  letter-spacing: var(--tracking-widest);
  line-height: var(--leading-none);
}

h2 {
  font-size: clamp(var(--text-4xl), 8vw, var(--text-6xl));
  letter-spacing: var(--tracking-wider);
}

h3 {
  font-size: clamp(var(--text-3xl), 5vw, var(--text-5xl));
}

h4 {
  font-size: clamp(var(--text-2xl), 3vw, var(--text-3xl));
}

h5 {
  font-size: var(--text-xl);
}

h6 {
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
}

/* Paragraphs */
p {
  margin-bottom: var(--space-5);
  color: var(--text-secondary);
  line-height: var(--leading-relaxed);
}

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

p.lead {
  font-size: var(--text-lg);
  line-height: var(--leading-loose);
  color: var(--text-primary);
}

/* Links */
a {
  color: inherit;
  text-decoration: none;
  transition: color var(--transition-base);
  cursor: pointer;
}

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

a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: var(--radius-sm);
}

/* Strong & emphasis */
strong, b {
  font-weight: var(--weight-bold);
  color: var(--text-primary);
}

em {
  font-style: italic;
  color: var(--accent);
  font-weight: var(--weight-medium);
}

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

/* Code & pre */
code {
  font-family: 'Courier New', monospace;
  font-size: 0.9em;
  padding: 0.125rem 0.375rem;
  background: var(--bg-tertiary);
  border: var(--border-1) solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--accent);
}

pre {
  font-family: 'Courier New', monospace;
  font-size: var(--text-sm);
  padding: var(--space-4);
  background: var(--bg-tertiary);
  border: var(--border-1) solid var(--border-color);
  border-radius: var(--radius-md);
  overflow-x: auto;
  margin-bottom: var(--space-5);
}

pre code {
  background: none;
  border: none;
  padding: 0;
}

/* Blockquotes */
blockquote {
  padding: var(--space-6);
  padding-left: var(--space-8);
  border-left: var(--border-4) solid var(--accent-secondary);
  margin-bottom: var(--space-5);
  font-style: italic;
  color: var(--text-secondary);
  background: var(--bg-card);
  border-radius: var(--radius-md);
}

blockquote p:last-child {
  margin-bottom: 0;
}

/* Horizontal rule */
hr {
  border: none;
  height: var(--border-2);
  background: linear-gradient(
    90deg,
    transparent 0%,
    var(--border-color) 20%,
    var(--border-strong) 50%,
    var(--border-color) 80%,
    transparent 100%
  );
  margin: var(--space-12) 0;
}

/* ===== LISTS ===== */
ul, ol {
  list-style: none;
}

ul.styled, ol.styled {
  padding-left: var(--space-6);
  margin-bottom: var(--space-5);
}

ul.styled {
  list-style: none;
}

ul.styled li {
  position: relative;
  padding-left: var(--space-4);
  margin-bottom: var(--space-3);
  color: var(--text-secondary);
}

ul.styled li::before {
  content: '▸';
  position: absolute;
  left: 0;
  color: var(--accent-secondary);
  font-weight: var(--weight-bold);
}

ol.styled {
  list-style: none;
  counter-reset: styled-counter;
}

ol.styled li {
  position: relative;
  padding-left: var(--space-8);
  margin-bottom: var(--space-3);
  color: var(--text-secondary);
  counter-increment: styled-counter;
}

ol.styled li::before {
  content: counter(styled-counter) '.';
  position: absolute;
  left: 0;
  color: var(--accent-secondary);
  font-weight: var(--weight-bold);
  font-family: var(--font-display);
}

/* ===== IMAGES & MEDIA ===== */
img, picture, video, canvas, svg {
  display: block;
  max-width: 100%;
  height: auto;
}

img {
  border-style: none;
}

figure {
  margin: 0;
}

figcaption {
  font-size: var(--text-sm);
  color: var(--text-muted);
  text-align: center;
  margin-top: var(--space-3);
}

/* ===== EMBEDDED CONTENT ===== */
iframe {
  border: 0;
  display: block;
}

/* ===== FORMS ===== */
button, input, optgroup, select, textarea {
  font-family: inherit;
  font-size: 100%;
  line-height: inherit;
  margin: 0;
}

button, select {
  text-transform: none;
}

button, [type='button'], [type='reset'], [type='submit'] {
  -webkit-appearance: button;
  cursor: pointer;
}

button:disabled, [disabled] {
  cursor: not-allowed;
  opacity: 0.5;
}

input, textarea, select {
  outline: none;
}

textarea {
  resize: vertical;
}

/* ===== UTILITY CLASSES ===== */
/* Text colors */
.text-primary { color: var(--text-primary) !important; }
.text-secondary { color: var(--text-secondary) !important; }
.text-muted { color: var(--text-muted) !important; }
.text-accent { color: var(--accent) !important; }
.text-gold { color: var(--accent-secondary) !important; }
.text-inverse { color: var(--text-inverse) !important; }

/* Text alignment */
.text-left { text-align: left !important; }
.text-center { text-align: center !important; }
.text-right { text-align: right !important; }
.text-justify { text-align: justify !important; }

/* Text transform */
.uppercase { text-transform: uppercase !important; }
.lowercase { text-transform: lowercase !important; }
.capitalize { text-transform: capitalize !important; }
.normal-case { text-transform: none !important; }

/* Font weight */
.font-light { font-weight: var(--weight-light) !important; }
.font-normal { font-weight: var(--weight-normal) !important; }
.font-medium { font-weight: var(--weight-medium) !important; }
.font-semibold { font-weight: var(--weight-semibold) !important; }
.font-bold { font-weight: var(--weight-bold) !important; }

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

/* Visibility */
.invisible { visibility: hidden !important; }
.visible { visibility: visible !important; }

/* ===== LAYOUT CONTAINERS ===== */
.container {
  width: 100%;
  max-width: var(--max-width-content);
  margin: 0 auto;
  padding-left: var(--space-6);
  padding-right: var(--space-6);
}

.container-narrow {
  width: 100%;
  max-width: var(--max-width-narrow);
  margin: 0 auto;
  padding-left: var(--space-6);
  padding-right: var(--space-6);
}

.container-wide {
  width: 100%;
  max-width: var(--max-width-wide);
  margin: 0 auto;
  padding-left: var(--space-6);
  padding-right: var(--space-6);
}

.container-full {
  width: 100%;
  padding-left: var(--space-6);
  padding-right: var(--space-6);
}

/* ===== SECTIONS ===== */
.section {
  padding: var(--space-24) 0;
  position: relative;
}

.section-sm {
  padding: var(--space-16) 0;
}

.section-lg {
  padding: var(--space-32) 0;
}

.section-xl {
  padding: var(--space-40) 0;
}

.section-dark {
  background: var(--bg-secondary);
}

.section-darker {
  background: var(--bg-primary);
}

/* Section headers */
.section-header {
  margin-bottom: var(--space-16);
}

.section-header.center {
  text-align: center;
  max-width: var(--max-width-narrow);
  margin-left: auto;
  margin-right: auto;
  margin-bottom: var(--space-16);
}

.section-tag {
  display: inline-block;
  font-family: var(--font-body);
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
  text-transform: uppercase;
  letter-spacing: var(--tracking-ultra);
  color: var(--accent-secondary);
  margin-bottom: var(--space-4);
  position: relative;
  padding-left: 60px;
}

.section-tag::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 48px;
  height: 2px;
  background: var(--accent-secondary);
}

.section-header.center .section-tag {
  padding-left: 0;
}

.section-header.center .section-tag::before {
  display: none;
}

.section-title {
  margin-bottom: var(--space-5);
}

.section-subtitle {
  font-size: var(--text-lg);
  color: var(--text-secondary);
  line-height: var(--leading-relaxed);
}

.section-header.center .section-subtitle {
  max-width: 600px;
  margin-left: auto;
  margin-right: auto;
}

/* ===== GRID UTILITIES ===== */
.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-12);
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-8);
}

.grid-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-8);
}

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

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

@media (max-width: 768px) {
  .grid-2 {
    grid-template-columns: 1fr;
  }

  .grid-3,
  .grid-4 {
    grid-template-columns: 1fr;
  }
}

/* ===== ASPECT RATIO BOXES ===== */
.aspect-ratio {
  position: relative;
  overflow: hidden;
}

.aspect-ratio::before {
  content: '';
  display: block;
  padding-bottom: 100%; /* Default 1:1 */
}

.aspect-ratio-square::before { padding-bottom: 100%; }
.aspect-ratio-16-9::before { padding-bottom: 56.25%; }
.aspect-ratio-4-3::before { padding-bottom: 75%; }
.aspect-ratio-3-2::before { padding-bottom: 66.66%; }
.aspect-ratio-2-1::before { padding-bottom: 50%; }
.aspect-ratio-21-9::before { padding-bottom: 42.86%; }

.aspect-ratio > * {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

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

/* Focus styles - premium accent ring */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: var(--radius-sm);
}

button:focus-visible,
a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

/* Skip to content link */
.skip-to-content {
  position: absolute;
  top: -100%;
  left: 50%;
  transform: translateX(-50%);
  padding: var(--space-4) var(--space-6);
  background: var(--accent);
  color: var(--text-primary);
  font-weight: var(--weight-bold);
  border-radius: var(--radius-base);
  z-index: var(--z-max);
  transition: top var(--transition-fast);
}

.skip-to-content:focus {
  top: var(--space-4);
}

/* ===== SELECTION ===== */
::selection {
  background-color: var(--accent-secondary);
  color: var(--text-primary);
}

::-moz-selection {
  background-color: var(--accent-secondary);
  color: var(--text-primary);
}

/* ===== SCROLLBAR - STYLED TO MATCH THEME ===== */
/* Firefox */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--accent-secondary) var(--bg-tertiary);
}

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

::-webkit-scrollbar-track {
  background: var(--bg-tertiary);
  border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb {
  background: var(--accent-secondary);
  border-radius: var(--radius-full);
  border: 2px solid var(--bg-tertiary);
  transition: background var(--transition-fast);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--accent-secondary-hover);
}

::-webkit-scrollbar-corner {
  background: var(--bg-tertiary);
}

/* ===== SCROLL REVEAL ANIMATIONS ===== */
/* Elements with [data-reveal] start hidden and animate in when .revealed is added */

[data-reveal] {
  opacity: 0;
  will-change: opacity, transform;
  transition:
    opacity 0.7s var(--ease-out),
    transform 0.7s var(--ease-out);
}

[data-reveal].revealed {
  opacity: 1;
  transform: none;
}

/* Fade Up (default) */
[data-reveal="fade-up"] {
  transform: translateY(40px);
}

/* Fade In (opacity only) */
[data-reveal="fade-in"] {
  transform: none;
}

/* Scale Up */
[data-reveal="scale-up"] {
  transform: scale(0.92);
}

/* Stagger delay support - only before reveal so it doesn't affect hover transitions */
[data-reveal]:not(.revealed)[style*="--delay"] {
  transition-delay: var(--delay);
}

/* ===== PAGE TRANSITIONS ===== */
/* Smooth fade between pages. Body fades in via CSS animation on load,
   and fades out with .page-leaving class before navigation. */

@keyframes pageFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

body {
  animation: pageFadeIn 0.3s var(--ease-smooth) both;
}

body.page-leaving {
  opacity: 0;
  animation: none;
  transition: opacity 0.2s var(--ease-in);
}

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

/* ===== RESPONSIVE BREAKPOINTS ===== */
@media (max-width: 1024px) {
  html {
    font-size: 15px;
  }
  
  .container, .container-narrow, .container-wide {
    padding-left: var(--space-5);
    padding-right: var(--space-5);
  }
  
  .section {
    padding: var(--space-20) 0;
  }
  
  .section-lg {
    padding: var(--space-24) 0;
  }
  
  .section-header {
    margin-bottom: var(--space-12);
  }
}

@media (max-width: 768px) {
  .section {
    padding: var(--space-16) 0;
  }
  
  .section-lg {
    padding: var(--space-20) 0;
  }
  
  .section-header {
    margin-bottom: var(--space-10);
  }
  
  .section-tag {
    padding-left: 0;
  }
  
  .section-tag::before {
    display: none;
  }
}

@media (max-width: 640px) {
  html {
    font-size: 14px;
  }
  
  .container, .container-narrow, .container-wide {
    padding-left: var(--space-4);
    padding-right: var(--space-4);
  }
  
  .section {
    padding: var(--space-12) 0;
  }
  
  .section-lg {
    padding: var(--space-16) 0;
  }
}

/* ===== PRINT STYLES ===== */
@media print {
  body {
    background: white;
    color: black;
  }
  
  body::before {
    display: none;
  }
  
  a {
    text-decoration: underline;
  }
  
  .no-print {
    display: none !important;
  }
}
