/* css/ctf.css — CTF challenge browse + play page styling.
   Extends the existing terminal palette (near-black bg, cyan-teal
   accent) rather than introducing a new one. */

.ctf-chip {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  font-family: var(--font-mono, 'JetBrains Mono', monospace);
  font-size: .72rem;
  padding: .3rem .65rem;
  border-radius: 4px;
  border: 1px solid #1e2330;
  background: #0d1119;
  color: #9aa5b8;
}

.ctf-chip-points {
  color: #00d4aa;
  border-color: rgba(0,212,170,.3);
  background: rgba(0,212,170,.08);
}

.ctf-diff-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  display: inline-block;
}
.ctf-diff-beginner     .ctf-diff-dot { background: #a6e3a1; box-shadow: 0 0 6px #a6e3a1; }
.ctf-diff-intermediate .ctf-diff-dot { background: #f9e2af; box-shadow: 0 0 6px #f9e2af; }
.ctf-diff-advanced     .ctf-diff-dot { background: #f38ba8; box-shadow: 0 0 6px #f38ba8; }
.ctf-diff-beginner     { color: #a6e3a1; }
.ctf-diff-intermediate { color: #f9e2af; }
.ctf-diff-advanced     { color: #f38ba8; }

/* Unified left panel: one continuous console, sections divided by
   hairlines rather than chopped into identical repeated cards. */
.ctf-console {
  background: #0d1119;
  border: 1px solid #1e2330;
  border-left: 2px solid #00d4aa;
  border-radius: 6px;
  overflow: hidden;
}
.ctf-console-section {
  padding: 1.5rem;
  border-bottom: 1px solid #1e2330;
}
.ctf-console-section:last-child { border-bottom: none; }
.ctf-console-label {
  font-family: var(--font-mono, 'JetBrains Mono', monospace);
  font-size: .72rem;
  color: #00d4aa;
  margin-bottom: .7rem;
  display: block;
}
.ctf-desc-text {
  color: #9aa5b8;
  line-height: 1.65;
  font-size: .92rem;
}

.ctf-hint {
  margin-top: .7rem;
  font-size: .85rem;
}
.ctf-hint summary {
  cursor: pointer;
  color: #00d4aa;
  font-family: var(--font-mono, monospace);
  font-size: .78rem;
  list-style: none;
  display: flex;
  align-items: center;
  gap: .45rem;
}
.ctf-hint summary::-webkit-details-marker { display: none; }
.ctf-hint summary::before {
  content: '▸';
  display: inline-block;
  transition: transform .15s;
}
.ctf-hint[open] summary::before { transform: rotate(90deg); }
.ctf-hint p {
  margin-top: .5rem;
  color: #9aa5b8;
  padding-left: 1.15rem;
}

.ctf-flag-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.ctf-flag-input-wrap::before {
  content: '>';
  position: absolute;
  left: .9rem;
  color: #00d4aa;
  font-family: var(--font-mono, monospace);
  pointer-events: none;
}
.ctf-flag-input-wrap input {
  padding-left: 1.8rem !important;
  font-family: var(--font-mono, monospace) !important;
  background: #0a0d12 !important;
  border-color: #1e2330 !important;
}
.ctf-flag-input-wrap input:focus {
  border-color: #00d4aa !important;
  box-shadow: 0 0 0 3px rgba(0,212,170,.12) !important;
}

.ctf-start-btn:hover {
  box-shadow: 0 0 24px rgba(0,212,170,.35);
}

/* Right side: standby state before the machine is deployed */
.ctf-standby {
  border: 1px dashed #1e2330;
  border-radius: 6px;
  background: #0d1119;
  padding: 4.5rem 2rem;
  text-align: center;
}
.ctf-standby-icon {
  width: 46px;
  height: 46px;
  margin: 0 auto 1.1rem;
  border: 1px solid rgba(0,212,170,.35);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #00d4aa;
  font-family: var(--font-mono, monospace);
  animation: ctf-standby-pulse 2.4s ease-in-out infinite;
}
@keyframes ctf-standby-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(0,212,170,.25); }
  50%      { box-shadow: 0 0 0 10px rgba(0,212,170,0); }
}
.ctf-standby-text {
  color: #6b7a8d;
  font-size: .88rem;
  max-width: 260px;
  margin: 0 auto;
}

@media (max-width: 900px) {
  .ctf-split { flex-direction: column; }
}

/* ── Browse page ── */
.ctf-filterbar {
  display: flex;
  align-items: center;
  gap: .75rem;
  flex-wrap: wrap;
  margin-bottom: 1.75rem;
}
.ctf-search-input-wrap {
  position: relative;
  flex: 1;
  min-width: 220px;
}
.ctf-search-input-wrap input {
  padding-left: 2.4rem !important;
  background: #0d1119 !important;
  border-color: #1e2330 !important;
}
.ctf-search-input-wrap input:focus {
  border-color: #00d4aa !important;
  box-shadow: 0 0 0 3px rgba(0,212,170,.12) !important;
}
.ctf-search-icon {
  position: absolute;
  left: .9rem;
  top: 50%;
  transform: translateY(-50%);
  color: #4a5568;
  pointer-events: none;
}

.ctf-filter-dropdown { position: relative; }
.ctf-filter-dropdown summary {
  list-style: none;
  cursor: pointer;
  font-family: var(--font-mono, monospace);
  font-size: .78rem;
  color: #9aa5b8;
  background: #0d1119;
  border: 1px solid #1e2330;
  border-radius: 6px;
  padding: .55rem 1rem;
  display: flex;
  align-items: center;
  gap: .5rem;
  user-select: none;
}
.ctf-filter-dropdown summary::-webkit-details-marker { display: none; }
.ctf-filter-dropdown summary::after { content: '▾'; font-size: .65rem; }
.ctf-filter-dropdown[open] summary { border-color: #00d4aa; color: #00d4aa; }
.ctf-filter-dropdown .ctf-filter-panel {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  background: #0d1119;
  border: 1px solid #1e2330;
  border-radius: 8px;
  padding: .85rem;
  min-width: 180px;
  z-index: 20;
  box-shadow: 0 12px 32px rgba(0,0,0,.5);
}
.ctf-filter-panel label {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-size: .82rem;
  color: #cdd6f4;
  padding: .35rem 0;
  cursor: pointer;
}

.ctf-results-count {
  font-family: var(--font-mono, monospace);
  font-size: .78rem;
  color: #6b7a8d;
  margin-left: auto;
}

.ctf-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 1.25rem;
}

.ctf-card {
  display: block;
  text-decoration: none;
  background: #0d1119;
  border: 1px solid #1e2330;
  border-radius: 10px;
  overflow: hidden;
  transition: transform .18s, border-color .18s, box-shadow .18s;
}
.ctf-card:hover {
  transform: translateY(-3px);
  border-color: rgba(0,212,170,.4);
  box-shadow: 0 16px 40px rgba(0,0,0,.45), 0 0 0 1px rgba(0,212,170,.15);
}

.ctf-card-banner {
  position: relative;
  height: 96px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background:
    radial-gradient(circle at 30% 20%, rgba(0,212,170,.16), transparent 60%),
    linear-gradient(135deg, #0a0d12, #10151f 60%, #0a0d12);
}
.ctf-card-banner::after {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(0,212,170,.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0,212,170,.06) 1px, transparent 1px);
  background-size: 18px 18px;
}
.ctf-card-icon {
  font-size: 2.1rem;
  opacity: .85;
  filter: drop-shadow(0 0 10px rgba(0,212,170,.35));
  position: relative;
  z-index: 1;
}
.ctf-card-diffbar {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 3px;
}
.ctf-card-body { padding: 1.1rem 1.2rem 1.25rem; }
.ctf-card-title {
  color: #eef1f8;
  font-size: 1.02rem;
  font-weight: 700;
  margin: 0 0 .4rem;
}
.ctf-card-desc {
  color: #6b7a8d;
  font-size: .82rem;
  line-height: 1.55;
  margin: 0 0 .9rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.ctf-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-family: var(--font-mono, monospace);
  font-size: .72rem;
}

/* ── Stage progress list (challenge page) ── */
.ctf-stage-item {
  display: flex;
  flex-direction: column;
  gap: .3rem;
  padding: .8rem 0;
  border-bottom: 1px solid #1e2330;
}
.ctf-stage-item:last-child { border-bottom: none; }
.ctf-stage-check {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 1px solid #2a2f3a;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .7rem;
  color: #4a5568;
  flex-shrink: 0;
}
.ctf-stage-item.done .ctf-stage-check {
  border-color: #a6e3a1;
  color: #a6e3a1;
  background: rgba(166,227,161,.1);
}
.ctf-stage-item > div:nth-child(2) { flex: 1; min-width: 0; }
.ctf-stage-title { font-size: .88rem; color: #cdd6f4; }
.ctf-stage-item.done .ctf-stage-title { color: #6b7a8d; text-decoration: line-through; }
.ctf-stage-desc { font-size: .76rem; color: #6b7a8d; margin-top: .15rem; }
.ctf-stage-points {
  font-family: var(--font-mono, monospace);
  font-size: .72rem;
  color: #00d4aa;
  flex-shrink: 0;
}

/* ── Per-stage flag submission ── */
.ctf-stage-header {
  display: flex;
  align-items: center;
  gap: .6rem;
}
.ctf-stage-header .ctf-stage-title { flex: 1; }
.ctf-stage-submit {
  display: flex;
  gap: .5rem;
  margin-top: .6rem;
}
.ctf-stage-msg {
  margin-top: .4rem;
  font-size: .78rem;
  min-height: 1em;
}

/* ── Leaderboard: proper table with aligned columns ── */
.ctf-lb-table {
  background: #0d1119;
  border: 1px solid #1e2330;
  border-radius: 6px;
  overflow: hidden;
}
.ctf-lb-header,
.ctf-lb-row {
  display: grid;
  grid-template-columns: 48px 40px 1fr 70px 80px 90px;
  align-items: center;
  gap: 1rem;
  padding: .9rem 1.2rem;
}
.ctf-lb-header {
  font-family: var(--font-mono, monospace);
  font-size: .65rem;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: #6b7a8d;
  border-bottom: 1px solid #1e2330;
  background: rgba(255,255,255,.015);
}
.ctf-lb-row { border-bottom: 1px solid #1e2330; }
.ctf-lb-row:last-child { border-bottom: none; }
.ctf-lb-rank {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,.03);
  border: 1px solid #1e2330;
  font-family: var(--font-mono, monospace);
  font-weight: 700;
  font-size: .82rem;
  color: #6b7a8d;
}
.ctf-lb-row { border-left: 3px solid transparent; transition: background .15s ease; }
.ctf-lb-row.top1 { background: rgba(249,226,175,.05); border-left-color: #f9e2af; }
.ctf-lb-row.top2 { background: rgba(205,214,244,.04); border-left-color: #cdd6f4; }
.ctf-lb-row.top3 { background: rgba(216,152,90,.05); border-left-color: #d8985a; }
.ctf-lb-row:hover { background: rgba(255,255,255,.035); }
.ctf-lb-row.me {
  background: rgba(0,212,170,.07);
  border-left-color: #00d4aa;
  border-bottom-color: rgba(0,212,170,.2);
}
.ctf-lb-row.me .ctf-lb-rank {
  border-color: #00d4aa;
  color: #00d4aa;
}

/* Solid-filled rank chip for top 3 instead of outline */
.ctf-lb-row.top1 .ctf-lb-rank { background: #f9e2af; border-color: #f9e2af; color: #0a0d12; }
.ctf-lb-row.top2 .ctf-lb-rank { background: #cdd6f4; border-color: #cdd6f4; color: #0a0d12; }
.ctf-lb-row.top3 .ctf-lb-rank { background: #d8985a; border-color: #d8985a; color: #0a0d12; }

/* Avatar ring + name tinted to match rank tier */
.ctf-lb-row.top1 .ctf-lb-avatar { border-color: #f9e2af; color: #f9e2af; background: rgba(249,226,175,.1); }
.ctf-lb-row.top2 .ctf-lb-avatar { border-color: #cdd6f4; color: #cdd6f4; background: rgba(205,214,244,.1); }
.ctf-lb-row.top3 .ctf-lb-avatar { border-color: #d8985a; color: #d8985a; background: rgba(216,152,90,.1); }

.ctf-lb-name { flex: 1; font-weight: 600; color: #eef1f8; }
.ctf-lb-row.top1 .ctf-lb-name { color: #f9e2af; }
.ctf-lb-row.top2 .ctf-lb-name { color: #cdd6f4; }
.ctf-lb-row.top3 .ctf-lb-name { color: #d8985a; }
.ctf-lb-row.me .ctf-lb-name::after {
  content: 'YOU';
  margin-left: .55rem;
  font-family: var(--font-mono, monospace);
  font-size: .58rem;
  font-weight: 700;
  color: #00d4aa;
  border: 1px solid rgba(0,212,170,.4);
  padding: .12rem .4rem;
  border-radius: 3px;
  vertical-align: middle;
  letter-spacing: .04em;
}
.ctf-lb-stages { font-family: var(--font-mono, monospace); font-size: .78rem; color: #6b7a8d; }

/* Points as a pill badge instead of plain text */
.ctf-lb-points {
  font-family: var(--font-mono, monospace);
  font-weight: 700;
  font-size: .8rem;
  color: #00d4aa;
  background: rgba(0,212,170,.08);
  border: 1px solid rgba(0,212,170,.22);
  border-radius: 999px;
  padding: .3rem .8rem;
  text-align: center;
  justify-self: end;
}
.ctf-lb-row.top1 .ctf-lb-points { color: #f9e2af; background: rgba(249,226,175,.12); border-color: rgba(249,226,175,.35); }
.ctf-lb-row.top2 .ctf-lb-points { color: #cdd6f4; background: rgba(205,214,244,.1); border-color: rgba(205,214,244,.3); }
.ctf-lb-row.top3 .ctf-lb-points { color: #d8985a; background: rgba(216,152,90,.1); border-color: rgba(216,152,90,.3); }

/* ── Leaderboard v2: literal podium pedestal, not cards ──
   Solid pillars of different heights, glowing rank numeral etched
   into each, avatar floating above — no bordered boxes at all. */
.ctf-podium {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 2rem;
  margin-bottom: 2.5rem;
}
.podium-slot {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 150px;
}
.podium-slot.rank1 { order: 2; }
.podium-slot.rank2 { order: 1; }
.podium-slot.rank3 { order: 3; }

.podium-avatar {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  margin-bottom: .85rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono, monospace);
  font-size: 1.2rem;
  font-weight: 700;
  background: rgba(0,212,170,.1);
  border: 2px solid rgba(0,212,170,.35);
  color: #00d4aa;
  z-index: 2;
}
.podium-slot.rank1 .podium-avatar {
  width: 76px; height: 76px; font-size: 1.5rem;
  border-color: #f9e2af; color: #f9e2af;
  background: rgba(249,226,175,.1);
  box-shadow: 0 0 26px rgba(249,226,175,.3);
}
.podium-slot.rank2 .podium-avatar { border-color: #cdd6f4; color: #cdd6f4; }
.podium-slot.rank3 .podium-avatar { border-color: #d8985a; color: #d8985a; }
.podium-slot.me .podium-avatar { border-color: #00d4aa; box-shadow: 0 0 20px rgba(0,212,170,.35); }

.podium-info { text-align: center; margin-bottom: 1rem; }
.podium-name {
  font-weight: 700;
  color: #eef1f8;
  max-width: 140px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.podium-points {
  font-family: var(--font-mono, monospace);
  font-weight: 700;
  color: #00d4aa;
  font-size: 1rem;
}
.podium-slot.rank1 .podium-points { color: #f9e2af; font-size: 1.15rem; }
.podium-stages {
  font-family: var(--font-mono, monospace);
  font-size: .68rem;
  color: #6b7a8d;
  margin-top: .1rem;
}

.podium-pillar {
  width: 100%;
  border-radius: 8px 8px 0 0;
  border: 1px solid;
  border-bottom: none;
  display: flex;
  justify-content: center;
  padding-top: .4rem;
}
.podium-number {
  font-family: var(--font-mono, 'JetBrains Mono', monospace);
  font-weight: 700;
  line-height: 1;
}
.podium-slot.rank1 .podium-pillar {
  height: 130px;
  background: linear-gradient(180deg, rgba(249,226,175,.22), rgba(249,226,175,.04));
  border-color: rgba(249,226,175,.4);
  box-shadow: 0 0 40px rgba(249,226,175,.14);
}
.podium-slot.rank1 .podium-number { color: #f9e2af; font-size: 3.25rem; }

.podium-slot.rank2 .podium-pillar {
  height: 92px;
  background: linear-gradient(180deg, rgba(205,214,244,.16), rgba(205,214,244,.03));
  border-color: rgba(205,214,244,.3);
}
.podium-slot.rank2 .podium-number { color: #cdd6f4; font-size: 2.5rem; }

.podium-slot.rank3 .podium-pillar {
  height: 64px;
  background: linear-gradient(180deg, rgba(216,152,90,.16), rgba(216,152,90,.03));
  border-color: rgba(216,152,90,.3);
}
.podium-slot.rank3 .podium-number { color: #d8985a; font-size: 2.1rem; }

.podium-slot.me .podium-pillar { border-color: #00d4aa; box-shadow: 0 0 24px rgba(0,212,170,.2); }

.ctf-lb-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(0,212,170,.08);
  border: 1px solid rgba(0,212,170,.25);
  color: #00d4aa;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono, monospace);
  font-size: .8rem;
  font-weight: 700;
  flex-shrink: 0;
}

/* ── Leaderboard: featured #1 banner + #2/#3 runner-up cards ── */
.ctf-lb-top { margin-bottom: 1.5rem; }

.ctf-lb-featured {
  position: relative;
  display: flex;
  align-items: center;
  gap: 1.25rem;
  background: linear-gradient(135deg, #14171f, #0d1119);
  border: 1px solid rgba(249,226,175,.4);
  border-radius: 10px;
  padding: 1.5rem 1.75rem;
  margin-bottom: 1rem;
  overflow: hidden;
  box-shadow: 0 0 40px rgba(249,226,175,.1);
}
.ctf-lb-featured.me { border-color: #00d4aa; box-shadow: 0 0 30px rgba(0,212,170,.15); }
.ctf-lb-featured-rank {
  font-family: var(--font-mono, monospace);
  font-weight: 700;
  font-size: 1.4rem;
  color: #f9e2af;
  width: 32px;
  text-align: center;
  flex-shrink: 0;
}
.ctf-lb-featured-avatar {
  width: 64px; height: 64px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-mono, monospace);
  font-size: 1.4rem;
  font-weight: 700;
  color: #f9e2af;
  background: rgba(249,226,175,.12);
  border: 2px solid #f9e2af;
  box-shadow: 0 0 20px rgba(249,226,175,.3);
  flex-shrink: 0;
}
.ctf-lb-featured-info { flex: 1; min-width: 0; }
.ctf-lb-featured-name {
  font-weight: 700;
  font-size: 1.15rem;
  color: #eef1f8;
  margin-bottom: .3rem;
}
.ctf-lb-featured-stats {
  display: flex;
  gap: 1.25rem;
  font-family: var(--font-mono, monospace);
  font-size: .8rem;
  color: #9aa5b8;
}
.ctf-lb-featured-stats b { color: #f9e2af; }
.ctf-lb-crown {
  position: absolute;
  right: -6px; bottom: -6px;
  width: 90px; height: 90px;
  clip-path: polygon(100% 0, 0% 100%, 100% 100%);
  background: rgba(249,226,175,.16);
  display: flex; align-items: flex-end; justify-content: flex-end;
  padding: 10px;
}
.ctf-lb-crown svg { width: 22px; height: 22px; color: #f9e2af; }

.ctf-lb-runners {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.ctf-lb-runner-card {
  background: #0d1119;
  border: 1px solid #1e2330;
  border-radius: 10px;
  padding: 1.1rem;
  text-align: center;
  position: relative;
}
.ctf-lb-runner-rank {
  position: absolute;
  top: .6rem; right: .8rem;
  font-family: var(--font-mono, monospace);
  font-weight: 700;
  font-size: .85rem;
  color: #6b7a8d;
}
.ctf-lb-runner-avatar {
  width: 48px; height: 48px;
  border-radius: 50%;
  margin: 0 auto .6rem;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-mono, monospace);
  font-weight: 700;
  background: rgba(0,212,170,.1);
  border: 2px solid rgba(0,212,170,.35);
  color: #00d4aa;
}
.ctf-lb-runner-card.top2 .ctf-lb-runner-avatar,
.ctf-lb-runner-card.top2 .ctf-lb-runner-rank { border-color: #cdd6f4; color: #cdd6f4; }
.ctf-lb-runner-card.top3 .ctf-lb-runner-avatar,
.ctf-lb-runner-card.top3 .ctf-lb-runner-rank { border-color: #d8985a; color: #d8985a; }
.ctf-lb-runner-card.me { border-color: #00d4aa; box-shadow: 0 0 16px rgba(0,212,170,.15); }
.ctf-lb-runner-name { font-weight: 700; color: #eef1f8; margin-bottom: .2rem; }
.ctf-lb-runner-stats {
  font-family: var(--font-mono, monospace);
  font-size: .7rem;
  color: #6b7a8d;
}
@media (max-width: 640px) {
  .ctf-lb-featured { flex-wrap: wrap; }
  .ctf-lb-runners { grid-template-columns: 1fr; }
}

/* ── Category pills, matching the Tools page filter style ── */
.ctf-category-pills {
  display: flex;
  align-items: center;
  gap: .5rem;
  flex-wrap: wrap;
}
.ctf-category-pills .tools-filter-btn {
  font-family: monospace;
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: #8b949e;
  background: rgba(255,255,255,.04);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 8px;
  padding: .4rem .9rem;
  cursor: pointer;
  transition: all .2s;
}
.ctf-category-pills .tools-filter-btn:hover,
.ctf-category-pills .tools-filter-btn.active {
  color: #00d4ff;
  border-color: rgba(0,212,255,.3);
  background: rgba(0,212,255,.08);
}
