/* ================================================================
 * academy-theme.css — shared Academy look for the area pages
 * ================================================================
 * index.html owns the canonical theme (styles.css :root). This file
 * republishes that palette for the pages that ship their own
 * stylesheet (learning.css, live-events.css, ctf.css) so the Live
 * Events, Courses, CTF and Verify screens read as one Academy area
 * rather than a separate product.
 *
 * Loaded AFTER the page stylesheet on purpose: it owns the shared
 * chrome (header, buttons, cards, modals, toasts) and the token
 * names, so on a tie it is the later rule and therefore the winner.
 * The page stylesheets keep layout and stay free of colour values.
 *
 * Two naming schemes are defined on purpose:
 *   1. The Academy names from styles.css (--primary, --glass-bg, ...)
 *   2. The short names the area stylesheets already consume
 *      (--bg, --card, --line, --txt, --mut, --pri, --acc, ...)
 * Mapping (2) onto (1) is what re-themes those pages: their existing
 * `var(--pri)` calls resolve to Academy purple with no edits needed
 * at the call sites.
 * ================================================================ */

/* ------------------------------------------------------------
   TOKENS
   ------------------------------------------------------------ */
:root {
    /* Academy palette - mirrors styles.css :root */
    --primary: #a855f7;
    --primary-dark: #7c3aed;
    --primary-light: #c084fc;
    --secondary: #ec4899;
    --secondary-dark: #db2777;
    --accent: #fbbf24;
    --accent-green: #34d399;
    --bg-dark: #0a0015;
    --bg-card: rgba(10, 10, 30, 0.85);
    --glass-bg: rgba(168, 85, 247, 0.05);
    --glass-border: rgba(168, 85, 247, 0.12);
    --glass-shadow: rgba(168, 85, 247, 0.08);
    --text-primary: #e8d4ff;
    --text-secondary: #a78bbf;
    --text-muted: #6d5a7a;
    --font-display: 'Orbitron', sans-serif;
    --font-body: 'Rajdhani', sans-serif;
    --font-text: 'Inter', sans-serif;
    --glass-blur: blur(20px);
    --transition-smooth: cubic-bezier(0.16, 1, 0.3, 1);
    --transition-elastic: cubic-bezier(0.68, -0.55, 0.265, 1.55);

    /* Semantic extras the Academy palette did not previously name.
       --success replaces the green these pages used to borrow for
       "solved / verified / reserved", which now clashes with purple
       since purple is the brand action colour. */
    --success: #34d399;
    --danger: #f87171;
    --ctf-gold: #f59e0b;

    /* Short names consumed by learning/live-events/ctf stylesheets */
    --bg: var(--bg-dark);
    --card: var(--bg-card);
    --line: rgba(168, 85, 247, 0.18);
    --txt: var(--text-primary);
    --mut: var(--text-secondary);
    --pri: var(--primary);
    --acc: var(--secondary);
    --warn: var(--accent);
    --bad: var(--danger);
    --gold: var(--ctf-gold);

    /* Tinted surfaces derived from the palette, so nested panels
       (challenge rows, id chips, bars) stay in-theme. */
    --surface: rgba(12, 4, 24, 0.72);
    --surface-2: rgba(20, 8, 40, 0.6);
    --primary-soft: rgba(168, 85, 247, 0.12);
    --secondary-soft: rgba(236, 72, 153, 0.12);
    --accent-soft: rgba(251, 191, 36, 0.12);
    --success-soft: rgba(52, 211, 153, 0.12);
    --danger-soft: rgba(248, 113, 113, 0.12);
}

/* ------------------------------------------------------------
   BASE
   ------------------------------------------------------------ */
/* The cursor stays the system default here: index.html hides the
   native cursor and draws its own with JS these pages do not load. */
body {
    background: var(--bg-dark);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-weight: 500;
    line-height: 1.5;
    margin: 0;
    padding: 0 0 70px;
    min-height: 100vh;
}

::selection { background: var(--primary); color: #fff; }
/* ------------------------------------------------------------
   AMBIENT BACKGROUND
   ------------------------------------------------------------ */
/* A CSS-only echo of index.html's Three.js scene and parallax layers:
   the same #0a0015 base, the same purple/pink radial glows and the
   same drifting shapes, with no WebGL dependency on these pages. */
.academy-bg {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    overflow: hidden;
    background: var(--bg-dark);
}
.academy-bg-glow {
    position: absolute;
    inset: 0;
    background:
        radial-gradient(ellipse at 50% 0%, rgba(168, 85, 247, 0.14), transparent 62%),
        radial-gradient(ellipse at 88% 78%, rgba(236, 72, 153, 0.1), transparent 60%),
        radial-gradient(ellipse at 8% 88%, rgba(124, 58, 237, 0.1), transparent 55%);
}
/* Faint grid, matching the wireframe feel of the dashboard canvas. */
.academy-bg-grid {
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(rgba(168, 85, 247, 0.055) 1px, transparent 1px),
        linear-gradient(90deg, rgba(168, 85, 247, 0.055) 1px, transparent 1px);
    background-size: 60px 60px;
    -webkit-mask-image: radial-gradient(ellipse at 50% 40%, #000 0%, transparent 78%);
    mask-image: radial-gradient(ellipse at 50% 40%, #000 0%, transparent 78%);
}
.academy-shape {
    position: absolute;
    border: 1px solid rgba(168, 85, 247, 0.09);
    animation: academyFloat 20s ease-in-out infinite;
}
.academy-shape.hex-1 { width: 400px; height: 400px; top: -100px; right: -100px; border-radius: 30% 70% 70% 30%; }
.academy-shape.hex-2 { width: 300px; height: 300px; bottom: 10%; left: -50px; border-radius: 60% 40% 30% 70%; animation-delay: -5s; }
.academy-shape.hex-3 { width: 200px; height: 200px; top: 22%; left: 20%; border-radius: 40% 60% 70% 30%; animation-delay: -10s; }
.academy-shape.hex-4 { width: 150px; height: 150px; bottom: 28%; right: 10%; border-radius: 50% 50% 30% 70%; animation-delay: -15s; }
@keyframes academyFloat {
    0%, 100% { transform: translate(0, 0) rotate(0deg) scale(1); }
    33% { transform: translate(30px, -30px) rotate(120deg) scale(1.1); }
    66% { transform: translate(-20px, 20px) rotate(240deg) scale(0.9); }
}

@media (prefers-reduced-motion: reduce) {
    .academy-shape { animation: none; }
}

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-dark); }
::-webkit-scrollbar-thumb { background: var(--primary); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--primary-light); }

/* Content sits above the fixed ambient layers. */
header, .wrap, .modal, #toast { position: relative; z-index: 1; }

h1 {
    font-family: var(--font-display);
    font-weight: 700;
    letter-spacing: 2px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}
/* The gradient fill above would otherwise swallow the icon colour. */
h1 i { -webkit-text-fill-color: currentColor; color: var(--primary); }
.sub { color: var(--mut); font-family: var(--font-text); font-size: 13px; margin-top: 6px; }
/* ------------------------------------------------------------
   HEADER - the dashboard's glass bar, rendered inline
   ------------------------------------------------------------ */
header {
    background: linear-gradient(135deg, rgba(20, 8, 40, 0.94), rgba(10, 0, 21, 0.96));
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border-bottom: 1px solid var(--glass-border);
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.45);
    padding: 20px 0;
    margin-bottom: 28px;
}
.head {
    max-width: 1150px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}
.head-title { display: flex; align-items: center; gap: 16px; }
/* The source PNG is 2161x2161 with wide transparent margins around the
   mark, so it needs a generous height to read at all. */
.head-logo {
    height: 96px;
    width: auto;
    flex: 0 0 auto;
    filter: drop-shadow(0 0 22px rgba(168, 85, 247, 0.45));
}
.head-brand {
    font-family: var(--font-display);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 3px;
    color: var(--text-muted);
    margin-top: 6px;
    animation: none !important;
}
h1 { font-size: 24px; margin: 0; }

@media (max-width: 560px) {
    .head-logo { height: 68px; }
    h1 { font-size: 19px; letter-spacing: 1px; }
}

/* ------------------------------------------------------------
   BUTTONS
   ------------------------------------------------------------ */
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.btn {
    border: 1px solid var(--glass-border);
    background: var(--glass-bg);
    color: var(--text-primary);
    border-radius: 8px;
    padding: 9px 15px;
    font-size: 13px;
    cursor: pointer;
    font-family: var(--font-body);
    font-weight: 600;
    letter-spacing: 0.5px;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    line-height: 1.2;
    transition: all 0.3s var(--transition-smooth);
}
.btn:hover {
    border-color: var(--primary);
    background: var(--primary-soft);
    color: var(--primary-light);
    transform: translateY(-2px);
}
.btn.primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff;
    border-color: var(--primary);
    font-weight: 700;
}
.btn.primary:hover { box-shadow: 0 4px 20px rgba(168, 85, 247, 0.35); }
.btn.live {
    background: linear-gradient(135deg, var(--danger), #dc2626);
    color: #fff;
    border-color: var(--danger);
    font-weight: 700;
}
.btn.ghost { color: var(--mut); background: transparent; }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }

/* ------------------------------------------------------------
   CARDS & PANELS
   ------------------------------------------------------------ */
.card, .stat, .signin, .verify-box {
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--glass-border);
    border-radius: 14px;
    transition: all 0.4s var(--transition-smooth);
}
.card:hover, .stat:hover {
    border-color: rgba(168, 85, 247, 0.28);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
}
.card h3 { font-family: var(--font-display); letter-spacing: 1px; }
.signin { text-align: center; }
/* Live emphasis picks up the theme's pink instead of the old red. */
.card.is-live { border-color: var(--secondary); box-shadow: 0 0 0 1px rgba(236, 72, 153, 0.22), 0 0 28px rgba(236, 72, 153, 0.14); }
.card.is-past { opacity: .72; }
/* ------------------------------------------------------------
   BADGES / CHIPS / TABS
   ------------------------------------------------------------ */
.badge, .chip {
    border: 1px solid var(--glass-border);
    color: var(--mut);
    font-family: var(--font-body);
    font-weight: 600;
}
/* .chip is a <button>, so it needs an explicit transparent background or
   the UA default grey/white button fill shows through on the inactive ones. */
.chip { background: transparent; padding: 7px 15px; font-size: 13px; cursor: pointer; display: inline-flex; align-items: center; gap: 7px; }
.chip:hover { color: var(--text-primary); border-color: var(--primary); background: var(--primary-soft); }
.chip.active {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff;
    border-color: var(--primary);
    font-weight: 700;
    box-shadow: 0 0 18px rgba(168, 85, 247, 0.3);
}
.tab { font-family: var(--font-display); letter-spacing: 1px; transition: color 0.3s, border-color 0.3s; }
.tab:hover { color: var(--text-primary); }
.tab.active { color: var(--primary-light); border-bottom-color: var(--primary); }
a.tab:hover { color: var(--secondary); }

/* ------------------------------------------------------------
   STATUS COLOURS
   ------------------------------------------------------------ */
/* Centralised so CTF "live", Live Events "live/soon/mine" and course
   badges all read from the same palette instead of each page
   hard-coding its own green/blue. */
.badge.live, .badge.soon, .badge.upcoming {
    color: var(--secondary);
    border-color: rgba(236, 72, 153, 0.35);
    background: var(--secondary-soft);
}
.badge.ended { color: var(--mut); }
.badge.mine, .badge.solved {
    color: var(--success);
    border-color: var(--success);
    background: var(--success-soft);
}
.badge.cert { color: var(--accent); border-color: rgba(251, 191, 36, 0.4); background: var(--accent-soft); }

.dot { background: var(--secondary); }
.countdown.now { color: var(--danger); }
.countdown.soon { color: var(--accent); }

.ok, .solved-note { color: var(--success); }
.verify-valid { border-color: var(--success); }
.verify-invalid { border-color: var(--danger); }
.verify-pending { border-color: var(--accent); }

.tag, .hint { color: var(--accent); }
.pts { color: var(--ctf-gold); }
.lb tr.me td { color: var(--accent); font-weight: 600; }

/* Nested surfaces sit on the glass card rather than on the page. */
.challenge, .lesson { background: var(--surface); border-color: var(--glass-border); }
.challenge.solved { border-color: var(--success); background: var(--success-soft); }
.lesson:hover { border-color: var(--primary); }
.lesson.active { border-color: var(--primary); background: var(--primary-soft); }
.lesson .n { color: var(--primary-light); }

/* ------------------------------------------------------------
   FORMS
   ------------------------------------------------------------ */
input, .flagrow input, .verify-input input, .filters input {
    background: var(--surface);
    border: 1px solid var(--glass-border);
    color: var(--text-primary);
    font-family: var(--font-text);
}
input::placeholder { color: var(--text-muted); }
input:focus, .flagrow input:focus, .verify-input input:focus, .filters input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--primary-soft);
}
.flagrow input { font-family: ui-monospace, Consolas, monospace; }

/* ------------------------------------------------------------
   PROGRESS BARS
   ------------------------------------------------------------ */
.bar { background: rgba(168, 85, 247, 0.14); }
.fill { background: linear-gradient(90deg, var(--primary), var(--secondary)); }
.fill.warn { background: linear-gradient(90deg, var(--accent), var(--danger)); }

/* ------------------------------------------------------------
   MODALS
   ------------------------------------------------------------ */
.modal { background: rgba(10, 0, 21, 0.88); backdrop-filter: blur(6px); }
.modal-box {
    background: linear-gradient(160deg, rgba(24, 10, 46, 0.96), rgba(10, 0, 21, 0.98));
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6), 0 0 40px rgba(168, 85, 247, 0.08);
}
.close:hover { color: var(--primary); }

/* ------------------------------------------------------------
   CERTIFICATE SHEET
   ------------------------------------------------------------ */
.cert-sheet {
    background: linear-gradient(160deg, rgba(30, 12, 54, 0.95), rgba(10, 0, 21, 0.98));
    border: 2px solid var(--primary);
    box-shadow: 0 0 40px rgba(168, 85, 247, 0.18);
}
.cert-brand, .cert-sub, .cert-note { color: var(--mut); }
.cert-title { color: var(--primary-light); font-family: var(--font-display); letter-spacing: 3px; }
.cert-name { font-family: var(--font-display); }
.cert-course, .cert-id { color: var(--secondary); }
.cred-id { color: var(--secondary); background: var(--secondary-soft); border: 1px solid rgba(236, 72, 153, 0.3); }
.cert-card { border-color: rgba(236, 72, 153, 0.3); }

/* ------------------------------------------------------------
   TOAST
   ------------------------------------------------------------ */
#toast { backdrop-filter: blur(10px); }
#toast.ok { background: rgba(6, 33, 24, 0.95); border: 1px solid var(--success); color: #86efac; }
#toast.err { background: rgba(42, 10, 15, 0.95); border: 1px solid var(--danger); color: #fca5a5; }

/* ------------------------------------------------------------
   PRINT
   ------------------------------------------------------------ */
/* Required because this file loads AFTER learning.css, whose own
   @media print block cannot out-rank an equal-specificity rule that
   comes later in the cascade. Without this the theme's dark
   .cert-sheet would win and a printed certificate would come out
   dark-on-dark. Mirrors the print block in learning.css. */
@media print {
    .academy-bg { display: none; }
    body { background: #fff; color: #000; padding: 0; }
    .card, .cert-sheet {
        background: #fff; color: #000;
        border-color: #000; box-shadow: none; backdrop-filter: none;
    }
    .cert-name, .cert-title, .cert-course, .cert-id { color: #000; }
    .cert-sub, .cert-brand, .cert-note, .meta { color: #333; }
    .cred-id { background: none; border-color: #000; color: #000; }
    .modal { position: static; background: none; padding: 0; backdrop-filter: none; }
    .modal-box {
        border: none; max-width: none; box-shadow: none;
        background: #fff; backdrop-filter: none;
    }
}