/* PYR-CTF — Matrix / Mountains theme for CTFd
   Palette + wireframe grammar for the PYR-CTF "Expansion" design. Self-hosted
   fonts only (no CDN) — CTF venue networks are frequently offline/restricted. */

@font-face {
  font-family: "Barlow";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("../webfonts/barlow-400.woff2") format("woff2");
}
@font-face {
  font-family: "Barlow";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("../webfonts/barlow-500.woff2") format("woff2");
}
@font-face {
  font-family: "Barlow";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("../webfonts/barlow-600.woff2") format("woff2");
}
@font-face {
  font-family: "Barlow Condensed";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("../webfonts/barlow-condensed-500.woff2") format("woff2");
}
@font-face {
  font-family: "Barlow Condensed";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("../webfonts/barlow-condensed-600.woff2") format("woff2");
}
@font-face {
  font-family: "Barlow Condensed";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("../webfonts/barlow-condensed-700.woff2") format("woff2");
}

:root {
  --bg: #050906;
  --bg-panel: rgba(5, 9, 6, 0.86);
  --text: #d5ecd9;
  --muted: rgba(213, 236, 217, 0.6);
  --acc: #46f08a;
  --acc-dim: rgba(70, 240, 138, 0.12);
  --divider: rgba(70, 240, 138, 0.2);
  --font-heading: "Barlow Condensed", system-ui, sans-serif;
  --font-body: "Barlow", system-ui, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, monospace;
  --sp-1: 3.4px; --sp-2: 6.8px; --sp-3: 10.2px; --sp-4: 13.6px; --sp-6: 20.4px; --sp-8: 27.2px;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--bg); color: var(--text);
  font-family: var(--font-body); font-size: 15px; line-height: 1.55;
}
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading); font-weight: 600;
  line-height: 1.12; letter-spacing: -0.01em; margin: 0 0 var(--sp-2);
}
h1 { font-size: 46px; } h2 { font-size: 30px; } h3 { font-size: 22px; }
p { margin: 0 0 var(--sp-3); }
a { color: var(--acc); text-decoration: none; text-underline-offset: 3px; }
a:hover { text-decoration: underline; }
img { display: block; max-width: 100%; }
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--acc); outline-offset: 2px; }
::selection { background: rgba(70, 240, 138, 0.3); }

.mono { font-family: var(--font-mono); }
.kicker {
  font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.2em;
  text-transform: uppercase; color: var(--muted);
}
.kicker-acc { color: var(--acc); }
.muted { color: var(--muted); }
.wrap { max-width: 1240px; margin: 0 auto; padding: 44px 34px 90px; }
.wrap-narrow { max-width: 520px; margin: 0 auto; padding: 70px 34px 90px; }
.rule { flex: 1; height: 1px; background: var(--divider); }
.row { display: flex; align-items: center; gap: var(--sp-4); }
.section-head { display: flex; align-items: baseline; gap: 14px; margin-bottom: 14px; }

/* ── background layers ────────────────────────────────────────── */
#pyr-rain { position: fixed; inset: 0; width: 100%; height: 100%; opacity: 0.18; pointer-events: none; z-index: 0; }
.ridge { position: fixed; left: 0; right: 0; bottom: 0; pointer-events: none; z-index: 0; }
.ridge-far {
  height: 44vh;
  clip-path: polygon(0% 100%, 0% 62%, 9% 74%, 18% 48%, 27% 66%, 38% 30%, 47% 55%, 56% 40%, 68% 71%, 79% 52%, 88% 68%, 100% 46%, 100% 100%);
  background: linear-gradient(to bottom, rgba(70, 240, 138, 0.13), rgba(70, 240, 138, 0));
}
.ridge-near {
  height: 30vh;
  clip-path: polygon(0% 100%, 0% 78%, 12% 60%, 22% 82%, 34% 44%, 45% 70%, 58% 52%, 70% 80%, 82% 58%, 93% 76%, 100% 64%, 100% 100%);
  background: linear-gradient(to bottom, rgba(20, 80, 45, 0.34), rgba(5, 9, 6, 0.95));
}
.shell { position: relative; z-index: 1; display: flex; flex-direction: column; min-height: 100vh; }
.shell > main { flex: 1; }

/* ── blueprint frame ──────────────────────────────────────────── */
.bp { position: relative; border: 1px solid var(--divider); border-radius: 0; }
.bp-fill { background: var(--bg-panel); }
.bp > .corner { position: absolute; width: 11px; height: 11px; color: rgba(213, 236, 217, 0.55); }
.bp > .corner::before, .bp > .corner::after { content: ""; position: absolute; background: currentColor; }
.bp > .corner::before { left: 0; right: 0; top: 50%; height: 1px; }
.bp > .corner::after { top: 0; bottom: 0; left: 50%; width: 1px; }
.bp > .tl { left: -6px; top: -6px; } .bp > .tr { right: -6px; top: -6px; }
.bp > .bl { left: -6px; bottom: -6px; } .bp > .br { right: -6px; bottom: -6px; }

/* ── nav ──────────────────────────────────────────────────────── */
.nav {
  display: flex; align-items: center; gap: 28px; padding: 14px 34px;
  border-bottom: 1px solid var(--divider); background: rgba(5, 9, 6, 0.72);
  backdrop-filter: blur(6px); position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: baseline; gap: 9px; }
.brand-mark { font-family: var(--font-heading); font-weight: 700; font-size: 22px; letter-spacing: 0.06em; color: var(--text); }
.brand-mark span { color: var(--acc); }
.brand-edition { font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.22em; color: var(--acc); text-transform: uppercase; }
.nav-links { display: flex; gap: 4px; margin-left: 14px; flex-wrap: wrap; }
.nav-link {
  font-family: var(--font-heading); font-size: 15px; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--muted); padding: 7px 12px; border-bottom: 2px solid transparent; background: none; border-top: 0; border-left: 0; border-right: 0; cursor: pointer;
}
.nav-link:hover { color: var(--acc); text-decoration: none; }
.nav-link.active { color: var(--acc); border-bottom-color: var(--acc); }
.nav-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.nav-sep { width: 1px; height: 20px; background: var(--divider); }
.avatar { width: 30px; height: 30px; display: grid; place-items: center; font-family: var(--font-heading); font-size: 14px; color: var(--acc); }
.bell { position: relative; color: var(--muted); font-family: var(--font-mono); font-size: 12px; background: none; border: 0; cursor: pointer; }
.bell[data-count]:not([data-count="0"])::after {
  content: attr(data-count); position: absolute; top: -6px; right: -10px;
  background: var(--acc); color: var(--bg); font-family: var(--font-mono); font-size: 9px; padding: 0 4px;
}
#pyr-clock { font-family: var(--font-mono); font-size: 12px; color: var(--acc); }

/* sponsor rotator — middle column of the nav grid (see the end of this file), so it sits at the
   page center when both sides fit. Waves crossfade via wireSponsors() in matrix-rain.js;
   --sp-scale is lowered by fitSponsors() when the nav is short on room. */
.nav-left { display: flex; align-items: center; gap: 28px; min-width: 0; }
.sponsors { --sp-scale: 1; flex: none; width: calc(360px * var(--sp-scale)); height: 44px; display: grid; }
.sponsor-wave {
  grid-area: 1 / 1; display: flex; align-items: center; justify-content: center; gap: calc(26px * var(--sp-scale));
  opacity: 0; transform: translateY(6px); pointer-events: none;
  transition: opacity 0.5s ease, transform 0.5s ease;
}
.sponsor-wave.is-active { opacity: 1; transform: none; pointer-events: auto; }
.sponsor-mention {
  font-family: var(--font-mono); font-size: 9px; line-height: 1.35; letter-spacing: 0.22em;
  text-transform: uppercase; color: var(--acc); max-width: 9em; text-align: right;
  margin-right: -12px; padding-right: 12px; border-right: 1px solid var(--divider);
}
.sponsor { display: flex; align-items: center; }
.sponsor img { height: calc(24px * var(--sp-scale)); width: auto; max-width: none; filter: grayscale(0.15); }
.sponsor:hover img { filter: none; }
.is-major .sponsor img { height: calc(30px * var(--sp-scale)); }

/* ── buttons, tags, fields ────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font-family: var(--font-heading); font-weight: 600; font-size: 15px; letter-spacing: 0.05em;
  text-transform: uppercase; padding: 12px 24px; border-radius: 0; cursor: pointer;
  background: transparent; border: 1px solid var(--divider); color: var(--text);
}
.btn:hover { border-color: var(--acc); color: var(--acc); text-decoration: none; }
.btn-primary { background: var(--acc); border-color: var(--acc); color: var(--bg); }
.btn-primary:hover { background: #2ed675; border-color: #2ed675; color: var(--bg); }
.btn-primary:active { background: #20b660; }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-sm { padding: 7px 15px; font-size: 14px; }
.btn-danger { background: #ff8f7a; border-color: #ff8f7a; color: var(--bg); }
.btn-danger:hover { background: #ff7259; border-color: #ff7259; color: var(--bg); }
.btn-info { background: transparent; border-color: var(--divider); color: var(--muted); }
.btn-info:hover { border-color: var(--acc); color: var(--acc); }

.chip {
  font-family: var(--font-heading); font-size: 14px; letter-spacing: 0.05em; text-transform: uppercase;
  padding: 7px 15px; border: 1px solid var(--divider); background: transparent; color: rgba(213, 236, 217, 0.75);
  border-radius: 0; cursor: pointer;
}
.chip:hover { border-color: var(--acc); color: var(--acc); }
.chip.active { background: var(--acc); border-color: var(--acc); color: var(--bg); }

.tag {
  display: inline-flex; align-items: center; padding: 6px 12px; border: 1px solid var(--divider);
  font-size: 12px; font-family: var(--font-mono); letter-spacing: 0.04em; color: var(--text);
}

.field { display: block; margin-bottom: 16px; }
.field > label {
  display: block; font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--muted); margin-bottom: var(--sp-2);
}
.input, select.input, textarea.input {
  width: 100%; padding: 10px 12px; font-family: var(--font-body); font-size: 14px;
  background: transparent; color: var(--text); border: 1px solid var(--divider); border-radius: 0;
}
.input:hover { border-color: rgba(70, 240, 138, 0.4); }
.input::placeholder { color: rgba(213, 236, 217, 0.35); }
.input:disabled { opacity: 0.5; }
.input option { background: var(--bg); color: var(--text); }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; margin-bottom: 16px; }

/* ── flash / verdict ──────────────────────────────────────────── */
.flash { padding: 12px 16px; margin-bottom: 20px; font-family: var(--font-mono); font-size: 12px; border: 1px solid var(--divider); }
.flash-ok { border-color: var(--acc); color: var(--acc); background: var(--acc-dim); }
.verdict { margin-top: 14px; font-family: var(--font-mono); font-size: 12px; min-height: 18px; color: var(--muted); }
.verdict.correct { color: var(--acc); }
.verdict.incorrect { color: #ff8f7a; }

/* ── bootstrap-compat shims ──────────────────────────────────────
   Minimal subset of Bootstrap's utility/component classes, for markup
   injected directly by challenge-type plugins (e.g. container/instance
   challenges) that we don't control the source of and can't restyle —
   see renderConnectionInfo()/runInlinePluginHandlers() in matrix-rain.js.
   Not a general-purpose Bootstrap replacement; extend only as new plugin
   markup actually needs it. */
.d-none { display: none !important; }
.text-center { text-align: center; }
.mb-1 { margin-bottom: 4px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 16px; }
.alert { padding: 12px 16px; margin-bottom: 16px; border: 1px solid var(--divider); font-size: 13px; }
.alert-primary, .alert-success { border-color: var(--acc); color: var(--acc); background: var(--acc-dim); }
.alert-danger { border-color: #ff8f7a; color: #ff8f7a; background: rgba(255, 143, 122, 0.1); }
.alert-info { border-color: var(--divider); color: var(--muted); }

/* ── challenge board ──────────────────────────────────────────── */
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 26px; }
.filters[hidden] { display: none; }
.board-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 26px; flex-wrap: wrap; }
.timer-box { padding: 12px 18px; display: flex; gap: 22px; align-items: center; }
.timer-box .value { font-family: var(--font-heading); font-size: 26px; color: var(--acc); line-height: 1.1; }
.cat-group { margin-bottom: 44px; }
.cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.chall {
  text-align: left; padding: 18px 18px 16px; cursor: pointer; font: inherit; color: var(--text);
  background: var(--bg-panel); display: block; width: 100%;
}
.chall:hover { border-color: var(--acc); }
.chall.solved { background: var(--acc-dim); border-color: var(--acc); }
.chall.locked { cursor: not-allowed; filter: grayscale(0.8) brightness(0.65); opacity: 0.65; }
.chall.locked:hover { border-color: var(--divider); }
.chall.locked .chall-mark { color: var(--muted); }
.chall-top { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.chall-name { font-family: var(--font-heading); font-size: 20px; }
.chall-mark { font-family: var(--font-mono); font-size: 11px; color: var(--acc); }
.chall-meta { display: flex; justify-content: space-between; align-items: center; margin-top: 16px; font-family: var(--font-mono); font-size: 11px; color: var(--muted); }
.chall-bar { height: 2px; margin-top: 10px; background: var(--divider); }
.chall-bar > i { display: block; height: 100%; background: var(--acc); opacity: 0.75; }
.empty { padding: 40px 0; font-family: var(--font-mono); font-size: 12px; color: var(--muted); }

/* ── modal ────────────────────────────────────────────────────── */
.backdrop { position: fixed; inset: 0; z-index: 20; background: rgba(2, 5, 3, 0.84); display: grid; place-items: center; padding: 40px; }
.backdrop[hidden] { display: none; }
.modal { width: min(680px, 100%); background: var(--bg); padding: 32px 34px; max-height: 86vh; overflow: visible; }
.modal-scroll { max-height: 52vh; overflow-y: auto; overflow-x: hidden; }
.modal-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; }
.modal-points { font-family: var(--font-heading); font-size: 34px; color: var(--acc); line-height: 1; text-align: right; }
.modal-body { margin: 22px 0 20px; font-size: 15px; color: rgba(213, 236, 217, 0.82); }
.modal-body pre, .modal-body code { font-family: var(--font-mono); font-size: 13px; }
.modal-body pre { padding: 12px; border: 1px solid var(--divider); overflow: auto; }
.modal-body code { padding: 2px 5px; background: rgba(70, 240, 138, 0.08); }
.modal-body pre code { padding: 0; background: none; }
.modal-body ul, .modal-body ol { padding-left: 22px; margin: 0 0 var(--sp-3); }
.modal-body a { text-decoration: underline; }
.modal-tags { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 24px; }
.submit-row { display: flex; gap: 10px; align-items: stretch; }
.submit-row .input { font-family: var(--font-mono); }
.close-x { background: none; border: 0; color: var(--muted); font-family: var(--font-mono); cursor: pointer; font-size: 14px; }
.close-x:hover { color: var(--acc); }

/* ── tables ───────────────────────────────────────────────────── */
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th {
  text-align: left; font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.16em;
  text-transform: uppercase; color: var(--muted); font-weight: 400;
  padding: 10px 12px; border-bottom: 1px solid var(--divider);
}
.table td { padding: 12px; border-bottom: 1px solid rgba(70, 240, 138, 0.1); }
.table tbody tr:hover { background: rgba(70, 240, 138, 0.07); }
.table tr.me { background: var(--acc-dim); }
.num { font-family: var(--font-mono); }
.right { text-align: right; }
/* `.table th` sets text-align: left and outranks `.right` alone: keep right-aligned
   headers over right-aligned numbers (scoreboard Membres / Points). */
.table th.right, .table td.right { text-align: right; }
.rank { font-family: var(--font-mono); color: var(--acc); }
.team-name { font-family: var(--font-heading); font-size: 18px; }

/* ── charts ───────────────────────────────────────────────────── */
.chart-box { padding: 24px 26px 18px; margin-bottom: 32px; }
.chart { width: 100%; height: 220px; display: block; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 14px; font-family: var(--font-mono); font-size: 11px; color: var(--muted); }
.chart-legend i { display: inline-block; width: 10px; height: 2px; margin-right: 6px; vertical-align: middle; }

/* ── stats / profile ──────────────────────────────────────────── */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 26px 20px; }
.stat-value { font-family: var(--font-heading); font-size: 44px; line-height: 1; color: var(--acc); }
.stat-label { font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--muted); margin-top: 5px; }
.two-col { display: grid; grid-template-columns: 1.35fr 1fr; gap: 44px; align-items: start; }
.panel { padding: 26px 28px; }
.cell-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: 1px; background: var(--divider); border: 1px solid var(--divider); }
.cell { background: var(--bg); padding: 20px 18px; display: flex; align-items: baseline; gap: 10px; }
.cell-num { font-family: var(--font-mono); font-size: 10px; color: var(--acc); }
.cell-name { font-family: var(--font-heading); font-size: 19px; }

.foot {
  border-top: 1px solid var(--divider); padding: 22px 34px; display: flex;
  justify-content: space-between; gap: 20px; font-family: var(--font-mono); font-size: 11px; color: var(--muted);
}

.notif { padding: 20px 22px; margin-bottom: 16px; }
.notif-time { font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); }

.err { text-align: center; padding: 120px 34px; }
.err-code { font-family: var(--font-heading); font-size: 120px; line-height: 1; color: var(--acc); }

.page-content img { max-width: 100%; }

/* ── lock page (pyrctf_schedule plugin, team's bracket not open yet) ── */
.lock-wrap { max-width: 640px; padding-top: 48px; padding-bottom: 48px; }
.lock-panel { text-align: center; }
.lock-logo { margin: 0 auto 26px; max-width: 200px; }
.lock-team { font-size: clamp(30px, 7vw, 46px); margin: 6px 0 4px; overflow-wrap: anywhere; }
.lock-format { color: var(--acc); font-size: 13px; letter-spacing: 0.08em; text-transform: uppercase; }
.lock-count { margin: 30px auto 18px; padding: 18px 14px 20px; max-width: 460px; }
.lock-value {
  font-family: var(--font-heading); font-weight: 600; color: var(--acc); line-height: 1;
  font-size: clamp(44px, 13vw, 84px); font-variant-numeric: tabular-nums; margin-top: 10px;
  white-space: nowrap;
}
.lock-value.is-open { animation: lock-blink 1s steps(2, start) infinite; }
@keyframes lock-blink { to { visibility: hidden; } }
.lock-open { font-size: 16px; color: var(--text); margin: 0 0 6px; }
.lock-note { font-size: 14px; margin: 0 0 26px; }
@media (max-width: 520px) {
  .lock-wrap { padding: 24px 16px 60px; }
  .lock-panel { padding: 22px 16px; }
  .lock-logo { max-width: 150px; margin-bottom: 18px; }
}
@media (prefers-reduced-motion: reduce) { .lock-value.is-open { animation: none; } }

@media (max-width: 860px) {
  .two-col { grid-template-columns: 1fr; }
  h1 { font-size: 36px; }
  .wrap { padding: 30px 20px 70px; }
  .nav { gap: 14px; padding: 12px 18px; }
  /* Phones: let the nav wrap instead of widening the page (horizontal scroll). */
  .nav, .nav-left, .nav-right { flex-wrap: wrap; }
  .nav-left { gap: 6px 16px; }
  .nav-links { margin-left: 0; }
  .nav-right { margin-left: 0; gap: 8px 10px; }
  .brand-mark { white-space: nowrap; }
}
@media print { #pyr-rain, .ridge { display: none; } }

/* nav centering for the sponsor rotator: 3-column grid on wide screens. fitSponsors() in
   matrix-rain.js adds .nav-tight (back to the plain flex nav, rotator hidden) when even the
   shrunk rotator would collide — the right side's width depends on the user (admin/team links). */
@media (max-width: 1180px) { .sponsors { display: none; } }
@media (min-width: 1181px) {
  .nav:not(.nav-tight) { display: grid; grid-template-columns: 1fr auto 1fr; }
  .nav:not(.nav-tight) .nav-right { justify-self: end; }
  .nav:not(.nav-tight) .nav-links { flex-wrap: nowrap; }
  .nav:not(.nav-tight) :is(.nav-link, .brand, #pyr-clock) { white-space: nowrap; }
  .nav:not(.nav-tight) { gap: 22px; }
  .nav:not(.nav-tight) .nav-link { padding-left: 9px; padding-right: 9px; }
  .nav.nav-tight .sponsors { display: none; }
}
@media (prefers-reduced-motion: reduce) { .sponsor-wave { transition: none; transform: none; } }
