/* SwarmInc owner app. Night-shift control desk: ink, chalk, sodium amber, signal red.
   One loud thing (the guarded stop switch); everything else stays quiet. */

@font-face { font-family: "Barlow"; font-weight: 400; font-display: swap; src: url("/fonts/barlow-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Barlow"; font-weight: 500; font-display: swap; src: url("/fonts/barlow-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "Barlow"; font-weight: 600; font-display: swap; src: url("/fonts/barlow-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "Barlow Semi Condensed"; font-weight: 500; font-display: swap; src: url("/fonts/barlow-semi-condensed-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "Barlow Semi Condensed"; font-weight: 600; font-display: swap; src: url("/fonts/barlow-semi-condensed-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "Barlow Semi Condensed"; font-weight: 700; font-display: swap; src: url("/fonts/barlow-semi-condensed-latin-700-normal.woff2") format("woff2"); }

:root {
  --ink: #0F1B2D;      /* page */
  --panel: #16253B;    /* lists and inputs */
  --raise: #1E3150;    /* hover, selected */
  --line: #2A3B55;
  --chalk: #E9E7E1;    /* text */
  --dim: #9AA7B8;      /* secondary text */
  --sodium: #F2A541;   /* attention, pace */
  --signal: #E5383B;   /* stop */
  --go: #5FBF8A;       /* running */
  --on-signal: #FFF6F4;
  --hatch: #1A1A1A;
  --display: "Barlow Semi Condensed", "Arial Narrow", sans-serif;
  --text: "Barlow", system-ui, sans-serif;
  --r: 10px;
  --tabs-h: 58px;
  --stop-h: 58px;
  color-scheme: dark;
}

@media (prefers-color-scheme: light) {
  :root {
    --ink: #EDF0F4; --panel: #FFFFFF; --raise: #E2E8F0; --line: #CDD5E0;
    --chalk: #13202F; --dim: #556275; --sodium: #A85F00; --signal: #C1121F; --go: #2E7D57;
    --on-signal: #FFFFFF; --hatch: #13202F;
    color-scheme: light;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--ink); color: var(--chalk);
  font: 400 16px/1.5 var(--text); font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration-color: var(--sodium); text-underline-offset: 3px; }
button, input, textarea, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--sodium); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* --- frame ---------------------------------------------------------------- */
.app { min-height: 100dvh; padding-bottom: calc(var(--tabs-h) + var(--stop-h) + 24px + env(safe-area-inset-bottom)); }
.top {
  display: flex; align-items: center; gap: 12px;
  padding: calc(12px + env(safe-area-inset-top)) 16px 12px;
  max-width: 1120px; margin: 0 auto;
}
.brand { font: 700 22px/1 var(--display); letter-spacing: .01em; margin: 0; }
.lamp { display: inline-flex; align-items: center; gap: 8px; font: 500 15px/1 var(--display); color: var(--dim); }
.lamp::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--go); box-shadow: 0 0 0 3px color-mix(in srgb, var(--go) 25%, transparent); }
.lamp[data-state="stopped"]::before { background: var(--signal); box-shadow: 0 0 0 3px color-mix(in srgb, var(--signal) 30%, transparent); }
.lamp[data-state="unknown"]::before { background: var(--dim); box-shadow: none; }
.top__spacer { flex: 1; }

.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; justify-content: space-around;
  height: calc(var(--tabs-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  background: var(--panel); border-top: 1px solid var(--line);
}
.tab {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  background: none; border: 0; color: var(--dim); font: 500 13px/1 var(--display); text-decoration: none; position: relative;
}
.tab[aria-current="page"] { color: var(--chalk); }
.tab[aria-current="page"]::after { content: ""; position: absolute; top: 0; left: 30%; right: 30%; height: 2px; background: var(--sodium); }
.tab__glyph { width: 22px; height: 22px; }
.tab__count {
  position: absolute; top: 6px; left: calc(50% + 6px); min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--sodium); color: var(--ink); font: 700 12px/18px var(--display);
}

.view { max-width: 1120px; margin: 0 auto; padding: 4px 16px 24px; }
.desk { display: grid; gap: 28px; }
.desk__col { display: grid; gap: 28px; align-content: start; }
.sect--gap { margin-top: 24px; }

h1, h2, h3 { font-family: var(--display); font-weight: 600; margin: 0; }
h1 { font-size: 26px; line-height: 1.15; }
h2 { font-size: 19px; line-height: 1.2; }
h3 { font-size: 16px; }
.sect { display: grid; gap: 10px; }
.sect__head { display: flex; align-items: baseline; gap: 12px; }
.sect__head .quiet { margin-left: auto; }
.quiet { color: var(--dim); font-size: 14px; }
.warn { color: var(--signal); border-left: 3px solid var(--signal); padding: 6px 10px; margin: 8px 0; font-size: 14px; }
.lede { color: var(--dim); max-width: 62ch; margin: 0; }

/* --- lists ---------------------------------------------------------------- */
.list { list-style: none; margin: 0; padding: 0; background: var(--panel); border-radius: var(--r); overflow: hidden; }
.row {
  display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; align-items: baseline;
  padding: 12px 14px; text-decoration: none; color: inherit; border-top: 1px solid var(--line);
}
.list > li:first-child > .row, .list > .row:first-child { border-top: 0; }
a.row:hover, button.row:hover { background: var(--raise); }
button.row { width: 100%; text-align: left; background: none; border: 0; border-top: 1px solid var(--line); cursor: pointer; }
.row__title { font-weight: 500; overflow-wrap: anywhere; }
.row__meta { grid-column: 1 / -1; color: var(--dim); font-size: 14px; }
.row__side { color: var(--dim); font-size: 14px; white-space: nowrap; }
.row--alert .row__title { color: var(--sodium); }
.empty { padding: 18px 14px; color: var(--dim); }

/* --- forms ---------------------------------------------------------------- */
.field { display: grid; gap: 6px; }
.field label { font: 500 14px/1.2 var(--display); color: var(--dim); }
input[type="text"], textarea, select {
  width: 100%; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px;
}
textarea { min-height: 96px; resize: vertical; line-height: 1.45; }
input:focus, textarea:focus, select:focus { border-color: var(--sodium); outline: none; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.actions select { width: auto; min-height: 44px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 16px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--panel); font: 600 16px/1 var(--display); cursor: pointer; text-decoration: none;
}
.btn:hover { background: var(--raise); }
.btn--primary { background: var(--chalk); color: var(--ink); border-color: var(--chalk); }
.btn--primary:hover { background: color-mix(in srgb, var(--chalk) 85%, var(--ink)); }
.btn--danger { color: var(--signal); border-color: color-mix(in srgb, var(--signal) 55%, var(--line)); }
.btn[disabled] { opacity: .5; cursor: default; }
.note { font-size: 14px; color: var(--dim); }
.note--error { color: var(--signal); }
.note--ok { color: var(--go); }

/* --- the stop switch ------------------------------------------------------ */
.stop {
  position: fixed; z-index: 19; left: 12px; right: 12px;
  bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom) + 10px);
  height: var(--stop-h); perspective: 700px;
}
.stop__pad, .stop__guard, .stop__resume {
  position: absolute; inset: 0; border-radius: 12px; border: 0; cursor: pointer;
  font: 700 18px/1 var(--display); letter-spacing: .01em;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  -webkit-user-select: none; user-select: none; touch-action: none;
}
.stop__pad { background: var(--signal); color: var(--on-signal); overflow: hidden; }
.stop__label { position: relative; }
.stop__fill { position: absolute; inset: 0; background: color-mix(in srgb, #000 28%, var(--signal)); transform-origin: left; transform: scaleX(0); }
.stop[data-state="holding"] .stop__fill { transform: scaleX(1); transition: transform 1.2s linear; }
.stop__guard {
  color: var(--on-signal); transform-origin: 50% 0; transition: transform .28s cubic-bezier(.3, .7, .2, 1);
  background:
    linear-gradient(color-mix(in srgb, var(--signal) 82%, transparent), color-mix(in srgb, var(--signal) 82%, transparent)),
    repeating-linear-gradient(-45deg, var(--hatch) 0 12px, #F2C230 12px 24px);
  box-shadow: 0 2px 0 color-mix(in srgb, #000 35%, transparent);
}
.stop__guard small { font: 500 14px/1 var(--display); opacity: .85; }
.stop__guard > span { display: inline-flex; gap: 10px; align-items: baseline; transition: opacity .15s; }
.stop[data-state="armed"] .stop__guard > span, .stop[data-state="holding"] .stop__guard > span { opacity: 0; }
.stop[data-state="armed"] .stop__guard, .stop[data-state="holding"] .stop__guard { transform: rotateX(-118deg); pointer-events: none; }
.stop[data-state="stopped"] .stop__guard, .stop[data-state="stopped"] .stop__pad { display: none; }
.stop__resume { display: none; background: var(--panel); color: var(--chalk); border: 1px solid var(--signal); }
.stop[data-state="stopped"] .stop__resume { display: flex; }
.stop__resume b { color: var(--signal); }

/* --- credits meters ------------------------------------------------------- */
.meters { display: grid; gap: 12px; background: var(--panel); border-radius: var(--r); padding: 14px; }
.meter { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; align-items: baseline; }
.meter__name { font-weight: 500; }
.meter__nums { color: var(--dim); font: 500 14px/1 var(--display); }
.meter__track { grid-column: 1 / -1; position: relative; height: 8px; border-radius: 4px; background: var(--line); }
.meter__fill { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 4px; background: var(--dim); }
.meter[data-paced="true"] .meter__fill { background: var(--sodium); }
.meter[data-paced="true"] .meter__name::after { content: " paced"; color: var(--sodium); font: 500 14px/1 var(--display); }
.meter__tick { position: absolute; top: -4px; bottom: -4px; width: 2px; background: var(--sodium); border-radius: 1px; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; color: var(--dim); font-size: 13px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }
.legend__spent { background: var(--dim); }
.legend__pace { background: var(--sodium); }

/* --- facts ---------------------------------------------------------------- */
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 1px; background: var(--line); border-radius: var(--r); overflow: hidden; }
.fact { background: var(--panel); padding: 12px 14px; display: grid; gap: 2px; }
.fact b { font: 600 22px/1.1 var(--display); overflow-wrap: anywhere; }
.fact span { color: var(--dim); font-size: 14px; }
.fact--wide { grid-column: 1 / -1; }
.fact--wide b { font-size: 18px; }

/* --- prose (issue bodies, the brief) -------------------------------------- */
.prose { max-width: 68ch; overflow-wrap: anywhere; }
.prose p, .prose ul, .prose ol, .prose pre, .prose table { margin: 0 0 .8em; }
.prose h1, .prose h2, .prose h3 { margin: 1em 0 .4em; }
.prose code { font-family: ui-monospace, Menlo, monospace; font-size: .9em; background: var(--panel); padding: 1px 5px; border-radius: 4px; }
.prose pre { background: var(--panel); padding: 12px; border-radius: 8px; overflow-x: auto; }
.prose pre code { background: none; padding: 0; }
.prose table { border-collapse: collapse; display: block; overflow-x: auto; font-size: 14px; }
.prose th, .prose td { border-bottom: 1px solid var(--line); padding: 6px 10px 6px 0; text-align: left; white-space: nowrap; }
.prose .linkhost { color: var(--dim); font-size: .85em; }
.thread { display: grid; gap: 14px; }
.msg { display: grid; gap: 4px; padding-left: 12px; border-left: 2px solid var(--line); }
.msg--you { border-left-color: var(--sodium); }
.msg__who { font: 600 15px/1.2 var(--display); }
.msg__who time { color: var(--dim); font-weight: 500; margin-left: 8px; }

/* --- org ------------------------------------------------------------------ */
.office { background: var(--panel); border-radius: var(--r); }
.office > summary { list-style: none; cursor: pointer; padding: 12px 14px; display: flex; gap: 10px; align-items: baseline; }
.office > summary::-webkit-details-marker { display: none; }
.office > summary .quiet { margin-left: auto; }
.office[open] > summary { border-bottom: 1px solid var(--line); }
.office__point { padding: 10px 14px 0; color: var(--dim); font-size: 14px; max-width: 70ch; }
.seat { display: grid; grid-template-columns: auto 1fr auto; gap: 4px 10px; align-items: center; padding: 10px 14px; border-top: 1px solid var(--line); }
.office__point + .seat { border-top: 0; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--dim); }
.dot[data-s="running"] { background: var(--go); }
.dot[data-s="error"], .dot[data-s="quarantined"] { background: var(--sodium); }
.dot[data-s="paused"], .dot[data-s="terminated"] { background: var(--line); }
.seat__actions { grid-column: 2 / -1; display: flex; gap: 8px; }

/* --- sign in -------------------------------------------------------------- */
.gate { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.gate__box { width: min(420px, 100%); display: grid; gap: 18px; }
.gate__mark { width: 56px; height: 56px; }

.toast {
  position: fixed; z-index: 30; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--tabs-h) + var(--stop-h) + 24px + env(safe-area-inset-bottom));
  background: var(--chalk); color: var(--ink); padding: 10px 16px; border-radius: 8px; font-weight: 500; max-width: calc(100% - 32px);
}

/* --- The Daily Rope (a newspaper, so here the rules and columns are the subject) */
.subtabs { display: flex; gap: 18px; margin: 4px 0 18px; font: 600 16px/1 var(--display); }
.subtabs a { color: var(--dim); text-decoration: none; padding-bottom: 6px; }
.subtabs a[aria-current="page"] { color: var(--chalk); box-shadow: inset 0 -2px 0 var(--sodium); }
.rope { max-width: 1040px; }
.rope__mast { text-align: center; border-bottom: 3px double var(--chalk); padding-bottom: 10px; margin-bottom: 18px; }
.rope__mast h1 { font: 700 clamp(38px, 9vw, 64px)/1 var(--display); letter-spacing: -.01em; }
.rope__mast p { margin: 8px 0 0; color: var(--dim); font-size: 14px; }
.rope__grid { display: grid; gap: 24px; }
.rope__kicker { margin: 0 0 4px; color: var(--sodium); font: 600 14px/1 var(--display); }
.rope__lead h2 { font: 700 clamp(28px, 6vw, 40px)/1.05 var(--display); margin-bottom: 10px; }
.rope__lead p:last-child { font-size: 18px; line-height: 1.55; max-width: 60ch; margin: 0; }
.rope__more { display: grid; gap: 18px; margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--line); }
.rope__story h2 { font-size: 21px; margin-bottom: 6px; }
.rope__story p:last-child { margin: 0; color: var(--chalk); max-width: 60ch; }
.rope__side { display: grid; gap: 16px; align-content: start; }
.rope__box { border-top: 1px solid var(--line); padding-top: 10px; }
.rope__box h3 { font-size: 15px; color: var(--dim); margin-bottom: 6px; }
.rope__box p, .rope__box ul { margin: 0; }
.rope__box ul { padding-left: 18px; }
.rope__markets { width: 100%; border-collapse: collapse; font-size: 14px; }
.rope__markets th { text-align: left; color: var(--dim); font-weight: 500; }
.rope__markets td, .rope__markets th { padding: 3px 8px 3px 0; border-bottom: 1px solid var(--line); }
.rope__thought p { font: 500 19px/1.35 var(--display); }

/* --- desktop -------------------------------------------------------------- */
@media (min-width: 960px) {
  .app { padding-bottom: 32px; }
  .tabs { position: static; height: auto; padding: 0; background: none; border: 0; justify-content: flex-start; gap: 4px; max-width: 1120px; margin: 0 auto 12px; padding: 0 16px; }
  .tab { flex: none; flex-direction: row; gap: 8px; padding: 10px 14px; font-size: 16px; border-radius: 8px; }
  .tab[aria-current="page"] { background: var(--panel); }
  .tab[aria-current="page"]::after { display: none; }
  .tab__count { position: static; }
  .stop { position: relative; left: auto; right: auto; bottom: auto; width: 300px; height: 48px; }
  .stop__pad, .stop__guard, .stop__resume { font-size: 16px; }
  .desk { grid-template-columns: 1.1fr 1fr; align-items: start; column-gap: 40px; }
  .rope__grid { grid-template-columns: 2fr 1fr; column-gap: 36px; }
  .rope__more { grid-template-columns: 1fr 1fr; column-gap: 28px; }
  .rope__side { border-left: 1px solid var(--line); padding-left: 24px; }
  .toast { bottom: 32px; }
}

@media (prefers-reduced-motion: reduce) {
  .stop__guard { transition: none; }
  .stop[data-state="holding"] .stop__fill { transition: none; transform: scaleX(1); }
}

/* money */
.gate-case { padding: .6rem 0 .9rem; }
.gate-case .prose { font-size: .92rem; margin: .4rem 0 .6rem; }
.gate-case .actions { flex-wrap: wrap; }
