/* =========================================================
   renai.dev — Chrome Metallic Neomorphic System
   Scroll architecture uses IntersectionObserver that adds/removes
   CSS classes (`is-incoming`, `is-current`, `is-receding`) to sections.
   ========================================================= */

/* Custom Properties */
:root {
    /* Chrome Palette */
    --carbon:       #1A1A1A;
    --carbon-warm:  #2A2A2A;
    --graphite:     #2E2E2E;
    --graphite-mid: #444444;
    --chrome-mid:   #7A7A7A;
    --chrome-sub:   #888888;
    --chrome-nav:   #9A9A9A;
    --silver:       #B8B8B8;
    --chrome-nav-hi: #C0C0C0;
    --chrome-surf:  #C8C8C8;
    --chrome-rule:  #CCCCCC;
    --platinum:     #D6D6D6;
    --chrome-nav-act: #E8E8E8;
    --chrome-hi:    #EFEFEF;
    --chrome-f0:    #F0F0F0;
    --chrome-light: #F5F5F5;
    --white:        #FFFFFF;
    --accent:       #6EC6FF;

    /* Neomorphic Shadows — Light Mode */
    --neo-raise:  6px 6px 12px #AFAFAF, -6px -6px 12px #FFFFFF;
    --neo-inset:  inset 4px 4px 8px #AFAFAF, inset -4px -4px 8px #FFFFFF;
    --neo-deep:   10px 10px 20px #A0A0A0, -10px -10px 20px #F5F5F5;
    --neo-rule:   1px solid #CCCCCC;
    --chrome-f0:  #F0F0F0;

    /* Neomorphic Shadows — Dark Mode */
    --neo-dark-raise: 6px 6px 14px #111111, -6px -6px 14px #3A3A3A;
    --neo-dark-inset: inset 4px 4px 8px #111111, inset -4px -4px 8px #3A3A3A;

    /* Angular Clip Paths */
    --angle-15: polygon(0 0, 100% 0, calc(100% - 2.7vh) 100%, 0 100%);
    --angle-30: polygon(0 0, 100% 0, calc(100% - 5.8vh) 100%, 0 100%);
    --angle-45: polygon(0 0, 100% 0, calc(100% - 10vh) 100%, 0 100%);

    /* Typography */
    --font-display: 'Libre Baskerville', Georgia, serif;
    --font-body:    'Inter', system-ui, sans-serif;
    --font-mono:    'DM Mono', 'Courier New', monospace;

    /* Transitions */
    --scroll-ease: cubic-bezier(0.23, 1, 0.32, 1);
    --scroll-dur:  700ms;
}

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

html {
    scroll-behavior: smooth;
    overflow-x: hidden;
}

body {
    background: var(--chrome-hi);
    color: var(--carbon);
    font-family: var(--font-body);
    overflow-x: hidden;
    overflow-y: scroll;
    width: 100%;
}

/* =========================================================
   Diamond Navigator
   ========================================================= */
#diamond-nav {
    position: fixed;
    right: 28px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 20px;
    align-items: center;
}

.diamond-indicator {
    position: relative;
    width: 16px;
    height: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.diamond-inner {
    width: 8px;
    height: 8px;
    transform: rotate(45deg);
    background: transparent;
    border: 1px solid #9A9A9A;
    transition: all 400ms var(--scroll-ease);
}

.diamond-indicator.active .diamond-inner {
    background: linear-gradient(135deg, #C0C0C0, #E8E8E8);
    border-color: var(--accent);
    box-shadow: 0 0 8px rgba(110, 198, 255, 0.5);
    width: 10px;
    height: 10px;
}

.diamond-tooltip {
    position: absolute;
    right: calc(100% + 14px);
    top: 50%;
    transform: translateY(-50%);
    white-space: nowrap;
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--chrome-mid);
    letter-spacing: 0.08em;
    pointer-events: none;
    opacity: 0;
    filter: blur(4px);
    transition: opacity 250ms ease, filter 250ms ease;
}

.diamond-indicator:hover .diamond-tooltip {
    opacity: 1;
    filter: blur(0);
}

/* =========================================================
   Section Architecture
   ========================================================= */
.section {
    position: relative;
    height: 100vh;
    width: 100%;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition:
        transform var(--scroll-dur) var(--scroll-ease),
        filter var(--scroll-dur) var(--scroll-ease),
        opacity var(--scroll-dur) var(--scroll-ease);
    will-change: transform, filter, opacity;
}

.section.is-incoming {
    transform: scale(1.02);
    filter: blur(12px);
    opacity: 0.8;
}

.section.is-current {
    transform: scale(1);
    filter: blur(0);
    opacity: 1;
}

.section.is-receding {
    transform: scale(0.96);
    filter: blur(8px);
    opacity: 0.7;
}

.section-bg-clip {
    position: absolute;
    inset: 0;
    background: var(--platinum);
    clip-path: var(--angle-15);
    z-index: 0;
}

.section-bg-clip.dark-bg       { background: var(--graphite); }
.section-bg-clip.light-bg      { background: var(--chrome-hi); }
.section-bg-clip.darkest-bg    { background: var(--carbon); }
.section-bg-clip.dark-section-bg { background: var(--graphite); }

.section-inner {
    position: relative;
    z-index: 2;
    height: 100%;
    width: 100%;
    display: flex;
    align-items: center;
    padding: 0 8vw;
    gap: 5vw;
}

/* Section Divider */
.section-divider {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 24px;
    z-index: 10;
}

/* Chrome seam rule — uses #CCCCCC and #2A2A2A and #888888 */
.chrome-seam {
    height: 1px;
    background: #CCCCCC;
    position: absolute;
    left: 0;
    right: 0;
    z-index: 5;
}

.section-sublabel {
    font-family: var(--font-mono);
    font-size: 10px;
    color: #888888;
    letter-spacing: 0.1em;
}

.dark-seam-text {
    color: #2A2A2A;
}

.mid-text {
    color: #444444;
}

/* Section background alternative using #F0F0F0 */
.section-bg-clip.panel-alt {
    background: #F0F0F0;
}

/* =========================================================
   Typography
   ========================================================= */
.section-label {
    font-family: var(--font-mono);
    font-size: 11px;
    letter-spacing: 0.12em;
    color: var(--chrome-mid);
    text-transform: uppercase;
    margin-bottom: 1.5rem;
}

.section-label.light-label { color: var(--silver); }

.section-title {
    font-family: var(--font-display);
    font-weight: 700;
    font-style: normal;
    font-size: clamp(40px, 5vw, 64px);
    line-height: 1.1;
    color: var(--carbon);
    margin-bottom: 2rem;
}

.section-title em {
    font-style: italic;
    color: var(--graphite);
}

.section-title.light-title     { color: var(--chrome-hi); }
.section-title.light-title em  { color: var(--silver); }

.section-body {
    font-family: var(--font-body);
    font-weight: 300;
    font-size: 16px;
    line-height: 1.75;
    color: var(--graphite);
    max-width: 480px;
    margin-bottom: 1.25rem;
}

.dm-mono {
    font-family: var(--font-mono);
}

/* =========================================================
   Section 1: Hero
   ========================================================= */
.hero-inner {
    position: relative;
    align-items: center;
    justify-content: center;
}

#hero-graph {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    opacity: 0;
    transition: opacity 1200ms ease-out;
}

#hero-graph.assembled {
    opacity: 1;
}

.hero-wordmark {
    position: relative;
    z-index: 3;
    text-align: center;
    pointer-events: none;
}

#hero-title {
    font-family: var(--font-display);
    font-weight: 700;
    font-style: italic;
    font-size: clamp(64px, 8vw, 100px);
    color: var(--carbon);
    line-height: 1;
    letter-spacing: -0.02em;
    text-shadow: 2px 2px 0 rgba(175, 175, 175, 0.4);
}

.hero-tld {
    font-family: var(--font-mono);
    font-size: clamp(18px, 2.5vw, 28px);
    color: var(--chrome-mid);
    letter-spacing: 0.1em;
    display: block;
    margin-top: 0.3em;
}

/* =========================================================
   Section 2: The Record
   ========================================================= */
.record-inner {
    justify-content: space-between;
    background: linear-gradient(135deg, rgba(46,46,46,0.95) 0%, rgba(30,30,30,0.98) 100%);
}

.record-inner .section-title { color: var(--chrome-hi); }
.record-inner .section-title em { color: var(--silver); }
.record-inner .section-label { color: var(--silver); }
.record-inner .section-body { color: var(--platinum); }

.content-col {
    flex: 0 0 42%;
    max-width: 520px;
}

.viz-col {
    flex: 0 0 48%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.viz-frame {
    position: relative;
    background: var(--graphite);
    box-shadow: var(--neo-dark-raise);
    padding: 20px;
    border-radius: 2px;
}

.parallelogram-frame {
    transform: skewX(-15deg);
    overflow: hidden;
    width: 380px;
    height: 380px;
}

.parallelogram-frame svg {
    transform: skewX(15deg);
    display: block;
    width: 100%;
    height: 100%;
}

#radial-timeline {
    opacity: 0;
    transition: opacity 900ms ease-out;
}

#radial-timeline.drawn {
    opacity: 1;
}

/* =========================================================
   Section 3: The Network
   ========================================================= */
.network-inner {
    justify-content: space-between;
    background: var(--chrome-hi);
}

.network-viz-col {
    flex: 0 0 55%;
}

.network-viz-col svg {
    width: 100%;
    height: auto;
    max-height: 70vh;
}

.content-col-right {
    flex: 0 0 38%;
    text-align: right;
}

/* =========================================================
   Section 4: The Stream
   ========================================================= */
.stream-inner {
    flex-direction: column;
    justify-content: center;
    align-items: flex-start;
    background: var(--carbon);
    padding: 5vh 8vw;
    gap: 2rem;
}

.stream-header { flex-shrink: 0; }

.stream-viz-container {
    width: 100%;
    flex: 1;
    min-height: 0;
    box-shadow: var(--neo-dark-inset);
    background: rgba(30, 30, 30, 0.8);
    padding: 16px;
    clip-path: var(--angle-15);
}

#stream-graph {
    width: 100%;
    height: 100%;
    display: block;
    opacity: 0;
    transition: opacity 800ms ease-out;
}

#stream-graph.visible { opacity: 1; }

/* =========================================================
   Section 5: The Territory
   ========================================================= */
.territory-inner {
    justify-content: space-between;
    background: var(--platinum);
}

.territory-content { flex: 0 0 26%; }

.small-body { font-size: 12px; color: var(--chrome-mid); }

.treemap-container {
    flex: 0 0 60%;
    box-shadow: var(--neo-deep);
    background: var(--chrome-surf);
    padding: 4px;
}

#treemap-viz {
    width: 100%;
    height: auto;
    display: block;
}

/* =========================================================
   Section 6: The Points
   ========================================================= */
.points-inner {
    flex-direction: column;
    justify-content: center;
    background: var(--graphite);
    padding: 5vh 8vw;
    gap: 2rem;
}

.points-header { flex-shrink: 0; }

.scatter-container {
    position: relative;
    flex: 1;
    min-height: 0;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

#scatter-plot {
    width: 100%;
    max-height: 60vh;
    height: auto;
    box-shadow: var(--neo-dark-inset);
    background: rgba(40, 40, 40, 0.9);
}

.scatter-tooltip {
    position: absolute;
    background: var(--chrome-surf);
    color: var(--carbon);
    font-family: var(--font-mono);
    font-size: 11px;
    padding: 8px 12px;
    letter-spacing: 0.05em;
    box-shadow: var(--neo-raise);
    pointer-events: none;
    opacity: 0;
    transition: opacity 200ms ease;
    transform: translateX(-50%);
    white-space: nowrap;
    z-index: 50;
}

.scatter-tooltip.visible { opacity: 1; }

/* =========================================================
   Section 7: The Line
   ========================================================= */
.line-inner {
    justify-content: center;
    background: var(--chrome-hi);
}

.line-content {
    width: 100%;
    max-width: 900px;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.line-viz-wrapper {
    box-shadow: var(--neo-deep);
    background: var(--chrome-surf);
    padding: 16px;
    clip-path: var(--angle-30);
}

#line-chart {
    width: 100%;
    height: auto;
    display: block;
}

.line-closing {
    font-family: var(--font-display);
    font-weight: 700;
    font-style: italic;
    font-size: clamp(32px, 4vw, 52px);
    color: var(--carbon);
    line-height: 1.2;
}

.line-cta {
    font-family: var(--font-display);
    font-style: italic;
    font-size: 18px;
    color: var(--carbon);
    text-decoration: underline;
    text-underline-offset: 4px;
    cursor: pointer;
    display: inline-block;
    transition: color 300ms ease;
}

.line-cta:hover { color: var(--graphite); }

/* =========================================================
   Neomorphic Interactive Panels — Hover Effects
   ========================================================= */
.neo-panel {
    background: var(--chrome-surf);
    box-shadow: var(--neo-raise);
    transition: box-shadow 300ms ease, filter 300ms ease;
    filter: blur(2px);
}

.neo-panel:hover {
    box-shadow: var(--neo-raise), 0 0 0 1px var(--accent) inset;
    filter: blur(0);
}

/* =========================================================
   SVG — Graph Edges & Nodes
   ========================================================= */
.graph-edge {
    stroke: var(--silver);
    stroke-width: 0.8;
    fill: none;
    opacity: 0;
    transition: opacity 600ms ease;
}

.graph-edge.visible { opacity: 0.5; }

.graph-node {
    fill: var(--chrome-surf);
    stroke: none;
    opacity: 0;
    transition: opacity 400ms ease;
}

.graph-node.visible { opacity: 1; }
.graph-node.accent  { fill: var(--accent); filter: drop-shadow(0 0 4px rgba(110,198,255,0.6)); }

/* Network pulses */
.net-edge {
    stroke: var(--chrome-mid);
    stroke-width: 1;
    fill: none;
    animation: pulse-edge 2s ease-in-out infinite;
}

@keyframes pulse-edge {
    0%, 100% { stroke: var(--chrome-mid); opacity: 0.6; }
    50%       { stroke: var(--chrome-surf); opacity: 1; }
}

.net-node {
    fill: var(--chrome-surf);
    box-shadow: var(--neo-raise);
}

.net-node.hub { fill: var(--silver); }

/* =========================================================
   Radial Timeline Rings
   ========================================================= */
.radial-ring {
    fill: none;
    stroke-linecap: round;
}

.ring-event {
    fill: var(--chrome-mid);
    opacity: 0;
    transition: opacity 400ms ease;
}

.ring-event.visible { opacity: 1; }
.ring-event.accent  { fill: var(--accent); }

/* =========================================================
   Treemap Cells
   ========================================================= */
.treemap-cell {
    stroke: var(--carbon);
    stroke-width: 0.5;
    fill: var(--chrome-surf);
    transition: fill 300ms ease, filter 300ms ease;
    filter: blur(0);
    cursor: default;
}

.treemap-cell:hover {
    filter: blur(0) brightness(1.08);
}

.treemap-cell.dark-cell  { fill: var(--chrome-mid); }
.treemap-cell.light-cell { fill: var(--chrome-hi); }
.treemap-cell.mid-cell   { fill: var(--silver); }

.treemap-label {
    font-family: var(--font-mono);
    font-size: 10px;
    fill: var(--carbon);
    pointer-events: none;
    letter-spacing: 0.06em;
}

/* =========================================================
   Scatter Plot
   ========================================================= */
.scatter-point {
    fill: var(--silver);
    cursor: pointer;
    transition: fill 200ms ease, r 200ms ease;
    opacity: 0;
    transition: opacity 300ms ease, fill 200ms ease;
}

.scatter-point.placed { opacity: 1; }
.scatter-point:hover  { fill: var(--chrome-hi); }

.axis-line {
    stroke: var(--chrome-mid);
    stroke-width: 0.5;
    opacity: 0.6;
}

/* =========================================================
   Line Chart
   ========================================================= */
#main-line-path {
    fill: none;
    stroke: var(--silver);
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.line-point-dot {
    fill: var(--silver);
}

.line-point-dot.final {
    fill: var(--accent);
    filter: drop-shadow(0 0 4px rgba(110,198,255,0.8));
}

/* =========================================================
   Stream Graph
   ========================================================= */
.stream-layer {
    opacity: 0.85;
    transition: opacity 300ms ease;
}

.stream-layer:hover { opacity: 1; }

/* =========================================================
   Responsive
   ========================================================= */
@media (max-width: 900px) {
    .section-inner {
        flex-direction: column;
        padding: 3vh 5vw;
        gap: 2vh;
    }

    .content-col,
    .viz-col,
    .network-viz-col,
    .content-col-right,
    .territory-content,
    .treemap-container {
        flex: 0 0 auto;
        width: 100%;
        max-width: 100%;
    }

    .parallelogram-frame {
        width: 280px;
        height: 280px;
    }

    #diamond-nav {
        right: 12px;
    }

    .section-title {
        font-size: clamp(28px, 6vw, 48px);
    }

    #hero-title {
        font-size: clamp(52px, 12vw, 80px);
    }
}

@media (max-width: 600px) {
    #diamond-nav {
        right: auto;
        bottom: 16px;
        top: auto;
        transform: none;
        flex-direction: row;
        left: 50%;
        transform: translateX(-50%);
        background: rgba(200,200,200,0.9);
        padding: 8px 16px;
        box-shadow: var(--neo-raise);
    }

    .diamond-tooltip { display: none; }
}
