/* ============================================================
   graphers.net — styles.css
   Precision Data Narratives
   Inspired by Playfair, Nightingale, and Minard — the original
   graphers. Interactive behaviors:** are data-first principles.
   Fonts loaded via (Google Fonts): Libre Franklin, Source Serif 4,
   IBM Plex Mono.
   ============================================================ */

/* --- CSS Custom Properties --- */
:root {
    /* Palette */
    --obsidian: #0C0C0F;
    --graphite: #161619;
    --slate: #1E1E23;
    --chalk: #E8E6E1;
    --fog: #8A9BA8;
    --steel: #6B7B8D;
    --signal-blue: #3B82F6;
    --coral-datum: #F97066;
    --verdant: #34D399;
    --amber-metric: #FBBF24;
    --wireframe: #2A2A30;

    /* Typography */
    --font-display: 'Libre Franklin', sans-serif;
    --font-body: 'Source Serif 4', serif;
    --font-mono: 'IBM Plex Mono', monospace;

    /* Spacing */
    --gutter: 24px;
    --rail-width: 48px;
}

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

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    background-color: var(--obsidian);
    color: var(--chalk);
    font-family: var(--font-body);
    font-weight: 400;
    line-height: 1.65;
    overflow: hidden;
}

/* --- Scroll Container --- */
.scroll-container {
    width: 100vw;
    height: 100vh;
    overflow-y: scroll;
    scroll-snap-type: y mandatory;
    scroll-behavior: smooth;
}

/* --- Plates (viewport sections) --- */
.plate {
    width: 100%;
    height: 100vh;
    scroll-snap-align: start;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* --- Navigation Rail --- */
.nav-rail {
    position: fixed;
    left: 0;
    top: 0;
    width: var(--rail-width);
    height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 20px;
    z-index: 100;
    background: transparent;
}

.nav-rail-line {
    position: absolute;
    width: 0.5px;
    height: 140px;
    background-color: var(--wireframe);
    top: 50%;
    transform: translateY(-50%);
}

.nav-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    border: 1px solid var(--steel);
    background: transparent;
    cursor: pointer;
    position: relative;
    z-index: 2;
    transition: background-color 0.3s ease, border-color 0.3s ease, transform 0.3s ease;
}

.nav-dot:hover {
    border-color: var(--fog);
    transform: scale(1.3);
}

.nav-dot.active {
    background-color: var(--signal-blue);
    border-color: var(--signal-blue);
}

/* --- Plate Counter --- */
.plate-counter {
    position: fixed;
    bottom: 24px;
    right: 24px;
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--steel);
    letter-spacing: 0.04em;
    z-index: 100;
}

/* --- Grid Dots Background --- */
.grid-dots {
    position: absolute;
    top: 0;
    left: var(--rail-width);
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 0;
    opacity: 0;
    transition: opacity 0.6s ease;
}

.grid-dots.visible {
    opacity: 1;
}

/* Grid dot points generated via JS as a repeating pattern */
.grid-dots::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: radial-gradient(circle, var(--wireframe) 1px, transparent 1px);
    background-size: calc((100%) / 12) var(--gutter);
    opacity: 0.2;
}

/* Flash effect during transitions */
.grid-dots.flash::before {
    opacity: 0.6;
    transition: opacity 0.15s ease-in;
}

/* ============================================================
   CALIBRATION PLATE (Plate 0)
   ============================================================ */
.plate-calibration {
    background-color: var(--obsidian);
    flex-direction: column;
}

.calibration-content {
    text-align: center;
    position: relative;
    z-index: 2;
}

.calibration-title {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 6vw;
    letter-spacing: -0.02em;
    color: var(--chalk);
    margin-bottom: 24px;
}

.calibration-title .char {
    display: inline-block;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.calibration-title .char.revealed {
    opacity: 1;
}

.calibration-title .dot-char {
    color: var(--signal-blue);
}

.calibration-line {
    width: 0;
    height: 1px;
    background-color: var(--signal-blue);
    margin: 0 auto 20px;
    transition: width 0.8s ease-out;
}

.calibration-line.expanded {
    width: 80vw;
}

.calibration-subtitle {
    font-family: var(--font-mono);
    font-size: 14px;
    color: var(--steel);
    letter-spacing: 0.12em;
    text-transform: uppercase;
    opacity: 0;
    transition: opacity 0.5s ease;
}

.calibration-subtitle.visible {
    opacity: 1;
}

/* ============================================================
   PORTFOLIO GRID (Plate 1)
   ============================================================ */
.plate-portfolio {
    background-color: var(--obsidian);
    padding-left: var(--rail-width);
    align-items: stretch;
}

.portfolio-grid {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: var(--gutter);
    padding: var(--gutter);
    width: 100%;
    height: 100%;
    align-content: center;
    position: relative;
    z-index: 1;
}

/* Card base */
.card {
    background-color: var(--graphite);
    border: 1px solid var(--wireframe);
    border-radius: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    position: relative;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.5s ease, transform 0.5s ease, box-shadow 0.2s ease-out;
    /* Surface level shadow */
    box-shadow: 4px 4px 0 rgba(0, 0, 0, 0.15);
}

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

/* Elevated shadow on hover */
.card:hover {
    box-shadow: 4px 4px 8px rgba(0, 0, 0, 0.3), 8px 8px 0 rgba(0, 0, 0, 0.1);
}

/* Floating shadow */
.card.floating {
    box-shadow: 4px 4px 16px rgba(0, 0, 0, 0.4), 12px 12px 0 rgba(0, 0, 0, 0.08);
}

/* Card layout variations */
.card-hero {
    grid-column: span 8;
}

.card-detail {
    grid-column: span 4;
}

.card-text {
    grid-column: span 6;
}

/* Card visualization area */
.card-viz {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    min-height: 0;
    position: relative;
}

.card-viz svg {
    width: 100%;
    height: 100%;
    max-height: 280px;
}

.card-hero .card-viz svg {
    max-height: 320px;
}

/* Crosshair visibility on hover */
.card .crosshair-h,
.card .crosshair-v {
    transition: opacity 0.2s ease;
}

.card:hover .crosshair-h,
.card:hover .crosshair-v {
    opacity: 1;
}

/* Stroke opacity increase on hover */
.card:hover .card-viz svg polygon,
.card:hover .card-viz svg polyline,
.card:hover .card-viz svg rect {
    stroke-opacity: 1;
}

/* Card info area */
.card-info {
    padding: 16px 20px;
    border-top: 1px solid var(--wireframe);
}

.card-title {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1.25rem;
    color: var(--chalk);
    letter-spacing: -0.02em;
    margin-bottom: 4px;
}

.card-desc {
    font-family: var(--font-body);
    font-size: 0.95rem;
    color: var(--fog);
    line-height: 1.5;
    margin-bottom: 10px;
}

.card-metrics {
    display: flex;
    align-items: center;
    gap: 10px;
}

.metric {
    font-family: var(--font-mono);
    font-size: 13px;
    color: var(--steel);
    letter-spacing: 0.04em;
}

.metric-divider {
    width: 1px;
    height: 14px;
    background-color: var(--wireframe);
}

/* Text block card */
.card-text .card-info {
    border-top: none;
    padding: 24px;
    display: flex;
    flex-direction: column;
    height: 100%;
    justify-content: center;
}

.card-text .card-title {
    font-family: var(--font-display);
    font-weight: 500;
    font-size: 12px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--fog);
    margin-bottom: 12px;
}

.card-body-text {
    font-family: var(--font-body);
    font-size: 16px;
    color: var(--chalk);
    line-height: 1.65;
    max-width: 65ch;
}

/* Inline sparkline */
.sparkline-inline {
    display: inline-block;
    width: 60px;
    height: 16px;
    vertical-align: middle;
    margin-left: 4px;
}

/* Pulse ring animation */
.pulse-ring {
    animation: pulseExpand 2s ease-out infinite;
}

@keyframes pulseExpand {
    0% {
        r: 3;
        opacity: 0.2;
    }
    100% {
        r: 11;
        opacity: 0;
    }
}

/* ============================================================
   DEEP DIVE PLATES (Plate 2, 3, 4)
   ============================================================ */
.plate-deepdive {
    background-color: var(--obsidian);
    padding-left: var(--rail-width);
}

.deepdive-layout {
    display: grid;
    grid-template-columns: 7fr 5fr;
    gap: calc(var(--gutter) * 2);
    width: 100%;
    height: 100%;
    padding: calc(var(--gutter) * 2);
    align-items: center;
    position: relative;
    z-index: 1;
}

.deepdive-viz {
    display: flex;
    align-items: center;
    justify-content: center;
}

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

.deepdive-text {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 24px;
}

.deepdive-title {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: clamp(2.4rem, 5vw, 4.5rem);
    color: var(--chalk);
    letter-spacing: -0.02em;
    line-height: 1.1;
}

.deepdive-description {
    font-family: var(--font-body);
    font-size: 16px;
    color: var(--fog);
    line-height: 1.65;
    max-width: 65ch;
}

.deepdive-metrics {
    display: flex;
    gap: 32px;
    padding-top: 16px;
    border-top: 1px solid var(--wireframe);
}

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

.metric-value {
    font-family: var(--font-mono);
    font-size: 24px;
    font-weight: 500;
    color: var(--chalk);
    letter-spacing: 0.04em;
}

.metric-label {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--steel);
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

/* Pulse ring for metric values */
.metric-value {
    position: relative;
}

/* Contour background */
.contour-bg {
    position: absolute;
    top: 0;
    left: var(--rail-width);
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 0;
    opacity: 0.1;
}

/* ============================================================
   AXIS LINES (hover reference lines)
   ============================================================ */
.axis-line {
    stroke: var(--wireframe);
    stroke-width: 0.5;
    stroke-dasharray: 1000;
    stroke-dashoffset: 1000;
    transition: stroke-dashoffset 0.3s ease-out;
}

.card:hover .axis-line {
    stroke-dashoffset: 0;
}

/* ============================================================
   TOOLTIP
   ============================================================ */
.viz-tooltip {
    position: fixed;
    background-color: var(--slate);
    border-left: 2px solid var(--signal-blue);
    padding: 6px 10px;
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--chalk);
    letter-spacing: 0.04em;
    pointer-events: none;
    z-index: 200;
    opacity: 0;
    transition: opacity 0.15s ease;
    white-space: nowrap;
}

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

/* ============================================================
   PLATE TRANSITIONS
   ============================================================ */
.plate {
    opacity: 1;
    transform: scale(1);
    transition: opacity 0.4s ease, transform 0.4s ease;
}

.plate.exiting {
    opacity: 0;
    transform: scale(0.97);
}

.plate.entering {
    opacity: 0;
    transform: scale(0.97);
}

.plate.entering.active {
    opacity: 1;
    transform: scale(1);
}

/* ============================================================
   RESPONSIVE ADJUSTMENTS
   ============================================================ */
@media (max-width: 1024px) {
    .portfolio-grid {
        grid-template-columns: repeat(8, 1fr);
    }

    .card-hero {
        grid-column: span 8;
    }

    .card-detail {
        grid-column: span 4;
    }

    .card-text {
        grid-column: span 8;
    }

    .deepdive-layout {
        grid-template-columns: 1fr;
        gap: var(--gutter);
    }

    .deepdive-viz svg {
        max-height: 40vh;
    }
}

@media (max-width: 768px) {
    :root {
        --rail-width: 36px;
    }

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

    .card-hero {
        grid-column: span 4;
    }

    .card-detail {
        grid-column: span 4;
    }

    .card-text {
        grid-column: span 4;
    }

    .calibration-title {
        font-size: 10vw;
    }

    .deepdive-title {
        font-size: clamp(1.8rem, 6vw, 3rem);
    }

    .deepdive-metrics {
        flex-direction: column;
        gap: 16px;
    }
}

/* ============================================================
   SVG VISUALIZATION HOVER STATES
   ============================================================ */

/* Data point hover highlight */
.card-viz svg circle[data-value]:hover,
.deepdive-viz svg circle[data-value]:hover {
    r: 5;
    filter: drop-shadow(0 0 4px var(--signal-blue));
}

/* Ensure SVG text is properly styled */
.card-viz svg text,
.deepdive-viz svg text {
    user-select: none;
}

/* ============================================================
   SCROLLBAR STYLING
   ============================================================ */
.scroll-container::-webkit-scrollbar {
    width: 0;
}

.scroll-container {
    scrollbar-width: none;
    -ms-overflow-style: none;
}

/* ============================================================
   CONTOUR BACKGROUND SVG (generated via JS)
   ============================================================ */
.contour-bg svg {
    width: 100%;
    height: 100%;
}

.contour-bg svg path,
.contour-bg svg ellipse {
    fill: none;
    stroke: var(--wireframe);
    stroke-width: 0.5;
}
