/* ============================================================
   CODEX CMS — Grimoire × Sci-Fi Theme
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@400;600;700&family=Crimson+Pro:ital,wght@0,300;0,400;0,600;1,300;1,400&family=Share+Tech+Mono&display=swap');

/* ── CSS Variables ─────────────────────────────────────────── */
:root {
    --bg-void:       #07070f;
    --bg-deep:       #0d0d1a;
    --bg-surface:    #12121f;
    --bg-elevated:   #181828;
    --bg-hover:      #1e1e32;

    --border-dim:    #1e1e30;
    --border-glow:   #2e2e50;
    --border-accent: #4a3f6b;

    --gold:          #d4a853;
    --gold-dim:      #8a6b30;
    --gold-bright:   #f0c870;
    --cyan:          #4cc9d4;
    --cyan-dim:      #1e5f65;
    --purple:        #7a5cb8;
    --purple-dim:    #3d2e5e;
    --red:           #c44a4a;
    --green:         #4ab87a;

    --text-primary:  #d4cbb8;
    --text-secondary:#8a8070;
    --text-muted:    #4a4560;
    --text-bright:   #f0e8d8;

    --font-display:  'Cinzel', serif;
    --font-body:     'Crimson Pro', Georgia, serif;
    --font-mono:     'Share Tech Mono', monospace;

    --radius-sm:     2px;
    --radius-md:     4px;
    --radius-lg:     8px;

    --shadow-glow:   0 0 20px rgba(212, 168, 83, 0.1);
    --shadow-deep:   0 8px 32px rgba(0, 0, 0, 0.6);
    --transition:    0.2s ease;
}

/* ── Reset & Base ───────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
    background-color: var(--bg-void);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 1.1rem;
    line-height: 1.75;
    min-height: 100vh;
    background-image:
        radial-gradient(ellipse at 20% 0%, rgba(122, 92, 184, 0.06) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 100%, rgba(76, 201, 212, 0.04) 0%, transparent 50%);
}

/* Runic grid overlay */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    background-image:
        linear-gradient(rgba(212, 168, 83, 0.015) 1px, transparent 1px),
        linear-gradient(90deg, rgba(212, 168, 83, 0.015) 1px, transparent 1px);
    background-size: 60px 60px;
    pointer-events: none;
    z-index: 0;
}

/* ── Typography ─────────────────────────────────────────────── */
h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-display);
    color: var(--text-bright);
    letter-spacing: 0.03em;
    line-height: 1.3;
}

h1 { font-size: clamp(1.6rem, 3vw, 2.4rem); }
h2 { font-size: clamp(1.3rem, 2.5vw, 1.9rem); }
h3 { font-size: 1.35rem; }

a {
    color: var(--gold);
    text-decoration: none;
    transition: color var(--transition);
}
a:hover { color: var(--gold-bright); }

code, pre, .mono {
    font-family: var(--font-mono);
    font-size: 0.88em;
    color: var(--cyan);
}

/* ── Layout Shell ───────────────────────────────────────────── */
.codex-wrapper {
    position: relative;
    z-index: 1;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.codex-main {
    flex: 1;
    padding: 2rem 0;
}

/* ── Navigation ─────────────────────────────────────────────── */
.codex-nav {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(7, 7, 15, 0.95);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-glow);
    padding: 0 1.5rem;
}

.codex-nav-inner {
    max-width: 1280px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 62px;
}

.codex-brand {
    font-family: var(--font-display);
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--gold) !important;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.codex-brand::before {
    content: '⬡';
    color: var(--cyan);
    font-size: 1rem;
}

.codex-nav-links {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    list-style: none;
}

.codex-nav-links a {
    font-family: var(--font-display);
    font-size: 0.75rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-secondary);
    padding: 0.4rem 0.9rem;
    border-radius: var(--radius-sm);
    transition: all var(--transition);
}

.codex-nav-links a:hover,
.codex-nav-links a.active {
    color: var(--gold);
    background: rgba(212, 168, 83, 0.08);
}

.notif-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--red);
    color: #fff;
    font-family: var(--font-mono);
    font-size: 0.7rem;
    min-width: 18px;
    height: 18px;
    border-radius: 50%;
    padding: 0 4px;
    margin-left: 4px;
    vertical-align: middle;
}

/* ── Cards ──────────────────────────────────────────────────── */
.codex-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-dim);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    position: relative;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.codex-card:hover {
    border-color: var(--border-accent);
    box-shadow: var(--shadow-glow);
}

.codex-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0;
    width: 3px;
    height: 100%;
    background: linear-gradient(to bottom, var(--gold), transparent);
    border-radius: var(--radius-md) 0 0 var(--radius-md);
    opacity: 0;
    transition: opacity var(--transition);
}

.codex-card:hover::before { opacity: 1; }

.codex-card-lore { border-left: 3px solid var(--purple); }
.codex-card-lore::before { background: linear-gradient(to bottom, var(--purple), transparent); opacity: 1; }

.codex-card-thread { border-left: 3px solid var(--cyan); }
.codex-card-thread::before { background: linear-gradient(to bottom, var(--cyan), transparent); opacity: 1; }

/* ── Post Feed Item ─────────────────────────────────────────── */
.post-item {
    padding: 1.75rem 0;
    border-bottom: 1px solid var(--border-dim);
}

.post-item:last-child { border-bottom: none; }

.post-meta {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--text-muted);
    letter-spacing: 0.05em;
    margin-bottom: 0.6rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.post-meta .category-badge {
    color: var(--gold);
    font-weight: 600;
}

.post-title {
    font-family: var(--font-display);
    font-size: 1.35rem;
    color: var(--text-bright);
    margin-bottom: 0.5rem;
    line-height: 1.35;
}

.post-title a { color: inherit; }
.post-title a:hover { color: var(--gold); }

.post-excerpt {
    color: var(--text-secondary);
    font-size: 1rem;
    margin-bottom: 0.75rem;
}

.post-tags { display: flex; gap: 0.4rem; flex-wrap: wrap; }

/* ── Tags & Badges ──────────────────────────────────────────── */
.codex-tag {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    letter-spacing: 0.06em;
    padding: 0.2rem 0.6rem;
    border: 1px solid var(--border-glow);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    transition: all var(--transition);
}

.codex-tag:hover {
    border-color: var(--gold-dim);
    color: var(--gold);
    background: rgba(212, 168, 83, 0.06);
}

.badge-canon    { background: rgba(74, 184, 122, 0.15); color: var(--green);  border: 1px solid rgba(74, 184, 122, 0.3); }
.badge-disputed { background: rgba(196, 74, 74, 0.15);  color: var(--red);    border: 1px solid rgba(196, 74, 74, 0.3); }
.badge-stub     { background: rgba(138, 96, 48, 0.15);  color: var(--gold-dim); border: 1px solid var(--gold-dim); }
.badge-fork     { background: rgba(76, 201, 212, 0.1);  color: var(--cyan);   border: 1px solid var(--cyan-dim); }

/* ── Forms ──────────────────────────────────────────────────── */
.codex-form-group { margin-bottom: 1.25rem; }

.codex-label {
    display: block;
    font-family: var(--font-mono);
    font-size: 0.72rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text-secondary);
    margin-bottom: 0.4rem;
}

.codex-input,
.codex-select,
.codex-textarea,
.form-control,
.form-select {
    width: 100%;
    background: var(--bg-deep);
    border: 1px solid var(--border-glow);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 1rem;
    padding: 0.65rem 1rem;
    transition: border-color var(--transition), box-shadow var(--transition);
    outline: none;
}

.codex-input:focus,
.codex-select:focus,
.codex-textarea:focus,
.form-control:focus,
.form-select:focus {
    border-color: var(--gold-dim);
    box-shadow: 0 0 0 3px rgba(212, 168, 83, 0.1);
    background: var(--bg-surface);
    color: var(--text-bright);
}

.codex-input::placeholder { color: var(--text-muted); }

.codex-textarea { resize: vertical; min-height: 120px; }

/* ── Buttons ────────────────────────────────────────────────── */
.btn-codex {
    font-family: var(--font-display);
    font-size: 0.75rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    padding: 0.6rem 1.5rem;
    border: 1px solid var(--gold-dim);
    background: transparent;
    color: var(--gold);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

.btn-codex:hover {
    background: var(--gold);
    color: var(--bg-void);
    box-shadow: 0 0 16px rgba(212, 168, 83, 0.3);
}

.btn-codex-ghost {
    border-color: var(--border-glow);
    color: var(--text-secondary);
}

.btn-codex-ghost:hover {
    border-color: var(--gold-dim);
    color: var(--gold);
    background: rgba(212, 168, 83, 0.06);
}

.btn-codex-danger {
    border-color: rgba(196, 74, 74, 0.4);
    color: var(--red);
}

.btn-codex-danger:hover {
    background: var(--red);
    color: #fff;
    box-shadow: 0 0 16px rgba(196, 74, 74, 0.3);
}

.btn-codex-cyan {
    border-color: var(--cyan-dim);
    color: var(--cyan);
}

.btn-codex-cyan:hover {
    background: var(--cyan);
    color: var(--bg-void);
}

/* ── Sidebar ────────────────────────────────────────────────── */
.codex-sidebar-section {
    margin-bottom: 2rem;
}

.sidebar-title {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-dim);
    padding-bottom: 0.5rem;
    margin-bottom: 1rem;
}

/* ── Lore Entry ──────────────────────────────────────────────── */
.lore-header {
    background: linear-gradient(135deg, var(--bg-elevated) 0%, rgba(122, 92, 184, 0.1) 100%);
    border: 1px solid var(--border-accent);
    padding: 2rem;
    border-radius: var(--radius-md);
    margin-bottom: 2rem;
    position: relative;
    overflow: hidden;
}

.lore-header::after {
    content: '◈';
    position: absolute;
    right: 1.5rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: 4rem;
    color: var(--purple);
    opacity: 0.08;
}

.lore-type-indicator {
    font-family: var(--font-mono);
    font-size: 0.65rem;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--purple);
    margin-bottom: 0.5rem;
}

.lore-summary-box {
    background: var(--bg-deep);
    border: 1px solid var(--border-glow);
    border-left: 3px solid var(--purple);
    padding: 1rem 1.25rem;
    margin: 1.5rem 0;
    font-size: 0.95rem;
    color: var(--text-secondary);
}

/* ── Thread ─────────────────────────────────────────────────── */
.thread-reply {
    padding: 1.25rem;
    border-bottom: 1px solid var(--border-dim);
    position: relative;
    transition: background var(--transition);
}

.thread-reply:hover { background: rgba(255,255,255,0.015); }

.thread-reply.nested {
    margin-left: 2.5rem;
    border-left: 2px solid var(--border-glow);
    padding-left: 1.25rem;
}

.reply-author {
    font-family: var(--font-mono);
    font-size: 0.78rem;
    color: var(--gold-dim);
    margin-bottom: 0.4rem;
}

.fork-banner {
    background: rgba(76, 201, 212, 0.06);
    border: 1px dashed var(--cyan-dim);
    border-radius: var(--radius-sm);
    padding: 0.75rem 1rem;
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--cyan);
    margin: 1rem 0;
}

/* ── Admin Sidebar ──────────────────────────────────────────── */
.admin-sidebar {
    background: var(--bg-surface);
    border-right: 1px solid var(--border-dim);
    width: 240px;
    min-height: 100vh;
    padding: 1.5rem 0;
    position: sticky;
    top: 62px;
}

.admin-nav-section {
    padding: 0 1rem;
    margin-bottom: 1.5rem;
}

.admin-nav-label {
    font-family: var(--font-mono);
    font-size: 0.62rem;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--text-muted);
    padding: 0 0.5rem;
    margin-bottom: 0.4rem;
}

.admin-nav-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-family: var(--font-body);
    font-size: 0.95rem;
    transition: all var(--transition);
    cursor: pointer;
}

.admin-nav-item:hover,
.admin-nav-item.active {
    background: rgba(212, 168, 83, 0.08);
    color: var(--gold);
}

.admin-nav-item .nav-icon { font-size: 0.9rem; width: 20px; text-align: center; }

/* ── Tables ─────────────────────────────────────────────────── */
.codex-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.92rem;
}

.codex-table thead th {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-muted);
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-glow);
    background: var(--bg-elevated);
    text-align: left;
}

.codex-table tbody td {
    padding: 0.9rem 1rem;
    border-bottom: 1px solid var(--border-dim);
    vertical-align: middle;
}

.codex-table tbody tr { transition: background var(--transition); }
.codex-table tbody tr:hover { background: var(--bg-elevated); }

/* ── Alerts ─────────────────────────────────────────────────── */
.codex-alert {
    padding: 0.85rem 1.25rem;
    border-radius: var(--radius-sm);
    font-family: var(--font-mono);
    font-size: 0.85rem;
    margin-bottom: 1.25rem;
    border-left: 3px solid;
}

.alert-success { background: rgba(74,184,122,0.08); border-color: var(--green); color: var(--green); }
.alert-danger   { background: rgba(196,74,74,0.08);  border-color: var(--red);   color: var(--red); }
.alert-warning  { background: rgba(212,168,83,0.08); border-color: var(--gold);  color: var(--gold); }
.alert-info     { background: rgba(76,201,212,0.08); border-color: var(--cyan);  color: var(--cyan); }

/* ── Pagination ─────────────────────────────────────────────── */
.codex-pagination .page-link {
    background: transparent;
    border: 1px solid var(--border-glow);
    color: var(--text-secondary);
    font-family: var(--font-mono);
    font-size: 0.8rem;
    padding: 0.45rem 0.9rem;
    border-radius: var(--radius-sm) !important;
    margin: 0 2px;
    transition: all var(--transition);
}

.codex-pagination .page-link:hover { border-color: var(--gold-dim); color: var(--gold); background: rgba(212,168,83,0.06); }
.codex-pagination .active .page-link { background: var(--gold); border-color: var(--gold); color: var(--bg-void); }

/* ── Footer ─────────────────────────────────────────────────── */
.codex-footer {
    border-top: 1px solid var(--border-dim);
    padding: 2rem 0;
    text-align: center;
    font-family: var(--font-mono);
    font-size: 0.72rem;
    color: var(--text-muted);
    letter-spacing: 0.08em;
}

.codex-footer::before {
    content: '— ⬡ —';
    display: block;
    color: var(--border-accent);
    margin-bottom: 0.75rem;
    font-size: 0.9rem;
}

/* ── Prose (article content) ────────────────────────────────── */
.codex-prose {
    max-width: 780px;
    color: var(--text-primary);
    font-size: 1.1rem;
    line-height: 1.85;
}

.codex-prose h2, .codex-prose h3 { margin: 2rem 0 0.75rem; }
.codex-prose p  { margin-bottom: 1.3rem; }
.codex-prose blockquote {
    border-left: 3px solid var(--gold-dim);
    padding: 0.5rem 1.25rem;
    color: var(--text-secondary);
    font-style: italic;
    margin: 1.5rem 0;
    background: rgba(212, 168, 83, 0.04);
}
.codex-prose img {
    max-width: 100%;
    border: 1px solid var(--border-glow);
    border-radius: var(--radius-md);
}
.codex-prose hr {
    border: none;
    border-top: 1px solid var(--border-glow);
    margin: 2.5rem 0;
    text-align: center;
}
.codex-prose hr::after {
    content: '◈';
    display: inline-block;
    background: var(--bg-void);
    padding: 0 1rem;
    color: var(--border-accent);
    position: relative;
    top: -0.7rem;
}

/* ── TinyMCE Skin Override ──────────────────────────────────── */
.tox-tinymce { border: 1px solid var(--border-glow) !important; border-radius: var(--radius-sm) !important; }
.tox .tox-toolbar { background: var(--bg-elevated) !important; }

/* ── Utility ────────────────────────────────────────────────── */
.text-gold   { color: var(--gold); }
.text-cyan   { color: var(--cyan); }
.text-purple { color: var(--purple); }
.text-muted-codex { color: var(--text-muted); font-family: var(--font-mono); font-size: 0.82rem; }
.divider-rune { border: none; border-top: 1px solid var(--border-dim); margin: 2rem 0; position: relative; }
.section-label {
    font-family: var(--font-mono);
    font-size: 0.65rem;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}
.section-label::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border-dim);
}

/* ── Animations ─────────────────────────────────────────────── */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes glowPulse {
    0%, 100% { box-shadow: 0 0 8px rgba(212,168,83,0.15); }
    50%       { box-shadow: 0 0 20px rgba(212,168,83,0.35); }
}

.fade-in { animation: fadeIn 0.35s ease forwards; }
.glow-pulse { animation: glowPulse 3s ease infinite; }

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 768px) {
    .admin-sidebar { display: none; }
    .codex-nav-links { gap: 0; }
    .codex-nav-links a { padding: 0.4rem 0.5rem; font-size: 0.68rem; }
}

/* ── Scrollbar ──────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-deep); }
::-webkit-scrollbar-thumb { background: var(--border-accent); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--gold-dim); }
