/**
 * GLOBAL STYLES
 * Modern CSS reset, typography, and foundational styles
 */

/* ===== FONT IMPORTS ===== */
@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:ital,wght@0,400;0,500;0,600;0,700;1,400;1,500&family=Source+Serif+4:ital,opsz,wght@0,8..60,300;0,8..60,400;0,8..60,500;0,8..60,600;1,8..60,400;1,8..60,500&family=JetBrains+Mono:wght@400;500&display=swap');

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

html {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    scroll-behavior: smooth;
    overflow-x: hidden;
    width: 100%;
}

body {
    font-family: var(--font-body);
    font-size: var(--text-base);
    line-height: var(--leading-relaxed);
    color: var(--foreground);
    background-color: var(--background);
    letter-spacing: var(--tracking-normal);
    min-height: 100vh;
    position: relative;
    overflow-x: hidden;
    width: 100%;
}

/* Global noise texture for paper-like quality */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
    opacity: 0.02;
    pointer-events: none;
    z-index: 9999;
}

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

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

/* Prevent iOS Safari from force-zooming on input focus */
input[type="text"],
input[type="search"],
input[type="email"],
input[type="tel"],
input[type="url"],
input[type="number"],
input[type="password"],
textarea,
select {
    font-size: 16px;
}

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

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

/* ===== TYPOGRAPHY ===== */
h1,
h2,
h3,
h4,
h5,
h6 {
    font-family: var(--font-display);
    font-weight: 600;
    line-height: var(--leading-tight);
    letter-spacing: var(--tracking-tight);
    overflow-wrap: break-word;
    word-wrap: break-word;
}

h1 {
    font-size: clamp(1.85rem, 5vw, 3.25rem);
    letter-spacing: var(--tracking-tight);
    line-height: 1.15;
}

h2 {
    font-size: clamp(1.4rem, 4vw, 2.35rem);
    line-height: 1.25;
}

h3 {
    font-size: clamp(1.15rem, 3vw, 1.75rem);
}

h4 {
    font-size: clamp(1rem, 2.5vw, 1.35rem);
}

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

h6 {
    font-size: var(--text-base);
}

p, li, blockquote {
    overflow-wrap: break-word;
    word-wrap: break-word;
}

p {
    margin-bottom: var(--space-4);
}

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

/* Container */
.container {
    width: 100%;
    max-width: var(--container-max);
    margin-left: auto;
    margin-right: auto;
    padding-left: clamp(1rem, 4vw, 2rem);
    padding-right: clamp(1rem, 4vw, 2rem);
}

/* Text Utilities */
.text-display {
    font-family: var(--font-display);
}

.text-mono {
    font-family: var(--font-mono);
}

.uppercase {
    text-transform: uppercase;
}

.italic {
    font-style: italic;
}

.tracking-widest {
    letter-spacing: var(--tracking-widest);
}

.tracking-tight {
    letter-spacing: var(--tracking-tight);
}

.tracking-tighter {
    letter-spacing: var(--tracking-tighter);
}

.leading-none {
    line-height: var(--leading-none);
}

.leading-tight {
    line-height: var(--leading-tight);
}

/* Border Utilities */
.border-t {
    border-top: var(--border-thin) solid var(--border);
}

.border-b {
    border-bottom: var(--border-thin) solid var(--border);
}

.border-thick {
    border-width: var(--border-thick);
}

.border-ultra {
    border-width: var(--border-ultra);
}

/* Spacing Utilities */
.section-spacing {
    padding-top: var(--space-24);
    padding-bottom: var(--space-24);
}

@media (min-width: 768px) {
    .section-spacing {
        padding-top: var(--space-32);
        padding-bottom: var(--space-32);
    }
}

@media (min-width: 1024px) {
    .section-spacing {
        padding-top: var(--space-40);
        padding-bottom: var(--space-40);
    }
}

/* Horizontal Rule (Section Divider) */
hr.section-divider {
    border: none;
    border-top: var(--border-thick) solid var(--foreground);
    margin: 0;
}

hr.section-divider-ultra {
    border: none;
    border-top: var(--border-ultra) solid var(--foreground);
    margin: 0;
}

/* Inverted Section */
.inverted {
    background-color: var(--foreground);
    color: var(--background);
}

/* Table, Code & Media Responsive Handling */
table {
    width: 100%;
    border-collapse: collapse;
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 1.5rem 0;
}

pre, code {
    font-family: var(--font-mono);
    max-width: 100%;
    overflow-x: auto;
    white-space: pre-wrap;
    word-break: break-word;
}

img {
    height: auto;
    max-width: 100%;
}

/* Focus visible (accessibility) */
:focus-visible {
    outline: 3px solid var(--foreground);
    outline-offset: 3px;
}

/* Remove focus outline on mouse click */
:focus:not(:focus-visible) {
    outline: none;
}