/**
 * MAIN GLOBAL STYLES
 * 
 * Core styles applied site-wide: typography, layout structure, and
 * base element styling. Works with variables.css and reset.css.
 */

/* ===== BODY & ROOT ===== */
body {
  background-color: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font-primary);
  font-size: var(--font-size-base);
  line-height: var(--line-height-normal);
  /* Prevent horizontal scroll on mobile */
  overflow-x: hidden;
}

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

/* Headings */
h1 {
  font-family: var(--font-headings);
  font-size: var(--font-size-5xl);
  font-weight: var(--font-weight-bold);
  line-height: var(--line-height-tight);
  color: var(--text-primary);
  margin-bottom: var(--space-lg);
}

h2 {
  font-family: var(--font-headings);
  font-size: var(--font-size-4xl);
  font-weight: var(--font-weight-bold);
  line-height: var(--line-height-tight);
  color: var(--text-primary);
  margin-bottom: var(--space-md);
}

h3 {
  font-family: var(--font-headings);
  font-size: var(--font-size-3xl);
  font-weight: var(--font-weight-semibold);
  line-height: var(--line-height-tight);
  color: var(--text-primary);
  margin-bottom: var(--space-md);
}

h4 {
  font-family: var(--font-headings);
  font-size: var(--font-size-2xl);
  font-weight: var(--font-weight-semibold);
  line-height: var(--line-height-normal);
  color: var(--text-primary);
  margin-bottom: var(--space-sm);
}

h5 {
  font-family: var(--font-headings);
  font-size: var(--font-size-xl);
  font-weight: var(--font-weight-medium);
  line-height: var(--line-height-normal);
  color: var(--text-primary);
  margin-bottom: var(--space-sm);
}

h6 {
  font-family: var(--font-headings);
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-medium);
  line-height: var(--line-height-normal);
  color: var(--text-secondary);
  margin-bottom: var(--space-sm);
}

/* Paragraphs */
p {
  margin-bottom: var(--space-md);
  color: var(--text-secondary);
  max-width: var(--max-width-text);
}

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

/* Links */
a {
  color: var(--link-blue);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover {
  color: var(--accent-soft);
  text-decoration: underline;
}

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

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

em, i {
  font-style: italic;
  color: var(--text-primary);
}

/* Code */
code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  background-color: var(--bg-code);
  color: var(--accent-soft);
  padding: 0.2em 0.4em;
  border-radius: var(--radius-sm);
}

pre {
  background-color: var(--bg-code);
  color: var(--text-primary);
  padding: var(--space-md);
  border-radius: var(--radius-md);
  overflow-x: auto;
  margin-bottom: var(--space-md);
  border: 1px solid var(--border-primary);
}

pre code {
  background: none;
  padding: 0;
  color: inherit;
}

/* Lists */
ul, ol {
  margin-bottom: var(--space-md);
  padding-left: var(--space-xl);
}

ul {
  list-style: disc;
}

ol {
  list-style: decimal;
}

li {
  margin-bottom: var(--space-sm);
  color: var(--text-secondary);
}

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

/* Blockquotes */
blockquote {
  border-left: 4px solid var(--accent-primary);
  padding-left: var(--space-lg);
  margin: var(--space-lg) 0;
  font-style: italic;
  color: var(--text-secondary);
}

/* Horizontal rule */
hr {
  border: none;
  height: 1px;
  background-color: var(--border-primary);
  margin: var(--space-2xl) 0;
}

/* ===== LAYOUT STRUCTURE ===== */

/* Main container - centers content and sets max width */
.container {
  width: 100%;
  max-width: var(--max-width-content);
  margin: 0 auto;
  padding: 0 var(--space-md);
}

@media (min-width: 768px) {
  .container {
    padding: 0 var(--space-xl);
  }
}

@media (min-width: 1024px) {
  .container {
    padding: 0 var(--space-2xl);
  }
}

/* Main content area - accounts for fixed header */
main {
  min-height: calc(100vh - var(--header-height));
  /* Add header height + extra spacing to push content below fixed header */
  padding-top: calc(var(--header-height) + var(--space-2xl));
  padding-bottom: var(--space-3xl);
}

/* Section spacing */
section {
  margin-bottom: var(--space-3xl);
}

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

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

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

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

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

/* Text colors */
.text-primary {
  color: var(--text-primary);
}

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

.text-muted {
  color: var(--text-muted);
}

.text-accent {
  color: var(--accent-primary);
}

/* Visibility */
.sr-only {
  /* Screen reader only - visually hidden but accessible */
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

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

/* Skip to main content link */
.skip-link {
  position: absolute;
  top: -100px;
  left: var(--space-md);
  background-color: var(--accent-primary);
  color: white;
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-md);
  z-index: var(--z-toast);
  transition: top var(--transition-fast);
}

.skip-link:focus {
  top: var(--space-md);
}

/* Focus visible styles for keyboard navigation */
*:focus-visible {
  outline: 2px solid var(--accent-primary);
  outline-offset: 2px;
}

/* ===== IMAGES ===== */

img {
  border-radius: var(--radius-md);
}

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

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

/* ===== SCROLLBAR (Webkit browsers) ===== */
::-webkit-scrollbar {
  width: 12px;
  height: 12px;
}

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

::-webkit-scrollbar-thumb {
  background: var(--border-primary);
  border-radius: var(--radius-md);
}

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