/* ============================================
   monopole.systems — CSS
   Mid-century scientific instrumentation aesthetic
   ============================================ */

/* Custom Properties */
:root {
    --bg-primary: #F5F0E8;
    --bg-alternate: #EDE6D6;
    --text-body: #3B2F2F;
    --text-heading: #5B3A29;
    --accent: #A0522D;
    --marginalia: #8B7D6B;
    --terracotta: #C97D5D;
    --slate: #2F3640;
    --tan: #D2B48C;
    --column-width: 42rem;
    --column-offset: calc(50% - 2rem);
}

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

html {
    scroll-behavior: smooth;
}

body {
    background-color: var(--bg-primary);
    color: var(--text-body);
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-size: clamp(1.05rem, 1.8vw, 1.2rem);
    line-height: 1.72;
    letter-spacing: 0.005em;
    font-feature-settings: 'onum' 1, 'liga' 1, 'kern' 1;
    text-rendering: optimizeLegibility;
    overflow-x: hidden;
    position: relative;
}

/* Marble vein overlay */
.marble-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    opacity: 0.03;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='400' height='400'%3E%3Cfilter id='m'%3E%3CfeTurbulence type='turbulence' baseFrequency='0.015' numOctaves='3' seed='42'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='400' height='400' filter='url(%23m)'/%3E%3C/svg%3E");
}

/* ---- Opening Sequence ---- */
.opening {
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    z-index: 1;
}

.opening-content {
    text-align: left;
    position: relative;
}

#title-monopole {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-weight: 700;
    font-size: clamp(3rem, 8vw, 6rem);
    line-height: 1.12;
    letter-spacing: -0.01em;
    color: var(--text-heading);
    font-feature-settings: 'onum' 1;
}

#title-monopole span {
    display: inline-block;
    opacity: 0;
}

#title-systems {
    display: block;
    text-align: right;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.9rem;
    color: var(--marginalia);
    opacity: 0;
    transition: opacity 0.6s ease;
}

#subtitle {
    margin-top: 1.5rem;
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-weight: 300;
    font-style: italic;
    font-size: clamp(1.4rem, 3vw, 2.2rem);
    color: var(--accent);
    opacity: 0;
    transition: opacity 0.8s ease;
}

/* ---- Main Column ---- */
.column {
    max-width: var(--column-width);
    margin: 0 auto;
    padding: 0 1.5rem 6rem;
    position: relative;
    z-index: 1;
    margin-left: var(--column-offset);
}

@media (max-width: 900px) {
    .column {
        margin-left: auto;
        margin-right: auto;
    }
}

/* ---- Sections ---- */
.content-section {
    margin-bottom: 6rem;
    position: relative;
}

.content-section p {
    margin-bottom: 1.5rem;
    opacity: 0;
    transform: translateY(1.5rem);
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.content-section p.visible {
    opacity: 1;
    transform: translateY(0);
}

/* Drop cap */
.content-section p:first-of-type::first-letter {
    float: left;
    font-size: 3.5em;
    line-height: 0.8;
    padding-right: 0.08em;
    color: var(--text-heading);
    font-weight: 700;
}

/* Section Headings */
.section-heading {
    margin-bottom: 2rem;
    position: relative;
}

.section-heading h2 {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-weight: 700;
    font-size: clamp(2rem, 5vw, 3.8rem);
    line-height: 1.12;
    letter-spacing: -0.01em;
    color: var(--text-heading);
    font-feature-settings: 'onum' 1;
    display: inline-block;
    position: relative;
    cursor: default;
}

.section-heading h2::after {
    content: '';
    position: absolute;
    left: 50%;
    top: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    box-shadow: 0 0 0 0 rgba(201, 125, 93, 0.4);
    transform: translate(-50%, -50%);
    pointer-events: none;
}

.section-heading h2:hover::after {
    animation: heading-ripple 0.8s ease-out;
}

@keyframes heading-ripple {
    0% { box-shadow: 0 0 0 0 rgba(201, 125, 93, 0.4); }
    100% { box-shadow: 0 0 0 40px rgba(201, 125, 93, 0); }
}

.section-number {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.85rem;
    color: var(--tan);
    display: block;
    margin-bottom: 0.3rem;
    letter-spacing: 0.05em;
}

/* ---- Margin Notes ---- */
.margin-note {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.78rem;
    line-height: 1.55;
    color: var(--marginalia);
    opacity: 0;
    transform: translateX(1rem);
    transition: opacity 0.4s ease, transform 0.4s ease;
}

.margin-note.visible {
    opacity: 1;
    transform: translateX(0);
}

@media (min-width: 1024px) {
    .margin-note {
        position: absolute;
        right: -14rem;
        width: 12rem;
        margin-top: -1rem;
    }
}

@media (max-width: 1023px) {
    .margin-note {
        display: block;
        margin: 1rem 0 1rem 2rem;
        padding-left: 1rem;
        border-left: 2px solid var(--tan);
        font-style: italic;
    }
}

/* ---- Pull Quotes ---- */
.pull-quote {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-weight: 300;
    font-style: italic;
    font-size: clamp(1.4rem, 3vw, 2.2rem);
    color: var(--accent);
    margin: 3rem 0 3rem 2rem;
    padding-left: 1.5rem;
    border-left: 2px solid var(--tan);
    line-height: 1.5;
}

/* ---- Vintage Photos ---- */
.vintage-photo {
    margin: 3rem 0;
    background: var(--bg-alternate);
    border: 1px solid var(--terracotta);
    padding: 0.5rem;
    opacity: 0;
    transform: scale(0.97);
    transition: opacity 0.8s ease, transform 0.8s ease;
}

.vintage-photo.visible {
    opacity: 1;
    transform: scale(1);
}

.photo-placeholder {
    width: 100%;
    filter: sepia(0.15) contrast(1.05) brightness(0.98);
}

.photo-placeholder svg {
    display: block;
    width: 100%;
    height: auto;
}

.vintage-photo figcaption {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.75rem;
    color: var(--marginalia);
    margin-top: 0.75rem;
    line-height: 1.5;
    padding: 0 0.25rem;
}

/* ---- Dividers ---- */
.ripple-divider {
    margin: 4rem auto;
    max-width: 600px;
    text-align: center;
}

.ripple-divider svg {
    width: 100%;
    height: auto;
    overflow: visible;
}

.ripple-ring {
    opacity: 0;
    transform-origin: 300px 40px;
    transform: scale(0.3);
}

.ripple-divider.animated .ripple-ring {
    animation: ripple-expand 1.2s ease-out forwards;
    animation-delay: calc(var(--delay) * 0.15s);
}

@keyframes ripple-expand {
    0% {
        opacity: 0;
        transform: scale(0.3);
    }
    40% {
        opacity: 0.8;
    }
    100% {
        opacity: 0.5;
        transform: scale(1);
    }
}

.wavy-divider {
    margin: 5rem auto;
    max-width: 600px;
}

.wavy-divider svg {
    width: 100%;
    height: auto;
}

/* ---- Full-Bleed Diagram ---- */
.full-bleed-diagram {
    width: 100vw;
    margin-left: calc(-50vw + 50%);
    min-height: 80vh;
    background: var(--slate);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem 2rem;
    position: relative;
    z-index: 1;
}

.field-lines-svg {
    width: 90%;
    max-width: 1000px;
    height: auto;
}

.field-line {
    stroke-dasharray: 300;
    stroke-dashoffset: 300;
    transition: stroke-dashoffset 2s ease-out;
}

.full-bleed-diagram.animated .field-line {
    stroke-dashoffset: 0;
}

.monopole-dot {
    opacity: 0;
    transition: opacity 0.5s ease 2s;
}

.full-bleed-diagram.animated .monopole-dot {
    opacity: 1;
    animation: pulse-attention 3s ease-in-out 2.5s infinite;
}

@keyframes pulse-attention {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.15); }
}

.diagram-caption {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.78rem;
    color: var(--terracotta);
    text-align: center;
    margin-top: 2rem;
    max-width: 40rem;
    line-height: 1.55;
    opacity: 0.7;
}

/* ---- Column Capitals ---- */
.column-capital {
    text-align: center;
    margin: 2rem auto;
    max-width: 120px;
    opacity: 0.5;
}

.top-capital {
    position: absolute;
    top: 1rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1;
}

.bottom-capital {
    margin: 4rem auto 2rem;
}

.column-capital svg {
    width: 100%;
    height: auto;
}

/* ---- Colophon ---- */
.colophon {
    text-align: center;
    padding: 4rem 0 2rem;
    border-top: none;
}

.colophon-text {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.72rem;
    color: var(--marginalia);
    margin-bottom: 0.5rem;
    opacity: 1 !important;
    transform: none !important;
}

/* ---- Feynman Diagrams ---- */
.feynman-diagrams {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
}

.feynman {
    position: absolute;
    width: 60px;
    height: 60px;
    opacity: 0.08;
    animation: feynman-rotate 120s linear infinite;
}

.feynman-1 {
    top: 25%;
    right: 5%;
}

.feynman-2 {
    top: 55%;
    left: 3%;
}

.feynman-3 {
    top: 80%;
    right: 8%;
}

@keyframes feynman-rotate {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

@media (max-width: 768px) {
    .feynman-diagrams {
        display: none;
    }
}

/* ---- Compass Needle ---- */
.compass-needle {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 24px;
    height: 48px;
    cursor: pointer;
    z-index: 100;
    opacity: 0.8;
    transition: opacity 0.4s ease;
    animation: needle-wobble 8s ease-in-out infinite alternate;
}

.compass-needle.faded {
    opacity: 0.3;
}

.compass-needle:hover {
    opacity: 1;
}

.compass-needle svg {
    width: 100%;
    height: 100%;
}

@keyframes needle-wobble {
    0% { transform: rotate(-3deg); }
    100% { transform: rotate(3deg); }
}

/* ---- Alternate section backgrounds ---- */
.content-section[data-section="02"],
.content-section[data-section="04"],
.content-section[data-section="06"] {
    padding: 3rem 0;
    position: relative;
}

.content-section[data-section="02"]::before,
.content-section[data-section="04"]::before,
.content-section[data-section="06"]::before {
    content: '';
    position: absolute;
    top: -2rem;
    left: -4rem;
    right: -4rem;
    bottom: -2rem;
    background: var(--bg-alternate);
    z-index: -1;
    border-radius: 0;
}

/* ---- Selection ---- */
::selection {
    background: var(--tan);
    color: var(--text-heading);
}
