/* hekma.ktesio.dev: the Hekma palette, wordmark, hero art, the fleet mock
   and the animated card elements. Layout and components come from base.css
   (shared/css/base.css), which loads first.
   Colours come from the Hekma banner: lapis ink, papyrus, gold, turquoise and
   sun-red. Dark is the default; [data-theme="light"] is the papyrus theme.
   scripts/contrast.py checks every text pair below against WCAG AA. */

/* ---------------------------------------------------------------- tokens */
:root {
  color-scheme: dark;
  --bg: #0b1017;
  --bg-2: #0f151e;
  --bg-3: #161f2b;
  --term: #080c12;
  --term-2: #0c121a;
  --line: #1c2531;
  --line-2: #2a3544;
  --fg: #eee8da;
  --fg-2: #c4bdae;
  --muted: #959eaa;
  --dim: #808a97;
  --accent: #e9b650;
  --ok: #5dcbb9;
  --warn: #e9b650;
  --bad: #f4845f;
  --bad-bg: rgba(244, 132, 95, 0.1);
  --focus: #f6d484;
  --art: rgba(233, 182, 80, 0.2);
  --num: #5b6573;
}
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f4eee0;
  --bg-2: #eee6d3;
  --bg-3: #e6dbc3;
  --term: #fbf8f0;
  --term-2: #f2ebdb;
  --line: #ddd2bb;
  --line-2: #c9bb9d;
  --fg: #1c1813;
  --fg-2: #3c372d;
  --muted: #625a4c;
  --dim: #675f51;
  --accent: #815300;
  --ok: #0b6b60;
  --warn: #815300;
  --bad: #ae3717;
  --bad-bg: rgba(174, 55, 23, 0.08);
  --focus: #815300;
  --art: rgba(138, 88, 0, 0.13);
  --num: #8a7f68;
}

/* ---------------------------------------------------------------- wordmark */
.mark {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font: 700 23px/1 var(--serif);
  letter-spacing: -0.01em;
}
.disc {
  flex: none;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
}
.mark-sm {
  font-size: 19px;
}
.mark-sm .disc {
  width: 9px;
  height: 9px;
}

/* ---------------------------------------------------------------- hero art */
.sun {
  position: absolute;
  top: 34px;
  right: -40px;
  width: min(620px, 50vw);
  color: var(--art);
  pointer-events: none;
}
.sun-core {
  fill: var(--art);
}
@media (max-width: 900px) {
  .sun {
    display: none;
  }
}

/* ---------------------------------------------------------------- the mock */
.fig {
  padding: 40px var(--pad) 38px;
  border-bottom: 1px solid var(--line);
}
.fig-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
  color: var(--muted);
  font: 500 11.5px/1 var(--mono);
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.mock {
  overflow: hidden;
  border: 1px solid var(--line-2);
  border-radius: 6px;
  background: var(--term);
  color: var(--fg-2);
  font: 400 12px/1.5 var(--mono);
}
.mock-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 36px;
  padding: 0 12px;
  border-bottom: 1px solid var(--line);
  background: var(--term-2);
  color: var(--dim);
  font-size: 11.5px;
}
.mock-sep {
  margin: 0 4px;
}
.mock-replay {
  padding: 4px 9px;
  border: 1px solid var(--line-2);
  border-radius: 3px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  cursor: pointer;
}
.mock-replay:hover {
  border-color: var(--accent);
  color: var(--fg);
}
.mock-body {
  display: grid;
  grid-template-columns: 238px minmax(0, 1fr);
  height: 620px;
}
.side {
  overflow-y: auto;
  padding: 8px 0 14px;
  border-right: 1px solid var(--line);
  background: var(--term-2);
  scrollbar-width: thin;
}
.side-h {
  margin: 10px 14px 4px;
  color: var(--dim);
  font-size: 10.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.side-g {
  margin: 10px 14px 3px;
  color: var(--muted);
  font-size: 11.5px;
}
.side-g::before {
  content: "~/";
  color: var(--dim);
}
.side ul {
  margin: 0;
  padding: 0;
  list-style: none;
}
.agent,
.view-btn {
  display: grid;
  gap: 5px;
  width: 100%;
  padding: 8px 14px 9px 12px;
  border: 0;
  border-left: 2px solid transparent;
  background: transparent;
  color: var(--fg-2);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
html:not(.js) .agent,
html:not(.js) .view-btn {
  cursor: default;
}
.agent:hover,
.view-btn:hover {
  background: color-mix(in srgb, var(--bg-3) 70%, transparent);
}
.agent[aria-current="true"],
.view-btn[aria-current="true"] {
  border-left-color: var(--accent);
  background: var(--bg-3);
}
.agent-top {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.agent-name {
  overflow: hidden;
  color: var(--fg);
  text-overflow: ellipsis;
  white-space: nowrap;
}
.agent-rs {
  margin-left: auto;
  color: var(--muted);
  font-size: 10.5px;
  white-space: nowrap;
}
.dot {
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--dim);
}
.agent[data-state="running"] .dot {
  background: var(--ok);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 20%, transparent);
}
.agent[data-state="paused"] .dot {
  background: var(--warn);
}
.agent[data-state="failed"] .dot {
  background: var(--bad);
}
.agent[data-state="stopped"] .dot {
  border: 1.5px solid var(--dim);
  background: transparent;
}
.agent-meta {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: var(--dim);
  font-size: 11px;
}
.agent[data-state="running"] .agent-state {
  color: var(--ok);
}
.agent[data-state="paused"] .agent-state {
  color: var(--warn);
}
.agent[data-state="failed"] .agent-state {
  color: var(--bad);
}
.agent-amt {
  white-space: nowrap;
}
.view-cmd {
  color: var(--dim);
  font-size: 10.5px;
}
.bar {
  display: block;
  width: 100%;
  height: 3px;
  overflow: visible;
}
.bar-bg {
  fill: var(--line-2);
}
.bar-fill {
  fill: var(--ok);
  transition: width 0.35s ease;
}
.bar.near .bar-fill {
  fill: var(--warn);
}
.bar.over .bar-fill {
  fill: var(--bad);
}
.main {
  position: relative;
  min-width: 0;
}
.view {
  position: absolute;
  inset: 0;
  display: grid;
  gap: 16px 12px;
  padding: 18px 14px 12px;
}
.view[hidden] {
  display: none;
}
.layout-single {
  grid-template: "top" minmax(0, 1fr) / minmax(0, 1fr);
}
.layout-stack {
  grid-template: "top" minmax(0, 57fr) "bottom" minmax(0, 43fr) / minmax(0, 1fr);
}
.area-top {
  grid-area: top;
}
.area-bottom {
  grid-area: bottom;
}
.pane {
  position: relative;
  min-width: 0;
  min-height: 0;
  border: 1px solid var(--line-2);
  border-radius: 4px;
}
.view[data-view="pay-triage"] .area-top {
  border-color: color-mix(in srgb, var(--accent) 55%, var(--line-2));
}
.pane-t {
  position: absolute;
  top: -8px;
  left: 10px;
  z-index: 1;
  padding: 0 6px;
  background: var(--term);
  color: var(--muted);
  font-size: 11px;
  line-height: 16px;
}
/* column-reverse keeps a full pane scrolled to its newest line, like a
   terminal; the auto margin keeps a short one at the top. */
.pane-b {
  display: flex;
  flex-direction: column-reverse;
  height: 100%;
  padding: 13px 12px 8px;
  overflow: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--line-2) transparent;
  -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 12px);
  mask-image: linear-gradient(to bottom, transparent 0, #000 12px);
}
.pane-b > .term {
  margin-bottom: auto;
}
.pane-b:focus-visible {
  outline-offset: -2px;
}
.term {
  margin: 0;
  font: inherit;
  white-space: pre;
}
.ln.wrap {
  white-space: pre-wrap;
}
.term code {
  font: inherit;
}
.ln.pending {
  display: none;
}
.ln.breach {
  background: var(--bad-bg);
}
.ln.breach .k-bad {
  font-weight: 600;
}
.ln.flash {
  animation: flash 1.4s ease-out;
}
@keyframes flash {
  from {
    background: color-mix(in srgb, var(--bad) 38%, transparent);
  }
  to {
    background: var(--bad-bg);
  }
}
.k-dim,
.k-rule,
.k-meter {
  color: var(--dim);
}
.k-label {
  color: var(--muted);
}
.k-prompt,
.k-accent {
  color: var(--accent);
}
.k-cmd,
.k-head {
  color: var(--fg);
}
.k-head {
  font-weight: 600;
}
.k-ok {
  color: var(--ok);
}
.k-warn {
  color: var(--warn);
}
.k-bad {
  color: var(--bad);
}
.figcap {
  margin: 14px 0 0;
  color: var(--muted);
  font: italic 400 14px/1.55 var(--sans);
}
@media (max-width: 1100px) {
  .mock {
    font-size: 11.5px;
  }
}
@media (max-width: 900px) {
  .mock {
    font-size: 11px;
  }
  .mock-bar {
    flex-wrap: wrap;
    padding: 6px 10px;
  }
  .mock-body {
    grid-template-columns: minmax(0, 1fr);
    height: auto;
  }
  .side {
    display: flex;
    gap: 6px;
    padding: 8px;
    overflow-x: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    scrollbar-width: none;
  }
  .side::-webkit-scrollbar {
    display: none;
  }
  .ln.log {
    white-space: pre-wrap;
  }
  .fig-hint {
    display: none;
  }
  .side-h,
  .side-g {
    display: none;
  }
  .side ul {
    display: contents;
  }
  .side li {
    flex: none;
  }
  .agent,
  .view-btn {
    width: 172px;
    height: 100%;
    border: 1px solid var(--line-2);
    border-radius: 4px;
  }
  .agent[aria-current="true"],
  .view-btn[aria-current="true"] {
    border-color: var(--accent);
  }
  .view {
    position: static;
    display: flex;
    flex-direction: column;
    gap: 18px;
    padding: 16px 10px 12px;
  }
  .view[hidden] {
    display: none;
  }
  .pane {
    height: 300px;
  }
  .area-bottom {
    height: 260px;
  }
  .layout-single .pane {
    height: 420px;
  }
}

/* ---------------------------------------------------------------- card live elements */
.cycle {
  display: grid;
  justify-items: end;
}
.cycle .st {
  grid-area: 1 / 1;
  opacity: 0;
  animation: 6s infinite;
}
.cycle .st-ok {
  animation-name: cyc-run;
}
.cycle .st-bad {
  animation-name: cyc-fail;
}
.cycle .st-dim {
  animation-name: cyc-start;
}
@keyframes cyc-run {
  0%, 44% { opacity: 1; }
  45%, 71% { opacity: 0; }
  72%, 100% { opacity: 1; }
}
@keyframes cyc-fail {
  0%, 44% { opacity: 0; }
  45%, 59% { opacity: 1; }
  60%, 100% { opacity: 0; }
}
@keyframes cyc-start {
  0%, 59% { opacity: 0; }
  60%, 71% { opacity: 1; }
  72%, 100% { opacity: 0; }
}
.ev .bar {
  height: 5px;
  margin: 0 0 12px;
}
.bar-grow {
  transform-box: fill-box;
  transform-origin: left center;
  animation: grow 5s ease-in-out infinite;
}
@keyframes grow {
  0% { transform: scaleX(0.75); fill: var(--warn); }
  62% { transform: scaleX(1); fill: var(--warn); }
  64%, 100% { transform: scaleX(1); fill: var(--bad); }
}
.wire {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 12px 0 8px;
}
.wire i {
  position: relative;
  flex: 1;
  height: 1px;
  overflow: hidden;
  background: var(--line-2);
}
.wire i::after {
  content: "";
  position: absolute;
  top: 0;
  left: -12%;
  width: 12%;
  height: 1px;
  background: var(--accent);
  animation: packet 2.2s linear infinite;
}
@keyframes packet {
  to { left: 100%; }
}

/* ---------------------------------------------------------------- motion */
@media (prefers-reduced-motion: reduce) {
  .cycle .st {
    opacity: 0;
  }
  .cycle .st-ok {
    opacity: 1;
  }
  .bar-grow {
    fill: var(--bad);
  }
}
