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

html {
    scroll-snap-type: y mandatory;
    overflow-x: hidden;
    font-family: 'Source Sans 3', sans-serif;
    color: #4a3728;
    background: #faf3e8;
}

body {
    overflow-x: hidden;
}

.scroll-container {
    width: 100%;
}

/* === Panels === */
.panel {
    width: 100%;
    min-height: 100vh;
    min-height: 100svh;
    scroll-snap-align: start;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

/* === Particles === */
.particles {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 0;
}

.particle {
    position: absolute;
    width: var(--size, 3px);
    height: var(--size, 3px);
    border-radius: 50%;
    background: rgba(232, 151, 63, 0.3);
    animation: particleDrift var(--dur, 12s) ease-in-out infinite;
    animation-delay: var(--del, 0s);
}

@keyframes particleDrift {
    0%, 100% { transform: translate(0, 0); opacity: 0.3; }
    25% { transform: translate(var(--dx, 20px), var(--dy, -30px)); opacity: 0.6; }
    50% { transform: translate(var(--dx2, -15px), var(--dy2, 15px)); opacity: 0.4; }
    75% { transform: translate(var(--dx3, 10px), var(--dy3, -10px)); opacity: 0.5; }
}

/* === Noise Texture Overlay === */
.panel::before {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 1;
    opacity: 0.02;
    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.8' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* === Section 0: The Surface === */
.panel-surface {
    background: #faf3e8;
    gap: 2rem;
}

.site-title {
    font-family: 'Commissioner', sans-serif;
    font-weight: 700;
    font-size: clamp(3rem, 8vw, 5.5rem);
    letter-spacing: -0.01em;
    color: #4a3728;
    z-index: 2;
    font-variation-settings: 'wght' var(--title-weight, 700);
}

.capsule {
    width: min(60vw, 700px);
    height: min(60vh, 500px);
    border-radius: 2rem;
    position: relative;
    z-index: 2;
    background: rgba(232, 151, 63, 0.12);
    border: 2px solid transparent;
    border-image: linear-gradient(135deg, #d4a04a, #8b6914, #d4a04a, #6b4226) 1;
    box-shadow: 0 8px 32px rgba(61, 43, 31, 0.1), inset 0 -4px 12px rgba(232, 151, 63, 0.2);
    overflow: hidden;
}

.capsule-inner {
    width: 100%;
    height: 100%;
    position: relative;
}

.capsule-bubble {
    position: absolute;
    border-radius: 50%;
    background:
        radial-gradient(ellipse at 30% 30%, rgba(255,255,255,0.4), transparent 60%),
        radial-gradient(ellipse at 70% 70%, rgba(194,85,26,0.15), transparent 50%),
        rgba(232, 151, 63, 0.12);
    box-shadow: 0 8px 32px rgba(61, 43, 31, 0.1), inset 0 -4px 12px rgba(232, 151, 63, 0.2);
    filter: blur(var(--blur, 4px));
    transition: filter 3s cubic-bezier(0.22, 1, 0.36, 1);
    animation: bubbleFloat var(--float-dur, 10s) ease-in-out infinite;
    animation-delay: var(--float-del, 0s);
}

.capsule-bubble.clarified {
    filter: blur(0px);
}

@keyframes bubbleFloat {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(var(--float-amp, -5px)); }
}

.tagline {
    font-family: 'Source Sans 3', sans-serif;
    font-size: clamp(1rem, 1.8vw, 1.25rem);
    line-height: 1.65;
    color: #6b4226;
    z-index: 2;
}

/* === Section 1: The Manifest === */
.panel-manifest {
    background: linear-gradient(to bottom, #faf3e8, #f5deb3);
    gap: 0;
    padding: 2rem 0;
}

.bezel-arc {
    width: 70%;
    height: 3px;
    background: linear-gradient(135deg, #d4a04a, #8b6914, #d4a04a, #6b4226);
    border-radius: 50%;
    z-index: 2;
    flex-shrink: 0;
}

.bezel-top {
    margin-bottom: 1.5rem;
}

.bezel-bottom {
    margin-top: 1.5rem;
}

.manifest-flow {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.8rem;
    z-index: 2;
    max-height: 80vh;
    overflow-y: auto;
    padding: 1rem 2rem;
    scrollbar-width: none;
}

.manifest-flow::-webkit-scrollbar {
    display: none;
}

.component-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.6rem 1.2rem;
    border-radius: 50px;
    background:
        radial-gradient(ellipse at 30% 30%, rgba(255,255,255,0.4), transparent 60%),
        radial-gradient(ellipse at 70% 70%, rgba(194,85,26,0.15), transparent 50%),
        rgba(232, 151, 63, 0.12);
    box-shadow: 0 4px 16px rgba(61, 43, 31, 0.08), inset 0 -2px 8px rgba(232, 151, 63, 0.15);
    border: 1px solid rgba(139, 105, 20, 0.2);
    opacity: 0;
    transform: translateY(30px);
    animation: pillEnter 600ms cubic-bezier(0.22, 1, 0.36, 1) forwards;
    animation-delay: var(--pill-delay, 0ms);
    animation-play-state: paused;
    margin-left: var(--pill-offset, 0);
}

.component-pill.animate {
    animation-play-state: running;
}

.pill-name {
    font-family: 'IBM Plex Mono', monospace;
    font-size: clamp(0.75rem, 1.2vw, 0.9rem);
    color: #6b4226;
    background: rgba(255, 183, 77, 0.15);
    padding: 0.1em 0.4em;
    border-radius: 4px;
}

.pill-version {
    font-family: 'IBM Plex Mono', monospace;
    font-size: clamp(0.65rem, 1vw, 0.8rem);
    color: #8b6914;
}

.pill-license {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.license-permissive { background: #4a7c59; }
.license-copyleft { background: #e8973f; }
.license-restrictive { background: #e8735a; }

@keyframes pillEnter {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* === Section 2: The Lineage === */
.panel-lineage {
    background: linear-gradient(to bottom, #f5deb3, #5c3a1e, #3d2b1f);
}

.lineage-tree {
    position: relative;
    width: min(90vw, 800px);
    height: 80vh;
    z-index: 2;
}

#lineage-svg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}

.connector {
    stroke: #e8973f;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-dasharray: 300;
    stroke-dashoffset: 300;
    transition: stroke-dashoffset 800ms cubic-bezier(0.22, 1, 0.36, 1);
}

.connector.drawn {
    stroke-dashoffset: 0;
}

.junction {
    fill: #c2551a;
    opacity: 0;
    transition: opacity 400ms ease;
}

.junction.visible {
    opacity: 1;
}

.tree-nodes {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}

.tree-node {
    position: absolute;
    padding: 0.4rem 0.8rem;
    border-radius: 8px;
    background: rgba(232, 151, 63, 0.12);
    border: 1px solid rgba(139, 105, 20, 0.3);
    text-align: center;
    transform: translate(-50%, -50%);
    opacity: 0;
    transition: opacity 500ms cubic-bezier(0.22, 1, 0.36, 1);
}

.tree-node.visible {
    opacity: 1;
}

.tree-node-name {
    font-family: 'Commissioner', sans-serif;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--node-color, #4a3728);
}

.tree-node-version {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.7rem;
    color: var(--node-color-sub, #6b4226);
}

/* === Section 3: The Signature === */
.panel-signature {
    background: #3d2b1f;
    gap: 2.5rem;
}

.spotlight-overlay {
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at center, rgba(232, 151, 63, 0.1), transparent 70%);
    pointer-events: none;
    z-index: 1;
}

.seal-container {
    width: min(40vw, 350px);
    height: min(40vw, 350px);
    z-index: 2;
    animation: sealPulse 4s ease-in-out infinite;
}

@keyframes sealPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.02); }
}

.seal {
    width: 100%;
    height: 100%;
}

.seal-ring {
    fill: none;
    stroke-width: 3;
}

.seal-ring-outer {
    stroke: #c2551a;
    stroke-dasharray: 8 4;
}

.seal-ring-mid {
    stroke: #e8973f;
    stroke-width: 2;
}

.seal-ring-inner {
    stroke: #e8973f;
    stroke-width: 1.5;
    stroke-dasharray: 4 6;
}

.hash-block {
    fill: var(--hash-color, #e8973f);
    rx: 1;
    ry: 1;
}

.seal-text {
    font-family: 'Commissioner', sans-serif;
    font-size: 28px;
    font-weight: 700;
    fill: #fef6e8;
    letter-spacing: 0.1em;
}

.seal-subtext {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 12px;
    fill: #e8973f;
    letter-spacing: 0.15em;
}

.signature-text {
    z-index: 2;
    display: flex;
    gap: 0.8rem;
    flex-wrap: wrap;
    justify-content: center;
}

.sig-word {
    font-family: 'Commissioner', sans-serif;
    font-weight: 300;
    font-size: clamp(1.5rem, 3vw, 2rem);
    color: #fef6e8;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 600ms cubic-bezier(0.22, 1, 0.36, 1), transform 600ms cubic-bezier(0.22, 1, 0.36, 1);
    transition-delay: calc(var(--delay) * 800ms);
}

.sig-word.visible {
    opacity: 1;
    transform: translateY(0);
}

/* === Reduced Motion === */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    html { scroll-snap-type: none; }
}
