/* ============ tokyonight ============ */

:root {
  --bg-page: #16161e;
  --bg: #1a1b26;
  --bg2: #16161e;
  --bg-hl: #292e42;
  --border: #3b4261;
  --fg: #c0caf5;
  --dim: #565f89;
  --tilde: #2f3450;
  --green: #9ece6a;
  --orange: #ff9e64;
  --red: #f7768e;
  --blue: #7aa2f7;
  --accent: var(--green);   /* state color: NORMAL green */
  --font-mono: "Cascadia Code", "Cascadia Mono", "JetBrains Mono", Consolas, monospace;
}

body.state-incident { --accent: var(--red); }
body.state-incident.acked { --accent: var(--blue); }
body.state-recovery { --accent: var(--orange); }

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

body {
  background: var(--bg-page);
  color: var(--fg);
  font-family: var(--font-mono);
  min-height: 100vh;
  display: grid;
  place-items: center;
  overflow: hidden;
}

/* Tux + dashboard are laid out as one group and scaled as a unit (--fit,
   set by main.js) so the whole scene always fits the viewport — width and
   height — with Tux never clipping off the edge. */
.scene {
  display: flex;
  align-items: flex-end;
  gap: 30px;
  transform: scale(var(--fit, 1));
  transform-origin: center center;
}

.tux-col { order: -1; flex: 0 0 auto; }

.dash-col {
  position: relative;
  width: 720px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ============ terminal window ============ */

.dashboard {
  background: var(--bg);
  border: 1px solid #101018;
  border-radius: 8px;
  overflow: hidden;
  font-size: 13px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
  transition: border-color 0.4s;
}

body.state-incident .dashboard { border-color: var(--accent); }

/* unacked page: cmdline error blinks, panel begs to be clicked */
body.unacked .dashboard { cursor: pointer; }
body.unacked .cmdline { animation: pill-blink 1s steps(2, jump-none) infinite; }

@keyframes pill-blink { 50% { opacity: 0.35; } }

/* escalated to SEV-1: the whole panel shakes */
body.sev-1 .dashboard { animation: panel-shake 0.25s linear infinite; }

@keyframes panel-shake {
  0%, 100% { transform: translateX(0); }
  25%      { transform: translateX(-2px); }
  75%      { transform: translateX(2px); }
}

/* tabline */

.tabline {
  display: flex;
  background: var(--bg2);
  font-size: 12px;
  color: var(--dim);
}

.tab { padding: 5px 14px; cursor: pointer; transition: color 0.15s; }
.tab:hover:not(.active) { color: var(--fg); }
.tab.active { background: var(--bg); color: var(--blue); }

/* an unacked page while you're reading another buffer: overview.tux pages you */
.tab.alert { color: var(--red); animation: pill-blink 1s steps(2, jump-none) infinite; }
.tabline .fill, .statusline .fill { flex: 1; }
.tabline .buf { padding: 5px 10px; }

/* panes */

/* both tab views are always laid out (never display:none), stacked in the
   same grid cell, so the row sizes to the taller one and switching tabs
   never changes the dashboard's height */
.panes-stack {
  display: grid;
}

.panes {
  grid-area: 1 / 1;
  padding: 16px 14px 12px;
  display: grid;
  gap: 15px;
  align-content: start;
}

.panes.view-hidden {
  visibility: hidden;
  pointer-events: none;
}

.pane {
  position: relative;
  border: 1px solid var(--border);
  border-radius: 2px;
  padding: 12px;
}

.pane-title {
  position: absolute;
  top: -8px;
  left: 10px;
  background: var(--bg);
  padding: 0 6px;
  font-size: 11px;
  color: var(--dim);
}

.pane-title b { color: var(--accent); font-weight: 600; }

/* graph: one thin column per sample, btop-style area silhouette;
   color ramps green -> orange -> red with the sample's value */

.cbars {
  position: relative;
  display: flex;
  align-items: flex-end;
  height: 76px;
  gap: 1px;
}

/* log-scale reference lines: 10ms bottom, 10s top -> 100ms and 1s land
   at exactly 1/3 and 2/3 of the height */
.cbars::before, .cbars::after {
  position: absolute;
  left: 0;
  right: 0;
  border-top: 1px dashed rgba(59, 66, 97, 0.55);
  font-size: 9px;
  line-height: 1;
  color: var(--dim);
  padding: 2px 0 0 2px;
  pointer-events: none;
}

.cbars::before { content: "1s"; bottom: 66.67%; }
.cbars::after  { content: "100ms"; bottom: 33.33%; }

.cbars i {
  flex: 1;
  min-height: 2px;
  border-radius: 1px 1px 0 0;
  background: var(--green);
}

.cbars i.warm { background: var(--orange); }
.cbars i.hot  { background: var(--red); }

.graph-base {
  border-top: 1px solid var(--border);
  margin-top: 3px;
  padding-top: 4px;
  font-size: 10px;
  color: var(--dim);
  display: flex;
  justify-content: space-between;
}

/* cluster key-values */

/* label/value pairs, two pairs per row; fixed ch-based columns so
   changing value widths can't shift the layout */
.kv {
  display: grid;
  grid-template-columns: 14ch 17ch 6ch 1fr;
  gap: 6px 2ch;
  font-size: 12.5px;
  white-space: pre;
  overflow: hidden;
}

.kv .k { color: var(--dim); }
.kv .gauge { color: var(--accent); transition: color 0.4s; }

/* pods.yaml view */

.yamlview {
  font-size: 12px;
  line-height: 1.65;
  /* matches the overview panes' combined height (3 panes + gaps + padding)
     so the pods.yaml view fills the row instead of leaving space below it */
  max-height: 390px;
  overflow-y: auto;
  overflow-x: hidden;
  white-space: pre-wrap;
  overflow-wrap: break-word;
  color: var(--fg);
  scrollbar-width: thin;
  scrollbar-color: var(--border) var(--bg);
}

.yamlview::-webkit-scrollbar { width: 8px; }
.yamlview::-webkit-scrollbar-track { background: var(--bg); }
.yamlview::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.yamlview .yk { color: var(--blue); }
.yamlview .ys { color: var(--green); }
.yamlview .yn { color: var(--orange); }
.yamlview .ye { color: var(--red); }
.yamlview .yc { color: var(--dim); font-style: italic; }

/* journal (log pane) */

.logpane {
  display: grid;
  grid-template-columns: 26px 1fr;
  column-gap: 10px;
  font-size: 12px;
  line-height: 1.75;
  min-height: 168px;
  align-content: start;
  white-space: pre;
  overflow: hidden;
}

.logpane .ln { color: var(--dim); text-align: right; }
.logpane .tilde { color: var(--tilde); }
.logpane .lvl-info { color: var(--dim); }
.logpane .lvl-warn { color: var(--orange); }
.logpane .lvl-error { color: var(--red); }

/* statusline */

.statusline {
  display: flex;
  font-size: 12px;
  background: var(--bg2);
  align-items: stretch;
}

.mode {
  background: var(--accent);
  color: var(--bg2);
  font-weight: 700;
  padding: 4px 12px;
  transition: background 0.4s;
}

.slfile { padding: 4px 12px; color: var(--fg); background: var(--bg-hl); }
.slseg { padding: 4px 10px; color: var(--dim); }
.slseg.hl { background: var(--bg-hl); color: var(--fg); }

/* cmdline */

.cmdline {
  padding: 5px 12px 7px;
  font-size: 12.5px;
  color: var(--fg);
  background: var(--bg);
  min-height: 27px;
}

.cmdline.err { color: var(--red); font-weight: 600; }

.cursor {
  display: inline-block;
  width: 7px;
  height: 14px;
  background: var(--fg);
  vertical-align: -2px;
  animation: cursor-blink 1.1s steps(2, jump-none) infinite;
}

@keyframes cursor-blink { 50% { opacity: 0; } }

/* ============ tux ============ */

#tux {
  display: block;
  width: 190px;
  /* rim glow: lifts the dark body off the near-black page */
  filter: drop-shadow(0 0 14px rgba(122, 162, 247, 0.16));
}

/* blink (ambient CSS loop) */
.eyelid {
  transform-box: fill-box;
  transform-origin: 50% 0%;
  transform: scaleY(0);
  animation: blink 4.5s infinite;
  transition: transform 0.4s;
}

/* moods override the blink loop with a held eyelid position */
body.mood-sleepy   .eyelid { animation: none; transform: scaleY(0.7); }
body.mood-facepalm .eyelid { animation: none; transform: scaleY(0.5); }

@keyframes blink {
  0%, 93%, 100% { transform: scaleY(0); }
  95%, 97%      { transform: scaleY(1); }
}

/* coffee steam (ambient CSS loop) */
.steam-line {
  animation: steam 2.4s infinite ease-in-out;
}
.steam-line--late { animation-delay: 1.2s; }

@keyframes steam {
  0%   { opacity: 0; transform: translateY(4px); }
  40%  { opacity: 0.8; }
  100% { opacity: 0; transform: translateY(-6px); }
}

/* gentle idle bob */
#tux-root {
  transform-box: fill-box;
  transform-origin: 50% 100%;
  animation: bob 3.2s infinite ease-in-out;
}

@keyframes bob {
  0%, 100% { transform: scaleY(1); }
  50%      { transform: scaleY(0.985); }
}

/* incident: pause ambient loops that clash with the panic timeline */
body.state-incident #tux-root { animation-play-state: paused; }
body.state-incident .steam-line { animation-play-state: paused; opacity: 0; }

/* ============ chaos button ============ */

#chaos-btn {
  align-self: flex-end;
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--dim);
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 8px 14px;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s;
}

#chaos-btn:hover {
  color: var(--red);
  border-color: var(--red);
}

#chaos-btn:disabled {
  opacity: 0.4;
  cursor: default;
}
