/* ==========================================================================
   Site theme: CSS variables, light/dark modes, accent colors.
   Adapted from certificationexams.pro; trimmed to what this site uses.
   Intended to survive a future move into a Jekyll include (_sass/theme.scss).
   ========================================================================== */

/* ---------- CSS Variables & Themes ---------- */
:root {
  /* Accent palette choices */
  --accent-purple: #761dfd;
  --accent-blue: #155bd5;
  --accent-green: #1c9d44;
  --accent-orange: #cf8508;
  --accent-orange-hover: #f59e0b;
  --accent-rose: #f43f5e;
  --accent-pink: #e729ce;

  /* Active accent + its hover shade */
  --accent: var(--accent-orange);
  --accent-hover: var(--accent-orange-hover);
  --accent-contrast: #ffffff;

  /* Navigation authentication buttons are neutral rather than accent-colored. */
  --nav-auth-button-color: #0f172a;
  --nav-auth-button-hover-text: #ffffff;

  /* Light theme tokens */
  --bg: #ffffff;
  --text: #0f172a;
  --muted: #6b7280;
  --panel: #f8fafc;
  --border: #e5e7eb;
  --contrast: #0b1020;
  --contrast-text: #eef2ff;
}

html[data-theme="dark"] {
  --bg: #0b1020;
  --text: #e5e7eb;
  --muted: #9ca3af;
  --panel: #070a17;
  --border: #1f2a44;
  --contrast: #070a17;
  --contrast-text: #e2e8f0;
  --nav-auth-button-color: #ffffff;
  --nav-auth-button-hover-text: #0b1020;
}

/* Accent selection, toggled by theme.js. */
html[data-accent="purple"] {
  --accent: var(--accent-purple);
  --accent-hover: color-mix(in oklab, var(--accent-purple), black 12%);
}

html[data-accent="blue"] {
  --accent: var(--accent-blue);
  --accent-hover: color-mix(in oklab, var(--accent-blue), black 12%);
}

html[data-accent="green"] {
  --accent: var(--accent-green);
  --accent-hover: color-mix(in oklab, var(--accent-green), black 12%);
}

html[data-accent="orange"] {
  --accent: var(--accent-orange);
  --accent-hover: var(--accent-orange-hover);
}

html[data-accent="rose"] {
  --accent: var(--accent-rose);
  --accent-hover: color-mix(in oklab, var(--accent-rose), black 12%);
}

html[data-accent="pink"] {
  --accent: var(--accent-pink);
  --accent-hover: color-mix(in oklab, var(--accent-pink), black 12%);
}

/* ---------- Global ---------- */
html,
body {
  background: var(--bg);
  color: var(--text);
}

body {
  transition:
    background-color 0.2s ease,
    color 0.2s ease;
}

a {
  color: var(--accent);
}

a:hover {
  color: var(--text);
}

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

.text-muted-light {
  color: var(--muted);
}

html[data-theme="dark"] .text-muted-light {
  color: color-mix(in oklab, var(--text) 90%, var(--muted));
}

.border-accent-subtle {
  border: 1px solid color-mix(in oklab, var(--accent) 35%, var(--border));
}

.fw-extrabold {
  font-weight: 800;
}

.bg-body {
  background: var(--bg) !important;
}

/* ---------- Accent-aware buttons ---------- */

/*
 * Default button state:
 * transparent background, accent border and accent text.
 *
 * These direct properties deliberately override the fixed blue rules from
 * Bootstrap variants and older shared stylesheets.
 */
.btn,
.btn-accent,
.btn-outline-accent,
.btn-outline-plain,
.btn-primary,
.btn-secondary,
.btn-success,
.btn-danger,
.btn-warning,
.btn-info,
.btn-light,
.btn-dark,
.btn-logout,
.btn-mock {
  --bs-btn-color: var(--accent);
  --bs-btn-bg: transparent;
  --bs-btn-border-color: var(--accent);
  --bs-btn-hover-color: var(--accent-contrast);
  --bs-btn-hover-bg: var(--accent-hover);
  --bs-btn-hover-border-color: var(--accent-hover);
  --bs-btn-active-color: var(--accent-contrast);
  --bs-btn-active-bg: var(--accent);
  --bs-btn-active-border-color: var(--accent);
  --bs-btn-disabled-color: var(--accent);
  --bs-btn-disabled-bg: transparent;
  --bs-btn-disabled-border-color: var(--accent);

  color: var(--accent) !important;
  background-color: transparent !important;
  border: 1px solid var(--accent) !important;
  box-shadow: none;

  transition:
    color 0.18s ease,
    background-color 0.18s ease,
    border-color 0.18s ease,
    box-shadow 0.18s ease,
    transform 0.18s ease;
}

.btn:hover,
.btn-accent:hover,
.btn-outline-accent:hover,
.btn-outline-plain:hover,
.btn-primary:hover,
.btn-secondary:hover,
.btn-success:hover,
.btn-danger:hover,
.btn-warning:hover,
.btn-info:hover,
.btn-light:hover,
.btn-dark:hover,
.btn-logout:hover,
.btn-mock:hover {
  color: var(--accent-contrast) !important;
  background-color: var(--accent-hover) !important;
  border-color: var(--accent-hover) !important;
  transform: translateY(-1px);
}

.btn:active,
.btn.active,
.btn.show,
.btn:first-child:active,
:not(.btn-check) + .btn:active {
  color: var(--accent-contrast) !important;
  background-color: var(--accent) !important;
  border-color: var(--accent) !important;
  transform: translateY(0);
}

.btn:focus-visible,
.link-btn:focus-visible,
.theme-toggle:focus-visible {
  outline: none;
  box-shadow:
    0 0 0 2px var(--bg),
    0 0 0 4px color-mix(in oklab, var(--accent) 72%, transparent) !important;
}

.btn:disabled,
.btn.disabled,
fieldset:disabled .btn {
  color: var(--accent) !important;
  background-color: transparent !important;
  border-color: var(--accent) !important;
  opacity: 0.5;
  transform: none;
  pointer-events: none;
}

/*
 * In an exact two-button flex row, the first action becomes the solid primary
 * action. The second remains outlined. This matches the site's paired-CTA
 * pattern without requiring every component to use special classes.
 */
.d-flex > .btn:first-child:nth-last-child(2),
.btn-group > .btn:first-child:nth-last-child(2),
.btn-group-vertical > .btn:first-child:nth-last-child(2) {
  color: var(--accent-contrast) !important;
  background-color: var(--accent) !important;
  border-color: var(--accent) !important;
}

.d-flex > .btn:first-child:nth-last-child(2):hover,
.btn-group > .btn:first-child:nth-last-child(2):hover,
.btn-group-vertical > .btn:first-child:nth-last-child(2):hover {
  color: var(--accent) !important;
  background-color: transparent !important;
  border-color: var(--accent) !important;
}

/* Optional explicit class for a primary button outside a two-button row. */
.btn-solid-accent {
  color: var(--accent-contrast) !important;
  background-color: var(--accent) !important;
  border-color: var(--accent) !important;
}

.btn-solid-accent:hover {
  color: var(--accent) !important;
  background-color: transparent !important;
  border-color: var(--accent) !important;
}

/* Button-like links used by authentication pages. */
.link-btn {
  color: var(--accent);
}

.link-btn:hover {
  color: var(--accent-hover);
}


/*
 * Register and Sign In stay visually neutral in the navbar.
 * Dark mode: white outline and white text.
 * Light mode: dark outline and dark text.
 * Hover reverses the foreground and background.
 *
 * The selectors are intentionally more specific than the generic paired-button
 * rule so neither authentication button becomes accent-filled.
 */
#nav-auth-controls .btn,
#nav-auth-controls .btn:first-child,
#nav-auth-controls .btn:first-child:nth-last-child(2) {
  color: var(--nav-auth-button-color) !important;
  background-color: transparent !important;
  border-color: var(--nav-auth-button-color) !important;
}

#nav-auth-controls .btn:hover,
#nav-auth-controls .btn:first-child:hover,
#nav-auth-controls .btn:first-child:nth-last-child(2):hover {
  color: var(--nav-auth-button-hover-text) !important;
  background-color: var(--nav-auth-button-color) !important;
  border-color: var(--nav-auth-button-color) !important;
}

#nav-auth-controls .btn:active,
#nav-auth-controls .btn.active,
#nav-auth-controls .btn:focus-visible {
  color: var(--nav-auth-button-hover-text) !important;
  background-color: var(--nav-auth-button-color) !important;
  border-color: var(--nav-auth-button-color) !important;
}

#nav-auth-controls .btn:focus-visible {
  box-shadow:
    0 0 0 2px var(--bg),
    0 0 0 4px color-mix(in oklab, var(--nav-auth-button-color) 70%, transparent) !important;
}

/* ---------- Navbar ---------- */
.navbar {
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.navbar .nav-link {
  color: var(--text);
}

.navbar .nav-link.active {
  color: var(--accent);
}

.navbar .navbar-toggler {
  border-color: var(--accent);
}

.navbar .navbar-toggler:focus {
  box-shadow:
    0 0 0 0.2rem
    color-mix(in oklab, var(--accent) 22%, transparent);
}

.navbar .navbar-nav {
  text-align: center;
}

.nav-brand-avatar {
  border-radius: 999px;
}

.navbar .discord-icon {
  display: inline-block;
  color: var(--accent);
}

/* Theme accent dots are color selectors, not normal accent buttons. */
.theme-dots {
  gap: 0.35rem;
}

.theme-dot {
  width: 18px;
  height: 18px;
  padding: 0;
  border: 2px solid var(--border);
  border-radius: 999px;
  outline: none;
  cursor: pointer;
}

.theme-dot[data-accent="purple"] {
  background: var(--accent-purple);
}

.theme-dot[data-accent="blue"] {
  background: var(--accent-blue);
}

.theme-dot[data-accent="green"] {
  background: var(--accent-green);
}

.theme-dot[data-accent="orange"] {
  background: var(--accent-orange);
}

.theme-dot[data-accent="rose"] {
  background: var(--accent-rose);
}

.theme-dot[data-accent="pink"] {
  background: var(--accent-pink);
}

.theme-dot:hover {
  transform: scale(1.12);
}

.theme-dot:focus-visible {
  outline: none;
  box-shadow:
    0 0 0 2px var(--bg),
    0 0 0 4px var(--accent);
}

.theme-dot[aria-pressed="true"] {
  border-color: var(--text);
  box-shadow:
    0 0 0 2px var(--bg),
    0 0 0 4px var(--accent);
}

/* Light/dark toggle follows the active accent. */
.theme-toggle,
.btn.theme-toggle,
.btn-outline-plain.theme-toggle {
  width: 34px;
  height: 34px;
  display: grid;
  place-content: center;
  padding: 0;
  color: var(--accent) !important;
  background-color: transparent !important;
  border: 1px solid var(--accent) !important;
  border-radius: 999px;
  line-height: 1;
}

.theme-toggle i {
  color: currentColor;
  font-size: 16px;
}

.theme-toggle:hover,
.btn.theme-toggle:hover,
.btn-outline-plain.theme-toggle:hover {
  color: var(--accent-contrast) !important;
  background-color: var(--accent-hover) !important;
  border-color: var(--accent-hover) !important;
}

/* ---------- Sections ---------- */
section {
  position: relative;
  padding: 3rem 0;
}

section::after {
  content: "";
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  height: 3px;
  background:
    linear-gradient(
      90deg,
      transparent,
      var(--accent),
      transparent
    );
  opacity: 0.95;
  pointer-events: none;
}

.section-bg {
  background: var(--bg);
  color: var(--text);
}

.section-panel {
  background: var(--panel);
  color: var(--text);
}

.section-contrast {
  background: var(--contrast);
  color: var(--contrast-text);
}

.section-contrast h2 {
  color: #fff;
}

.section-contrast a {
  color: var(--accent);
}

/* ---------- Footer ---------- */
footer {
  background: var(--panel);
  border-top: 1px solid var(--border);
  color: var(--muted);
}
