/* ========================================================
   scire.dev :: github-dark-syntax monospace terminal
   ========================================================
   Palette
     bg            #0D1117
     surface       #161B22
     edge          #30363D
     edge-hover    #484F58
     text          #E6EDF3
     muted         #8B949E
     accent-blue   #58A6FF
     accent-num    #79C0FF
     accent-str    #A5D6FF
     accent-fn     #D2A8FF
     accent-key    #FF7B72
     accent-ok     #3FB950
     dot-yellow    #D29922
     warn          #F85149
   ========================================================
*/

:root {
    --bg:          #0D1117;
    --surface:     #161B22;
    --edge:        #30363D;
    --edge-hover:  #484F58;
    --text:        #E6EDF3;
    --muted:       #8B949E;
    --accent:      #58A6FF;
    --num:         #79C0FF;
    --str:         #A5D6FF;
    --fn:          #D2A8FF;
    --key:         #FF7B72;
    --ok:          #3FB950;
    --yellow:      #D29922;
    --warn:        #F85149;

    --cell-x: 9.6px;
    --cell-y: 20px;
    --pad-h: calc(var(--cell-x) * 6);
    --pad-v: calc(var(--cell-y) * 2);
    --margin-cells: calc(var(--cell-y) * 2);

    --fs: 14px;
    --lh: 1.6;
    --tab-h: 40px;

    --mono: "JetBrains Mono", "SF Mono", Menlo, Consolas, monospace;
}

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

html, body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--mono);
    font-size: var(--fs);
    line-height: var(--lh);
    font-weight: 400;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-feature-settings: "calt" 1, "liga" 1;
    overflow-x: hidden;
}

body {
    padding-top: var(--tab-h);
    min-height: 100vh;
}

::selection {
    background: rgba(88, 166, 255, 0.25);
    color: var(--text);
}

/* ===========================================================
   TAB BAR
=========================================================== */
.tab-bar {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: var(--tab-h);
    background: var(--bg);
    border-bottom: 1px solid var(--edge);
    z-index: 50;
    display: flex;
    align-items: stretch;
    overflow-x: auto;
    overflow-y: hidden;
}

.tab-bar-inner {
    display: flex;
    align-items: stretch;
    gap: 0;
    width: 100%;
    padding: 0 var(--margin-cells);
    min-width: max-content;
}

.tab-prefix {
    display: inline-flex;
    align-items: center;
    color: var(--ok);
    padding: 0 calc(var(--cell-x) * 2) 0 0;
    font-weight: 500;
    white-space: nowrap;
}

.tab {
    display: inline-flex;
    align-items: center;
    gap: calc(var(--cell-x) * 1);
    padding: 0 calc(var(--cell-x) * 1.5);
    height: 100%;
    color: var(--muted);
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: background 200ms ease, border-color 200ms ease, color 200ms ease;
    white-space: nowrap;
}

.tab .tab-dot {
    color: var(--edge);
    font-size: 10px;
    line-height: 1;
    transition: color 200ms ease;
}

.tab:hover {
    background: var(--surface);
    color: var(--text);
    border-bottom-color: var(--edge-hover);
}

.tab.active {
    color: var(--text);
    border-bottom-color: var(--accent);
    background: var(--surface);
}

.tab.active .tab-dot {
    color: var(--accent);
}

.tab-sep {
    display: inline-flex;
    align-items: center;
    color: var(--edge);
    user-select: none;
}

.tab-loading {
    display: inline-flex;
    align-items: center;
    margin-left: auto;
    padding: 0 calc(var(--cell-x) * 1);
    color: var(--yellow);
    opacity: 0;
    transition: opacity 150ms ease;
    white-space: nowrap;
}

.tab-loading.show {
    opacity: 1;
}

/* ===========================================================
   TERMINAL WINDOW
=========================================================== */
.terminal-window {
    padding: var(--margin-cells);
    display: flex;
    flex-direction: column;
    gap: var(--margin-cells);
    max-width: 1280px;
    margin: 0 auto;
}

/* ===========================================================
   PANE
=========================================================== */
.pane {
    position: relative;
    background: var(--bg);
    border: 1px solid var(--edge);
    transition: border-color 300ms ease;
    overflow: hidden;
}

.pane:hover {
    border-color: var(--edge-hover);
}

.pane-titlebar {
    display: flex;
    align-items: center;
    gap: calc(var(--cell-x) * 1);
    background: var(--surface);
    border-bottom: 1px solid var(--edge);
    padding: 0 calc(var(--cell-x) * 2);
    height: 32px;
    color: var(--muted);
    font-size: 12px;
    flex-wrap: nowrap;
    overflow: hidden;
    white-space: nowrap;
}

.dot {
    display: inline-block;
    width: 10px; height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.dot-red    { background: var(--warn);   }
.dot-yellow { background: var(--yellow); }
.dot-green  { background: var(--ok);     }

.pane-path {
    margin-left: calc(var(--cell-x) * 2);
    color: var(--muted);
    text-overflow: ellipsis;
    overflow: hidden;
}

.pane-meta {
    margin-left: auto;
    color: var(--edge-hover);
    font-size: 11px;
}

.pane-body {
    padding: var(--pad-v) var(--pad-h);
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: calc(var(--cell-x) * 4);
}

.pane-body.single {
    display: block;
}

/* ===========================================================
   FRAME-DRAW ANIMATION (clockwise)
=========================================================== */
.frame-draw {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 2;
}

.fd {
    position: absolute;
    background: var(--accent);
    opacity: 0;
}

.fd.top    { top: 0;    left: 0;   width: 0;  height: 1px; }
.fd.right  { top: 0;    right: 0;  width: 1px; height: 0; }
.fd.bottom { bottom: 0; right: 0;  width: 0;  height: 1px; }
.fd.left   { bottom: 0; left: 0;   width: 1px; height: 0; }

.pane.frame-running .fd       { opacity: 1; }
.pane.frame-running .fd.top    { animation: fd-top    200ms ease-out forwards; }
.pane.frame-running .fd.right  { animation: fd-right  200ms ease-out 200ms forwards; }
.pane.frame-running .fd.bottom { animation: fd-bottom 200ms ease-out 400ms forwards; }
.pane.frame-running .fd.left   { animation: fd-left   200ms ease-out 600ms forwards; }

@keyframes fd-top    { from { width: 0; }  to { width: 100%; } }
@keyframes fd-right  { from { height: 0; } to { height: 100%; } }
@keyframes fd-bottom { from { width: 0; }  to { width: 100%; } }
@keyframes fd-left   { from { height: 0; } to { height: 100%; } }

.pane.frame-done .fd { opacity: 0; transition: opacity 200ms 200ms ease; }

.pane .pane-body > * {
    opacity: 0;
    transform: translateX(-8px);
    transition: opacity 250ms ease, transform 250ms ease;
}

.pane.frame-done .pane-body > * {
    opacity: 1;
    transform: translateX(0);
}

.pane.frame-done .pane-body > *:nth-child(2) { transition-delay: 80ms; }
.pane.frame-done .pane-body > *:nth-child(3) { transition-delay: 160ms; }

/* hero pane skips frame-draw (immediate) */
.hero-pane .pane-body > * {
    opacity: 1;
    transform: none;
}

.hero-pane .frame-draw {
    display: none;
}

/* ===========================================================
   HERO PANE
=========================================================== */
.hero-pane {
    min-height: calc(100vh - var(--tab-h) - var(--margin-cells) * 2);
    display: flex;
    flex-direction: column;
}

.hero-pane .pane-body {
    flex: 1;
    grid-template-columns: 1.4fr 1fr;
}

.terminal-stream {
    display: flex;
    flex-direction: column;
}

.line {
    display: block;
    color: var(--text);
    white-space: pre-wrap;
    word-break: break-word;
}

.line.blank {
    height: var(--cell-y);
}

.line-prompt {
    color: var(--text);
    margin-bottom: var(--cell-y);
}

.prompt-user   { color: var(--ok); }
.prompt-at     { color: var(--muted); }
.prompt-host   { color: var(--accent); }
.prompt-colon  { color: var(--muted); }
.prompt-path   { color: var(--fn); }
.prompt-dollar { color: var(--ok); margin: 0 calc(var(--cell-x) * 1); }
.prompt-dollar.inline { margin: 0 calc(var(--cell-x) * 1) 0 0; }
.prompt-typed  { color: var(--text); }
.prompt-cmd    { color: var(--text); }

.cursor {
    display: inline-block;
    width: var(--cell-x);
    height: calc(var(--cell-y) * 0.85);
    background: var(--accent);
    vertical-align: middle;
    transform: translateY(-1px);
    margin-left: 1px;
    animation: blink 530ms step-end infinite;
}

@keyframes blink {
    0%, 100%   { opacity: 1; }
    50%        { opacity: 0; }
}

.boot-output {
    display: flex;
    flex-direction: column;
}

.line.out {
    opacity: 0;
    transform: translateX(-8px);
    transition: opacity 200ms ease, transform 200ms ease;
}

.boot-output.run .line.out,
.line.out.shown {
    opacity: 1;
    transform: translateX(0);
}

.prompt-row {
    margin-top: var(--cell-y);
    opacity: 0;
    transform: translateX(-8px);
    transition: opacity 200ms ease, transform 200ms ease;
}

.boot-output.run + .ascii-block + .prompt-row,
.prompt-row.shown {
    opacity: 1;
    transform: translateX(0);
}

.ascii-block {
    color: var(--accent);
    font-family: var(--mono);
    font-size: var(--fs);
    line-height: 1.2;
    margin: var(--cell-y) 0;
    white-space: pre;
    overflow-x: auto;
    opacity: 0;
    transform: translateX(-8px);
    transition: opacity 250ms ease, transform 250ms ease;
}

.ascii-block.shown {
    opacity: 1;
    transform: translateX(0);
}

.ascii-block.small {
    color: var(--muted);
    line-height: 1.3;
    margin: calc(var(--cell-y) * 1.2) 0;
}

.ascii-block.tree-block {
    color: var(--text);
    line-height: 1.6;
}

.tree-key {
    color: var(--accent);
    font-weight: 500;
}

/* ===========================================================
   HERO SIDE
=========================================================== */
.hero-side {
    display: flex;
    flex-direction: column;
    gap: var(--cell-y);
}

.side-frame {
    border: 1px solid var(--edge);
    background: var(--surface);
}

.side-frame-head {
    background: var(--bg);
    border-bottom: 1px solid var(--edge);
    color: var(--muted);
    padding: 6px calc(var(--cell-x) * 1.5);
    font-size: 12px;
    letter-spacing: 0.02em;
}

/* ===========================================================
   CODE BLOCKS
=========================================================== */
.code-block {
    font-family: var(--mono);
    font-size: var(--fs);
    line-height: var(--lh);
    color: var(--text);
    padding: calc(var(--cell-y) * 1) calc(var(--cell-x) * 2);
    white-space: pre;
    overflow-x: auto;
    counter-reset: ln;
    transition: background 200ms ease;
    cursor: copy;
}

.code-block:hover {
    background: rgba(88, 166, 255, 0.04);
}

.code-block.copy-flash {
    background: rgba(63, 185, 80, 0.10);
    transition: background 200ms ease;
}

.code-block.tall {
    min-height: calc(var(--cell-y) * 18);
}

.cb-comm   { color: var(--muted); font-style: italic; }
.cb-key    { color: var(--key); }
.cb-str    { color: var(--str); }
.cb-num    { color: var(--num); }
.cb-fn     { color: var(--fn); }
.cb-flag   { color: var(--key); }
.cb-prompt { color: var(--ok); }
.cb-ok     { color: var(--ok); }
.cb-warn   { color: var(--yellow); }
.cb-add    { color: var(--ok); }
.cb-rem    { color: var(--key); }

/* inline highlights inside terminal stream / prose */
.hl-comm { color: var(--muted); font-style: italic; }
.hl-key  { color: var(--key); }
.hl-str  { color: var(--str); }
.hl-num  { color: var(--num); }
.hl-fn   { color: var(--fn); }
.hl-flag { color: var(--key); }
.hl-ok   { color: var(--ok); }

/* ===========================================================
   PROGRESS BARS
=========================================================== */
.bar-stack {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: calc(var(--cell-y) * 0.8) calc(var(--cell-x) * 2);
}

.bar-stack.tight {
    padding: calc(var(--cell-y) * 0.6) 0;
}

.bar-row {
    display: grid;
    grid-template-columns: calc(var(--cell-x) * 6) 1fr calc(var(--cell-x) * 6);
    gap: calc(var(--cell-x) * 1);
    align-items: center;
    color: var(--muted);
    font-size: var(--fs);
}

.bar-label {
    color: var(--muted);
    text-transform: lowercase;
}

.bar-track {
    display: inline-block;
    height: 10px;
    background: var(--edge);
    position: relative;
    overflow: hidden;
}

.bar-fill {
    display: block;
    height: 100%;
    width: 0;
    background: var(--ok);
    transition: width 600ms cubic-bezier(.2,.8,.2,1);
}

.bar-num {
    color: var(--num);
    text-align: right;
    font-size: 12px;
}

.side-foot {
    padding: 6px calc(var(--cell-x) * 2);
    border-top: 1px solid var(--edge);
    color: var(--muted);
    font-size: 12px;
}

/* ===========================================================
   PROSE / HEADINGS
=========================================================== */
.md-heading {
    font-size: var(--fs);
    font-weight: 700;
    color: var(--text);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: var(--cell-y);
}

.md-hash {
    color: var(--edge);
    font-weight: 700;
    margin-right: calc(var(--cell-x) * 1);
}

.prose {
    color: var(--text);
    margin-bottom: var(--cell-y);
    max-width: 70ch;
}

.prose.tight {
    margin-top: calc(var(--cell-y) * 0.6);
    color: var(--muted);
    font-size: 13px;
}

.prose-col {
    display: flex;
    flex-direction: column;
}

/* ===========================================================
   DIFF LIST
=========================================================== */
.diff-list {
    list-style: none;
    margin: var(--cell-y) 0 0 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.diff-list li {
    padding: 2px calc(var(--cell-x) * 1);
    color: var(--text);
}

.diff-mark {
    display: inline-block;
    width: calc(var(--cell-x) * 2);
    font-weight: 700;
}

.diff-add {
    background: rgba(63, 185, 80, 0.06);
}

.diff-add .diff-mark {
    color: var(--ok);
}

.diff-rem {
    background: rgba(248, 81, 73, 0.06);
    color: var(--muted);
    text-decoration: line-through;
    text-decoration-color: rgba(255, 123, 114, 0.4);
}

.diff-rem .diff-mark {
    color: var(--key);
    text-decoration: none;
}

/* ===========================================================
   STEP LIST
=========================================================== */
.step-list {
    list-style: none;
    margin: var(--cell-y) 0 0 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: calc(var(--cell-y) * 0.5);
    counter-reset: stepc;
}

.step-list li {
    display: grid;
    grid-template-columns: calc(var(--cell-x) * 5) calc(var(--cell-x) * 11) 1fr;
    gap: calc(var(--cell-x) * 1);
    color: var(--text);
    align-items: baseline;
}

.step-no {
    color: var(--num);
    font-weight: 500;
}

.step-name {
    font-weight: 500;
}

.step-desc {
    color: var(--muted);
}

/* ===========================================================
   ARCH SPLIT
=========================================================== */
.split-grid {
    display: grid;
    grid-template-columns: 1.2fr 1fr;
    gap: calc(var(--cell-x) * 4);
    margin-top: var(--cell-y);
}

.arch-side {
    display: flex;
    flex-direction: column;
    gap: calc(var(--cell-y) * 0.6);
    border-left: 1px solid var(--edge);
    padding-left: calc(var(--cell-x) * 3);
}

.kv-row {
    display: flex;
    align-items: baseline;
    color: var(--muted);
    font-size: 13px;
    gap: calc(var(--cell-x) * 0.5);
}

.kv-key {
    color: var(--text);
}

.kv-dot {
    flex: 1;
    color: var(--edge);
    overflow: hidden;
    white-space: nowrap;
    text-align: left;
}

.kv-val {
    color: var(--num);
    text-align: right;
    min-width: calc(var(--cell-x) * 4);
}

/* ===========================================================
   PROCESS LOG
=========================================================== */
.log-block {
    background: rgba(22, 27, 34, 0.5);
    line-height: 1.7;
}

.log-time {
    color: var(--muted);
    margin-right: calc(var(--cell-x) * 1);
}

.log-cursor {
    display: inline-block;
    width: var(--cell-x);
    height: calc(var(--cell-y) * 0.8);
    background: var(--accent);
    vertical-align: middle;
    animation: blink 530ms step-end infinite;
}

/* ===========================================================
   DIFF / MANIFEST
=========================================================== */
.diff-block {
    background: var(--surface);
    border: 1px solid var(--edge);
    line-height: 1.8;
}

/* ===========================================================
   CTA / LINKS
=========================================================== */
.cta-row {
    display: flex;
    flex-wrap: wrap;
    gap: calc(var(--cell-x) * 4);
    margin-top: calc(var(--cell-y) * 1.5);
}

.cli-link {
    color: var(--accent);
    text-decoration: none;
    transition: color 200ms ease;
    border-bottom: 1px dashed transparent;
    padding-bottom: 2px;
}

.cli-link:hover {
    color: var(--text);
    border-bottom: 1px dashed var(--accent);
}

.cli-prompt {
    color: var(--ok);
    margin-right: calc(var(--cell-x) * 1);
}

a {
    color: var(--accent);
    text-decoration: none;
    transition: color 200ms ease;
}

a:hover {
    color: var(--text);
    text-decoration: underline dashed;
    text-underline-offset: 3px;
}

/* ===========================================================
   PANE FOOT
=========================================================== */
.pane-foot {
    margin-top: calc(var(--cell-y) * 1.5);
    padding-top: calc(var(--cell-y) * 0.6);
    border-top: 1px dashed var(--edge);
    color: var(--muted);
    font-size: 12px;
    display: flex;
    flex-wrap: wrap;
    gap: calc(var(--cell-x) * 0.5);
    align-items: center;
}

.foot-sep {
    color: var(--edge);
    margin: 0 calc(var(--cell-x) * 0.5);
}

/* ===========================================================
   SCROLL PROGRESS
=========================================================== */
.scroll-progress {
    position: fixed;
    bottom: 0; left: 0;
    height: 2px;
    width: 0%;
    background: var(--accent);
    z-index: 100;
    transition: width 80ms linear;
}

/* ===========================================================
   COPY TOAST
=========================================================== */
.copy-toast {
    position: fixed;
    bottom: calc(var(--cell-y) * 2);
    left: 50%;
    transform: translateX(-50%) translateY(8px);
    background: var(--surface);
    border: 1px solid var(--ok);
    color: var(--ok);
    padding: 6px calc(var(--cell-x) * 2);
    font-size: 12px;
    z-index: 200;
    opacity: 0;
    pointer-events: none;
    transition: opacity 200ms ease, transform 200ms ease;
}

.copy-toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ===========================================================
   TRANSITIONS BETWEEN TABBED VIEWS
=========================================================== */
.pane.is-leaving .pane-body > * {
    opacity: 0;
    transform: translateY(-20px);
    transition: opacity 300ms ease, transform 300ms ease;
}

/* ===========================================================
   RESPONSIVE
=========================================================== */
@media (max-width: 900px) {
    :root {
        --pad-h: calc(var(--cell-x) * 3);
        --pad-v: calc(var(--cell-y) * 1.5);
    }

    .pane-body,
    .hero-pane .pane-body,
    .split-grid {
        grid-template-columns: 1fr;
    }

    .arch-side {
        border-left: none;
        border-top: 1px solid var(--edge);
        padding-left: 0;
        padding-top: var(--cell-y);
    }

    .tab-prefix {
        display: none;
    }

    .tab-loading {
        display: none;
    }

    .pane-meta {
        display: none;
    }

    .step-list li {
        grid-template-columns: calc(var(--cell-x) * 5) calc(var(--cell-x) * 9) 1fr;
    }
}

@media (max-width: 560px) {
    .terminal-window {
        padding: var(--cell-y);
    }

    .ascii-block,
    .code-block {
        font-size: 12px;
    }

    .step-list li {
        grid-template-columns: 1fr;
    }
}
