/* ==============================================
   rironbusou.com - Armed with Theory
   Candlelit philosophical library aesthetic
   ============================================== */

/* --- CSS Custom Properties --- */
:root {
    --deep-forest: #1B3A2D;
    --candle-cream: #F5ECD7;
    --moss-ink: #2C3E2D;
    --parchment-light: #E8DFC4;
    --flame-amber: #D4A26A;
    --burnished-gold: #B8860B;
    --lichen-gray: #7A8B7A;
    --deep-charcoal: #1A1A1A;

    --font-display: 'Gloock', serif;
    --font-body: 'Crimson Pro', serif;
    --font-marginal: 'Caveat', cursive;
    --font-mono: 'Inconsolata', monospace;

    --content-max: 1100px;
    --section-pad: clamp(2rem, 5vw, 6rem);
}

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

html {
    scroll-behavior: smooth;
    font-size: 16px;
}

body {
    font-family: var(--font-body);
    background: var(--deep-charcoal);
    color: var(--moss-ink);
    overflow-x: hidden;
    line-height: 1.75;
    position: relative;
}

/* --- Paper Grain Overlay --- */
#paper-grain {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1000;
    opacity: 0.03;
    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='256' height='256' filter='url(%23noise)' opacity='1'/%3E%3C/svg%3E");
    background-repeat: repeat;
    background-size: 256px 256px;
}

/* --- Candle Navigation --- */
#candle-nav {
    position: fixed;
    left: 20px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 999;
    display: flex;
    flex-direction: column;
    gap: 16px;
    align-items: center;
}

.candle-item {
    cursor: pointer;
    opacity: 0.4;
    transition: opacity 0.6s ease;
    position: relative;
}

.candle-item .candle-flame {
    opacity: 0;
    transition: opacity 0.6s ease;
}

.candle-item .candle-smoke {
    opacity: 0;
    transition: opacity 0.6s ease;
}

.candle-item.active {
    opacity: 1;
}

.candle-item.active .candle-flame {
    opacity: 1;
    animation: flicker 2.5s ease-in-out infinite;
    transform-origin: 12px 14px;
}

.candle-item.active .candle-smoke {
    opacity: 1;
    animation: smoke-rise 4s ease-in-out infinite;
}

.candle-item:hover {
    opacity: 0.8;
}

@keyframes flicker {
    0% { transform: scaleY(1) scaleX(1); }
    25% { transform: scaleY(1.1) scaleX(0.92); }
    50% { transform: scaleY(1.15) scaleX(0.9); }
    75% { transform: scaleY(0.95) scaleX(1.05); }
    100% { transform: scaleY(1) scaleX(1); }
}

@keyframes smoke-rise {
    0% { transform: translateY(0) scaleX(1); opacity: 0.2; }
    50% { transform: translateY(-4px) scaleX(1.2); opacity: 0.1; }
    100% { transform: translateY(0) scaleX(1); opacity: 0.2; }
}

/* --- Diagonal Sections --- */
.diagonal-section {
    position: relative;
    min-height: 100vh;
    padding: var(--section-pad);
    overflow: hidden;
}

.section-dark {
    background: var(--deep-forest);
    color: var(--parchment-light);
}

.section-light {
    background: var(--candle-cream);
    color: var(--moss-ink);
}

/* Diagonal clip-paths with varying angles */
#section-0 {
    clip-path: polygon(0 0, 100% 0, 100% 96%, 0 100%);
    z-index: 5;
}

#section-1 {
    clip-path: polygon(0 4vh, 100% 0, 100% 94%, 0 100%);
    margin-top: -4vh;
    z-index: 6;
    box-shadow: 0 -4px 20px rgba(26, 26, 26, 0.3);
}

#section-2 {
    clip-path: polygon(0 0, 100% 5vh, 100% 95%, 0 100%);
    margin-top: -5vh;
    z-index: 7;
    box-shadow: 0 -4px 20px rgba(26, 26, 26, 0.3);
}

#section-3 {
    clip-path: polygon(0 3vh, 100% 0, 100% 97%, 0 100%);
    margin-top: -3vh;
    z-index: 8;
    box-shadow: 0 -4px 20px rgba(26, 26, 26, 0.3);
}

#section-4 {
    clip-path: polygon(0 0, 100% 6vh, 100% 100%, 0 100%);
    margin-top: -6vh;
    z-index: 9;
    box-shadow: 0 -4px 20px rgba(26, 26, 26, 0.3);
}

/* --- Section Inner --- */
.section-inner {
    max-width: var(--content-max);
    margin: 0 auto;
    padding: clamp(3rem, 8vh, 8rem) var(--section-pad);
    position: relative;
}

/* --- Content Grid (3-column asymmetric) --- */
.content-grid {
    display: grid;
    grid-template-columns: 1fr 2fr 1fr;
    gap: 2rem;
    align-items: start;
}

.margin-left,
.margin-right {
    padding-top: 3rem;
}

.marginal-note {
    font-family: var(--font-marginal);
    font-size: 0.875rem;
    color: var(--lichen-gray);
    line-height: 1.5;
    display: block;
    opacity: 0;
    transform: translateX(-20px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.margin-right .marginal-note {
    text-align: right;
    transform: translateX(20px);
}

.marginal-note.revealed {
    opacity: 1;
    transform: translateX(0);
}

.section-dark .marginal-note {
    color: var(--lichen-gray);
}

/* --- Typography --- */
.section-heading {
    font-family: var(--font-display);
    font-size: clamp(2.5rem, 6vw, 5rem);
    font-weight: 400;
    letter-spacing: 0.02em;
    line-height: 1.15;
    margin-bottom: 2rem;
    opacity: 0;
    transform: translateX(-30px) translateY(20px);
    transition: opacity 0.8s ease, transform 0.8s ease;
}

.section-heading.revealed {
    opacity: 1;
    transform: translateX(0) translateY(0);
}

.section-light .section-heading {
    color: var(--moss-ink);
}

.section-dark .section-heading {
    color: var(--parchment-light);
}

.body-text {
    font-family: var(--font-body);
    font-size: 1.125rem;
    line-height: 1.75;
    font-weight: 400;
    margin-bottom: 1.5rem;
    opacity: 0;
    transform: translateY(15px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.body-text.revealed {
    opacity: 1;
    transform: translateY(0);
}

.body-text em {
    font-weight: 600;
    font-style: italic;
}

.logic-notation {
    font-family: var(--font-mono);
    font-size: 0.95rem;
    font-weight: 400;
    color: var(--burnished-gold);
    letter-spacing: 0.05em;
}

.section-light .logic-notation {
    color: var(--burnished-gold);
}

.section-dark .logic-notation {
    color: var(--flame-amber);
}

/* --- Opening Scene --- */
.opening-scene {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--deep-charcoal);
}

.opening-glow {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(212, 162, 106, 0.15) 0%, rgba(27, 58, 45, 0.4) 40%, rgba(26, 26, 26, 0) 70%);
    transform: translate(-50%, -50%);
    animation: glow-expand 2s ease-out forwards;
    z-index: 0;
}

@keyframes glow-expand {
    0% {
        width: 0;
        height: 0;
        opacity: 0;
    }
    100% {
        width: 150vmax;
        height: 150vmax;
        opacity: 1;
    }
}

.opening-content {
    text-align: center;
    position: relative;
    z-index: 1;
}

.site-title {
    font-family: var(--font-display);
    font-size: clamp(3rem, 8vw, 7rem);
    font-weight: 400;
    letter-spacing: 0.04em;
    color: var(--parchment-light);
    margin-bottom: 1.5rem;
}

.site-title span {
    display: inline-block;
    opacity: 0;
    animation: letter-appear 0.4s ease forwards;
}

.title-candle {
    margin: 2rem auto;
    opacity: 0;
    animation: fade-in 1s ease 1.8s forwards;
}

.hero-flame {
    animation: flicker 2.5s ease-in-out infinite;
    transform-origin: 30px 35px;
}

.hero-smoke {
    animation: smoke-rise 4s ease-in-out infinite;
}

.tagline {
    font-family: var(--font-marginal);
    font-size: clamp(1.2rem, 3vw, 1.8rem);
    color: var(--flame-amber);
    opacity: 0;
    animation: fade-in 1s ease 2.2s forwards;
}

@keyframes letter-appear {
    0% { opacity: 0; transform: translateY(10px); }
    100% { opacity: 1; transform: translateY(0); }
}

@keyframes fade-in {
    0% { opacity: 0; }
    100% { opacity: 1; }
}

/* Watermark seal */
.watermark-seal {
    position: absolute;
    bottom: 15%;
    right: 10%;
    opacity: 0.05;
    pointer-events: none;
}

/* --- Interstitial Dividers --- */
.interstitial {
    position: relative;
    height: 60px;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    margin-top: -30px;
    margin-bottom: -30px;
}

.divider-ornament {
    width: 100%;
    height: 40px;
}

/* --- Isometric Icons --- */
.iso-icon {
    margin: 2rem auto;
    text-align: center;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.8s ease, transform 0.8s ease;
}

.iso-icon.revealed {
    opacity: 1;
    transform: translateY(0);
}

.iso-icon svg {
    max-width: 200px;
    height: auto;
}

.iso-draw {
    stroke-dasharray: 500;
    stroke-dashoffset: 500;
    transition: stroke-dashoffset 0.8s ease;
}

.iso-icon.revealed .iso-draw {
    stroke-dashoffset: 0;
}

/* --- Candle Glow Effect (on light sections) --- */
.candle-glow {
    position: absolute;
    top: 20%;
    right: -10%;
    width: 50vw;
    height: 50vw;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(212, 162, 106, 0.06) 0%, transparent 70%);
    pointer-events: none;
    z-index: 0;
}

/* --- Dust Motes --- */
.dust-motes {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: hidden;
    z-index: 1;
}

.mote {
    position: absolute;
    width: 2px;
    height: 2px;
    border-radius: 50%;
    background: var(--parchment-light);
    opacity: 0.15;
}

.mote-1 {
    left: 15%;
    top: 70%;
    animation: mote-drift 12s ease-in-out infinite;
}

.mote-2 {
    left: 35%;
    top: 80%;
    animation: mote-drift 15s ease-in-out infinite 2s;
}

.mote-3 {
    left: 55%;
    top: 75%;
    animation: mote-drift 10s ease-in-out infinite 4s;
}

.mote-4 {
    left: 75%;
    top: 85%;
    animation: mote-drift 14s ease-in-out infinite 1s;
}

.mote-5 {
    left: 90%;
    top: 65%;
    animation: mote-drift 11s ease-in-out infinite 3s;
}

@keyframes mote-drift {
    0% { transform: translateY(0) translateX(0); opacity: 0; }
    20% { opacity: 0.15; }
    50% { transform: translateY(-120px) translateX(10px); opacity: 0.1; }
    80% { opacity: 0.15; }
    100% { transform: translateY(-240px) translateX(-5px); opacity: 0; }
}

/* --- Closing Scene --- */
.closing-scene .section-inner {
    padding-bottom: clamp(5rem, 12vh, 12rem);
}

.closing-candle-group {
    margin: 3rem auto;
    text-align: center;
    opacity: 0;
    transform: translateY(15px);
    transition: opacity 0.8s ease, transform 0.8s ease;
}

.closing-candle-group.revealed {
    opacity: 1;
    transform: translateY(0);
}

.cluster-flame-1 {
    animation: flicker 2.5s ease-in-out infinite;
    transform-origin: 36px 18px;
}

.cluster-flame-2 {
    animation: flicker 2.5s ease-in-out infinite 0.8s;
    transform-origin: 66px 28px;
}

.cluster-flame-3 {
    animation: flicker 2.5s ease-in-out infinite 1.5s;
    transform-origin: 96px 38px;
}

.closing-attribution {
    text-align: center;
    font-family: var(--font-display);
    font-size: 1.25rem;
    color: var(--flame-amber);
    letter-spacing: 0.05em;
}

/* --- Hover / Interactive States --- */
a {
    color: var(--burnished-gold);
    text-decoration: none;
    position: relative;
    display: inline-block;
}

a::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 0;
    height: 1px;
    background: var(--burnished-gold);
    transition: width 0.3s ease;
}

a:hover::after {
    width: 100%;
}

a:hover {
    box-shadow: 0 0 20px rgba(212, 162, 106, 0.3);
}

/* --- Responsive --- */
@media (max-width: 768px) {
    #candle-nav {
        left: 10px;
        gap: 10px;
    }

    .candle-icon {
        width: 18px;
        height: 30px;
    }

    .content-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .margin-left,
    .margin-right {
        padding-top: 0;
    }

    .marginal-note {
        font-size: 0.8rem;
        transform: translateX(0);
    }

    .margin-right .marginal-note {
        text-align: left;
    }

    .section-inner {
        padding-left: 3rem;
        padding-right: 1.5rem;
    }

    .interstitial {
        height: 40px;
    }
}

@media (max-width: 480px) {
    #candle-nav {
        display: none;
    }

    .section-inner {
        padding-left: 1.5rem;
        padding-right: 1.5rem;
    }

    .site-title {
        font-size: clamp(2rem, 10vw, 4rem);
    }
}

/* --- Wax Drip Decorations (vertical borders) --- */
.section-dark::before {
    content: '';
    position: absolute;
    left: 60px;
    top: 10%;
    width: 3px;
    height: 80%;
    background: linear-gradient(
        to bottom,
        transparent 0%,
        rgba(184, 134, 11, 0.15) 10%,
        rgba(184, 134, 11, 0.25) 20%,
        rgba(184, 134, 11, 0.1) 30%,
        rgba(184, 134, 11, 0.3) 40%,
        rgba(184, 134, 11, 0.15) 50%,
        rgba(184, 134, 11, 0.25) 60%,
        rgba(184, 134, 11, 0.1) 70%,
        rgba(184, 134, 11, 0.2) 80%,
        transparent 100%
    );
    border-radius: 2px;
    pointer-events: none;
    z-index: 2;
}

@media (max-width: 768px) {
    .section-dark::before {
        display: none;
    }
}

/* --- Corner Ornaments on light sections --- */
.section-light::after {
    content: '';
    position: absolute;
    top: 8%;
    right: 5%;
    width: 60px;
    height: 60px;
    border-top: 1px solid rgba(184, 134, 11, 0.2);
    border-right: 1px solid rgba(184, 134, 11, 0.2);
    border-radius: 0 8px 0 0;
    pointer-events: none;
    z-index: 2;
}

/* --- Selection Color --- */
::selection {
    background: rgba(212, 162, 106, 0.3);
    color: var(--moss-ink);
}

/* --- Scrollbar --- */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: var(--deep-charcoal);
}

::-webkit-scrollbar-thumb {
    background: var(--lichen-gray);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--flame-amber);
}
