/* --- Global Variables & Theme --- */
:root {
    --bg-main: #0f172a;
    /* Dark Navy */
    --bg-card: #1e293b;
    /* Lighter Navy for cards */
    --accent: #f59e0b;
    /* Amber/Gold */
    --text-main: #f8fafc;
    /* Off-White */
    --text-muted: #94a3b8;
    /* Gray-Blue */
    --text-accent: #000000;
    /* Gray-Blue */
    --border: #334155;
    /* Subtle border */
    --success: #10b981;
    /* Emerald */
    --warning: #ef4444;
    /* Red */
}

/* --- Base Layout --- */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

img {
    max-width: 100%;
    height: auto;
}

body {
    background-color: var(--bg-main);
    color: var(--text-main);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    line-height: 1.6;
}

.container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 2rem;
}

header {
    text-align: center;
    padding: 4rem 1rem;
    background: linear-gradient(180deg, #1e293b 0%, #0f172a 100%);
    border-bottom: 1px solid var(--border);
}

header h1 {
    font-size: 2.5rem;
    color: var(--accent);
    margin-bottom: 0.5rem;
}

header p {
    color: var(--text-muted);
}

section {
    margin-bottom: 4rem;
}

h2 {
    font-size: 1.8rem;
    margin-top: 1em;
    margin-bottom: 1.5rem;
    border-left: 4px solid var(--accent);
    padding-left: 1rem;
}

h3 {
    font-size: 1.8rem;
    margin-top: 1em;
    margin-bottom: 1.5rem;
    color: var(--text-muted);
    padding-left: 1rem;
}

/* --- Grid & Cards --- */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr));
    gap: 1.5rem;
    margin-top: 1.5rem;
}

.card {
    background: var(--bg-card);
    padding: 1.5rem;
    border-radius: 12px;
    border: 2px solid var(--border);
    transition: transform 0.2s ease, border-color 0.2s ease;
}

.card:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
}

.card h3 {
    color: var(--accent);
    margin-bottom: 1rem;
}

/* --- Tables --- */
.table-wrapper {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    margin: 1rem 0;
    font-size: 0.95rem;
    overflow-x: auto;
    word-break: break-word;
}

th,
td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

th {
    color: var(--accent);
    font-weight: 600;
}

/* --- UI Elements --- */
.btn {
    display: inline-block;
    padding: 10px 20px;
    background: transparent;
    border: 1px solid var(--accent);
    color: var(--accent);
    text-decoration: none;
    border-radius: 6px;
    transition: all 0.2s;
}

.btn:hover {
    background: var(--accent);
    color: var(--text-accent);
}

code {
    font-family: 'Fira Code', monospace;
    color: var(--accent);
}

.warning-box {
    border-radius: 8px;
}

.footnote {
    text-decoration: none;
    font-size: 0.8rem;
    vertical-align: super;
    color: var(--accent);
    margin-left: 2px;
    font-weight: bold;
}

.img-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-top: 20px;
    margin-bottom: 10px;
}

/* --- Modal Background --- */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.95);
    cursor: zoom-out;
}

/* --- The Actual Image Container --- */
.modal-content {
    margin: auto;
    display: block;
    width: fit-content;
    height: fit-content;
    max-width: 95%;
    max-height: 95%;
    position: relative;
    top: 50%;
    transform: translateY(-50%);
    border: 3px solid var(--accent);
    border-radius: 12px;
    background-color: var(--bg-card);
    box-shadow: 0 0 50px rgba(0, 0, 0, 0.8);
    overflow: hidden;
}

.modal-content img {
    display: block;
    max-width: 100%;
    max-height: 85vh;
    height: auto;
}

/* --- Close Button --- */
.close {
    position: absolute;
    top: 10px;
    right: 15px;
    color: var(--accent);
    font-size: 30px;
    font-weight: bold;
    cursor: pointer;
    z-index: 1001;
    background: rgba(30, 41, 59, 0.7);
    /* Semi-transparent background */
    width: 40px;
    height: 40px;
    line-height: 38px;
    text-align: center;
    border-radius: 50%;
    transition: all 0.2s;
}

.close:hover {
    background: var(--accent);
    color: var(--bg-main);
}

/* --- Responsive --- */
@media (max-width: 600px) {
    .container {
        padding: 1rem;
    }

    header h1 {
        font-size: 1.8rem;
    }
}

/* --- Architecture Diagram & Interactive Styles --- */
.arch-diagram {
    display: flex;
    align-items: stretch;
    justify-content: space-between;
    gap: 1.5rem;
    margin: 2.5rem 0;
    flex-wrap: wrap;
}

.arch-card {
    background: linear-gradient(145deg, #1e293b, #111827);
    border: 2px solid var(--border);
    border-radius: 12px;
    padding: 1.5rem;
    flex: 1 1 300px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.arch-card:hover {
    border-color: var(--accent);
    box-shadow: 0 8px 30px rgba(245, 158, 11, 0.15);
    transform: translateY(-2px);
}

.arch-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: var(--accent);
    opacity: 0.8;
}

.arch-card.hub::before {
    background: #f59e0b; /* Amber */
}

.arch-card.node::before {
    background: #10b981; /* Emerald */
}

.arch-card h3 {
    margin-top: 0;
    font-size: 1.4rem;
    display: flex;
    align-items: center;
    gap: 10px;
}

.arch-card-list {
    list-style-type: none;
    margin-top: 1rem;
}

.arch-card-list li {
    margin-bottom: 0.8rem;
    padding-left: 1.5rem;
    position: relative;
    font-size: 0.95rem;
}

.arch-card-list li::before {
    content: "•";
    color: var(--accent);
    font-size: 1.5rem;
    position: absolute;
    left: 0;
    top: -4px;
}

.arch-card.node .arch-card-list li::before {
    color: #10b981;
}

/* Cable Flow styling */
.cable-flow {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 0 1 150px;
    min-width: 100px;
    text-align: center;
    position: relative;
    padding: 1rem 0;
}

.cable-line-container {
    width: 100%;
    height: 12px;
    background: #1e293b;
    border-radius: 6px;
    border: 1px solid var(--border);
    position: relative;
    overflow: hidden;
    margin: 1rem 0;
}

.cable-pulse {
    position: absolute;
    top: 0;
    left: -100%;
    height: 100%;
    width: 100%;
    background: linear-gradient(90deg, transparent, rgba(245, 158, 11, 0.8), #10b981, transparent);
    animation: flow-pulse 2.5s infinite linear;
}

.cable-labels {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.cable-label-power {
    color: #f59e0b;
}

.cable-label-data {
    color: #10b981;
}

@keyframes flow-pulse {
    0% {
        left: -100%;
    }
    100% {
        left: 100%;
    }
}

/* Interactive architecture diagram responsive */
@media (max-width: 800px) {
    .arch-diagram {
        flex-direction: column;
    }
    .cable-flow {
        flex: 1 1 auto;
        width: 100%;
        padding: 1.5rem 0;
    }
    .cable-line-container {
        width: 12px;
        height: 100px;
        margin: 0.5rem auto;
    }
    .cable-pulse {
        top: -100%;
        left: 0;
        width: 100%;
        height: 100%;
        background: linear-gradient(180deg, transparent, rgba(245, 158, 11, 0.8), #10b981, transparent);
        animation: flow-pulse-vertical 2.5s infinite linear;
    }
}

@keyframes flow-pulse-vertical {
    0% {
        top: -100%;
    }
    100% {
        top: 100%;
    }
}

/* Style for technical specs grids */
.spec-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
    margin-top: 1.5rem;
}

.spec-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.25rem;
    transition: border-color 0.2s;
}

.spec-card:hover {
    border-color: var(--accent);
}

.spec-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--accent);
    margin-bottom: 0.5rem;
}

/* --- Purpose & Motivation Cards --- */
.purpose-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 400px), 1fr));
    gap: 1.5rem;
    margin-top: 1.5rem;
    margin-bottom: 2.5rem;
}

.purpose-card {
    background: linear-gradient(145deg, rgba(30, 41, 59, 0.4) 0%, rgba(15, 23, 42, 0.3) 100%);
    border: 2px solid var(--border);
    border-radius: 12px;
    padding: 1.75rem;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.purpose-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
}

.purpose-card.exists {
    border-left: 4px solid var(--accent);
}

.purpose-card.exists:hover {
    border-color: var(--accent);
    box-shadow: 0 8px 30px rgba(245, 158, 11, 0.15);
}

.purpose-card.hardware {
    border-left: 4px solid var(--success);
}

.purpose-card.hardware:hover {
    border-color: var(--success);
    box-shadow: 0 8px 30px rgba(16, 185, 129, 0.15);
}

.purpose-card h3 {
    margin-top: 0;
    margin-bottom: 1rem;
    padding-left: 0;
    font-size: 1.4rem;
    display: flex;
    align-items: center;
    gap: 12px;
}

.purpose-card.exists h3 {
    color: var(--accent);
}

.purpose-card.hardware h3 {
    color: var(--success);
}

.purpose-card p {
    color: var(--text-main);
    line-height: 1.7;
    font-size: 0.95rem;
}

/* --- Thermal Stability Section --- */
.thermal-container {
    display: flex;
    gap: 2rem;
    background: linear-gradient(145deg, rgba(30, 41, 59, 0.4) 0%, rgba(15, 23, 42, 0.3) 100%);
    border: 2px solid var(--border);
    border-top: 4px solid var(--success);
    border-radius: 12px;
    padding: 2rem;
    margin-top: 1.5rem;
    transition: all 0.3s ease;
}

.thermal-container:hover {
    border-color: var(--success);
    box-shadow: 0 12px 40px rgba(16, 185, 129, 0.1);
}

.thermal-image-wrapper {
    flex: 0 0 380px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.thermal-image-wrapper img {
    border-radius: 10px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.4);
    transition: transform 0.3s ease;
    width: 100%;
}

.thermal-image-wrapper img:hover {
    transform: scale(1.02);
}

.thermal-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.thermal-badge-container {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-bottom: 0.5rem;
}

.thermal-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.thermal-badge.problem {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.thermal-badge.solution {
    background: rgba(16, 185, 129, 0.15);
    color: var(--success);
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.thermal-badge.materials {
    background: rgba(245, 158, 11, 0.15);
    color: var(--accent);
    border: 1px solid rgba(245, 158, 11, 0.3);
}

.thermal-content p {
    color: var(--text-main);
    line-height: 1.7;
    font-size: 0.95rem;
    text-align: justify;
}

/* Responsive adjustment for thermal container */
@media (max-width: 850px) {
    .thermal-container {
        flex-direction: column;
        padding: 1.5rem;
    }
    .thermal-image-wrapper {
        flex: 1 1 auto;
        width: 100%;
    }
}

/* --- AI Copilot Section --- */
.ai-copilot-card {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.1) 0%, rgba(168, 85, 247, 0.05) 50%, rgba(15, 23, 42, 0.3) 100%);
    border: 2px solid rgba(168, 85, 247, 0.25);
    border-radius: 12px;
    padding: 2rem;
    margin-top: 2rem;
    margin-bottom: 2.5rem;
    position: relative;
    overflow: hidden;
    transition: all 0.3s ease;
}

.ai-copilot-card:hover {
    border-color: rgba(168, 85, 247, 0.5);
    box-shadow: 0 12px 40px rgba(168, 85, 247, 0.15);
    transform: translateY(-3px);
}

.ai-copilot-card::after {
    content: '';
    position: absolute;
    top: -50%;
    right: -50%;
    width: 250px;
    height: 250px;
    background: radial-gradient(circle, rgba(168, 85, 247, 0.12) 0%, transparent 70%);
    z-index: 0;
    pointer-events: none;
}

.ai-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.5rem;
    z-index: 1;
    position: relative;
}

.ai-title-group {
    display: flex;
    align-items: center;
    gap: 12px;
}

.ai-title-group h3 {
    margin: 0 !important;
    padding-left: 0 !important;
    font-size: 1.5rem;
    background: linear-gradient(90deg, var(--accent), #a855f7);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    font-weight: 700;
}

.ai-prompt-box {
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.25rem;
    font-family: 'Fira Code', 'Courier New', monospace;
    font-size: 0.85rem;
    color: var(--text-muted);
    max-height: 240px;
    overflow-y: auto;
    line-height: 1.6;
    margin-bottom: 1rem;
    white-space: pre-wrap;
    text-align: left;
    position: relative;
    z-index: 1;
}

.ai-prompt-box::-webkit-scrollbar {
    width: 6px;
}

.ai-prompt-box::-webkit-scrollbar-track {
    background: rgba(15, 23, 42, 0.3);
    border-radius: 4px;
}

.ai-prompt-box::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

.ai-prompt-box::-webkit-scrollbar-thumb:hover {
    background: rgba(168, 85, 247, 0.4);
}

.btn-ai {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: linear-gradient(90deg, var(--accent) 0%, #a855f7 100%);
    border: none;
    color: #0f172a;
    font-weight: bold;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: inherit;
    font-size: 0.9rem;
    box-shadow: 0 4px 15px rgba(168, 85, 247, 0.2);
    z-index: 1;
    position: relative;
}

.btn-ai:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(168, 85, 247, 0.4);
    filter: brightness(1.15);
}

.btn-ai:active {
    transform: translateY(1px);
}

.btn-ai.copied {
    background: var(--success) !important;
    color: var(--bg-main) !important;
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.4) !important;
}