/* ------------------------------------------------------------------ */
/*  UEFI Driver Binding Mechanism Visualizer – Styles                  */
/*  Dark teal/orange theme                                             */
/* ------------------------------------------------------------------ */

:root {
    /* backgrounds */
    --bg:             #0b1220;
    --bg-soft:        #111927;
    --panel:          rgba(17, 25, 39, 0.85);
    --panel-border:   rgba(20, 184, 166, 0.12);

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

    /* accents */
    --primary:        #14b8a6;   /* teal */
    --primary-dim:    rgba(20, 184, 166, 0.18);
    --accent:         #fb923c;   /* orange */
    --accent-dim:     rgba(251, 146, 60, 0.15);

    /* domain colours */
    --driver-color:   #14b8a6;
    --driver-bg:      rgba(20, 184, 166, 0.10);
    --handle-color:   #fb923c;
    --handle-bg:      rgba(251, 146, 60, 0.10);
    --proto-color:    #a78bfa;
    --proto-bg:       rgba(167, 139, 250, 0.10);
    --core-color:     #38bdf8;
    --core-bg:        rgba(56, 189, 248, 0.10);
    --child-color:    #34d399;
    --child-bg:       rgba(52, 211, 153, 0.10);
    --warn-color:     #f87171;
    --warn-bg:        rgba(248, 113, 113, 0.10);

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

    /* layout */
    --nav-h: 64px;
    --max-w: 1140px;
    --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(90px);
    opacity: 0.15;
    pointer-events: none;
    z-index: -1;
}
.orb-a { width: 340px; height: 340px; top: -80px; left: -80px; background: var(--primary); }
.orb-b { width: 300px; height: 300px; bottom: 80px; right: -60px; background: var(--accent); }

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

.brand {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-shrink: 0;
    font-family: var(--head);
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text);
}

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

.nav-links {
    display: flex;
    list-style: none;
    gap: 4px;
    flex: 1;
    overflow-x: auto;
}

.nav-link {
    display: block;
    padding: 6px 12px;
    border-radius: 8px;
    color: var(--muted);
    text-decoration: none;
    font-size: 0.82rem;
    font-weight: 500;
    white-space: nowrap;
    transition: color 0.2s, background 0.2s;
}
.nav-link:hover, .nav-link.active {
    color: var(--primary);
    background: var(--driver-bg);
}

.lang-switcher {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

.lang-btn {
    padding: 5px 12px;
    border-radius: 8px;
    border: 1px solid var(--panel-border);
    background: transparent;
    color: var(--muted);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-family: var(--head);
}
.lang-btn:hover, .lang-btn.active {
    background: var(--primary-dim);
    border-color: var(--primary);
    color: var(--primary);
}

/* ================================================================== */
/*  Page layout                                                         */
/* ================================================================== */
.page {
    max-width: var(--max-w);
    margin: 0 auto;
    padding: 48px 24px 96px;
}

.section {
    margin-bottom: 80px;
    scroll-margin-top: calc(var(--nav-h) + 24px);
}

.section-head {
    margin-bottom: 36px;
    text-align: center;
}
.section-head h2 {
    font-family: var(--head);
    font-size: 1.7rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 10px;
}
.section-head p {
    color: var(--muted);
    font-size: 1rem;
    max-width: 700px;
    margin: 0 auto;
}

/* ---- hero ---- */
.hero {
    text-align: center;
    padding: 56px 0 40px;
}
.eyebrow {
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--primary);
    margin-bottom: 16px;
}
.hero h1 {
    font-family: var(--head);
    font-size: clamp(1.8rem, 4vw, 2.8rem);
    font-weight: 700;
    line-height: 1.15;
    background: linear-gradient(135deg, #14b8a6 0%, #fb923c 60%, #a78bfa 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 20px;
}
.hero-desc {
    color: var(--muted);
    font-size: 1.05rem;
    max-width: 680px;
    margin: 0 auto 48px;
}

/* ================================================================== */
/*  Panels / cards                                                      */
/* ================================================================== */
.panel {
    background: var(--panel);
    border: 1px solid var(--panel-border);
    border-radius: var(--radius);
    padding: 40px;
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    margin-top: 32px;
}

.card {
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.07);
    border-radius: 12px;
    padding: 24px;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.card:hover {
    border-color: var(--primary);
    box-shadow: 0 0 24px rgba(20,184,166,0.12);
}
.card-icon {
    font-size: 1.8rem;
    margin-bottom: 12px;
}
.card h3 {
    font-family: var(--head);
    font-size: 1rem;
    font-weight: 600;
    color: var(--primary);
    margin-bottom: 8px;
}
.card p {
    font-size: 0.9rem;
    color: var(--muted);
    line-height: 1.6;
}

/* three-function cards */
.fn-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 20px;
    margin-top: 28px;
}
.fn-card {
    border-radius: 12px;
    padding: 24px;
    border: 1px solid;
}
.fn-card.supported { border-color: rgba(20,184,166,0.35); background: rgba(20,184,166,0.06); }
.fn-card.start      { border-color: rgba(251,146,60,0.35);  background: rgba(251,146,60,0.06); }
.fn-card.stop       { border-color: rgba(248,113,113,0.35); background: rgba(248,113,113,0.06); }
.fn-card h3 {
    font-family: var(--mono);
    font-size: 1.05rem;
    margin-bottom: 10px;
}
.fn-card.supported h3 { color: var(--primary); }
.fn-card.start h3      { color: var(--accent); }
.fn-card.stop h3       { color: var(--warn-color); }
.fn-card p { font-size: 0.88rem; color: var(--muted); line-height: 1.65; }

/* connect box */
.connect-box {
    margin-top: 28px;
    padding: 24px;
    border-radius: 12px;
    border: 1px solid rgba(56,189,248,0.3);
    background: rgba(56,189,248,0.06);
}
.connect-box h3 {
    font-family: var(--head);
    font-size: 1rem;
    font-weight: 600;
    color: var(--core-color);
    margin-bottom: 10px;
}
.connect-box p { font-size: 0.9rem; color: var(--muted); line-height: 1.65; }

/* ================================================================== */
/*  Struct section                                                      */
/* ================================================================== */
.struct-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 24px;
    margin-top: 32px;
}

.struct-card {
    border-radius: 12px;
    padding: 0;
    border: 1px solid rgba(255,255,255,0.08);
    overflow: hidden;
}
.struct-card-header {
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
}
.struct-card-header .struct-name {
    font-family: var(--mono);
    font-size: 1.05rem;
    font-weight: 700;
}
.struct-card-header .struct-sig {
    font-family: var(--mono);
    font-size: 0.78rem;
    padding: 3px 8px;
    border-radius: 6px;
    opacity: 0.8;
}
.struct-ihandle   .struct-card-header { background: rgba(251,146,60,0.1); }
.struct-ihandle   .struct-name        { color: var(--handle-color); }
.struct-ihandle   .struct-sig         { background: rgba(251,146,60,0.2); color: var(--handle-color); }
.struct-pi        .struct-card-header { background: rgba(167,139,250,0.1); }
.struct-pi        .struct-name        { color: var(--proto-color); }
.struct-pi        .struct-sig         { background: rgba(167,139,250,0.2); color: var(--proto-color); }
.struct-pe        .struct-card-header { background: rgba(20,184,166,0.1); }
.struct-pe        .struct-name        { color: var(--primary); }
.struct-pe        .struct-sig         { background: rgba(20,184,166,0.2); color: var(--primary); }

.struct-desc {
    padding: 14px 20px;
    font-size: 0.88rem;
    color: var(--muted);
    border-bottom: 1px solid rgba(255,255,255,0.06);
    line-height: 1.6;
}

.struct-fields {
    padding: 12px 0;
}
.struct-field {
    display: flex;
    gap: 12px;
    padding: 9px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.04);
    align-items: flex-start;
}
.struct-field:last-child { border-bottom: none; }
.field-name {
    font-family: var(--mono);
    font-size: 0.8rem;
    font-weight: 600;
    flex-shrink: 0;
    min-width: 100px;
    color: var(--text);
}
.field-desc {
    font-size: 0.82rem;
    color: var(--muted);
    line-height: 1.5;
}

.diagram-wrap {
    margin-top: 36px;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--panel-border);
    background: rgba(0,0,0,0.25);
    padding: 24px;
}
.diagram-title {
    font-family: var(--head);
    font-size: 1rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 8px;
}
.diagram-desc {
    font-size: 0.88rem;
    color: var(--muted);
    margin-bottom: 20px;
}
.diagram-wrap svg {
    width: 100%;
    height: auto;
    display: block;
}

/* ================================================================== */
/*  Step-by-step controls                                               */
/* ================================================================== */
.step-controls {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.step-btn {
    padding: 8px 20px;
    border-radius: 8px;
    border: 1px solid var(--primary);
    background: transparent;
    color: var(--primary);
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-family: var(--head);
}
.step-btn:hover:not(:disabled) {
    background: var(--primary-dim);
}
.step-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
    border-color: var(--muted);
    color: var(--muted);
}
.reset-btn {
    border-color: var(--muted);
    color: var(--muted);
}
.reset-btn:hover:not(:disabled) {
    background: rgba(139,155,176,0.12);
    border-color: var(--text);
    color: var(--text);
}

.step-indicator {
    font-family: var(--mono);
    font-size: 0.85rem;
    color: var(--muted);
    min-width: 80px;
    text-align: center;
}

.step-description {
    background: rgba(20,184,166,0.06);
    border: 1px solid rgba(20,184,166,0.2);
    border-radius: 10px;
    padding: 18px 22px;
    margin-bottom: 20px;
}
.step-description h3 {
    font-family: var(--head);
    font-size: 1rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 8px;
}
.step-description p {
    font-size: 0.9rem;
    color: var(--muted);
    line-height: 1.65;
}
.step-description p + p { margin-top: 6px; }
.step-description code {
    font-family: var(--mono);
    font-size: 0.82rem;
    background: rgba(20,184,166,0.12);
    color: var(--primary);
    padding: 1px 5px;
    border-radius: 4px;
}

.step-description.disconnect-step {
    background: rgba(248,113,113,0.06);
    border-color: rgba(248,113,113,0.2);
}
.step-description.disconnect-step h3 { color: var(--warn-color); }
.step-description.disconnect-step code {
    background: rgba(248,113,113,0.12);
    color: var(--warn-color);
}

.svg-container {
    width: 100%;
    overflow-x: auto;
    border-radius: 10px;
    background: rgba(0,0,0,0.3);
    border: 1px solid var(--panel-border);
    margin-bottom: 20px;
    padding: 4px;
}
.svg-container svg {
    width: 100%;
    min-width: 700px;
    height: auto;
    display: block;
}

/* ================================================================== */
/*  Code section                                                        */
/* ================================================================== */
.code-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 0;
    border-bottom: 1px solid var(--panel-border);
    padding-bottom: 0;
}
.code-tab {
    padding: 9px 18px;
    border-radius: 8px 8px 0 0;
    border: 1px solid transparent;
    border-bottom: none;
    background: transparent;
    color: var(--muted);
    font-size: 0.83rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-family: var(--head);
}
.code-tab:hover { color: var(--text); }
.code-tab.active {
    background: var(--panel);
    border-color: var(--panel-border);
    color: var(--primary);
}

.code-pane { display: none; }
.code-pane.active { display: block; }

.code-file-label {
    font-family: var(--mono);
    font-size: 0.78rem;
    color: var(--muted);
    padding: 10px 20px 6px;
    border-bottom: 1px solid var(--panel-border);
    background: rgba(0,0,0,0.2);
}

.code-block {
    background: rgba(0,0,0,0.4);
    border-radius: 0 0 10px 10px;
    padding: 20px;
    overflow-x: auto;
}
.code-block pre {
    font-family: var(--mono);
    font-size: 0.82rem;
    line-height: 1.7;
    color: #c9d1d9;
    white-space: pre;
}

/* syntax-like highlight helpers */
.kw  { color: #ff7b72; }   /* keyword */
.fn  { color: #d2a8ff; }   /* function */
.cm  { color: #6e7681; font-style: italic; } /* comment */
.str { color: #a5d6ff; }   /* string */
.num { color: #79c0ff; }   /* number */
.tp  { color: #ffa657; }   /* type */

/* ================================================================== */
/*  Scenario                                                            */
/* ================================================================== */
.scenario-desc {
    font-size: 0.95rem;
    color: var(--muted);
    margin-bottom: 36px;
    line-height: 1.7;
    max-width: 780px;
}

.scenario-chain {
    display: flex;
    flex-direction: column;
    gap: 0;
}
.scenario-layer {
    display: flex;
    align-items: stretch;
    gap: 24px;
    padding: 0 0 0 24px;
    position: relative;
}
.scenario-layer::before {
    content: '';
    position: absolute;
    left: 11px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: linear-gradient(to bottom, var(--primary), var(--accent));
    border-radius: 2px;
}
.scenario-layer:last-child::before { bottom: 50%; }
.scenario-dot {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--primary);
    border: 3px solid var(--bg);
    flex-shrink: 0;
    margin-top: 18px;
    z-index: 1;
    position: absolute;
    left: 0;
}
.scenario-layer:nth-child(2) .scenario-dot { background: var(--accent); }
.scenario-layer:nth-child(3) .scenario-dot { background: var(--proto-color); }
.scenario-layer:nth-child(4) .scenario-dot { background: var(--child-color); }
.scenario-content {
    flex: 1;
    padding: 18px 20px;
    margin: 10px 0;
    border-radius: 10px;
    border: 1px solid rgba(255,255,255,0.07);
    background: rgba(255,255,255,0.025);
}
.scenario-layer-label {
    font-family: var(--mono);
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--primary);
    margin-bottom: 4px;
}
.scenario-layer:nth-child(2) .scenario-layer-label { color: var(--accent); }
.scenario-layer:nth-child(3) .scenario-layer-label { color: var(--proto-color); }
.scenario-layer:nth-child(4) .scenario-layer-label { color: var(--child-color); }
.scenario-content h4 {
    font-family: var(--head);
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 6px;
}
.scenario-content p {
    font-size: 0.87rem;
    color: var(--muted);
    line-height: 1.6;
}
.scenario-protocols {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 10px;
}
.proto-badge {
    font-family: var(--mono);
    font-size: 0.72rem;
    padding: 3px 10px;
    border-radius: 20px;
    background: rgba(20,184,166,0.12);
    color: var(--primary);
    border: 1px solid rgba(20,184,166,0.25);
}
.proto-badge.new {
    background: rgba(251,146,60,0.12);
    color: var(--accent);
    border-color: rgba(251,146,60,0.25);
}
.proto-badge.child {
    background: rgba(52,211,153,0.12);
    color: var(--child-color);
    border-color: rgba(52,211,153,0.25);
}

/* ================================================================== */
/*  References                                                          */
/* ================================================================== */
.refs-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.refs-list li {
    padding: 18px 22px;
    border-radius: 10px;
    border: 1px solid rgba(255,255,255,0.07);
    background: rgba(255,255,255,0.025);
}
.refs-list a {
    font-family: var(--mono);
    font-size: 0.88rem;
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
    display: block;
    margin-bottom: 6px;
}
.refs-list a:hover { color: var(--accent); text-decoration: underline; }
.refs-list p {
    font-size: 0.85rem;
    color: var(--muted);
    line-height: 1.55;
}

/* ================================================================== */
/*  Footer                                                              */
/* ================================================================== */
.footer {
    text-align: center;
    padding: 24px;
    border-top: 1px solid var(--panel-border);
    color: var(--muted);
    font-size: 0.82rem;
}

/* ================================================================== */
/*  Responsive                                                          */
/* ================================================================== */
@media (max-width: 900px) {
    .top-nav { padding: 0 16px; gap: 12px; }
    .nav-links { gap: 2px; }
    .page { padding: 32px 16px 64px; }
    .panel { padding: 24px 18px; }
    .struct-grid { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
    .nav-links { display: none; }
    .brand span { display: none; }
    .hero h1 { font-size: 1.6rem; }
    .fn-grid { grid-template-columns: 1fr; }
}
