/* ============================================
   HAQUARIS — Unified Design System
   Theory of Everything by Maurizio Fedeli
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@400;700;900&family=Source+Sans+3:wght@300;400;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

/* === VARIABLES === */
:root {
    --bg-deep: #08080c;
    --bg-primary: #0d0d12;
    --bg-card: #16161f;
    --bg-card-hover: #1e1e2a;
    --gold: #c9a227;
    --gold-light: #dbb848;
    --gold-dim: #5a4a35;
    --gold-muted: #8b7355;
    --text-primary: #e8e4df;
    --text-secondary: #b8b4af;
    --accent-blue: #4a6fa5;
    --border: #252530;
    --border-subtle: #1c1c25;
    --red-accent: #e74c3c;
    --green-accent: #2ecc71;
}

/* === RESET === */
* { margin: 0; padding: 0; box-sizing: border-box; }

/* === BODY === */
body {
    font-family: 'Source Sans 3', sans-serif;
    background: var(--bg-deep);
    color: var(--text-primary);
    line-height: 1.75;
    min-height: 100vh;
}

/* Noise texture overlay — matches Quaderno DARK */
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.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
    opacity: 0.015;
    pointer-events: none; z-index: 0;
}

/* === BACKGROUND PATTERN === */
.bg-pattern {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background:
        radial-gradient(ellipse at 20% 50%, rgba(74,111,165,0.05) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 20%, rgba(201,162,39,0.04) 0%, transparent 50%);
    pointer-events: none; z-index: 0;
}

/* === HEADER === */
header {
    position: relative; z-index: 1;
    text-align: center;
    padding: 60px 20px 40px;
    border-bottom: 1px solid var(--border);
}

header h1 {
    font-family: 'Playfair Display', serif;
    font-size: 3.5em; font-weight: 900;
    background: linear-gradient(135deg, var(--gold-light), var(--gold), var(--gold-dim));
    -webkit-background-clip: text; -webkit-text-fill-color: transparent;
    background-clip: text; letter-spacing: 6px;
}

header .subtitle {
    font-size: 1.05em; color: var(--text-secondary);
    margin-top: 8px; font-style: italic; letter-spacing: 2px;
}

header .tagline {
    font-size: 1.3em; color: var(--gold);
    margin-top: 16px; font-weight: 600;
}

header .paper-num {
    font-family: 'JetBrains Mono', monospace;
    font-size: .95em; color: var(--gold);
    letter-spacing: 2px; margin-top: 8px;
}

header .paper-title {
    font-family: 'Playfair Display', serif;
    font-size: 1.6em; font-weight: 700;
    color: var(--text-primary); margin-top: 12px;
}

header .paper-subtitle {
    font-size: 1.05em; color: var(--text-secondary);
    margin-top: 6px; font-style: italic;
}

/* === NAVIGATION === */
.back-arrow {
    position: absolute; top: 20px; left: 20px;
    color: var(--gold); text-decoration: none;
    font-size: 1.1em; font-weight: 600;
    transition: color 0.3s; z-index: 10;
}
.back-arrow:hover { color: var(--gold-light); }

.nav-footer {
    display: flex; justify-content: space-between;
    margin-top: 50px; padding-top: 20px;
    border-top: 1px solid var(--border);
}
.nav-footer a {
    color: var(--gold); text-decoration: none;
    font-weight: 600; transition: color 0.3s;
}
.nav-footer a:hover { color: var(--gold-light); }

/* === MAIN CONTENT === */
main {
    position: relative; z-index: 1;
    max-width: 860px; margin: 0 auto;
    padding: 40px 30px 60px;
}

/* === TYPOGRAPHY === */
h2 {
    font-family: 'Playfair Display', serif;
    color: var(--gold); font-size: 1.5em;
    margin: 44px 0 16px; padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}

h3 {
    font-family: 'Playfair Display', serif;
    color: var(--gold-light); font-size: 1.2em;
    margin: 28px 0 10px;
}

p { margin-bottom: 14px; }
ul { margin: 10px 0 14px 28px; }
ol { margin: 10px 0 14px 28px; }
li { margin-bottom: 6px; }

blockquote {
    border-left: 3px solid var(--gold);
    padding: 12px 20px; margin: 16px 0;
    color: var(--gold-light); font-style: italic;
    font-size: 1.05em;
    background: rgba(212,168,83,0.04);
}

/* === HERO STATS === */
.hero-stats {
    display: flex; justify-content: center;
    gap: 30px; flex-wrap: wrap; margin: 30px 0;
}

.stat-box {
    text-align: center; padding: 20px 24px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px; min-width: 140px;
    transition: border-color 0.3s;
}
.stat-box:hover { border-color: var(--gold-dim); }

.stat-number {
    font-family: 'JetBrains Mono', monospace;
    color: var(--gold); font-size: 1.8em; font-weight: 700;
}

.stat-label {
    color: var(--text-secondary);
    font-size: 0.85em; margin-top: 4px;
}

/* === CHAPTER CARDS (INDEX) === */
.chapter-list { list-style: none; }

.chapter-item {
    display: block; text-decoration: none; color: inherit;
    padding: 22px 28px; margin-bottom: 10px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    transition: all 0.3s ease;
    cursor: pointer;
}
.chapter-item:hover {
    background: var(--bg-card-hover);
    border-color: var(--gold-dim);
    transform: translateX(6px);
}

.chapter-number {
    font-family: 'JetBrains Mono', monospace;
    color: var(--gold); font-size: 0.85em;
    font-weight: 500; letter-spacing: 1px;
}

.chapter-title {
    font-family: 'Playfair Display', serif;
    font-size: 1.2em; font-weight: 700;
    margin: 5px 0 3px; color: var(--text-primary);
}

.chapter-subtitle {
    font-size: 0.93em; color: var(--text-secondary);
}

/* === CONTENT BOXES === */

/* Intro Box */
.intro-box {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-left: 3px solid var(--gold);
    padding: 24px 28px; margin-bottom: 30px;
    border-radius: 4px;
    font-style: italic; color: var(--text-secondary);
    line-height: 1.85;
}

/* Principle Box */
.principle-box {
    background: linear-gradient(135deg, rgba(212,168,83,0.08), rgba(212,168,83,0.02));
    border: 2px solid var(--gold);
    padding: 28px 32px; margin: 30px 0;
    border-radius: 8px; text-align: center;
}
.principle-box .principle-title {
    font-family: 'Playfair Display', serif;
    font-size: 1.3em; font-weight: 900;
    color: var(--gold-light);
    letter-spacing: 2px; margin-bottom: 16px;
}
.principle-box p { font-size: 1.05em; line-height: 1.8; margin-bottom: 10px; }
.principle-box ul, .principle-box ol { text-align: left; margin: 12px 0 0 30px; }
.principle-box li { margin-bottom: 8px; }

/* Analogy Box */
.analogy-box {
    background: var(--bg-card);
    border: 1px solid var(--border);
    padding: 20px 24px; margin: 20px 0;
    border-radius: 6px;
}
.analogy-box .analogy-title {
    font-family: 'Playfair Display', serif;
    color: var(--gold); font-size: 1.05em;
    margin-bottom: 10px;
}

/* Formula Box */
.formula-box {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-left: 3px solid var(--gold);
    padding: 16px 20px; margin: 16px 0;
    border-radius: 4px;
    overflow-x: auto; text-align: center;
    font-size: 1.1em;
}
.formula-box .formula-title {
    font-family: 'Playfair Display', serif;
    color: var(--gold); font-size: 1em;
    margin-bottom: 8px; text-align: left;
}

/* Warning & Correct Boxes */
.warning-box {
    background: rgba(231,76,60,0.08);
    border: 1px solid rgba(231,76,60,0.3);
    border-left: 3px solid var(--red-accent);
    padding: 16px 20px; margin: 16px 0;
    border-radius: 4px;
}

.correct-box {
    background: rgba(46,204,113,0.06);
    border: 1px solid rgba(46,204,113,0.25);
    border-left: 3px solid var(--green-accent);
    padding: 16px 20px; margin: 16px 0;
    border-radius: 4px;
}

/* Chain Box */
.chain {
    text-align: center;
    font-family: 'JetBrains Mono', monospace;
    font-size: 1.05em; color: var(--gold);
    margin: 20px 0; padding: 16px;
    background: var(--bg-card);
    border-radius: 6px;
}

/* Closing Text */
.closing-text {
    font-family: 'Playfair Display', serif;
    font-size: 1.15em; color: var(--text-primary);
    text-align: center; line-height: 1.9;
    margin: 40px 0; padding: 30px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
}

/* === TABLES === */
.comparison-table {
    width: 100%; border-collapse: collapse;
    margin: 20px 0; font-size: 0.95em;
}
.comparison-table th, .comparison-table td {
    padding: 12px 16px; text-align: left;
    border-bottom: 1px solid var(--border);
}
.comparison-table th {
    color: var(--gold); font-weight: 600;
    background: var(--bg-card);
}
.comparison-table tr:hover td { background: var(--bg-card-hover); }

.term-avoid { color: var(--red-accent); font-weight: 600; }
.term-correct { color: var(--green-accent); font-weight: 600; }

/* === INTERACTIVE 3D SECTION === */
.interactive-section {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px; margin: 30px 0;
}

.interactive-card {
    display: block; text-decoration: none; color: inherit;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px; padding: 30px;
    text-align: center;
    transition: all 0.4s ease;
    overflow: hidden; position: relative;
}
.interactive-card:hover {
    border-color: var(--gold);
    transform: translateY(-4px);
    box-shadow: 0 8px 30px rgba(212,168,83,0.1);
}
.interactive-card .card-icon {
    font-size: 3em; margin-bottom: 12px;
    display: block;
}
.interactive-card .card-title {
    font-family: 'Playfair Display', serif;
    font-size: 1.2em; color: var(--gold-light);
    margin-bottom: 6px;
}
.interactive-card .card-desc {
    font-size: 0.9em; color: var(--text-secondary);
}

/* === SECTION DIVIDERS === */
.section-title {
    font-family: 'Playfair Display', serif;
    color: var(--gold); font-size: 1.6em;
    margin: 40px 0 24px; padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
}

/* === FOOTER === */
footer {
    position: relative; z-index: 1;
    text-align: center; padding: 40px 20px;
    border-top: 1px solid var(--border);
    color: var(--text-secondary); font-size: 0.9em;
}

.footer-logo {
    font-family: 'Playfair Display', serif;
    color: var(--gold-dim); font-size: 1.3em;
    letter-spacing: 4px; margin-bottom: 8px;
}

/* === QUOTE BOX === */
.quote-box {
    text-align: center; margin: 40px 0; padding: 30px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
}
.quote-box p {
    font-family: 'Playfair Display', serif;
    font-size: 1.2em; color: var(--gold);
    font-style: italic; line-height: 1.8;
}
.quote-box .quote-author {
    color: var(--text-secondary); margin-top: 12px;
    font-family: 'Source Sans 3', sans-serif;
    font-size: 0.9em; font-style: normal;
}

/* === RESPONSIVE === */
@media (max-width: 768px) {
    header h1 { font-size: 2.2em; }
    header .paper-title { font-size: 1.3em; }
    main { padding: 20px 16px 40px; }
    .chapter-item { padding: 18px 16px; }
    .hero-stats { gap: 12px; }
    .stat-box { min-width: 100px; padding: 14px; }
    .interactive-section { grid-template-columns: 1fr; }
    .principle-box { padding: 20px 16px; }
}
