/* =============================================
   AddrEnvoy — Address Routing Intelligence
   Color Palette:
     Deep Carbon:    #0D1117
     Gunmetal:       #161B22
     Steel Border:   #1C2937
     Titanium Text:  #E6EDF3
     Aluminum Body:  #B0BEC5
     Muted Steel:    #7D8B99
     Electric Cyan:  #00D4FF
     Warm Amber:     #E8A73D
     Deep Teal:      #1A6B5A
     Dark Terminal:  #080C11
   ============================================= */

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

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

body {
    background-color: #0D1117;
    color: #B0BEC5;
    font-family: 'Inter', sans-serif;
    font-weight: 400;
    line-height: 1.65;
    overflow-x: hidden;
}

/* === Typography === */
h1 {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    font-size: 3rem;
    letter-spacing: -0.03em;
    color: #E6EDF3;
}

h2 {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 600;
    font-size: 2rem;
    letter-spacing: -0.03em;
    color: #E6EDF3;
}

h3, h4 {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 500;
    font-size: 1.125rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: #7D8B99;
}

p {
    font-family: 'Inter', sans-serif;
    font-weight: 400;
    font-size: 1rem;
    line-height: 1.65;
    color: #B0BEC5;
}

/* === SVG Gradient Definitions (for connectors) === */
svg defs {
    position: absolute;
}

/* === Control Rail (Left Navigation) === */
#control-rail {
    position: fixed;
    left: 0;
    top: 0;
    width: 48px;
    height: 100vh;
    background-color: #0D1117;
    border-right: 1px solid #1C2937;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 32px;
    z-index: 1000;
    transform: translateX(-48px);
    opacity: 0;
}

#control-rail.visible {
    transform: translateX(0);
    opacity: 1;
    transition: transform 200ms ease-out, opacity 200ms ease-out;
}

.rail-icon {
    position: relative;
    color: #7D8B99;
    cursor: pointer;
    transition: color 250ms ease, transform 250ms cubic-bezier(0.34, 1.56, 0.64, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
}

.rail-icon::after {
    content: '';
    position: absolute;
    bottom: -4px;
    left: 50%;
    width: 0%;
    height: 2px;
    background: #00D4FF;
    transform: translateX(-50%) scaleX(0);
    transition: transform 250ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

.rail-icon:hover {
    color: #00D4FF;
    transform: scale(1.2);
    filter: drop-shadow(0 0 6px rgba(0, 212, 255, 0.4));
}

.rail-icon:hover::after {
    transform: translateX(-50%) scaleX(1);
    width: 100%;
}

.rail-tooltip {
    position: absolute;
    left: 52px;
    top: 50%;
    transform: translateY(-50%) translateX(-8px);
    background: #161B22;
    color: #E6EDF3;
    font-family: 'Inter', sans-serif;
    font-size: 0.75rem;
    font-weight: 500;
    padding: 4px 10px;
    border-radius: 4px;
    border: 1px solid #1C2937;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 200ms ease, transform 200ms ease;
}

.rail-icon:hover .rail-tooltip {
    opacity: 1;
    transform: translateY(-50%) translateX(0);
}

/* === Hero Section === */
#hero {
    position: relative;
    width: 100%;
    height: 100vh;
    margin-left: 48px;
    width: calc(100% - 48px);
    overflow: hidden;
    background-color: #0D1117;
}

#network-graph {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

#hero-content {
    position: absolute;
    top: 12%;
    left: 50%;
    transform: translateX(-50%);
    text-align: center;
    z-index: 10;
    opacity: 0;
}

#hero-content.visible {
    opacity: 1;
    transition: opacity 600ms ease;
}

.hero-title {
    font-size: clamp(2.5rem, 6vw, 4.5rem);
    letter-spacing: -0.03em;
    margin-bottom: 0.5rem;
    background: linear-gradient(135deg, #E6EDF3 0%, #00D4FF 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.hero-subtitle {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.8125rem;
    font-weight: 400;
    letter-spacing: 0.05em;
    color: #00D4FF;
}

/* === Hero Panels === */
#hero-panels {
    position: absolute;
    bottom: 8%;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 2px;
    z-index: 10;
    width: 90%;
    max-width: 1100px;
}

/* === Routing Panels === */
.routing-panel {
    background-color: #161B22;
    border: 1px solid #1C2937;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.4);
    padding: 24px;
    position: relative;
    overflow: hidden;
    transition: transform 250ms cubic-bezier(0.34, 1.56, 0.64, 1), border-color 250ms ease;
    background-image: radial-gradient(circle, #1C2937 1px, transparent 1px);
    background-size: 24px 24px;
    opacity: 0;
    transform: translateY(12px);
}

.routing-panel.visible {
    opacity: 1;
    transform: translateY(0);
    transition: opacity 400ms ease, transform 400ms ease;
}

.routing-panel:hover {
    transform: scale(1.02);
    border-color: #00D4FF;
}

.panel-node-cluster {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 40px;
    height: 40px;
    opacity: 0.15;
}

.panel-node-cluster::before,
.panel-node-cluster::after {
    content: '';
    position: absolute;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    border: 2px solid #00D4FF;
}

.panel-node-cluster::before {
    top: 0;
    right: 0;
}

.panel-node-cluster::after {
    bottom: 4px;
    right: 16px;
}

.panel-label {
    font-size: 0.75rem;
    margin-bottom: 8px;
}

.panel-title {
    font-size: 1.5rem;
    margin-bottom: 12px;
}

.panel-body {
    margin-bottom: 16px;
    font-size: 0.9375rem;
}

.panel-metric {
    display: flex;
    align-items: baseline;
    gap: 8px;
    padding-top: 12px;
    border-top: 1px solid #1C2937;
}

.metric-value {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 1.5rem;
    font-weight: 500;
    color: #00D4FF;
    letter-spacing: 0.05em;
}

.metric-label {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.8125rem;
    color: #4A6A7A;
    letter-spacing: 0.05em;
}

/* Hero panel layout */
#hero-panels .routing-panel {
    flex: 1;
}

/* === Section Connectors === */
.section-connector {
    margin-left: 48px;
    width: calc(100% - 48px);
    padding: 20px 0;
    display: flex;
    justify-content: center;
}

.connector-line {
    width: 200px;
    height: 60px;
}

/* === Routing Section (Dashboard Grid) === */
#routing-section {
    margin-left: 48px;
    width: calc(100% - 48px);
    padding: 60px 40px;
}

.routing-grid {
    display: grid;
    grid-template-columns: 65fr 35fr;
    gap: 2px;
    max-width: 1200px;
    margin: 0 auto;
}

.primary-panel {
    grid-row: 1;
}

.secondary-stack {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.secondary-panel {
    flex: 1;
}

/* Panel Stats */
.panel-stats {
    display: flex;
    gap: 24px;
    padding-top: 20px;
    border-top: 1px solid #1C2937;
    margin-top: 8px;
}

.stat-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.stat-value {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 1.25rem;
    font-weight: 500;
    color: #00D4FF;
    letter-spacing: 0.05em;
}

.stat-label {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.6875rem;
    color: #4A6A7A;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

/* Metric Readout (secondary panels) */
.metric-readout {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin: 12px 0;
}

.readout-value {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 2rem;
    font-weight: 500;
    color: #00D4FF;
    letter-spacing: 0.05em;
}

.readout-unit {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.8125rem;
    color: #4A6A7A;
    letter-spacing: 0.05em;
}

.readout-status {
    display: flex;
    align-items: center;
    gap: 6px;
}

.status-text {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.8125rem;
    color: #1A6B5A;
    letter-spacing: 0.05em;
}

/* === Relay Section === */
#relay-section {
    margin-left: 48px;
    width: calc(100% - 48px);
    padding: 80px 40px;
    position: relative;
}

.relay-heading {
    text-align: center;
    margin-bottom: 60px;
}

.relay-container {
    position: relative;
    max-width: 1200px;
    margin: 0 auto;
}

#relay-path-svg {
    width: 100%;
    height: 200px;
}

.relay-cards {
    display: flex;
    justify-content: space-around;
    margin-top: 40px;
    gap: 24px;
}

.relay-card {
    flex: 1;
    max-width: 300px;
    padding: 24px;
    background-color: #161B22;
    border: 1px solid #1C2937;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.4);
    opacity: 0;
    transform: translateY(16px);
    transition: opacity 500ms ease, transform 500ms ease;
    background-image: radial-gradient(circle, #1C2937 1px, transparent 1px);
    background-size: 24px 24px;
}

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

.relay-card:hover {
    border-color: #00D4FF;
    transform: scale(1.02);
    transition: transform 250ms cubic-bezier(0.34, 1.56, 0.64, 1), border-color 250ms ease;
}

/* Network node dot */
.network-node {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    border: 2px solid #00D4FF;
    box-shadow: 0 0 8px rgba(0, 212, 255, 0.3);
    margin-bottom: 12px;
    animation: node-breathe 3s ease-in-out infinite;
}

@keyframes node-breathe {
    0%, 100% { transform: scale(1); box-shadow: 0 0 8px rgba(0, 212, 255, 0.3); }
    50% { transform: scale(1.2); box-shadow: 0 0 14px rgba(0, 212, 255, 0.5); }
}

.relay-card-label {
    font-size: 0.75rem;
    margin-bottom: 8px;
}

.relay-card-text {
    font-size: 0.875rem;
    line-height: 1.6;
}

/* === Terminal Footer === */
#terminal-footer {
    margin-left: 48px;
    width: calc(100% - 48px);
    background-color: #080C11;
    padding: 40px;
}

.terminal-window {
    max-width: 900px;
    margin: 0 auto;
    background: #0D1117;
    border: 1px solid #1C2937;
    border-radius: 6px;
    overflow: hidden;
}

.terminal-header {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 14px;
    background: #161B22;
    border-bottom: 1px solid #1C2937;
}

.terminal-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.terminal-dot.red { background: #ff5f56; }
.terminal-dot.yellow { background: #ffbd2e; }
.terminal-dot.green { background: #27c93f; }

.terminal-title {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.75rem;
    color: #4A6A7A;
    margin-left: 8px;
}

.terminal-body {
    padding: 20px;
}

.terminal-line {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.8125rem;
    color: #00D4FF;
    letter-spacing: 0.05em;
    line-height: 2;
    white-space: nowrap;
    overflow: hidden;
    opacity: 0;
}

.terminal-line.visible {
    opacity: 1;
}

.terminal-line .typed-text {
    display: inline;
}

.cursor {
    animation: blink 530ms step-end infinite;
    color: #00D4FF;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

/* === Network Graph Nodes & Lines === */
.graph-node {
    fill: #0D1117;
    stroke: #00D4FF;
    stroke-width: 2;
    opacity: 0;
    transition: opacity 300ms ease;
}

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

.graph-node:hover {
    transform-origin: center;
    filter: drop-shadow(0 0 12px rgba(0, 212, 255, 0.6));
}

.graph-line {
    stroke: #1C2937;
    stroke-width: 1;
    fill: none;
}

.graph-line-active {
    stroke: #00D4FF;
    stroke-width: 1;
    fill: none;
    opacity: 0.6;
}

/* === Responsive === */
@media (max-width: 768px) {
    #control-rail {
        width: 100%;
        height: 48px;
        flex-direction: row;
        justify-content: center;
        gap: 16px;
        bottom: 0;
        top: auto;
        border-right: none;
        border-top: 1px solid #1C2937;
    }

    #control-rail.visible {
        transform: translateX(0) translateY(0);
    }

    .rail-tooltip {
        display: none;
    }

    #hero,
    #routing-section,
    #relay-section,
    #terminal-footer,
    .section-connector {
        margin-left: 0;
        width: 100%;
    }

    #hero {
        height: 100vh;
    }

    #hero-panels {
        flex-direction: column;
        width: 90%;
        bottom: 5%;
        gap: 2px;
    }

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

    .relay-cards {
        flex-direction: column;
        align-items: center;
    }

    .panel-stats {
        flex-wrap: wrap;
    }

    .hero-title {
        font-size: 2.5rem;
    }

    #routing-section,
    #relay-section,
    #terminal-footer {
        padding: 40px 20px;
    }

    .terminal-line {
        font-size: 0.6875rem;
        white-space: pre-wrap;
        word-break: break-all;
    }
}

@media (max-width: 480px) {
    #hero-panels {
        bottom: 2%;
    }

    .routing-panel {
        padding: 16px;
    }

    .panel-title {
        font-size: 1.25rem;
    }

    .readout-value {
        font-size: 1.5rem;
    }
}
