/* ============================================
   RRIPPL.com - Isometric Technical Blueprint
   ============================================ */

/* --- CSS Custom Properties --- */
:root {
    --deep-bg: #0D1B2A;
    --surface: #1B2838;
    --elevated: #2A3A4D;
    --signal-teal: #4ECDC4;
    --copper-wire: #E8A87C;
    --bright-cyan: #56E3E0;
    --pale-fog: #C8D6E5;
    --steel-mist: #6B7B8D;
    --warm-amber: #F4A261;
    --ghost-blue: #1E3044;
    --black: #000000;
    --plate-2-bg: #1E2F42;
    --plate-3-bg: #213548;

    --ease-mechanical: cubic-bezier(0.25, 0.1, 0.25, 1.0);
    --font-display: 'Josefin Sans', sans-serif;
    --font-body: 'Source Sans 3', sans-serif;
    --font-mono: 'IBM Plex Mono', monospace;
    --font-numeral: 'Orbitron', sans-serif;
}

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

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

body {
    background-color: var(--deep-bg);
    color: var(--pale-fog);
    font-family: var(--font-body);
    font-weight: 400;
    line-height: 1.7;
    overflow-x: hidden;
    position: relative;
}

/* --- Grid Substrate Background --- */
#grid-substrate {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
    opacity: 0;
    transition: opacity 2s ease;
}

#grid-substrate.visible {
    opacity: 1;
}

/* --- Index Rail Navigation --- */
#index-rail {
    position: fixed;
    left: 0;
    top: 0;
    width: 48px;
    height: 100vh;
    background: var(--deep-bg);
    border-right: 1px solid rgba(42, 58, 77, 0.3);
    z-index: 100;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 24px;
}

.rail-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    position: relative;
    opacity: 0.4;
    transition: opacity 0.3s var(--ease-mechanical);
}

.rail-item.active {
    opacity: 1;
}

.rail-item.active .rail-icon {
    filter: drop-shadow(0 0 4px rgba(78, 205, 196, 0.5));
}

.rail-icon {
    width: 24px;
    height: 24px;
}

.rail-number {
    font-family: var(--font-numeral);
    font-size: 0.625rem;
    font-weight: 500;
    color: var(--signal-teal);
    letter-spacing: 0.02em;
}

.rail-ripple {
    position: absolute;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: 1px solid var(--signal-teal);
    opacity: 0;
    pointer-events: none;
    animation: rail-pulse 2s var(--ease-mechanical) infinite;
}

@keyframes rail-pulse {
    0% { transform: scale(0.5); opacity: 0.6; }
    100% { transform: scale(2); opacity: 0; }
}

/* --- Sections / Acts --- */
.act {
    position: relative;
    z-index: 1;
    margin-left: 48px;
    padding: 0 40px;
}

.act-inner {
    max-width: 1440px;
    margin: 0 auto;
}

/* --- Act 1: The Grid Awakens --- */
#act-1 {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.grid-awakens-content {
    text-align: center;
}

.title-block {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 1.2s var(--ease-mechanical), transform 1.2s var(--ease-mechanical);
}

.title-block.visible {
    opacity: 1;
    transform: translateY(0);
}

.main-title {
    font-family: var(--font-display);
    font-weight: 300;
    font-size: 6rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--pale-fog);
    line-height: 1.1;
    margin: 16px 0;
}

.subtitle {
    font-family: var(--font-body);
    font-weight: 400;
    font-size: 1.125rem;
    color: var(--steel-mist);
    letter-spacing: 0.04em;
}

/* --- Annotation Labels --- */
.annotation-label {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    font-weight: 400;
    color: var(--signal-teal);
    letter-spacing: 0.02em;
}

.label-text {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    font-weight: 400;
    color: var(--signal-teal);
    letter-spacing: 0.02em;
    display: block;
    margin-bottom: 6px;
}

.data-numeral {
    font-family: var(--font-numeral);
    font-size: 2rem;
    font-weight: 500;
    color: var(--pale-fog);
    display: block;
}

/* --- Act 2: The Exploded View --- */
#act-2 {
    min-height: 200vh;
    padding-top: 10vh;
    padding-bottom: 10vh;
    position: relative;
}

.exploded-view {
    position: sticky;
    top: 10vh;
    height: 80vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.assembly-container {
    position: relative;
    width: 600px;
    height: 400px;
}

.iso-component {
    position: absolute;
    transition: transform 0.05s linear;
    z-index: 2;
}

#comp-core { left: 250px; top: 130px; }
#comp-signal { left: 130px; top: 90px; }
#comp-data { left: 370px; top: 190px; }
#comp-output { left: 110px; top: 230px; }
#comp-input { left: 260px; top: 30px; }
#comp-filter { left: 160px; top: 30px; }
#comp-cache { left: 400px; top: 130px; }

/* --- Isometric Cubes --- */
.iso-cube {
    position: relative;
    transform-style: preserve-3d;
}

.cube-128 {
    width: 128px;
    height: 128px;
}

.cube-64 {
    width: 64px;
    height: 64px;
}

.cube-32 {
    width: 32px;
    height: 32px;
}

.iso-cube .cube-face {
    position: absolute;
}

/* Isometric cube using 2D transforms (skew-based) */
.cube-128 .cube-top {
    width: 128px;
    height: 74px;
    background: var(--elevated);
    transform: rotate(210deg) skewX(-30deg) scaleY(0.864);
    transform-origin: bottom left;
    bottom: 74px;
    left: 0;
}

.cube-128 .cube-left {
    width: 128px;
    height: 74px;
    background: var(--deep-bg);
    transform: rotate(90deg) skewX(-30deg) scaleY(0.864);
    transform-origin: bottom left;
    bottom: 0;
    left: 0;
}

.cube-128 .cube-right {
    width: 128px;
    height: 74px;
    background: var(--surface);
    transform: rotate(-30deg) skewX(-30deg) scaleY(0.864);
    transform-origin: bottom right;
    bottom: 0;
    right: 0;
}

.cube-64 .cube-top {
    width: 64px;
    height: 37px;
    background: var(--elevated);
    transform: rotate(210deg) skewX(-30deg) scaleY(0.864);
    transform-origin: bottom left;
    bottom: 37px;
    left: 0;
}

.cube-64 .cube-left {
    width: 64px;
    height: 37px;
    background: var(--deep-bg);
    transform: rotate(90deg) skewX(-30deg) scaleY(0.864);
    transform-origin: bottom left;
    bottom: 0;
    left: 0;
}

.cube-64 .cube-right {
    width: 64px;
    height: 37px;
    background: var(--surface);
    transform: rotate(-30deg) skewX(-30deg) scaleY(0.864);
    transform-origin: bottom right;
    bottom: 0;
    right: 0;
}

.cube-32 .cube-top {
    width: 32px;
    height: 18px;
    background: var(--elevated);
    transform: rotate(210deg) skewX(-30deg) scaleY(0.864);
    transform-origin: bottom left;
    bottom: 18px;
    left: 0;
}

.cube-32 .cube-left {
    width: 32px;
    height: 18px;
    background: var(--deep-bg);
    transform: rotate(90deg) skewX(-30deg) scaleY(0.864);
    transform-origin: bottom left;
    bottom: 0;
    left: 0;
}

.cube-32 .cube-right {
    width: 32px;
    height: 18px;
    background: var(--surface);
    transform: rotate(-30deg) skewX(-30deg) scaleY(0.864);
    transform-origin: bottom right;
    bottom: 0;
    right: 0;
}

/* Assembly shadows - isometric drop shadow */
.iso-component::after {
    content: '';
    position: absolute;
    bottom: -8px;
    left: 10%;
    width: 80%;
    height: 6px;
    background: #000000;
    opacity: 0.15;
    border-radius: 50%;
    filter: blur(4px);
}

/* Active glow on cube tops */
.active-glow {
    box-shadow: inset 0 0 20px rgba(78, 205, 196, 0.1);
}

/* --- Component Labels / Leader Lines --- */
.component-label {
    position: absolute;
    top: -30px;
    left: 50%;
    white-space: nowrap;
    opacity: 0;
    transition: opacity 0.6s var(--ease-mechanical);
}

.component-label.visible {
    opacity: 1;
}

.leader-line {
    width: 1px;
    height: 20px;
    background: var(--steel-mist);
    margin: 0 auto 4px;
    position: relative;
}

.leader-line::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 50%;
    transform: translateX(-50%);
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: var(--steel-mist);
}

/* --- Data Pipes --- */
.data-pipes {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.8s var(--ease-mechanical);
}

.data-pipes.visible {
    opacity: 1;
}

.pipe {
    stroke: var(--signal-teal);
    stroke-width: 2;
    stroke-opacity: 0.6;
    fill: none;
}

.animated-pipe {
    stroke-dasharray: 8 6;
    animation: pipe-flow 2s linear infinite;
}

@keyframes pipe-flow {
    to { stroke-dashoffset: -28; }
}

/* --- Assembly Status --- */
.assembly-status {
    position: absolute;
    bottom: 20px;
    right: 20px;
    display: flex;
    gap: 8px;
    align-items: baseline;
}

.status-value {
    font-family: var(--font-numeral);
    font-size: 1.25rem;
    font-weight: 500;
    color: var(--warm-amber);
}

/* --- Section Dividers --- */
.section-divider {
    margin-left: 48px;
    position: relative;
    z-index: 1;
}

/* --- Act 3: Layer Plates --- */
#act-3 {
    padding-top: 80px;
    padding-bottom: 80px;
}

.plate {
    background: var(--surface);
    border: 1px solid rgba(42, 58, 77, 0.3);
    padding: 48px;
    margin-bottom: 40px;
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.6s var(--ease-mechanical), transform 0.6s var(--ease-mechanical);
}

.plate.visible {
    opacity: 1;
    transform: translateY(0);
}

.plate-1 { background: var(--surface); }
.plate-2 { background: var(--plate-2-bg); }
.plate-3 { background: var(--plate-3-bg); }

.plate-header {
    margin-bottom: 32px;
    display: flex;
    align-items: baseline;
    gap: 16px;
    flex-wrap: wrap;
}

.plate-number {
    font-family: var(--font-numeral);
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--copper-wire);
}

.plate-title {
    font-family: var(--font-display);
    font-weight: 300;
    font-size: 2.5rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--pale-fog);
}

/* --- Bento Grid --- */
.bento-grid {
    display: grid;
    gap: 2px;
}

.bento-3col {
    grid-template-columns: repeat(3, 1fr);
}

.bento-2col {
    grid-template-columns: repeat(2, 1fr);
}

.bento-cell {
    border: 1px solid rgba(42, 58, 77, 0.3);
    padding: 24px;
    transition: border-color 0.3s var(--ease-mechanical);
}

.bento-span-2 {
    grid-column: span 2;
}

/* --- Isometric Scenes within Bento --- */
.iso-scene {
    height: 150px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
    position: relative;
}

.iso-scene.small {
    height: 80px;
}

.iso-scene.mini {
    height: 60px;
}

.iso-scene.mini.wide {
    height: 80px;
}

.iso-container {
    position: relative;
    transform-style: preserve-3d;
}

.positioned {
    position: absolute;
    left: var(--ix, 0);
    top: var(--iy, 0);
}

.cell-annotation {
    padding-top: 8px;
}

.cell-description {
    font-family: var(--font-body);
    font-size: 0.9375rem;
    font-weight: 400;
    color: var(--steel-mist);
    line-height: 1.7;
    max-width: 42em;
}

/* --- Flow Diagram --- */
.flow-diagram {
    height: 150px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
}

.flow-svg {
    width: 100%;
    max-width: 300px;
    height: auto;
}

/* --- Flow Metrics --- */
.flow-metrics {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.metric {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

/* --- Annotation Block (Plate 3) --- */
.annotation-block {
    display: flex;
    flex-direction: column;
    gap: 32px;
}

.annotation-entry {
    display: flex;
    gap: 16px;
    align-items: flex-start;
}

.leader-line-h {
    width: 40px;
    min-width: 40px;
    height: 1px;
    background: var(--steel-mist);
    margin-top: 10px;
    position: relative;
}

.leader-line-h::before {
    content: '';
    position: absolute;
    left: -2px;
    top: 50%;
    transform: translateY(-50%);
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: var(--steel-mist);
}

.annotation-content {
    flex: 1;
}

/* --- Act 4: Ripple Cascade --- */
#act-4 {
    padding-top: 80px;
    padding-bottom: 80px;
}

.cascade-header {
    margin-bottom: 40px;
    display: flex;
    align-items: baseline;
    gap: 16px;
    flex-wrap: wrap;
}

.cascade-network {
    width: 100%;
    height: 500px;
    position: relative;
    border: 1px solid rgba(42, 58, 77, 0.3);
    background: rgba(13, 27, 42, 0.5);
    overflow: hidden;
}

.network-svg {
    width: 100%;
    height: 100%;
}

.network-node {
    cursor: pointer;
    transition: filter 0.2s;
}

.network-node:hover {
    filter: drop-shadow(0 0 8px rgba(78, 205, 196, 0.6));
}

.network-connection {
    stroke: var(--ghost-blue);
    stroke-width: 1;
    fill: none;
}

.network-connection.active {
    stroke: var(--signal-teal);
    stroke-width: 1.5;
    stroke-opacity: 0.6;
    stroke-dasharray: 6 4;
    animation: pipe-flow 1.5s linear infinite;
}

/* Ripple ring animation */
.ripple-ring {
    fill: none;
    stroke: var(--signal-teal);
    stroke-width: 1;
    opacity: 0;
}

@keyframes ripple-expand {
    0% {
        r: 6;
        opacity: 0.8;
    }
    100% {
        r: 40;
        opacity: 0;
    }
}

/* --- Act 5: The Index --- */
#act-5 {
    padding-top: 80px;
    padding-bottom: 120px;
}

.index-header {
    margin-bottom: 40px;
    display: flex;
    align-items: baseline;
    gap: 16px;
    flex-wrap: wrap;
}

.bento-index {
    grid-template-columns: repeat(4, 1fr);
}

.index-cell {
    transition: border-color 0.3s var(--ease-mechanical), transform 0.2s ease;
}

.index-cell:hover {
    border-color: var(--signal-teal);
    transform: translateY(-2px);
    transition-duration: 300ms;
}

.index-cell.span-2 {
    grid-column: span 2;
}

.mini-flow,
.mini-ripple,
.mini-node,
.mini-graph {
    width: 100%;
    height: 100%;
}

/* --- Footer --- */
#site-footer {
    margin-left: 48px;
    padding: 32px 40px;
    border-top: 1px solid rgba(42, 58, 77, 0.3);
    position: relative;
    z-index: 1;
}

.footer-inner {
    max-width: 1440px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* --- Decorative Ripple Rings --- */
.ripple-decoration {
    position: fixed;
    pointer-events: none;
    z-index: 0;
}

#ripple-deco-1 {
    width: 200px;
    height: 200px;
    border-radius: 50%;
    border: 1px solid var(--signal-teal);
    opacity: 0;
    right: 10%;
    top: 20%;
    animation: deco-ripple 4s linear infinite;
}

#ripple-deco-2 {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    border: 1px solid var(--signal-teal);
    opacity: 0;
    left: 15%;
    bottom: 30%;
    animation: deco-ripple 4s linear infinite 2s;
}

@keyframes deco-ripple {
    0% {
        transform: scale(0.3);
        opacity: 0.15;
    }
    50% {
        opacity: 0.08;
    }
    100% {
        transform: scale(2);
        opacity: 0;
    }
}

/* --- Responsive: Tablet --- */
@media (max-width: 1024px) {
    .main-title {
        font-size: 4rem;
    }

    .plate-title {
        font-size: 2rem;
    }

    .bento-3col {
        grid-template-columns: repeat(2, 1fr);
    }

    .bento-index {
        grid-template-columns: repeat(3, 1fr);
    }

    .act {
        padding: 0 24px;
    }

    .assembly-container {
        width: 500px;
        height: 350px;
        transform: scale(0.85);
    }
}

/* --- Responsive: Mobile --- */
@media (max-width: 768px) {
    #index-rail {
        display: none;
    }

    .act {
        margin-left: 0;
        padding: 0 16px;
    }

    .section-divider {
        margin-left: 0;
    }

    #site-footer {
        margin-left: 0;
    }

    .main-title {
        font-size: 3rem;
    }

    .plate-title {
        font-size: 1.75rem;
    }

    .plate {
        padding: 24px;
    }

    .bento-3col,
    .bento-2col {
        grid-template-columns: 1fr;
    }

    .bento-span-2,
    .index-cell.span-2 {
        grid-column: span 1;
    }

    .bento-index {
        grid-template-columns: repeat(2, 1fr);
    }

    .assembly-container {
        width: 320px;
        height: 280px;
        transform: scale(0.7);
    }

    .cascade-network {
        height: 350px;
    }

    .plate-header {
        flex-direction: column;
        gap: 8px;
    }

    .cascade-header,
    .index-header {
        flex-direction: column;
        gap: 8px;
    }
}
