/* DevOps Arena design system: terminal obsidian + signal green + electric cyan */
:root {
  --bg: #08090c;
  --surface: #0e1117;
  --surface-2: #161b22;
  --surface-3: #1c232d;
  --border: #232a34;
  --border-hi: #2f3947;
  --text: #e6edf3;
  --muted: #8b949e;
  --faint: #5b6572;
  --green: #00f59b;
  --green-2: #10b981;
  --cyan: #00d2ff;
  --cyan-2: #38bdf8;
  --amber: #f59e0b;
  --red: #ef4444;
  --mono: "JetBrains Mono", "Fira Code", ui-monospace, Menlo, Consolas, monospace;
  --sans: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --radius: 12px;
  --glow-green: 0 0 0 1px rgba(0, 245, 155, .35), 0 0 24px rgba(0, 245, 155, .18);
  --nav-h: 60px;
}
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text); font-family: var(--sans); font-size: 16px; line-height: 1.6;
  background-image: linear-gradient(rgba(255,255,255,.025) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.025) 1px, transparent 1px);
  background-size: 44px 44px; min-height: 100vh;
}
a { color: var(--cyan-2); text-decoration: none; }
a:hover { color: var(--cyan); }
img { max-width: 100%; }
code, pre, kbd { font-family: var(--mono); }
:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; border-radius: 4px; }
::selection { background: rgba(0, 245, 155, .3); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.wrap { width: min(1200px, 100% - 32px); margin-inline: auto; }
.mono { font-family: var(--mono); }
.muted { color: var(--muted); }
.green { color: var(--green); } .cyan { color: var(--cyan-2); } .amber { color: var(--amber); } .red { color: var(--red); }

/* ---------- nav ---------- */
.nav { position: sticky; top: 0; z-index: 50; height: var(--nav-h); background: rgba(8, 9, 12, .82); backdrop-filter: blur(14px); border-bottom: 1px solid var(--border); }
.nav .wrap { height: 100%; display: flex; align-items: center; gap: 24px; }
.brand { display: flex; align-items: center; gap: 10px; font-family: var(--mono); font-weight: 700; color: var(--text); letter-spacing: -.02em; }
.brand:hover { color: var(--text); }
.brand svg { width: 26px; height: 26px; }
.brand b { color: var(--green); font-weight: 700; }
.nav-links { display: flex; gap: 4px; margin-left: 12px; }
.nav-links a { color: var(--muted); font-size: .9rem; font-weight: 500; padding: 8px 12px; border-radius: 8px; }
.nav-links a:hover { color: var(--text); background: var(--surface-2); }
.nav-links a[aria-current="page"] { color: var(--green); background: rgba(0, 245, 155, .08); }
.nav-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.nav-user { display: flex; align-items: center; gap: 8px; font-family: var(--mono); font-size: .82rem; color: var(--text); padding: 4px 10px 4px 4px; border: 1px solid var(--border); border-radius: 999px; }
.nav-user img { width: 24px; height: 24px; border-radius: 50%; background: var(--surface-2); }
.nav-user:hover { border-color: var(--green); color: var(--text); }
.nav-toggle { display: none; background: none; border: 1px solid var(--border); color: var(--text); border-radius: 8px; width: 40px; height: 40px; font-size: 1.1rem; cursor: pointer; }
@media (max-width: 820px) {
  .nav-toggle { display: inline-flex; align-items: center; justify-content: center; margin-left: auto; }
  .nav-right { margin-left: 0; }
  .nav .wrap { flex-wrap: wrap; height: auto; min-height: var(--nav-h); padding-block: 9px; gap: 8px; }
  .nav-links, .nav-right { display: none; width: 100%; }
  .nav.open .nav-links { display: flex; flex-direction: column; }
  .nav.open .nav-right { display: flex; padding-bottom: 6px; }
}

/* ---------- buttons / pills ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; font: 600 .92rem var(--sans); padding: 10px 18px; border-radius: 10px; border: 1px solid var(--border-hi); background: var(--surface-2); color: var(--text); cursor: pointer; transition: transform .15s, box-shadow .15s, border-color .15s, background .15s; white-space: nowrap; }
.btn:hover { border-color: var(--cyan-2); color: var(--text); transform: translateY(-1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--green); border-color: var(--green); color: #04130d; }
.btn-primary:hover { color: #04130d; box-shadow: var(--glow-green); border-color: var(--green); }
.btn-cyan { background: rgba(0, 210, 255, .1); border-color: rgba(0, 210, 255, .5); color: var(--cyan); }
.btn-sm { padding: 6px 12px; font-size: .82rem; border-radius: 8px; }
.btn-lg { padding: 14px 26px; font-size: 1rem; }
.pill { display: inline-flex; align-items: center; gap: 6px; font: 600 .72rem var(--mono); text-transform: uppercase; letter-spacing: .06em; padding: 3px 10px; border-radius: 999px; border: 1px solid; }
.pill.easy { color: var(--green-2); border-color: rgba(16, 185, 129, .45); background: rgba(16, 185, 129, .08); }
.pill.medium { color: var(--cyan-2); border-color: rgba(56, 189, 248, .45); background: rgba(56, 189, 248, .08); }
.pill.hard { color: var(--amber); border-color: rgba(245, 158, 11, .5); background: rgba(245, 158, 11, .08); }
.pill.incident { color: var(--red); border-color: rgba(239, 68, 68, .55); background: rgba(239, 68, 68, .1); }
.pill.cat { color: var(--muted); border-color: var(--border-hi); background: var(--surface-2); text-transform: none; letter-spacing: 0; font-weight: 500; }
.pill.solved { color: var(--green); border-color: rgba(0, 245, 155, .5); background: rgba(0, 245, 155, .08); }
.pill.attempted { color: var(--amber); border-color: rgba(245, 158, 11, .5); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); display: inline-block; }
.dot.ok { background: var(--green); box-shadow: 0 0 0 0 rgba(0, 245, 155, .6); animation: pulse 2s infinite; }
.dot.bad { background: var(--red); }
.dot.warn { background: var(--amber); }
@keyframes pulse { 70% { box-shadow: 0 0 0 8px rgba(0, 245, 155, 0); } 100% { box-shadow: 0 0 0 0 rgba(0, 245, 155, 0); } }

/* ---------- layout blocks ---------- */
section.block { padding: 72px 0; position: relative; }
.eyebrow { font: 600 .78rem var(--mono); letter-spacing: .14em; text-transform: uppercase; color: var(--green); display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.eyebrow::before { content: "//"; color: var(--faint); }
h1, h2, h3, h4 { line-height: 1.2; letter-spacing: -.02em; margin: 0 0 .5em; }
h1 { font-size: clamp(2.2rem, 5.2vw, 3.8rem); font-weight: 800; }
h2 { font-size: clamp(1.6rem, 3.2vw, 2.3rem); font-weight: 800; }
h3 { font-size: 1.15rem; font-weight: 700; }
.lead { font-size: 1.08rem; color: var(--muted); max-width: 62ch; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; transition: border-color .2s, transform .2s; }
.card.hover:hover { border-color: rgba(0, 245, 155, .5); transform: translateY(-2px); }
.grid { display: grid; gap: 16px; }
.grid.c2 { grid-template-columns: repeat(2, 1fr); }
.grid.c3 { grid-template-columns: repeat(3, 1fr); }
.grid.c4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 960px) { .grid.c3, .grid.c4 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 640px) { .grid.c2, .grid.c3, .grid.c4 { grid-template-columns: 1fr; } section.block { padding: 48px 0; } }
.stat { font: 800 2rem var(--mono); color: var(--green); letter-spacing: -.03em; line-height: 1.1; }
.stat small { display: block; font: 500 .78rem var(--sans); color: var(--muted); letter-spacing: 0; margin-top: 6px; }

/* ---------- terminal ---------- */
.term { background: #05070a; border: 1px solid var(--border-hi); border-radius: var(--radius); overflow: hidden; box-shadow: 0 20px 60px rgba(0, 0, 0, .5), 0 0 0 1px rgba(0, 245, 155, .05); font-family: var(--mono); }
.term-bar { display: flex; align-items: center; gap: 8px; padding: 10px 14px; background: var(--surface-2); border-bottom: 1px solid var(--border); font-size: .76rem; color: var(--muted); }
.term-bar i { width: 11px; height: 11px; border-radius: 50%; display: inline-block; }
.term-bar i:nth-child(1) { background: #ff5f57; } .term-bar i:nth-child(2) { background: #febc2e; } .term-bar i:nth-child(3) { background: #28c840; }
.term-bar span { margin-left: 8px; }
.term-body { padding: 14px 16px; font-size: .82rem; line-height: 1.65; height: 340px; overflow-y: auto; white-space: pre-wrap; word-break: break-word; color: #c9d4df; }
.term-body .ln { display: block; min-height: 1.65em; }
.term-body .ps { color: var(--green); } .term-body .ps2 { color: var(--cyan-2); }
.term-input { display: flex; align-items: center; gap: 8px; padding: 0 16px 14px; font-size: .82rem; }
.term-input input { flex: 1; background: transparent; border: 0; color: var(--text); font: inherit; caret-color: var(--green); outline: none; min-width: 0; }
.ansi-red { color: #ff6b6b; } .ansi-green { color: #3ddc97; } .ansi-yellow { color: #f5c542; } .ansi-cyan { color: #4cd7f6; } .ansi-bold { font-weight: 700; } .ansi-dim { opacity: .6; }
.cursor::after { content: "▋"; color: var(--green); animation: blink 1s steps(2) infinite; margin-left: 1px; }
@keyframes blink { 50% { opacity: 0; } }

/* ---------- forms ---------- */
.field { display: grid; gap: 6px; margin-bottom: 16px; }
.field label { font: 600 .8rem var(--mono); color: var(--muted); }
.input, select.input { width: 100%; background: var(--bg); border: 1px solid var(--border-hi); color: var(--text); border-radius: 10px; padding: 11px 14px; font: 500 .95rem var(--sans); }
.input:focus { border-color: var(--green); outline: none; box-shadow: 0 0 0 3px rgba(0, 245, 155, .12); }
.form-msg { font-size: .88rem; min-height: 1.3em; margin: 4px 0 12px; }
.form-msg.err { color: var(--red); } .form-msg.ok { color: var(--green); }

/* ---------- arena grid ---------- */
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 24px 0 8px; }
.chip { border: 1px solid var(--border-hi); background: var(--surface); color: var(--muted); font: 600 .78rem var(--mono); padding: 6px 12px; border-radius: 999px; cursor: pointer; transition: all .15s; }
.chip:hover { color: var(--text); border-color: var(--cyan-2); }
.chip[aria-pressed="true"] { background: rgba(0, 245, 155, .12); border-color: var(--green); color: var(--green); }
.search { position: relative; flex: 1 1 260px; max-width: 420px; }
.search input { padding-left: 38px; }
.search::before { content: "⌕"; position: absolute; left: 13px; top: 50%; transform: translateY(-52%); color: var(--faint); font-size: 1.2rem; }
.ch-card { display: flex; flex-direction: column; gap: 10px; color: var(--text); height: 100%; }
.ch-card:hover { color: var(--text); }
.ch-card h3 { margin: 0; font-size: 1.02rem; }
.ch-meta { display: flex; flex-wrap: wrap; gap: 6px; }
.ch-foot { margin-top: auto; display: flex; justify-content: space-between; align-items: center; font: 500 .78rem var(--mono); color: var(--muted); padding-top: 10px; border-top: 1px dashed var(--border); }
.ch-status { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--border-hi); flex: none; display: inline-grid; place-items: center; font-size: .65rem; }
.ch-status.solved { border-color: var(--green); background: var(--green); color: #04130d; }
.ch-status.attempted { border-color: var(--amber); }
.empty { text-align: center; padding: 60px 20px; color: var(--muted); border: 1px dashed var(--border-hi); border-radius: var(--radius); }

/* ---------- workspace ---------- */
body.ws { overflow: hidden; }
.ws-main { display: grid; grid-template-columns: minmax(340px, 42%) 1fr; height: calc(100vh - var(--nav-h)); }
.ws-left { border-right: 1px solid var(--border); background: var(--surface); display: flex; flex-direction: column; min-height: 0; }
.ws-tabs { display: flex; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.ws-tabs button { background: none; border: 0; color: var(--muted); font: 600 .82rem var(--mono); padding: 12px 16px; cursor: pointer; border-bottom: 2px solid transparent; }
.ws-tabs button[aria-selected="true"] { color: var(--green); border-bottom-color: var(--green); }
.ws-pane { padding: 22px; overflow-y: auto; flex: 1; min-height: 0; }
.ws-pane[hidden] { display: none; }
.prose p { margin: 0 0 1em; color: #c9d4df; white-space: pre-line; }
.prose ul { padding-left: 1.2em; color: #c9d4df; } .prose li { margin-bottom: .45em; }
.prose pre { background: #05070a; border: 1px solid var(--border); border-radius: 10px; padding: 14px; overflow-x: auto; font-size: .8rem; line-height: 1.6; }
.prose code { background: var(--surface-2); padding: 1px 6px; border-radius: 5px; font-size: .86em; color: var(--cyan); }
.prose pre code { background: none; padding: 0; color: #c9d4df; }
.prose h3 { margin-top: 1.4em; font-size: .95rem; font-family: var(--mono); color: var(--green); }
.ws-right { display: grid; grid-template-rows: 1fr minmax(180px, 38%); min-width: 0; min-height: 0; }
.editor-wrap { display: flex; flex-direction: column; min-height: 0; border-bottom: 1px solid var(--border); }
.editor-bar { display: flex; align-items: center; gap: 10px; padding: 8px 14px; background: var(--surface-2); border-bottom: 1px solid var(--border); font: 500 .78rem var(--mono); color: var(--muted); }
.editor-bar .grow { flex: 1; }
#editor { flex: 1; min-height: 0; }
#editorFallback { flex: 1; width: 100%; resize: none; background: #05070a; color: #d6e2ee; border: 0; padding: 16px; font: 500 .86rem/1.6 var(--mono); tab-size: 2; outline: none; }
.out-wrap { display: flex; flex-direction: column; min-height: 0; background: #05070a; }
.out-bar { display: flex; align-items: center; gap: 10px; padding: 8px 14px; background: var(--surface-2); border-bottom: 1px solid var(--border); font: 600 .78rem var(--mono); }
.out-body { flex: 1; overflow-y: auto; padding: 12px 16px; font: 500 .8rem/1.65 var(--mono); white-space: pre-wrap; word-break: break-word; color: #c9d4df; }
.flow { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 14px 0 20px; }
.flow .n { font: 600 .74rem var(--mono); padding: 6px 10px; border-radius: 8px; border: 1px solid var(--border-hi); background: var(--surface-2); }
.flow .n.warn { border-color: rgba(245, 158, 11, .6); color: var(--amber); } .flow .n.fail { border-color: rgba(239, 68, 68, .6); color: var(--red); }
.flow .n.ok { border-color: rgba(16, 185, 129, .5); }
.flow .ar { color: var(--faint); font-family: var(--mono); }
@media (max-width: 900px) {
  body.ws { overflow: auto; }
  .ws-main { grid-template-columns: 1fr; height: auto; }
  .ws-left { border-right: 0; border-bottom: 1px solid var(--border); }
  .ws-pane { max-height: 60vh; }
  .ws-right { grid-template-rows: 420px 280px; }
}

/* ---------- table / leaderboard ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
table.lb { width: 100%; border-collapse: collapse; min-width: 640px; }
.lb th { text-align: left; font: 600 .72rem var(--mono); text-transform: uppercase; letter-spacing: .08em; color: var(--muted); padding: 14px 16px; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.lb td { padding: 14px 16px; border-bottom: 1px solid var(--border); font-size: .92rem; vertical-align: middle; }
.lb tr:last-child td { border-bottom: 0; }
.lb tr.me td { background: rgba(0, 245, 155, .06); }
.lb .rk { font: 800 1.05rem var(--mono); width: 64px; }
.lb .rk.r1 { color: #ffd34d; } .lb .rk.r2 { color: #cfd8e3; } .lb .rk.r3 { color: #e0955a; }
.lb .who { display: flex; align-items: center; gap: 12px; font-weight: 600; color: var(--text); }
.lb .who img { width: 34px; height: 34px; border-radius: 50%; background: var(--surface-2); border: 1px solid var(--border-hi); }
.lb .num { font-family: var(--mono); }

/* ---------- heatmap / badges / progress ---------- */
.heat-scroll { overflow-x: auto; padding-bottom: 6px; }
.heat { display: grid; grid-auto-flow: column; grid-template-rows: repeat(7, 13px); grid-auto-columns: 13px; gap: 3px; width: max-content; }
.heat i { width: 13px; height: 13px; border-radius: 3px; background: #131a22; display: block; }
.heat i.l1 { background: #0b4d37; } .heat i.l2 { background: #0e7a56; } .heat i.l3 { background: #10b981; } .heat i.l4 { background: #00f59b; box-shadow: 0 0 8px rgba(0, 245, 155, .5); }
.heat-legend { display: flex; align-items: center; gap: 4px; font: 500 .72rem var(--mono); color: var(--muted); margin-top: 10px; }
.heat-legend i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; background: #131a22; }
.progress { height: 8px; background: var(--surface-3); border-radius: 99px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: linear-gradient(90deg, var(--green), var(--cyan)); border-radius: 99px; transition: width .6s cubic-bezier(.2, .8, .2, 1); }
.badge-card { display: flex; flex-direction: column; gap: 10px; }
.badge-card img { width: 100%; border-radius: 10px; border: 1px solid var(--border-hi); background: var(--surface-2); }
.badge-card.locked { opacity: .45; filter: grayscale(1); }
.tier-ladder { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.tier-ladder div { font: 600 .72rem var(--mono); text-align: center; padding: 10px 6px; border: 1px solid var(--border); border-radius: 8px; color: var(--faint); background: var(--surface); }
.tier-ladder div.done { color: var(--green); border-color: rgba(0, 245, 155, .4); }
.tier-ladder div.cur { color: #04130d; background: var(--green); border-color: var(--green); }
@media (max-width: 640px) { .tier-ladder { grid-template-columns: 1fr; } }
.timeline-row { display: grid; grid-template-columns: 90px 1fr auto; gap: 12px; padding: 10px 0; border-bottom: 1px dashed var(--border); font-size: .88rem; align-items: center; }
.timeline-row:last-child { border-bottom: 0; }

/* ---------- pipeline visualizer ---------- */
.pipe { display: flex; align-items: stretch; gap: 0; overflow-x: auto; padding: 6px 2px 14px; }
.pipe .st { flex: 1 0 98px; position: relative; text-align: center; font: 600 .72rem var(--mono); color: var(--muted); padding: 12px 6px; border: 1px solid var(--border-hi); border-radius: 10px; background: var(--surface-2); margin-right: 22px; transition: all .3s; }
.pipe .st:last-child { margin-right: 0; }
.pipe .st::after { content: ""; position: absolute; right: -22px; top: 50%; width: 22px; height: 2px; background: var(--border-hi); }
.pipe .st:last-child::after { display: none; }
.pipe .st.run { color: var(--cyan); border-color: var(--cyan); box-shadow: 0 0 18px rgba(0, 210, 255, .25); }
.pipe .st.done { color: var(--green); border-color: rgba(0, 245, 155, .5); }
.pipe .st.done::after { background: var(--green); }
.pipe .st small { display: block; font: 500 .66rem var(--sans); margin-top: 3px; color: var(--faint); }

/* ---------- misc ---------- */
.toast-host { position: fixed; right: 16px; bottom: 16px; display: grid; gap: 10px; z-index: 100; max-width: min(380px, calc(100vw - 32px)); }
.toast { background: var(--surface-3); border: 1px solid var(--border-hi); border-left: 3px solid var(--cyan); border-radius: 10px; padding: 12px 16px; font-size: .88rem; box-shadow: 0 10px 30px rgba(0, 0, 0, .5); animation: slidein .25s ease-out; }
.toast.ok { border-left-color: var(--green); } .toast.err { border-left-color: var(--red); }
@keyframes slidein { from { transform: translateY(12px); opacity: 0; } }
.hero-canvas { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 0; pointer-events: none; opacity: .9; }
.hero > .wrap { position: relative; z-index: 1; }
.footer { border-top: 1px solid var(--border); padding: 36px 0; color: var(--muted); font-size: .88rem; margin-top: 40px; }
.footer .wrap { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 16px; }
.timeline { position: relative; padding-left: 30px; }
.timeline::before { content: ""; position: absolute; left: 7px; top: 6px; bottom: 6px; width: 2px; background: linear-gradient(var(--green), var(--cyan), transparent); }
.tl-item { position: relative; margin-bottom: 26px; }
.tl-item::before { content: ""; position: absolute; left: -30px; top: 8px; width: 16px; height: 16px; border-radius: 50%; background: var(--bg); border: 2px solid var(--green); box-shadow: 0 0 12px rgba(0, 245, 155, .5); }
.tag { display: inline-block; font: 500 .72rem var(--mono); color: var(--cyan-2); background: rgba(56, 189, 248, .08); border: 1px solid rgba(56, 189, 248, .25); padding: 2px 8px; border-radius: 6px; margin: 2px 4px 2px 0; }
.spark { width: 100%; height: 56px; display: block; }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } html { scroll-behavior: auto; } }
