/* ==========================================================================
   Typography System - ITCSS Layer 2 (Base)
   ========================================================================== */

/* Base typography styles */
html {
    font-family: var(--font-family-sans);
    font-size: var(--font-size-base);
    line-height: var(--line-height-normal);
    color: var(--sys-color-text-primary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

body {
    font-family: inherit;
    font-size: inherit;
    line-height: inherit;
    color: inherit;
    background-color: var(--sys-color-background-page);
}

/* Headings */
h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-family-sans);
    font-weight: var(--font-weight-bold);
    line-height: var(--line-height-tight);
    color: var(--sys-color-heading);
    margin-bottom: var(--spacing-md);
    letter-spacing: -0.025em;
}

h1 {
    font-size: var(--font-size-4xl);
    font-weight: var(--font-weight-bold);
    margin-bottom: var(--spacing-lg);
}

h2 {
    font-size: var(--font-size-3xl);
    font-weight: var(--font-weight-bold);
}

h3 {
    font-size: var(--font-size-2xl);
    font-weight: var(--font-weight-semibold);
}

h4 {
    font-size: var(--font-size-xl);
    font-weight: var(--font-weight-semibold);
}

h5 {
    font-size: var(--font-size-lg);
    font-weight: var(--font-weight-medium);
}

h6 {
    font-size: var(--font-size-base);
    font-weight: var(--font-weight-medium);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Paragraphs and text */
p {
    margin-bottom: var(--spacing-md);
    line-height: var(--line-height-normal);
    color: var(--sys-color-text-primary);
}

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

/* Links */
a {
    color: var(--sys-color-interactive);
    text-decoration: none;
    transition: color var(--transition-speed-fast) var(--transition-easing);
}

a:hover {
    color: var(--sys-color-interactive-hover);
    text-decoration: underline;
}

a:focus-visible {
    outline: 2px solid var(--sys-color-interactive);
    outline-offset: 2px;
    border-radius: var(--border-radius-xs);
}

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

em, i {
    font-style: italic;
}

small {
    font-size: var(--font-size-sm);
    color: var(--sys-color-text-secondary);
}

/* Code and preformatted text */
code {
    font-family: var(--font-family-mono);
    font-size: 0.875em;
    background-color: var(--sys-color-background-elevated);
    color: var(--sys-color-text-primary);
    padding: var(--spacing-xxs) var(--spacing-xs);
    border-radius: var(--border-radius-sm);
    border: var(--border-width-sm) solid var(--sys-color-border-subtle);
}

pre {
    font-family: var(--font-family-mono);
    font-size: var(--font-size-sm);
    background-color: var(--sys-color-background-elevated);
    color: var(--sys-color-text-primary);
    padding: var(--spacing-md);
    border-radius: var(--border-radius-md);
    border: var(--border-width-sm) solid var(--sys-color-border-subtle);
    overflow-x: auto;
    line-height: var(--line-height-normal);
    margin-bottom: var(--spacing-md);
}

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

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

ul {
    list-style-type: disc;
}

ol {
    list-style-type: decimal;
}

li {
    margin-bottom: var(--spacing-xs);
    line-height: var(--line-height-normal);
    color: var(--sys-color-text-primary);
}

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

/* Nested lists */
ul ul, ol ol, ul ol, ol ul {
    margin-top: var(--spacing-xs);
    margin-bottom: 0;
}

/* Definition lists */
dl {
    margin-bottom: var(--spacing-md);
}

dt {
    font-weight: var(--font-weight-semibold);
    color: var(--sys-color-text-primary);
    margin-bottom: var(--spacing-xs);
}

dd {
    margin-bottom: var(--spacing-sm);
    margin-left: var(--spacing-lg);
    color: var(--sys-color-text-secondary);
}

/* Blockquotes */
blockquote {
    margin: var(--spacing-lg) 0;
    padding: var(--spacing-md) var(--spacing-lg);
    border-left: var(--border-width-lg) solid var(--sys-color-border-default);
    background-color: var(--sys-color-background-elevated);
    font-style: italic;
    color: var(--sys-color-text-secondary);
}

blockquote p {
    margin-bottom: var(--spacing-sm);
}

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

/* Horizontal rule */
hr {
    border: none;
    height: var(--border-width-sm);
    background-color: var(--sys-color-divider-default);
    margin: var(--spacing-xl) 0;
}

/* Mark and highlight */
mark {
    background-color: var(--sys-color-status-warning-background);
    color: var(--sys-color-status-warning-text);
    padding: var(--spacing-xxs) var(--spacing-xs);
    border-radius: var(--border-radius-xs);
}

/* Subscript and superscript */
sub, sup {
    font-size: 0.75em;
    line-height: 0;
    position: relative;
    vertical-align: baseline;
}

sup {
    top: -0.5em;
}

sub {
    bottom: -0.25em;
}

/* Abbreviations */
abbr[title] {
    text-decoration: underline dotted;
    cursor: help;
    border-bottom: none;
}

/* Address */
address {
    font-style: normal;
    line-height: var(--line-height-normal);
    margin-bottom: var(--spacing-md);
    color: var(--sys-color-text-secondary);
}

/* Typography utility classes */
.text-display {
    font-size: var(--font-size-4xl);
    font-weight: var(--font-weight-bold);
    line-height: var(--line-height-tight);
    letter-spacing: -0.025em;
}

.text-headline {
    font-size: var(--font-size-3xl);
    font-weight: var(--font-weight-bold);
    line-height: var(--line-height-tight);
}

.text-title {
    font-size: var(--font-size-2xl);
    font-weight: var(--font-weight-semibold);
    line-height: var(--line-height-tight);
}

.text-subtitle {
    font-size: var(--font-size-lg);
    font-weight: var(--font-weight-medium);
    line-height: var(--line-height-normal);
}

.text-body {
    font-size: var(--font-size-base);
    font-weight: var(--font-weight-normal);
    line-height: var(--line-height-normal);
}

.text-caption {
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-normal);
    line-height: var(--line-height-normal);
    color: var(--sys-color-text-secondary);
}

.text-overline {
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-medium);
    line-height: var(--line-height-normal);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--sys-color-text-subtle);
}

/* Responsive typography */
@media (max-width: 768px) {
    h1 {
        font-size: var(--font-size-3xl);
    }
    
    h2 {
        font-size: var(--font-size-2xl);
    }
    
    h3 {
        font-size: var(--font-size-xl);
    }
    
    .text-display {
        font-size: var(--font-size-3xl);
    }
    
    .text-headline {
        font-size: var(--font-size-2xl);
    }
}