/* kkaji.com - Brutalist Anti-Design: Extinction Narrative */

:root {
    --flame-core: #E8520C;
    --flame-edge: #8B1A1A;
    --ash: #2D2D2D;
    --smoke: #6B6260;
    --paper: #F5F0EB;
    --soot: #3A3530;
    --wax: #C4A67D;
    --void: #0D0D0D;
    --near-black: #1A1A1A;
    --body-light: #4A4A4A;
    --body-dark: #A0A0A0;
}

/* ===== RESET & BASE ===== */

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

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
    scroll-behavior: auto;
}

body {
    background: var(--void);
    color: var(--paper);
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 400;
    overflow: hidden;
}

::selection {
    background: var(--flame-edge);
    color: var(--paper);
}

/* ===== SCROLL SNAP CONTAINER ===== */

.snap-container {
    height: 100vh;
    overflow-y: scroll;
    scroll-snap-type: y mandatory;
    -webkit-overflow-scrolling: touch;
}

.section {
    height: 100vh;
    width: 100%;
    position: relative;
    overflow: hidden;
    display: grid;
    grid-template-columns: repeat(13, 1fr);
    grid-template-rows: 1fr auto;
    scroll-snap-align: start;
}

/* ===== WICK (scroll progress) ===== */

.wick {
    position: fixed;
    top: 0;
    left: 0;
    width: 1px;
    height: 0%;
    background: linear-gradient(to bottom, var(--flame-core), var(--flame-edge), var(--ash));
    z-index: 1000;
    transition: height 0.15s linear;
}

/* ===== FIXED BRANDING ===== */

.fixed-brand {
    position: fixed;
    bottom: 20px;
    left: 20px;
    z-index: 999;
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: default;
}

.brand-text {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 10px;
    font-weight: 400;
    color: var(--paper);
    opacity: 0.3;
    transition: opacity 0.3s ease;
    letter-spacing: 0.05em;
}

.brand-flame {
    opacity: 0;
    transition: opacity 0.5s ease;
}

.fixed-brand:hover .brand-text {
    opacity: 1;
}

.fixed-brand:hover .brand-flame path {
    opacity: 1;
}

.fixed-brand:hover .brand-flame {
    opacity: 1;
}

/* ===== OPENING SECTION ===== */

.section-opening {
    background: var(--void);
    scroll-snap-stop: always;
    place-items: center;
    grid-template-rows: 1fr;
}

.opening-flame-container {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 2;
    opacity: 0;
    animation: flameIgnite 3s ease-out 0.6s forwards;
}

@keyframes flameIgnite {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(1);
    }
    30% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
    100% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(5);
    }
}

.opening-flame .flame-outer,
.opening-flame .flame-inner {
    animation: flicker1 2.3s ease-in-out infinite alternate,
               flicker2 3.7s ease-in-out infinite alternate;
}

.section-opening .opening-grid {
    grid-column: 3 / 12;
    grid-row: 1;
    display: flex;
    align-items: center;
    z-index: 3;
    opacity: 0;
    animation: textAppear 1.5s ease-out 2.6s forwards;
}

.section-opening {
    animation: bgIgnite 1.2s ease-out 2.2s forwards;
}

@keyframes bgIgnite {
    0% { background: var(--void); }
    100% { background: var(--paper); }
}

@keyframes textAppear {
    0% {
        opacity: 0;
        transform: translateY(30px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

.opening-text {
    color: var(--near-black);
    transform: rotate(-3deg);
}

/* ===== SHOUT SECTIONS ===== */

.section-shout {
    scroll-snap-stop: always;
    align-items: center;
}

.shout-text {
    font-family: 'Bebas Neue', sans-serif;
    font-weight: 400;
    font-size: clamp(8rem, 20vw, 28rem);
    line-height: 0.85;
    letter-spacing: -0.03em;
    text-transform: uppercase;
    white-space: nowrap;
}

.shout-grid {
    grid-column: 1 / -1;
    grid-row: 1;
    display: flex;
    align-items: center;
    position: relative;
}

.shout-overflow {
    white-space: nowrap;
    margin-left: -5vw;
    margin-right: -5vw;
}

/* Radial glow behind shout text */
.shout-grid::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 80%;
    height: 80%;
    background: radial-gradient(ellipse at center, rgba(232, 82, 12, 0.08) 0%, transparent 60%);
    pointer-events: none;
}

/* SHOUT 1 - Molten Orange */
.shout-1 {
    background: var(--flame-core);
    clip-path: polygon(0 0, 100% 0, 100% 92%, 97% 94%, 92% 91%, 85% 95%, 78% 92%, 72% 96%, 65% 91%, 58% 94%, 50% 90%, 43% 95%, 35% 92%, 28% 96%, 20% 91%, 12% 94%, 5% 90%, 0 93%);
}

.shout-1 .shout-text {
    color: var(--paper);
}

.shout-1 .shout-grid {
    grid-column: 2 / 11;
}

/* SHOUT 2 - Smolder Red */
.shout-2 {
    background: var(--flame-edge);
    clip-path: polygon(0 0, 100% 0, 100% 91%, 95% 94%, 88% 90%, 82% 95%, 75% 91%, 68% 93%, 60% 90%, 52% 96%, 45% 91%, 38% 94%, 30% 90%, 22% 95%, 15% 91%, 8% 93%, 3% 90%, 0 94%);
}

.shout-2 .shout-text {
    color: var(--paper);
}

.shout-2 .shout-grid {
    grid-column: 5 / 14;
}

/* SHOUT 3 - Charcoal */
.shout-3 {
    background: var(--ash);
    clip-path: polygon(0 0, 100% 0, 100% 93%, 96% 90%, 90% 95%, 83% 91%, 76% 94%, 70% 90%, 63% 96%, 56% 91%, 48% 94%, 40% 90%, 33% 95%, 25% 91%, 18% 94%, 10% 90%, 4% 95%, 0 91%);
}

.shout-3 .shout-text {
    color: var(--paper);
}

.shout-3 .shout-grid {
    grid-column: 1 / 8;
}

/* Final SHOUT - Soot into void */
.shout-final {
    background: var(--soot);
}

.shout-final .shout-text {
    color: var(--flame-core);
}

.shout-final .shout-grid {
    grid-column: 3 / 13;
}

/* ===== LOG ENTRIES ===== */

.log-entries {
    grid-column: 2 / 12;
    grid-row: 2;
    padding: 0 0 5vh 0;
    align-self: end;
}

.log-line {
    font-family: 'IBM Plex Mono', monospace;
    font-size: clamp(0.85rem, 1.1vw, 1.1rem);
    font-weight: 300;
    line-height: 1.65;
    letter-spacing: 0.01em;
    color: var(--body-dark); /* #A0A0A0 on dark shout backgrounds */
    opacity: 0;
    transition: opacity 0.8s ease;
}

.log-line.visible {
    opacity: 0.7;
}

/* ===== SILENCE SECTIONS ===== */

.section-silence {
    background: var(--paper);
    scroll-snap-stop: normal;
    place-items: center;
    grid-template-rows: 1fr;
    padding: 20vh 15vw;
}

.noise-overlay {
    position: absolute;
    inset: 0;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23n)' opacity='0.03'/%3E%3C/svg%3E");
    background-repeat: repeat;
    pointer-events: none;
    z-index: 0;
}

.silence-flame-wrap {
    grid-column: 1 / -1;
    grid-row: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1;
}

/* Flame flicker keyframes */
@keyframes flicker1 {
    0% { transform: scaleY(1) skewX(0deg); }
    25% { transform: scaleY(1.04) skewX(2deg); }
    50% { transform: scaleY(0.96) skewX(-1deg); }
    75% { transform: scaleY(1.02) skewX(1.5deg); }
    100% { transform: scaleY(0.98) skewX(-2deg); }
}

@keyframes flicker2 {
    0% { opacity: 0.35; }
    33% { opacity: 0.45; }
    66% { opacity: 0.3; }
    100% { opacity: 0.4; }
}

@keyframes flicker3 {
    0% { transform: scaleX(1) scaleY(1); }
    20% { transform: scaleX(0.97) scaleY(1.03); }
    40% { transform: scaleX(1.02) scaleY(0.98); }
    60% { transform: scaleX(0.99) scaleY(1.01); }
    80% { transform: scaleX(1.01) scaleY(0.97); }
    100% { transform: scaleX(0.98) scaleY(1.02); }
}

/* Flame size classes */
.flame-size-1 {
    width: 60px;
    height: 100px;
}

.flame-size-2 {
    width: 35px;
    height: 58px;
}

.flame-size-3 {
    width: 12px;
    height: 20px;
}

/* Progressive slowing of flicker */
.flicker-slow-1 {
    animation: flicker1 2.3s ease-in-out infinite alternate,
               flicker3 3.7s ease-in-out infinite alternate;
}

.flicker-slow-2 {
    animation: flicker1 4.1s ease-in-out infinite alternate,
               flicker3 5.3s ease-in-out infinite alternate;
}

.flicker-slow-3 {
    animation: flicker1 8s ease-in-out infinite alternate,
               flicker3 10s ease-in-out infinite alternate;
}

/* Flame extinction animation for the smallest flame */
.flame-extinct {
    animation: extinguish 4s ease-out forwards !important;
}

@keyframes extinguish {
    0% {
        opacity: 1;
        transform: scale(1);
    }
    70% {
        opacity: 0.3;
        transform: scale(0.4);
    }
    100% {
        opacity: 0;
        transform: scale(0);
    }
}

/* ===== MARGIN NOTES (Caveat) ===== */

.margin-note {
    position: absolute;
    z-index: 2;
}

.note-right {
    bottom: 12vh;
    right: 8vw;
}

.caveat-text {
    font-family: 'Caveat', cursive;
    font-size: clamp(1rem, 1.8vw, 1.6rem);
    font-weight: 400;
    color: var(--body-light); /* #4A4A4A on light silence backgrounds */
    transform: rotate(-1deg);
    display: inline-block;
    opacity: 0;
    transition: opacity 1.2s ease;
}

.caveat-text.visible {
    opacity: 1;
}

/* ===== STRUCK-THROUGH TEXT ===== */

.struck-text-block {
    grid-column: 3 / 11;
    grid-row: 2;
    padding-bottom: 8vh;
    align-self: end;
}

.struck-line {
    font-family: 'IBM Plex Mono', monospace;
    font-size: clamp(0.85rem, 1.1vw, 1.1rem);
    font-weight: 400;
    line-height: 1.65;
    letter-spacing: 0.01em;
    color: var(--smoke);
    text-decoration: line-through;
    text-decoration-color: var(--flame-edge);
    text-decoration-thickness: 1.5px;
}

/* ===== REDACTION BLOCKS ===== */

.redact {
    background: var(--ash);
    color: var(--ash);
    padding: 0 4px;
    transition: background 0.5s ease, color 0.5s ease;
    cursor: default;
    display: inline;
}

.redact:hover {
    background: transparent;
    color: var(--wax);
}

.redact-final {
    background: var(--void);
    color: var(--void);
}

.redact-final:hover {
    background: transparent;
    color: var(--wax);
}

/* ===== VOID / FINAL SECTION ===== */

.section-void {
    background: var(--void);
    scroll-snap-stop: always;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
}

.smoke-field {
    position: absolute;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
}

.smoke-particle {
    position: absolute;
    bottom: -10px;
    left: var(--x);
    width: var(--size);
    height: var(--size);
    border-radius: 50%;
    background: var(--smoke);
    opacity: var(--alpha);
    animation: smokeRise var(--dur) linear var(--delay) infinite;
}

@keyframes smokeRise {
    0% {
        transform: translateY(0) translateX(0);
        opacity: var(--alpha);
    }
    50% {
        opacity: calc(var(--alpha) * 0.7);
    }
    100% {
        transform: translateY(-110vh) translateX(var(--drift));
        opacity: 0;
    }
}

.void-text {
    text-align: center;
    z-index: 2;
}

.void-line {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 14px;
    font-weight: 300;
    color: var(--smoke);
    opacity: 0;
    line-height: 2;
}

.void-line.visible {
    opacity: 0.7;
    transition: opacity 2s ease;
}

.void-redactions {
    position: absolute;
    bottom: 15vh;
    left: 15vw;
    right: 15vw;
    text-align: center;
    z-index: 2;
}

.void-redact-line {
    font-family: 'IBM Plex Mono', monospace;
    font-size: clamp(0.75rem, 1vw, 0.95rem);
    font-weight: 300;
    line-height: 1.8;
    color: var(--smoke);
    opacity: 0;
    transition: opacity 2s ease;
}

.void-redact-line.visible {
    opacity: 0.5;
}

/* ===== HORIZONTAL RULE IN SILENCE ===== */

.silence-hr {
    width: 60%;
    height: 1px;
    background: var(--smoke);
    opacity: 0.3;
    border: none;
}

/* ===== RESPONSIVE ===== */

@media (max-width: 768px) {
    .shout-text {
        font-size: clamp(5rem, 18vw, 12rem);
    }

    .section-silence {
        padding: 15vh 8vw;
    }

    .log-entries {
        grid-column: 1 / -1;
        padding: 0 5vw 5vh 5vw;
    }

    .struck-text-block {
        grid-column: 1 / -1;
        padding: 0 5vw 5vh 5vw;
    }

    .note-right {
        right: 5vw;
        bottom: 8vh;
    }

    .void-redactions {
        left: 5vw;
        right: 5vw;
    }

    .shout-1 .shout-grid,
    .shout-2 .shout-grid,
    .shout-3 .shout-grid,
    .shout-final .shout-grid {
        grid-column: 1 / -1;
    }
}
