/* cysec-theme: layout, top bar, background field and special screens.
   Loaded after CTFd's bundle (main.css) and tokens.css.
   Bans: no cards, pills, badges, status dots, coloured side strips or small
   uppercase labels above headings. Hierarchy comes from size, weight and
   contrast. Hairlines and grids organise data. */

/* ---------- base and Bootstrap variables ---------- */
html[data-bs-theme="dark"] {
  --bs-body-bg: var(--bg);
  --bs-body-color: var(--fg);
  --bs-body-font-family: var(--font);
  --bs-emphasis-color: var(--fg);
  --bs-secondary-color: var(--mid);
  --bs-tertiary-color: var(--dim);
  --bs-secondary-bg: var(--track);
  --bs-tertiary-bg: var(--track);
  --bs-border-color: var(--line);
  --bs-link-color: var(--acc);
  --bs-link-color-rgb: 110, 155, 255;
  --bs-link-hover-color: var(--fg);
  --bs-link-hover-color-rgb: 242, 244, 252;
  --bs-heading-color: var(--fg);
  --bs-font-monospace: var(--mono);
  color-scheme: dark;
}

html {
  background: var(--bg);
}

body.cy {
  margin: 0;
  min-height: 100vh;
  background: var(--page-bg) fixed;
  color: var(--fg);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

body.cy h1, body.cy h2, body.cy h3, body.cy h4, body.cy h5, body.cy h6,
body.cy .h1, body.cy .h2, body.cy .h3, body.cy .h4, body.cy .h5, body.cy .h6 {
  font-family: var(--font);
  color: var(--fg);
}

body.cy code, body.cy kbd, body.cy pre, body.cy samp {
  font-family: var(--mono);
}

body.cy a:focus-visible,
body.cy button:focus-visible {
  outline: 2px solid var(--acc);
  outline-offset: 2px;
}

/* CTFd's page header strip: let the field show through (pages restyle it later). */
body.cy .jumbotron {
  background: transparent;
}

.cy-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.cy-skip {
  position: absolute;
  left: var(--gutter);
  top: -60px;
  z-index: 60;
  padding: 10px 14px;
  border-radius: 6px;
  background: var(--fg);
  color: var(--bg);
  font-weight: 700;
  text-decoration: none;
}
.cy-skip:focus {
  top: 10px;
}

/* ---------- background field ---------- */
.cy-field {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  display: block;
  z-index: 0;
  pointer-events: none;
}

.cy-scrim {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  /* Dimmed: working pages. The page content stays the hero. */
  background: linear-gradient(90deg, rgba(11, 15, 38, .94) 0%, rgba(11, 15, 38, .82) 55%, rgba(11, 15, 38, .35) 100%);
}

body[data-field="full"] .cy-scrim {
  /* Full: shade behind the text on the left, fingerprint bright on the right. */
  background: linear-gradient(90deg, rgba(11, 15, 38, .95) 0%, rgba(11, 15, 38, .74) 44%, rgba(11, 15, 38, 0) 74%);
}

/* CTFd's bundle pads main for its fixed navbar and sticky footer. Ours has neither. */
/* No z-index here: a stacking context on main would trap Bootstrap modals
   (the challenge window) under their backdrop, which sits on body. main comes
   after the field and scrim in the page, so it still paints above them. */
main.cy-main {
  position: relative;
  padding-top: 0;
  margin-bottom: 0;
}

/* ---------- top bar (decision 8, variant B) ---------- */
.cy-bar {
  position: sticky;
  top: 0;
  z-index: 30;
  border-bottom: 1px solid var(--line);
  background: rgba(11, 15, 38, .86);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}

.cy-bar-in {
  position: relative;
  max-width: var(--max);
  margin: 0 auto;
  padding: 0 var(--gutter);
  height: var(--bar-h);
  display: flex;
  align-items: center;
  gap: 28px;
}

/* Logo and the main links. */
.cy-left {
  display: flex;
  align-items: center;
  gap: 28px;
  min-width: 0;
}
/* Three columns, so the clock sits in the exact middle of the bar
   whatever is either side of it. Each column is set by number, so a bar
   with no clock keeps the account menu on the right. */
.cy-bar-in {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
}
.cy-left {
  grid-column: 1;
}
.cy-clock {
  grid-column: 2;
}
.cy-right {
  grid-column: 3;
  justify-self: end;
  max-width: 100%;
}

.cy-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: none;
  color: var(--fg);
  text-decoration: none;
}
.cy-logo:hover {
  color: var(--fg);
}
.cy-logo img {
  display: block;
  height: 44px;
  width: auto;
}
.cy-logo span {
  font-weight: 800;
  font-size: 15px;
  line-height: 1.1;
}
.cy-logo small {
  display: block;
  font-weight: 500;
  font-size: 12px;
  color: var(--dim);
}

.cy-nav {
  display: flex;
  gap: 22px;
}
.cy-nav a {
  color: var(--mid);
  text-decoration: none;
  font-weight: 600;
  font-size: 15px;
  padding: 24px 0 21px;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
}
.cy-nav a:hover {
  color: var(--fg);
}
.cy-nav a.on {
  color: var(--fg);
  border-bottom: 2px solid;
  border-image: var(--grad) 1;
}
/* Leadership link with its state next to it ("In progress, 3 of 41"). */
.cy-nav-lead {
  display: flex;
  align-items: center;
  gap: 8px;
}
.cy-nav-lead small {
  color: var(--dim);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.cy-tab-note {
  display: block;
  margin-top: 1px;
  color: var(--dim);
  font-size: 11px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

/* The middle column of the bar (see .cy-bar-in). */
.cy-clock {
  text-align: center;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}
.cy-clock b {
  display: block;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -.01em;
}
.cy-clock small {
  display: block;
  color: var(--dim);
  font-weight: 500;
  font-size: 12px;
}
.cy-clock-line {
  display: block;
  height: 2px;
  margin-top: 4px;
  border-radius: 1px;
  overflow: hidden;
  background: var(--track);
}
.cy-clock-line i {
  display: block;
  height: 100%;
  background: var(--grad);
  transform-origin: left center;
  transition: transform 1s linear;
}
.cy-clock[hidden] {
  display: none;
}
.cy-clock[data-state="paused"] b {
  color: var(--warn);
}

.cy-right {
  position: relative;
  display: flex;
  align-items: center;
  gap: 22px;
  min-width: 0;
}

.cy-me {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 10px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--fg);
  font: 600 14px var(--font);
  text-align: left;
  cursor: pointer;
}
.cy-me i {
  width: 32px;
  height: 32px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid var(--line2);
  background: var(--track);
  font-style: normal;
  font-weight: 700;
  font-size: 13px;
}
.cy-me-txt {
  display: block;
  min-width: 0;
  max-width: 180px;
}
.cy-me-name,
.cy-me small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cy-me small {
  color: var(--dim);
  font-weight: 500;
  font-size: 12px;
}

.cy-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 14px);
  width: 240px;
  padding: 6px 0;
  border: 1px solid var(--line2);
  border-radius: 6px;
  background: var(--bg);
  animation: cy-drop .18s var(--ease);
}
.cy-menu[hidden] {
  display: none;
}
.cy-menu a {
  display: block;
  padding: 10px 16px;
  color: var(--mid);
  text-decoration: none;
  font-weight: 600;
  font-size: 14px;
}
.cy-menu a:hover,
.cy-menu a:focus-visible,
.cy-menu a[aria-current="page"] {
  color: var(--fg);
  background: var(--track);
}
.cy-menu hr {
  margin: 6px 0;
  border: 0;
  border-top: 1px solid var(--line);
  opacity: 1;
}
@keyframes cy-drop {
  from { opacity: 0; transform: translateY(-4px); }
}

.cy-signin {
  color: var(--fg);
  font-weight: 700;
  font-size: 15px;
  text-decoration: none;
}

.cy-tabbar {
  display: none;
}

/* The bar sheds detail as it narrows, so it never runs wider than the
   screen. The short Leadership state ("3 of 41") is for the eye only: the
   link still describes itself with the full state (#cy-lead-state). */
.cy-nav-lead .cy-lead-short {
  display: none;
}
@media (max-width: 1280px) {
  .cy-nav-lead #cy-lead-state {
    display: none;
  }
  .cy-nav-lead .cy-lead-short {
    display: inline;
  }
}
/* Between phone and wide desktop the logo shows only the badge and the
   menu button only the initials, so the clock keeps the middle. */
@media (max-width: 1100px) {
  .cy-me-txt,
  .cy-logo span {
    display: none;
  }
}
@media (max-width: 960px) {
  .cy-bar-in,
  .cy-left,
  .cy-right,
  .cy-nav {
    gap: 16px;
  }
}

/* ---------- special screens (decision 11) ---------- */
.cy-stage {
  min-height: calc(100vh - var(--bar-h) - 1px);
  max-width: var(--max);
  margin: 0 auto;
  padding: 48px var(--gutter);
  display: flex;
  align-items: center;
}

.cy-screen {
  width: min(560px, 100%);
}
.cy-screen h1 {
  margin: 0 0 16px;
  font-size: 54px;
  line-height: 1.02;
  letter-spacing: -.035em;
  font-weight: 800;
  overflow-wrap: anywhere;
}
.cy-screen p {
  margin: 0 0 20px;
  color: var(--mid);
  font-size: 17px;
  line-height: 1.55;
  max-width: 52ch;
}
.cy-screen p b {
  color: var(--fg);
}
.cy-screen .cy-warn,
.cy-warn {
  color: var(--warn);
}

.cy-big {
  margin: 0 0 12px;
  font-size: 128px;
  line-height: .9;
  font-weight: 800;
  letter-spacing: -.05em;
  background: var(--grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.cy-countdown,
.cy-facts {
  display: grid;
  justify-content: start;
  margin: 4px 0 24px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.cy-countdown {
  grid-template-columns: repeat(4, auto);
}
.cy-facts {
  grid-template-columns: repeat(3, auto);
}
.cy-facts.cy-facts-4 {
  grid-template-columns: repeat(4, auto);
}
.cy-countdown > div,
.cy-facts > div {
  padding: 16px 28px 14px 0;
  margin-right: 28px;
  border-right: 1px solid var(--line);
}
.cy-countdown > div:last-child,
.cy-facts > div:last-child {
  margin-right: 0;
  border-right: 0;
}
.cy-countdown b,
.cy-facts b {
  display: block;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
.cy-countdown b {
  font-size: 52px;
  letter-spacing: -.03em;
}
.cy-facts b {
  font-size: 30px;
  margin-bottom: 4px;
}
.cy-facts b small {
  color: var(--dim);
  font-size: 16px;
  font-weight: 700;
}
.cy-countdown span,
.cy-facts span {
  color: var(--dim);
  font-size: 14px;
  font-weight: 600;
}

.cy-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.cy-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 14px 22px;
  border: 0;
  border-radius: 6px;
  font: 700 15px var(--font);
  text-decoration: none;
  cursor: pointer;
  transition: transform .15s var(--ease);
}
.cy-btn:active {
  transform: scale(.97);
}
.cy-btn.p {
  background: var(--fg);
  color: var(--bg);
}
.cy-btn.s {
  background: var(--track);
  color: var(--fg);
}
.cy-btn.p:hover {
  color: var(--bg);
}
.cy-btn.s:hover {
  color: var(--fg);
  background: var(--line);
}

.cy-wait {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
}
.cy-wait i {
  width: 14px;
  height: 14px;
  flex: none;
  border: 2px solid var(--warn);
  border-right-color: transparent;
  border-radius: 50%;
  animation: cy-spin 1s linear infinite;
}
@keyframes cy-spin {
  to { transform: rotate(360deg); }
}

/* Entrance rise: children come up one after another. */
.cy-rise > * {
  opacity: 0;
  animation: cy-rise var(--rise) var(--ease) forwards;
}
.cy-rise > *:nth-child(2) { animation-delay: calc(var(--stagger) * 1); }
.cy-rise > *:nth-child(3) { animation-delay: calc(var(--stagger) * 2); }
.cy-rise > *:nth-child(4) { animation-delay: calc(var(--stagger) * 3); }
.cy-rise > *:nth-child(5) { animation-delay: calc(var(--stagger) * 4); }
.cy-rise > *:nth-child(n+6) { animation-delay: calc(var(--stagger) * 5); }
@keyframes cy-rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

/* ---------- live notifications ---------- */
.cy-toasts {
  position: fixed;
  right: 0;
  bottom: 0;
  z-index: 1090;
  padding: var(--gutter);
}
.cy-toast {
  --bs-toast-bg: var(--bg);
  --bs-toast-header-bg: var(--bg);
  --bs-toast-header-color: var(--fg);
  --bs-toast-color: var(--mid);
  --bs-toast-border-color: var(--line2);
  --bs-toast-border-radius: 6px;
  --bs-toast-header-border-color: var(--line);
}
.cy-modal {
  --bs-modal-bg: var(--bg);
  --bs-modal-color: var(--mid);
  --bs-modal-border-color: var(--line2);
  --bs-modal-border-radius: 6px;
  --bs-modal-header-border-color: var(--line);
  --bs-modal-footer-border-color: var(--line);
}
.cy-modal .modal-title {
  font-size: 22px;
  font-weight: 800;
  color: var(--fg);
}

/* ---------- phones ---------- */
@media (max-width: 760px) {
  .cy-bar-in {
    gap: 12px;
  }
  .cy-logo img {
    height: 36px;
  }
  .cy-nav,
  .cy-me-txt {
    display: none;
  }
  .cy-clock b {
    font-size: 16px;
  }
  .cy-clock small {
    display: none;
  }
  .cy-right {
    gap: 12px;
  }
  .cy-menu {
    top: calc(100% + 12px);
    width: min(240px, calc(100vw - 2 * var(--gutter)));
  }

  .cy-tabbar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 30;
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: 1fr;
    padding-bottom: env(safe-area-inset-bottom, 0px);
    border-top: 1px solid var(--line);
    background: rgba(11, 15, 38, .96);
  }
  .cy-tabbar a {
    padding: 12px 0 14px;
    text-align: center;
    color: var(--mid);
    font-weight: 600;
    font-size: 13px;
    text-decoration: none;
  }
  .cy-tabbar a.on {
    color: var(--fg);
    box-shadow: inset 0 2px 0 var(--acc);
  }
  body.cy:has(.cy-tabbar) main.cy-main {
    padding-bottom: 56px;
  }
  body.cy:has(.cy-tabbar) .cy-toasts {
    bottom: 50px;
  }

  .cy-scrim {
    background: linear-gradient(180deg, rgba(11, 15, 38, .94) 0%, rgba(11, 15, 38, .84) 60%, rgba(11, 15, 38, .6) 100%);
  }
  body[data-field="full"] .cy-scrim {
    background: linear-gradient(180deg, rgba(11, 15, 38, .94) 0%, rgba(11, 15, 38, .66) 58%, rgba(11, 15, 38, .1) 88%);
  }

  .cy-stage {
    align-items: flex-start;
    padding-top: 32px;
    min-height: 0;
  }
  .cy-screen h1 {
    font-size: 36px;
  }
  .cy-big {
    font-size: 88px;
  }
  .cy-countdown b {
    font-size: 34px;
  }
  .cy-facts b {
    font-size: 24px;
  }
  .cy-countdown > div,
  .cy-facts > div {
    padding-right: 14px;
    margin-right: 14px;
  }
}

/* Four facts (the ended screen in a team) go two by two on phones, with a
   hairline between the rows. */
@media (max-width: 560px) {
  .cy-facts.cy-facts-4 {
    grid-template-columns: repeat(2, auto);
  }
  .cy-facts.cy-facts-4 > div:nth-child(2) {
    margin-right: 0;
    border-right: 0;
  }
  .cy-facts.cy-facts-4 > div:nth-child(n+3) {
    border-top: 1px solid var(--line);
  }
}

@media (max-width: 340px) {
  .cy-logo span {
    display: none;
  }
}

@media (max-width: 400px) {
  .cy-countdown b {
    font-size: 28px;
  }
  .cy-countdown > div,
  .cy-facts > div {
    padding-right: 10px;
    margin-right: 10px;
  }
}

/* ---------- reduced motion: nothing moves ---------- */
@media (prefers-reduced-motion: reduce) {
  .cy-rise > * {
    opacity: 1;
    animation: none;
  }
  .cy-menu,
  .cy-wait i {
    animation: none;
  }
  .cy-clock-line i,
  .cy-btn {
    transition: none;
  }
}
