/* =================================================================
   openbun.org — the face
   one palette, real hierarchy, breathing whitespace.
   stdlib only — no build, no framework, no webfont fetch required.
   ================================================================= */

:root {
  /* ink — deep, slightly warm, never flat black */
  --ink-900: #0b0d12;
  --ink-850: #0f1218;
  --ink-800: #131722;
  --ink-750: #181d29;
  --ink-700: #1d2330;
  --line:    #262d3c;
  --line-soft: #1c2230;

  /* text */
  --fg:      #e8ebf2;
  --fg-soft: #aab2c5;
  --fg-mute: #6b7488;
  --fg-faint:#454d5f;

  /* accent — warm amber, the "bun rising" warmth */
  --amber:   #f5b14c;
  --amber-bright: #ffc266;
  --amber-deep:   #c8893a;
  --amber-glow:   rgba(245, 177, 76, 0.14);

  /* state */
  --ok:   #57d9a3;
  --busy: #f5b14c;
  --idle: #586079;

  /* ticker category tints — subtle, drawn from the engine palette. Each rail
     topic renders CATEGORY · subcategory · value with a faint per-category hue. */
  --cat-telemetry:  #6c8cd5;   /* throughput / middleway / health — bridge blue */
  --cat-commerce:   #f5b14c;   /* tickets — amber, the commerce lane */
  --cat-directives: #57d9a3;   /* agent-directives / instructions — ok green */
  --cat-guidance:   #b890e0;   /* hints / tips & tricks — soft violet */
  --cat-protocol:   #5fb3a3;   /* ports / protocols / services / tunnel / seal — teal */

  --radius: 14px;
  --radius-sm: 9px;

  --mono: ui-monospace, "SF Mono", "JetBrains Mono", "Cascadia Code", Menlo, Consolas, monospace;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;

  --shadow-card: 0 30px 80px -30px rgba(0,0,0,0.75), 0 1px 0 rgba(255,255,255,0.03) inset;
}

* { box-sizing: border-box; }

/* a class-level `display` (grid/flex) beats the UA [hidden] rule —
   make [hidden] authoritative so the gate↔shell toggle actually hides. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--ink-900);
  color: var(--fg);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body {
  min-height: 100dvh;
}

/* ===========================  THE GATE (login)  ========================= */

.gate {
  position: relative;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 2rem;
  overflow: hidden;
  /* a quiet, deep field — radial warmth from below */
  background:
    radial-gradient(120% 80% at 50% 118%, rgba(245,177,76,0.10), transparent 55%),
    radial-gradient(90% 70% at 50% -20%, rgba(86,120,200,0.08), transparent 60%),
    var(--ink-900);
}

/* a slow breathing aura behind the card */
.gate__aura {
  position: absolute;
  width: 620px; height: 620px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--amber-glow), transparent 62%);
  filter: blur(20px);
  animation: breathe 9s ease-in-out infinite;
  pointer-events: none;
}
@keyframes breathe {
  0%, 100% { transform: scale(1);    opacity: 0.55; }
  50%      { transform: scale(1.12); opacity: 0.9;  }
}

.card {
  position: relative;
  width: min(400px, 100%);
  background: linear-gradient(180deg, var(--ink-800), var(--ink-850));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 2.6rem 2.4rem 1.5rem;
  animation: rise 0.7s cubic-bezier(.2,.7,.2,1) both;
}
@keyframes rise {
  from { opacity: 0; transform: translateY(14px) scale(.985); }
  to   { opacity: 1; transform: none; }
}

/* a hairline of warmth across the top edge */
.card::before {
  content: "";
  position: absolute; inset: 0 0 auto 0; height: 1px;
  background: linear-gradient(90deg, transparent, var(--amber), transparent);
  opacity: 0.5;
}

.brand { text-align: center; margin-bottom: 2.1rem; }

.brand__engine {
  display: inline-block;
  margin: 0 0 0.95rem;
  font-family: var(--mono);
  font-size: 0.66rem;
  letter-spacing: 0.26em;
  text-transform: uppercase;
  color: var(--fg-faint);
}

.brand__name {
  margin: 0;
  font-size: 2.15rem;
  font-weight: 680;
  letter-spacing: -0.03em;
  line-height: 1;
  color: var(--fg);
}
.brand__dot { color: var(--fg-mute); font-weight: 500; }

.brand__tag {
  margin: 0.8rem 0 0;
  font-size: 0.9rem;
  color: var(--fg-soft);
  letter-spacing: 0.01em;
}

/* form */
.form { display: flex; flex-direction: column; gap: 1.05rem; }

.field { display: flex; flex-direction: column; gap: 0.45rem; }

.field__label {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--fg-mute);
  padding-left: 0.1rem;
}

.field__input {
  appearance: none;
  width: 100%;
  background: var(--ink-900);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0.82rem 0.9rem;
  font-size: 0.95rem;
  font-family: var(--sans);
  color: var(--fg);
  transition: border-color .18s ease, box-shadow .18s ease, background .18s ease;
}
.field__input::placeholder { color: var(--fg-faint); }
.field__input:focus {
  outline: none;
  border-color: var(--amber-deep);
  background: var(--ink-850);
  box-shadow: 0 0 0 3px var(--amber-glow);
}

.btn {
  margin-top: 0.4rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  width: 100%;
  padding: 0.86rem 1rem;
  border: none;
  border-radius: var(--radius-sm);
  background: linear-gradient(180deg, var(--amber-bright), var(--amber-deep));
  color: #1a1206;
  font-size: 0.95rem;
  font-weight: 680;
  font-family: var(--sans);
  letter-spacing: -0.01em;
  cursor: pointer;
  transition: transform .12s ease, box-shadow .18s ease, filter .18s ease;
  box-shadow: 0 10px 26px -12px rgba(245,177,76,0.55);
}
.btn:hover { transform: translateY(-1px); filter: brightness(1.04); box-shadow: 0 16px 32px -12px rgba(245,177,76,0.6); }
.btn:active { transform: translateY(0); filter: brightness(0.97); }
.btn__arrow { transition: transform .18s ease; }
.btn:hover .btn__arrow { transform: translateX(3px); }

.form__hint {
  margin: 0.5rem 0 0;
  text-align: center;
  font-size: 0.78rem;
  color: var(--fg-faint);
  letter-spacing: 0.01em;
}

.card__foot {
  margin-top: 1.7rem;
  padding-top: 1.1rem;
  border-top: 1px solid var(--line-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}
.card__footlabel {
  font-size: 0.74rem;
  color: var(--fg-mute);
  font-family: var(--mono);
  letter-spacing: 0.02em;
}

.dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--idle);
  display: inline-block;
  flex: none;
}
.dot--ok { background: var(--ok); box-shadow: 0 0 10px rgba(87,217,163,0.6); }

.gate__engine {
  position: absolute;
  bottom: 1.4rem;
  width: 100%;
  text-align: center;
  margin: 0;
  font-family: var(--mono);
  font-size: 0.64rem;
  letter-spacing: 0.22em;
  color: var(--fg-faint);
  text-transform: uppercase;
}

/* ===========================  THE SHELL  ========================= */

.shell {
  /* hard-bound the cockpit to the viewport: the page itself never scrolls.
     top ticker · panes (flex middle) · bottom ticker live inside this box;
     the terminal/board/editor scroll WITHIN their own panes, never growing
     the page. height (not min-height) + overflow:hidden is what bounds it. */
  height: 100dvh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: var(--ink-900);
  animation: shellin 0.55s cubic-bezier(.2,.7,.2,1) both;
}
@keyframes shellin {
  from { opacity: 0; transform: scale(1.01); }
  to   { opacity: 1; transform: none; }
}

/* top bar */
.topbar {
  display: flex;
  align-items: center;
  gap: 1.4rem;
  padding: 0.7rem 1.2rem;
  background: var(--ink-850);
  border-bottom: 1px solid var(--line);
  flex: none;
}
.topbar__brand { display: flex; align-items: baseline; gap: 0.6rem; }
.topbar__name { font-weight: 680; letter-spacing: -0.02em; font-size: 1.02rem; }
.topbar__engine {
  font-family: var(--mono);
  font-size: 0.64rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--fg-faint);
  padding-left: 0.6rem;
  border-left: 1px solid var(--line);
}
.topbar__crumbs { display: flex; align-items: center; gap: 0.9rem; flex: 1; }
.crumb { font-size: 0.8rem; color: var(--fg-mute); }
.crumb em { color: var(--fg-soft); font-style: normal; }
.crumb--active { color: var(--fg); font-weight: 600; }
.topbar__right { display: flex; align-items: center; gap: 0.8rem; }
.pill {
  font-size: 0.72rem; color: var(--ok);
  background: rgba(87,217,163,0.1);
  border: 1px solid rgba(87,217,163,0.25);
  padding: 0.22rem 0.6rem; border-radius: 999px;
  font-family: var(--mono); letter-spacing: 0.02em;
}
.ghostbtn {
  background: transparent; border: 1px solid var(--line);
  color: var(--fg-soft); font-size: 0.78rem;
  padding: 0.32rem 0.7rem; border-radius: 7px; cursor: pointer;
  transition: border-color .15s, color .15s;
}
.ghostbtn:hover { border-color: var(--fg-mute); color: var(--fg); }

/* ticker strip */
.ticker {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  height: 38px;
  padding: 0 1.2rem;
  background: linear-gradient(90deg, var(--ink-800), var(--ink-850));
  border-bottom: 1px solid var(--line);
  flex: none;
  overflow: hidden;
}
.ticker__lead {
  display: flex; align-items: center; gap: 0.5rem;
  font-family: var(--mono); font-size: 0.74rem;
  color: var(--amber); letter-spacing: 0.04em;
  flex: none; padding-right: 0.9rem;
  border-right: 1px solid var(--line);
}
.ticker__viewport { flex: 1; overflow: hidden; position: relative; height: 100%; }
.ticker__track {
  display: flex; align-items: center; gap: 2.6rem;
  height: 100%;
  white-space: nowrap;
  will-change: transform;
  animation: marquee 38s linear infinite;
}
.ticker:hover .ticker__track { animation-play-state: paused; }
@keyframes marquee {
  from { transform: translateX(0); }
  to   { transform: translateX(-50%); }
}

/* bottom rail — the protocol/status feed. Sits at the foot of the bounded
   shell, border on TOP (mirror of the top rail's bottom border), and its
   track scrolls the OTHER way. */
.ticker--bottom {
  border-bottom: none;
  border-top: 1px solid var(--line);
  background: linear-gradient(90deg, var(--ink-850), var(--ink-800));
}
.ticker__lead--proto { color: var(--ok); border-right-color: var(--line); }
/* opposite-direction marquee: starts shifted and slides back to 0 */
.ticker__track--down { animation-name: marquee-down; }
@keyframes marquee-down {
  from { transform: translateX(-50%); }
  to   { transform: translateX(0); }
}
.tick {
  display: inline-flex; align-items: baseline; gap: 0.32rem;
  font-size: 0.78rem; color: var(--fg-soft);
  font-family: var(--mono);
}
.tick__k { color: var(--fg-mute); }
.tick__v { color: var(--fg); }
.tick__v--amber { color: var(--amber); }
.tick__v--ok { color: var(--ok); }
.tick__sep { color: var(--fg-faint); }

/* CATEGORY · subcategory · value — the categorized topic shape.
   The category label carries a subtle per-category tint; the inner dots are
   faint separators. A hairline left accent keys the whole topic to its hue. */
.tick__cat {
  text-transform: uppercase;
  font-size: 0.66rem;
  letter-spacing: 0.07em;
  color: var(--fg-mute);
}
.tick__dot { color: var(--fg-faint); margin: 0 0.06rem; }
.tick {
  padding-left: 0.55rem;
  border-left: 2px solid transparent;
}
.tick--telemetry  { border-left-color: var(--cat-telemetry); }
.tick--telemetry  .tick__cat { color: var(--cat-telemetry); }
.tick--commerce   { border-left-color: var(--cat-commerce); }
.tick--commerce   .tick__cat { color: var(--cat-commerce); }
.tick--directives { border-left-color: var(--cat-directives); }
.tick--directives .tick__cat { color: var(--cat-directives); }
.tick--guidance   { border-left-color: var(--cat-guidance); }
.tick--guidance   .tick__cat { color: var(--cat-guidance); }
.tick--protocol   { border-left-color: var(--cat-protocol); }
.tick--protocol   .tick__cat { color: var(--cat-protocol); }

/* three panes */
.panes {
  flex: 1;
  display: grid;
  grid-template-columns: 1.35fr 1fr 0.9fr;
  gap: 1px;
  background: var(--line);
  min-height: 0;
}
.pane {
  background: var(--ink-850);
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
}
.pane__head {
  display: flex; align-items: baseline; gap: 0.6rem;
  padding: 0.7rem 1rem;
  border-bottom: 1px solid var(--line-soft);
  flex: none;
}
.pane__title { font-size: 0.78rem; font-weight: 650; letter-spacing: 0.05em; text-transform: uppercase; color: var(--fg-soft); }
.pane__sub { font-size: 0.74rem; color: var(--fg-mute); font-family: var(--mono); }

/* workspace pane */
.workspace { flex: 1; display: grid; grid-template-columns: 150px 1fr; min-height: 0; }
.tree {
  border-right: 1px solid var(--line-soft);
  padding: 0.7rem 0.5rem;
  overflow: auto;
  font-size: 0.82rem;
}
.tree__list, .tree ul { list-style: none; margin: 0; padding: 0; }
.tree ul { padding-left: 0.85rem; }
.tree__dir, .tree__file {
  padding: 0.2rem 0.4rem; border-radius: 6px; color: var(--fg-soft); cursor: default;
}
.tree__dir { color: var(--fg); font-weight: 600; }
.tree__dir::before { content: "▸ "; color: var(--fg-mute); }
.tree__dir--open::before { content: "▾ "; color: var(--amber); }
.tree__file::before { content: ""; }
.tree__file--active { background: var(--amber-glow); color: var(--amber-bright); }
.tree__file:hover { background: var(--ink-800); }

.editor { display: flex; flex-direction: column; min-height: 0; }
.editor__tab {
  padding: 0.4rem 0.9rem; font-size: 0.78rem; color: var(--fg);
  font-family: var(--mono);
  border-bottom: 1px solid var(--line-soft);
  background: var(--ink-800);
  width: fit-content;
  border-right: 1px solid var(--line-soft);
  border-radius: 0 0 0 0;
}
.editor__code {
  margin: 0; padding: 1rem 1.1rem; overflow: auto; flex: 1; min-height: 0;
  font-family: var(--mono); font-size: 0.82rem; line-height: 1.65;
  color: var(--fg-soft);
}
.c-kw { color: #c792ea; }
.c-ty { color: var(--amber); }
.c-fn { color: #82aaff; }
.c-st { color: var(--ok); }

/* terminal pane */
.term {
  flex: 1; min-height: 0;
  background: var(--ink-900);
  padding: 0.85rem 1rem;
  font-family: var(--mono); font-size: 0.8rem; line-height: 1.6;
  color: var(--fg-soft);
  /* the term box is bounded; only its inner scroll region moves */
  overflow: hidden;
  display: flex; flex-direction: column;
}
/* the actual scroll region — command output scrolls HERE, never the page.
   min-height:0 lets it shrink inside the flex column so overflow engages. */
.term__scroll { flex: 1; min-height: 0; overflow-y: auto; }
/* keep the live prompt pinned to the bottom of the terminal */
.term__input { flex: none; }
.term__row { white-space: pre-wrap; word-break: break-word; }
.term__row--cmd { color: var(--fg); }
.term__row--ok  { color: var(--ok); }
.term__row--info { color: var(--fg-mute); }
.term__row--amber { color: var(--amber); }
.term__prompt { color: var(--amber); }
.term__cwd { color: var(--fg-mute); }
.term__line { display: flex; align-items: center; gap: 0.5rem; }
.term__field {
  flex: 1; min-width: 0;
  background: transparent; border: none; outline: none;
  color: var(--fg); caret-color: var(--amber);
  font-family: var(--mono); font-size: 0.8rem; line-height: 1.6;
  padding: 0;
}
.term__field::placeholder { color: var(--fg-mute); }
@keyframes blink { 50% { opacity: 0; } }

/* board pane */
.board { flex: 1; min-height: 0; overflow: auto; padding: 0.8rem; display: flex; flex-direction: column; gap: 1rem; }
.col__head {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 0.72rem; font-weight: 650; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--fg-mute); margin-bottom: 0.5rem;
}
.col__count {
  font-family: var(--mono); background: var(--ink-800);
  border: 1px solid var(--line-soft); border-radius: 999px;
  padding: 0.05rem 0.45rem; color: var(--fg-soft); font-size: 0.68rem;
}
.cards { display: flex; flex-direction: column; gap: 0.5rem; }
.tcard {
  background: var(--ink-800);
  border: 1px solid var(--line-soft);
  border-left: 2px solid var(--line);
  border-radius: 8px;
  padding: 0.6rem 0.7rem;
  font-size: 0.8rem; color: var(--fg);
  transition: border-color .15s, transform .15s;
}
.tcard:hover { transform: translateX(2px); border-left-color: var(--amber-deep); }
.tcard--p   { border-left-color: var(--amber); }
.tcard--ok  { border-left-color: var(--ok); }
.tcard__meta { margin-top: 0.35rem; font-size: 0.68rem; color: var(--fg-mute); font-family: var(--mono); display: flex; gap: 0.5rem; }
.tag {
  font-family: var(--mono); font-size: 0.64rem; padding: 0.04rem 0.34rem;
  border-radius: 4px; background: var(--ink-750); color: var(--fg-soft);
}
.tag--p { background: var(--amber-glow); color: var(--amber-bright); }

/* dot states reused in shell */
#tickerDot { background: var(--amber); box-shadow: 0 0 9px rgba(245,177,76,0.6); animation: pulse 2.4s ease-in-out infinite; }
#protoDot  { background: var(--ok);    box-shadow: 0 0 9px rgba(87,217,163,0.6); animation: pulse 2.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.45; } }

/* responsive — stack panes on narrow */
@media (max-width: 1000px) {
  .panes { grid-template-columns: 1fr; grid-auto-rows: minmax(220px, auto); }
  .topbar__crumbs { display: none; }
}

/* respect reduced motion */
@media (prefers-reduced-motion: reduce) {
  .gate__aura, .ticker__track, .ticker__track--down, #tickerDot, #protoDot { animation: none; }
}
