/* ==========================================================================
   Hogwarts theme for CTFd
   Layered on top of the core theme's compiled Bootstrap stylesheet.
   Dark mode  = the Great Hall at night
   Light mode = an old parchment scroll
   ========================================================================== */

:root,
[data-bs-theme="dark"] {
  --hp-bg: #0b0d1a;
  --hp-bg-2: #141833;
  --hp-surface: rgba(22, 26, 52, 0.82);
  --hp-surface-solid: #161a34;
  --hp-border: rgba(212, 175, 55, 0.35);
  --hp-text: #ece3c8;
  --hp-muted: #a99f84;
  --hp-gold: #d4af37;
  --hp-gold-bright: #f3d77a;
  --hp-glow: rgba(243, 215, 122, 0.45);
  --hp-solved: #1a472a;
  --hp-solved-bright: #2a7a46;

  --hp-gryffindor: #740001;
  --hp-slytherin: #1a472a;
  --hp-ravenclaw: #0e1a40;
  --hp-hufflepuff: #a8790b;

  --bs-body-bg: var(--hp-bg);
  --bs-body-color: var(--hp-text);
  --bs-secondary-color: var(--hp-muted);
  --bs-border-color: var(--hp-border);
  --bs-link-color: var(--hp-gold-bright);
  --bs-link-color-rgb: 243, 215, 122;
  --bs-link-hover-color: #fff2c4;
  --bs-link-hover-color-rgb: 255, 242, 196;
  --bs-primary: #740001;
  --bs-primary-rgb: 116, 0, 1;
  --bs-emphasis-color: #fff8e1;
  --bs-tertiary-bg: var(--hp-bg-2);
}

[data-bs-theme="light"] {
  --hp-bg: #efe2c0;
  --hp-bg-2: #e6d4a8;
  --hp-surface: rgba(250, 241, 214, 0.9);
  --hp-surface-solid: #f7ecd0;
  --hp-border: rgba(110, 72, 24, 0.4);
  --hp-text: #3b2a14;
  --hp-muted: #6f5a3a;
  --hp-gold: #9a7414;
  --hp-gold-bright: #7a1f12;
  --hp-glow: rgba(154, 116, 20, 0.35);
  --hp-solved: #2a6b3f;
  --hp-solved-bright: #358a50;

  --bs-body-bg: var(--hp-bg);
  --bs-body-color: var(--hp-text);
  --bs-secondary-color: var(--hp-muted);
  --bs-border-color: var(--hp-border);
  --bs-link-color: #7a1f12;
  --bs-link-color-rgb: 122, 31, 18;
  --bs-link-hover-color: #a8321e;
  --bs-link-hover-color-rgb: 168, 50, 30;
  --bs-primary: #740001;
  --bs-primary-rgb: 116, 0, 1;
  --bs-emphasis-color: #24180a;
  --bs-tertiary-bg: var(--hp-bg-2);
}

/* ---------- Page background ---------- */

html,
body,
.container,
.jumbotron .container {
  font-family: "EB Garamond", Georgia, "Times New Roman", serif;
}

body {
  font-size: 1.08rem;
  color: var(--hp-text);
  background-color: var(--hp-bg);
  background-attachment: fixed;
}

[data-bs-theme="dark"] body {
  background-image:
    radial-gradient(ellipse at 50% -10%, rgba(116, 0, 1, 0.35), transparent 55%),
    radial-gradient(ellipse at 100% 100%, rgba(14, 26, 64, 0.9), transparent 60%),
    linear-gradient(180deg, #0b0d1a 0%, #10132a 60%, #0b0d1a 100%);
}

[data-bs-theme="light"] body {
  background-image:
    radial-gradient(ellipse at center, rgba(255, 250, 230, 0.6) 0%, transparent 70%),
    radial-gradient(ellipse at 0% 0%, rgba(120, 80, 30, 0.25), transparent 45%),
    radial-gradient(ellipse at 100% 100%, rgba(120, 80, 30, 0.3), transparent 45%),
    linear-gradient(180deg, #f1e4c3, #e8d6aa);
}

/* Effects layer (stars / candles), filled by hogwarts.js */
/* Negative z-index paints the sky above the page background but below all
   content, without giving main its own stacking context (which would trap
   Bootstrap modals underneath their backdrop). */
#hp-sky {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: -1;
  overflow: hidden;
}

.hp-star {
  position: absolute;
  width: 2px;
  height: 2px;
  border-radius: 50%;
  background: #fff8dc;
  animation: hp-twinkle var(--d, 4s) ease-in-out infinite;
  animation-delay: var(--delay, 0s);
}

[data-bs-theme="light"] .hp-star {
  display: none;
}

.hp-candle {
  position: absolute;
  top: 0;
  width: 10px;
  height: 46px;
  border-radius: 2px;
  background: linear-gradient(90deg, #d8cfb4, #fffaf0 45%, #cfc3a2);
  opacity: 0.85;
  animation: hp-float var(--d, 7s) ease-in-out infinite;
  animation-delay: var(--delay, 0s);
}

.hp-candle::before {
  /* flame */
  content: "";
  position: absolute;
  left: 50%;
  top: -16px;
  width: 8px;
  height: 14px;
  transform: translateX(-50%);
  border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
  background: radial-gradient(circle at 50% 70%, #fff 0%, #ffd56a 35%, #ff8a00 75%, transparent 80%);
  box-shadow: 0 0 18px 6px rgba(255, 196, 80, 0.45);
  animation: hp-flicker 0.15s ease-in-out infinite alternate;
}

[data-bs-theme="light"] .hp-candle {
  display: none;
}

@keyframes hp-twinkle {
  0%, 100% { opacity: 0.15; }
  50% { opacity: 1; }
}

@keyframes hp-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-14px); }
}

@keyframes hp-flicker {
  from { transform: translateX(-50%) scale(1, 1); opacity: 0.9; }
  to { transform: translateX(-50%) scale(0.9, 1.1); opacity: 1; }
}

/* Wand sparkles that follow clicks */
.hp-spark {
  position: fixed;
  pointer-events: none;
  z-index: 9999;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--hp-gold-bright);
  box-shadow: 0 0 8px 2px var(--hp-glow);
  animation: hp-spark 0.8s ease-out forwards;
}

@keyframes hp-spark {
  to {
    transform: translate(var(--dx), var(--dy)) scale(0);
    opacity: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .hp-star,
  .hp-candle,
  .hp-candle::before {
    animation: none;
  }
  .hp-spark {
    display: none;
  }
}

/* ---------- Typography ---------- */

h1, h2, h3, h4, h5, h6,
.navbar-brand,
.modal-title {
  font-family: "Cinzel", Georgia, serif;
  letter-spacing: 1px;
  font-variant-ligatures: no-common-ligatures no-discretionary-ligatures no-contextual;
}

/* Landing title matches the condensed lettering under the Securinets logo */
.hp-hero-title {
  font-family: "Oswald", "Arial Narrow", sans-serif;
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  /* trailing tracking would push the text off-centre */
  margin-right: -0.18em;
}

h1, h2 {
  color: var(--hp-gold-bright);
  font-weight: 700;
}

[data-bs-theme="dark"] h1,
[data-bs-theme="dark"] h2 {
  text-shadow: 0 0 18px var(--hp-glow);
}

.text-muted {
  color: var(--hp-muted) !important;
}

hr {
  border-color: var(--hp-border);
  opacity: 1;
}

::selection {
  background: var(--hp-gold);
  color: #1a1206;
}

/* ---------- Navbar ---------- */

.navbar.bg-dark {
  background: linear-gradient(180deg, #2a0303 0%, #4a0606 100%) !important;
  border-bottom: 2px solid var(--hp-gold);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.55);
}

.navbar .navbar-brand {
  color: #f3d77a !important;
  font-weight: 700;
  text-shadow: 0 0 10px rgba(243, 215, 122, 0.5);
}

/* 4px + 64px logo + 10px logo margin + 4px = 82px navbar, so push content down to match */
.navbar.fixed-top {
  padding-top: 4px;
  padding-bottom: 4px;
}

main {
  padding-top: 82px;
}

.navbar .navbar-brand {
  padding-top: 0;
  padding-bottom: 0;
}

/* Nudge the logo left of the container edge on wider screens */
@media (min-width: 768px) {
  .navbar .navbar-brand {
    margin-left: -32px;
  }
}

.navbar .hp-logo {
  height: 64px;
  margin-bottom: 10px;
  width: auto;
  filter: drop-shadow(0 0 6px rgba(243, 215, 122, 0.35));
  transition: filter 0.2s;
}

.navbar .navbar-brand:hover .hp-logo {
  filter: drop-shadow(0 0 10px rgba(243, 215, 122, 0.8));
}

.navbar .navbar-brand .hp-bolt {
  color: #f3d77a;
  margin-right: 0.4rem;
}

.navbar .nav-link {
  font-family: "Cinzel", Georgia, serif;
  color: #ecd9a0 !important;
  transition: color 0.2s, text-shadow 0.2s;
}

.navbar .nav-link:hover,
.navbar .nav-link:focus {
  color: #fff4c8 !important;
  text-shadow: 0 0 8px rgba(243, 215, 122, 0.8);
}

.dropdown-menu {
  background: var(--hp-surface-solid);
  border: 1px solid var(--hp-border);
}

.dropdown-item {
  color: var(--hp-text);
  cursor: pointer;
}

.dropdown-item:hover {
  background: rgba(212, 175, 55, 0.18);
  color: var(--hp-text);
}

/* ---------- Jumbotron (page headers) ---------- */

.jumbotron {
  position: relative;
  background: transparent !important;
  color: var(--hp-text) !important;
  border-bottom: 1px solid var(--hp-border);
  overflow: hidden;
}

.jumbotron::after {
  /* ornamental divider */
  content: "\2726  \2767  \2726";
  display: block;
  margin-top: 1rem;
  color: var(--hp-gold);
  letter-spacing: 0.6rem;
  font-size: 1.1rem;
}

.jumbotron h1 {
  font-size: clamp(2rem, 5vw, 3.4rem);
}

.hp-subtitle {
  font-style: italic;
  color: var(--hp-muted);
  font-size: 1.15rem;
  margin-top: 0.5rem;
}

/* ---------- Cards, modals, forms ---------- */

.card,
.modal-content,
.list-group-item,
.toast {
  background: var(--hp-surface) !important;
  color: var(--hp-text);
  border: 1px solid var(--hp-border) !important;
  backdrop-filter: blur(4px);
}

.modal-content {
  background: var(--hp-surface-solid) !important;
  box-shadow: 0 0 40px rgba(0, 0, 0, 0.6), 0 0 0 4px rgba(212, 175, 55, 0.12);
  border-radius: 10px;
}

[data-bs-theme="light"] .modal-content {
  box-shadow: 0 10px 40px rgba(60, 40, 10, 0.45), inset 0 0 60px rgba(120, 80, 30, 0.18);
}

.modal-header,
.modal-footer {
  border-color: var(--hp-border);
}

.nav-tabs {
  border-color: var(--hp-border);
}

.nav-tabs .nav-link {
  font-family: "Cinzel", Georgia, serif;
  color: var(--hp-muted);
}

.nav-tabs .nav-link.active {
  background: transparent;
  color: var(--hp-gold-bright);
  border-color: var(--hp-border) var(--hp-border) transparent;
}

.form-control,
.form-select {
  background-color: rgba(0, 0, 0, 0.25);
  color: var(--hp-text);
  border: 1px solid var(--hp-border);
  font-family: "EB Garamond", Georgia, serif;
}

[data-bs-theme="light"] .form-control,
[data-bs-theme="light"] .form-select {
  background-color: rgba(255, 252, 240, 0.7);
}

.form-control::placeholder {
  color: var(--hp-muted);
  font-style: italic;
}

.form-control:focus,
.form-select:focus {
  background-color: rgba(0, 0, 0, 0.3);
  color: var(--hp-text);
  border-color: var(--hp-gold);
  box-shadow: 0 0 0 0.2rem var(--hp-glow);
}

[data-bs-theme="light"] .form-control:focus {
  background-color: #fffaf0;
}

/* ---------- Buttons ---------- */

.btn {
  font-family: "Cinzel", Georgia, serif;
  letter-spacing: 0.5px;
}

.btn-primary,
.btn-outline-primary:hover {
  background: linear-gradient(180deg, #8f0a0b, #5c0001);
  border: 1px solid var(--hp-gold);
  color: #fdf1c9;
}

.btn-primary:hover,
.btn-primary:focus,
.btn-primary:active {
  background: linear-gradient(180deg, #a5150f, #740001) !important;
  border-color: var(--hp-gold-bright) !important;
  color: #fff !important;
  box-shadow: 0 0 14px var(--hp-glow);
}

.btn-outline-primary {
  color: var(--hp-gold-bright);
  border-color: var(--hp-gold);
}

.btn-success {
  background: linear-gradient(180deg, #2a6b3f, #1a472a);
  border-color: var(--hp-gold);
}

/* ---------- Challenge board ---------- */

.category-header h3 {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--hp-gold-bright);
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--hp-border);
}

.category-header h3::before {
  content: "";
  width: 14px;
  height: 22px;
  flex: none;
  background: var(--hp-house, var(--hp-gryffindor));
  border: 1px solid var(--hp-gold);
  clip-path: polygon(0 0, 100% 0, 100% 75%, 50% 100%, 0 75%);
}

/* Each category gets a house colour in turn */
[x-data="ChallengeBoard"] > div[x-show="loaded"] > div:nth-of-type(4n + 1) { --hp-house: var(--hp-gryffindor); }
[x-data="ChallengeBoard"] > div[x-show="loaded"] > div:nth-of-type(4n + 2) { --hp-house: var(--hp-slytherin); }
[x-data="ChallengeBoard"] > div[x-show="loaded"] > div:nth-of-type(4n + 3) { --hp-house: var(--hp-ravenclaw); }
[x-data="ChallengeBoard"] > div[x-show="loaded"] > div:nth-of-type(4n + 4) { --hp-house: var(--hp-hufflepuff); }

[data-bs-theme] .challenge-button {
  position: relative;
  border: 1px solid var(--hp-border) !important;
  border-top: 4px solid var(--hp-house, var(--hp-gryffindor)) !important;
  border-radius: 8px;
  background: var(--hp-surface) !important;
  color: var(--hp-text) !important;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

[data-bs-theme="light"] .challenge-button {
  box-shadow: 0 4px 14px rgba(80, 50, 10, 0.25), inset 0 0 30px rgba(140, 100, 40, 0.12);
}

[data-bs-theme] .challenge-button:hover,
[data-bs-theme] .challenge-button:focus-visible {
  transform: translateY(-4px);
  border-color: var(--hp-gold) !important;
  box-shadow: 0 0 22px var(--hp-glow);
}

.challenge-button .challenge-inner p {
  font-family: "Cinzel", Georgia, serif;
  font-weight: 700;
  font-size: 1.05rem;
  margin-bottom: 0.4rem;
}

.challenge-button .challenge-inner span {
  font-family: "Cinzel Decorative", Georgia, serif;
  color: var(--hp-gold-bright);
  font-size: 1.25rem;
}

.challenge-button .challenge-inner span::after {
  content: " pts";
  font-family: "EB Garamond", Georgia, serif;
  font-size: 0.85rem;
  color: var(--hp-muted);
}

/* Solved: sealed with a wax seal */
[data-bs-theme] .challenge-button.challenge-solved {
  background: linear-gradient(160deg, var(--hp-solved-bright), var(--hp-solved)) !important;
  color: #f4ecd2 !important;
}

[data-bs-theme] .challenge-button.challenge-solved .challenge-inner span,
[data-bs-theme] .challenge-button.challenge-solved .challenge-inner span::after {
  color: #f3d77a;
}

.challenge-button.challenge-solved::after {
  content: "\2713";
  position: absolute;
  top: -12px;
  right: -10px;
  width: 34px;
  height: 34px;
  line-height: 34px;
  border-radius: 50%;
  font-weight: 700;
  color: #f8e3b0;
  background: radial-gradient(circle at 35% 35%, #c0262b, #7a0d10 70%);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
}

/* ---------- Tables (scoreboard, users, teams) ---------- */

.table {
  --bs-table-bg: transparent;
  --bs-table-color: var(--hp-text);
  --bs-table-border-color: var(--hp-border);
  --bs-table-striped-bg: rgba(212, 175, 55, 0.06);
  --bs-table-hover-bg: rgba(212, 175, 55, 0.12);
  --bs-table-hover-color: var(--hp-text);
}

.table thead th {
  font-family: "Cinzel", Georgia, serif;
  color: var(--hp-gold-bright);
  border-bottom: 2px solid var(--hp-gold) !important;
}

/* Top three on the scoreboard: gold, silver, bronze */
#scoreboard tbody tr:nth-child(1) th,
#scoreboard tbody tr:nth-child(1) td:first-child { color: #f3d77a; }
#scoreboard tbody tr:nth-child(2) th,
#scoreboard tbody tr:nth-child(2) td:first-child { color: #d9d9d9; }
#scoreboard tbody tr:nth-child(3) th,
#scoreboard tbody tr:nth-child(3) td:first-child { color: #cd8a4b; }

/* ---------- Misc ---------- */

.badge.bg-primary,
.bg-primary {
  background-color: #740001 !important;
}

.alert {
  border: 1px solid var(--hp-border);
  font-style: italic;
}

.footer {
  z-index: 1;
  font-family: "Cinzel", Georgia, serif;
}

.footer .hp-mischief {
  color: var(--hp-gold);
  letter-spacing: 1px;
}

.spinner {
  color: var(--hp-gold-bright);
}


/* ==========================================================================
   Landing page (index)
   ========================================================================== */

.hp-hero {
  min-height: calc(100vh - 82px - 100px);
  display: flex;
  align-items: center;
  text-align: center;
  padding: 3rem 0 2rem;
}

.hp-hero-crest {
  width: min(260px, 60vw);
  height: auto;
  filter: drop-shadow(0 0 24px var(--hp-glow));
  animation: hp-float 6s ease-in-out infinite;
}

[data-bs-theme="light"] .hp-hero-crest {
  /* white artwork needs a dark backing on parchment */
  filter: invert(18%) sepia(60%) saturate(1200%) hue-rotate(340deg) brightness(0.55)
    drop-shadow(0 4px 10px rgba(80, 40, 10, 0.35));
}

.hp-hero-title {
  font-size: clamp(2.4rem, 7vw, 4.8rem);
  margin-top: 1.5rem;
}

.hp-hero-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 1rem;
  margin-top: 2rem;
}

.hp-hero-actions .btn-lg {
  padding: 0.75rem 1.75rem;
  min-width: 220px;
}

.hp-countdown {
  margin-top: 2rem;
}

.hp-countdown-label {
  font-family: "Cinzel", Georgia, serif;
  color: var(--hp-muted);
  letter-spacing: 2px;
  text-transform: uppercase;
  font-size: 0.9rem;
  margin-bottom: 0.75rem;
}

.hp-countdown-units {
  display: inline-flex;
  gap: 0.75rem;
}

.hp-countdown-units > div {
  min-width: 78px;
  padding: 0.6rem 0.4rem;
  border: 1px solid var(--hp-border);
  border-radius: 8px;
  background: var(--hp-surface);
}

.hp-countdown-units span {
  display: block;
  font-family: "Cinzel", Georgia, serif;
  font-weight: 700;
  font-size: 1.9rem;
  line-height: 1.1;
  color: var(--hp-gold-bright);
  font-variant-numeric: tabular-nums;
}

.hp-countdown-units small {
  font-size: 0.75rem;
  color: var(--hp-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.hp-countdown-done {
  font-family: "Cinzel", Georgia, serif;
  color: var(--hp-gold-bright);
  font-size: 1.3rem;
}

.hp-houses {
  display: flex;
  justify-content: center;
  gap: 0.9rem;
  margin-top: 2.5rem;
}

.hp-house {
  width: 22px;
  height: 32px;
  border: 1px solid var(--hp-gold);
  clip-path: polygon(0 0, 100% 0, 100% 75%, 50% 100%, 0 75%);
  opacity: 0.9;
}

.hp-house-gryffindor { background: linear-gradient(180deg, #ae0001, #740001); }
.hp-house-slytherin { background: linear-gradient(180deg, #2a623d, #1a472a); }
.hp-house-ravenclaw { background: linear-gradient(180deg, #222f5b, #0e1a40); }
.hp-house-hufflepuff { background: linear-gradient(180deg, #ecb939, #a8790b); }

.hp-page-content:not(:empty) {
  margin-bottom: 3rem;
}

@media (max-width: 575px) {
  .hp-countdown-units > div { min-width: 64px; }
  .hp-countdown-units span { font-size: 1.4rem; }
  .hp-hero-actions .btn-lg { min-width: 0; width: 100%; }
}

/* ==========================================================================
   Parchment panels for auth and team forms
   ========================================================================== */

main > .jumbotron + .container > .row > [class*="offset-md"]:has(> form) {
  padding: 2rem 2rem 1.5rem;
  border: 1px solid var(--hp-border);
  border-radius: 10px;
  background: var(--hp-surface);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35), inset 0 0 0 4px rgba(212, 175, 55, 0.06);
}

[data-bs-theme="light"] main > .jumbotron + .container > .row > [class*="offset-md"]:has(> form) {
  box-shadow: 0 8px 24px rgba(80, 50, 10, 0.25), inset 0 0 40px rgba(140, 100, 40, 0.15);
}

@media (max-width: 767px) {
  main > .jumbotron + .container > .row > [class*="offset-md"]:has(> form) {
    width: auto;
    margin-inline: 12px;
    padding: 1.5rem 1.25rem 1.25rem;
  }
}

/* ==========================================================================
   Challenge board progress
   ========================================================================== */

.hp-board-progress {
  margin-top: 1rem;
  padding: 1rem 1.25rem;
  border: 1px solid var(--hp-border);
  border-radius: 10px;
  background: var(--hp-surface);
}

.hp-board-progress-label {
  font-family: "Cinzel", Georgia, serif;
  color: var(--hp-gold-bright);
}

.hp-board-progress-count {
  font-family: "Cinzel", Georgia, serif;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.hp-progress-track {
  height: 10px;
  border-radius: 5px;
  background: rgba(0, 0, 0, 0.3);
  overflow: hidden;
}

[data-bs-theme="light"] .hp-progress-track {
  background: rgba(110, 72, 24, 0.15);
}

.hp-progress-fill {
  height: 100%;
  border-radius: 5px;
  background: linear-gradient(90deg, #9a7414, #f3d77a, #9a7414);
  background-size: 200% 100%;
  box-shadow: 0 0 10px var(--hp-glow);
  transition: width 0.6s ease;
  animation: hp-shimmer 3s linear infinite;
}

@keyframes hp-shimmer {
  to { background-position: -200% 0; }
}

.hp-cat-progress {
  margin-left: auto;
  font-size: 0.95rem;
  color: var(--hp-muted);
  font-variant-numeric: tabular-nums;
}

/* ==========================================================================
   Bootstrap leftovers (blue pills, secondary buttons, progress bars)
   ========================================================================== */

.nav-pills {
  --bs-nav-pills-link-active-bg: #740001;
  --bs-nav-pills-link-active-color: #fdf1c9;
}

.nav-pills .nav-link {
  font-family: "Cinzel", Georgia, serif;
}

.nav-pills .nav-link.active {
  border: 1px solid var(--hp-gold);
}

.btn-secondary,
.btn-outline-secondary:hover {
  background: var(--hp-surface-solid);
  border-color: var(--hp-border);
  color: var(--hp-text);
}

.btn-outline-secondary {
  color: var(--hp-text);
  border-color: var(--hp-border);
}

.btn-info {
  background: linear-gradient(180deg, #222f5b, #0e1a40);
  border-color: var(--hp-gold);
  color: #f3d77a;
}

.progress {
  background: rgba(0, 0, 0, 0.25);
}

.progress-bar {
  background-color: var(--hp-gold);
}

/* Challenge modal: clear the fixed navbar */
@media (min-width: 576px) {
  .modal-dialog {
    margin-top: 100px;
  }
}
.modal-backdrop.show {
  opacity: 0.75;
}

.modal-content .challenge-desc {
  font-size: 1.1rem;
}

.modal-content code,
.challenge-desc code {
  color: var(--hp-gold-bright);
  background: rgba(0, 0, 0, 0.3);
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
}

[data-bs-theme="light"] .modal-content code,
[data-bs-theme="light"] .challenge-desc code {
  background: rgba(110, 72, 24, 0.12);
}

.modal-content .btn-close {
  filter: invert(85%) sepia(30%) saturate(500%) hue-rotate(5deg);
}

[data-bs-theme="light"] .modal-content .btn-close {
  filter: none;
}

/* ==========================================================================
   Golden snitch
   ========================================================================== */

.hp-snitch {
  position: fixed;
  z-index: 1029;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fff6c8, #e8c252 45%, #9a7414);
  box-shadow: 0 0 12px rgba(243, 215, 122, 0.8);
  pointer-events: auto;
  cursor: pointer;
}

.hp-snitch::before,
.hp-snitch::after {
  content: "";
  position: absolute;
  top: 2px;
  width: 26px;
  height: 10px;
  border-radius: 50% 50% 50% 50% / 100% 100% 0 0;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.95), rgba(220, 220, 220, 0.5));
  animation: hp-flap 0.08s ease-in-out infinite alternate;
}

.hp-snitch::before {
  right: 14px;
  transform-origin: right bottom;
}

.hp-snitch::after {
  left: 14px;
  transform-origin: left bottom;
}

@keyframes hp-flap {
  from { transform: rotate(-25deg) scaleY(1); }
  to { transform: rotate(15deg) scaleY(0.4); }
}

/* ==========================================================================
   Scrollbar
   ========================================================================== */

html {
  scrollbar-color: var(--hp-gold) var(--hp-bg);
}

::-webkit-scrollbar {
  width: 10px;
}

::-webkit-scrollbar-track {
  background: var(--hp-bg);
}

::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, #9a7414, #d4af37);
  border-radius: 5px;
}

@media (prefers-reduced-motion: reduce) {
  .hp-hero-crest,
  .hp-progress-fill {
    animation: none;
  }
  .hp-snitch {
    display: none;
  }
}

/* ==========================================================================
   Landing page: event details
   ========================================================================== */

.hp-about {
  padding: 2rem 0 4rem;
}

.hp-section-head {
  text-align: center;
  margin: 3.5rem auto 2rem;
  max-width: 760px;
}

.hp-section-head:first-child {
  margin-top: 0;
}

.hp-section-head h2 {
  font-size: clamp(1.7rem, 4vw, 2.4rem);
}

.hp-section-head h2::after {
  content: "\2726  \2767  \2726";
  display: block;
  margin-top: 0.6rem;
  font-size: 0.9rem;
  letter-spacing: 0.5rem;
  color: var(--hp-gold);
  text-shadow: none;
}

.hp-lead {
  font-size: 1.25rem;
  line-height: 1.6;
  margin-top: 1rem;
}

.hp-facts {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
}

.hp-fact {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  padding: 1.5rem 1rem;
  text-align: center;
  border: 1px solid var(--hp-border);
  border-radius: 10px;
  background: var(--hp-surface);
}

.hp-fact i {
  font-size: 1.6rem;
  color: var(--hp-gold-bright);
  margin-bottom: 0.4rem;
}

.hp-fact small {
  font-family: "Cinzel", Georgia, serif;
  font-size: 0.8rem;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--hp-muted);
}

.hp-fact strong {
  font-family: "Cinzel", Georgia, serif;
  font-size: 1.2rem;
}

.hp-disciplines {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
}

.hp-discipline {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  padding: 1rem 1.1rem;
  border: 1px solid var(--hp-border);
  border-left: 4px solid var(--hp-house);
  border-radius: 8px;
  background: var(--hp-surface);
  font-family: "Cinzel", Georgia, serif;
  font-weight: 700;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.hp-discipline:hover {
  transform: translateY(-3px);
  border-color: var(--hp-gold);
  border-left-color: var(--hp-house);
  box-shadow: 0 0 18px var(--hp-glow);
}

.hp-discipline i {
  flex: none;
  width: 2.2rem;
  height: 2.2rem;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--hp-house);
  border: 1px solid var(--hp-gold);
  color: #f3d77a;
  font-size: 0.95rem;
}

.hp-d-gryffindor { --hp-house: var(--hp-gryffindor); }
.hp-d-slytherin { --hp-house: var(--hp-slytherin); }
.hp-d-ravenclaw { --hp-house: #222f5b; }
.hp-d-hufflepuff { --hp-house: var(--hp-hufflepuff); }

.hp-rules-row {
  margin-top: 3.5rem;
}

.hp-scroll {
  height: 100%;
  padding: 1.75rem 2rem;
  border: 1px solid var(--hp-border);
  border-radius: 10px;
  background: var(--hp-surface);
  box-shadow: inset 0 0 0 4px rgba(212, 175, 55, 0.06);
}

[data-bs-theme="light"] .hp-scroll {
  box-shadow: inset 0 0 40px rgba(140, 100, 40, 0.15);
}

.hp-scroll h3 {
  color: var(--hp-gold-bright);
  font-size: 1.4rem;
  margin-bottom: 1.25rem;
}

.hp-rules {
  list-style: none;
  padding: 0;
  margin: 0;
}

.hp-rules li {
  display: flex;
  align-items: baseline;
  gap: 0.9rem;
  padding: 0.6rem 0;
  border-bottom: 1px dashed var(--hp-border);
  font-size: 1.12rem;
}

.hp-rules li:last-child {
  border-bottom: none;
}

.hp-rules i {
  flex: none;
  width: 1.3rem;
  text-align: center;
  color: #c0262b;
}

[data-bs-theme="dark"] .hp-rules i {
  color: #e05a5e;
}

.hp-flag-format {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.hp-flag-format code {
  display: block;
  margin-top: 0.5rem;
  padding: 1rem;
  text-align: center;
  font-size: 1.35rem;
  color: var(--hp-gold-bright);
  background: rgba(0, 0, 0, 0.3);
  border: 1px dashed var(--hp-gold);
  border-radius: 8px;
  overflow-wrap: anywhere;
}

[data-bs-theme="light"] .hp-flag-format code {
  background: rgba(110, 72, 24, 0.1);
}

@media (max-width: 991px) {
  .hp-facts,
  .hp-disciplines {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 575px) {
  .hp-discipline {
    font-size: 0.85rem;
    padding: 0.8rem;
    gap: 0.6rem;
  }
  .hp-discipline i {
    width: 1.9rem;
    height: 1.9rem;
  }
  .hp-scroll {
    padding: 1.4rem 1.25rem;
  }
}

/* ==========================================================================
   Landing page: Join us (Discord) as a Hogwarts letter
   The letter is parchment in both modes, so its colours are fixed.
   ========================================================================== */

.hp-letter {
  position: relative;
  max-width: 680px;
  margin: 3rem auto 0;
  padding: 3.5rem 3rem 2.5rem;
  color: #3b2a14;
  font-size: 1.15rem;
  line-height: 1.65;
  border-radius: 4px;
  background:
    radial-gradient(ellipse at 20% 15%, rgba(255, 252, 238, 0.9), transparent 55%),
    radial-gradient(ellipse at 85% 90%, rgba(150, 105, 45, 0.28), transparent 50%),
    linear-gradient(135deg, #f6ead0, #e9d5a6);
  box-shadow:
    0 18px 40px rgba(0, 0, 0, 0.45),
    inset 0 0 60px rgba(120, 80, 30, 0.28);
  transition: transform 0.3s ease;
}

.hp-letter:hover {
  transform: translateY(-3px);
}

[data-bs-theme="light"] .hp-letter {
  box-shadow:
    0 14px 32px rgba(80, 50, 10, 0.35),
    inset 0 0 60px rgba(120, 80, 30, 0.28);
}

.hp-letter::before {
  /* inked double border */
  content: "";
  position: absolute;
  inset: 12px;
  border: 1px solid rgba(122, 31, 18, 0.35);
  outline: 1px solid rgba(122, 31, 18, 0.18);
  outline-offset: 4px;
  pointer-events: none;
}

.hp-seal {
  position: absolute;
  top: -34px;
  left: 50%;
  width: 72px;
  height: 72px;
  transform: translateX(-50%) rotate(-8deg);
  display: grid;
  place-items: center;
  border-radius: 46% 54% 50% 50% / 52% 48% 52% 48%;
  background: radial-gradient(circle at 35% 30%, #d6383d, #8e1014 60%, #5c0508);
  box-shadow:
    0 4px 10px rgba(0, 0, 0, 0.45),
    inset 0 0 0 6px rgba(0, 0, 0, 0.12),
    inset 0 0 0 9px rgba(255, 255, 255, 0.06);
  color: rgba(255, 220, 200, 0.85);
  font-size: 1.9rem;
  text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.45);
}

.hp-letter-kicker {
  text-align: center;
  font-family: "Cinzel", Georgia, serif;
  font-size: 0.8rem;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: #8a6a2e;
  margin-bottom: 1.5rem;
}

.hp-letter-salute {
  font-style: italic;
  font-size: 1.25rem;
  color: #7a1f12;
}

.hp-letter-sign {
  margin-top: 1.5rem;
  font-style: italic;
}

.hp-letter-sign span {
  font-family: "Cinzel", Georgia, serif;
  font-style: normal;
  font-weight: 700;
  color: #7a1f12;
  letter-spacing: 1px;
}

.hp-letter-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: fit-content;
  margin: 2rem auto 0;
  padding: 0.8rem 2.25rem;
  line-height: 1.3;
}

.hp-letter-btn-sub {
  font-family: "EB Garamond", Georgia, serif;
  font-size: 0.85rem;
  letter-spacing: 0.5px;
  opacity: 0.85;
}

@media (max-width: 575px) {
  .hp-letter {
    padding: 3.25rem 1.6rem 2rem;
    font-size: 1.05rem;
  }
  .hp-letter-btn {
    width: 100%;
  }
}

/* ==========================================================================
   Profile breakdown bars (solves / fails / categories)
   ========================================================================== */

:root,
[data-bs-theme="dark"] {
  --hp-solves: #3fae6a;
  --hp-fails: #e0474c;
  --hp-cat-0: #f3d77a;
  --hp-cat-1: #e0474c;
  --hp-cat-2: #3fae6a;
  --hp-cat-3: #5b8def;
  --hp-cat-4: #ecb939;
  --hp-cat-5: #cd8a4b;
  --hp-cat-6: #a779e9;
  --hp-cat-7: #4fc3c7;
}

[data-bs-theme="light"] {
  --hp-solves: #1a6b3a;
  --hp-fails: #ae0001;
  --hp-cat-0: #9a7414;
  --hp-cat-1: #ae0001;
  --hp-cat-2: #1a6b3a;
  --hp-cat-3: #1f3f8f;
  --hp-cat-4: #b8860b;
  --hp-cat-5: #8b5a2b;
  --hp-cat-6: #6a3fb0;
  --hp-cat-7: #1f7f83;
}

.progress {
  height: 12px;
  border-radius: 6px;
  border: 1px solid var(--hp-border);
}

/* ==========================================================================
   Error pages
   ========================================================================== */

.hp-error {
  min-height: calc(100vh - 82px - 100px);
  display: flex;
  align-items: center;
  text-align: center;
  padding: 3rem 0;
}

.hp-error-icon {
  font-size: 3.5rem;
  color: var(--hp-gold-bright);
  filter: drop-shadow(0 0 18px var(--hp-glow));
  animation: hp-float 6s ease-in-out infinite;
}

.hp-error-code {
  font-family: "Oswald", "Arial Narrow", sans-serif;
  font-size: clamp(4rem, 14vw, 8rem);
  line-height: 1;
  letter-spacing: 0.15em;
  margin: 0.5rem -0.15em 0.5rem 0;
  color: transparent;
  -webkit-text-stroke: 1.5px var(--hp-gold);
  opacity: 0.8;
}

.hp-error h1 {
  font-size: clamp(1.8rem, 5vw, 3rem);
}

.hp-error .hp-lead {
  max-width: 560px;
  margin: 1rem auto 0;
}

.hp-error-detail {
  max-width: 560px;
  margin: 0.75rem auto 0;
  font-style: italic;
  color: var(--hp-muted);
}

/* ==========================================================================
   Flag submission feedback
   ========================================================================== */

.modal-content.hp-shake {
  animation: hp-shake 0.45s ease-in-out;
}

@keyframes hp-shake {
  10%, 90% { transform: translateX(-2px); }
  20%, 80% { transform: translateX(4px); }
  30%, 50%, 70% { transform: translateX(-8px); }
  40%, 60% { transform: translateX(8px); }
}

.modal-content.hp-celebrate {
  animation: hp-celebrate 1.4s ease-out;
}

@keyframes hp-celebrate {
  0% { box-shadow: 0 0 0 0 rgba(243, 215, 122, 0.9); }
  40% { box-shadow: 0 0 60px 14px rgba(243, 215, 122, 0.55); }
  100% { box-shadow: 0 0 40px rgba(0, 0, 0, 0.6), 0 0 0 4px rgba(212, 175, 55, 0.12); }
}

.modal-content .alert-success {
  background: linear-gradient(160deg, rgba(42, 122, 70, 0.35), rgba(26, 71, 42, 0.35));
  border-color: rgba(63, 174, 106, 0.6);
  color: var(--hp-text);
}

.modal-content .alert-danger {
  background: linear-gradient(160deg, rgba(174, 0, 1, 0.3), rgba(116, 0, 1, 0.3));
  border-color: rgba(224, 71, 76, 0.6);
  color: var(--hp-text);
}

/* ==========================================================================
   Navbar: current page
   ========================================================================== */

.navbar .nav-link.active {
  color: #fff4c8 !important;
  position: relative;
}

@media (min-width: 768px) {
  .navbar .nav-link.active::after {
    content: "";
    position: absolute;
    left: 0.5rem;
    right: 0.5rem;
    bottom: -2px;
    height: 2px;
    border-radius: 1px;
    background: linear-gradient(90deg, transparent, #f3d77a, transparent);
  }
}

/* ==========================================================================
   Focus rings and quotes in gold rather than Bootstrap blue/grey
   ========================================================================== */

:root {
  --bs-focus-ring-color: rgba(212, 175, 55, 0.4);
}

.btn {
  --bs-btn-focus-shadow-rgb: 212, 175, 55;
}

blockquote {
  border-left-color: var(--hp-gold) !important;
}

@media (prefers-reduced-motion: reduce) {
  .hp-error-icon,
  .modal-content.hp-shake,
  .modal-content.hp-celebrate {
    animation: none;
  }
}
