@font-face {
  font-family: "Inter Tight";
  src: url("/fonts/of-inter-tight-800.woff2") format("woff2");
  font-weight: 800;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Inter";
  src: url("/fonts/of-inter-400.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "JetBrains Mono";
  src: url("/fonts/of-jetbrains-mono-400.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  --field: #151513;
  --lime: #faff69;
  --grey: #414141;
  --panel: #1c1c19;
  --panel-hi: #242420;
  --ink: #f4f4ef;
  --dim: #8d8d83;
  --dimmer: #5e5e57;
  --display: "Inter Tight", "Helvetica Neue", Arial, sans-serif;
  --body: "Inter", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --pad: clamp(16px, 3.2vw, 44px);
}

*,
*::before,
*::after { box-sizing: border-box; }

html { height: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--field);
  color: var(--ink);
  font-family: var(--body);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  -webkit-text-size-adjust: 100%;
  text-rendering: optimizeLegibility;
}

/* ---- mast ---- */

.mast {
  flex: 0 0 auto;
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: clamp(14px, 2vw, 24px) var(--pad) 0;
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--dim);
}

.mast .mark {
  font-family: var(--display);
  font-weight: 800;
  color: var(--ink);
  letter-spacing: -0.01em;
  text-transform: none;
  font-size: 15px;
}

.mast .slash { color: var(--dimmer); }

/* ---- stage: the display line, then the shrinking stack ---- */

.stage {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 0 var(--pad);
  overflow: hidden;
}

.hero-wrap {
  flex: 0 0 auto;
  min-height: 0;
  display: flex;
  align-items: flex-end;
  padding: clamp(10px, 2vh, 26px) 0 clamp(14px, 2.4vh, 30px);
}

.hero {
  width: 100%;
  margin: 0;
  border-top: 1px solid var(--panel-hi);
  border-bottom: 1px solid var(--panel-hi);
  padding: clamp(10px, 2vh, 26px) 0 clamp(12px, 2.2vh, 28px);
}

.hero-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  margin: 0 0 clamp(8px, 1.4vh, 16px);
  font-family: var(--mono);
  font-size: clamp(10px, 1vw, 12px);
  letter-spacing: 0.06em;
  color: var(--dim);
  text-transform: lowercase;
}

.hero-meta .metalevel { color: var(--dimmer); }

.hero-text {
  margin: 0;
  font-family: var(--display);
  font-weight: 800;
  font-size: clamp(2rem, 4.6vw, 5rem);
  line-height: 0.94;
  letter-spacing: -0.035em;
  color: var(--ink);
  text-wrap: balance;
  overflow-wrap: anywhere;
  hyphens: none;
}

.hero.is-open .hero-text { color: var(--ink); }
.hero.is-err .hero-text { color: var(--lime); }

.hero.placeholder .hero-text {
  color: var(--dimmer);
  font-size: clamp(1.6rem, 3.2vw, 3.2rem);
  letter-spacing: -0.025em;
}

.hero.is-err .metalevel { color: var(--lime); }

/* the re-set: the whole display line is replaced, never patched */
.hero.sets {
  animation: reset 620ms cubic-bezier(0.2, 0.85, 0.25, 1) both;
}

@keyframes reset {
  from {
    opacity: 0;
    transform: translateY(0.34em);
    filter: blur(6px);
  }
  60% { filter: blur(0); }
  to {
    opacity: 1;
    transform: none;
    filter: blur(0);
  }
}

/* ---- the dim stack of older lines ---- */

.stack {
  flex: 0 1 auto;
  min-height: 0;
  max-height: 34vh;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-bottom: clamp(10px, 2vh, 22px);
  scrollbar-width: thin;
  scrollbar-color: var(--panel-hi) transparent;
  -webkit-mask-image: linear-gradient(to bottom, #000 0%, #000 72%, transparent 100%);
  mask-image: linear-gradient(to bottom, #000 0%, #000 72%, transparent 100%);
  mask-repeat: no-repeat;
  mask-size: 100% 100%;
}

.line {
  display: flex;
  align-items: baseline;
  gap: clamp(8px, 1.2vw, 18px);
  padding: 3px 0;
  font-family: var(--mono);
  font-size: clamp(10px, 0.86vw, 12px);
  line-height: 1.42;
  color: var(--dim);
}

.line .lts {
  flex: 0 0 auto;
  color: var(--dimmer);
  letter-spacing: 0.03em;
}

.line .llvl {
  flex: 0 0 auto;
  width: 5.5ch;
  color: var(--dimmer);
  text-transform: lowercase;
}

.line .lvl-warn .llvl,
.line.warn .llvl { color: #c9c98a; }
.line.err .llvl,
.line.error .llvl { color: var(--lime); }

.line .ltext {
  flex: 1 1 auto;
  min-width: 0;
  color: var(--dim);
  overflow-wrap: anywhere;
}

.line.err .ltext,
.line.error .ltext { color: var(--lime); }

.line.fresh { animation: settle 700ms ease-out both; }

@keyframes settle {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: none; }
}

/* ---- cadence bar: one cycle of the router's interval ---- */

.cadence {
  flex: 0 0 auto;
  height: 2px;
  background: var(--panel-hi);
  overflow: hidden;
}

.cadence-fill {
  display: block;
  height: 100%;
  width: 0;
  background: var(--lime);
  opacity: 0.5;
  transition: width 120ms linear;
}

/* ---- control bar ---- */

.bar {
  flex: 0 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px clamp(8px, 1.4vw, 16px);
  padding: 10px var(--pad) 12px;
  border-top: 1px solid var(--panel-hi);
  background: var(--field);
}

.ctl {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1 1 320px;
  min-width: 0;
}

.klabel {
  flex: 0 0 auto;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--dim);
}

.kinput {
  flex: 1 1 auto;
  min-width: 0;
  max-width: 220px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--grey);
  border-radius: 2px;
  padding: 7px 9px;
  outline: none;
}

.kinput::placeholder { color: var(--dimmer); }

.kinput:focus-visible,
.btn:focus-visible {
  border-color: var(--lime);
  outline: 2px solid rgba(250, 255, 105, 0.45);
  outline-offset: 1px;
}

.btn {
  flex: 0 0 auto;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--grey);
  border-radius: 2px;
  padding: 7px 11px;
  cursor: pointer;
  transition: background 140ms ease, border-color 140ms ease, color 140ms ease;
}

.btn:hover { background: var(--panel-hi); border-color: var(--dimmer); }

.btn[aria-pressed="true"] {
  color: var(--field);
  background: var(--lime);
  border-color: var(--lime);
}

.btn.done {
  color: var(--field);
  background: var(--lime);
  border-color: var(--lime);
}

.btn[disabled] { cursor: default; opacity: 0.55; }

.state {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--dim);
}

.state .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--grey);
}

.state[data-state="open"] { color: var(--lime); }
.state[data-state="open"] .dot { background: var(--lime); }

.state[data-state="connecting"] .dot { background: var(--dim); animation: pulse 1.1s ease-in-out infinite; }
.state[data-state="closed"] .dot { background: var(--grey); }
.state[data-state="closed"] { color: var(--dim); }

@keyframes pulse {
  0%, 100% { opacity: 0.25; }
  50% { opacity: 1; }
}

.gloss {
  flex: 1 1 100%;
  margin: 0;
  font-family: var(--mono);
  font-size: 10px;
  line-height: 1.5;
  letter-spacing: 0.02em;
  color: var(--dimmer);
}

.gloss code {
  font-family: var(--mono);
  color: var(--dim);
}

.clip {
  position: fixed;
  top: 0;
  left: 0;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

/* ---- reduced motion ---- */

@media (prefers-reduced-motion: reduce) {
  .hero.sets,
  .line.fresh { animation: none; }
  .cadence-fill { transition: none; }
  .state[data-state="connecting"] .dot { animation: none; opacity: 1; }
  .btn { transition: none; }
}

@media (max-width: 720px) {
  .hero-text { font-size: clamp(1.7rem, 8.4vw, 3rem); }
  .stack { max-height: 30vh; }
  .kinput { max-width: none; }
}
