/* =============================================
   rational.today — Styles
   Palette: #6B2D5B #9B3A6A #C4687A #C9B8A5 #F5F0EB #1E0F1B #D4A857
   Fonts: Poiret One, Josefin Sans, IBM Plex Mono, Playfair Display
   ============================================= */

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

html {
    scroll-behavior: smooth;
}

body {
    background: #F5F0EB;
    color: #1E0F1B;
    font-family: 'Josefin Sans', sans-serif;
    font-weight: 300;
    font-size: clamp(1rem, 1.5vw, 1.2rem);
    line-height: 1.85;
    letter-spacing: 0.01em;
    overflow-x: hidden;
}

/* Watercolor grain overlay */
body::after {
    content: '';
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: repeating-conic-gradient(
        rgba(30,15,27,0.02) 0% 25%,
        transparent 0% 50%
    ) 0 0 / 4px 4px;
    pointer-events: none;
    z-index: 9999;
    opacity: 0.5;
}

/* ---- Gradient Mesh ---- */
#gradient-mesh {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    z-index: 0;
    pointer-events: none;
    background:
        radial-gradient(ellipse at 30% 20%, rgba(107,45,91,0.25) 0%, transparent 60%),
        radial-gradient(ellipse at 70% 60%, rgba(155,58,106,0.2) 0%, transparent 55%),
        radial-gradient(ellipse at 50% 80%, rgba(196,104,122,0.2) 0%, transparent 50%),
        radial-gradient(ellipse at 15% 70%, rgba(212,168,87,0.1) 0%, transparent 45%),
        radial-gradient(ellipse at 85% 30%, rgba(107,45,91,0.15) 0%, transparent 50%),
        radial-gradient(ellipse at 60% 10%, rgba(196,104,122,0.15) 0%, transparent 55%);
    background-size: 200% 200%;
    animation: meshShift 28s ease-in-out infinite alternate;
}

@keyframes meshShift {
    0% { background-position: 0% 0%, 100% 100%, 50% 50%, 0% 100%, 100% 0%, 50% 0%; }
    33% { background-position: 30% 50%, 70% 30%, 20% 80%, 50% 50%, 80% 60%, 10% 40%; }
    66% { background-position: 60% 20%, 40% 70%, 80% 30%, 20% 60%, 50% 40%, 70% 80%; }
    100% { background-position: 100% 100%, 0% 0%, 50% 50%, 100% 0%, 0% 100%, 50% 100%; }
}

/* ---- Scroll Progress ---- */
#scroll-progress {
    position: fixed;
    left: 0;
    top: 0;
    width: 3px;
    height: 100vh;
    z-index: 1000;
}

#scroll-line {
    position: absolute;
    top: 0; left: 0;
    width: 3px;
    height: 0%;
    background: #C9B8A5;
    transition: height 0.1s linear;
}

.scroll-node {
    position: absolute;
    left: -3px;
    width: 9px;
    height: 9px;
    background: #D4A857;
    transform: rotate(45deg);
    z-index: 1001;
}

/* ---- Watercolor Bleeds ---- */
.watercolor-bleed {
    position: absolute;
    pointer-events: none;
    filter: url(#watercolor);
    border-radius: 0;
    z-index: 1;
}

.bleed-top-right {
    top: -30px; right: -30px;
    width: 45vw; height: 40vh;
    background: radial-gradient(ellipse at center, rgba(155,58,106,0.2) 0%, rgba(196,104,122,0.1) 50%, transparent 80%);
}

.bleed-bottom-left {
    bottom: -30px; left: -30px;
    width: 40vw; height: 35vh;
    background: radial-gradient(ellipse at center, rgba(107,45,91,0.2) 0%, rgba(155,58,106,0.1) 50%, transparent 80%);
}

.module-bleed {
    top: -15px; left: -15px; right: -15px; bottom: -15px;
    background: radial-gradient(ellipse at center, rgba(155,58,106,0.12) 0%, transparent 70%);
}

.dialectic-bleed-left {
    top: 0; left: -20px; right: 0; bottom: 0;
    background: radial-gradient(ellipse at 30% 50%, rgba(107,45,91,0.15) 0%, transparent 70%);
}

.dialectic-bleed-right {
    top: 0; left: 0; right: -20px; bottom: 0;
    background: radial-gradient(ellipse at 70% 50%, rgba(196,104,122,0.15) 0%, transparent 70%);
}

/* ---- Pulse Nodes ---- */
.pulse-node {
    position: absolute;
    width: 8px;
    height: 8px;
    background: #D4A857;
    border-radius: 50%;
    z-index: 10;
}

.pulse-node::after {
    content: '';
    position: absolute;
    top: 50%; left: 50%;
    width: 8px; height: 8px;
    margin: -4px 0 0 -4px;
    border: 1.5px solid #D4A857;
    border-radius: 50%;
    animation: pulse-ring 1.5s ease-out infinite;
}

@keyframes pulse-ring {
    0% { transform: scale(1); opacity: 0.8; }
    100% { transform: scale(3); opacity: 0; }
}

/* ---- Section: Overture ---- */
#overture {
    position: relative;
    width: 100%;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    background: #1E0F1B;
    overflow: hidden;
    z-index: 1;
}

#overture::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background:
        radial-gradient(ellipse at 40% 40%, rgba(107,45,91,0.4) 0%, transparent 60%),
        radial-gradient(ellipse at 70% 60%, rgba(155,58,106,0.3) 0%, transparent 55%),
        radial-gradient(ellipse at 30% 80%, rgba(196,104,122,0.2) 0%, transparent 50%);
    background-size: 200% 200%;
    animation: meshShift 25s ease-in-out infinite alternate;
}

.overture-content {
    position: relative;
    z-index: 5;
    padding-left: 10vw;
}

.brand-name {
    font-family: 'Poiret One', cursive;
    font-weight: 400;
    font-size: clamp(4rem, 12vw, 10rem);
    letter-spacing: 0.08em;
    color: #F5F0EB;
    text-shadow: 3px 3px 0 rgba(107,45,91,0.3);
    line-height: 1;
}

.circuit-underline {
    display: block;
    width: clamp(300px, 50vw, 700px);
    height: 40px;
    margin-top: 0.5rem;
    overflow: visible;
}

.circuit-underline path {
    stroke-dasharray: 1000;
    stroke-dashoffset: 1000;
    animation: drawLine 2s ease-in-out 0.5s forwards;
}

.circuit-underline circle {
    opacity: 0;
    animation: fadeIn 0.3s ease forwards;
    animation-delay: 2s;
}

@keyframes drawLine {
    to { stroke-dashoffset: 0; }
}

@keyframes fadeIn {
    to { opacity: 1; }
}

.tagline {
    font-family: 'IBM Plex Mono', monospace;
    font-size: clamp(0.75rem, 1vw, 0.9rem);
    color: #C9B8A5;
    position: fixed;
    bottom: 3rem;
    right: 3rem;
    max-width: 30ch;
    text-align: right;
    opacity: 0;
    animation: fadeIn 1s ease forwards;
    animation-delay: 1.5s;
    z-index: 10;
}

/* ---- Section: Thesis Grid ---- */
#thesis-grid {
    position: relative;
    z-index: 1;
    padding: 6rem 2rem;
    background: #C9B8A5;
}

.grid-container {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 3px;
    max-width: 1400px;
    margin: 0 auto;
}

.module {
    position: relative;
    background: #F5F0EB;
    padding: 2.5rem 2rem;
    overflow: hidden;
    opacity: 0;
    transform: scale(0.95);
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.module.visible {
    opacity: 1;
    transform: scale(1);
}

.module-1 { grid-column: span 4; min-height: 320px; }
.module-2 { grid-column: span 8; min-height: 280px; }
.module-3 { grid-column: span 5; min-height: 350px; }
.module-4 { grid-column: span 3; min-height: 350px; }
.module-5 { grid-column: span 4; min-height: 300px; }
.module-6 { grid-column: span 7; min-height: 260px; }
.module-5 { grid-column: 1 / span 4; }
.module-6 { grid-column: 5 / span 8; }

/* Art Deco Borders */
.art-deco-border {
    position: absolute;
    top: 8px; left: 8px; right: 8px; bottom: 8px;
    border: 1px solid rgba(201,184,165,0.6);
    pointer-events: none;
    z-index: 3;
}

.art-deco-border::before {
    content: '';
    position: absolute;
    top: 4px; left: 4px; right: 4px; bottom: 4px;
    border: 1px solid rgba(201,184,165,0.4);
}

.corner {
    position: absolute;
    width: 16px;
    height: 16px;
    z-index: 4;
    transition: transform 0.4s ease;
}

.corner::before, .corner::after {
    content: '';
    position: absolute;
    background: #C9B8A5;
}

.corner::before {
    width: 16px; height: 1px;
    top: 50%; left: 0;
}

.corner::after {
    width: 1px; height: 16px;
    top: 0; left: 50%;
}

.corner.tl { top: 0; left: 0; }
.corner.tr { top: 0; right: 0; }
.corner.bl { bottom: 0; left: 0; }
.corner.br { bottom: 0; right: 0; }

.module:hover .corner {
    transform: scale(1.2) rotate(45deg);
}

.module:hover .art-deco-border {
    border-color: rgba(201,184,165,1);
}

.module-content {
    position: relative;
    z-index: 5;
}

.module-content h2 {
    font-family: 'Poiret One', cursive;
    font-weight: 400;
    font-size: clamp(1.5rem, 3vw, 2.2rem);
    letter-spacing: 0.08em;
    color: #9B3A6A;
    margin-bottom: 1rem;
}

.module-content p {
    font-family: 'Josefin Sans', sans-serif;
    font-weight: 300;
    color: #1E0F1B;
    line-height: 1.85;
}

.circuit-icon {
    width: 40px;
    height: 40px;
    margin-bottom: 1rem;
    display: block;
}

/* ---- Section: Dialectic ---- */
#dialectic {
    position: relative;
    z-index: 1;
    padding: 6rem 2rem;
    background: #F5F0EB;
}

.dialectic-container {
    display: flex;
    gap: 0;
    max-width: 1200px;
    margin: 0 auto;
    align-items: stretch;
}

.dialectic-left,
.dialectic-right {
    position: relative;
    padding: 3rem;
    overflow: hidden;
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.8s ease, transform 0.8s ease;
}

.dialectic-left.visible,
.dialectic-right.visible {
    opacity: 1;
    transform: translateY(0);
}

.dialectic-left {
    flex: 7;
    background: rgba(107,45,91,0.05);
}

.dialectic-right {
    flex: 5;
    background: rgba(196,104,122,0.05);
}

.dialectic-left h2,
.dialectic-right h2 {
    font-family: 'Poiret One', cursive;
    font-weight: 400;
    font-size: clamp(2rem, 5vw, 4rem);
    letter-spacing: 0.08em;
    color: #9B3A6A;
    margin-bottom: 1.5rem;
}

.dialectic-left p,
.dialectic-right p {
    line-height: 1.85;
    margin-bottom: 1.5rem;
}

.meta-text {
    font-family: 'IBM Plex Mono', monospace;
    font-size: clamp(0.7rem, 0.9vw, 0.85rem);
    color: #C9B8A5;
    display: block;
    margin-top: 1rem;
}

.dialectic-divider {
    width: 6px;
    flex-shrink: 0;
    position: relative;
}

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

.divider-node {
    animation: pulse-glow 2s ease-in-out infinite;
}

@keyframes pulse-glow {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 1; }
}

/* ---- Section: Codex ---- */
#codex {
    position: relative;
    z-index: 1;
    padding: 8rem 2rem;
    background: #1E0F1B;
    color: #F5F0EB;
    overflow: hidden;
}

#codex::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background:
        radial-gradient(ellipse at 30% 30%, rgba(107,45,91,0.08) 0%, transparent 60%),
        radial-gradient(ellipse at 70% 70%, rgba(196,104,122,0.05) 0%, transparent 50%);
    pointer-events: none;
}

.circuit-frame {
    position: absolute;
    top: 2rem; left: 2rem; right: 2rem; bottom: 2rem;
    pointer-events: none;
    z-index: 2;
}

.frame-trace {
    position: absolute;
    overflow: visible;
}

.top-trace { top: 0; left: 0; width: 100%; height: 10px; }
.bottom-trace { bottom: 0; left: 0; width: 100%; height: 10px; }
.left-trace { top: 0; left: 0; width: 10px; height: 100%; }
.right-trace { top: 0; right: 0; width: 10px; height: 100%; }

.frame-trace path {
    filter: drop-shadow(0 0 4px rgba(212,168,87,0.3));
}

.codex-content {
    position: relative;
    z-index: 3;
    max-width: 800px;
    margin: 0 auto;
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.8s ease, transform 0.8s ease;
}

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

.codex-content p {
    margin-bottom: 2rem;
    line-height: 1.9;
    font-weight: 300;
}

.drop-cap {
    font-family: 'Playfair Display', serif;
    font-weight: 700;
    font-style: italic;
    font-size: 3.5em;
    float: left;
    line-height: 0.8;
    margin-right: 0.1em;
    margin-top: 0.05em;
    color: #D4A857;
}

/* ---- Section: Signal ---- */
#signal {
    position: relative;
    z-index: 1;
    width: 100%;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #1E0F1B;
    overflow: hidden;
}

#signal::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background:
        radial-gradient(ellipse at 40% 50%, rgba(196,104,122,0.25) 0%, transparent 55%),
        radial-gradient(ellipse at 65% 40%, rgba(212,168,87,0.15) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 70%, rgba(155,58,106,0.2) 0%, transparent 55%);
    background-size: 200% 200%;
    animation: meshShift 22s ease-in-out infinite alternate;
}

.signal-content {
    position: relative;
    z-index: 5;
    text-align: center;
}

.signal-letters {
    display: inline-flex;
    gap: 0;
}

.signal-letter,
.signal-dot {
    font-family: 'Poiret One', cursive;
    font-size: clamp(3rem, 8vw, 7rem);
    letter-spacing: 0.05em;
    color: #F5F0EB;
    display: inline-block;
    opacity: 0;
    transform: translateY(20px);
    animation: letterArrive 0.6s ease forwards;
}

.signal-dot {
    color: #D4A857;
}

.signal-letter[data-delay="0"] { animation-delay: 0.1s; }
.signal-letter[data-delay="1"] { animation-delay: 0.2s; }
.signal-letter[data-delay="2"] { animation-delay: 0.3s; }
.signal-letter[data-delay="3"] { animation-delay: 0.4s; }
.signal-letter[data-delay="4"] { animation-delay: 0.5s; }
.signal-letter[data-delay="5"] { animation-delay: 0.6s; }
.signal-letter[data-delay="6"] { animation-delay: 0.7s; }
.signal-letter[data-delay="7"] { animation-delay: 0.8s; }
.signal-dot { animation-delay: 0.85s; }
.signal-letter[data-delay="8"] { animation-delay: 0.9s; }
.signal-letter[data-delay="9"] { animation-delay: 1.0s; }
.signal-letter[data-delay="10"] { animation-delay: 1.1s; }
.signal-letter[data-delay="11"] { animation-delay: 1.2s; }
.signal-letter[data-delay="12"] { animation-delay: 1.3s; }

@keyframes letterArrive {
    to { opacity: 1; transform: translateY(0); }
}

.signal-traces {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 80vw;
    height: 60vh;
    z-index: -1;
    pointer-events: none;
}

.converge-trace {
    stroke-dasharray: 600;
    stroke-dashoffset: 600;
    opacity: 0.5;
}

.signal-traces.animate .converge-trace {
    animation: drawLine 2s ease-in-out forwards;
}

.signal-center-node {
    filter: drop-shadow(0 0 6px rgba(212,168,87,0.6));
    animation: pulse-glow 2s ease-in-out infinite;
}

/* Signal mouse-follow gradient */
#signal .mouse-gradient {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    pointer-events: none;
    z-index: 2;
}

/* ---- Responsive ---- */
@media (max-width: 768px) {
    .grid-container {
        grid-template-columns: repeat(4, 1fr);
    }

    .module-1, .module-2, .module-3,
    .module-4, .module-5, .module-6 {
        grid-column: span 4;
        min-height: auto;
    }

    .dialectic-container {
        flex-direction: column;
    }

    .dialectic-divider {
        width: 100%;
        height: 6px;
    }

    .dialectic-divider svg {
        display: none;
    }

    .dialectic-left, .dialectic-right {
        flex: 1;
    }

    .tagline {
        position: absolute;
        bottom: 2rem;
        right: 2rem;
        left: 2rem;
        text-align: center;
    }

    .overture-content {
        padding-left: 5vw;
        padding-right: 5vw;
    }

    .signal-traces {
        width: 95vw;
    }
}
