/* ============================================================================
   PCAP Decode and Analysis Platform - base, shell and layout
   ----------------------------------------------------------------------------
   Data is monospace, chrome is sans. Never the other way round. A protocol
   name, a hash, an identifier and a timestamp are data. A screen title, a nav
   item, a column head and a status word are chrome.

   Load order: tokens.css, app.css, components.css.
   ========================================================================== */

/* ==========================================================================
   Base
   ========================================================================== */
* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: var(--t-body);
  font-weight: var(--w-body);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent2); text-decoration: underline; }

h1 {
  font-size: var(--t-title); font-weight: var(--w-title);
  letter-spacing: -.02em; line-height: 1.2; margin: 0 0 .2rem;
}
h2 {
  font-size: var(--t-sect); font-weight: var(--w-sect);
  letter-spacing: -.01em; margin: 2rem 0 .6rem;
}
h3 { font-size: 13px; font-weight: 600; margin: 1.2rem 0 .4rem; color: var(--ink2); }
p  { margin: .5rem 0; }

code, .mono, kbd {
  font-family: var(--mono);
  font-size: .875em;
  font-variant-ligatures: none;
}

code {
  background: var(--raised);
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: .08em .34em;
}

/* Data values: monospace, tight, tabular. The rule the whole look rests on. */
.v {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  letter-spacing: -.012em;
}

.hash {
  font-family: var(--mono);
  font-size: .8em;
  color: var(--ink3);
  letter-spacing: -.02em;
}

.muted   { color: var(--ink2); }
.muted2  { color: var(--ink3); }
.nowrap  { white-space: nowrap; }
.right   { text-align: right; }
.grow    { flex: 1; }

/* Section labels are chrome, so they are sans. Tracking does the work, and
   the colour keeps them from competing with the thing they label. */
.lbl {
  font-family: var(--sans);
  font-size: var(--t-label);
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--ink3);
  font-weight: var(--w-label);
}

/* Two-line cell: the machine value leads, the human name follows quietly. */
.pair { display: flex; flex-direction: column; gap: .1rem; }
.pair .lead {
  font-family: var(--mono);
  font-size: var(--t-data);
  font-weight: 500;
  color: var(--ink);
  letter-spacing: -.012em;
}
.pair .sub { font-size: var(--t-xs); color: var(--ink3); line-height: 1.35; }

.t-md { font-size: var(--t-md); }
.t-sm { font-size: var(--t-sm); }
.t-xs { font-size: var(--t-xs); }

/* ==========================================================================
   Shell: fixed sidebar + content
   ========================================================================== */
.shell { display: grid; grid-template-columns: var(--nav) minmax(0, 1fr); min-height: 100vh; }

.side {
  background: var(--surface);
  border-right: 1px solid var(--line);
  padding: 1rem .75rem 2rem;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.brand { display: flex; align-items: baseline; gap: .45rem; padding: .2rem .5rem 1.1rem; }
.brand .mark { font-family: var(--mono); font-weight: 700; color: var(--accent); font-size: 1rem; }
.brand .name { font-weight: 620; font-size: .9rem; letter-spacing: -.015em; }
.brand .navtoggle {
  margin-left: auto;
  width: 24px;
  height: 24px;
  font-size: 13px;
  flex: none;
}

/* A label with an action on the same row. The action is an affordance, not a
   second label, so it stays the weight of the text it sits beside. */
.lblrow { display: flex; align-items: center; margin-right: .5rem; }
.lblrow .lbl { flex: 1; }
.lblbtn {
  color: var(--ink3);
  font-size: 15px;
  line-height: 1;
  padding: 0 .3rem;
  border-radius: var(--r);
  text-decoration: none;
}
.lblbtn:hover { color: var(--accent); background: var(--raised); text-decoration: none; }

.caseacts { display: flex; align-items: center; gap: .4rem; margin-top: .35rem; }
.caseacts a { font-size: var(--t-xs); color: var(--ink3); }
.caseacts a:hover { color: var(--accent); text-decoration: none; }
.caseacts .sep { color: var(--line2); font-size: var(--t-xs); }

.side .lbl {
  display: block;
  margin: 1.5rem .5rem .3rem;
  font-size: 9.5px;
  font-weight: 500;
  letter-spacing: .13em;
  color: var(--ink3);
  opacity: .72;
}
.side .lbl:first-of-type { margin-top: .2rem; }

.nav a {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .4rem .5rem;
  border-radius: var(--r);
  color: var(--ink2);
  font-size: var(--t-nav);
  font-weight: var(--w-nav);
  border-left: 2px solid transparent;
}
.nav a:hover { background: var(--raised); color: var(--ink); text-decoration: none; }
.nav a[aria-current="page"] {
  background: var(--accentbg);
  color: var(--accent2);
  border-left-color: var(--accent);
  font-weight: 600;
}
.nav a .ic { font-size: .8rem; width: 1.1rem; text-align: center; opacity: .75; }
.nav a .ct { margin-left: auto; font-family: var(--mono); font-size: 10px; color: var(--ink3); }

.main { min-width: 0; display: flex; flex-direction: column; }

.top {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: .85rem 1.6rem .95rem;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 20;
}

.content { padding: 1.6rem; max-width: 1400px; width: 100%; }

/* The trail under the title: which case, and which artefact within it. Reads
   as one line, but the id and the filename stay mono and the name stays sans -
   machine and human are still not mixed inside a single string. */
.caseline {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: .45rem;
  margin-top: .3rem;
  font-size: var(--t-caseid);
}
.caseline .cid {
  font-family: var(--mono);
  font-weight: var(--w-caseid);
  color: var(--accent);
  letter-spacing: -.01em;
}
.caseline .csep { color: var(--line2); font-weight: 400; }
.caseline .cname { color: var(--ink2); font-weight: 500; }
/* The separator is the component's, not the template's, so any screen that
   fills the context block gets it without repeating the markup. */
.caseline .ctx {
  font-family: var(--mono);
  font-weight: var(--w-caseid);
  color: var(--ink3);
  letter-spacing: -.01em;
}
.caseline .ctx.words { font-family: var(--sans); letter-spacing: 0; }
.caseline .ctx::before {
  content: ">";
  margin-right: .45rem;
  color: var(--line2);
  font-family: var(--sans);
}
.ptitle {
  font-size: var(--t-title);
  font-weight: var(--w-title);
  letter-spacing: -.02em;
  line-height: 1.15;
}

/* The product spine. Metadata leads to Content; the rail says so on every
   screen that is part of it. */
.rail { display: flex; align-items: center; gap: .15rem; }
.rail a {
  padding: .28rem .6rem;
  border-radius: var(--r);
  font-size: 12.5px;
  font-weight: 500;
  color: var(--ink2);
}
.rail a:hover { background: var(--raised); color: var(--ink); text-decoration: none; }
.rail a[aria-current="page"] { background: var(--raised); color: var(--ink); font-weight: 600; }
.rail .arw { color: var(--ink3); font-size: 11px; padding: 0 .1rem; }

/* -- Collapsed navigation --------------------------------------------------
   An icons-only rail rather than a hidden panel: the operator keeps one-click
   access to every screen, and the shell does not reflow into a different
   layout. Text is hidden, not removed, so tooltips and screen readers keep it.
   -------------------------------------------------------------------------- */
:root[data-nav="collapsed"] .side { padding: 1rem .5rem 2rem; overflow: visible; }
:root[data-nav="collapsed"] .brand { padding: .2rem 0 1rem; justify-content: center; }
:root[data-nav="collapsed"] .brand .mark,
:root[data-nav="collapsed"] .brand .name,
:root[data-nav="collapsed"] .side .lbl,
:root[data-nav="collapsed"] .side .nt { display: none; }   /* labels, link text, case block */
:root[data-nav="collapsed"] .brand .navtoggle { margin: 0; transform: rotate(180deg); }
:root[data-nav="collapsed"] .nav { margin-bottom: .5rem; }
:root[data-nav="collapsed"] .nav a {
  justify-content: center;
  padding: .5rem 0;
  border-left: none;
  border-radius: var(--r);
}
:root[data-nav="collapsed"] .nav a .ic { width: auto; font-size: .95rem; opacity: .9; }
:root[data-nav="collapsed"] .nav a[aria-current="page"] {
  box-shadow: inset 0 0 0 1px var(--accentln);
}

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .side {
    position: static; height: auto;
    border-right: none; border-bottom: 1px solid var(--line);
  }
  .content { padding: 1rem; }
}

/* ==========================================================================
   Panels
   ========================================================================== */
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r2);
  margin: 0 0 1rem;
  overflow: hidden;
}

.panel > .ph {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .7rem 1rem;
  border-bottom: 1px solid var(--line);
  background: var(--raised);
}
.panel > .ph h2 {
  margin: 0;
  font-size: var(--t-sect);
  font-weight: var(--w-sect);
  letter-spacing: -.01em;
}
.panel > .pb { padding: 1rem; }
.panel > .pb.flush { padding: 0; }
.panel > .pf {
  padding: .6rem 1rem;
  border-top: 1px solid var(--line);
  background: var(--raised);
  font-size: var(--t-xs);
  color: var(--ink3);
  line-height: 1.5;
}

.grid  { display: grid; gap: 1rem; }
.g2    { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.g3    { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.row   { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }

/* ==========================================================================
   KPI tiles
   ========================================================================== */
.kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: .7rem;
  margin-bottom: 1rem;
}

.kpi {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r2);
  padding: .85rem 1rem;
}
.kpi .n {
  font-family: var(--mono);
  font-size: 1.55rem;
  font-weight: 600;
  line-height: 1;
  letter-spacing: -.04em;
  font-variant-numeric: tabular-nums;
}
.kpi .k {
  margin-top: .4rem;
  font-size: var(--t-label);
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--ink3);
  font-weight: var(--w-label);
}
.kpi .sub {
  margin-top: .25rem;
  font-size: var(--t-xs);
  color: var(--ink3);
  font-family: var(--mono);
}
.kpi.acc  .n { color: var(--accent); }
.kpi.crit .n { color: var(--crit); }
.kpi.high .n { color: var(--high); }
.kpi.good .n { color: var(--good); }

/* ==========================================================================
   Tables - dense, tabular, scrollable in their own container
   ========================================================================== */
.tw { overflow-x: auto; }

table { border-collapse: collapse; width: 100%; font-size: var(--t-data); }

th {
  text-align: left;
  padding: .6rem 1rem;
  background: var(--raised);
  border-bottom: 1px solid var(--line);
  font-family: var(--sans);
  font-size: var(--t-label);
  font-weight: var(--w-label);
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--ink3);
  white-space: nowrap;
  position: sticky;
  top: 0;
}
td {
  padding: .68rem 1rem;
  border-bottom: 1px solid var(--line3);
  vertical-align: top;
  line-height: 1.45;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--raised); }
td.num {
  font-family: var(--mono); font-variant-numeric: tabular-nums;
  text-align: right; white-space: nowrap;
}

/* ==========================================================================
   Drop zone
   ========================================================================== */
.drop {
  border: 1px dashed var(--line2);
  border-radius: var(--r2);
  padding: 1.8rem 1rem;
  text-align: center;
  cursor: pointer;
  transition: border-color .12s, background .12s;
}
.drop:hover { border-color: var(--accent); }
.drop.over { border-color: var(--accent); background: var(--accentbg); }
.drop .btn { cursor: pointer; }

/* ==========================================================================
   Auth screen
   ========================================================================== */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem; }
.auth .card { width: 100%; max-width: 350px; }
.auth .brand { justify-content: center; padding-bottom: 1.3rem; }

/* ==========================================================================
   Utility
   ========================================================================== */
.stack > * + * { margin-top: .6rem; }
.hr { border: none; border-top: 1px solid var(--line); margin: .9rem 0; }
[x-cloak] { display: none !important; }
.htmx-request .spin { display: inline; }
.spin { display: none; }
