/* ------------------------------------------------------------------ */
/*  SMM/MM Communication Visualizer – Styles                           */
/*  Dark red/cyan theme                                                */
/* ------------------------------------------------------------------ */

:root {
    /* backgrounds */
    --bg:             #0c1118;
    --bg-soft:        #131a24;
    --panel:          rgba(19, 26, 36, 0.82);
    --panel-border:   rgba(239, 68, 68, 0.12);

    /* text */
    --text:           #e6edf3;
    --muted:          #8b9bb0;

    /* accents */
    --primary:        #ef4444;
    --primary-dim:    rgba(239, 68, 68, 0.18);
    --accent:         #22d3ee;
    --accent-dim:     rgba(34, 211, 238, 0.15);

    /* domain colours */
    --dxe-color:      #34d399;
    --dxe-bg:         rgba(52, 211, 153, 0.10);
    --smm-color:      #ef4444;
    --smm-bg:         rgba(239, 68, 68, 0.10);
    --comm-color:     #fbbf24;
    --comm-bg:        rgba(251, 191, 36, 0.10);
    --smram-color:    #f472b6;
    --smram-bg:       rgba(244, 114, 182, 0.10);
    --cpu-color:      #a78bfa;
    --cpu-bg:         rgba(167, 139, 250, 0.10);
    --mm-color:       #22d3ee;
    --mm-bg:          rgba(34, 211, 238, 0.10);

    /* phase colours */
    --phase-dxe:      #34d399;
    --phase-smi:      #ef4444;
    --phase-smm:      #f472b6;
    --phase-ret:      #22d3ee;

    /* fonts */
    --head:  'Space Grotesk', system-ui, sans-serif;
    --body:  'Manrope', system-ui, sans-serif;
    --mono:  'JetBrains Mono', 'Cascadia Code', monospace;

    /* layout */
    --nav-h: 64px;
    --max-w: 1120px;
    --radius: 16px;
}

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

html {
    scroll-behavior: smooth;
    scroll-padding-top: calc(var(--nav-h) + 24px);
}

body {
    font-family: var(--body);
    background: var(--bg);
    color: var(--text);
    line-height: 1.65;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

/* ---- ambient orbs ---- */
.bg-orb {
    position: fixed;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.18;
    pointer-events: none;
    z-index: -1;
}
.orb-a { width: 320px; height: 320px; top: -60px; left: -80px;  background: var(--smm-color); }
.orb-b { width: 280px; height: 280px; bottom: -40px; right: -60px; background: var(--accent); }

/* ================================================================== */
/*  Top Navigation                                                     */
/* ================================================================== */
.top-nav {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    gap: 16px;
    height: var(--nav-h);
    padding: 0 24px;
    background: rgba(12, 17, 24, 0.85);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--panel-border);
}

.back-link {
    color: var(--muted);
    text-decoration: none;
    font-size: 0.85rem;
    font-family: var(--head);
    white-space: nowrap;
    transition: color 0.2s;
}
.back-link:hover { color: var(--primary); }

.nav-links {
    display: flex;
    gap: 6px;
    flex: 1;
    justify-content: center;
    overflow-x: auto;
}
.nav-link {
    color: var(--muted);
    text-decoration: none;
    font-size: 0.82rem;
    font-family: var(--head);
    padding: 6px 14px;
    border-radius: 8px;
    transition: all 0.2s;
    white-space: nowrap;
}
.nav-link:hover            { color: var(--text); background: var(--primary-dim); }
.nav-link.active           { color: var(--primary); background: var(--primary-dim); font-weight: 600; }

.lang-switcher { display: flex; gap: 4px; }
.lang-btn {
    background: transparent;
    border: 1px solid var(--panel-border);
    color: var(--muted);
    font-family: var(--head);
    font-size: 0.78rem;
    padding: 4px 10px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}
.lang-btn:hover  { color: var(--text); border-color: var(--primary); }
.lang-btn.active { color: var(--primary); border-color: var(--primary); background: var(--primary-dim); }

/* ================================================================== */
/*  Sections                                                           */
/* ================================================================== */
.section {
    max-width: var(--max-w);
    margin: 0 auto;
    padding: 60px 24px 40px;
}
.section + .section { padding-top: 30px; }

.panel {
    background: var(--panel);
    border: 1px solid var(--panel-border);
    border-radius: var(--radius);
    padding: 48px 36px;
    margin-bottom: 32px;
}

h1 {
    font-family: var(--head);
    font-size: 2.4rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--smm-color) 0%, var(--accent) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 8px;
    text-align: center;
}
h2 {
    font-family: var(--head);
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 6px;
}
h3 {
    font-family: var(--head);
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 8px;
}
.section-subtitle {
    color: var(--muted);
    font-size: 0.95rem;
    margin-bottom: 28px;
    text-align: center;
}
.panel > .section-subtitle { text-align: left; }

/* ================================================================== */
/*  Phase Timeline                                                     */
/* ================================================================== */
.phase-timeline {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    flex-wrap: wrap;
    margin: 32px 0 40px;
}
.phase-item {
    padding: 10px 18px;
    border-radius: 10px;
    font-family: var(--head);
    font-size: 0.85rem;
    font-weight: 600;
    border: 1px solid transparent;
    transition: transform 0.2s;
}
.phase-item.dxe-phase   { background: rgba(52,211,153,0.12);  color: var(--phase-dxe);  border-color: rgba(52,211,153,0.25); }
.phase-item.smi-phase   { background: rgba(239,68,68,0.12);   color: var(--phase-smi);  border-color: rgba(239,68,68,0.25); }
.phase-item.smm-phase   { background: rgba(244,114,182,0.12); color: var(--phase-smm);  border-color: rgba(244,114,182,0.25); }
.phase-item.ret-phase   { background: rgba(34,211,238,0.12);  color: var(--phase-ret);  border-color: rgba(34,211,238,0.25); }
.phase-item.highlight {
    animation: pulseGlow 2s ease-in-out infinite;
}
@keyframes pulseGlow {
    0%, 100% { box-shadow: 0 0 0 0 rgba(239,68,68,0.25); }
    50%      { box-shadow: 0 0 18px 4px rgba(239,68,68,0.18); }
}
.phase-arrow {
    color: var(--muted);
    font-size: 1.1rem;
    user-select: none;
}

/* ================================================================== */
/*  Info Cards (Overview)                                              */
/* ================================================================== */
.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 24px;
}
.info-card {
    background: var(--bg-soft);
    border: 1px solid var(--panel-border);
    border-radius: var(--radius);
    padding: 28px 24px;
    transition: transform 0.25s, box-shadow 0.25s;
}
.info-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 32px rgba(0,0,0,0.25);
}
.info-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--head);
    font-weight: 700;
    font-size: 1.2rem;
    margin-bottom: 16px;
}
.smm-icon  { background: var(--smm-bg);  color: var(--smm-color);  border: 1px solid rgba(239,68,68,0.25); }
.dxe-icon  { background: var(--dxe-bg);  color: var(--dxe-color);  border: 1px solid rgba(52,211,153,0.25); }
.mm-icon   { background: var(--mm-bg);   color: var(--mm-color);   border: 1px solid rgba(34,211,238,0.25); }
.comm-icon { background: var(--comm-bg);  color: var(--comm-color); border: 1px solid rgba(251,191,36,0.25); }

.info-card p { color: var(--muted); font-size: 0.9rem; line-height: 1.7; }

/* ================================================================== */
/*  Architecture Cards                                                 */
/* ================================================================== */
.arch-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 20px;
    margin-top: 28px;
}
.arch-card {
    padding: 22px 20px;
    border-radius: 12px;
    border: 1px solid transparent;
}
.arch-card h3 { font-size: 1.05rem; margin-bottom: 6px; }
.arch-card p  { color: var(--muted); font-size: 0.88rem; line-height: 1.65; }
.dram-card  { background: var(--dxe-bg);   border-color: rgba(52,211,153,0.18); }
.dram-card h3  { color: var(--dxe-color); }
.smram-card { background: var(--smram-bg); border-color: rgba(244,114,182,0.18); }
.smram-card h3 { color: var(--smram-color); }
.comm-card  { background: var(--comm-bg);  border-color: rgba(251,191,36,0.18); }
.comm-card h3  { color: var(--comm-color); }

/* ================================================================== */
/*  Diagram Containers                                                 */
/* ================================================================== */
.diagram-container {
    width: 100%;
    margin: 20px 0;
    border-radius: 12px;
    background: rgba(0,0,0,0.25);
    border: 1px solid rgba(255,255,255,0.05);
    overflow: hidden;
}
.diagram-container svg {
    display: block;
    width: 100%;
    height: auto;
}
.flow-diagram-container {
    min-height: 420px;
}

/* ================================================================== */
/*  Step Controls                                                      */
/* ================================================================== */
.step-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}
.step-btn {
    font-family: var(--head);
    font-size: 0.85rem;
    font-weight: 600;
    padding: 8px 20px;
    border-radius: 8px;
    border: 1px solid var(--panel-border);
    background: var(--bg-soft);
    color: var(--text);
    cursor: pointer;
    transition: all 0.2s;
}
.step-btn:hover:not(:disabled) {
    background: var(--primary-dim);
    border-color: var(--primary);
    color: var(--primary);
}
.step-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}
.step-btn.reset {
    border-color: rgba(239,68,68,0.3);
    color: var(--smm-color);
}
.step-btn.reset:hover {
    background: rgba(239,68,68,0.12);
    border-color: var(--smm-color);
}
#flow-indicator {
    font-family: var(--mono);
    font-size: 0.9rem;
    color: var(--primary);
    min-width: 100px;
    text-align: center;
}

/* ================================================================== */
/*  Step Description                                                   */
/* ================================================================== */
.step-description {
    background: var(--bg-soft);
    border: 1px solid var(--panel-border);
    border-radius: 12px;
    padding: 24px;
    margin-top: 16px;
}
.step-description h3 {
    color: var(--primary);
    margin-bottom: 10px;
}
.step-description p {
    color: var(--muted);
    font-size: 0.92rem;
    line-height: 1.7;
}
.step-detail {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--panel-border);
    font-size: 0.85rem !important;
    font-style: italic;
    opacity: 0.8;
}

/* ================================================================== */
/*  Buffer Layout                                                      */
/* ================================================================== */
.buffer-intro {
    color: var(--muted);
    font-size: 0.92rem;
    line-height: 1.7;
    margin-bottom: 20px;
}
.struct-box {
    text-align: center;
    margin: 20px 0 28px;
}
.struct-box code {
    font-family: var(--mono);
    font-size: 1.05rem;
    color: var(--primary);
    background: var(--primary-dim);
    padding: 12px 28px;
    border-radius: 10px;
    border: 1px solid rgba(239,68,68,0.25);
    display: inline-block;
}
.buffer-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 20px;
    margin-top: 24px;
}
.buffer-card {
    background: var(--bg-soft);
    border: 1px solid var(--panel-border);
    border-radius: 12px;
    padding: 22px 20px;
}
.buffer-card h3 { color: var(--accent); font-size: 1rem; margin-bottom: 8px; }
.buffer-card p  { color: var(--muted); font-size: 0.88rem; line-height: 1.65; }

/* ================================================================== */
/*  Comparison Cards (Standalone MM)                                   */
/* ================================================================== */
.compare-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 24px;
    margin-top: 24px;
}
.compare-card {
    background: var(--bg-soft);
    border: 1px solid var(--panel-border);
    border-radius: var(--radius);
    padding: 28px 24px;
}
.compare-card h3 { margin-bottom: 12px; }
.compare-card.traditional h3 { color: var(--smm-color); }
.compare-card.standalone h3  { color: var(--accent); }
.compare-card ul {
    list-style: none;
    padding: 0;
}
.compare-card li {
    color: var(--muted);
    font-size: 0.88rem;
    line-height: 1.7;
    padding: 4px 0 4px 16px;
    position: relative;
}
.compare-card li::before {
    content: '';
    position: absolute;
    left: 0;
    top: 11px;
    width: 6px;
    height: 6px;
    border-radius: 50%;
}
.compare-card.traditional li::before { background: var(--smm-color); }
.compare-card.standalone  li::before { background: var(--accent); }

/* ================================================================== */
/*  Code Blocks                                                        */
/* ================================================================== */
.code-blocks {
    display: flex;
    flex-direction: column;
    gap: 28px;
}
.code-block {
    background: var(--bg-soft);
    border: 1px solid var(--panel-border);
    border-radius: 12px;
    padding: 24px;
}
.code-block h3 { color: var(--primary); margin-bottom: 6px; }
.code-block > p { color: var(--muted); font-size: 0.88rem; margin-bottom: 16px; }

.code-block pre {
    background: rgba(0,0,0,0.35);
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: 10px;
    padding: 20px;
    overflow-x: auto;
    font-size: 0.82rem;
    line-height: 1.6;
}
.code-block code {
    font-family: var(--mono);
    color: #c9d1d9;
}

/* ================================================================== */
/*  Reference Grid                                                     */
/* ================================================================== */
.ref-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-top: 20px;
}
.ref-card {
    display: block;
    text-decoration: none;
    background: var(--bg-soft);
    border: 1px solid var(--panel-border);
    border-radius: 12px;
    padding: 22px 20px;
    transition: all 0.25s;
}
.ref-card:hover {
    border-color: var(--primary);
    transform: translateY(-3px);
    box-shadow: 0 8px 24px rgba(0,0,0,0.25);
}
.ref-card h3 { color: var(--primary); font-size: 1rem; margin-bottom: 6px; }
.ref-card p  { color: var(--muted); font-size: 0.85rem; line-height: 1.55; }

/* ================================================================== */
/*  Footer                                                             */
/* ================================================================== */
footer {
    max-width: var(--max-w);
    margin: 0 auto;
    text-align: center;
    padding: 40px 24px 48px;
    border-top: 1px solid var(--panel-border);
}
footer p   { color: #6e6e6e; font-size: 0.85rem; }
footer a   { color: var(--primary); text-decoration: none; }
footer a:hover { text-decoration: underline; }

/* ================================================================== */
/*  Responsive                                                         */
/* ================================================================== */
@media (max-width: 768px) {
    :root { --nav-h: 56px; }
    h1 { font-size: 1.8rem; }
    .panel { padding: 28px 18px; }
    .phase-timeline { gap: 6px; }
    .phase-item { padding: 7px 10px; font-size: 0.75rem; }
    .phase-arrow { font-size: 0.9rem; }
    .nav-links { gap: 2px; }
    .nav-link { font-size: 0.75rem; padding: 5px 8px; }
    .back-link { font-size: 0.78rem; }
    .step-controls { gap: 8px; }
    .step-btn { padding: 6px 12px; font-size: 0.8rem; }
    .flow-diagram-container { min-height: 320px; }
}

@media (max-width: 480px) {
    .phase-timeline { flex-direction: column; align-items: stretch; }
    .phase-arrow { text-align: center; transform: rotate(90deg); }
}

/* ---- reduced motion ---- */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}
