/* ==========================================================================
   22B1 Design System - Base Styles
   Reset, typography, and foundational styles
   ========================================================================== */

/* ==========================================================================
   CSS RESET
   ========================================================================== */

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

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

body {
    font-family: var(--font-body);
    font-size: var(--text-md);
    font-weight: var(--font-weight-normal);
    line-height: 1.75;
    color: var(--color-text-secondary);
    background-color: var(--color-bg);
    min-height: 100vh;
}

/* Remove default list styling */
ul, ol {
    list-style: none;
}

/* Remove default link styling */
a {
    color: inherit;
    text-decoration: none;
}

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

/* Form elements inherit font */
input, button, textarea, select {
    font: inherit;
    color: inherit;
}

/* Remove default button styling */
button {
    background: none;
    border: none;
    cursor: pointer;
}

/* Tables */
table {
    border-collapse: collapse;
    border-spacing: 0;
}

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

/* Headings */
h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-heading);
    font-weight: var(--font-weight-semibold);
    line-height: var(--leading-tight);
    color: var(--color-text-primary);
    letter-spacing: var(--tracking-tight);
}

h1 {
    font-size: var(--text-4xl);
    font-weight: var(--font-weight-bold);
    letter-spacing: var(--tracking-tighter);
    line-height: 1.1;
}

h2 {
    font-size: var(--text-2xl);
    font-weight: var(--font-weight-bold);
    margin-bottom: var(--space-6);
    letter-spacing: var(--tracking-tight);
}

h3 {
    font-size: var(--text-xl);
    font-weight: var(--font-weight-semibold);
    margin-bottom: var(--space-4);
}

h4 {
    font-size: var(--text-lg);
    margin-bottom: var(--space-3);
}

h5 {
    font-size: var(--text-base);
    font-weight: var(--font-weight-semibold);
    margin-bottom: var(--space-2);
}

h6 {
    font-size: var(--text-sm);
    font-weight: var(--font-weight-semibold);
    text-transform: uppercase;
    letter-spacing: var(--tracking-wider);
    margin-bottom: var(--space-2);
}

/* Paragraphs */
p {
    margin-bottom: var(--space-4);
    max-width: var(--content-width);
}

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

/* Lead text */
.lead {
    font-size: var(--text-lg);
    color: var(--color-text-secondary);
    line-height: var(--leading-relaxed);
    max-width: var(--content-width);
}

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

.text-xs {
    font-size: var(--text-xs);
}

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

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

/* Content links (within body text) */
.content a,
.article-content a,
p a {
    text-decoration: underline;
    text-decoration-color: var(--color-border-strong);
    text-underline-offset: 2px;
    transition: all var(--duration-fast) var(--ease-out);
}

.content a:hover,
.article-content a:hover,
p a:hover {
    text-decoration-color: var(--color-link-hover);
}

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

em, i {
    font-style: italic;
}

/* Blockquotes */
blockquote {
    font-size: var(--text-lg);
    font-style: italic;
    color: var(--color-text-secondary);
    border-left: 3px solid var(--color-brand-gold);
    padding-left: var(--space-6);
    margin: var(--space-8) 0;
    max-width: var(--content-width);
}

blockquote cite {
    display: block;
    font-size: var(--text-sm);
    font-style: normal;
    color: var(--color-text-tertiary);
    margin-top: var(--space-3);
}

blockquote cite::before {
    content: '— ';
}

/* Code */
code {
    font-family: var(--font-mono);
    font-size: 0.9em;
    background: var(--color-bg-surface);
    padding: var(--space-1) var(--space-2);
    border-radius: var(--radius-sm);
    color: var(--color-text-primary);
}

pre {
    font-family: var(--font-mono);
    font-size: var(--text-sm);
    background: var(--color-bg-surface);
    color: var(--color-text-primary);
    padding: var(--space-6);
    border-radius: var(--radius-lg);
    border: 1px solid var(--color-border);
    overflow-x: auto;
    margin: var(--space-6) 0;
}

pre code {
    background: none;
    padding: 0;
    font-size: inherit;
}

/* Lists (styled) */
.content ul,
.content ol,
.article-content ul,
.article-content ol {
    padding-left: var(--space-6);
    margin-bottom: var(--space-6);
}

.content ul {
    list-style: disc;
}

.content ol {
    list-style: decimal;
}

.content li,
.article-content li {
    margin-bottom: var(--space-2);
    padding-left: var(--space-2);
}

.content li::marker,
.article-content li::marker {
    color: var(--color-brand-gold);
}

/* Horizontal rule */
hr {
    border: none;
    border-top: 1px solid var(--color-border);
    margin: var(--space-8) 0;
}

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

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

/* Text colors */
.text-primary { color: var(--color-text-primary); }
.text-secondary { color: var(--color-text-secondary); }
.text-tertiary { color: var(--color-text-tertiary); }
.text-muted { color: var(--color-text-muted); }
.text-gold { color: var(--color-brand-gold); }
.text-success { color: var(--color-success); }
.text-warning { color: var(--color-warning); }
.text-error { color: var(--color-error); }

/* Font families */
.font-heading { font-family: var(--font-heading); }
.font-body { font-family: var(--font-body); }
.font-mono { font-family: var(--font-mono); }
.font-ui { font-family: var(--font-ui); }

/* Font weights */
.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); }

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

/* Flex utilities */
.flex-col { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.items-start { align-items: flex-start; }
.items-center { align-items: center; }
.items-end { align-items: flex-end; }
.justify-start { justify-content: flex-start; }
.justify-center { justify-content: center; }
.justify-end { justify-content: flex-end; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.gap-6 { gap: var(--space-6); }
.gap-8 { gap: var(--space-8); }

/* Margin utilities */
.m-0 { margin: 0; }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
.mt-4 { margin-top: var(--space-4); }
.mt-6 { margin-top: var(--space-6); }
.mt-8 { margin-top: var(--space-8); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-6 { margin-bottom: var(--space-6); }
.mb-8 { margin-bottom: var(--space-8); }

/* Padding utilities */
.p-0 { padding: 0; }
.p-4 { padding: var(--space-4); }
.p-6 { padding: var(--space-6); }
.p-8 { padding: var(--space-8); }

/* Width utilities */
.w-full { width: 100%; }
.max-w-content { max-width: var(--content-width); }
.max-w-content-wide { max-width: var(--content-width-wide); }

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

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

/* Focus styles */
:focus-visible {
    outline: 3px solid var(--color-brand-gold);
    outline-offset: 3px;
    border-radius: var(--radius-sm);
}

/* High contrast focus for critical elements */
button:focus-visible,
a:focus-visible {
    outline: 3px solid var(--color-brand-gold);
    outline-offset: 3px;
}

/* Skip link */
.skip-link {
    position: absolute;
    top: -100%;
    left: var(--space-4);
    padding: var(--space-3) var(--space-6);
    background: var(--color-brand-gold);
    color: var(--color-text-inverse);
    font-family: var(--font-ui);
    font-weight: var(--font-weight-semibold);
    border-radius: var(--radius-md);
    z-index: var(--z-tooltip);
    transition: top var(--duration-fast);
}

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

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

/* ==========================================================================
   SELECTION
   ========================================================================== */

::selection {
    background: var(--color-brand-gold);
    color: var(--color-text-inverse);
}

::-moz-selection {
    background: var(--color-brand-gold);
    color: var(--color-text-inverse);
}
