/* ============================================
   UNDO.SYSTEMS - Blueprint Architecture
   ============================================ */

:root {
    --bp-bg: #0a1628;
    --surface: #0e1f38;
    --header: #1a3a5c;
    --grid: #1a3a5c;
    --text-primary: #e0ecf4;
    --text-secondary: #b0c4d8;
    --text-tertiary: #6a8aac;
    --conn: #3a9aca;
    --green: #3ad68c;
    --amber: #e8a040;
    --red: #d05050;
}

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

html {
    background: var(--bp-bg);
}

body {
    font-family: 'Inter', sans-serif;
    color: var(--text-secondary);
    background: var(--bp-bg);
    background-image:
        repeating-linear-gradient(0deg, transparent, transparent 119px, rgba(26,58,92,0.2) 119px, rgba(26,58,92,0.2) 120px),
        repeating-linear-gradient(90deg, transparent, transparent 119px, rgba(26,58,92,0.2) 119px, rgba(26,58,92,0.2) 120px),
        repeating-linear-gradient(0deg, transparent, transparent 29px, rgba(26,58,92,0.08) 29px, rgba(26,58,92,0.08) 30px),
        repeating-linear-gradient(90deg, transparent, transparent 29px, rgba(26,58,92,0.08) 29px, rgba(26,58,92,0.08) 30px);
    overflow-x: hidden;
    line-height: 1.65;
    padding-bottom: 36px;
}

/* === Status Bar === */
#status-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 36px;
    background: var(--bp-bg);
    border-top: 1px solid var(--grid);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    z-index: 100;
    padding: 0 1rem;
}

.status-text {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.7rem;
    color: var(--text-tertiary);
    white-space: nowrap;
}

.status-sep {
    color: rgba(106,138,172,0.3);
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.7rem;
}

/* === Blueprint Sections === */
.blueprint-section {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4rem 2rem;
}

.section-inner {
    max-width: 960px;
    width: 100%;
    position: relative;
}

.shutdown-center {
    text-align: center;
}

/* === System Title === */
.system-title {
    font-family: 'Space Grotesk', sans-serif;
    font-size: clamp(1.8rem, 4vw, 3.2rem);
    font-weight: 700;
    letter-spacing: -0.01em;
    text-transform: uppercase;
    color: var(--text-primary);
    text-align: center;
    margin-bottom: 3rem;
}

.system-title .letter {
    display: inline-block;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.system-title .letter.visible {
    opacity: 1;
}

/* === Module Title === */
.module-title {
    font-family: 'Space Grotesk', sans-serif;
    font-size: clamp(1.3rem, 2.5vw, 2rem);
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-primary);
    margin-bottom: 1.5rem;
    letter-spacing: -0.01em;
}

/* === System Blocks === */
.sys-block {
    background: rgba(14,31,56,0.8);
    border: 1px solid var(--grid);
    overflow: hidden;
    opacity: 0;
    transition: opacity 0.8s ease;
}

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

.sys-block-wide {
    width: 100%;
}

.block-header {
    height: 24px;
    background: var(--header);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 0.75rem;
}

.block-id {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.7rem;
    color: var(--text-tertiary);
}

.version-stamp {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.6rem;
    padding: 1px 6px;
    border: 1px solid;
}

.stamp-green {
    color: var(--green);
    border-color: var(--green);
}

.stamp-amber {
    color: var(--amber);
    border-color: var(--amber);
}

.stamp-red {
    color: var(--red);
    border-color: var(--red);
}

.block-body {
    padding: 1.5rem;
}

.block-text {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.75rem;
}

.block-subtext {
    font-family: 'Inter', sans-serif;
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.6;
}

.body-text {
    font-family: 'Inter', sans-serif;
    font-size: clamp(0.9rem, 1.05vw, 1.05rem);
    color: var(--text-secondary);
    line-height: 1.65;
    margin-bottom: 1rem;
}

/* === Annotations === */
.annotation {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 1rem;
}

.annotation-dot {
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: var(--conn);
    flex-shrink: 0;
}

.annotation-text {
    font-family: 'Inter', sans-serif;
    font-size: 0.75rem;
    font-style: italic;
    color: var(--text-tertiary);
}

/* === Module Grid === */
.module-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 3rem;
    align-items: start;
}

/* === Connection Lines === */
.connection-line {
    position: absolute;
    top: 50%;
    left: calc(50% - 30px);
    width: 60px;
    height: 2px;
    z-index: 5;
}

.conn-path {
    stroke-dasharray: 60;
    stroke-dashoffset: 60;
    transition: stroke-dashoffset 0.8s ease;
}

.conn-path.drawn {
    stroke-dashoffset: 0;
}

/* === Stack Diagram === */
.stack-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.stack-diagram {
    display: flex;
    flex-direction: column;
    gap: 2px;
    width: 200px;
    margin: 0 auto;
}

.stack-item {
    height: 40px;
    display: flex;
    align-items: center;
    padding: 0 0.75rem;
    border: 1px solid var(--grid);
    opacity: 0;
    transform: translateY(-10px);
    transition: opacity 0.4s ease, transform 0.4s ease;
}

.stack-item.visible {
    opacity: 1;
    transform: translateY(0);
}

.stack-item:nth-child(odd) { background: var(--surface); }
.stack-item:nth-child(even) { background: var(--header); }

.stack-label {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.7rem;
    color: var(--text-tertiary);
}

.stack-arrows {
    display: flex;
    justify-content: space-between;
    margin-top: 0.5rem;
}

.stack-arrow-label {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.6rem;
    color: var(--conn);
}

/* === State Machine === */
.state-diagram {
    width: 100%;
    overflow-x: auto;
}

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

.state-node {
    opacity: 0;
    transition: opacity 0.6s ease;
}

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

.state-active {
    filter: drop-shadow(0 0 12px rgba(58,214,140,0.3));
}

.state-warning {
    filter: drop-shadow(0 0 12px rgba(232,160,64,0.3));
}

.state-label {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 10px;
    fill: var(--text-primary);
}

.state-sublabel {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 8px;
    fill: var(--text-tertiary);
}

.trans-path {
    stroke-dasharray: 200;
    stroke-dashoffset: 200;
    transition: stroke-dashoffset 1s ease;
}

.trans-path.drawn {
    stroke-dashoffset: 0;
}

.trans-label {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 9px;
    fill: var(--text-tertiary);
}

/* === Flowchart === */
.flowchart {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
    padding: 2rem 0;
}

.flow-node {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    border: 1.5px solid var(--conn);
    opacity: 0;
    transition: opacity 0.6s ease;
}

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

.flow-diamond {
    width: 220px;
    height: 80px;
    transform: rotate(0deg);
    background: transparent;
    clip-path: polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%);
    background: var(--surface);
    border: none;
    position: relative;
}

.flow-diamond::before {
    content: '';
    position: absolute;
    top: -1px;
    left: -1px;
    right: -1px;
    bottom: -1px;
    clip-path: polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%);
    border: 1.5px solid var(--conn);
    pointer-events: none;
}

.flow-rect {
    width: 180px;
    min-height: 48px;
    background: var(--surface);
}

.flow-terminal {
    width: 200px;
    min-height: 48px;
    border-radius: 24px;
}

.flow-terminal-green {
    border-color: var(--green);
    color: var(--green);
}

.flow-terminal-amber {
    border-color: var(--amber);
    color: var(--amber);
}

.flow-text {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.75rem;
    color: var(--text-primary);
    text-align: center;
}

.flow-terminal-green .flow-text { color: var(--green); }
.flow-terminal-amber .flow-text { color: var(--amber); }

.flow-connector {
    width: 1.5px;
    background: var(--conn);
}

.flow-v {
    height: 24px;
}

.flow-branch {
    display: flex;
    gap: 4rem;
    margin-top: 1rem;
}

.flow-path {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
}

.flow-path .flow-connector {
    height: 16px;
}

.flow-label {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.7rem;
    margin-bottom: 0.5rem;
}

.label-green { color: var(--green); }
.label-amber { color: var(--amber); }

/* === Shutdown === */
.shutdown-text {
    font-family: 'Space Grotesk', sans-serif;
    font-size: clamp(1.3rem, 2.5vw, 2rem);
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.shutdown-domain {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.8rem;
    color: var(--text-tertiary);
    margin-top: 2rem;
    opacity: 0.5;
}

/* === Responsive === */
@media (max-width: 768px) {
    .module-grid {
        grid-template-columns: 1fr;
    }

    .connection-line {
        display: none;
    }

    .flow-branch {
        flex-direction: column;
        gap: 1rem;
    }

    .state-svg {
        min-width: 500px;
    }

    #status-bar {
        gap: 0.5rem;
    }

    .status-text {
        font-size: 0.6rem;
    }
}
