/* ============================================================
   Centralized blog header + page theme - makes every /blog page
   look identical to the React app (same purple-gradient theme and
   the same glass navbar from client/src/styles/Header.css).
   Namespaced .hra-* so it never collides with per-page blog CSS.
   Loaded after each page's inline <style>, so its body/theme rules
   win at equal specificity. Theme syncs with the app via the
   `darkMode` localStorage key + body.dark-mode / html.dark.
   ============================================================ */

:root {
    --hra-accent: #667eea;
    --hra-accent2: #764ba2;
    --hra-text: #1f2937;
    --hra-muted: #6b7280;
    --hra-hover: rgba(255, 255, 255, 0.25);
    --hra-bar: rgba(255, 255, 255, 0.1);
    --hra-border: rgba(255, 255, 255, 0.18);
    --hra-card: #ffffff;
    --hra-card-border: rgba(102, 126, 234, 0.25);
    --hra-gold: linear-gradient(135deg, #ffd84d 0%, #f5a623 100%);
    --hra-gold-hover: linear-gradient(135deg, #ffe066 0%, #ff9f1c 100%);
    --hra-gold-text: #1a1a2e;

    /* Reading surface for long-form content sitting on the gradient */
    --hra-surface: #ffffff;
    --hra-surface-border: rgba(102, 126, 234, 0.16);
}

/* ---------- Page theme (mirror the app) ---------- */
body {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
}

body.dark-mode {
    background: linear-gradient(135deg, #0f172a 0%, #1f2937 100%);
    color: #e5e7eb;

    --hra-text: #e5e7eb;
    --hra-muted: #9ca3af;
    --hra-hover: rgba(255, 255, 255, 0.12);
    --hra-bar: rgba(15, 23, 42, 0.4);
    --hra-border: rgba(255, 255, 255, 0.08);
    --hra-card: #0b1220;
    --hra-card-border: #1f2937;
    --hra-surface: #0b1220;
    --hra-surface-border: #1f2937;
}
/* Each blog page owns its own dark palette (its former prefers-color-scheme block
   is now a body.dark-mode block), so the toggle drives the content theme. */

body.hra-no-scroll {
    overflow: hidden;
}

/* Long-form article content → a readable card floating on the gradient
   (the app never puts body text directly on the gradient). Only the main
   content wrap (direct child of body); the footer's inner .wrap is untouched. */
body > .wrap {
    background: var(--hra-surface);
    border: 1px solid var(--hra-surface-border);
    border-radius: 16px;
    padding: clamp(22px, 4vw, 44px) !important;
    margin: 28px auto 40px !important;
    box-shadow: 0 20px 45px rgba(0, 0, 0, 0.18);
}

/* Index hero + footers sit directly on the gradient → light text */
body > .hero h1 {
    background: none !important;
    -webkit-text-fill-color: #fff !important;
    color: #fff !important;
}
body > .hero p {
    color: rgba(255, 255, 255, 0.92) !important;
}
body > footer,
body > footer a {
    color: rgba(255, 255, 255, 0.85) !important;
    border-top-color: rgba(255, 255, 255, 0.15) !important;
}

/* ============================================================
   Navbar - matches client/src/styles/Header.css (.main-header)
   ============================================================ */
.hra-nav {
    position: sticky;
    top: 0;
    z-index: 1000;
    width: 100%;
    border-bottom: 1px solid transparent;
    transition:
        border-color 0.2s ease,
        box-shadow 0.2s ease;
}

/* Glass on ::before so .hra-nav is not a containing block for the fixed drawer */
.hra-nav::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    background: var(--hra-bar);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
    pointer-events: none;
}

.hra-nav.is-scrolled {
    border-bottom-color: var(--hra-border);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.06);
}
body.dark-mode .hra-nav.is-scrolled {
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

.hra-nav__bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    max-width: 1280px;
    height: 56px;
    margin: 0 auto;
    padding: 0 clamp(16px, 4vw, 32px);
}

/* ---------- Logo ---------- */
.hra-nav__logo {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    flex-shrink: 1;
    text-decoration: none;
    color: var(--hra-text);
    overflow: hidden;
}
.hra-nav__logo:hover {
    text-decoration: none;
}
.hra-nav__logo-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    border-radius: 9px;
    background: linear-gradient(135deg, var(--hra-accent), var(--hra-accent2));
}
.hra-nav__logo-icon svg {
    width: 17px;
    height: 17px;
    color: #fff;
}
.hra-nav__logo-text {
    font-weight: 700;
    font-size: 1rem;
    color: var(--hra-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ---------- Desktop nav (revealed >= 1100px, like the app) ---------- */
.hra-nav__desktop {
    display: none;
    align-items: center;
    gap: 18px;
}
.hra-nav__links {
    display: flex;
    align-items: center;
    gap: 4px;
    list-style: none;
    margin: 0;
    padding: 0;
}
.hra-nav__links a {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 12px;
    border-radius: 8px;
    font-size: 0.88rem;
    font-weight: 500;
    color: var(--hra-text);
    text-decoration: none;
    white-space: nowrap;
    transition:
        color 0.15s ease,
        background 0.15s ease;
}
.hra-nav__links a:hover {
    background: var(--hra-hover);
    text-decoration: none;
}
.hra-nav__links a.is-active {
    color: #fff;
    background: linear-gradient(135deg, var(--hra-accent), var(--hra-accent2));
    font-weight: 600;
}
.hra-nav__links a.is-highlight {
    font-weight: 600;
}
.hra-nav__links a svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}
.hra-drawer__links a svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.hra-nav__actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* ---------- Language switcher (mirrors the app's LanguageSwitcher) ---------- */
.hra-lang {
    position: relative;
}
.hra-lang__btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 9px;
    border: 1px solid transparent;
    border-radius: 8px;
    background: transparent;
    color: var(--hra-text);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
}
.hra-lang__btn:hover {
    background: var(--hra-hover);
}
.hra-lang__caret {
    font-size: 0.65rem;
}
.hra-lang__menu {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    min-width: 150px;
    padding: 4px;
    background: var(--hra-card);
    border: 1px solid var(--hra-card-border);
    border-radius: 10px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.16);
    z-index: 20;
}
.hra-lang__menu[hidden] {
    display: none;
}
.hra-lang__opt {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 8px 10px;
    border: none;
    border-radius: 7px;
    background: transparent;
    color: var(--hra-text);
    font-size: 0.9rem;
    text-align: left;
    cursor: pointer;
}
.hra-lang__opt:hover,
.hra-lang__opt.is-current {
    background: var(--hra-hover);
}
.hra-lang__opt.is-current {
    font-weight: 600;
}

/* ---------- Auth buttons (match .btn-signin / .btn-signup) ---------- */
.hra-nav__signin,
.hra-nav__signup {
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 0.9rem;
    cursor: pointer;
    border: 1px solid transparent;
    text-decoration: none;
    white-space: nowrap;
    transition:
        transform 0.15s ease,
        box-shadow 0.15s ease,
        background 0.15s ease;
}
.hra-nav__signin {
    background: transparent;
    color: var(--hra-text);
    font-weight: 600;
}
.hra-nav__signin:hover {
    background: var(--hra-hover);
    text-decoration: none;
}
.hra-nav__signup {
    color: var(--hra-gold-text);
    background: var(--hra-gold);
    font-weight: 700;
}
.hra-nav__signup:hover {
    transform: translateY(-1px);
    background: var(--hra-gold-hover);
    box-shadow: 0 8px 18px rgba(245, 166, 35, 0.45);
    text-decoration: none;
}

/* ---------- Theme pill (mirrors the app's DarkModeToggle) ---------- */
.hra-theme {
    position: relative;
    width: 50px;
    height: 26px;
    flex-shrink: 0;
    padding: 0;
    border: none;
    border-radius: 26px;
    background: #8a9ceb;
    cursor: pointer;
    transition: background 0.4s ease;
}
body.dark-mode .hra-theme {
    background: #2d3748;
}
.hra-theme::before {
    content: "☀️";
    position: absolute;
    left: 6px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.7rem;
    line-height: 1;
}
.hra-theme::after {
    content: "🌙";
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.7rem;
    line-height: 1;
}
.hra-theme__knob {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #4a52c0;
    transition: left 0.3s ease;
    z-index: 1;
}
body.dark-mode .hra-theme__knob {
    left: 27px;
}

/* ---------- Hamburger (shown < 1100px) ---------- */
.hra-nav__burger {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    width: 44px;
    height: 44px;
    flex-shrink: 0;
    padding: 0;
    border: none;
    border-radius: 10px;
    background: transparent;
    color: var(--hra-text);
    cursor: pointer;
}
.hra-nav__burger:hover {
    background: var(--hra-hover);
}
.hra-nav__burger span {
    display: block;
    width: 22px;
    height: 2px;
    border-radius: 2px;
    background: var(--hra-text);
}

/* ---------- Mobile drawer (appended to <body>) ---------- */
.hra-drawer-overlay {
    position: fixed;
    inset: 0;
    z-index: 1100;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    visibility: hidden;
    transition:
        opacity 0.25s ease,
        visibility 0.25s ease;
}
.hra-drawer-overlay.is-open {
    opacity: 1;
    visibility: visible;
}
.hra-drawer {
    position: absolute;
    top: 0;
    right: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
    width: min(340px, 86vw);
    height: 100%;
    padding: 16px;
    background: var(--hra-card);
    box-shadow: -8px 0 30px rgba(0, 0, 0, 0.2);
    transform: translateX(100%);
    transition: transform 0.28s ease;
    overflow-y: auto;
}
.hra-drawer-overlay.is-open .hra-drawer {
    transform: translateX(0);
}
.hra-drawer__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 2px 4px 14px;
    margin-bottom: 6px;
    border-bottom: 1px solid var(--hra-card-border);
}
.hra-drawer__title {
    font-weight: 700;
    color: var(--hra-text);
}
.hra-drawer__close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--hra-text);
    font-size: 1.6rem;
    line-height: 1;
    cursor: pointer;
}
.hra-drawer__close:hover {
    background: var(--hra-hover);
}
.hra-drawer__links {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.hra-drawer__links a {
    display: flex;
    align-items: center;
    padding: 12px 14px;
    border-radius: 10px;
    color: var(--hra-text);
    font-size: 0.98rem;
    font-weight: 500;
    text-decoration: none;
}
.hra-drawer__links a:hover {
    background: var(--hra-hover);
    text-decoration: none;
}
.hra-drawer__links a.is-active {
    color: var(--hra-accent);
    background: var(--hra-hover);
    font-weight: 600;
}
.hra-drawer__actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 12px;
}
.hra-drawer__actions .hra-nav__signin,
.hra-drawer__actions .hra-nav__signup {
    width: 100%;
    text-align: center;
    padding: 12px;
    border-radius: 10px;
    font-size: 0.95rem;
}
.hra-drawer__actions .hra-nav__signin {
    border: 1px solid var(--hra-card-border);
}
.hra-drawer__theme {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 14px 6px 4px;
    margin-top: auto;
    color: var(--hra-muted);
    font-size: 0.9rem;
    border-top: 1px solid var(--hra-card-border);
}

/* ---------- Breakpoint (match the app: nav at >= 1100px) ---------- */
@media (min-width: 1100px) {
    .hra-nav__desktop {
        display: flex;
    }
    .hra-nav__burger {
        display: none;
    }
}
@media (min-width: 640px) {
    .hra-nav__bar {
        height: 60px;
    }
}
