/* OpenFlow — instrument panel for a shared pipe. */

@import url("https://fonts.googleapis.com/css2?family=Bricolage+Grotesque:opsz,wght@12..96,500;12..96,700&family=Inter+Tight:wght@400;500&family=Martian+Mono:wght@400;600&display=swap");

:root {
  --ink: #071316;
  --surface: #0d1f24;
  --raised: #122a30;
  --line: #1b3a42;
  --flow: #2fd4b4;
  --surge: #ff7043;
  --text: #d9ede8;
  --muted: #6e948e;

  --display: "Bricolage Grotesque", ui-sans-serif, system-ui, sans-serif;
  --body: "Inter Tight", ui-sans-serif, system-ui, sans-serif;
  --data: "Martian Mono", ui-monospace, "SF Mono", monospace;

  --gutter: clamp(1.15rem, 5vw, 5rem);
  --shell: 68rem;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--ink);
  color: var(--text);
  font-family: var(--body);
  font-size: 16px;
  line-height: 1.6;
  padding: 0 var(--gutter) 6rem;
}

a { color: var(--flow); text-underline-offset: 3px; }

:focus-visible { outline: 2px solid var(--flow); outline-offset: 3px; border-radius: 2px; }

::selection { background: var(--flow); color: var(--ink); }

/* ---------------------------------------------------------------- masthead */

.masthead {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 2.25rem 0 0;
  max-width: var(--shell);
  margin: 0 auto;
}

.wordmark {
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.4rem;
  letter-spacing: -0.02em;
  margin: 0;
}
.wordmark a { color: inherit; text-decoration: none; }
.wordmark span { color: var(--flow); }

.masthead nav {
  font-family: var(--data);
  font-size: 0.7rem;
  letter-spacing: 0.04em;
  display: flex;
  gap: 1.15rem;
  flex-wrap: wrap;
}
.masthead nav a { color: var(--muted); text-decoration: none; }
.masthead nav a:hover { color: var(--text); }
.masthead nav a[hidden] { display: none; }

/* ------------------------------------------------------------------- shell */

.shell { max-width: var(--shell); margin: 0 auto; }

.thesis {
  font-family: var(--display);
  font-weight: 500;
  font-size: clamp(1.8rem, 5.5vw, 3.4rem);
  line-height: 1.08;
  letter-spacing: -0.03em;
  margin: 3.25rem 0 1rem;
  max-width: 22ch;
}
.thesis em { font-style: normal; color: var(--flow); }

.standfirst { color: var(--muted); max-width: 46ch; margin: 0 0 2.5rem; }

.eyebrow {
  font-family: var(--data);
  font-size: 0.65rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 1rem;
}

.section { margin: 4.5rem 0 0; }

.section > h2 {
  font-family: var(--display);
  font-weight: 500;
  font-size: clamp(1.35rem, 3vw, 1.9rem);
  letter-spacing: -0.02em;
  margin: 0 0 0.5rem;
  max-width: 26ch;
}
.section > p { color: var(--muted); max-width: 52ch; margin: 0; }

/* ------------------------------------------------------------------ gauges */

.rig { border-top: 1px solid var(--line); margin-top: 3rem; }

.rig-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem 1rem;
  flex-wrap: wrap;
  padding: 1.25rem 0 0.75rem;
}

.rig-state {
  font-family: var(--data);
  font-size: 0.65rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0;
}

.pip { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); flex: none; }
.rig-state[data-live="yes"] .pip { background: var(--flow); }
.rig-state[data-live="no"] .pip { background: var(--surge); }

#rig-count { color: var(--line); letter-spacing: 0.1em; }

.sift {
  width: 100%;
  max-width: 18rem;
  background: var(--ink);
  border: 1px solid var(--line);
  border-radius: 5px;
  color: var(--text);
  font-family: var(--data);
  font-size: 0.72rem;
  padding: 0.5rem 0.7rem;
}
.sift:focus { border-color: var(--flow); outline: none; }
.sift::placeholder { color: var(--muted); }

.group { margin: 1.75rem 0 0; }
.group[hidden] { display: none; }

.group-name {
  font-family: var(--data);
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  padding-bottom: 0.6rem;
  border-bottom: 1px solid var(--line);
  margin: 0 0 0.25rem;
}

.gauge {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.2rem 1.25rem;
  align-items: baseline;
  padding: 0.85rem 0 0.95rem;
  border-bottom: 1px solid var(--line);
}
.gauge[hidden] { display: none; }

.gauge-id {
  font-family: var(--data);
  font-size: 0.8rem;
  font-weight: 600;
  word-break: break-all;
}

.gauge-limit {
  font-family: var(--data);
  font-size: 0.7rem;
  color: var(--muted);
  text-align: right;
  white-space: nowrap;
}

.gauge-blurb {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 0.85rem;
  margin: 0.15rem 0 0;
}
.gauge-blurb:empty { display: none; }

.gauge-bar {
  grid-column: 1 / -1;
  height: 5px;
  margin-top: 0.65rem;
  background: var(--raised);
  border-radius: 99px;
  overflow: hidden;
}

.gauge-fill {
  height: 100%;
  width: 100%;
  background: var(--flow);
  border-radius: 99px;
  transition: width 600ms cubic-bezier(0.22, 1, 0.36, 1), background 400ms;
}

.gauge[data-pressure="high"] .gauge-fill { background: var(--surge); }

.gauge[data-state="unlimited"] .gauge-fill {
  background: linear-gradient(90deg, var(--flow), #55e8a2, var(--flow));
  background-size: 200% 100%;
  animation: drift 3.5s linear infinite;
}

.gauge[data-state="idle"] .gauge-fill { background: var(--line); width: 100%; }

/* The landing page lists limits without levels — no bar to draw there. */
.gauge[data-state="listed"] .gauge-bar { display: none; }

.gauge[data-state="offline"] .gauge-fill { background: var(--line); width: 100%; }
.gauge[data-state="offline"] .gauge-id { color: var(--muted); }

@keyframes drift { from { background-position: 0% 0; } to { background-position: 200% 0; } }

@media (prefers-reduced-motion: reduce) {
  .gauge-fill { transition: none; animation: none; }
  html { scroll-behavior: auto; }
}

/* ------------------------------------------------------------------- steps */

.steps {
  display: grid;
  gap: 1.5rem;
  grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
  margin: 2rem 0 0;
  padding: 0;
  list-style: none;
  counter-reset: step;
}

.steps li { counter-increment: step; border-top: 1px solid var(--line); padding-top: 1rem; }

.steps li::before {
  content: counter(step, decimal-leading-zero);
  font-family: var(--data);
  font-size: 0.68rem;
  color: var(--flow);
  display: block;
  margin-bottom: 0.5rem;
}

.steps h3 { font-family: var(--display); font-weight: 500; font-size: 1.05rem; margin: 0 0 0.35rem; }
.steps p { color: var(--muted); font-size: 0.9rem; margin: 0; }

/* -------------------------------------------------------------------- code */

pre {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 1.15rem;
  overflow-x: auto;
  font-family: var(--data);
  font-size: 0.73rem;
  line-height: 1.8;
  margin: 1.5rem 0 0;
}
pre .c { color: var(--muted); }
pre .k { color: var(--flow); }

code { font-family: var(--data); font-size: 0.85em; }

.endpoint { margin: 1.25rem 0 0; font-family: var(--data); font-size: 0.78rem; }

.endpoint code {
  background: var(--surface);
  border: 1px solid var(--flow);
  border-radius: 5px;
  padding: 0.55rem 0.8rem;
  display: inline-block;
  color: var(--flow);
  word-break: break-all;
}

/* ------------------------------------------------------------------ panels */

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: clamp(1.15rem, 3vw, 1.85rem);
}

.rule { border: 0; border-top: 1px solid var(--line); margin: 1.5rem 0; }

/* ------------------------------------------------------------------- forms */

label {
  display: block;
  font-family: var(--data);
  font-size: 0.62rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 1.15rem 0 0.4rem;
}

input, textarea, select {
  width: 100%;
  background: var(--ink);
  border: 1px solid var(--line);
  border-radius: 5px;
  color: var(--text);
  font-family: var(--data);
  font-size: 0.82rem;
  padding: 0.65rem 0.8rem;
}
input:focus, textarea:focus, select:focus { border-color: var(--flow); outline: none; }

textarea { resize: vertical; min-height: 5.5rem; line-height: 1.65; font-family: var(--body); font-size: 0.95rem; }

select { appearance: none; cursor: pointer; }

input[type="file"] {
  padding: 0.5rem;
  font-family: var(--data);
  font-size: 0.72rem;
  cursor: pointer;
}
input[type="file"]::file-selector-button {
  font-family: var(--data);
  font-size: 0.65rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: var(--raised);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0.4rem 0.7rem;
  margin-right: 0.7rem;
  cursor: pointer;
}
input[type="file"]::file-selector-button:hover { border-color: var(--flow); }

details summary::-webkit-details-marker { color: var(--muted); }
option { background: var(--surface); color: var(--text); }

button {
  font-family: var(--data);
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: var(--flow);
  color: var(--ink);
  border: 0;
  border-radius: 5px;
  padding: 0.7rem 1.1rem;
  cursor: pointer;
  font-weight: 600;
  white-space: nowrap;
}
button:hover { filter: brightness(1.1); }
button:disabled { opacity: 0.4; cursor: not-allowed; filter: none; }

button.ghost { background: transparent; color: var(--muted); border: 1px solid var(--line); }
button.ghost:hover { color: var(--text); border-color: var(--flow); filter: none; }

button.tiny { font-size: 0.6rem; padding: 0.42rem 0.7rem; }

.row { display: flex; gap: 0.6rem; flex-wrap: wrap; align-items: center; }
.row.spread { justify-content: space-between; }
.row.tight { gap: 0.4rem; }
.grow { flex: 1; min-width: 10rem; }

.note { font-size: 0.85rem; color: var(--muted); margin: 1rem 0 0; }

.alert {
  font-family: var(--data);
  font-size: 0.7rem;
  line-height: 1.7;
  border-left: 2px solid var(--surge);
  padding: 0.45rem 0 0.45rem 0.8rem;
  margin: 1.15rem 0 0;
  color: var(--text);
}
.alert.good { border-left-color: var(--flow); }
.alert[hidden] { display: none; }

/* -------------------------------------------------------------------- keys */

.stat { font-family: var(--data); font-size: 0.85rem; margin: 0; word-break: break-all; }

.keyrow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1rem;
  flex-wrap: wrap;
  padding: 0.85rem 0;
  border-top: 1px solid var(--line);
}
.keyrow .mono { font-family: var(--data); font-size: 0.76rem; word-break: break-all; }
.keyrow .meta { font-family: var(--data); font-size: 0.62rem; color: var(--muted); letter-spacing: 0.04em; }
.keyrow[data-revoked="true"] .mono { color: var(--muted); text-decoration: line-through; }

.reveal {
  background: var(--ink);
  border: 1px solid var(--flow);
  border-radius: 6px;
  padding: 0.95rem;
  margin: 1.35rem 0 0;
  font-family: var(--data);
  font-size: 0.76rem;
  word-break: break-all;
}
.reveal[hidden] { display: none; }

/* -------------------------------------------------------------- playground */

.play-meter { margin: 1rem 0 0; }

.play-meter .gauge-bar { margin-top: 0.45rem; }

.play-meter .label {
  font-family: var(--data);
  font-size: 0.62rem;
  letter-spacing: 0.08em;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
  gap: 1rem;
}

.reply {
  margin: 1.35rem 0 0;
  padding: 1.05rem 1.15rem;
  background: var(--ink);
  border: 1px solid var(--line);
  border-radius: 6px;
  white-space: pre-wrap;
  word-break: break-word;
  min-height: 3rem;
  font-size: 0.94rem;
  line-height: 1.7;
}
.reply[hidden] { display: none; }
.reply[data-state="error"] { border-color: var(--surge); font-family: var(--data); font-size: 0.72rem; }

.reply .caret {
  display: inline-block;
  width: 7px;
  height: 1em;
  background: var(--flow);
  vertical-align: text-bottom;
  animation: blink 1s steps(2) infinite;
}
@keyframes blink { 50% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .reply .caret { animation: none; } }

/* ------------------------------------------------------------------ footer */

footer {
  max-width: var(--shell);
  margin: 6rem auto 0;
  padding-top: 1.5rem;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-family: var(--data);
  font-size: 0.66rem;
  letter-spacing: 0.04em;
  display: flex;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  flex-wrap: wrap;
}
footer a { color: var(--muted); text-decoration: none; }
footer a:hover { color: var(--text); }

@media (max-width: 34rem) {
  .gauge-limit { font-size: 0.64rem; }
  .sift { max-width: 100%; }
}

/* Easter-egg breadcrumbs. Quiet enough to ignore, loud enough to notice. */
.secret {
  font-family: var(--data);
  font-size: 0.65rem;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin: 1.25rem 0 0;
}

.secret button {
  background: none;
  border: 0;
  padding: 0;
  margin: 0;
  font: inherit;
  letter-spacing: inherit;
  text-transform: none;
  color: var(--muted);
  border-bottom: 1px dotted var(--line);
  cursor: pointer;
}

.secret button:hover { color: var(--flow); border-bottom-color: var(--flow); }

.secret a { color: var(--muted); text-decoration: none; border-bottom: 1px dotted var(--line); }
.secret a:hover { color: var(--flow); border-bottom-color: var(--flow); }

#riddle { font-family: var(--data); font-size: 0.7rem; line-height: 1.8; }

/* ------------------------------------------------------------------ chat */

.chat-body { padding-bottom: 2rem; }

.chat-shell { display: flex; flex-direction: column; gap: 1.25rem; }

.chat-shell #setup[hidden] { display: none; }

.thread {
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
  min-height: 40vh;
  max-height: 62vh;
  overflow-y: auto;
  padding: 0.25rem 0.15rem 0.5rem;
  scroll-behavior: smooth;
}

.thread .empty {
  color: var(--muted);
  font-size: 0.9rem;
  text-align: center;
  margin: auto;
  line-height: 1.9;
}
.thread .empty .dim { color: var(--line); font-size: 0.82rem; }

.msg {
  border-left: 2px solid var(--line);
  padding: 0 0 0 1rem;
  position: relative;
}

.msg[data-role="user"] { border-left-color: var(--muted); }
.msg[data-role="assistant"] { border-left-color: var(--flow); }
.msg[data-role="error"] { border-left-color: var(--surge); }

.msg .who {
  font-family: var(--data);
  font-size: 0.6rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 0.4rem;
}

.msg .body {
  font-size: 0.96rem;
  line-height: 1.72;
  word-break: break-word;
}

.msg .body code {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 0.05rem 0.3rem;
  font-size: 0.85em;
}

.msg .body pre.code {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.9rem 1rem;
  overflow-x: auto;
  font-family: var(--data);
  font-size: 0.72rem;
  line-height: 1.75;
  margin: 0.8rem 0;
  white-space: pre;
}

.msg-tools {
  display: flex;
  gap: 0.35rem;
  margin-top: 0.55rem;
  opacity: 0;
  transition: opacity 150ms;
}
.msg:hover .msg-tools, .msg:focus-within .msg-tools { opacity: 1; }
@media (hover: none) { .msg-tools { opacity: 1; } }

.composer {
  border-top: 1px solid var(--line);
  padding-top: 1.1rem;
}

.composer textarea {
  min-height: 3.4rem;
  font-size: 0.96rem;
}

.composer-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin-top: 0.7rem;
  flex-wrap: wrap;
}

.composer .meta {
  font-family: var(--data);
  font-size: 0.62rem;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin: 0.7rem 0 0;
  min-height: 1em;
}

@media (max-width: 40rem) {
  .thread { max-height: 52vh; }
}

/* ----------------------------------------------------------------- video */

#player {
  width: 100%;
  margin-top: 1.25rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--ink);
  display: block;
}
#player[hidden] { display: none; }

.meta {
  font-family: var(--data);
  font-size: 0.65rem;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin: 0;
}
