/* ========================================
   sbom.study - Coastal Blend Design
   Maritime forensic SBOM investigation
   ======================================== */

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

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

body {
    font-family: 'Libre Baskerville', Georgia, serif;
    color: #2D5F6E;
    background: #E8F4F8;
    min-height: 100vh;
    overflow-x: hidden;
    line-height: 1.75;
    position: relative;
}

/* Background gradient overlay that darkens with scroll -
   applied via JS by changing body background, but base gradient set here */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(180deg, #E8F4F8 0%, #A8D8E8 15%, #5B8FA4 35%, #1A3A4A 60%, #0B1D26 100%);
    z-index: 0;
    pointer-events: none;
}

/* --- Typography --- */
h1, h2, h3 {
    font-family: 'Libre Baskerville', Georgia, serif;
    font-weight: 700;
    letter-spacing: -0.02em;
}

h2 {
    font-size: clamp(2rem, 4vw, 3.5rem);
    margin-bottom: 1rem;
}

p {
    font-size: clamp(1rem, 1.2vw, 1.15rem);
    line-height: 1.75;
}

code, .mono {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.875rem;
    font-weight: 400;
}

/* --- Depth Gauge --- */
#depth-gauge {
    position: fixed;
    left: 16px;
    top: 0;
    bottom: 0;
    width: 56px;
    z-index: 100;
    display: flex;
    align-items: center;
    pointer-events: none;
}

#depth-gauge-svg {
    width: 48px;
    height: 100vh;
}

#depth-indicator {
    transition: none;
}

#depth-dot {
    transition: none;
}

#depth-labels {
    position: absolute;
    left: 0;
    top: 0;
    width: 56px;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 24px 0;
}

.depth-label {
    font-family: 'Libre Baskerville', Georgia, serif;
    font-style: italic;
    font-size: 0.7rem;
    color: #5B8FA4;
    text-align: center;
    opacity: 0.7;
    text-shadow: 0 0 8px rgba(168, 216, 232, 0.3);
}

/* --- Sonar Overlay --- */
#sonar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 5;
    overflow: hidden;
}

.sonar-line {
    position: absolute;
    left: 0;
    width: 100%;
    height: 1px;
    background: linear-gradient(90deg, transparent 0%, #2D5F6E 20%, #2D5F6E 80%, transparent 100%);
    opacity: 0;
    transform: translateY(0);
}

/* --- Contour Background --- */
#contour-bg {
    position: fixed;
    top: 50%;
    left: 50%;
    width: 100vw;
    height: 100vh;
    transform: translate(-50%, -50%);
    pointer-events: none;
    z-index: 1;
    opacity: 0.5;
}

/* --- Stratum Sections --- */
.stratum {
    position: relative;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 100px 20px 80px;
    z-index: 10;
}

.stratum-content {
    max-width: 960px;
    width: 100%;
    margin: 0 auto;
    padding: 0 40px;
}

.stratum-title {
    color: #2D5F6E;
    margin-bottom: 0.5rem;
    transition: color 0.6s ease;
}

.stratum-description {
    max-width: 680px;
    margin-bottom: 3rem;
    opacity: 0.85;
    transition: color 0.6s ease;
}

/* Text adaptation for deeper sections - dark-on-light to light-on-dark */
#dependency-stratum .stratum-title,
#dependency-stratum .stratum-description {
    color: #A8D8E8;
}

#license-stratum .stratum-title,
#license-stratum .stratum-description {
    color: #A8D8E8;
}

#vulnerability-stratum .stratum-title,
#vulnerability-stratum .stratum-description {
    color: #A8D8E8;
}

/* --- Fault Lines (seismic reading between strata) --- */
.fault-line {
    width: 100%;
    height: 20px;
    margin-top: 60px;
    overflow: hidden;
}

.fault-svg {
    width: 100%;
    height: 20px;
}

.fault-path {
    stroke-dasharray: 2400;
    stroke-dashoffset: 2400;
    transition: stroke-dashoffset 1.2s ease-out;
}

.fault-line.animated .fault-path {
    stroke-dashoffset: 0;
}

/* --- Core Connectors (vertical dashed lines between sections) --- */
.core-connector {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px 0;
}

.connector-line {
    width: 1px;
    height: 60px;
    border-left: 2px dashed #5B8FA4;
    opacity: 0.35;
}

.connector-node {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #5B8FA4;
    border: 2px solid #A8D8E8;
    margin-top: -1px;
    box-shadow: 0 0 10px rgba(168, 216, 232, 0.3);
}

/* ========================================
   SECTION 1: Hero / Surface Layer
   ======================================== */
#surface-layer {
    min-height: 100vh;
    background: transparent;
}

.hero-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 60px;
}

.hero-title-block {
    perspective: 800px;
}

/* 3D extruded typographic block -- carved from coastal stone, lit from upper left */
.hero-title {
    font-size: clamp(2.5rem, 5vw, 4.5rem);
    font-weight: 700;
    color: #1A3A4A;
    letter-spacing: -0.02em;
    text-shadow:
        1px 1px 0 #2D5F6E,
        2px 2px 0 #2D5F6E,
        3px 3px 0 rgba(45, 95, 110, 0.8),
        4px 4px 0 rgba(45, 95, 110, 0.6),
        5px 5px 0 rgba(45, 95, 110, 0.4),
        6px 6px 0 rgba(45, 95, 110, 0.25),
        7px 7px 0 rgba(45, 95, 110, 0.15),
        8px 8px 0 rgba(45, 95, 110, 0.08),
        10px 10px 25px rgba(11, 29, 38, 0.35);
    margin-bottom: 1rem;
}

.hero-subtitle {
    font-family: 'IBM Plex Mono', monospace;
    font-size: clamp(0.85rem, 1.2vw, 1rem);
    color: #5B8FA4;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

/* --- Card Flip System --- */
.hero-card-flip {
    width: 280px;
    height: 380px;
    perspective: 1000px;
    cursor: pointer;
}

.card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transition: transform 600ms ease-in-out;
    transform-style: preserve-3d;
}

.hero-card-flip:hover .card-inner,
.hero-card-flip.flipped .card-inner {
    transform: rotateY(180deg);
}

.card-front, .card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 32px;
}

.card-front {
    background: #1A3A4A;
    border: 1px solid #5B8FA4;
    box-shadow: 0 4px 30px rgba(11, 29, 38, 0.3), inset 0 1px 0 rgba(168, 216, 232, 0.1);
}

.card-front-text {
    font-family: 'Libre Baskerville', Georgia, serif;
    font-size: 1.4rem;
    font-weight: 700;
    color: #E8F4F8;
    text-align: center;
    line-height: 1.5;
}

.card-back {
    background: #E8F4F8;
    border: 1px solid #5B8FA4;
    transform: rotateY(180deg);
    box-shadow: 0 4px 30px rgba(11, 29, 38, 0.2);
}

.card-back-text {
    font-family: 'Libre Baskerville', Georgia, serif;
    font-size: 0.95rem;
    color: #1A3A4A;
    text-align: center;
    line-height: 1.8;
}

.flip-affordance {
    position: absolute;
    bottom: 16px;
    right: 16px;
    color: #5B8FA4;
    opacity: 0.3;
    transition: opacity 0.3s ease;
}

.hero-card-flip:hover .flip-affordance,
.license-flip-card:hover .flip-affordance {
    opacity: 0.6;
}

/* ========================================
   SECTION 2: Metadata Stratum
   ======================================== */
#metadata-stratum {
    background: transparent;
}

.metadata-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 24px;
    max-width: 960px;
}

.specimen-card {
    background: #F5F0E8;
    border: 1px solid rgba(91, 143, 164, 0.3);
    border-radius: 8px;
    padding: 24px 28px;
    position: relative;
    opacity: 0;
    transform: rotateX(5deg);
    transition: opacity 0.5s ease, transform 0.5s ease, box-shadow 0.3s ease;
}

.specimen-card.visible {
    opacity: 1;
    transform: rotateX(0deg);
}

.specimen-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, #5B8FA4, #A8D8E8);
    border-radius: 8px 8px 0 0;
}

.specimen-card:hover {
    box-shadow: 0 6px 24px rgba(11, 29, 38, 0.18);
    transform: translateY(-2px);
}

.specimen-label {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.7rem;
    font-weight: 500;
    color: #5B8FA4;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 8px;
}

.specimen-value {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.95rem;
    color: #1A3A4A;
    font-weight: 400;
}

/* ========================================
   SECTION 3: Dependency Graph
   ======================================== */
#dependency-stratum {
    padding-bottom: 120px;
}

.dependency-tree {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 40px;
    perspective: 1000px;
}

.dep-level {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 20px;
}

.dep-level.level-0 {
    margin-bottom: 20px;
}

/* --- Isometric Dependency Blocks ---
   3D rectangular prisms with package name on top face,
   version on right face, license on left face.
   Styled via CSS transforms to create isometric view. */
.iso-block {
    width: 140px;
    height: 100px;
    position: relative;
    transform-style: preserve-3d;
    transform: rotateX(25deg) rotateZ(-30deg);
    opacity: 0;
    transition: opacity 0.5s ease, transform 0.5s ease;
    cursor: default;
}

.iso-block.visible {
    opacity: 1;
}

.iso-block.root-block {
    width: 180px;
    height: 120px;
}

.iso-face {
    position: absolute;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.7rem;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 4px 6px;
    color: #E8F4F8;
    overflow: hidden;
}

.iso-top {
    width: 100%;
    height: 60%;
    top: 0;
    left: 0;
    font-weight: 500;
    font-size: 0.75rem;
    border-radius: 4px 4px 0 0;
}

.iso-right {
    width: 100%;
    height: 20%;
    bottom: 20%;
    left: 0;
    font-size: 0.65rem;
    opacity: 0.85;
}

.iso-left {
    width: 100%;
    height: 20%;
    bottom: 0;
    left: 0;
    font-size: 0.65rem;
    opacity: 0.85;
    border-radius: 0 0 4px 4px;
}

/* License-based colors per DESIGN.md:
   MIT = #5B8FA4, Apache = #2D5F6E, GPL = #D4A574 */
.iso-block[data-license="mit"] .iso-top { background: #5B8FA4; }
.iso-block[data-license="mit"] .iso-right { background: rgba(91, 143, 164, 0.8); }
.iso-block[data-license="mit"] .iso-left { background: rgba(91, 143, 164, 0.65); }

.iso-block[data-license="apache"] .iso-top { background: #2D5F6E; }
.iso-block[data-license="apache"] .iso-right { background: rgba(45, 95, 110, 0.8); }
.iso-block[data-license="apache"] .iso-left { background: rgba(45, 95, 110, 0.65); }

.iso-block[data-license="gpl"] .iso-top { background: #D4A574; }
.iso-block[data-license="gpl"] .iso-right { background: rgba(212, 165, 116, 0.8); }
.iso-block[data-license="gpl"] .iso-left { background: rgba(212, 165, 116, 0.65); }

.iso-block[data-license="root"] .iso-top { background: #1A3A4A; border: 1px solid #5B8FA4; }
.iso-block[data-license="root"] .iso-right { background: rgba(26, 58, 74, 0.85); }
.iso-block[data-license="root"] .iso-left { background: rgba(26, 58, 74, 0.7); }

.iso-block[data-license="bsd"] .iso-top { background: #5B8FA4; }
.iso-block[data-license="bsd"] .iso-right { background: rgba(91, 143, 164, 0.8); }
.iso-block[data-license="bsd"] .iso-left { background: rgba(91, 143, 164, 0.65); }

/* 3D shadow effect on blocks */
.iso-block::after {
    content: '';
    position: absolute;
    top: 6px;
    left: 6px;
    width: 100%;
    height: 100%;
    background: rgba(11, 29, 38, 0.25);
    border-radius: 4px;
    z-index: -1;
    transition: opacity 0.3s ease;
}

.iso-block:hover::after {
    opacity: 0.4;
}

/* Data readout overlay -- instrument HUD style */
.data-readout {
    margin-top: 40px;
    padding: 12px 24px;
    border: 1px solid #5B8FA4;
    border-radius: 4px;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.7rem;
    color: #A8D8E8;
    background: rgba(11, 29, 38, 0.65);
    display: inline-block;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.readout-label {
    color: #5B8FA4;
    font-weight: 500;
}

/* ========================================
   SECTION 4: License Stratum
   Card-flip gallery -- the signature interaction
   ======================================== */
#license-stratum {
    padding-bottom: 120px;
}

.license-card-gallery {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 24px;
}

.license-flip-card {
    width: 280px;
    height: 380px;
    perspective: 1000px;
    cursor: pointer;
    opacity: 0;
    transform: rotateX(5deg);
    transition: opacity 0.5s ease, transform 0.5s ease;
}

.license-flip-card.visible {
    opacity: 1;
    transform: rotateX(0deg);
}

.license-flip-card .card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transition: transform 600ms ease-in-out;
    transform-style: preserve-3d;
}

.license-flip-card:hover .card-inner,
.license-flip-card.flipped .card-inner {
    transform: rotateY(180deg);
}

.license-front, .license-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 32px;
}

.license-front {
    background: #1A3A4A;
    border: 1px solid #5B8FA4;
    box-shadow: 0 4px 24px rgba(11, 29, 38, 0.3);
}

.license-front[data-license="gpl"] {
    border-color: #D4A574;
}

.license-front[data-license="unknown"] {
    border-color: #D4A574;
    background: linear-gradient(135deg, #1A3A4A, #2D5F6E);
}

.license-name {
    font-family: 'Libre Baskerville', Georgia, serif;
    font-style: italic;
    font-size: 1.3rem;
    font-weight: 700;
    color: #E8F4F8;
    margin-bottom: 16px;
}

.license-count {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.8rem;
    color: #A8D8E8;
    opacity: 0.7;
}

/* Back face: light (#E8F4F8) with detailed content -- dramatic light/dark inversion */
.license-back {
    background: #E8F4F8;
    border: 1px solid #5B8FA4;
    transform: rotateY(180deg);
    box-shadow: 0 4px 24px rgba(11, 29, 38, 0.2);
}

.license-detail {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.85rem;
    color: #1A3A4A;
    line-height: 1.7;
    text-align: center;
}

.license-flip-card .flip-affordance {
    color: #5B8FA4;
    opacity: 0.3;
}

/* ========================================
   SECTION 5: Vulnerability Trench
   Ocean trench cross-section -- severity mapped to depth
   ======================================== */
#vulnerability-stratum {
    min-height: 100vh;
    padding-bottom: 120px;
}

.trench-visualization {
    max-width: 700px;
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 0;
}

.trench-layer {
    padding: 24px 32px;
    border-left: 3px solid;
    position: relative;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.trench-layer.visible {
    opacity: 1;
    transform: translateY(0);
}

.trench-low {
    border-left-color: #5B8FA4;
    background: rgba(91, 143, 164, 0.1);
}

.trench-medium {
    border-left-color: #A8D8E8;
    background: rgba(168, 216, 232, 0.08);
}

.trench-high {
    border-left-color: #D4A574;
    background: rgba(212, 165, 116, 0.1);
}

.trench-critical {
    border-left-color: #D4A574;
    background: rgba(212, 165, 116, 0.15);
    border-left-width: 4px;
}

.trench-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 12px;
}

.severity-badge {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.7rem;
    font-weight: 500;
    letter-spacing: 0.1em;
    padding: 4px 12px;
    border-radius: 3px;
    color: #E8F4F8;
}

.severity-low { background: #2D5F6E; }
.severity-medium { background: #5B8FA4; }
.severity-high { background: #D4A574; }
.severity-critical {
    background: #D4A574;
    animation: pulse-critical 2s ease-in-out infinite;
}

@keyframes pulse-critical {
    0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(212, 165, 116, 0.4); }
    50% { opacity: 0.8; box-shadow: 0 0 12px 4px rgba(212, 165, 116, 0.2); }
}

.severity-count {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.75rem;
    color: #A8D8E8;
    opacity: 0.7;
}

.trench-details {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.vuln-entry {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: baseline;
    padding: 8px 0;
    border-bottom: 1px solid rgba(91, 143, 164, 0.15);
}

.vuln-entry:last-child {
    border-bottom: none;
}

.vuln-id {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.75rem;
    color: #D4A574;
    font-weight: 500;
    white-space: nowrap;
}

.vuln-pkg {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.75rem;
    color: #A8D8E8;
    white-space: nowrap;
}

.vuln-desc {
    font-family: 'Libre Baskerville', Georgia, serif;
    font-size: 0.8rem;
    color: #A8D8E8;
    opacity: 0.7;
    flex: 1;
    min-width: 200px;
}

/* Sonar Ping -- expanding rings at the bottom of the trench */
.sonar-ping-container {
    position: relative;
    width: 200px;
    height: 200px;
    margin: 60px auto 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sonar-ping {
    position: absolute;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 2px solid #A8D8E8;
    animation: sonar-expand 3s ease-out infinite;
}

.sonar-ping.delay-1 { animation-delay: 1s; }
.sonar-ping.delay-2 { animation-delay: 2s; }

@keyframes sonar-expand {
    0% {
        width: 20px;
        height: 20px;
        opacity: 0.8;
    }
    100% {
        width: 180px;
        height: 180px;
        opacity: 0;
    }
}

/* ========================================
   Footer
   ======================================== */
#site-footer {
    position: relative;
    z-index: 10;
    padding: 60px 20px;
    text-align: center;
    border-top: 1px solid rgba(91, 143, 164, 0.2);
}

.footer-text {
    font-family: 'Libre Baskerville', Georgia, serif;
    font-size: 0.9rem;
    color: #A8D8E8;
    margin-bottom: 8px;
}

.footer-depth {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.7rem;
    color: #5B8FA4;
    opacity: 0.6;
}

/* ========================================
   Sonar Scan Line Animation
   ======================================== */
@keyframes sonar-scan {
    0% { opacity: 0; transform: translateY(-100vh); }
    5% { opacity: 0.15; }
    95% { opacity: 0.15; }
    100% { opacity: 0; transform: translateY(100vh); }
}

/* ========================================
   Responsive
   ======================================== */
@media (max-width: 768px) {
    #depth-gauge {
        display: none;
    }

    .stratum-content {
        padding: 0 20px;
    }

    .stratum {
        padding: 60px 16px;
    }

    .hero-title {
        text-shadow:
            1px 1px 0 #2D5F6E,
            2px 2px 0 rgba(45, 95, 110, 0.6),
            3px 3px 10px rgba(11, 29, 38, 0.3);
    }

    .hero-card-flip,
    .license-flip-card {
        width: 260px;
        height: 350px;
    }

    .metadata-grid {
        grid-template-columns: 1fr;
    }

    .iso-block {
        width: 110px;
        height: 80px;
    }

    .iso-block.root-block {
        width: 140px;
        height: 100px;
    }

    .dep-level {
        gap: 12px;
    }

    .vuln-entry {
        flex-direction: column;
        gap: 4px;
    }

    .license-card-gallery {
        gap: 16px;
    }

    .trench-layer {
        padding: 16px 20px;
    }
}

@media (max-width: 480px) {
    .iso-block {
        width: 90px;
        height: 70px;
        transform: rotateX(20deg) rotateZ(-20deg);
    }

    .iso-top { font-size: 0.6rem; }
    .iso-right, .iso-left { font-size: 0.55rem; }

    .hero-card-flip,
    .license-flip-card {
        width: 240px;
        height: 320px;
    }

    .hero-content {
        gap: 40px;
    }

    .card-front-text {
        font-size: 1.15rem;
    }

    .license-name {
        font-size: 1.1rem;
    }
}
