/* ============================================
   rinji.dev — styles.css
   Goblincore Developer Workshop
   ============================================ */

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Source Serif 4', Georgia, serif;
    font-weight: 400;
    font-size: clamp(1rem, 1.1vw, 1.15rem);
    line-height: 1.75;
    color: #b5b0a0;
    background: #0d0d08;
    overflow-x: hidden;
}

/* Palette: #3D4A2A sidebar lichen, #8E44AD aurora violet */

/* --- Aurora Canopy (Background) --- */
.aurora-layer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
}

.aurora-green {
    background: radial-gradient(ellipse 800px 200px at 30% 15%, rgba(46,204,113,0.06), transparent);
    animation: aurora-drift-1 45s ease-in-out infinite alternate;
}

.aurora-blue {
    background: radial-gradient(ellipse 600px 300px at 60% 10%, rgba(10,189,227,0.04), transparent);
    animation: aurora-drift-2 60s ease-in-out infinite alternate;
}

.aurora-violet {
    background: radial-gradient(ellipse 500px 250px at 50% 20%, rgba(142,68,173,0.03), transparent);
    animation: aurora-drift-3 75s ease-in-out infinite alternate;
}

@keyframes aurora-drift-1 {
    0% { transform: translate(0, 0); }
    100% { transform: translate(80px, 30px); }
}

@keyframes aurora-drift-2 {
    0% { transform: translate(0, 0); }
    100% { transform: translate(-60px, 20px); }
}

@keyframes aurora-drift-3 {
    0% { transform: translate(0, 0); }
    100% { transform: translate(40px, -25px); }
}

/* --- Spore Particles --- */
.spore-container {
    position: fixed;
    top: 0;
    left: 280px;
    width: calc(100% - 280px);
    height: 100%;
    pointer-events: none;
    z-index: 1;
    overflow: hidden;
}

.spore {
    position: absolute;
    border-radius: 50%;
    background: #4a7a3a;
    animation: spore-rise linear infinite;
}

@keyframes spore-rise {
    0% { transform: translateY(100vh) translateX(0); opacity: 0; }
    10% { opacity: 1; }
    90% { opacity: 1; }
    100% { transform: translateY(-100px) translateX(20px); opacity: 0; }
}

/* --- Sidebar --- */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 280px;
    height: 100vh;
    background: #1a1a0e;
    z-index: 100;
    overflow: hidden;
}

.sidebar-texture {
    position: absolute;
    inset: 0;
    background:
        repeating-linear-gradient(
            180deg,
            transparent,
            transparent 8px,
            rgba(42,42,26,0.08) 8px,
            rgba(42,42,26,0.08) 9px
        ),
        radial-gradient(circle 3px at 30% 20%, rgba(61,74,42,0.05), transparent),
        radial-gradient(circle 5px at 70% 50%, rgba(61,74,42,0.05), transparent),
        radial-gradient(circle 4px at 50% 80%, rgba(61,74,42,0.05), transparent);
    /* Design palette: #3d4a2a #8e44ad */
    pointer-events: none;
}

.sidebar-aurora-glow {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 80px;
    background: linear-gradient(to bottom, rgba(46,204,113,0.08), transparent);
    animation: sidebar-glow 8s ease-in-out infinite alternate;
    pointer-events: none;
}

@keyframes sidebar-glow {
    0% { opacity: 0.3; }
    100% { opacity: 1; }
}

.root-network {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    opacity: 0.6;
}

.root-network path {
    stroke-dasharray: 1000;
    stroke-dashoffset: 1000;
    transition: stroke-dashoffset 0.1s linear;
}

.sidebar-content {
    position: relative;
    z-index: 2;
    padding: 40px 20px;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.sidebar-title {
    font-family: 'Roboto Slab', serif;
    font-weight: 700;
    font-size: 3rem;
    color: #c9a84c;
    writing-mode: vertical-rl;
    text-orientation: upright;
    letter-spacing: 0.15em;
    margin-bottom: 40px;
    align-self: center;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 500;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #5a6a5a;
    text-decoration: none;
    padding: 8px 12px;
    background: rgba(26,26,14,0.6);
    border: 1px solid rgba(74,90,58,0.2);
    clip-path: polygon(2% 0%, 98% 1%, 100% 3%, 99% 97%, 97% 100%, 3% 99%, 0% 96%, 1% 2%);
    transition: color 0.3s, background 0.3s, border-color 0.3s;
    position: relative;
}

.nav-item::after {
    content: '';
    position: absolute;
    bottom: 2px;
    left: 12px;
    right: 12px;
    height: 1px;
    background: #c9a84c;
    transform: scaleX(0);
    transition: transform 0.3s ease;
}

.nav-item.active {
    color: #c9a84c;
    background: rgba(42,42,26,0.4);
    border-color: rgba(74,122,58,0.3);
}

.nav-item.active::after {
    transform: scaleX(1);
}

.nav-item:hover {
    color: #c9a84c;
}

.mushroom-glyph {
    flex-shrink: 0;
}

/* --- Mobile Top Bar --- */
.mobile-topbar {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 56px;
    background: #1a1a0e;
    z-index: 200;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
}

.mobile-title {
    font-family: 'Roboto Slab', serif;
    font-weight: 700;
    font-size: 1.5rem;
    color: #c9a84c;
}

.twig-hamburger {
    background: none;
    border: none;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 5px;
    padding: 8px;
}

.twig {
    display: block;
    width: 24px;
    height: 2px;
    background: #5a6a5a;
    clip-path: polygon(0% 0%, 95% 10%, 100% 50%, 97% 100%, 2% 90%);
    transition: transform 0.3s, opacity 0.3s;
}

.twig-hamburger.open .twig-1 {
    transform: rotate(45deg) translate(4px, 4px);
}
.twig-hamburger.open .twig-2 {
    opacity: 0;
}
.twig-hamburger.open .twig-3 {
    transform: rotate(-45deg) translate(4px, -4px);
}

/* --- Specimen Hall (Main Content) --- */
.specimen-hall {
    margin-left: 280px;
    position: relative;
    z-index: 2;
}

/* --- Sections --- */
.section {
    padding: 80px 60px;
    min-height: 80vh;
}

.section-inner {
    max-width: 900px;
    margin: 0 auto;
}

/* --- Threshold (Hero) --- */
.threshold {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.threshold-content {
    opacity: 0;
    animation: threshold-appear 2s ease forwards 0.5s;
}

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

.threshold-kanji {
    font-family: 'Roboto Slab', serif;
    font-weight: 700;
    font-size: clamp(5rem, 15vw, 12rem);
    color: #c9a84c;
    letter-spacing: 0.05em;
    line-height: 1;
    margin-bottom: 24px;
}

.threshold-subtitle {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 500;
    font-size: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #7a8a6a;
    margin-bottom: 16px;
}

.threshold-desc {
    font-family: 'Source Serif 4', serif;
    font-style: italic;
    font-size: 1.1rem;
    color: #5a6a5a;
}

/* --- Fade In Animation --- */
.fade-in {
    opacity: 0;
    transform: translateY(40px);
    transition: opacity 0.8s ease, transform 0.8s ease;
}

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

/* --- Typography --- */
h1 {
    font-family: 'Roboto Slab', serif;
    font-weight: 700;
    font-size: clamp(1.8rem, 5vw, 3.5rem);
    color: #c9a84c;
    letter-spacing: 0.02em;
    margin-bottom: 24px;
    line-height: 1.2;
}

h2 {
    font-family: 'Roboto Slab', serif;
    font-weight: 700;
    font-size: clamp(1.2rem, 3vw, 1.8rem);
    color: #7a8a6a;
    letter-spacing: 0.02em;
    margin-top: 48px;
    margin-bottom: 16px;
    line-height: 1.3;
}

p {
    margin-bottom: 20px;
}

em {
    font-weight: 600;
    color: #c9a84c;
    font-style: italic;
}

/* --- Section with Specimen --- */
.section-with-specimen {
    display: grid;
    grid-template-columns: 1fr 200px;
    gap: 40px;
    align-items: start;
}

.specimen-display {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 200px;
    position: sticky;
    top: 200px;
}

/* --- Code Specimen Blocks --- */
.code-specimen {
    margin: 32px 0;
    border-radius: 4px;
    border: 1px solid #4a5a3a;
    box-shadow: inset 0 0 30px rgba(46,204,113,0.05);
    overflow: hidden;
}

.code-label {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 16px;
    background: #1a1a0e;
    border-bottom: 1px solid #2a2a1a;
}

.code-filename {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 500;
    font-size: 0.8rem;
    color: #b5b0a0;
    letter-spacing: 0.04em;
}

.code-lang {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 500;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #5a6a5a;
}

.status-badge {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #c9a84c;
    margin-left: auto;
    animation: badge-pulse 4s ease-in-out infinite;
}

@keyframes badge-pulse {
    0%, 100% { background-color: #c9a84c; }
    50% { background-color: #4a7a3a; }
}

.code-block {
    background: #0d0d08;
    padding: 20px;
    overflow-x: auto;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.9rem;
    line-height: 1.6;
    color: #d4d0c0;
}

.code-block code {
    font-family: inherit;
}

/* Syntax Highlighting */
.kw { color: #2ecc71; }
.str { color: #c9a84c; }
.cm { color: #5a6a5a; font-style: italic; }
.fn { color: #0abde3; }

/* --- Decomposition Bands --- */
.decomposition-band {
    height: 40px;
    overflow: hidden;
    background: linear-gradient(to right, #2a2a1a, #1a1a0e, #2a2a1a);
}

.decomposition-band svg {
    display: block;
    width: 100%;
    height: 100%;
}

/* --- Spore Divider --- */
.spore-divider {
    position: relative;
    height: 60px;
    margin: 40px 0;
}

.spore-dot {
    position: absolute;
    border-radius: 50%;
    background: radial-gradient(circle, #c9a84c, #2a2a1a);
    opacity: 0.5;
}

/* --- 3D Dodecahedron --- */
.dodecahedron {
    width: 120px;
    height: 120px;
    position: relative;
    transform-style: preserve-3d;
    animation: specimen-rotate 20s linear infinite;
}

@keyframes specimen-rotate {
    0% { transform: rotateY(0deg) rotateX(0deg); }
    100% { transform: rotateY(360deg) rotateX(180deg); }
}

.face {
    position: absolute;
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, #2a2a1a, #1a1a0e);
    border: 1px solid #4a7a3a;
    clip-path: polygon(50% 0%, 100% 38%, 82% 100%, 18% 100%, 0% 38%);
    animation: face-glow 15s ease-in-out infinite;
}

@keyframes face-glow {
    0%, 100% { box-shadow: 0 0 10px rgba(46,204,113,0.1); }
    33% { box-shadow: 0 0 10px rgba(10,189,227,0.1); }
    66% { box-shadow: 0 0 10px rgba(142,68,173,0.1); }
}

.face-1  { transform: rotateY(0deg) translateZ(50px); opacity: 0.35; }
.face-2  { transform: rotateY(72deg) translateZ(50px); opacity: 0.25; }
.face-3  { transform: rotateY(144deg) translateZ(50px); opacity: 0.3; }
.face-4  { transform: rotateY(216deg) translateZ(50px); opacity: 0.2; }
.face-5  { transform: rotateY(288deg) translateZ(50px); opacity: 0.4; }
.face-6  { transform: rotateX(72deg) translateZ(50px); opacity: 0.15; }
.face-7  { transform: rotateX(144deg) translateZ(50px); opacity: 0.3; }
.face-8  { transform: rotateX(216deg) translateZ(50px); opacity: 0.25; }
.face-9  { transform: rotateX(288deg) translateZ(50px); opacity: 0.35; }
.face-10 { transform: rotateX(36deg) rotateY(36deg) translateZ(50px); opacity: 0.2; }
.face-11 { transform: rotateX(108deg) rotateY(108deg) translateZ(50px); opacity: 0.3; }
.face-12 { transform: rotateX(252deg) rotateY(180deg) translateZ(50px); opacity: 0.25; }

/* --- 3D Fractured Cube --- */
.cube-3d {
    width: 100px;
    height: 100px;
    position: relative;
    transform-style: preserve-3d;
    animation: cube-rotate 25s linear infinite;
}

@keyframes cube-rotate {
    0% { transform: rotateY(0deg) rotateX(15deg); }
    100% { transform: rotateY(360deg) rotateX(15deg); }
}

.cube-face {
    position: absolute;
    width: 100px;
    height: 100px;
    background: linear-gradient(135deg, rgba(42,42,26,0.6), rgba(26,26,14,0.4));
    border: 1px solid rgba(74,122,58,0.3);
    animation: face-glow 15s ease-in-out infinite;
}

.cube-front  { transform: translateZ(50px); }
.cube-back   { transform: rotateY(180deg) translateZ(50px); }
.cube-left   { transform: rotateY(-90deg) translateZ(50px); }
.cube-right  { transform: rotateY(90deg) translateZ(50px); }
.cube-top    { transform: rotateX(90deg) translateZ(50px); }
.cube-bottom { transform: rotateX(-90deg) translateZ(50px); }

.fractured .fractured-face {
    transform: rotateX(-90deg) translateZ(70px) rotate(5deg);
    opacity: 0.5;
    border-color: rgba(201,168,76,0.3);
}

/* --- Compost Section --- */
.compost {
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.compost-content {
    max-width: 700px;
}

.compost-specimen {
    justify-content: center;
    margin-bottom: 40px;
    position: static;
}

.compost-closing {
    margin-top: 80px;
    padding-top: 40px;
}

.closing-line {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 500;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #5a6a5a;
    animation: closing-fade 10s ease-in-out infinite;
}

@keyframes closing-fade {
    0%, 100% { opacity: 0.4; }
    50% { opacity: 1; }
}

/* --- Responsive --- */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        z-index: 300;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .mobile-topbar {
        display: flex;
    }

    .specimen-hall {
        margin-left: 0;
        padding-top: 56px;
    }

    .spore-container {
        left: 0;
        width: 100%;
    }

    .section {
        padding: 60px 24px;
    }

    .section-with-specimen {
        grid-template-columns: 1fr;
    }

    .specimen-display {
        position: static;
        min-height: 150px;
    }

    .threshold-kanji {
        font-size: clamp(3rem, 20vw, 6rem);
    }
}

@media (max-width: 480px) {
    .section {
        padding: 40px 16px;
    }

    .code-block {
        font-size: 0.75rem;
        padding: 12px;
    }
}
