/* Self-hosted fonts (Fontsource variable builds, SIL OFL 1.1, see fonts/*-OFL.txt):
   no requests to Google, so no visitor data leaves this server */
@font-face {
    font-family: 'Inter'; font-style: normal; font-weight: 100 900; font-display: swap;
    src: url(./fonts/inter-latin-ext-wght-normal.woff2) format('woff2');
    unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF;
}
@font-face {
    font-family: 'Inter'; font-style: normal; font-weight: 100 900; font-display: swap;
    src: url(./fonts/inter-latin-wght-normal.woff2) format('woff2');
    unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
}
@font-face {
    font-family: 'JetBrains Mono'; font-style: normal; font-weight: 100 800; font-display: swap;
    src: url(./fonts/jetbrains-mono-latin-ext-wght-normal.woff2) format('woff2');
    unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF;
}
@font-face {
    font-family: 'JetBrains Mono'; font-style: normal; font-weight: 100 800; font-display: swap;
    src: url(./fonts/jetbrains-mono-latin-wght-normal.woff2) format('woff2');
    unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
}

/* Approdorix design system tokens */
:root {
    --ink: #171513;
    --ink-2: #2a2724;
    --ink-3: #3d3934;
    --cream: #ece8df;
    --cream-2: #e3ddd0;
    --cream-3: #d8d3c6;
    --orange: #c44b1a;
    --orange-soft: #f5e6dc;
    --muted: #8a8a82;
    --muted-2: #a8a59a;
    --ok: #3a6b3a;
    --live-on: #3a6b3a;
    --live-off: var(--orange);

    --sans: 'Inter', system-ui, sans-serif;
    --mono: 'JetBrains Mono', ui-monospace, monospace;
}

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

html, body { margin: 0; padding: 0; background: var(--cream); color: var(--ink); }

/* Full-height layout: the console stretches to the bottom and only the log scrolls */
body { display: flex; flex-direction: column; height: 100vh; height: 100dvh; }
.topstrip { flex-shrink: 0; }

body {
    font-family: var(--sans);
    -webkit-font-smoothing: antialiased;
    font-feature-settings: "ss01" on, "cv11" on;
    line-height: 1.5;
}

button { font-family: inherit; }

/* Top strip */
.topstrip {
    height: 28px;
    border-bottom: 1px solid var(--ink);
    display: flex; align-items: center;
    font-family: var(--mono); font-size: 10px; letter-spacing: 0.12em; text-transform: uppercase;
    overflow: hidden; white-space: nowrap;
}
.topstrip .logo { display: block; flex-shrink: 0; width: 28px; height: 100%; border-right: 1px solid var(--ink); }
.topstrip .tag { background: var(--ink); color: var(--cream); padding: 0 14px; height: 100%; display: flex; align-items: center; font-weight: 700; }
.topstrip .cell { padding: 0 14px; border-right: 1px solid var(--ink); height: 100%; display: flex; align-items: center; }
.topstrip .grow { flex: 1; }
.topstrip .cell b { font-weight: 700; }
.topstrip .cell .tech { margin-left: 8px; }

@keyframes pulse { 0%, 60% { opacity: 1; } 80% { opacity: 0.2; } 100% { opacity: 1; } }

/* Connection status, state set from Rust via data-state */
.status { padding: 0 14px; color: var(--muted); font-weight: 700; }
.status::before { content: '●'; margin-right: 6px; }
/* Status colour lives only in the dot (semantic dots only, Rule 04) */
.status[data-state="open"]::before { color: var(--live-on); animation: pulse 1.6s infinite; }
.status[data-state="closed"]::before { color: var(--live-off); }

/* Masthead */
.masthead { padding: 56px 56px 24px; flex: 1; min-height: 0; display: flex; flex-direction: column; }
.masthead .eyebrow {
    display: flex; justify-content: space-between;
    font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--muted);
}
.masthead .eyebrow > :only-child { margin-left: auto; }
.triple-rule { display: flex; flex-direction: column; gap: 2px; padding: 14px 0 18px; }
.triple-rule > div { height: 1px; background: var(--ink); }
.triple-rule > div:last-child { height: 4px; }
.masthead h1 {
    font-weight: 800; font-size: clamp(40px, 7vw, 88px); letter-spacing: -0.045em; line-height: 0.92;
    margin: 0; text-wrap: pretty;
}
.masthead .console { padding-top: 8px; flex: 1; min-height: 0; display: flex; flex-direction: column; }

/* Buttons */
.btn {
    cursor: pointer; font-family: var(--mono);
    letter-spacing: 0.14em; text-transform: uppercase; font-weight: 700;
    border: 1px solid var(--ink); background: var(--ink); color: var(--cream);
    padding: 12px 18px; font-size: 11px;
    display: inline-flex; align-items: center; gap: 10px;
    transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.btn:hover { background: var(--orange); border-color: var(--orange); color: #fff; }
.btn:focus-visible { outline: 2px solid var(--orange); outline-offset: 2px; }
.btn--secondary { background: transparent; color: var(--ink); }
.btn--secondary:hover { background: var(--ink); color: var(--cream); border-color: var(--ink); }

/* Stream panel (chat log) */
.stream { background: var(--ink); color: var(--cream); border: 1px solid var(--ink); padding: 22px; flex: 1; min-height: 0; display: flex; flex-direction: column; }
.stream-body { flex: 1; min-height: 120px; overflow-y: auto; }

.stream-body:empty::before {
    content: 'No messages yet';
    font-family: var(--mono); font-size: 11px; color: var(--muted-2);
}

.row {
    font-family: var(--mono); font-size: 11.5px; padding: 7px 0;
    border-top: 1px solid var(--ink-2);
    display: grid; grid-template-columns: 70px 56px 1fr; gap: 12px; align-items: baseline;
}
.row:first-child { border-top: none; }
.row .ts { color: var(--muted-2); }
.row .ev { font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; font-size: 10px; }
.row .det { overflow-wrap: anywhere; white-space: pre-wrap; }
.row--out .ev { color: var(--orange); }
.row--in .ev { color: #9ed09e; }
.row--sys .ev, .row--sys .det { color: var(--muted-2); }

/* Markdown messages (server replies starting with "MARKDOWN") */
.row .md { white-space: normal; line-height: 1.6; }
.row .md > :first-child { margin-top: 0; }
.row .md > :last-child { margin-bottom: 0; }
.row .md p, .row .md ul, .row .md ol, .row .md pre, .row .md blockquote, .row .md table { margin: 0 0 10px; }
.row .md h1, .row .md h2, .row .md h3, .row .md h4 {
    font-family: var(--sans); font-weight: 800; letter-spacing: -0.02em; line-height: 1.15; margin: 14px 0 8px;
}
.row .md h1 { font-size: 22px; }
.row .md h2 { font-size: 18px; }
.row .md h3, .row .md h4 { font-size: 15px; }
.row .md ul, .row .md ol { padding-left: 20px; }
.row .md li { margin: 2px 0; }
.row .md li::marker { color: var(--muted-2); }
.row .md a { color: inherit; text-underline-offset: 2px; }
.row .md strong { color: inherit; }
.row .md code { background: var(--ink-2); padding: 1px 5px; font-size: 0.95em; }
.row .md pre { background: var(--ink-2); padding: 12px 14px; overflow-x: auto; border-left: 2px solid var(--ink-3); }
.row .md pre code { background: none; padding: 0; white-space: pre; }
.row .md blockquote { border-left: 2px solid var(--muted); padding-left: 12px; color: var(--muted-2); }
.row .md hr { border: none; border-top: 1px solid var(--ink-3); margin: 12px 0; }
.row .md table { border-collapse: collapse; display: block; overflow-x: auto; }
.row .md th, .row .md td { border: 1px solid var(--ink-3); padding: 5px 10px; text-align: left; }
.row .md th { font-size: 10px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted-2); }
.row .md img { max-width: 100%; }

/* Stream tabs, after the Approdorix "08 Navigation" tab bar: a flat cream-2 strip
   with ink dividers; the active tab is inverted and runs into the ink panel below. */
.stream-tabs {
    display: flex; align-items: stretch;
    background: var(--cream-2); border: 1px solid var(--ink); border-bottom: none;
    font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.12em; text-transform: uppercase;
}
.stream-tabs #ws-url {
    margin-left: auto; display: flex; align-items: center; padding: 0 16px;
    color: var(--muted); font-size: 10px; font-weight: 700; white-space: nowrap;
}
.tabs { display: flex; overflow-x: auto; }
.tab {
    font: inherit; letter-spacing: inherit; text-transform: inherit; font-weight: 700;
    padding: 12px 18px; border: none; border-right: 1px solid var(--ink);
    background: transparent; color: var(--ink); cursor: pointer; white-space: nowrap;
    display: inline-flex; align-items: center; gap: 10px;
    transition: background 0.12s, color 0.12s;
}
.tab .num { color: var(--muted); }
.tab:hover { background: var(--cream-3); }
.tab[aria-selected="true"] { background: var(--ink); color: var(--cream); }
.tab[aria-selected="true"] .num { color: var(--muted-2); }
.tab:focus-visible { outline: 2px solid var(--orange); outline-offset: -2px; }
/* Unread marker on tabs that got new rows while hidden */
.tab[data-unread]::after { content: ''; width: 6px; height: 6px; background: var(--orange); }
@media (max-width: 700px) {
    .stream-tabs #ws-url { display: none; }
    .tab { padding: 12px 14px; }
}
#log-thinking .md { color: var(--muted-2); }

/* Command field */
.field { border: 1px solid var(--ink); border-top: none; background: var(--cream); display: flex; align-items: stretch; margin: 0; }
.field-label {
    width: 110px; flex-shrink: 0; border-right: 1px solid var(--ink);
    padding: 12px; font-family: var(--mono); font-size: 10px;
    letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted);
    font-weight: 700; display: flex; align-items: center; background: var(--cream-2);
    transition: background 0.12s, color 0.12s;
}
.field-input {
    flex: 1; border: none; background: transparent; padding: 12px 14px;
    font-family: var(--mono); font-size: 13px; color: var(--ink);
    outline: none; min-width: 0;
}
.field-input::placeholder { color: var(--muted); opacity: 0.7; }
.field:focus-within .field-label { background: var(--ink); color: var(--cream); }
.field .btn { border-width: 0 0 0 1px; }

/* Command autocompletion, opens above the command field */
.field { position: relative; }
.suggest {
    position: absolute; left: -1px; right: -1px; bottom: 100%; z-index: 10;
    margin: 0; padding: 0; list-style: none;
    background: var(--cream); border: 1px solid var(--ink);
    max-height: 240px; overflow-y: auto;
}
.suggest li {
    display: flex; gap: 16px; align-items: baseline;
    padding: 10px 14px; border-top: 1px solid var(--cream-3);
    font-family: var(--mono); font-size: 12px; cursor: pointer;
}
.suggest li:first-child { border-top: none; }
.suggest .name { font-weight: 700; }
.suggest .desc { color: var(--muted); font-size: 11px; }
.suggest li:hover { background: var(--cream-2); }
.suggest li[aria-selected="true"] { background: var(--ink); color: var(--cream); }
.suggest li[aria-selected="true"] .desc { color: var(--muted-2); }

@media (max-width: 1100px) {
    .masthead { padding: 36px 24px 18px; }
}

@media (max-width: 700px) {
    .topstrip .cell .tech { display: none; }
    .field-label { width: auto; }
    .row { grid-template-columns: 60px 1fr; }
    .row .det { grid-column: 1 / -1; }
}
