/*
 * Sovereign Header Hardening — Geometric Baseline
 * Authority: AGC Directive Phase 2
 * Locked by: leodennis [2026-05-01]
 * Source of Truth: This file overrides all per-file inline header rules.
 * DO NOT DUPLICATE any rule from this file in page-level <style> blocks.
 */

@import url('https://fonts.googleapis.com/css2?family=Bebas+Neue&display=swap');

/* ══════════════════════════════════════════════════════════════
   §1  CSS VARIABLES — extends :root (safe additive merge)
══════════════════════════════════════════════════════════════ */
:root {
    --gold-grad: linear-gradient(45deg, #3b2222, #654328, #b59140, #ffeaaa);
    --neon-green: #00C853;

    /* Spectral lane gradients — L1 to L5  (Source: Design Spec §2-4 Spectral Accents) */
    --lane-l1: linear-gradient(90deg, #faee21, #6fc600, #00ffff);
    --lane-l2: linear-gradient(90deg, #c90003, #185100, #64aa38);
    --lane-l3: linear-gradient(90deg, #6ae70e, #08fded, #d072ed);
    --lane-l4: linear-gradient(90deg, #007daf, #c771d4, #ffb529);
    --lane-l5: linear-gradient(90deg, #1ebda5, #e26a00, #ffe046);
}

/* ══════════════════════════════════════════════════════════════
   §2  BRANDING ARCHITECTURE — Bebas Neue 30px + 45° Gold Gradient
══════════════════════════════════════════════════════════════ */
.hdr-brand-text {
    font-family: 'Bebas Neue', sans-serif !important;
    font-size: 30px !important;
    font-weight: 400 !important;          /* Bebas Neue has no weight variants */
    letter-spacing: 3px;
    background: var(--gold-grad) !important;
    -webkit-background-clip: text !important;
    -webkit-text-fill-color: transparent !important;
    background-clip: text !important;
    white-space: nowrap;
    /* override any previous color or gradient property */
    color: transparent !important;
}

/* ══════════════════════════════════════════════════════════════
   §3  EVALUATION TUBE PHYSICS
   Pill-shaped, centered, widened — 5 sovereign lanes
══════════════════════════════════════════════════════════════ */

/* ══ VERTICAL CENTERING: eng-bars fills hdr-engines and centers tube cols ══ */
.hdr-engines {
    display: flex !important;
    flex-direction: column !important;
    justify-content: center !important;   /* vertical center within 218px zone */
    align-items: stretch !important;
}

/* Remove any inherited bottom border from legacy .eng-bars */
.eng-bars {
    display: flex !important;
    justify-content: center !important;
    gap: 24px !important;
    align-items: center !important;
    height: auto !important;              /* let content determine height, centered by parent */
    padding: 0 40px !important;
    border-bottom: none !important;
    flex-shrink: 0 !important;
    position: relative !important;
}

.eng-bar-col {
    flex: 1 !important;
    max-width: 300px !important;
    min-width: 140px !important;
    position: relative !important;        /* anchor for flyout */
    display: flex !important;
    flex-direction: column !important;
    gap: 6px !important;
    padding: 0 !important;
    border-left: none !important;
    border-right: none !important;
    justify-content: center !important;
    align-items: stretch !important;
}

.eng-bar-col:last-child {
    border-right: none !important;
}

/* ══ TUBE HEADER ROW LAYOUT ══
   Structure: [LABEL TEXT]──────[PCT%]──[▼]
   Label: left-aligned, truncated
   Pct:   center-right, neon green
   Arrow: far right, gold triangle — REQUIRED BY SPEC
══════════════════════════════════════════════════════ */
.eng-tube-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0;
    width: 100%;
}

.eng-tube-label {
    font-family: 'JetBrains Mono', Calibri, monospace;
    font-size: 9.5px;
    font-weight: 700;
    color: #aaa;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;                              /* grows to fill space, pushes % and ▼ right */
    min-width: 0;
}

/* Percentage — neon green, compact, right of label */
/* ── HIDE % labels on OP dashboards — segments speak for themselves ── */
.eng-tube-pct,
.eng-bar-pct {
    display: none !important;
}

/* (legacy selector kept for reference only — now hidden) */
.eng-tube-pct {
    font-family: 'JetBrains Mono', Calibri, monospace;
    font-size: 10px;
    font-weight: 700;
    color: var(--neon-green);
    white-space: nowrap;
    flex-shrink: 0;
    margin: 0 4px;
}

/* Keep legacy .eng-bar-pct working (used by JS to update %) */
.eng-bar-pct {
    font-family: 'JetBrains Mono', Calibri, monospace;
    font-size: 10px;
    font-weight: 700;
    color: var(--neon-green);
}

/* ══ ▼ TRIANGLE TRIGGER — spec §2.3: right-side of each tube lane ══
   Rendered as solid CSS border-triangle (NOT Unicode ▼ — hidden via color:transparent).
   At rest : gold #b59140
   Hover   : light gold #ffeaaa
   Active  : emerald green #00C853 + rotate(180deg) to ▲
════════════════════════════════════════════════════════════════════ */
.eng-tube-arrow {
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 16px;
    height: 16px;
    user-select: none;
    position: relative;
    /* Render a solid downward triangle via CSS */
    color: transparent;                  /* hide the ▼ character */
}

/* CSS triangle rendered as ::after pseudo-element */
.eng-tube-arrow::after {
    content: '';
    display: block;
    width: 0;
    height: 0;
    border-left:   5px solid transparent;
    border-right:  5px solid transparent;
    border-top:    7px solid #b59140;    /* gold at rest */
    transition: border-top-color 0.2s ease, transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.eng-tube-arrow:hover::after {
    border-top-color: #ffeaaa;           /* light gold on hover */
}

.eng-tube-arrow.active::after {
    border-top-color: var(--neon-green); /* neon green when flyout is open */
    transform: rotate(180deg);           /* flip to ▲ when open */
}

/* PILL-SHAPED TRACK — 16px height for visual presence (spec min 14px) */
.eng-bar-track {
    width: 100% !important;
    height: 16px !important;
    border-radius: 10px !important;
    background: #1a1a1a !important;
    overflow: hidden !important;
    border: 1px solid #333 !important;
    margin-top: 0 !important;
    position: relative !important;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.8) !important;
}

/* 10-SEGMENT STENCIL GRID — repeating dividers painted OVER the fill */
.eng-bar-track::after {
    content: '' !important;
    position: absolute !important;
    inset: 0 !important;
    /* 9 dividers at 10%, 20%, … 90% — each 1.5px wide dark gap */
    background: repeating-linear-gradient(
        to right,
        transparent 0%,
        transparent calc(10% - 0.75px),
        rgba(0, 0, 0, 0.80) calc(10% - 0.75px),
        rgba(0, 0, 0, 0.80) calc(10% + 0.75px),
        transparent calc(10% + 0.75px),
        transparent 20%,
        rgba(0, 0, 0, 0.80) calc(20% - 0.75px),
        rgba(0, 0, 0, 0.80) calc(20% + 0.75px),
        transparent calc(20% + 0.75px),
        transparent 30%,
        rgba(0, 0, 0, 0.80) calc(30% - 0.75px),
        rgba(0, 0, 0, 0.80) calc(30% + 0.75px),
        transparent calc(30% + 0.75px),
        transparent 40%,
        rgba(0, 0, 0, 0.80) calc(40% - 0.75px),
        rgba(0, 0, 0, 0.80) calc(40% + 0.75px),
        transparent calc(40% + 0.75px),
        transparent 50%,
        rgba(0, 0, 0, 0.80) calc(50% - 0.75px),
        rgba(0, 0, 0, 0.80) calc(50% + 0.75px),
        transparent calc(50% + 0.75px),
        transparent 60%,
        rgba(0, 0, 0, 0.80) calc(60% - 0.75px),
        rgba(0, 0, 0, 0.80) calc(60% + 0.75px),
        transparent calc(60% + 0.75px),
        transparent 70%,
        rgba(0, 0, 0, 0.80) calc(70% - 0.75px),
        rgba(0, 0, 0, 0.80) calc(70% + 0.75px),
        transparent calc(70% + 0.75px),
        transparent 80%,
        rgba(0, 0, 0, 0.80) calc(80% - 0.75px),
        rgba(0, 0, 0, 0.80) calc(80% + 0.75px),
        transparent calc(80% + 0.75px),
        transparent 90%,
        rgba(0, 0, 0, 0.80) calc(90% - 0.75px),
        rgba(0, 0, 0, 0.80) calc(90% + 0.75px),
        transparent calc(90% + 0.75px),
        transparent 100%
    ) !important;
    pointer-events: none !important;
    z-index: 2 !important;
    border-radius: 10px !important;
}

/* PILL-SHAPED FILL */
.eng-bar-fill {
    height: 100% !important;
    border-radius: 10px !important;
    transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1) !important;
    min-width: 0;
    position: relative !important;
    z-index: 1 !important;
}

/* ══════════════════════════════════════════════════════════════
   §4  SEGMENTAL LOGIC — legacy helpers (kept for JS compat)
══════════════════════════════════════════════════════════════ */
.eng-bar-fill.segmented {
    /* segment appearance now driven by ::after on track */
}
.eng-bar-fill.full {
    /* no override needed */
}

/* ══════════════════════════════════════════════════════════════
   §5  SPECTRAL GRADIENTS — per-lane, applied via data-lane attr
   Usage: <div class="eng-bar-fill" data-lane="1">
══════════════════════════════════════════════════════════════ */
.eng-bar-fill[data-lane="1"] { background: var(--lane-l1) !important; }
.eng-bar-fill[data-lane="2"] { background: var(--lane-l2) !important; }
.eng-bar-fill[data-lane="3"] { background: var(--lane-l3) !important; }
.eng-bar-fill[data-lane="4"] { background: var(--lane-l4) !important; }
.eng-bar-fill[data-lane="5"] { background: var(--lane-l5) !important; }

/* ══════════════════════════════════════════════════════════════
   §6  RICH FLYOUT — Non-Destructive Overlay
   Drops below header; z-index:500 overrides GNN canvas
══════════════════════════════════════════════════════════════ */
.eng-tube-flyout {
    display: none;
    position: absolute;
    top: calc(100% + 14px);              /* drop below the tube col */
    left: 0;
    width: 360px;
    background: rgba(8, 8, 8, 0.98);
    border: 1px solid #2a2a2a;
    border-top: 2px solid #b59140;       /* gold accent top border */
    border-radius: 10px;
    padding: 18px 20px;
    z-index: 500;
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.95), 0 0 1px rgba(181, 145, 64, 0.3);
    pointer-events: auto;
    font-family: Calibri, '微軟正黑體', sans-serif;
    font-size: 12px;
    color: #ccc;
    line-height: 1.65;
}

.eng-tube-flyout.visible {
    display: block;
    animation: flyout-open 0.22s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes flyout-open {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ══════════════════════════════════════════════════════════════
   §Z-INDEX GUARD — Flyout vs Scrollbar Rail
   When body.flyout-active is present (set by tube_engine.js),
   the active flyout is elevated above the scrollbar rail.
   The companion rule in sovereign_scrollbar.css drops .sv-pill
   to z-index: 400 to create the required gap.
══════════════════════════════════════════════════════════════ */
body.flyout-active .eng-tube-flyout.visible {
    z-index: 2147483640 !important;   /* just below MAX_INT; above .sv-pill's 400 */
}

/* Flyout content zones */
.gate-status-pill {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 4px 10px;
    border-radius: 20px;
    margin-bottom: 12px;
    display: inline-block;
    border: 1px solid #444;
    color: #aaa;
    background: rgba(255, 255, 255, 0.04);
}

/* Pill colour variants */
.gate-status-pill.blue   { border-color: #00aaff; color: #00aaff; background: rgba(0, 170, 255, 0.08); }
.gate-status-pill.orange { border-color: #ff914d; color: #ff914d; background: rgba(255, 145, 77, 0.08); }
.gate-status-pill.red    { border-color: #ff3333; color: #ff3333; background: rgba(255, 51, 51, 0.08);  }
.gate-status-pill.green  { border-color: #00C853; color: #00C853; background: rgba(0, 200, 83, 0.10); }
.gate-status-pill.gold   { border-color: #b59140; color: #b59140; background: rgba(181, 145, 64, 0.08); }

.gate-meaning {
    color: #fff;
    font-size: 13px;
    margin-bottom: 10px;
    font-weight: 600;
}

.gate-body {
    color: #aaa;
    font-size: 12px;
    line-height: 1.65;
    margin-bottom: 10px;
}

.gate-math {
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    color: #00C853;
    border-left: 2px solid #00C853;
    padding: 6px 10px;
    background: rgba(0, 200, 83, 0.06);
    border-radius: 0 6px 6px 0;
    margin-bottom: 10px;
    line-height: 1.6;
}

.gate-thinking-log {
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    color: #555;
    font-style: italic;
    margin-top: 6px;
    border-top: 1px solid #1a1a1a;
    padding-top: 6px;
}

.status-badge {
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 1px;
    padding: 3px 8px;
    border-radius: 4px;
    display: inline-block;
    margin-top: 8px;
}

/* mono-term utility (used inside flyout bodies) */
.mono-term {
    font-family: 'JetBrains Mono', monospace;
    color: #6dd;
    font-size: 11px;
}

/* ══════════════════════════════════════════════════════════════
   §7  LEGACY PURGE — Remove static eng-descs from layout flow
   .eng-descs is deleted from DOM in OP-01/03; hidden in OP-02 during transition.
══════════════════════════════════════════════════════════════ */
.eng-descs {
    display: none !important;
}

/* ══════════════════════════════════════════════════════════════
   §8  FLYOUT BACKDROP FREEZE — prevent scroll-through on open
══════════════════════════════════════════════════════════════ */
.op-stage.flyout-lock {
    pointer-events: none;
}
