/* ==========================================================================
   Tramontane — components
   Requires tokens/tokens.css. Class prefix: .tm-
   ========================================================================== */

/* ---- Base ---------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--tm-bg);
  color: var(--tm-text);
  font: 400 var(--tm-body)/var(--tm-body-lh) var(--tm-font-sans);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
:focus-visible { outline: 2px solid var(--tm-accent); outline-offset: 2px; }
code, kbd, pre, samp { font-family: var(--tm-font-mono); }
::selection { background: var(--tm-accent); color: var(--tm-on-accent); }

.tm-container { max-width: var(--tm-container); margin-inline: auto; padding-inline: var(--tm-gutter); }
.tm-section { padding-block: var(--tm-section-y); }
.tm-section + .tm-section, .tm-rule-top { border-top: 1px solid var(--tm-line); }
.tm-section--surface { background: var(--tm-surface); border-block: 1px solid var(--tm-line); }

/* ---- Type ---------------------------------------------------------------- */
.tm-display-xl, .tm-display-l, .tm-h2 {
  margin: 0; font-family: var(--tm-font-mono); font-weight: 500; text-wrap: balance;
}
.tm-display-xl { font-size: var(--tm-display-xl); line-height: var(--tm-display-xl-lh); letter-spacing: var(--tm-display-xl-ls); }
.tm-display-l  { font-size: var(--tm-display-l);  line-height: var(--tm-display-l-lh);  letter-spacing: var(--tm-display-l-ls); }
.tm-h2         { font-size: var(--tm-h2);         line-height: var(--tm-h2-lh);         letter-spacing: var(--tm-h2-ls); }
.tm-h3 { margin: 0; font: 600 var(--tm-h3)/var(--tm-h3-lh) var(--tm-font-sans); letter-spacing: var(--tm-h3-ls); }
.tm-h4 { margin: 0; font: 600 var(--tm-h4)/var(--tm-h4-lh) var(--tm-font-sans); }
.tm-lede { margin: 0; font-size: var(--tm-body-l); line-height: var(--tm-body-l-lh); color: var(--tm-text-muted); max-width: 34em; text-wrap: pretty; }
.tm-body { margin: 0; color: var(--tm-text-muted); line-height: var(--tm-body-lh); }
.tm-ui { font: 400 var(--tm-ui)/1.4 var(--tm-font-mono); }
.tm-caption { font: 400 var(--tm-caption)/1.4 var(--tm-font-mono); color: var(--tm-text-subtle); }
.tm-eyebrow { font: 400 var(--tm-caption)/1.4 var(--tm-font-mono); color: var(--tm-accent-text); }
.tm-accent-text { color: var(--tm-accent-text); }
.tm-muted { color: var(--tm-text-muted); }
.tm-subtle { color: var(--tm-text-subtle); }

/* ---- Mark / lockup ------------------------------------------------------- */
.tm-lockup { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; color: var(--tm-text); }
.tm-lockup__word { font: 700 15px/1 var(--tm-font-mono); letter-spacing: -0.01em; }
.tm-mark { display: block; flex: none; }
.tm-mark .tm-mark__t { stroke: currentColor; }
.tm-mark .tm-mark__wind { stroke: var(--tm-accent); }

/* ---- Buttons ------------------------------------------------------------- */
.tm-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 18px;
  font: 500 var(--tm-ui)/1 var(--tm-font-mono);
  text-decoration: none; white-space: nowrap; cursor: pointer;
  border: 1px solid var(--tm-line); border-radius: var(--tm-radius);
  background: transparent; color: var(--tm-text);
  transition: background var(--tm-dur-fast) var(--tm-ease), border-color var(--tm-dur-fast) var(--tm-ease), color var(--tm-dur-fast) var(--tm-ease);
}
.tm-btn:hover { border-color: var(--tm-line-strong); background: var(--tm-raised); }
.tm-btn--primary { background: var(--tm-text); color: var(--tm-bg); border-color: var(--tm-text); font-weight: 700; }
.tm-btn--primary:hover { background: var(--tm-text-muted); border-color: var(--tm-text-muted); }
.tm-btn--accent { background: var(--tm-accent); color: var(--tm-on-accent); border-color: var(--tm-accent); font-weight: 700; }
.tm-btn--accent:hover { filter: brightness(1.08); background: var(--tm-accent); }
.tm-btn--quiet { border-color: transparent; color: var(--tm-text-muted); }
.tm-btn--quiet:hover { color: var(--tm-text); background: transparent; border-color: transparent; }
.tm-btn--sm { min-height: 32px; padding: 0 10px; font-size: var(--tm-caption); }
.tm-btn--lg { min-height: 50px; padding: 0 22px; font-size: 14px; }
.tm-btn[disabled] { opacity: 0.5; cursor: not-allowed; }
.tm-icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; padding: 0; border: 0; background: none; color: var(--tm-text-subtle); cursor: pointer; }
.tm-icon-btn:hover { color: var(--tm-text); }

/* ---- Command input (the `>` prompt) ------------------------------------- */
.tm-command {
  display: flex; align-items: center; gap: 10px;
  min-height: 44px; padding: 0 14px;
  border: 1px solid var(--tm-line); background: var(--tm-surface);
  font: 400 var(--tm-ui)/1 var(--tm-font-mono);
}
.tm-command::before { content: ">"; color: var(--tm-text-subtle); }
.tm-command:focus-within { border-color: var(--tm-line-strong); }
.tm-command input { flex: 1; min-width: 0; border: 0; outline: none; background: none; color: var(--tm-text); font: inherit; }
.tm-command input::placeholder { color: var(--tm-text-subtle); }
.tm-kbd { font: 400 var(--tm-caption)/1 var(--tm-font-mono); color: var(--tm-text-subtle); }

/* ---- Field --------------------------------------------------------------- */
.tm-field { display: flex; flex-direction: column; gap: 6px; }
.tm-field label { font: 400 var(--tm-caption)/1.4 var(--tm-font-mono); color: var(--tm-text-subtle); }
.tm-input {
  min-height: 44px; padding: 0 12px; border: 1px solid var(--tm-line); border-radius: 0;
  background: var(--tm-surface); color: var(--tm-text); font: 400 var(--tm-body-s)/1 var(--tm-font-sans);
}
.tm-input:focus { outline: none; border-color: var(--tm-accent); }

/* ---- Status dot, tag, pill ---------------------------------------------- */
.tm-dot { display: inline-block; flex: none; width: 7px; height: 7px; border-radius: var(--tm-radius-dot); background: var(--tm-text-subtle); }
.tm-dot--ok   { background: var(--tm-success); }
.tm-dot--warn { background: var(--tm-warning); }
.tm-dot--err  { background: var(--tm-danger); }
.tm-dot--live { background: var(--tm-success); box-shadow: 0 0 0 3px var(--tm-success-line); }
.tm-tag { display: inline-flex; align-items: center; padding: 0 6px; border: 1px solid var(--tm-line); font: 400 var(--tm-micro)/18px var(--tm-font-mono); color: var(--tm-text-subtle); white-space: nowrap; }
.tm-pill { display: inline-flex; align-items: center; gap: 10px; padding: 7px 12px; border: 1px solid var(--tm-line); font: 400 var(--tm-caption)/1 var(--tm-font-mono); color: var(--tm-text-muted); }
.tm-status { display: inline-flex; align-items: center; gap: 8px; }

/* ---- Dividers ------------------------------------------------------------ */
.tm-divider { display: flex; align-items: center; gap: 12px; padding: 10px 0; font: 400 var(--tm-micro)/1 var(--tm-font-mono); color: var(--tm-text-subtle); }
.tm-divider::before, .tm-divider::after { content: ""; flex: 1; height: 1px; background: var(--tm-line); }
.tm-divider--live { color: var(--tm-success); }
.tm-divider--live::before, .tm-divider--live::after { background: var(--tm-success-line); }
.tm-divider--plain::before, .tm-divider--plain::after { background: transparent; }

/* ---- Streamlines (the brand motif) -------------------------------------- */
/* <div class="tm-streamlines" aria-hidden="true">
     <i style="--x:0%;--w:58%"></i> … <i class="is-accent" style="--x:22%;--w:86%"></i> …
   </div> */
.tm-streamlines { display: flex; flex-direction: column; gap: 11px; padding-block: 24px; overflow: hidden; }
.tm-streamlines > i { display: block; flex: none; height: 1px; width: var(--w, 60%); margin-left: var(--x, 0%); background: var(--tm-line-strong); }
.tm-streamlines > i.is-accent { background: var(--tm-accent); }
.tm-streamlines--mirror > i { margin-left: auto; margin-right: var(--x, 0%); }
.tm-streamlines--tight { gap: 6px; padding-block: 0; }
.tm-streamlines--drift > i { animation: tm-drift var(--tm-dur-drift) var(--tm-ease) infinite alternate; }
.tm-streamlines--drift > i:nth-child(2n) { animation-duration: calc(var(--tm-dur-drift) * 1.3); }
.tm-streamlines--drift > i:nth-child(3n) { animation-duration: calc(var(--tm-dur-drift) * 0.8); }
@keyframes tm-drift { from { transform: translateX(-2%); } to { transform: translateX(3%); } }
@media (prefers-reduced-motion: reduce) { .tm-streamlines--drift > i { animation: none; } }

/* ---- Panels, windows ----------------------------------------------------- */
.tm-panel { border: 1px solid var(--tm-line); background: var(--tm-surface); }
.tm-panel--outline { background: transparent; }
.tm-panel__head { display: flex; align-items: center; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--tm-line); }
.tm-panel__head > :last-child:not(:first-child) { margin-left: auto; }
.tm-panel__body { padding: 20px; }

.tm-window { border: 1px solid var(--tm-line); background: var(--tm-surface); box-shadow: var(--tm-shadow-window); font: 400 var(--tm-ui)/1.5 var(--tm-font-mono); }
.tm-window__bar { display: flex; align-items: center; gap: 14px; padding: 12px 14px; border-bottom: 1px solid var(--tm-line); color: var(--tm-text-muted); }
.tm-window__lights { display: flex; gap: 7px; }
.tm-window__lights i { width: 11px; height: 11px; border-radius: var(--tm-radius-dot); background: var(--tm-raised-strong); }
.tm-window__body { padding: 18px 20px; display: flex; flex-direction: column; gap: 9px; }
.tm-log-time { color: var(--tm-text-subtle); margin-right: 1.5ch; }
.tm-log-ok { color: var(--tm-success); }
.tm-log-err { color: var(--tm-danger); }

/* ---- Feature grid (hairline grid) --------------------------------------- */
/* Fill every row: with 3 columns, one .span-2 lead + 4 items = two full rows. */
.tm-grid-lines { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1px; background: var(--tm-line); border: 1px solid var(--tm-line); }
.tm-grid-lines > * { background: var(--tm-bg); padding: 32px; display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.tm-grid-lines > .span-2 { grid-column: span 2; }
@media (max-width: 960px) { .tm-grid-lines { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 640px) { .tm-grid-lines { grid-template-columns: minmax(0, 1fr); } .tm-grid-lines > .span-2 { grid-column: auto; } .tm-grid-lines > * { padding: 24px; } }

/* ---- Code ---------------------------------------------------------------- */
.tm-code { margin: 0; padding: 16px 18px; border: 1px solid var(--tm-line); background: var(--tm-surface); font: 400 var(--tm-ui)/1.7 var(--tm-font-mono); overflow-x: auto; color: var(--tm-text); }
.tm-code .k { color: var(--tm-text-subtle); }
.tm-code .s { color: var(--tm-success); }
.tm-code .d { color: var(--tm-accent-text); }
.tm-code .c { color: var(--tm-text-subtle); }
.tm-inline-code { font: 400 0.9em var(--tm-font-mono); color: var(--tm-text); }

/* ---- Table --------------------------------------------------------------- */
.tm-table-wrap { overflow-x: auto; }
.tm-table { width: 100%; border-collapse: collapse; font-size: 15px; }
.tm-table th { text-align: left; padding: 0 16px 14px; font: 400 var(--tm-caption)/1.4 var(--tm-font-mono); color: var(--tm-text-subtle); border-bottom: 1px solid var(--tm-line); }
.tm-table th:first-child, .tm-table td:first-child { padding-left: 0; }
.tm-table th.is-us { color: var(--tm-text); font-weight: 700; border-bottom: 2px solid var(--tm-accent); }
.tm-table td { padding: 16px; border-bottom: 1px solid var(--tm-line); color: var(--tm-text-muted); }
.tm-table td.is-us { color: var(--tm-text); font-weight: 500; }

/* ---- Navigation ---------------------------------------------------------- */
.tm-nav { display: flex; align-items: center; gap: 28px; flex-wrap: wrap; padding-block: 18px; }
.tm-nav__links { display: flex; gap: 22px; flex-wrap: wrap; font: 400 var(--tm-ui)/1 var(--tm-font-mono); }
.tm-nav__links a { color: var(--tm-text-muted); text-decoration: none; padding-block: 8px; }
.tm-nav__links a:hover, .tm-nav__links a[aria-current] { color: var(--tm-text); }
.tm-nav__end { margin-left: auto; display: flex; gap: 8px; align-items: center; }

.tm-tabs { display: flex; gap: 4px; flex-wrap: wrap; border-bottom: 1px solid var(--tm-line); font: 400 var(--tm-ui)/1 var(--tm-font-mono); }
.tm-tabs a { padding: 14px 10px; color: var(--tm-text-muted); text-decoration: none; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tm-tabs a:hover { color: var(--tm-text); }
.tm-tabs a[aria-current="page"] { color: var(--tm-text); border-bottom-color: var(--tm-accent); }

.tm-crumbs { display: flex; align-items: center; gap: 12px; font: 400 var(--tm-ui)/1 var(--tm-font-mono); }
.tm-crumbs .sep { color: var(--tm-text-subtle); }

/* ---- List rows (the chat-list pattern) ---------------------------------- */
.tm-list { font-family: var(--tm-font-mono); }
.tm-list__head { display: flex; align-items: center; gap: 8px; padding: 16px 20px; font-size: var(--tm-ui); color: var(--tm-text-muted); }
.tm-list__head > :last-child { margin-left: auto; }
.tm-row { display: flex; flex-direction: column; gap: 6px; padding: 14px 20px; border-top: 1px solid var(--tm-line); text-decoration: none; color: var(--tm-text); }
.tm-row:hover { background: var(--tm-raised); }
.tm-row[aria-current] { background: var(--tm-raised); }
.tm-row__top { display: flex; align-items: baseline; gap: 10px; }
.tm-row__title { font-weight: 700; font-size: 14px; }
.tm-row__time { margin-left: auto; font-size: var(--tm-caption); color: var(--tm-text-subtle); }
.tm-row__sub { display: flex; align-items: center; gap: 8px; font-size: var(--tm-ui); color: var(--tm-text-muted); min-width: 0; }
.tm-row__sub > span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---- Event (deployment thread item) ------------------------------------- */
.tm-event { display: flex; flex-direction: column; gap: 3px; padding: 9px 0; }
.tm-event__top { display: flex; align-items: center; gap: 8px; font: 400 var(--tm-ui)/1.4 var(--tm-font-mono); }
.tm-event__time { margin-left: auto; font-size: var(--tm-caption); color: var(--tm-text-subtle); }
.tm-event__msg { padding-left: 15px; color: var(--tm-text-muted); font-size: var(--tm-body-s); }

/* ---- Stats --------------------------------------------------------------- */
.tm-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
.tm-stat { display: flex; flex-direction: column; gap: 4px; padding: 16px 20px; border-right: 1px solid var(--tm-line); }
.tm-stat:last-child { border-right: 0; }
.tm-stat__label { font: 400 var(--tm-caption)/1.4 var(--tm-font-mono); color: var(--tm-text-subtle); }
.tm-stat__value { font: 500 26px/1.1 var(--tm-font-mono); letter-spacing: -0.04em; font-variant-numeric: tabular-nums; }

/* ---- Definition list ----------------------------------------------------- */
.tm-dl { margin: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px 28px; font-size: var(--tm-body-s); }
.tm-dl > div { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.tm-dl > .span-2 { grid-column: span 2; }
.tm-dl dt { font: 400 var(--tm-caption)/1.4 var(--tm-font-mono); color: var(--tm-text-subtle); }
.tm-dl dd { margin: 0; overflow-wrap: anywhere; }

/* ---- Bar chart (stacked hit/miss) --------------------------------------- */
.tm-bars { height: 120px; display: flex; align-items: flex-end; gap: 4px; }
.tm-bars > div { flex: 1; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; gap: 2px; }
.tm-bars > div > * { display: block; flex: none; }
.tm-bars .hit { background: var(--tm-accent); }
.tm-bars .miss { background: var(--tm-raised-strong); }
.tm-legend { display: flex; gap: 18px; flex-wrap: wrap; font: 400 var(--tm-caption)/1 var(--tm-font-mono); color: var(--tm-text-muted); }
.tm-legend span { display: inline-flex; align-items: center; gap: 6px; }
.tm-legend i { width: 10px; height: 10px; display: inline-block; }

/* ---- App shell ----------------------------------------------------------- */
.tm-app-bar { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; padding: 10px 20px; border-bottom: 1px solid var(--tm-line); font: 400 var(--tm-ui)/1 var(--tm-font-mono); }
.tm-app { display: flex; flex-wrap: wrap; align-items: stretch; min-height: calc(100vh - 57px); }
.tm-app__side { flex: 1 1 280px; max-width: var(--tm-sidebar-w); min-width: 0; background: var(--tm-surface-sunk); border-right: 1px solid var(--tm-line); }
.tm-app__main { flex: 999 1 600px; min-width: 0; display: flex; flex-direction: column; }
@media (max-width: 900px) {
  .tm-app__side { max-width: none; border-right: 0; border-bottom: 1px solid var(--tm-line); }
}
.tm-avatar { width: 32px; height: 32px; display: inline-flex; align-items: center; justify-content: center; background: var(--tm-raised); border: 1px solid var(--tm-line); font: 700 var(--tm-ui)/1 var(--tm-font-mono); color: var(--tm-text); }

/* ---- Utilities ----------------------------------------------------------- */
.tm-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.tm-rule-bottom { border-bottom: 1px solid var(--tm-line); }

/* ---- Theme toggle helper ------------------------------------------------- */
.tm-theme-toggle { font: 400 var(--tm-caption)/1 var(--tm-font-mono); }
