/*
    rhf_apexpedia - the page.

    Civilopedia-shaped and deliberately quiet: one dark neutral, light text, ONE accent (the
    server's cyan) for links and the selected row only. Teko for headings, Inter for reading.

    NUI rules from the old server, all of which bit once:
      - no backdrop-filter (renders as a black rectangle), no color-mix() (some CEF builds drop
        the whole declaration);
      - [hidden] must win over every author display rule;
      - box-sizing reset from day one.
*/

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

:root {
    --bg:       #0f1114;
    --panel:    #14171b;
    --panel-2:  #191d22;
    --line:     #252a30;
    --line-2:   #30363d;
    --text:     #e7e5e1;
    --text-2:   #c3c6ca;
    --muted:    #8d949c;
    --dim:      #646b73;
    --accent:   #3DD6FF;
    --accent-bg: rgba(61, 214, 255, 0.08);
    --accent-line: rgba(61, 214, 255, 0.45);

    --head: 'Teko', 'Inter', sans-serif;
    --body: 'Inter', 'Segoe UI', Arial, sans-serif;
}

html, body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: transparent;
    font-family: var(--body);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
}

button { font-family: inherit; cursor: pointer; }
kbd {
    display: inline-block;
    min-width: 1.6em;
    padding: 0 0.4em;
    border: 1px solid var(--line-2);
    border-bottom-width: 2px;
    border-radius: 4px;
    background: var(--panel-2);
    color: var(--text);
    font-family: var(--body);
    font-size: 0.78em;
    font-weight: 600;
    line-height: 1.6;
    text-align: center;
    vertical-align: 0.05em;
}

/* ── the frame ─────────────────────────────────────────────────────────────── */

.book {
    position: fixed;
    inset: 3vh 3vw;
    display: flex;
    flex-direction: column;
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: 10px;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.65);
    overflow: hidden;
    animation: bookIn 160ms ease-out;
}
@keyframes bookIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.top {
    display: flex;
    align-items: center;
    gap: 18px;
    padding: 12px 18px;
    background: var(--panel);
    border-bottom: 1px solid var(--line);
    flex: 0 0 auto;
}

.brand { display: flex; align-items: baseline; gap: 12px; min-width: 300px; }
.brand__icon { color: var(--accent); font-size: 18px; align-self: center; }
.brand__name {
    font-family: var(--head);
    font-size: 30px;
    font-weight: 500;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    line-height: 1;
    color: var(--text);
}
.brand__sub { font-size: 13px; color: var(--muted); }

.nav { display: flex; gap: 6px; }
.nav__btn {
    width: 36px;
    height: 36px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--panel-2);
    color: var(--text-2);
    font-size: 14px;
}
.nav__btn:hover:not(:disabled) { border-color: var(--line-2); color: var(--text); }
.nav__btn:disabled { opacity: 0.35; cursor: default; }

.search {
    position: relative;
    flex: 1 1 auto;
    max-width: 560px;
    display: flex;
    align-items: center;
}
.search__icon { position: absolute; left: 13px; color: var(--dim); font-size: 14px; pointer-events: none; }
.search__input {
    width: 100%;
    height: 38px;
    padding: 0 36px 0 38px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--bg);
    color: var(--text);
    font-family: var(--body);
    font-size: 15px;
    outline: none;
}
.search__input::placeholder { color: var(--dim); }
.search__input:focus { border-color: var(--accent-line); }
.search__clear {
    position: absolute;
    right: 6px;
    width: 26px;
    height: 26px;
    border: 0;
    border-radius: 4px;
    background: transparent;
    color: var(--muted);
}
.search__clear:hover { color: var(--text); }

.close {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 8px;
    height: 36px;
    padding: 0 12px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--panel-2);
    color: var(--text-2);
    font-size: 13px;
}
.close:hover { color: var(--text); border-color: var(--line-2); }

.body { flex: 1 1 auto; display: flex; min-height: 0; }

/* ── the left column: categories, or search results ───────────────────────── */

.side {
    flex: 0 0 300px;
    overflow-y: auto;
    background: var(--panel);
    border-right: 1px solid var(--line);
    padding: 10px 0 24px;
}

.cat__head {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 9px 18px;
    border: 0;
    background: transparent;
    color: var(--text-2);
    font-family: var(--head);
    font-size: 21px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    text-align: left;
    line-height: 1.1;
}
.cat__head:hover { color: var(--text); background: var(--panel-2); }
.cat__icon { width: 18px; font-size: 14px; color: var(--muted); text-align: center; }
.cat__name { flex: 1; padding-top: 3px; }
.cat__count { font-family: var(--body); font-size: 11px; color: var(--dim); letter-spacing: 0; }
.cat__chev { font-size: 10px; color: var(--dim); transition: transform 120ms; }
.cat.is-open .cat__chev { transform: rotate(90deg); }
.cat.is-open > .cat__head { color: var(--text); }
.cat.is-open .cat__icon { color: var(--accent); }

.cat__body { padding: 2px 0 10px; }
.grp__head {
    padding: 10px 18px 4px 48px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--dim);
}
.ent {
    display: block;
    width: 100%;
    padding: 5px 18px 5px 48px;
    border: 0;
    border-left: 2px solid transparent;
    background: transparent;
    color: var(--text-2);
    font-size: 14px;
    text-align: left;
    line-height: 1.35;
}
.ent:hover { background: var(--panel-2); color: var(--text); }
.ent.is-active { border-left-color: var(--accent); background: var(--accent-bg); color: var(--text); }
.ent--dim { color: var(--dim); }

.results__count { padding: 4px 18px 10px; font-size: 12px; color: var(--muted); }
.res {
    display: block;
    width: 100%;
    padding: 8px 18px;
    border: 0;
    border-left: 2px solid transparent;
    background: transparent;
    color: var(--text);
    text-align: left;
}
.res:hover, .res.is-sel { background: var(--panel-2); border-left-color: var(--accent); }
.res__title { font-size: 14.5px; font-weight: 600; }
.res__meta { margin-top: 1px; font-size: 11.5px; color: var(--muted); }
.res__snip { margin-top: 3px; font-size: 12.5px; line-height: 1.45; color: var(--text-2); }
.res mark { background: transparent; color: var(--accent); font-weight: 600; }
.results__none { padding: 18px; color: var(--muted); font-size: 14px; }

/* ── the middle: the article ──────────────────────────────────────────────── */

.main { flex: 1 1 auto; overflow-y: auto; min-width: 0; }

.page { display: flex; gap: 40px; padding: 34px 44px 60px; }
.art { flex: 1 1 auto; min-width: 0; max-width: 780px; }

.art__crumb { font-size: 12px; color: var(--muted); letter-spacing: 0.02em; }
.art__crumb .lnk { color: var(--muted); }
.art__title {
    margin: 4px 0 0;
    font-family: var(--head);
    font-size: 52px;
    font-weight: 500;
    line-height: 0.95;
    letter-spacing: 0.02em;
    color: var(--text);
}
.art__sub { margin-top: 6px; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; }
.art__lead {
    margin: 22px 0 6px;
    font-size: 17px;
    line-height: 1.65;
    color: var(--text);
}

.sec { margin-top: 30px; }
.sec h2 {
    margin: 0 0 10px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--line);
    font-family: var(--head);
    font-size: 25px;
    font-weight: 500;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-2);
    line-height: 1.1;
}
.sec p, .sec li { font-size: 15.5px; line-height: 1.7; color: var(--text-2); }
.sec p { margin: 0 0 12px; }
.sec ul, .sec ol { margin: 0 0 12px; padding-left: 22px; }
.sec li { margin: 3px 0; }
.sec li::marker { color: var(--dim); }
.sec strong, .art__lead strong { color: var(--text); font-weight: 600; }

.tbl { width: 100%; border-collapse: collapse; margin: 4px 0 12px; font-size: 14.5px; }
.tbl th {
    padding: 8px 10px;
    border-bottom: 1px solid var(--line-2);
    color: var(--muted);
    font-size: 11.5px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    text-align: left;
}
.tbl td { padding: 8px 10px; border-bottom: 1px solid var(--line); color: var(--text-2); vertical-align: top; line-height: 1.45; }
.tbl tr:last-child td { border-bottom: 0; }

.lnk { color: var(--accent); text-decoration: none; cursor: pointer; }
.lnk:hover { text-decoration: underline; text-underline-offset: 3px; }
.li { width: 1.25em; height: 1.25em; object-fit: contain; vertical-align: -0.28em; margin-right: 5px; }
.note { margin-top: 36px; font-size: 12px; color: var(--dim); }

/* ── the right: the info box ──────────────────────────────────────────────── */

.info {
    flex: 0 0 320px;
    align-self: flex-start;
    position: sticky;
    top: 0;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    overflow: hidden;
}
.info__pic {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 170px;
    background: var(--panel-2);
    border-bottom: 1px solid var(--line);
}
.info__pic img { max-width: 62%; max-height: 130px; object-fit: contain; }
.info__pic i { font-size: 56px; color: var(--dim); }
.info__name {
    padding: 12px 16px 2px;
    font-family: var(--head);
    font-size: 24px;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    line-height: 1.1;
}
.info__type { padding: 0 16px 10px; font-size: 12px; color: var(--muted); }
.facts { margin: 0; padding: 4px 16px 10px; }
.fact { display: flex; gap: 12px; padding: 7px 0; border-top: 1px solid var(--line); font-size: 13.5px; line-height: 1.45; }
.fact dt { flex: 0 0 42%; color: var(--muted); }
.fact dd { flex: 1 1 auto; margin: 0; color: var(--text); min-width: 0; overflow-wrap: anywhere; }
.info__block { padding: 10px 16px 14px; border-top: 1px solid var(--line); }
.info__block h3 {
    margin: 0 0 8px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--dim);
}
.links { display: flex; flex-direction: column; gap: 5px; font-size: 13.5px; }
.links .lnk { display: inline-flex; align-items: center; }
.place { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 5px 0; font-size: 13.5px; color: var(--text-2); }
.place__d { color: var(--dim); font-size: 12px; margin-left: 6px; }
.place__btn {
    flex: 0 0 auto;
    padding: 3px 9px;
    border: 1px solid var(--line-2);
    border-radius: 4px;
    background: transparent;
    color: var(--text-2);
    font-size: 11.5px;
}
.place__btn:hover { border-color: var(--accent-line); color: var(--accent); }
.place__btn.is-done { color: var(--accent); border-color: var(--accent-line); }

/* ── home and category pages ──────────────────────────────────────────────── */

.home { padding: 40px 44px 60px; max-width: 1180px; }
.home__title { margin: 0; font-family: var(--head); font-size: 64px; font-weight: 500; letter-spacing: 0.04em; text-transform: uppercase; line-height: 0.9; }
.home__lead { margin: 14px 0 0; max-width: 760px; font-size: 17px; line-height: 1.65; color: var(--text-2); }
.home h2 {
    margin: 36px 0 12px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--line);
    font-family: var(--head);
    font-size: 25px;
    font-weight: 500;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-2);
}
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px; }
.tile {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    color: var(--text);
    text-align: left;
}
.tile:hover { border-color: var(--line-2); background: var(--panel-2); }
.tile i { width: 22px; font-size: 18px; color: var(--muted); text-align: center; }
.tile__name { font-family: var(--head); font-size: 21px; letter-spacing: 0.04em; text-transform: uppercase; line-height: 1; padding-top: 3px; }
.tile__count { font-size: 11.5px; color: var(--dim); }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 8px; }
.card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--panel);
    color: var(--text-2);
    font-size: 14px;
    text-align: left;
    line-height: 1.3;
}
.card:hover { border-color: var(--line-2); color: var(--text); }
.card img { width: 28px; height: 28px; object-fit: contain; flex: 0 0 auto; }
.card i { width: 28px; text-align: center; color: var(--dim); flex: 0 0 auto; }
.card__sub { display: block; font-size: 11.5px; color: var(--dim); margin-top: 1px; }

/* ── loading ──────────────────────────────────────────────────────────────── */

.loading {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    background: var(--bg);
}
.loading__icon { font-size: 40px; color: var(--accent); }
.loading__text { font-size: 15px; color: var(--text-2); }
.loading__bar { width: 280px; height: 3px; background: var(--line); border-radius: 2px; overflow: hidden; }
.loading__fill { width: 0; height: 100%; background: var(--accent); transition: width 200ms; }

/* ── the graduation popup ─────────────────────────────────────────────────── */

.intro {
    position: fixed;
    left: 50%;
    bottom: 13vh;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 22px;
    width: 560px;
    padding: 22px 26px;
    background: #121418;
    border: 1px solid var(--line-2);
    border-radius: 10px;
    box-shadow: 0 18px 60px rgba(0, 0, 0, 0.6);
    opacity: 0;
    transition: opacity 400ms ease, transform 400ms ease;
}
.intro.is-in { opacity: 1; transform: translateX(-50%) translateY(-6px); }
.intro__book {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 86px;
    height: 104px;
    border: 1px solid var(--accent-line);
    border-radius: 4px 10px 10px 4px;
    background: #171b20;
    color: var(--accent);
    font-size: 40px;
    box-shadow: inset 6px 0 0 rgba(61, 214, 255, 0.25);
}
.intro__kicker { font-size: 12px; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; color: var(--accent); }
.intro__title { font-family: var(--head); font-size: 46px; letter-spacing: 0.05em; text-transform: uppercase; line-height: 0.95; margin-top: 4px; }
.intro__text { margin-top: 6px; font-size: 14px; line-height: 1.5; color: var(--text-2); }
.intro__key { margin-top: 10px; font-size: 14px; color: var(--text); }

/* ── scrollbars ───────────────────────────────────────────────────────────── */

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 5px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background-color: #3c434b; }

@media (max-width: 1500px) {
    .page { gap: 28px; padding: 28px 30px 50px; }
    .info { flex-basis: 290px; }
    .side { flex-basis: 270px; }
    .brand__sub { display: none; }
    .brand { min-width: 0; }
}
