/* continu.st — flat-design, stacked-sections, sunset-warm
   Intersection Observer detecting which section is most visible.
   Intersection Observer for scroll-triggered typewriter animations and background color transitions. */

:root {
    --bg-primary: #F5EBD8;   /* Warm Parchment */
    --bg-soft:    #F2E8D4;   /* Cream Linen */
    --bg-deep:    #3D2B1F;   /* Evening Umber */
    --ink:        #4A3728;   /* Ink Sepia */
    --accent-1:   #C4785B;   /* Terracotta Glow */
    --accent-2:   #D4956A;   /* Dusty Coral */
    --accent-3:   #E8B87A;   /* Amber Crystal */
    --inverse:    #F2E8D4;   /* Cream Linen (text inverse) */

    --baseline: 1.618rem;

    --f-display: "Cormorant Garamond", "Cormorant", Georgia, serif;
    --f-body: "Inter", system-ui, sans-serif;
    --f-type: "Space Mono", "Inter", "Courier New", monospace;
}

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

html, body {
    background-color: #F5EBD8;
    color: #4A3728;
    font-family: var(--f-body);
    font-size: 16px;
    line-height: 1.75;
    letter-spacing: 0.01em;
    min-height: 100%;
    overflow-x: hidden;
}

body {
    transition: background-color 1.2s cubic-bezier(0.25, 0.1, 0.25, 1);
    scroll-behavior: smooth;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0,0,0,0);
    border: 0;
}

/* Background tessellation */
.tessellation {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    opacity: 0.05;
    z-index: 0;
}

.essay {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: stretch;
}

/* Section base */
.section {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: calc(var(--baseline) * 2) calc(var(--baseline) * 1.5);
    border-top: 1px solid rgba(74, 55, 40, 0.12);
}

.section:first-of-type {
    border-top: none;
}

/* Opening */
.section--opening {
    min-height: 100vh;
    background-color: #F5EBD8;
}

.opening-inner {
    max-width: 64rem;
    width: 100%;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: calc(var(--baseline) * 1.5);
}

.title {
    font-family: var(--f-display);
    font-weight: 600;
    font-size: clamp(3rem, 8vw, 7rem);
    line-height: 1.15;
    letter-spacing: 0.02em;
    color: var(--ink);
    position: relative;
    display: inline-block;
    min-height: 1.15em;
}

.title-type {
    display: inline-block;
    font-family: var(--f-type);
    font-weight: 400;
    font-size: 0.82em;
    letter-spacing: 0.02em;
    color: var(--ink);
    opacity: 1;
    transition: opacity 0.6s ease;
    white-space: nowrap;
}

.title-type::after {
    content: "";
    display: inline-block;
    width: 2px;
    height: 1.2em;
    background-color: var(--accent-1);
    margin-left: 4px;
    vertical-align: -0.15em;
    animation: blink 0.53s step-end infinite;
    opacity: 0;
}

.title-type.typing::after {
    opacity: 1;
}

.title-type.finished::after {
    opacity: 0;
}

.title-final {
    display: inline-block;
    font-family: var(--f-display);
    font-weight: 600;
    opacity: 0;
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    transition: opacity 0.6s ease;
    white-space: nowrap;
}

.title.finalized .title-type {
    opacity: 0;
}

.title.finalized .title-final {
    opacity: 1;
    position: relative;
}

@keyframes blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0; }
}

.rule-expand {
    width: 100%;
    display: flex;
    justify-content: center;
    margin-top: var(--baseline);
}

.rule-expand-bar {
    display: block;
    height: 1px;
    width: 70vw;
    max-width: 52rem;
    background-color: var(--accent-1);
    transform: scaleX(0);
    transform-origin: center;
    transition: transform 2.5s cubic-bezier(0.25, 0.1, 0.25, 1);
}

.rule-expand.active .rule-expand-bar {
    transform: scaleX(1);
}

.opening-sub {
    font-family: var(--f-display);
    font-style: italic;
    font-size: clamp(1.1rem, 1.5vw, 1.45rem);
    color: var(--accent-1);
    letter-spacing: 0.08em;
    opacity: 0;
    transition: opacity 1.2s ease;
}

.opening-sub.visible {
    opacity: 1;
}

/* Prism Divider */
.prism-divider {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: calc(var(--baseline) * 2) 0;
    background-color: transparent;
}

.prism-divider svg {
    display: block;
}

.prism-divider .facet {
    transform-origin: center;
    animation: breathe 4s ease-in-out infinite alternate;
}

.prism-divider .facet:nth-child(1) { animation-delay: 0s; }
.prism-divider .facet:nth-child(2) { animation-delay: 0.8s; }
.prism-divider .facet:nth-child(3) { animation-delay: 1.6s; }
.prism-divider .facet:nth-child(4) { animation-delay: 2.4s; }
.prism-divider .facet:nth-child(5) { animation-delay: 3.2s; }

@keyframes breathe {
    0%   { opacity: 0.7; }
    50%  { opacity: 1.0; }
    100% { opacity: 0.7; }
}

/* Thesis */
.section--thesis {
    min-height: 90vh;
    background-color: transparent;
}

.thesis-inner {
    max-width: 38rem;
    width: 100%;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: calc(var(--baseline) * 1.2);
}

.thesis-title {
    font-family: var(--f-display);
    font-weight: 600;
    font-size: clamp(2rem, 4.5vw, 3.6rem);
    line-height: 1.2;
    letter-spacing: 0.015em;
    color: var(--ink);
    margin-bottom: calc(var(--baseline) * 0.4);
    position: relative;
    display: inline-block;
    align-self: center;
}

.thesis-title::after {
    content: "";
    display: block;
    height: 1px;
    width: 0;
    background-color: var(--accent-1);
    margin: calc(var(--baseline) * 0.6) auto 0;
    transition: width 1.6s cubic-bezier(0.25, 0.1, 0.25, 1);
}

.section--thesis.visible .thesis-title::after {
    width: 4rem;
}

.thesis-body {
    font-family: var(--f-body);
    font-size: clamp(0.98rem, 1.1vw, 1.08rem);
    line-height: 1.9;
    color: var(--ink);
    letter-spacing: 0.01em;
    text-align: left;
}

/* Rhythm Section */
.section--rhythm {
    min-height: 100vh;
    background-color: #F5EBD8;
    padding: calc(var(--baseline) * 3) calc(var(--baseline) * 1.5);
}

.rhythm-inner {
    position: relative;
    width: 100%;
    max-width: 52rem;
    min-height: 60vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: calc(var(--baseline) * 2) 0;
}

.ruled-lines {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    pointer-events: none;
}

.ruled-line {
    display: block;
    width: 100%;
    height: 1px;
    background-color: var(--accent-2);
}

.ruled-line:nth-child(1)  { opacity: 0.15; }
.ruled-line:nth-child(2)  { opacity: 0.22; }
.ruled-line:nth-child(3)  { opacity: 0.30; }
.ruled-line:nth-child(4)  { opacity: 0.38; }
.ruled-line:nth-child(5)  { opacity: 0.46; }
.ruled-line:nth-child(6)  { opacity: 0.52; }
.ruled-line:nth-child(7)  { opacity: 0.52; }
.ruled-line:nth-child(8)  { opacity: 0.46; }
.ruled-line:nth-child(9)  { opacity: 0.38; }
.ruled-line:nth-child(10) { opacity: 0.30; }
.ruled-line:nth-child(11) { opacity: 0.22; }
.ruled-line:nth-child(12) { opacity: 0.15; }

.shard {
    position: absolute;
    width: 14px;
    height: 14px;
}

.shard-1 { top: 8%;  left: 12%; }
.shard-2 { top: 22%; right: 18%; }
.shard-3 { top: 38%; left: 30%; }
.shard-4 { top: 52%; right: 12%; }
.shard-5 { top: 66%; left: 20%; }
.shard-6 { top: 78%; right: 28%; }
.shard-7 { top: 90%; left: 8%; }

.rhythm-text {
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    gap: calc(var(--baseline) * 1.2);
    text-align: center;
    padding: calc(var(--baseline) * 1.5) 0;
}

.rhythm-text p {
    font-family: var(--f-type);
    font-size: clamp(0.95rem, 1.2vw, 1.15rem);
    line-height: 1.6;
    color: var(--ink);
    letter-spacing: 0.02em;
    min-height: 1.6em;
    transition: font-family 0.6s ease, font-size 0.6s ease, font-style 0.6s ease;
}

.rhythm-text p.finalized {
    font-family: var(--f-display);
    font-style: italic;
    font-weight: 500;
    font-size: clamp(1.2rem, 1.8vw, 1.6rem);
    letter-spacing: 0.01em;
}

.typewriter-target::after {
    content: "";
    display: inline-block;
    width: 2px;
    height: 1.2em;
    background-color: var(--accent-1);
    margin-left: 3px;
    vertical-align: -0.15em;
    animation: blink 0.53s step-end infinite;
    opacity: 0;
}

.typewriter-target.typing::after {
    opacity: 1;
}

.typewriter-target.finished::after {
    opacity: 0;
}

/* Closing */
.section--closing {
    min-height: 80vh;
    background-color: #3D2B1F;
    color: #F2E8D4;
    padding: calc(var(--baseline) * 3) calc(var(--baseline) * 1.5);
}

.closing-inner {
    max-width: 46rem;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: calc(var(--baseline) * 2);
}

.closing-phrase {
    font-family: var(--f-type);
    font-size: clamp(1.3rem, 2.4vw, 2rem);
    color: #F2E8D4;
    letter-spacing: 0.03em;
    line-height: 1.5;
    min-height: 1.5em;
    transition: font-family 0.6s ease, font-size 0.6s ease, letter-spacing 0.6s ease, font-style 0.6s ease;
}

.closing-phrase.finalized {
    font-family: var(--f-display);
    font-style: italic;
    font-weight: 500;
    font-size: clamp(1.8rem, 3.6vw, 3rem);
    color: #F2E8D4;
    letter-spacing: 0.01em;
}

.closing-phrase::after {
    background-color: var(--accent-3);
}

.closing-prism {
    display: block;
}

.closing-prism svg {
    display: block;
    animation: rotate 20s linear infinite;
    transform-origin: center;
}

.closing-prism .cfacet {
    animation: breathe 4s ease-in-out infinite alternate;
}

.closing-prism .cfacet:nth-child(2) { animation-delay: 0.0s; }
.closing-prism .cfacet:nth-child(3) { animation-delay: 0.6s; }
.closing-prism .cfacet:nth-child(4) { animation-delay: 1.2s; }
.closing-prism .cfacet:nth-child(5) { animation-delay: 1.8s; }
.closing-prism .cfacet:nth-child(6) { animation-delay: 2.4s; }
.closing-prism .cfacet:nth-child(7) { animation-delay: 3.0s; }

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

.colophon {
    font-family: var(--f-display);
    font-style: italic;
    font-size: clamp(0.85rem, 1vw, 1rem);
    color: var(--accent-3);
    letter-spacing: 0.15em;
    opacity: 0.75;
    text-transform: lowercase;
}

/* Responsive */
@media (max-width: 640px) {
    .section {
        padding: calc(var(--baseline) * 1.5) 1.2rem;
    }

    .rhythm-inner {
        min-height: 70vh;
    }

    .thesis-body {
        text-align: left;
    }

    .title-type, .title-final {
        font-size: 0.9em;
    }
}
