/* ============================================
   economic.wiki — Styles
   Light-academia meets radical pamphlet
   ============================================ */

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

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

body {
    font-family: 'Source Serif 4', Georgia, serif;
    color: #2b2d33;
    background-color: #f5f0e8;
    line-height: 1.72;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

/* ---------- Font Classes ---------- */
.caveat {
    font-family: 'Caveat', cursive;
}

.mono {
    font-family: 'IBM Plex Mono', monospace;
}

/* ---------- Linen Texture ---------- */
.linen-texture {
    background-image:
        repeating-linear-gradient(0deg, transparent, transparent 2px, rgba(0,0,0,0.015) 2px, rgba(0,0,0,0.015) 4px),
        repeating-linear-gradient(90deg, transparent, transparent 2px, rgba(0,0,0,0.01) 2px, rgba(0,0,0,0.01) 4px);
}

/* ---------- Torn Edge ---------- */
.torn-edge {
    clip-path: polygon(0 0, 3% 1%, 6% 0, 9% 0.5%, 12% 0, 15% 1.2%, 18% 0, 21% 0.8%, 24% 0, 27% 1%, 30% 0, 33% 0.5%, 36% 0, 39% 1.5%, 42% 0, 45% 0.3%, 48% 0, 51% 1%, 54% 0, 57% 0.7%, 60% 0, 63% 1.2%, 66% 0, 69% 0.5%, 72% 0, 75% 1%, 78% 0, 81% 0.8%, 84% 0, 87% 1.5%, 90% 0, 93% 0.5%, 96% 0, 100% 0, 100% 100%, 97% 99%, 94% 100%, 91% 99.5%, 88% 100%, 85% 98.8%, 82% 100%, 79% 99.2%, 76% 100%, 73% 99%, 70% 100%, 67% 99.5%, 64% 100%, 61% 98.5%, 58% 100%, 55% 99.7%, 52% 100%, 49% 99%, 46% 100%, 43% 99.3%, 40% 100%, 37% 98.8%, 34% 100%, 31% 99.5%, 28% 100%, 25% 99%, 22% 100%, 19% 99.2%, 16% 100%, 13% 98.5%, 10% 100%, 7% 99.5%, 4% 100%, 0 100%);
}

/* ============================================
   TITLE PAGE
   ============================================ */
#title-page {
    min-height: 100vh;
    background-color: #2b2d33;
    background-image:
        linear-gradient(to bottom, rgba(43,45,51,0.95), rgba(43,45,51,0.7)),
        repeating-linear-gradient(0deg, transparent, transparent 2px, rgba(255,255,255,0.02) 2px, rgba(255,255,255,0.02) 4px),
        repeating-linear-gradient(90deg, transparent, transparent 2px, rgba(255,255,255,0.015) 2px, rgba(255,255,255,0.015) 4px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.title-content {
    text-align: center;
    z-index: 2;
    padding: 0 2rem;
}

.title-heading {
    font-family: 'Libre Baskerville', 'Georgia', serif;
    font-weight: 700;
    font-size: clamp(3rem, 8vw, 6rem);
    color: #faf8f4;
    letter-spacing: 0.01em;
    line-height: 1.15;
    margin-bottom: 1.5rem;
}

.title-rule {
    width: 40%;
    height: 1px;
    background-color: #5a5f6b;
    margin: 0 auto 1.5rem;
}

.title-subtitle {
    font-family: 'Caveat', cursive;
    font-size: clamp(1.1rem, 2.5vw, 1.6rem);
    color: #8a8f9a;
    max-width: 600px;
    margin: 0 auto;
    opacity: 0;
    animation: fadeInSubtitle 1.2s ease-out 0.5s forwards;
}

@keyframes fadeInSubtitle {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Drifting Fish on Title Page */
.drifting-fish {
    position: absolute;
    bottom: 20%;
    left: -120px;
    z-index: 1;
    animation: driftFish 20s ease-in-out infinite alternate;
}

@keyframes driftFish {
    0% { transform: translateX(0) translateY(0); }
    25% { transform: translateX(30vw) translateY(-15px); }
    50% { transform: translateX(60vw) translateY(10px); }
    75% { transform: translateX(80vw) translateY(-8px); }
    100% { transform: translateX(calc(100vw + 120px)) translateY(5px); }
}

/* ============================================
   TROPICAL FISH — CSS Illustrations
   ============================================ */

/* --- Keynesian Angelfish --- */
.fish-angelfish {
    position: relative;
    width: 80px;
    height: 100px;
}

.fish-angelfish .fish-body {
    position: absolute;
    width: 50px;
    height: 50px;
    top: 25px;
    left: 15px;
    background: linear-gradient(135deg, #e8734a, #2a8f8f);
    border-radius: 50% 0 50% 0;
    transform: rotate(45deg);
}

.fish-angelfish .fish-fin-top {
    position: absolute;
    width: 20px;
    height: 30px;
    top: 5px;
    left: 30px;
    background: linear-gradient(to bottom, rgba(232,115,74,0.7), rgba(42,143,143,0.5));
    border-radius: 50% 50% 0 0;
    transform: rotate(10deg);
}

.fish-angelfish .fish-fin-bottom {
    position: absolute;
    width: 18px;
    height: 25px;
    bottom: 8px;
    left: 32px;
    background: linear-gradient(to top, rgba(42,143,143,0.7), rgba(232,115,74,0.5));
    border-radius: 0 0 50% 50%;
    transform: rotate(-5deg);
}

.fish-angelfish .fish-tail {
    position: absolute;
    width: 0;
    height: 0;
    top: 35px;
    left: -5px;
    border-top: 15px solid transparent;
    border-bottom: 15px solid transparent;
    border-right: 20px solid #2a8f8f;
}

.fish-angelfish .fish-eye {
    position: absolute;
    width: 8px;
    height: 8px;
    top: 38px;
    right: 18px;
    background: #faf8f4;
    border-radius: 50%;
    z-index: 2;
}

.fish-angelfish .fish-eye::after {
    content: '';
    position: absolute;
    width: 4px;
    height: 4px;
    top: 2px;
    left: 2px;
    background: #2b2d33;
    border-radius: 50%;
}

/* --- Monetarist Puffer --- */
.fish-puffer {
    position: relative;
    width: 90px;
    height: 90px;
}

.puffer-body {
    position: absolute;
    width: 55px;
    height: 55px;
    top: 17px;
    left: 17px;
    background: #e8734a;
    border-radius: 50%;
}

.puffer-spine {
    position: absolute;
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-bottom: 12px solid #e8734a;
}

.puffer-spine-1 { top: 5px; left: 35px; transform: rotate(0deg); }
.puffer-spine-2 { top: 10px; right: 8px; transform: rotate(60deg); }
.puffer-spine-3 { bottom: 10px; right: 8px; transform: rotate(120deg); }
.puffer-spine-4 { bottom: 5px; left: 35px; transform: rotate(180deg); }
.puffer-spine-5 { bottom: 10px; left: 8px; transform: rotate(240deg); }
.puffer-spine-6 { top: 10px; left: 8px; transform: rotate(300deg); }

.puffer-eye {
    position: absolute;
    width: 10px;
    height: 10px;
    top: 32px;
    right: 22px;
    background: #faf8f4;
    border-radius: 50%;
    z-index: 2;
}

.puffer-eye::after {
    content: '';
    position: absolute;
    width: 5px;
    height: 5px;
    top: 2.5px;
    left: 2.5px;
    background: #2b2d33;
    border-radius: 50%;
}

/* --- Austrian Swordtail --- */
.fish-swordtail {
    position: relative;
    width: 100px;
    height: 60px;
}

.swordtail-body {
    position: absolute;
    width: 60px;
    height: 35px;
    top: 12px;
    left: 20px;
    background: #2a8f8f;
    clip-path: polygon(0 40%, 70% 0, 100% 50%, 70% 100%, 0 60%);
}

.swordtail-sword {
    position: absolute;
    width: 30px;
    height: 4px;
    top: 35px;
    left: -5px;
    background: linear-gradient(to left, #2a8f8f, transparent);
    border-radius: 0 0 0 2px;
}

.swordtail-eye {
    position: absolute;
    width: 7px;
    height: 7px;
    top: 24px;
    right: 22px;
    background: #faf8f4;
    border-radius: 50%;
    z-index: 2;
}

.swordtail-eye::after {
    content: '';
    position: absolute;
    width: 3px;
    height: 3px;
    top: 2px;
    left: 2px;
    background: #2b2d33;
    border-radius: 50%;
}

/* --- Marxist Betta --- */
.fish-betta {
    position: relative;
    width: 100px;
    height: 100px;
}

.betta-body {
    position: absolute;
    width: 40px;
    height: 30px;
    top: 35px;
    left: 30px;
    background: linear-gradient(135deg, #e8734a, #2a8f8f);
    border-radius: 50% 30% 30% 50%;
}

.betta-fin {
    position: absolute;
    border-radius: 50%;
    opacity: 0.7;
}

.betta-fin-1 {
    width: 35px;
    height: 45px;
    top: 10px;
    left: 25px;
    background: linear-gradient(180deg, rgba(232,115,74,0.6), rgba(42,143,143,0.4));
    transform: rotate(-15deg);
}

.betta-fin-2 {
    width: 30px;
    height: 40px;
    bottom: 10px;
    left: 28px;
    background: linear-gradient(0deg, rgba(42,143,143,0.6), rgba(232,115,74,0.4));
    transform: rotate(10deg);
}

.betta-fin-3 {
    width: 25px;
    height: 30px;
    top: 20px;
    left: 15px;
    background: rgba(232,115,74,0.5);
    transform: rotate(-25deg);
}

.betta-tail {
    position: absolute;
    width: 40px;
    height: 50px;
    top: 22px;
    left: -5px;
    background: linear-gradient(90deg, rgba(232,115,74,0.8), rgba(42,143,143,0.6));
    border-radius: 50% 0 50% 30%;
    transform: rotate(10deg);
}

.betta-eye {
    position: absolute;
    width: 7px;
    height: 7px;
    top: 42px;
    right: 28px;
    background: #faf8f4;
    border-radius: 50%;
    z-index: 2;
}

.betta-eye::after {
    content: '';
    position: absolute;
    width: 3px;
    height: 3px;
    top: 2px;
    left: 2px;
    background: #2b2d33;
    border-radius: 50%;
}

/* Small fish variant */
.fish-small {
    transform: scale(0.4);
}

/* ============================================
   TABLE OF CONTENTS
   ============================================ */
#toc {
    background-color: #f5f0e8;
    padding: 5rem 3vw;
    max-width: 800px;
    margin: 0 auto;
}

.toc-heading {
    font-family: 'Libre Baskerville', serif;
    font-weight: 700;
    font-size: clamp(1.4rem, 3vw, 2rem);
    color: #2b2d33;
    letter-spacing: 0.01em;
    line-height: 1.15;
    margin-bottom: 2.5rem;
    text-align: center;
}

.toc-list {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.toc-item {
    display: flex;
    align-items: baseline;
    text-decoration: none;
    color: #2b2d33;
    padding: 0.4rem 0;
    transition: color 0.25s ease;
}

.toc-item:hover {
    color: #e8734a;
}

.toc-term {
    font-family: 'Libre Baskerville', serif;
    font-size: 1.15rem;
    font-weight: 400;
    white-space: nowrap;
    transition: color 0.25s ease;
}

.toc-item:hover .toc-term {
    color: #e8734a;
}

.toc-leader {
    flex-grow: 1;
    border-bottom: 1px dotted #8a8f9a;
    margin: 0 0.8rem;
    min-width: 2rem;
    position: relative;
    top: -4px;
    transition: border-bottom-style 0.25s ease;
}

.toc-item:hover .toc-leader {
    border-bottom-style: solid;
    border-bottom-color: #e8734a;
}

.toc-category {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.8rem;
    color: #8a8f9a;
    white-space: nowrap;
    transition: color 0.25s ease;
}

.toc-item:hover .toc-category {
    color: #2a8f8f;
}

/* ============================================
   MASONRY KNOWLEDGE GRID
   ============================================ */
#masonry-grid {
    background-color: #f5f0e8;
    padding: 3rem 3vw 6rem;
}

.masonry-container {
    max-width: 1100px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.4rem;
    align-items: start;
}

/* --- Fade-in Animation --- */
.fade-in {
    opacity: 0;
    transform: translateY(12px);
    transition: opacity 0.4s ease-out, transform 0.4s ease-out;
}

.fade-in.visible {
    opacity: 1;
    transform: translateY(0);
}

/* --- Base Cell --- */
.cell {
    border-radius: 2px;
    overflow: hidden;
}

/* --- Definition Tiles --- */
.definition-tile {
    background-color: #f5f0e8;
    border-left: 4px solid #e8734a;
    padding: 1.4rem 1.3rem;
    transition: border-left-width 0.2s ease-out, background-color 0.2s ease-out;
}

.definition-tile:hover {
    border-left-width: 8px;
    background-color: #faf8f4;
}

.definition-term {
    font-family: 'Libre Baskerville', serif;
    font-weight: 700;
    font-size: clamp(1.1rem, 2vw, 1.4rem);
    color: #2b2d33;
    letter-spacing: 0.01em;
    line-height: 1.15;
    margin-bottom: 0.7rem;
}

.definition-text {
    font-family: 'Source Serif 4', Georgia, serif;
    font-size: clamp(0.9rem, 1.3vw, 1rem);
    color: #2b2d33;
    line-height: 1.72;
    margin-bottom: 0.8rem;
}

.annotation {
    display: block;
    font-size: 0.95rem;
    color: #2a8f8f;
    font-style: normal;
    margin-top: 0.5rem;
}

/* --- Theory Panels --- */
.theory-panel {
    background-color: #f5f0e8;
    padding: 1.8rem 1.5rem;
    position: relative;
}

.theory-heading {
    font-family: 'Libre Baskerville', serif;
    font-weight: 700;
    font-size: clamp(1.2rem, 2vw, 1.5rem);
    color: #2b2d33;
    letter-spacing: 0.01em;
    line-height: 1.15;
    margin-bottom: 1rem;
}

.theory-text {
    font-family: 'Source Serif 4', Georgia, serif;
    font-size: clamp(0.9rem, 1.3vw, 1.05rem);
    color: #2b2d33;
    line-height: 1.72;
    margin-bottom: 0.8rem;
}

.formula {
    font-size: 1rem;
    color: #5a5f6b;
    background: rgba(90,95,107,0.08);
    padding: 0.6rem 1rem;
    border-radius: 2px;
    margin: 0.8rem 0;
    text-align: center;
}

.marginalia {
    display: block;
    font-size: 0.95rem;
    color: #2a8f8f;
    margin-top: 0.8rem;
    padding-left: 1rem;
    border-left: 2px solid rgba(42,143,143,0.3);
}

/* Coffee stains */
.coffee-stain {
    position: absolute;
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: radial-gradient(ellipse, rgba(139,119,86,0.08) 40%, transparent 70%);
    top: 10px;
    right: 10px;
    pointer-events: none;
}

.coffee-stain-alt {
    top: auto;
    right: auto;
    bottom: 15px;
    left: 15px;
}

/* --- Diagram Slots --- */
.diagram-slot {
    background-color: #5a5f6b;
    padding: 1.2rem;
}

.diagram-container {
    width: 100%;
    position: relative;
}

.econ-diagram {
    width: 100%;
    height: auto;
}

.diagram-curve {
    stroke-dasharray: 1000;
    stroke-dashoffset: 0;
    transition: stroke-dashoffset 0.8s ease-out;
}

.diagram-slot:hover .diagram-curve {
    animation: drawCurve 0.8s ease-out forwards;
}

@keyframes drawCurve {
    from { stroke-dashoffset: 1000; }
    to { stroke-dashoffset: 0; }
}

.diagram-label {
    font-size: 0.8rem;
    color: #8a8f9a;
    text-align: center;
    margin-top: 0.8rem;
}

/* --- Fish Cards --- */
.fish-card {
    background-color: #faf8f4;
    padding: 1.5rem 1.2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.fish-card-fish {
    margin-bottom: 1rem;
    transition: transform 0.3s ease;
}

.fish-card:hover .fish-card-fish {
    transform: rotate(5deg) scale(1.05);
}

.fish-card-quote {
    font-size: 1.05rem;
    color: #5a5f6b;
    line-height: 1.5;
}

/* Redacted block */
.redacted-block {
    width: 100%;
    height: 60px;
    background: #2b2d33;
    opacity: 0.85;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1rem;
}

.redacted-label {
    color: #e8734a;
    font-size: 1.3rem;
    font-weight: 700;
    letter-spacing: 0.3em;
    text-transform: uppercase;
}


/* --- Hover highlights with pale parchment --- */
.toc-item:hover {
    background-color: #eae4d8;
    border-radius: 2px;
}

.theory-panel:hover {
    background-color: #eae4d8;
}

.cell:nth-child(even).definition-tile:hover {
    background-color: #eae4d8;
}

/* ============================================
   LINKS
   ============================================ */
a {
    color: #2b2d33;
    text-decoration: none;
    border-bottom: 2px solid #2a8f8f;
    transition: border-bottom-color 0.15s ease;
}

a:hover {
    border-bottom-color: #e8734a;
}

/* ============================================
   FOOTER
   ============================================ */
#footer {
    background-color: #2b2d33;
    padding: 3rem 3vw;
    text-align: center;
}

.footer-rule {
    width: 40%;
    height: 1px;
    background-color: #5a5f6b;
    margin: 0 auto 1.5rem;
}

.footer-text {
    font-size: 1.1rem;
    color: #8a8f9a;
}

.footer-fish {
    margin-top: 1.5rem;
    display: flex;
    justify-content: center;
    opacity: 0.5;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 900px) {
    .masonry-container {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 600px) {
    .masonry-container {
        grid-template-columns: 1fr;
    }
    
    #toc {
        padding: 3rem 5vw;
    }
    
    .toc-category {
        display: none;
    }
    
    .toc-leader {
        display: none;
    }
    
    .title-heading {
        font-size: clamp(2rem, 10vw, 3.5rem);
    }
}
