/* bio_kernel_emu — Demo UI · industrial dark theme */

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

:root {
    --inert-color:  #c0392b;
    --active-color: #27ae60;
    --bg:           #0d1117;
    --surface:      #161b22;
    --surface2:     #21262d;
    --border:       #30363d;
    --text:         #c9d1d9;
    --text-dim:     #6e7681;
    --mono:         'Courier New', Courier, monospace;
    --transition:   0.35s ease;
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--mono);
    height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    user-select: none;
}

/* ── Header ── */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
    flex-shrink: 0;
}
.header h1   { font-size: 13px; font-weight: 600; letter-spacing: .05em; }
.subtitle    { font-size: 10px; color: var(--text-dim); margin-top: 2px; }
.proof-link  {
    font-size: 10px; font-weight: 700; letter-spacing: .07em;
    padding: 4px 10px; border: 1px solid var(--active-color);
    border-radius: 3px; color: var(--active-color); text-decoration: none;
    transition: var(--transition); white-space: nowrap;
}
.proof-link:hover { background: rgba(39,174,96,.1); }

/* ── State Badge ── */
.state-badge {
    display: flex; align-items: center; gap: 7px;
    padding: 5px 14px; border-radius: 20px; border: 1px solid;
    font-size: 11px; font-weight: 700; letter-spacing: .1em;
    transition: var(--transition);
}
.state-badge.inert  { border-color: var(--inert-color);  color: var(--inert-color);  box-shadow: 0 0 10px rgba(192,57,43,.25); }
.state-badge.active { border-color: var(--active-color); color: var(--active-color); box-shadow: 0 0 10px rgba(39,174,96,.3); }
.state-dot { width: 7px; height: 7px; border-radius: 50%; transition: var(--transition); }
.state-badge.inert  .state-dot { background: var(--inert-color); }
.state-badge.active .state-dot { background: var(--active-color); animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.35} }

/* ── Main Grid ── */
.main {
    flex: 1;
    min-height: 0;
    display: grid;
    grid-template-columns: 1fr 1fr 300px;
    grid-template-rows: 1fr auto;
    gap: 1px;
    background: var(--border);
}

/* ── Panel ── */
.panel {
    background: var(--surface);
    display: flex; flex-direction: column;
    min-height: 0; overflow: hidden;
}
.panel-header {
    padding: 9px 14px; font-size: 11px; font-weight: 600;
    letter-spacing: .07em; color: var(--text-dim);
    border-bottom: 1px solid var(--border);
    text-transform: uppercase;
    display: flex; align-items: center; justify-content: space-between;
    flex-shrink: 0;
}
.panel-body { flex: 1; position: relative; overflow: hidden; min-height: 0; }

/* ── op_class tag ── */
.op-tag {
    font-size: 9px; letter-spacing: .06em; font-weight: 700;
    padding: 1px 5px; border-radius: 3px;
    background: var(--surface2); color: var(--text-dim);
    border: 1px solid var(--border); margin-left: 6px;
    vertical-align: middle;
}

/* ── Resource status ── */
.res-status {
    font-size: 10px; font-weight: 700; letter-spacing: .07em;
    padding: 2px 8px; border-radius: 3px; border: 1px solid;
    transition: var(--transition);
}
.res-status.denied  { border-color: var(--inert-color);  color: var(--inert-color); }
.res-status.granted { border-color: var(--active-color); color: var(--active-color); }

/* ── Camera ── */
#camera-canvas { width: 100%; height: 100%; display: block; cursor: pointer; }

/* ── Resource overlay ── */
.resource-overlay {
    position: absolute; inset: 0;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center; gap: 6px;
    pointer-events: none;
    transition: opacity var(--transition);
    background: rgba(0,0,0,.55);
}
.resource-overlay.hidden { opacity: 0; pointer-events: none; }
.overlay-code { font-size: 22px; font-weight: 700; color: var(--inert-color); letter-spacing: .05em; }
.overlay-msg  { font-size: 11px; color: var(--text-dim); }
.overlay-hint { font-size: 10px; color: #555; text-align: center; line-height: 1.6; margin-top: 2px; }

/* ── Activate button (inside overlay) ── */
.activate-btn {
    pointer-events: all;
    margin-top: 10px;
    padding: 9px 22px;
    border: 2px solid var(--inert-color);
    border-radius: 5px;
    background: transparent;
    color: var(--inert-color);
    font-family: var(--mono);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .08em;
    cursor: pointer;
    animation: activate-pulse 2s ease-in-out infinite;
    transition: background .15s;
}
.activate-btn:hover  { background: rgba(192,57,43,.15); }
.activate-btn:active { background: rgba(192,57,43,.3); }
.activate-btn-net { border-color: #e67e22; color: #e67e22; animation: activate-pulse-net 2s ease-in-out infinite; }
.activate-btn-net:hover  { background: rgba(230,126,34,.15); }
@keyframes activate-pulse     { 0%,100%{box-shadow:0 0 0 0 rgba(192,57,43,.5)} 50%{box-shadow:0 0 0 7px rgba(192,57,43,0)} }
@keyframes activate-pulse-net { 0%,100%{box-shadow:0 0 0 0 rgba(230,126,34,.5)} 50%{box-shadow:0 0 0 7px rgba(230,126,34,0)} }

/* ── Reset button ── */
.reset-btn {
    padding: 10px 28px;
    border: 2px solid var(--inert-color);
    border-radius: 6px;
    background: transparent;
    color: var(--inert-color);
    font-family: var(--mono);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .08em;
    cursor: pointer;
    opacity: 0.25;
    transition: opacity .35s, box-shadow .35s, background .15s;
    pointer-events: none;
}
.reset-btn.live {
    opacity: 1;
    pointer-events: all;
    box-shadow: 0 0 12px rgba(192,57,43,.3);
}
.reset-btn.live:hover  { background: rgba(192,57,43,.1); }
.reset-btn.live:active { background: rgba(192,57,43,.25); }

/* ── Browser ── */
.browser-chrome {
    background: var(--surface2); border-bottom: 1px solid var(--border);
    padding: 7px 10px; display: flex; align-items: center; gap: 8px; flex-shrink: 0;
}
.browser-dots   { display: flex; gap: 4px; }
.browser-dot    { width: 7px; height: 7px; border-radius: 50%; background: var(--border); }
.browser-url {
    flex: 1; background: var(--bg); border: 1px solid var(--border);
    border-radius: 3px; padding: 3px 7px; font-size: 10px; color: var(--text-dim);
    transition: var(--transition); white-space: nowrap; overflow: hidden;
}
.browser-content { flex: 1; position: relative; overflow: hidden; }
.browser-page {
    position: absolute; inset: 0; padding: 18px;
    opacity: 0; transition: opacity .5s ease .15s; overflow: auto;
}
.browser-page.visible { opacity: 1; }
.page-title { font-size: 17px; font-weight: 700; color: var(--active-color); margin-bottom: 6px; }
.page-sub   { font-size: 10px; color: var(--text-dim); margin-bottom: 14px; }
.page-line  { height: 7px; background: var(--surface2); border-radius: 3px; margin-bottom: 7px; }
.page-line.w80{width:80%} .page-line.w60{width:60%} .page-line.w90{width:90%}

/* ── Audit Log ── */
.audit-log {
    height: 100%; overflow-y: auto; padding: 7px; display: flex;
    flex-direction: column; gap: 3px;
}
.audit-log::-webkit-scrollbar       { width: 3px; }
.audit-log::-webkit-scrollbar-track { background: transparent; }
.audit-log::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
.audit-event {
    padding: 4px 7px; border-radius: 3px; font-size: 10px; line-height: 1.45;
    border-left: 2px solid; background: var(--surface2);
    animation: slide-in .15s ease;
}
@keyframes slide-in { from{opacity:0;transform:translateX(-3px)} to{opacity:1;transform:none} }
.audit-event.denied    { border-color: var(--inert-color);  color: #e88; }
.audit-event.active    { border-color: var(--active-color); color: #8d8; }
.audit-event.expired   { border-color: #e67e22; color: #fa8; }
.audit-event.apoptosis { border-color: #9b59b6; color: #c8a; }
.audit-event.sat       { border-color: var(--active-color); color: var(--text-dim); }
.audit-event.system    { border-color: var(--border); color: var(--text-dim); }
.audit-time { color: var(--text-dim); font-size: 9px; margin-bottom: 1px; }

/* ── Trigger bar (footer) ── */
.trigger-bar {
    grid-column: 1 / -1;
    background: var(--surface); border-top: 1px solid var(--border);
    padding: 12px 20px; display: flex; align-items: center;
    justify-content: space-between; gap: 16px; flex-shrink: 0;
}
.trigger-btn {
    padding: 12px 36px; border: 2px solid var(--inert-color);
    border-radius: 6px; background: transparent; color: var(--inert-color);
    font-family: var(--mono); font-size: 12px; font-weight: 700;
    letter-spacing: .08em; cursor: pointer; transition: var(--transition);
    position: relative; overflow: hidden;
}
.trigger-btn::before {
    content: ''; position: absolute; inset: 0;
    background: currentColor; opacity: 0; transition: opacity .15s;
}
.trigger-btn:hover::before  { opacity: .07; }
.trigger-btn:active::before { opacity: .15; }
.trigger-btn.active {
    border-color: var(--active-color); color: var(--active-color);
    box-shadow: 0 0 18px rgba(39,174,96,.2);
}
.trigger-hint { font-size: 10px; color: var(--text-dim); line-height: 1.55; }

/* ── Causal chain ── */
.chain-viz { display: flex; align-items: center; gap: 5px; font-size: 10px; color: var(--text-dim); }
.chain-node {
    padding: 3px 7px; border: 1px solid var(--border); border-radius: 3px;
    transition: var(--transition); white-space: nowrap; cursor: pointer;
}
.chain-node:hover { border-color: var(--text-dim); }
.chain-arrow { color: var(--border); font-size: 11px; transition: var(--transition); }
.chain-active .chain-node { border-color: var(--active-color); color: var(--active-color); }
.chain-active .chain-arrow { color: var(--active-color); }

/* ── Info button ── */
.info-btn {
    width: 18px; height: 18px; border-radius: 50%;
    border: 1px solid var(--border); background: transparent;
    color: var(--text-dim); font-size: 10px; cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center;
    transition: var(--transition); flex-shrink: 0; font-family: var(--mono);
}
.info-btn:hover { border-color: var(--active-color); color: var(--active-color); }
.info-btn-lg { width: 28px; height: 28px; font-size: 14px; }

/* ── Modal ── */
.modal-overlay {
    display: none; position: fixed; inset: 0;
    background: rgba(0,0,0,.72); z-index: 1000;
    align-items: center; justify-content: center; padding: 24px;
}
.modal-overlay.open { display: flex; }
.modal-box {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 8px; max-width: 640px; width: 100%;
    max-height: 80vh; display: flex; flex-direction: column;
    box-shadow: 0 24px 48px rgba(0,0,0,.6);
    animation: modal-in .2s ease;
}
@keyframes modal-in { from{opacity:0;transform:translateY(-10px)} to{opacity:1;transform:none} }
.modal-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 20px; border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.modal-title { font-size: 13px; font-weight: 700; color: var(--active-color); letter-spacing: .05em; }
.modal-close {
    background: transparent; border: 1px solid var(--border); color: var(--text-dim);
    width: 26px; height: 26px; border-radius: 4px; cursor: pointer;
    font-size: 12px; transition: var(--transition); font-family: var(--mono);
}
.modal-close:hover { border-color: var(--inert-color); color: var(--inert-color); }
.modal-body {
    padding: 20px; overflow-y: auto; font-size: 12px; line-height: 1.75;
    color: var(--text);
}
.modal-body h3       { color: var(--active-color); font-size: 11px; letter-spacing: .08em; margin: 14px 0 6px; text-transform: uppercase; }
.modal-body code     { background: var(--surface2); border: 1px solid var(--border); padding: 1px 5px; border-radius: 3px; font-size: 11px; color: #79c0ff; }
.modal-body pre      { background: var(--surface2); border: 1px solid var(--border); border-radius: 4px; padding: 10px 12px; font-size: 10px; overflow-x: auto; margin: 8px 0; line-height: 1.6; }
.modal-body .tag-inert  { color: var(--inert-color); font-weight: 700; }
.modal-body .tag-active { color: var(--active-color); font-weight: 700; }
.modal-body p        { margin-bottom: 10px; }
.modal-body ul       { padding-left: 16px; margin-bottom: 10px; }
.modal-body li       { margin-bottom: 4px; }

/* ── Panel clickable cursor ── */
#camera-panel .panel-body,
#browser-panel .panel-body { cursor: pointer; }
#camera-panel .panel-body:hover .resource-overlay .overlay-hint,
#browser-panel .panel-body:hover .resource-overlay .overlay-hint { color: #666; }
