/* HMAC-Protected Circuit Breaker - Technical Documentation CSS */
/* No inline styles - CSP compliant */

:root {
    --primary-color: #f59e0b;
    --primary-dark: #d97706;
    --primary-light: #fbbf24;
    --accent-color: #ef4444;
    --accent-dark: #dc2626;
    --success-color: #10b981;
    --success-dark: #059669;
    --warning-color: #f97316;
    --bg-dark: #0a0a12;
    --bg-card: #111118;
    --bg-card-hover: #18181f;
    --text-primary: #ffffff;
    --text-secondary: #9ca3af;
    --text-muted: #6b7280;
    --border-color: #1f2937;
    --border-amber: rgba(245, 158, 11, 0.25);
    --code-bg: #0d0d1a;
    --code-border: #1e1e3a;
    --shadow-glow: 0 0 24px rgba(245, 158, 11, 0.25);
    --shadow-card: 0 4px 12px rgba(0, 0, 0, 0.5);
    --shadow-amber: 0 0 16px rgba(245, 158, 11, 0.35);
    --shadow-red: 0 0 16px rgba(239, 68, 68, 0.3);
    --shadow-green: 0 0 16px rgba(16, 185, 129, 0.3);
}

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

html, body {
    background: transparent;
    min-height: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    color: var(--text-primary);
    line-height: 1.65;
    min-height: 100vh;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 12px;
    height: 12px;
}

::-webkit-scrollbar-track {
    background: linear-gradient(180deg, #0a0a12 0%, #0f0a1a 100%);
    border-radius: 6px;
}

::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, var(--primary-color) 0%, var(--accent-color) 100%);
    border-radius: 6px;
    border: 2px solid rgba(0, 0, 0, 0.3);
    box-shadow: 0 0 10px rgba(245, 158, 11, 0.4);
}

::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, var(--primary-light) 0%, var(--warning-color) 100%);
    box-shadow: 0 0 15px rgba(245, 158, 11, 0.6);
}

* {
    scrollbar-width: thin;
    scrollbar-color: var(--primary-color) #0a0a12;
}

/* ──────────────────────────────────────────────
   Header
────────────────────────────────────────────── */
.cb-header {
    background: linear-gradient(135deg, #0f0a00 0%, #1a0f00 40%, #120a0a 100%);
    padding: 2rem 1rem;
    box-shadow: 0 4px 24px rgba(245, 158, 11, 0.25);
    border-bottom: 3px solid var(--primary-color);
    position: relative;
    z-index: 50;
}

.header-container {
    max-width: 1400px;
    margin: 0 auto;
}

.header-content {
    display: flex;
    align-items: center;
    gap: 2rem;
}

.logo-link {
    display: flex;
    align-items: center;
    text-decoration: none;
    transition: transform 0.3s ease;
    flex-shrink: 0;
}

.logo-link:hover {
    transform: scale(1.05);
}

.logo-image {
    width: 72px;
    height: 72px;
    border-radius: 12px;
    border: 2px solid var(--primary-color);
    box-shadow: var(--shadow-amber);
    object-fit: cover;
}

.title-container {
    flex: 1;
}

.page-title {
    font-size: 2.2rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--primary-light) 0%, var(--primary-color) 50%, var(--warning-color) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    line-height: 1.2;
    margin-bottom: 0.35rem;
    text-shadow: none;
}

.page-subtitle {
    font-size: 1rem;
    color: var(--text-secondary);
    margin-bottom: 0.8rem;
}

.badge-container {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
}

.badge-img {
    height: 20px;
    border-radius: 3px;
    vertical-align: middle;
}

/* ──────────────────────────────────────────────
   Tab Navigation
────────────────────────────────────────────── */
.tab-nav {
    position: sticky;
    top: 0;
    z-index: 40;
    background: rgba(10, 10, 18, 0.97);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-amber);
    padding: 0 1rem;
    box-shadow: 0 2px 16px rgba(0, 0, 0, 0.5);
}

.tab-nav-inner {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    flex-wrap: wrap;
    gap: 0;
}

.tab-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
    padding: 1rem 1.4rem;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    transition: color 0.2s ease, border-color 0.2s ease;
    white-space: nowrap;
    letter-spacing: 0.01em;
}

.tab-btn:hover {
    color: var(--primary-light);
    border-bottom-color: rgba(245, 158, 11, 0.4);
}

.tab-btn.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
    font-weight: 700;
    text-shadow: 0 0 12px rgba(245, 158, 11, 0.5);
}

/* ──────────────────────────────────────────────
   Content Container
────────────────────────────────────────────── */
.content-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem 1rem 4rem;
    position: relative;
    z-index: 50;
}

.tab-content {
    display: none;
    animation: fadeTabIn 0.3s ease;
}

.tab-content.active {
    display: block;
}

@keyframes fadeTabIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ──────────────────────────────────────────────
   Cards
────────────────────────────────────────────── */
.info-card {
    background: linear-gradient(135deg, var(--bg-card) 0%, rgba(15, 10, 0, 0.9) 100%);
    border: 1px solid var(--border-amber);
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: var(--shadow-card);
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.info-card:hover {
    border-color: var(--primary-color);
    box-shadow: var(--shadow-amber);
}

.card-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-amber);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-size: 0.85rem;
}

/* ──────────────────────────────────────────────
   Overview Grid
────────────────────────────────────────────── */
.overview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.info-list {
    list-style: none;
}

.info-list dt {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-top: 0.75rem;
}

.info-list dd {
    font-size: 0.95rem;
    color: var(--text-primary);
    margin-top: 0.2rem;
}

.info-list dd a {
    color: var(--primary-color);
    text-decoration: none;
}

.info-list dd a:hover {
    text-decoration: underline;
    color: var(--primary-light);
}

.feature-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
}

.feature-list li {
    font-size: 0.9rem;
    color: var(--text-secondary);
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    line-height: 1.4;
}

.icon-check {
    color: var(--success-color);
    font-size: 1rem;
    flex-shrink: 0;
    margin-top: 0.05rem;
    font-weight: 700;
}

.icon-warn {
    color: var(--warning-color);
    font-size: 1rem;
    flex-shrink: 0;
    margin-top: 0.05rem;
}

.icon-block {
    color: var(--accent-color);
    font-size: 1rem;
    flex-shrink: 0;
    margin-top: 0.05rem;
}

/* ──────────────────────────────────────────────
   Section headings
────────────────────────────────────────────── */
.section-title {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 1.25rem;
    margin-top: 2rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--border-amber);
}

.section-title:first-child {
    margin-top: 0;
}

.section-subtitle {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--primary-light);
    margin-bottom: 0.75rem;
    margin-top: 1.5rem;
}

.section-text {
    color: var(--text-secondary);
    font-size: 0.95rem;
    line-height: 1.7;
    margin-bottom: 1rem;
}

.section-text a {
    color: var(--primary-color);
    text-decoration: none;
}

.section-text a:hover {
    color: var(--primary-light);
    text-decoration: underline;
}

/* Callout / note boxes */
.callout {
    border-left: 4px solid var(--primary-color);
    background: rgba(245, 158, 11, 0.07);
    border-radius: 0 8px 8px 0;
    padding: 1rem 1.25rem;
    margin: 1.25rem 0;
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.6;
}

.callout-warning {
    border-left-color: var(--accent-color);
    background: rgba(239, 68, 68, 0.07);
}

.callout-success {
    border-left-color: var(--success-color);
    background: rgba(16, 185, 129, 0.07);
}

.callout strong {
    color: var(--primary-color);
}

.callout-warning strong {
    color: var(--accent-color);
}

.callout-success strong {
    color: var(--success-color);
}

/* ──────────────────────────────────────────────
   Code Blocks
────────────────────────────────────────────── */
.code-block-wrapper {
    position: relative;
    margin: 1rem 0;
}

.code-label {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--primary-color);
    background: rgba(245, 158, 11, 0.12);
    border: 1px solid var(--border-amber);
    border-bottom: none;
    border-radius: 6px 6px 0 0;
    padding: 0.25rem 0.75rem;
}

.code-block {
    background: var(--code-bg);
    border: 1px solid var(--code-border);
    border-radius: 8px;
    padding: 1.25rem 1.5rem;
    overflow-x: auto;
    position: relative;
    box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.4);
}

.code-block-wrapper .code-label + .code-block {
    border-top-left-radius: 0;
}

.code-block pre {
    margin: 0;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 0.85rem;
    line-height: 1.6;
    color: #e2e8f0;
    white-space: pre;
}

.code-block code {
    font-family: inherit;
    font-size: inherit;
    color: inherit;
}

.copy-btn {
    position: absolute;
    top: 0.6rem;
    right: 0.6rem;
    background: rgba(245, 158, 11, 0.15);
    border: 1px solid var(--border-amber);
    border-radius: 5px;
    color: var(--primary-color);
    font-size: 0.72rem;
    font-weight: 600;
    padding: 0.3rem 0.65rem;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s ease, background 0.2s ease;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.code-block-wrapper:hover .copy-btn {
    opacity: 1;
}

.copy-btn:hover {
    background: rgba(245, 158, 11, 0.3);
    color: var(--primary-light);
}

.copy-btn.copied {
    background: rgba(16, 185, 129, 0.2);
    border-color: var(--success-color);
    color: var(--success-color);
    opacity: 1;
}

/* Syntax color helpers */
.kw  { color: #c792ea; }      /* keywords */
.str { color: #c3e88d; }      /* strings */
.com { color: #546e7a; }      /* comments */
.num { color: #f78c6c; }      /* numbers */
.fn  { color: #82aaff; }      /* function names */
.ty  { color: #ffcb6b; }      /* types */
.mc  { color: #89ddff; }      /* macros / special */
.op  { color: #89ddff; }      /* operators */
.hx  { color: #f59e0b; }      /* hex / amber highlights */

/* ──────────────────────────────────────────────
   Tables
────────────────────────────────────────────── */
.table-wrapper {
    overflow-x: auto;
    border-radius: 10px;
    border: 1px solid var(--border-amber);
    margin: 1rem 0 1.5rem;
    box-shadow: var(--shadow-card);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
}

.data-table thead {
    background: linear-gradient(90deg, #1a0e00 0%, #1f1200 100%);
}

.data-table th {
    padding: 0.85rem 1rem;
    text-align: left;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--primary-color);
    border-bottom: 2px solid var(--primary-dark);
    white-space: nowrap;
}

.data-table td {
    padding: 0.75rem 1rem;
    color: var(--text-secondary);
    border-bottom: 1px solid rgba(31, 41, 55, 0.5);
    vertical-align: top;
    line-height: 1.5;
}

.data-table tbody tr:hover td {
    background: rgba(245, 158, 11, 0.05);
}

.data-table tbody tr:last-child td {
    border-bottom: none;
}

.data-table code {
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.82rem;
    color: var(--primary-light);
    background: rgba(245, 158, 11, 0.08);
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
}

.td-default {
    color: var(--text-muted);
    font-size: 0.82rem;
}

.td-desc {
    font-size: 0.85rem;
    max-width: 420px;
}

.td-fit {
    width: 44px;
    text-align: center;
    white-space: nowrap;
    vertical-align: middle;
}

.td-fit .icon-check,
.td-fit .icon-block {
    font-size: 1.1rem;
    margin: 0;
}

/* ──────────────────────────────────────────────
   Architecture Diagram
────────────────────────────────────────────── */
.arch-diagram {
    background: var(--code-bg);
    border: 1px solid var(--code-border);
    border-radius: 10px;
    padding: 1.5rem;
    overflow-x: auto;
    margin: 1.25rem 0;
}

.arch-diagram pre {
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 0.82rem;
    line-height: 1.55;
    color: #94a3b8;
    white-space: pre;
}

.arch-svg {
    width: 100%;
    max-width: 560px;
    display: block;
    overflow: visible;
}

.state-svg {
    width: 100%;
    display: block;
    overflow: visible;
}

.arch-diagram .arch-amber { color: #f59e0b; }
.arch-diagram .arch-green { color: #10b981; }
.arch-diagram .arch-red   { color: #ef4444; }
.arch-diagram .arch-blue  { color: #60a5fa; }

/* ──────────────────────────────────────────────
   State Machine Diagrams
────────────────────────────────────────────── */
.state-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
    margin: 1.25rem 0;
}

.state-card {
    background: linear-gradient(135deg, var(--bg-card) 0%, rgba(15, 10, 0, 0.85) 100%);
    border: 1px solid var(--border-amber);
    border-radius: 12px;
    padding: 1.5rem;
}

.state-card-title {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--primary-color);
    text-transform: uppercase;
    letter-spacing: 0.07em;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-amber);
}

.state-legend {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    margin-top: 1rem;
}

.state-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.87rem;
}

.state-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
}

.state-dot-closed  { background: var(--success-color); box-shadow: 0 0 8px var(--success-color); }
.state-dot-open    { background: var(--primary-color); box-shadow: 0 0 8px var(--primary-color); }
.state-dot-tripped { background: var(--accent-color);  box-shadow: 0 0 8px var(--accent-color); }
.state-dot-half    { background: #60a5fa;               box-shadow: 0 0 8px #60a5fa; }

/* ──────────────────────────────────────────────
   Design Guarantees Table highlight
────────────────────────────────────────────── */
.guarantee-label {
    font-weight: 700;
    color: var(--primary-light);
    font-size: 0.85rem;
}

/* ──────────────────────────────────────────────
   Security badges / tags
────────────────────────────────────────────── */
.security-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin: 1rem 0;
}

.security-tag {
    background: rgba(245, 158, 11, 0.12);
    border: 1px solid var(--border-amber);
    border-radius: 20px;
    color: var(--primary-light);
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.3rem 0.8rem;
    letter-spacing: 0.04em;
}

.security-tag-green {
    background: rgba(16, 185, 129, 0.1);
    border-color: rgba(16, 185, 129, 0.3);
    color: var(--success-color);
}

.security-tag-red {
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.3);
    color: var(--accent-color);
}

/* ──────────────────────────────────────────────
   Two-column layout helpers
────────────────────────────────────────────── */
.two-col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin: 1rem 0;
}

@media (max-width: 768px) {
    .two-col {
        grid-template-columns: 1fr;
    }
}

/* ──────────────────────────────────────────────
   Footer
────────────────────────────────────────────── */
.cb-footer {
    background: linear-gradient(135deg, #0a0a12 0%, #0f0a00 100%);
    border-top: 1px solid var(--border-amber);
    padding: 2rem 1rem;
    position: relative;
    z-index: 10;
}

.footer-container {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

.footer-links {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    list-style: none;
}

.footer-link {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.85rem;
    transition: color 0.2s ease;
}

.footer-link:hover {
    color: var(--primary-color);
}

.footer-copy {
    font-size: 0.82rem;
    color: var(--text-muted);
}

/* ──────────────────────────────────────────────
   Responsive
────────────────────────────────────────────── */
@media (max-width: 1024px) {
    .page-title {
        font-size: 1.8rem;
    }
}

@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    .page-title {
        font-size: 1.5rem;
    }

    .tab-nav {
        padding: 0 0.5rem;
    }

    .tab-nav-inner {
        overflow-x: auto;
        flex-wrap: nowrap;
    }

    .tab-btn {
        padding: 0.85rem 1rem;
        font-size: 0.82rem;
    }

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

    .content-container {
        padding: 1.25rem 0.75rem 3rem;
    }

    .section-title {
        font-size: 1.3rem;
    }
}

@media (max-width: 480px) {
    .logo-image {
        width: 56px;
        height: 56px;
    }

    .code-block {
        padding: 1rem;
    }

    .code-block pre {
        font-size: 0.78rem;
    }
}
