/**
 * BigCat Codeworks Base Styles
 * Reset, typography, and basic element styling
 * 
 * Import order: _tokens.css → base.css → layout.css → components → utilities
 */

/* ===== CSS RESET & NORMALIZE ===== */

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

* {
  margin: 0;
  padding: 0;
}

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

/* Ensure anchor targets are not hidden behind fixed header */
:target {
  scroll-margin-top: var(--header-height);
}

body {
  line-height: var(--line-height-normal);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

main {
  display: block;
  /* Header spacing is now handled dynamically by JavaScript */
  /* Safety padding to ensure content is never hidden behind fixed header */
  padding-top: 6rem; /* 96px - provides extra buffer above minimum header height */
}

/* Fallback for when JavaScript is not available */
main:not([style*="padding-top"]) {
  padding-top: 5rem; /* 80px fallback */
}

h1, h2, h3, h4, h5, h6 {
  font-size: inherit;
  font-weight: inherit;
}

p, h1, h2, h3, h4, h5, h6 {
  overflow-wrap: break-word;
}

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

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

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

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

ul, ol {
  list-style: none;
}

/* ===== TYPOGRAPHY ===== */

body {
  font-family: var(--font-body);
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-normal);
  line-height: var(--line-height-normal);
  color: var(--color-text-primary);
  background-color: var(--color-bg-primary);
}

/* Headings */
h1, .h1 {
  font-family: var(--font-hero);
  font-size: var(--font-size-6xl);
  font-weight: var(--font-weight-bold);
  line-height: var(--line-height-tight);
  color: var(--color-text-primary);
}

h2, .h2 {
  font-family: var(--font-heading);
  font-size: var(--font-size-5xl);
  font-weight: var(--font-weight-semibold);
  line-height: var(--line-height-tight);
  color: var(--color-text-primary);
}

h3, .h3 {
  font-family: var(--font-heading);
  font-size: var(--font-size-4xl);
  font-weight: var(--font-weight-semibold);
  line-height: var(--line-height-tight);
  color: var(--color-text-primary);
}

h4, .h4 {
  font-family: var(--font-heading);
  font-size: var(--font-size-3xl);
  font-weight: var(--font-weight-medium);
  line-height: var(--line-height-tight);
  color: var(--color-text-primary);
}

h5, .h5 {
  font-family: var(--font-heading);
  font-size: var(--font-size-2xl);
  font-weight: var(--font-weight-medium);
  line-height: var(--line-height-normal);
  color: var(--color-text-primary);
}

h6, .h6 {
  font-family: var(--font-heading);
  font-size: var(--font-size-xl);
  font-weight: var(--font-weight-medium);
  line-height: var(--line-height-normal);
  color: var(--color-text-primary);
}

/* Hero Text */
.hero-text {
  font-family: var(--font-hero);
  font-size: var(--font-size-5xl);
  font-weight: var(--font-weight-bold);
  line-height: var(--line-height-tight);
  color: var(--color-text-primary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.hero-text--large {
  font-size: var(--font-size-6xl);
}

.hero-text--small {
  font-size: var(--font-size-4xl);
}

/* Terminal/Code Text */
.terminal-text {
  font-family: var(--font-terminal);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-normal);
  line-height: var(--line-height-normal);
  color: var(--color-text-secondary);
}

/* Paragraphs */
p {
  margin-bottom: var(--spacing-4);
  color: var(--color-text-primary);
}

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

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

.text-small {
  font-size: var(--font-size-sm);
  line-height: var(--line-height-normal);
}

.text-large {
  font-size: var(--font-size-lg);
  line-height: var(--line-height-relaxed);
}

/* Links */
a {
  color: var(--color-primary);
  text-decoration: none;
  transition: color var(--duration-fast) var(--ease-cyber-out);
}

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

a:focus {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

/* ===== BASIC ELEMENTS ===== */

/* Buttons */
button {
  font-family: var(--font-body);
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-medium);
  line-height: var(--line-height-normal);
  padding: var(--spacing-3) var(--spacing-4);
  border-radius: var(--radius-base);
  transition: all var(--duration-fast) var(--ease-cyber-out);
}

button:focus {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

/* Form Elements */
input, textarea, select {
  font-family: var(--font-body);
  font-size: var(--font-size-base);
  line-height: var(--line-height-normal);
  padding: var(--spacing-3);
  border: 1px solid var(--color-bg-tertiary);
  border-radius: var(--radius-base);
  background-color: var(--color-bg-secondary);
  color: var(--color-text-primary);
  transition: border-color var(--duration-fast) var(--ease-cyber-out);
}

input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(255, 0, 255, 0.1);
}

/* ===== UTILITY CLASSES ===== */

/* Text Colors */
.text-primary { color: var(--color-text-primary); }
.text-secondary { color: var(--color-text-secondary); }
.text-muted { color: var(--color-text-muted); }
.text-inverse { color: var(--color-text-inverse); }

.text-cyber-pink { color: var(--color-primary); }
.text-cyber-blue { color: var(--color-secondary); }
.text-cyber-cyan { color: var(--color-tertiary); }
.text-cyber-green { color: var(--color-cyber-green); }
.text-warning { color: var(--color-warning-orange); }
.text-error { color: var(--color-infrared-red); }

/* Text Alignment */
.text-left { text-align: left; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-justify { text-align: justify; }

/* Font Weights */
.font-light { font-weight: var(--font-weight-light); }
.font-normal { font-weight: var(--font-weight-normal); }
.font-medium { font-weight: var(--font-weight-medium); }
.font-semibold { font-weight: var(--font-weight-semibold); }
.font-bold { font-weight: var(--font-weight-bold); }
.font-extrabold { font-weight: var(--font-weight-extrabold); }
.font-black { font-weight: var(--font-weight-black); }

/* Font Families */
.font-hero { font-family: var(--font-hero); }
.font-heading { font-family: var(--font-heading); }
.font-body { font-family: var(--font-body); }
.font-terminal { font-family: var(--font-terminal); }

/* ===== ACCESSIBILITY ===== */

/* Skip Links */
.skip-link {
  position: absolute;
  top: -40px;
  left: 6px;
  background: var(--color-primary);
  color: var(--color-text-inverse);
  padding: 8px;
  text-decoration: none;
  border-radius: var(--radius-base);
  z-index: var(--z-tooltip);
  transition: top var(--duration-normal) var(--ease-cyber-out);
}

.skip-link:focus {
  top: 6px;
}

/* Focus Indicators */
.focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

/* Screen Reader Only */
.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;
}

/* ===== PRINT STYLES ===== */

@media print {
  * {
    background: transparent !important;
    color: black !important;
    box-shadow: none !important;
    text-shadow: none !important;
  }
  
  a, a:visited {
    text-decoration: underline;
  }
  
  a[href]:after {
    content: " (" attr(href) ")";
  }
  
  abbr[title]:after {
    content: " (" attr(title) ")";
  }
  
  pre, blockquote {
    border: 1px solid #999;
    page-break-inside: avoid;
  }
  
  thead {
    display: table-header-group;
  }
  
  tr, img {
    page-break-inside: avoid;
  }
  
  img {
    max-width: 100% !important;
  }
  
  p, h2, h3 {
    orphans: 3;
    widows: 3;
  }
  
  h2, h3 {
    page-break-after: avoid;
  }
}

/* ===== RESPONSIVE HEADER SPACING ===== */
/* Header height is now calculated dynamically by JavaScript */

/* Additional safety padding for mobile devices */
@media (max-width: 767px) {
  main {
    padding-top: 7rem; /* 112px - extra safety buffer for mobile */
  }
}

@media (max-width: 480px) {
  main {
    padding-top: 8rem; /* 128px - maximum safety buffer for small screens */
  }
}
