/* ============================================================================
   NERDDPEDIA THEME - shared design system
   Extracted from the redesigned index.php so every inner page matches it.
   Loaded by includes/page_top.php. Page-specific styles live in each page.
   ============================================================================ */

:root {
    color-scheme: light;
    --page: #f7f8fb;
    --surface: #ffffff;
    --surface-soft: #f1f3f7;
    --surface-elevated: rgba(255,255,255,.88);
    --ink: #151821;
    --ink-soft: #4f5665;
    --muted: #7b8495;
    --line: #dfe3ea;
    --line-strong: #cbd1dc;
    --brand: #2457e6;
    --brand-dark: #173fb2;
    --brand-soft: #eaf0ff;
    --violet: #7057e9;
    --green: #0c8b68;
    --gold: #c47a10;
    --red: #d14b53;
    --shadow-sm: 0 1px 2px rgba(16,24,40,.04), 0 5px 18px rgba(16,24,40,.05);
    --shadow-md: 0 18px 45px rgba(20,32,64,.11);
    --radius-sm: 10px;
    --radius: 16px;
    --radius-lg: 24px;
    --header-h: 76px;
    --serif: 'Newsreader', Georgia, serif;
    --sans: 'DM Sans', Inter, system-ui, sans-serif;
}

[data-theme="dark"] {
    color-scheme: dark;
    --page: #0d1017;
    --surface: #151923;
    --surface-soft: #1c212d;
    --surface-elevated: rgba(21,25,35,.9);
    --ink: #f4f6fb;
    --ink-soft: #b8c0cf;
    --muted: #858fa1;
    --line: #2a3140;
    --line-strong: #3a4354;
    --brand: #7da0ff;
    --brand-dark: #a9bdff;
    --brand-soft: #1c294d;
    --violet: #a695ff;
    --green: #5bd1ae;
    --gold: #f0b968;
    --red: #ff8189;
    --shadow-sm: 0 1px 2px rgba(0,0,0,.2), 0 8px 20px rgba(0,0,0,.18);
    --shadow-md: 0 20px 55px rgba(0,0,0,.34);
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
    margin: 0;
    min-height: 100vh;
    background:
        radial-gradient(circle at 12% -8%, rgba(36,87,230,.09), transparent 28rem),
        radial-gradient(circle at 92% 8%, rgba(112,87,233,.07), transparent 24rem),
        var(--page);
    color: var(--ink);
    font-family: var(--sans);
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}
body.menu-open, body.modal-open { overflow: hidden; }
img { display: block; max-width: 100%; }
button, input, textarea, select { font: inherit; }
button { color: inherit; }
a { color: inherit; text-decoration: none; }
a:focus-visible, button:focus-visible, input:focus-visible {
    outline: 3px solid color-mix(in srgb, var(--brand) 45%, transparent);
    outline-offset: 3px;
}
.skip-link {
    position: fixed; left: 16px; top: -60px; z-index: 1000;
    padding: 10px 14px; border-radius: 9px; background: var(--ink); color: var(--surface);
    transition: top .2s ease;
}
.skip-link:focus { top: 12px; }

/* ----------------------------------------------------------------------------
   Header
---------------------------------------------------------------------------- */
.site-header {
    position: sticky; top: 0; z-index: 100;
    height: var(--header-h);
    border-bottom: 1px solid color-mix(in srgb, var(--line) 82%, transparent);
    background: var(--surface-elevated);
    backdrop-filter: blur(18px) saturate(150%);
    -webkit-backdrop-filter: blur(18px) saturate(150%);
}
.header-inner {
    width: min(1480px, calc(100% - 36px)); height: 100%; margin: 0 auto;
    display: grid; grid-template-columns: auto minmax(240px, 540px) auto;
    align-items: center; gap: 26px;
}
.brand { display: flex; align-items: center; gap: 12px; min-width: max-content; }
.brand-mark { width: 46px; height: 46px; object-fit: contain; }
.theme-logo-light { display: none; }
[data-theme="light"] .theme-logo-default { display: none; }
[data-theme="light"] .theme-logo-light { display: block; }
.brand-copy { display: flex; flex-direction: column; line-height: 1; }
.brand-name { font-family: var(--serif); font-size: 1.55rem; font-weight: 700; letter-spacing: -.035em; }
.brand-tag { margin-top: 5px; color: var(--muted); font-size: .69rem; font-weight: 700; text-transform: uppercase; letter-spacing: .13em; }
.header-search { position: relative; }
.header-search i { position: absolute; left: 16px; top: 50%; translate: 0 -50%; color: var(--muted); }
.header-search input {
    width: 100%; height: 46px; padding: 0 46px 0 44px;
    border: 1px solid var(--line); border-radius: 13px;
    background: var(--surface-soft); color: var(--ink); transition: .2s ease;
}
.header-search input:hover { border-color: var(--line-strong); }
.header-search input:focus { border-color: var(--brand); background: var(--surface); box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 12%, transparent); outline: none; }
.search-shortcut {
    position: absolute; right: 10px; top: 50%; translate: 0 -50%;
    border: 1px solid var(--line); border-radius: 7px; padding: 2px 7px;
    color: var(--muted); background: var(--surface); font-size: .72rem;
}
.header-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; }
.header-link, .icon-button {
    height: 42px; display: inline-flex; align-items: center; justify-content: center;
    border: 1px solid transparent; border-radius: 11px; background: transparent;
    color: var(--ink-soft); cursor: pointer; transition: .2s ease;
}
.header-link { padding: 0 12px; gap: 8px; font-weight: 700; font-size: .86rem; }
.header-link:hover, .icon-button:hover { color: var(--ink); background: var(--surface-soft); border-color: var(--line); }
.icon-button { width: 42px; }
.avatar-button {
    width: 44px; height: 44px; padding: 0; display: inline-flex; border: 2px solid var(--line);
    border-radius: 50%; background: var(--surface-soft); cursor: pointer; overflow: hidden; transition: .2s ease;
}
.avatar-button:hover { border-color: var(--brand); }
.avatar-button img { width: 100%; height: 100%; object-fit: cover; }
.avatar-fallback { width: 100%; height: 100%; display: grid; place-items: center; color: var(--ink-soft); font-weight: 800; }

/* ----------------------------------------------------------------------------
   Layout + shared bits
---------------------------------------------------------------------------- */
.page-shell { width: min(1480px, calc(100% - 36px)); margin: 0 auto; }
.page-shell--narrow { width: min(980px, calc(100% - 36px)); }
.eyebrow {
    display: inline-flex; align-items: center; gap: 8px; padding: 7px 13px;
    border: 1px solid color-mix(in srgb, var(--brand) 30%, var(--line));
    border-radius: 999px; background: var(--brand-soft); color: var(--brand);
    font-size: .72rem; font-weight: 800; text-transform: uppercase; letter-spacing: .1em;
}
.page-intro { padding: 46px 0 8px; }
.page-intro h1 { margin: 16px 0 0; font-family: var(--serif); font-size: clamp(2.3rem, 5vw, 3.4rem); font-weight: 700; letter-spacing: -.035em; line-height: 1.02; }
.page-intro p { max-width: 640px; margin: 12px 0 0; color: var(--ink-soft); font-size: 1.02rem; }

.section-heading { margin: 0 0 20px; display: flex; align-items: end; justify-content: space-between; gap: 16px; }
.section-heading h2 { margin: 0; font-family: var(--serif); font-size: 1.75rem; font-weight: 700; letter-spacing: -.03em; }
.section-heading p { margin: 5px 0 0; color: var(--muted); font-size: .85rem; }
.section-action { color: var(--brand); font-size: .84rem; font-weight: 800; }
.section-action:hover { color: var(--brand-dark); }

.primary-button {
    position: relative; min-height: 48px; padding: 0 19px; display: inline-flex; align-items: center; justify-content: center; gap: 9px;
    border: 0; border-radius: 12px; background: var(--brand); color: #fff; font-weight: 800; cursor: pointer;
    box-shadow: 0 10px 24px color-mix(in srgb, var(--brand) 24%, transparent); transition: .2s ease;
}
.primary-button:hover { transform: translateY(-2px); }
.ghost-button {
    min-height: 44px; padding: 0 16px; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--ink-soft);
    font-weight: 700; font-size: .88rem; cursor: pointer; transition: .2s ease;
}
.ghost-button:hover { color: var(--brand); border-color: color-mix(in srgb, var(--brand) 45%, var(--line)); transform: translateY(-1px); }

.surface-card { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-sm); }

.empty-state { padding: 70px 24px; text-align: center; }
.empty-state i { display: block; margin: 0 auto 18px; color: var(--line-strong); font-size: 3rem; }
.empty-state h2 { margin: 0 0 8px; font-family: var(--serif); font-size: 1.7rem; }
.empty-state p { max-width: 480px; margin: 0 auto; color: var(--ink-soft); line-height: 1.6; }

/* ----------------------------------------------------------------------------
   Cards (article / category / editor) - shared with the homepage
---------------------------------------------------------------------------- */
.article-card { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); overflow: hidden; box-shadow: var(--shadow-sm); transition: .25s ease; display: block; }
.article-card:hover { transform: translateY(-4px); border-color: var(--line-strong); box-shadow: var(--shadow-md); }
.article-image-wrap { position: relative; aspect-ratio: 16 / 9; overflow: hidden; background: var(--surface-soft); }
.article-image { width: 100%; height: 100%; object-fit: cover; transition: transform .55s ease; }
.article-card:hover .article-image { transform: scale(1.035); }
.article-category { position: absolute; left: 12px; bottom: 12px; padding: 5px 9px; border-radius: 8px; background: rgba(12,16,25,.78); color: #fff; backdrop-filter: blur(8px); font-size: .69rem; font-weight: 800; }
.article-card .article-content { padding: 18px; }
.article-card .article-title { margin: 0 0 8px; font-family: var(--serif); font-size: 1.35rem; line-height: 1.08; letter-spacing: -.02em; }
.article-summary { margin: 0; color: var(--ink-soft); font-size: .86rem; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }
.article-meta { margin-top: 16px; padding-top: 13px; display: flex; align-items: center; justify-content: space-between; gap: 12px; border-top: 1px solid var(--line); color: var(--muted); font-size: .72rem; font-weight: 700; }
.editor-inline { min-width: 0; display: flex; align-items: center; gap: 8px; }
.editor-inline img { width: 24px; height: 24px; flex: 0 0 auto; border-radius: 50%; object-fit: cover; background: var(--surface-soft); }
.editor-inline span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.categories-grid { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 14px; }
.category-card { position: relative; min-height: 148px; padding: 19px; display: flex; flex-direction: column; justify-content: space-between; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-sm); overflow: hidden; transition: .25s ease; }
.category-card::after { content: ''; position: absolute; right: -30px; bottom: -42px; width: 100px; height: 100px; border-radius: 50%; background: color-mix(in srgb, var(--category) 10%, transparent); transition: .25s ease; }
.category-card:hover { transform: translateY(-4px); border-color: color-mix(in srgb, var(--category) 48%, var(--line)); box-shadow: var(--shadow-md); }
.category-card:hover::after { transform: scale(1.25); }
.category-icon { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 11px; background: color-mix(in srgb, var(--category) 14%, var(--surface)); color: var(--category); }
.category-name { margin-top: 22px; font-weight: 800; display: block; }
.category-count { margin-top: 4px; color: var(--muted); font-size: .77rem; display: block; }

.editor-card { min-width: 0; padding: 20px 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); text-align: center; box-shadow: var(--shadow-sm); transition: .22s ease; display: block; }
.editor-card:hover { transform: translateY(-3px); border-color: var(--brand); box-shadow: var(--shadow-md); }
.editor-avatar { width: 64px; height: 64px; margin: 0 auto 13px; border-radius: 50%; object-fit: cover; border: 3px solid var(--surface); box-shadow: 0 0 0 2px var(--brand-soft); background: var(--surface-soft); }
.editor-name { font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.editor-title { margin-top: 4px; color: var(--muted); font-size: .72rem; line-height: 1.3; }

/* ----------------------------------------------------------------------------
   Slide menu, overlay, request modal, FAB
---------------------------------------------------------------------------- */
.overlay { position: fixed; inset: 0; z-index: 300; background: rgba(6,10,18,.58); backdrop-filter: blur(4px); opacity: 0; visibility: hidden; transition: .25s ease; }
.overlay.open { opacity: 1; visibility: visible; }
.slide-menu {
    position: fixed; z-index: 310; top: 12px; right: 12px; bottom: 12px; width: min(370px, calc(100% - 24px));
    display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 22px; background: var(--surface);
    box-shadow: 0 30px 90px rgba(0,0,0,.3); transform: translateX(calc(100% + 32px)); transition: transform .3s cubic-bezier(.2,.8,.2,1); overflow: hidden;
}
.slide-menu.open { transform: translateX(0); }
.menu-head { padding: 17px 18px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.menu-brand { display: flex; align-items: center; gap: 10px; }
.menu-brand img { width: 38px; height: 38px; object-fit: contain; }
.menu-brand strong { font-family: var(--serif); font-size: 1.3rem; }
.menu-scroll { flex: 1; overflow-y: auto; padding: 14px; }
.menu-label { margin: 12px 10px 7px; color: var(--muted); font-size: .67rem; font-weight: 800; text-transform: uppercase; letter-spacing: .12em; }
.menu-item { min-height: 45px; padding: 0 12px; display: flex; align-items: center; gap: 12px; border-radius: 10px; color: var(--ink-soft); font-size: .88rem; font-weight: 700; }
.menu-item i { width: 19px; color: var(--muted); text-align: center; }
.menu-item:hover { color: var(--ink); background: var(--surface-soft); }
.menu-item:hover i { color: var(--brand); }
.menu-divider { height: 1px; margin: 13px 8px; background: var(--line); }
.menu-foot { padding: 14px; border-top: 1px solid var(--line); }
.theme-button { width: 100%; min-height: 48px; padding: 0 14px; display: flex; align-items: center; justify-content: space-between; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-soft); cursor: pointer; }
.theme-button span { display: flex; align-items: center; gap: 10px; font-weight: 800; }
.theme-pill { width: 42px; height: 24px; padding: 3px; border-radius: 999px; background: var(--line-strong); transition: .2s ease; }
.theme-pill::after { content: ''; display: block; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform .2s ease; }
[data-theme="dark"] .theme-pill { background: var(--brand); }
[data-theme="dark"] .theme-pill::after { transform: translateX(18px); }

.request-modal {
    position: fixed; z-index: 410; left: 50%; top: 50%; width: min(560px, calc(100% - 28px));
    border: 1px solid var(--line); border-radius: 22px; background: var(--surface); box-shadow: 0 32px 90px rgba(0,0,0,.35);
    transform: translate(-50%,-46%) scale(.96); opacity: 0; visibility: hidden; transition: .24s ease; overflow: hidden;
}
.request-modal.open { transform: translate(-50%,-50%) scale(1); opacity: 1; visibility: visible; }
.modal-head { padding: 20px 22px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.modal-title { display: flex; align-items: center; gap: 10px; font-family: var(--serif); font-size: 1.45rem; font-weight: 700; }
.modal-title i { color: var(--brand); }
.modal-body { padding: 24px; }
.modal-body > p { margin: 0 0 18px; color: var(--ink-soft); }
.request-input { width: 100%; height: 52px; padding: 0 15px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-soft); color: var(--ink); }
.request-input:focus { border-color: var(--brand); background: var(--surface); outline: none; box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 12%, transparent); }
.request-submit { width: 100%; margin-top: 12px; }
.request-result { display: none; margin-top: 14px; padding: 12px 14px; border-radius: 10px; font-size: .86rem; font-weight: 700; }
.request-result.success { display: block; color: var(--green); background: color-mix(in srgb, var(--green) 10%, var(--surface)); border: 1px solid color-mix(in srgb, var(--green) 35%, var(--line)); }
.request-result.error { display: block; color: var(--red); background: color-mix(in srgb, var(--red) 10%, var(--surface)); border: 1px solid color-mix(in srgb, var(--red) 35%, var(--line)); }
.request-result.info { display: block; color: var(--brand); background: var(--brand-soft); border: 1px solid color-mix(in srgb, var(--brand) 35%, var(--line)); }
.request-result a { text-decoration: underline; }

.fab {
    position: fixed; z-index: 90; right: max(22px, env(safe-area-inset-right)); bottom: max(22px, env(safe-area-inset-bottom));
    width: 56px; height: 56px; display: grid; place-items: center; border: 0; border-radius: 17px;
    background: var(--brand); color: #fff; box-shadow: 0 14px 35px color-mix(in srgb, var(--brand) 34%, transparent); cursor: pointer; transition: .2s ease;
}
.fab:hover { transform: translateY(-3px) rotate(2deg); }

/* ----------------------------------------------------------------------------
   Footer
---------------------------------------------------------------------------- */
.site-footer { margin-top: 76px; border-top: 1px solid var(--line); background: var(--surface); }
.footer-main { width: min(1480px, calc(100% - 36px)); margin: 0 auto; padding: 48px 0 36px; display: grid; grid-template-columns: 1.45fr repeat(3, 1fr); gap: 50px; }
.footer-brand { display: flex; align-items: center; gap: 12px; }
.footer-brand img { width: 46px; height: 46px; object-fit: contain; }
.footer-brand strong { font-family: var(--serif); font-size: 1.55rem; }
.footer-about { max-width: 390px; margin: 14px 0 0; color: var(--ink-soft); font-size: .87rem; }
.footer-column h3 { margin: 0 0 13px; font-size: .75rem; text-transform: uppercase; letter-spacing: .11em; }
.footer-column a { display: block; width: fit-content; margin: 8px 0; color: var(--ink-soft); font-size: .84rem; }
.footer-column a:hover { color: var(--brand); }
.footer-bottom { border-top: 1px solid var(--line); }
.footer-bottom-inner { width: min(1480px, calc(100% - 36px)); min-height: 64px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 20px; color: var(--muted); font-size: .76rem; }

/* ----------------------------------------------------------------------------
   Bottom navigation (mobile) - the app-style bottom menu
---------------------------------------------------------------------------- */
.bottom-nav {
    position: fixed; z-index: 200; left: 0; right: 0; bottom: 0;
    display: none;
    border-top: 1px solid color-mix(in srgb, var(--line) 82%, transparent);
    background: var(--surface-elevated);
    backdrop-filter: blur(18px) saturate(150%);
    -webkit-backdrop-filter: blur(18px) saturate(150%);
    padding-bottom: env(safe-area-inset-bottom);
}
.bottom-nav-inner { display: grid; grid-template-columns: repeat(5, 1fr); }
.bottom-nav-item {
    min-height: 58px; padding: 8px 4px 6px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
    border: 0; background: transparent; color: var(--muted); font-size: .62rem; font-weight: 800; letter-spacing: .02em; cursor: pointer;
}
.bottom-nav-item i { font-size: 1.08rem; }
.bottom-nav-item.active, .bottom-nav-item:hover { color: var(--brand); }
.bottom-nav-item.active i { transform: translateY(-1px); }

@media (max-width: 680px) {
    .bottom-nav { display: block; }
    body { padding-bottom: calc(66px + env(safe-area-inset-bottom)); }
    .fab { bottom: calc(78px + env(safe-area-inset-bottom)); }
    .site-footer { margin-bottom: 0; }
}

/* ----------------------------------------------------------------------------
   Responsive (shared parts)
---------------------------------------------------------------------------- */
@media (max-width: 1180px) {
    .header-inner { grid-template-columns: auto minmax(220px,1fr) auto; }
    .header-link span { display: none; }
    .categories-grid { grid-template-columns: repeat(3, minmax(0,1fr)); }
}
@media (max-width: 960px) {
    :root { --header-h: 68px; }
    .header-inner { width: min(100% - 24px, 1480px); grid-template-columns: auto 1fr auto; gap: 12px; }
    .brand-tag, .header-search, .header-link { display: none; }
    .brand-mark { width: 40px; height: 40px; }
    .brand-name { font-size: 1.35rem; }
    .page-shell { width: min(100% - 24px, 1480px); }
    .page-shell--narrow { width: min(100% - 24px, 980px); }
    .footer-main { width: min(100% - 24px, 1480px); grid-template-columns: repeat(2,1fr); gap: 34px; }
    .footer-bottom-inner { width: min(100% - 24px, 1480px); }
}
@media (max-width: 680px) {
    .section-heading { align-items: start; }
    .section-action { display: none; }
    .categories-grid { grid-template-columns: repeat(2, minmax(0,1fr)); gap: 9px; }
    .category-card { min-height: 132px; padding: 15px; }
    .category-name { margin-top: 16px; }
    .footer-main { grid-template-columns: 1fr; }
    .footer-bottom-inner { padding: 18px 0; align-items: flex-start; flex-direction: column; }
    .page-intro { padding: 34px 0 4px; }
}
@media (max-width: 420px) {
    .brand-name { font-size: 1.2rem; }
    .avatar-button, .icon-button { width: 38px; height: 38px; }
    .header-actions { gap: 4px; }
    .category-card { min-height: 126px; }
    .category-icon { width: 36px; height: 36px; }
}
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
