/* p9.rs - Dark Academia / Editorial Flow / High-Contrast */

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

body {
    background-color: #FAFAF5;
    font-family: 'Alegreya Sans', sans-serif;
    color: #1A1A1A;
    min-height: 100vh;
    position: relative;
    overflow-x: hidden;
}

/* Grid-lines ruled paper background */
.page-grid-lines {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    background-image:
        repeating-linear-gradient(
            to bottom,
            transparent,
            transparent 27px,
            rgba(51, 51, 51, 0.08) 27px,
            rgba(51, 51, 51, 0.08) 28px
        );
}

/* Editorial container */
.editorial-container {
    position: relative;
    z-index: 1;
    max-width: 960px;
    margin: 0 auto;
    display: flex;
    gap: 40px;
    padding: 80px 40px 120px;
}

.main-column {
    flex: 1;
    max-width: 680px;
    position: relative;
    /* Red margin rule */
    border-left: 1px solid rgba(204, 0, 0, 0.15);
    padding-left: 32px;
}

.marginalia-column {
    width: 200px;
    flex-shrink: 0;
    position: relative;
    padding-top: 240px;
}

/* Domain title */
.domain-title {
    font-family: 'Libre Baskerville', serif;
    font-weight: 700;
    font-size: 48px;
    color: #0A0A0A;
    margin-bottom: 40px;
    text-align: left;
    letter-spacing: -0.5px;
}

.glitch-letter {
    display: inline-block;
    position: relative;
}

/* Glitch animation for title letters on load */
@keyframes letter-glitch {
    0% { text-shadow: -2px 0 #CC0000, 2px 0 #0A0A0A; opacity: 0.8; }
    100% { text-shadow: none; opacity: 1; }
}

.glitch-letter.animate {
    animation: letter-glitch 0.1s ease forwards;
}

/* Abstract block */
.abstract-block {
    background: #F0F0EA;
    padding: 16px;
    margin-bottom: 48px;
    border-left: 3px solid #CC0000;
}

.abstract-text {
    font-family: 'Alegreya Sans', sans-serif;
    font-weight: 400;
    font-style: italic;
    font-size: 15px;
    line-height: 1.65;
    color: #333333;
}

/* Article sections */
.article-section {
    margin-bottom: 48px;
    position: relative;
}

.article-section::after {
    content: '';
    display: block;
    width: 100%;
    height: 1px;
    background: rgba(51, 51, 51, 0.3);
    margin-top: 48px;
}

.article-section:last-child::after {
    display: none;
}

/* Section headings with glitch hover */
.section-heading {
    font-family: 'Libre Baskerville', serif;
    font-weight: 700;
    font-size: 24px;
    color: #0A0A0A;
    margin-bottom: 20px;
    cursor: default;
    position: relative;
}

.glitch-heading:hover {
    animation: heading-glitch 0.1s ease;
}

@keyframes heading-glitch {
    0% { text-shadow: -2px 0 #CC0000, 2px 0 #0A0A0A; }
    50% { text-shadow: -2px 0 #CC0000, 2px 0 #0A0A0A; }
    100% { text-shadow: none; }
}

/* Body text */
.body-text {
    font-family: 'Alegreya Sans', sans-serif;
    font-weight: 400;
    font-size: 17px;
    line-height: 1.65;
    color: #1A1A1A;
    margin-bottom: 16px;
}

.body-text code {
    font-family: monospace;
    background: #F0F0EA;
    padding: 1px 4px;
    font-size: 15px;
    color: #0A0A0A;
}

/* Footnote references */
.footnote-ref {
    font-family: 'Libre Baskerville', serif;
    font-size: 14px;
    color: #CC0000;
    cursor: pointer;
    vertical-align: super;
    line-height: 0;
    position: relative;
}

.footnote-ref:hover {
    color: #990000;
}

/* Footnote tooltip */
.footnote-tooltip {
    position: absolute;
    background: #F0F0EA;
    border: 1px solid #333333;
    padding: 12px 16px;
    max-width: 300px;
    font-family: 'Alegreya', serif;
    font-style: italic;
    font-size: 14px;
    color: #666666;
    line-height: 1.5;
    z-index: 100;
    display: none;
    box-shadow: 2px 2px 0 rgba(0, 0, 0, 0.05);
}

.footnote-tooltip.visible {
    display: block;
}

/* Marginalia column */
.margin-icon {
    margin-bottom: 120px;
    opacity: 0;
    transition: opacity 0.3s ease;
    display: flex;
    align-items: flex-start;
    gap: 8px;
}

.margin-icon.visible {
    opacity: 1;
}

.margin-note {
    font-family: 'Alegreya', serif;
    font-style: italic;
    font-size: 14px;
    color: #666666;
    line-height: 1.4;
}

/* Links */
a {
    color: #CC0000;
    text-decoration: none;
    border-bottom: 1px solid rgba(204, 0, 0, 0.3);
}

a:hover {
    color: #990000;
    border-bottom-color: #990000;
}

/* Mobile responsive */
@media (max-width: 768px) {
    .editorial-container {
        flex-direction: column;
        padding: 40px 20px 80px;
        gap: 0;
    }

    .main-column {
        max-width: 100%;
        padding-left: 24px;
    }

    .marginalia-column {
        display: none;
    }

    .domain-title {
        font-size: 36px;
    }

    .section-heading {
        font-size: 20px;
    }

    /* Show inline marginalia on mobile */
    .article-section::before {
        font-family: 'Alegreya', serif;
        font-style: italic;
        font-size: 13px;
        color: #CC0000;
        opacity: 0.6;
        display: block;
        margin-bottom: 8px;
    }

    .article-section[data-marginalia="manicule"]::before { content: "\261E nota bene"; }
    .article-section[data-marginalia="asterisk"]::before { content: "* cf. Thompson"; }
    .article-section[data-marginalia="section-mark"]::before { content: "\00A7 per-process view"; }
    .article-section[data-marginalia="dagger"]::before { content: "\2020 contra mundum"; }
    .article-section[data-marginalia="pilcrow"]::before { content: "\00B6 typed conduits"; }
    .article-section[data-marginalia="fleuron"]::before { content: "\2767 finis"; }
}

@media (max-width: 480px) {
    .domain-title {
        font-size: 26px;
    }
}
