/* ========================================
   rational.business — Goblincore Bureaucracy
   ======================================== */

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

:root {
    --deep-forest: #1a2e1a;
    --parchment: #faf3e0;
    --fuchsia: #ff2d8b;
    --lime: #a8ff04;
    --tangerine: #ff8c42;
    --cyan: #42d4f4;
    --gold: #c4a35a;
    --ink: #0f0e0a;
    --birch: #f0ece4;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    padding: 0;
    background: var(--ink);
    color: var(--ink);
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 400;
    line-height: 1.7;
    font-size: clamp(0.95rem, 1.8vw, 1.15rem);
    overflow-x: hidden;
}

/* Paper grain noise texture */
.section-ledger,
.section-hero {
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.03'/%3E%3C/svg%3E");
}

/* ---- Typography ---- */
h1, .hero-title {
    font-family: 'Playfair Display', serif;
    font-weight: 700;
    letter-spacing: 0.02em;
}

h2, .section-heading {
    font-family: 'Caveat', cursive;
    font-weight: 700;
    font-size: clamp(1.5rem, 4vw, 3rem);
    color: var(--ink);
    text-align: center;
    margin-bottom: 2rem;
}

h3 {
    font-family: 'Caveat', cursive;
    font-weight: 700;
    font-size: clamp(1.2rem, 2.5vw, 1.8rem);
}

.chart-label-text {
    font-family: 'Inconsolata', monospace;
    font-size: 10px;
    fill: #a8ff0488;
    letter-spacing: 0.05em;
}

/* ---- Reveal animation ---- */
.reveal-item {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.7s ease, transform 0.7s ease;
}
.reveal-item.visible {
    opacity: 1;
    transform: translateY(0);
}

/* ---- SECTION: Hero (Counting House) ---- */
.section-hero {
    position: relative;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background-color: var(--parchment);
    clip-path: polygon(0 0, 100% 0, 100% 95%, 0% 100%);
    z-index: 1;
    overflow: hidden;
    transform: rotate(-3deg);
    margin: -2rem -2rem 0;
    padding: clamp(4rem, 8vh, 8rem) clamp(2rem, 6vw, 6rem);
}

.hero-inner {
    position: relative;
    z-index: 2;
    text-align: center;
    max-width: 900px;
    width: 100%;
}

.certificate-border {
    position: relative;
    border: 3px double var(--gold);
    padding: clamp(2rem, 5vw, 4rem);
    background: rgba(250, 243, 224, 0.7);
}

.certificate-ornament {
    position: absolute;
    width: 30px;
    height: 30px;
    border-color: var(--gold);
    border-style: solid;
}
.certificate-ornament.top-left { top: 8px; left: 8px; border-width: 2px 0 0 2px; }
.certificate-ornament.top-right { top: 8px; right: 8px; border-width: 2px 2px 0 0; }
.certificate-ornament.bottom-left { bottom: 8px; left: 8px; border-width: 0 0 2px 2px; }
.certificate-ornament.bottom-right { bottom: 8px; right: 8px; border-width: 0 2px 2px 0; }

.hero-title {
    font-size: clamp(3rem, 10vw, 8rem);
    color: var(--ink);
    margin-bottom: 0.5rem;
    line-height: 1.1;
}

.hero-subtitle {
    font-family: 'Inconsolata', monospace;
    font-size: clamp(0.8rem, 1.5vw, 1rem);
    color: var(--gold);
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.hero-chart {
    position: absolute;
    bottom: -20px;
    left: 0;
    width: 100%;
    height: 200px;
    opacity: 0.2;
    z-index: -1;
}

.hero-chart .chart-grid line {
    stroke: var(--gold);
    stroke-width: 0.5;
    opacity: 0.3;
}

.hero-line {
    fill: none;
    stroke: var(--fuchsia);
    stroke-width: 3;
    stroke-dasharray: 1200;
    stroke-dashoffset: 1200;
    transition: stroke-dashoffset 3s ease-out;
}
.hero-line.drawn {
    stroke-dashoffset: 0;
}

.mushroom-svg {
    fill: none;
    stroke: var(--fuchsia);
    stroke-width: 2;
}
.mushroom-svg.small {
    stroke-width: 1.5;
}

/* Vignette overlay */
.vignette {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: radial-gradient(ellipse at center, transparent 50%, rgba(15,14,10,0.25) 100%);
    pointer-events: none;
    z-index: 3;
}

/* Moss edges */
.moss-edge {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 80px;
    z-index: 4;
    pointer-events: none;
}
.moss-edge-left {
    left: 0;
    background: linear-gradient(to right,
        rgba(168,255,4,0.15) 0%,
        rgba(168,255,4,0.08) 30%,
        transparent 100%
    );
    box-shadow:
        inset 20px 0 40px rgba(168,255,4,0.06),
        inset 10px 0 20px rgba(168,255,4,0.04);
}
.moss-edge-right {
    right: 0;
    background: linear-gradient(to left,
        rgba(168,255,4,0.15) 0%,
        rgba(168,255,4,0.08) 30%,
        transparent 100%
    );
}

/* Scroll indicator */
.scroll-indicator {
    position: absolute;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 5;
    animation: acornBounce 2s ease-in-out infinite;
}

@keyframes acornBounce {
    0%, 100% { transform: translateX(-50%) translateY(0); }
    50% { transform: translateX(-50%) translateY(12px); }
}

/* ---- SECTION: Ledger Spread ---- */
.section-ledger {
    position: relative;
    background-color: var(--parchment);
    clip-path: polygon(0 8%, 100% 0%, 100% 92%, 0% 100%);
    margin-top: -60px;
    z-index: 2;
    padding: clamp(6rem, 10vh, 10rem) clamp(2rem, 6vw, 6rem);
    box-shadow: 0 -10px 30px rgba(15,14,10,0.15);
}

.ledger-grid {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background-image:
        repeating-linear-gradient(0deg, transparent, transparent 39px, rgba(196,163,90,0.12) 39px, rgba(196,163,90,0.12) 40px),
        repeating-linear-gradient(90deg, transparent, transparent 39px, rgba(196,163,90,0.06) 39px, rgba(196,163,90,0.06) 40px);
    pointer-events: none;
}

.gear-divider {
    display: flex;
    justify-content: center;
    margin-bottom: 2rem;
}

.gear-spin {
    transform-origin: 30px 30px;
    animation: spin 60s linear infinite;
}

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

/* Dept cards */
.dept-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 2rem;
    max-width: 1100px;
    margin: 0 auto;
}

.dept-card {
    position: relative;
    background: rgba(250,243,224,0.9);
    border: 1px solid var(--gold);
    border-radius: 8px;
    padding: 2rem;
    box-shadow: 4px 6px 20px rgba(15,14,10,0.12);
}

.fern-corner {
    position: absolute;
    top: -5px;
    right: -5px;
    animation: sway 4s ease-in-out infinite;
}

@keyframes sway {
    0%, 100% { transform: rotate(-2deg); }
    50% { transform: rotate(2deg); }
}

.dept-name {
    color: var(--ink);
    margin-bottom: 0.5rem;
}

.dept-desc {
    font-weight: 300;
    font-size: 0.95rem;
    margin-bottom: 1.5rem;
    color: #3a3a2f;
}

/* Mini bar chart */
.bar-chart { display: flex; flex-direction: column; gap: 0.6rem; }
.bar-row { display: flex; align-items: center; gap: 0.5rem; }
.bar-label, .bar-value {
    font-family: 'Inconsolata', monospace;
    font-size: 0.8rem;
    color: var(--ink);
    width: 30px;
    letter-spacing: 0.05em;
}
.bar-track {
    flex: 1;
    height: 14px;
    background: rgba(15,14,10,0.06);
    border-radius: 3px;
    overflow: hidden;
}
.bar-fill {
    height: 100%;
    width: 0%;
    border-radius: 3px;
    transition: width 1.2s ease-out;
}

/* Mini donut */
.donut-chart-wrap {
    display: flex;
    align-items: center;
    gap: 1rem;
}
.donut-chart {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: conic-gradient(
        var(--fuchsia) 0deg 151.2deg,
        var(--lime) 151.2deg 262.8deg,
        var(--tangerine) 262.8deg 360deg
    );
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    opacity: 0;
    transform: scale(0.8);
    transition: opacity 0.8s ease, transform 0.8s ease;
}
.donut-chart.animated {
    opacity: 1;
    transform: scale(1);
}
.donut-hole {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: var(--parchment);
}
.donut-labels {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}
.donut-label {
    font-family: 'Inconsolata', monospace;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
}

/* Mini scatter */
.scatter-chart {
    width: 100%;
    max-width: 200px;
}
.scatter-line {
    stroke-dasharray: 400;
    stroke-dashoffset: 400;
    transition: stroke-dashoffset 2s ease-out;
}
.scatter-line.drawn {
    stroke-dashoffset: 0;
}

/* ---- SECTION: Filing Cabinet ---- */
.section-filing {
    position: relative;
    background: linear-gradient(135deg, var(--deep-forest) 0%, var(--ink) 100%);
    clip-path: polygon(0 0%, 100% 6%, 100% 100%, 0% 94%);
    margin-top: -60px;
    z-index: 3;
    padding: clamp(6rem, 10vh, 10rem) clamp(2rem, 6vw, 6rem);
    box-shadow: 0 -10px 30px rgba(15,14,10,0.3);
}

.timeline {
    position: relative;
    max-width: 600px;
    margin: 0 auto;
    padding-left: 40px;
}

.timeline-path-svg {
    position: absolute;
    left: 10px;
    top: 0;
    width: 4px;
    height: 100%;
}

.timeline-line {
    transition: stroke-dashoffset 2.5s ease-out;
}
.timeline-line.drawn {
    stroke-dashoffset: 0;
}

.timeline-entry {
    position: relative;
    margin-bottom: 2.5rem;
    padding-left: 1rem;
}

.timeline-date {
    font-family: 'Inconsolata', monospace;
    font-size: 1rem;
    color: var(--gold);
    font-weight: 400;
    letter-spacing: 0.05em;
}

.timeline-icon {
    display: inline-block;
    vertical-align: middle;
    margin-left: 0.5rem;
}

.timeline-text {
    color: var(--birch);
    font-weight: 300;
    margin-top: 0.3rem;
    font-size: 0.95rem;
}

/* ---- SECTION: Observation Terrarium ---- */
.section-terrarium {
    position: relative;
    background: linear-gradient(180deg, var(--deep-forest) 0%, var(--ink) 60%, var(--deep-forest) 100%);
    clip-path: polygon(0 6%, 100% 0%, 100% 94%, 0% 100%);
    margin-top: -60px;
    z-index: 4;
    padding: clamp(6rem, 10vh, 10rem) clamp(2rem, 6vw, 6rem);
    box-shadow: 0 -10px 30px rgba(15,14,10,0.3);
}

.terrarium-subtitle {
    text-align: center;
    font-family: 'Inconsolata', monospace;
    color: var(--gold);
    letter-spacing: 0.1em;
    font-size: 0.9rem;
    margin-bottom: 3rem;
}

.terrarium-charts {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
    max-width: 1200px;
    margin: 0 auto;
}

.chart-panel {
    background: rgba(26,46,26,0.5);
    border: 1px solid rgba(196,163,90,0.25);
    border-radius: 6px;
    padding: 1.5rem;
}

.chart-title {
    color: var(--birch);
    margin-bottom: 1rem;
    font-size: 1.3rem;
}

.spore-chart {
    width: 100%;
    max-height: 200px;
}

.spore-line {
    stroke-dasharray: 600;
    stroke-dashoffset: 600;
    transition: stroke-dashoffset 2s ease-out;
}
.spore-line.drawn {
    stroke-dashoffset: 0;
}

/* Big donut */
.big-donut-wrap {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    flex-wrap: wrap;
}

.big-donut {
    width: 140px;
    height: 140px;
    border-radius: 50%;
    background: conic-gradient(
        var(--fuchsia) 0deg 151.2deg,
        var(--lime) 151.2deg 252deg,
        var(--cyan) 252deg 313.2deg,
        var(--tangerine) 313.2deg 360deg
    );
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transform: scale(0.8);
    transition: opacity 0.8s ease, transform 0.8s ease;
    flex-shrink: 0;
}
.big-donut.animated {
    opacity: 1;
    transform: scale(1);
}
.big-donut-hole {
    width: 90px;
    height: 90px;
    border-radius: 50%;
    background: #1a2e1a;
    display: flex;
    align-items: center;
    justify-content: center;
}
.big-donut-center {
    font-family: 'Playfair Display', serif;
    color: var(--birch);
    font-size: 1.3rem;
}
.big-donut-legend {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}
.legend-item {
    font-family: 'Inconsolata', monospace;
    font-size: 0.8rem;
    color: var(--birch);
    display: flex;
    align-items: center;
    gap: 0.4rem;
    letter-spacing: 0.05em;
}
.legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
}

/* Lichen bars */
.lichen-bars {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}
.lichen-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.lichen-label {
    font-family: 'Inconsolata', monospace;
    font-size: 0.75rem;
    color: var(--birch);
    width: 80px;
    letter-spacing: 0.05em;
}
.lichen-track {
    flex: 1;
    height: 16px;
    background: rgba(168,255,4,0.08);
    border-radius: 3px;
    overflow: hidden;
}
.lichen-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(to right, var(--lime), var(--deep-forest));
    border-radius: 3px;
    transition: width 1.2s ease-out;
}
.lichen-value {
    font-family: 'Inconsolata', monospace;
    font-size: 0.75rem;
    color: var(--lime);
    width: 35px;
    letter-spacing: 0.05em;
}

/* ---- SECTION: Archive Basement ---- */
.section-archive {
    position: relative;
    background: linear-gradient(135deg, var(--ink) 0%, var(--deep-forest) 50%, var(--ink) 100%);
    clip-path: polygon(0 3%, 100% 0%, 100% 100%, 0% 100%);
    margin-top: -60px;
    z-index: 5;
    padding: clamp(6rem, 10vh, 10rem) clamp(2rem, 6vw, 6rem);
    padding-bottom: clamp(8rem, 15vh, 14rem);
    min-height: 80vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.archive-content {
    max-width: 650px;
    text-align: center;
    z-index: 2;
    position: relative;
}

.quill-svg {
    margin-bottom: 2rem;
    opacity: 0.7;
}

.memo-text {
    color: var(--birch);
}

.memo-line {
    font-family: 'Caveat', cursive;
    font-size: clamp(1.1rem, 2.5vw, 1.5rem);
    line-height: 1.8;
    margin-bottom: 1.5rem;
    color: var(--birch);
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}
.memo-line.visible {
    opacity: 1;
    transform: translateY(0);
}

.firm-seal {
    margin-top: 3rem;
}

/* Moss growing from bottom */
.moss-bottom {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 80px;
    background: linear-gradient(to top,
        rgba(168,255,4,0.12) 0%,
        rgba(168,255,4,0.06) 40%,
        transparent 100%
    );
    box-shadow:
        inset 0 -20px 40px rgba(168,255,4,0.08),
        inset 0 -40px 80px rgba(26,46,26,0.3);
    pointer-events: none;
    z-index: 1;
}

/* ---- Moth flutter animation (used in JS for hover) ---- */
@keyframes flutter {
    0%, 100% { transform: scaleX(1); }
    50% { transform: scaleX(0.7); }
}

/* ---- Responsive ---- */
@media (max-width: 1024px) {
    .section-hero { transform: rotate(-1.5deg); }
    .section-ledger { clip-path: polygon(0 5%, 100% 0%, 100% 95%, 0% 100%); }
    .section-filing { clip-path: polygon(0 0%, 100% 4%, 100% 100%, 0% 96%); }
    .section-terrarium { clip-path: polygon(0 4%, 100% 0%, 100% 96%, 0% 100%); }
    .section-archive { clip-path: polygon(0 2%, 100% 0%, 100% 100%, 0% 100%); }
}

@media (max-width: 768px) {
    .section-hero { transform: rotate(-1deg); margin: -1rem -1rem 0; }
    .section-ledger { clip-path: polygon(0 3%, 100% 0%, 100% 97%, 0% 100%); }
    .section-filing { clip-path: polygon(0 0%, 100% 2%, 100% 100%, 0% 98%); }
    .section-terrarium { clip-path: polygon(0 2%, 100% 0%, 100% 98%, 0% 100%); }
    .section-archive { clip-path: polygon(0 1%, 100% 0%, 100% 100%, 0% 100%); }

    .dept-cards { grid-template-columns: 1fr; }
    .terrarium-charts { grid-template-columns: 1fr; }
    .big-donut-wrap { flex-direction: column; align-items: center; }

    .hero-title { font-size: clamp(2.5rem, 12vw, 4rem); }
}
