/* LabYard — dark jeopardy-board theme */
:root {
  --bg: #070b18;
  --bg-2: #0d1428;
  --panel: #111a33;
  --panel-2: #16203d;
  --line: #23305a;
  --text: #e6ecff;
  --muted: #8e9dc4;
  --accent: #2ee6c5;
  --accent-2: #6f8cff;
  --gold: #ffcc55;
  --danger: #ff6b81;
  --ok: #4ade80;
  --radius: 12px;
  --mono: "JetBrains Mono", "Fira Code", "SFMono-Regular", Consolas, monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background:
    radial-gradient(1100px 600px at 80% -10%, #16224a 0%, transparent 60%),
    radial-gradient(900px 500px at -10% 10%, #102b3f 0%, transparent 55%),
    var(--bg);
  color: var(--text);
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  min-height: 100vh;
  line-height: 1.55;
}

a { color: var(--accent); text-decoration: none; }
/* Underline prose links on hover only where hovering is a real thing. On a
   touch screen the :hover state sticks after a tap, which left the option a
   user just selected permanently underlined. */
@media (hover: hover) and (pointer: fine) {
  a:hover { text-decoration: underline; }
}
/* Anchors rendered as cards, buttons, tiles or pills are UI targets rather
   than prose links — they must never underline, tapped or hovered. */
a.card, a.btn, a.cat-card, a.chal, a.tile, a.pill, a.chip, a.brand,
a.course-pill, a.crumb-back, a.hub-card, a.dash-tile, a.course-card, a.nav-course,
a.card:hover, a.btn:hover, a.cat-card:hover, a.chal:hover, a.tile:hover,
a.pill:hover, a.chip:hover, a.brand:hover, a.course-pill:hover,
a.crumb-back:hover, a.hub-card:hover, a.dash-tile:hover, a.course-card:hover,
a.nav-course:hover {
  text-decoration: none;
}
code, pre, .mono { font-family: var(--mono); }

.wrap { max-width: 1180px; margin: 0 auto; padding: 0 20px; }

/* ------------------------------------------------------------------ navbar */
header.nav {
  position: sticky; top: 0; z-index: 50;
  background: rgba(7, 11, 24, 0.85);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.nav-inner { display: flex; align-items: center; gap: 26px; height: 62px; }
.brand { font-family: var(--mono); font-weight: 700; font-size: 1.15rem; color: var(--text); letter-spacing: -0.5px; }
.brand span { color: var(--accent); }
.brand:hover { text-decoration: none; }
.nav-links { display: flex; gap: 20px; margin-left: auto; align-items: center; flex-wrap: wrap; }
.nav-links a { color: var(--muted); font-size: 0.92rem; font-weight: 500; }
.nav-links a:hover, .nav-links a.active { color: var(--text); text-decoration: none; }
.nav-score { font-family: var(--mono); color: var(--accent); font-size: 0.85rem;
  border: 1px solid var(--line); padding: 4px 10px; border-radius: 999px; }

/* Breadcrumb-style course pill in the nav: names the course you're inside and
   links back to its home. Shown on the learning pages (not the hub/course
   home), where the P/Q/I links otherwise gave no clue which course you're in
   and no way back to it. Sits at the left of the link group. */
.nav-course { display: inline-flex; align-items: center; gap: 6px; margin-right: auto;
  padding: 5px 12px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--panel-2); color: var(--text); font-weight: 600; font-size: 0.85rem; }
.nav-course:hover { border-color: var(--accent); color: var(--accent); }
.nav-course-name { white-space: nowrap; }

/* ------------------------------------------------------------------ shared */
.btn {
  display: inline-block; border: 0; cursor: pointer; border-radius: 8px;
  padding: 10px 18px; font-weight: 600; font-size: 0.92rem;
  background: linear-gradient(135deg, var(--accent), #21b8ff); color: #05121b;
  transition: transform .12s ease, filter .12s ease;
}
.btn:hover { filter: brightness(1.08); transform: translateY(-1px); text-decoration: none; }
.btn.ghost { background: transparent; color: var(--text); border: 1px solid var(--line); }
.btn.ghost:hover { border-color: var(--accent); color: var(--accent); }
.btn.sm { padding: 6px 12px; font-size: 0.8rem; }
.btn.danger { background: linear-gradient(135deg, #ff7a8a, #ff4d6d); color: #2a0009; }

input, select, textarea {
  width: 100%; padding: 11px 13px; border-radius: 8px;
  background: var(--bg-2); border: 1px solid var(--line); color: var(--text);
  font-size: 0.95rem; font-family: inherit;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); border-color: transparent; }
label { display: block; font-size: 0.82rem; color: var(--muted); margin: 14px 0 6px;
  text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.flash { padding: 12px 16px; border-radius: 8px; margin: 14px 0; font-size: 0.9rem; }
.flash.error { background: rgba(255,107,129,.12); border: 1px solid var(--danger); color: #ffc2cb; }
.flash.ok { background: rgba(74,222,128,.12); border: 1px solid var(--ok); color: #bdf5d1; }

.pill { display: inline-block; font-size: 0.7rem; padding: 3px 10px; border-radius: 999px;
  font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }
.pill.easy { background: rgba(74,222,128,.15); color: #7ff0a8; }
.pill.medium { background: rgba(255,204,85,.15); color: var(--gold); }
.pill.hard { background: rgba(255,107,129,.15); color: #ff9aa8; }

/* -------------------------------------------------------------------- hero */
.hero { padding: 78px 0 54px; text-align: center; }
.hero h1 { font-size: clamp(2.2rem, 6vw, 3.6rem); margin: 0 0 14px; line-height: 1.1;
  letter-spacing: -1.5px; }
.hero h1 .grad { background: linear-gradient(120deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero p { color: var(--muted); font-size: 1.08rem; max-width: 660px; margin: 0 auto 28px; }
.hero .cta { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; }
.term { font-family: var(--mono); color: var(--accent); font-size: .85rem; letter-spacing: .12em;
  text-transform: uppercase; margin-bottom: 12px; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px; margin: 44px 0; }
.stat { padding: 22px; text-align: center; }
.stat b { display: block; font-size: 2rem; font-family: var(--mono); color: var(--accent); }
.stat span { color: var(--muted); font-size: 0.82rem; text-transform: uppercase; letter-spacing: .07em; }

.cat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 16px; }
.cat-card { padding: 20px; transition: border-color .15s, transform .15s; }
.cat-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.cat-card h3 { margin: 8px 0 6px; font-size: 1.05rem; }
.cat-card p { color: var(--muted); font-size: 0.85rem; margin: 0; }
.cat-ico { font-size: 1.5rem; }

h2.section { font-size: 1.5rem; margin: 46px 0 18px; letter-spacing: -0.5px; }
h2.section small { color: var(--muted); font-size: .85rem; font-weight: 400; margin-left: 10px; }

/* -------------------------------------------------------------- auth pages */
.auth { max-width: 420px; margin: 70px auto; padding: 34px; }
.auth h1 { margin: 0 0 6px; font-size: 1.6rem; }
.auth p.sub { color: var(--muted); font-size: .9rem; margin: 0 0 10px; }
.auth .btn { width: 100%; margin-top: 22px; }
.auth .alt { text-align: center; color: var(--muted); font-size: .88rem; margin-top: 18px; }

/* -------------------------------------------------------------- challenges */
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin: 22px 0; }
.chip { padding: 7px 14px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--panel); color: var(--muted); cursor: pointer; font-size: .85rem; font-weight: 500; }
.chip:hover { color: var(--text); border-color: var(--accent-2); }
.chip.active { background: var(--accent); color: #05121b; border-color: var(--accent); font-weight: 700; }
.filters input[type=search] { max-width: 240px; margin-left: auto; }

.cat-block { margin: 34px 0; }
.cat-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 14px;
  border-bottom: 1px solid var(--line); padding-bottom: 8px; }
.cat-head h2 { margin: 0; font-size: 1.15rem; }
.cat-head span { color: var(--muted); font-size: .82rem; font-family: var(--mono); }

.chal-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(238px, 1fr)); gap: 14px; }
.chal {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; cursor: pointer; position: relative; overflow: hidden;
  transition: transform .14s ease, border-color .14s ease, box-shadow .14s ease;
}
.chal:hover { transform: translateY(-3px); border-color: var(--accent);
  box-shadow: 0 10px 30px rgba(46,230,197,.10); }
.chal.solved { border-color: rgba(74,222,128,.5); background:
  linear-gradient(160deg, rgba(74,222,128,.08), var(--panel) 55%); }
.chal .pts { font-family: var(--mono); font-size: 1.6rem; color: var(--accent); font-weight: 700; }
.chal.solved .pts { color: var(--ok); }
.chal h3 { margin: 4px 0 10px; font-size: 1rem; line-height: 1.3; }
.chal .meta { display: flex; justify-content: space-between; align-items: center;
  color: var(--muted); font-size: .75rem; }
.chal .check { position: absolute; top: 12px; right: 14px; color: var(--ok); font-size: 1.1rem; }

/* ------------------------------------------------------------------- modal */
.modal-bg { position: fixed; inset: 0; background: rgba(3,6,15,.78); backdrop-filter: blur(4px);
  display: none; align-items: flex-start; justify-content: center; z-index: 100; padding: 40px 16px;
  overflow-y: auto; }
.modal-bg.open { display: flex; }
.modal { background: var(--panel-2); border: 1px solid var(--line); border-radius: 14px;
  max-width: 640px; width: 100%; padding: 28px; animation: pop .16s ease; }
@keyframes pop { from { transform: scale(.97); opacity: 0 } to { transform: scale(1); opacity: 1 } }
.modal h2 { margin: 6px 0 4px; font-size: 1.4rem; }
.modal .sub { color: var(--muted); font-size: .85rem; font-family: var(--mono); margin-bottom: 16px; }
.modal .desc { white-space: pre-wrap; margin: 18px 0; color: #cfd8f0; }
.modal .desc code { background: var(--bg-2); padding: 2px 6px; border-radius: 4px; color: var(--accent); }
.close-x { float: right; cursor: pointer; color: var(--muted); font-size: 1.5rem; line-height: 1;
  background: none; border: 0; padding: 0; }
.close-x:hover { color: var(--danger); }
.dl { display: inline-flex; align-items: center; gap: 8px; background: var(--bg-2);
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 14px; font-family: var(--mono);
  font-size: .84rem; margin: 0 8px 8px 0; }
.hint { background: var(--bg-2); border-left: 3px solid var(--gold); padding: 10px 14px;
  border-radius: 0 8px 8px 0; margin: 8px 0; font-size: .88rem; color: #e9dcbb; }
.submit-row { display: flex; gap: 10px; margin-top: 8px; }
.submit-row input { font-family: var(--mono); }
.result { margin-top: 12px; padding: 10px 14px; border-radius: 8px; font-size: .9rem; display: none; }
.result.correct { display: block; background: rgba(74,222,128,.13); color: #b6f5cc;
  border: 1px solid var(--ok); }
.result.incorrect { display: block; background: rgba(255,107,129,.13); color: #ffc2cb;
  border: 1px solid var(--danger); }
.result.info { display: block; background: rgba(111,140,255,.13); color: #ccd7ff;
  border: 1px solid var(--accent-2); }

/* ------------------------------------------------------------------ tables */
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th { text-align: left; color: var(--muted); font-size: .74rem; text-transform: uppercase;
  letter-spacing: .07em; padding: 12px 14px; border-bottom: 1px solid var(--line); }
td { padding: 12px 14px; border-bottom: 1px solid rgba(35,48,90,.5); }
tr:hover td { background: rgba(111,140,255,.05); }
.rank { font-family: var(--mono); font-weight: 700; color: var(--muted); width: 62px; }
.rank.r1 { color: var(--gold); } .rank.r2 { color: #cfd8ea; } .rank.r3 { color: #d9a066; }
.score-cell { font-family: var(--mono); color: var(--accent); font-weight: 700; }
.me td { background: rgba(46,230,197,.07); }

.bar { height: 7px; background: var(--bg-2); border-radius: 99px; overflow: hidden; }
.bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
/* The tab strip scrolls sideways on narrow screens instead of pushing the
   whole page wider. */
.tabs { display: flex; gap: 8px; margin: 22px 0 16px; border-bottom: 1px solid var(--line);
  overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { padding: 10px 16px; cursor: pointer; color: var(--muted); font-weight: 600; font-size: .9rem;
  border-bottom: 2px solid transparent; white-space: nowrap; flex: none; }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.tabpane { display: none; } .tabpane.active { display: block; }

footer { border-top: 1px solid var(--line); margin-top: 70px; padding: 26px 0; color: var(--muted);
  font-size: .84rem; text-align: center; }

/* ------------------------------------------------------- mobile hamburger */
.nav-burger { display: none; margin-left: auto; width: 40px; height: 36px; flex: none;
  background: transparent; border: 1px solid var(--line); border-radius: 8px;
  cursor: pointer; padding: 0 9px; }
.nav-burger span { display: block; height: 2px; background: var(--text); border-radius: 2px;
  margin: 4px 0; transition: transform .2s ease, opacity .2s ease; }
.nav-burger.open span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.nav-burger.open span:nth-child(2) { opacity: 0; }
.nav-burger.open span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

@media (max-width: 720px) {
  .grid-2 { grid-template-columns: 1fr; }
  .nav-inner { height: 56px; gap: 12px; flex-wrap: nowrap; }
  .filters input[type=search] { margin-left: 0; max-width: 100%; }

  /* The links collapse behind the burger so the bar stays one row tall. */
  .nav-burger { display: block; }
  .nav-links {
    display: none; position: absolute; left: 0; right: 0; top: 100%;
    flex-direction: column; align-items: stretch; gap: 0; margin: 0;
    padding: 6px 0 10px; background: var(--panel);
    border-bottom: 1px solid var(--line);
    box-shadow: 0 14px 28px rgba(0, 0, 0, .28);
  }
  .nav-links.open { display: flex; }
  .nav-links > a {
    padding: 13px 20px; font-size: 1rem; border-bottom: 1px solid var(--line);
  }
  .nav-links > a:last-of-type { border-bottom: 0; }
  /* The course pill becomes a normal (accented) menu row inside the panel. */
  .nav-links > a.nav-course {
    margin: 0; border-radius: 0; background: transparent; border: 0;
    border-bottom: 1px solid var(--line); color: var(--accent); font-weight: 700;
  }
  .nav-links a.active { color: var(--accent); }
  /* Theme toggle and the account button sit side by side under the links. */
  .nav-links .theme-toggle { margin: 10px 0 0 20px; }
  .nav-links .user-menu, .nav-links .btn { margin: 10px 20px 0; }
  .nav-links .btn { display: block; text-align: center; }
  .nav-links .user-menu { width: calc(100% - 40px); }
  .nav-links .user-btn { width: 100%; justify-content: flex-start; }
  .nav-links .dropdown { position: static; width: 100%; margin-top: 8px; box-shadow: none; }
  header.nav { position: sticky; }
}

/* ============================================================ light theme */
:root[data-theme="light"] {
  --bg: #eef1f8;
  --bg-2: #ffffff;
  --panel: #ffffff;
  --panel-2: #f5f7fc;
  --line: #dbe2f0;
  --text: #172038;
  --muted: #566083;
  --accent: #12a08b;
  --accent-2: #3a5bd0;
  --gold: #b7791f;
  --danger: #d64560;
  --ok: #2f8f52;
}
:root[data-theme="light"] body {
  background:
    radial-gradient(1100px 600px at 80% -10%, #e6ecfb 0%, transparent 60%),
    radial-gradient(900px 500px at -10% 10%, #e7f3f2 0%, transparent 55%),
    var(--bg);
}
:root[data-theme="light"] header.nav { background: rgba(255,255,255,0.85); }
/* Only the filled buttons want white text; ghost buttons keep dark --text so
   they stay readable on the light background (Make admin / Grant premium / Hide). */
:root[data-theme="light"] .btn:not(.ghost) { color: #ffffff; }

/* Text colours that were hardcoded light for the dark board become unreadable
   on the light background — override them with dark, high-contrast values. */
:root[data-theme="light"] .flash.error,
:root[data-theme="light"] .result.incorrect,
:root[data-theme="light"] .pill.hard { color: #b0213a; }
:root[data-theme="light"] .flash.ok,
:root[data-theme="light"] .result.correct,
:root[data-theme="light"] .pill.easy { color: #1c7a44; }
:root[data-theme="light"] .result.info { color: #2b3e8f; }
:root[data-theme="light"] .modal .desc { color: var(--text); }
:root[data-theme="light"] .hint { color: #6a5417; }
:root[data-theme="light"] .rank.r2 { color: #6b7590; }
:root[data-theme="light"] .rank.r3 { color: #a5642a; }

/* smooth transition when switching themes */
body, header.nav, .card, .btn, .chal, .stat, input, select, textarea {
  transition: background-color .28s ease, color .22s ease, border-color .28s ease,
              box-shadow .2s ease, transform .18s ease;
}

/* theme toggle button */
.theme-toggle {
  background: transparent; border: 1px solid var(--line); color: var(--text);
  width: 34px; height: 34px; border-radius: 999px; cursor: pointer; font-size: 1rem;
  display: inline-grid; place-items: center; line-height: 1;
}
.theme-toggle:hover { border-color: var(--accent); transform: rotate(-12deg); }

/* ============================================================ animations */
@keyframes fadeUp { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes popIn  { from { opacity: 0; transform: scale(.96); }        to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: no-preference) {
  .stats .stat { animation: fadeUp .5s both; }
  .stats .stat:nth-child(2) { animation-delay: .06s; }
  .stats .stat:nth-child(3) { animation-delay: .12s; }
  .stats .stat:nth-child(4) { animation-delay: .18s; }
  .cat-grid .cat-card { animation: fadeUp .5s both; }
  .chal-grid .chal { animation: popIn .35s both; }
  .modal.open, .modal-bg.open .modal { animation: popIn .22s both; }
  .flash { animation: fadeUp .35s both; }
}
/* hover lifts */
.card, .chal, .cat-card { will-change: transform; }
.chal:hover, .cat-card:hover { transform: translateY(-3px); box-shadow: 0 10px 26px rgba(10,16,40,.18); }
.btn:hover { transform: translateY(-1px); }
.stat b { transition: color .3s ease; }

.crumb-back { color: var(--muted); text-decoration: none; font-size: .9rem; }
.crumb-back:hover { color: var(--accent); }

/* ============================================================ user menu */

.user-menu { position: relative; }
.user-btn {
  display: inline-flex; align-items: center; gap: 8px; cursor: pointer;
  background: transparent; border: 1px solid var(--line); border-radius: 999px;
  padding: 4px 10px 4px 4px; color: var(--text); font: inherit;
}
.user-btn:hover { border-color: var(--accent); }
.user-name { font-size: .9rem; font-weight: 600; max-width: 130px; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; }
.user-btn .caret { color: var(--muted); font-size: .7rem; }
.avatar-sm, .avatar-md {
  display: inline-grid; place-items: center; border-radius: 50%; flex: none;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #05121b; font-weight: 800;
}
.avatar-sm { width: 28px; height: 28px; font-size: .9rem; }
.avatar-md { width: 40px; height: 40px; font-size: 1.15rem; }
:root[data-theme="light"] .avatar-sm, :root[data-theme="light"] .avatar-md { color: #fff; }
.avatar-img { object-fit: cover; background: none; padding: 0; }

.dropdown {
  position: absolute; right: 0; top: calc(100% + 10px); width: 250px; z-index: 200;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 14px 40px rgba(6, 12, 30, .28); padding: 6px; display: none;
  animation: popIn .16s ease;
}
.dropdown.open { display: block; }
.dd-head { display: flex; align-items: center; gap: 12px; padding: 12px 12px 10px; }
.dd-head strong { font-size: .95rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dd-role { color: var(--muted); font-size: .78rem; }
.dd-sep { height: 1px; background: var(--line); margin: 6px 4px; }
.dd-item {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 9px 12px; border-radius: 8px; color: var(--text); font-size: .9rem;
  text-decoration: none;
}
a.dd-item:hover { background: var(--panel-2); text-decoration: none; }
.dd-item.dd-static { cursor: default; color: var(--muted); }
.dd-val { font-family: var(--mono); font-weight: 700; color: var(--accent); }
.dd-gold { color: var(--gold) !important; font-weight: 600; }

@media (max-width: 720px) {
  /* Inside the collapsed menu there is room for the name, so keep it — the
     rule only needs to hide it where the bar itself is tight. */
  .nav-links:not(.open) .user-name { display: none; }
  .nav-links.open .user-name { max-width: none; }
  .dropdown { right: 0; }
}
