/* ============================================================================
   Outpost Archive — sci-fi themed viewer for outpost2.net's Discord history.

   THEME SYSTEM
   ------------
   Every colour is a CSS custom property. The default palette lives in :root;
   each [data-theme="…"] block below only overrides the variables. app.js sets
   <html data-theme> and persists the choice, so adding a theme = adding one
   block here + one <option> in config.php's THEMES.
   Themes are flavoured after Outpost 2 lore: the rival colonies Plymouth &
   Eden, the Blight plague, and an amber CRT Terminal.
   ============================================================================ */

/* --- Plymouth: survivalist colony, amber / industrial (default) --- */
:root {
    --bg:        #0d0b08;
    --bg-grid:   #1a140b;
    --panel:     #16120c;
    --panel-2:   #1f1810;
    --border:    #3a2c18;
    --text:      #f0e6d6;
    --muted:     #9a8b73;
    --accent:    #ff9a3c;
    --accent-dim:#b96e22;
    --ok:        #7bd06b;
    --danger:    #e6553c;
    --font-ui:   system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --font-mono: "Cascadia Code", "SF Mono", Consolas, "DejaVu Sans Mono", monospace;
}

/* --- Eden: science colony, teal / clean --- */
[data-theme="eden"] {
    --bg:        #060d0e;
    --bg-grid:   #0c1c1d;
    --panel:     #0c1618;
    --panel-2:   #102220;
    --border:    #1c3a38;
    --text:      #e0f5f2;
    --muted:     #6f9a95;
    --accent:    #35e0c8;
    --accent-dim:#1f9a8a;
    --ok:        #6be0a0;
    --danger:    #e6737d;
}

/* --- Blight: the creeping plague, toxic green on black --- */
[data-theme="blight"] {
    --bg:        #050705;
    --bg-grid:   #0f160c;
    --panel:     #0b100a;
    --panel-2:   #101810;
    --border:    #22371b;
    --text:      #d8f0cd;
    --muted:     #6f8a63;
    --accent:    #8fe83f;
    --accent-dim:#5aa020;
    --ok:        #b6f06b;
    --danger:    #e08a3a;
}

/* --- Outpost.net: outpost2.net's ACTUAL skin — values lifted verbatim from the site's
       stylesheet: black starfield tile, #642121→#0c0c0c header gradient, .content_float
       cards (#4f4f4f border, 10px radius, maroon 20px lip → #282828 body), #ccc body
       text, #f0f0f0 headings, #fdfdfd links, #171a1a heading band, Open Sans.
       The full site chrome (logo/nav bar + tagline band + card layout) is applied by
       the [data-theme="opnet"] structural block at the end of this file. --- */
[data-theme="opnet"] {
    --bg:        #000000;
    --bg-grid:   #642121;
    --panel:     #1f1f1f;   /* row hover on the #282828 card body */
    --panel-2:   #171a1a;   /* the site's heading-band base tone */
    --border:    #4f4f4f;
    --text:      #cccccc;   /* the site's body/table text */
    --muted:     #8f9aa4;   /* between the site's #7c7c7c and footer #7890a1 */
    --accent:    #addcfe;   /* the site's pale-blue feature headings */
    --accent-dim:#176eb0;   /* the site's link blue */
    --ok:        #7bd06b;
    --danger:    #d9524a;
    --font-ui:   "Open Sans", system-ui, "Segoe UI", Roboto, sans-serif;
}

/* --- Terminal: amber CRT monochrome, retro computer --- */
[data-theme="terminal"] {
    --bg:        #090600;
    --bg-grid:   #1a1200;
    --panel:     #120d02;
    --panel-2:   #191203;
    --border:    #3a2a06;
    --text:      #ffbe4a;
    --muted:     #a8791f;
    --accent:    #ffd27a;
    --accent-dim:#b8860b;
    --ok:        #ffd27a;
    --danger:    #ff7a3a;
    --font-ui:   var(--font-mono);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
    margin: 0;
    /* Top-down colour wash over the base — mirrors outpost2.net's skin gradient
       (maroon fading into charcoal). Each theme tints it via --bg-grid. */
    background:
        linear-gradient(180deg, color-mix(in srgb, var(--bg-grid) 92%, transparent) 0%, transparent 58%),
        radial-gradient(150% 62% at 50% 0%, color-mix(in srgb, var(--bg-grid) 55%, transparent), transparent 72%),
        var(--bg);
    background-attachment: fixed;
    color: var(--text);
    font-family: var(--font-ui);
    line-height: 1.5;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Faint CRT scanlines + vignette laid over everything. */
.scanlines {
    position: fixed; inset: 0; z-index: 100; pointer-events: none;
    background: repeating-linear-gradient(
        to bottom, rgba(0,0,0,0) 0, rgba(0,0,0,0) 2px, rgba(0,0,0,.16) 3px);
    mix-blend-mode: multiply; opacity: .5;
}

.muted { color: var(--muted); }
.pad { padding: 12px 16px; }

/* ---------- Top bar ---------- */
.topbar {
    display: flex; align-items: center; justify-content: space-between; gap: 16px;
    padding: 14px 22px;
    /* Metallic banner: a tint of the theme's wash colour over the panel, with a blue
       accent underline — reads like outpost2.net's header strip. */
    background: linear-gradient(180deg, color-mix(in srgb, var(--bg-grid) 45%, var(--panel-2)) 0%, var(--panel) 100%);
    border-bottom: 2px solid var(--accent-dim);
    box-shadow: inset 0 1px 0 rgba(255,255,255,.06), 0 2px 0 rgba(0,0,0,.35), 0 10px 26px rgba(0,0,0,.5);
}
.brand { display: flex; align-items: center; gap: 14px; }
.brand-logo { height: 40px; width: 40px; filter: drop-shadow(0 0 6px var(--accent-dim)); }
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-title {
    font-family: var(--font-mono); font-weight: 700; font-size: 1.25rem;
    letter-spacing: .12em; color: var(--text);
    text-shadow: 0 0 12px color-mix(in srgb, var(--accent) 45%, transparent);
}
.brand-sep { color: var(--accent); margin: 0 .1em; }
.brand-tag { font-size: .72rem; letter-spacing: .18em; text-transform: uppercase; color: var(--muted); }

.topbar-right { display: flex; align-items: center; gap: 18px; }
.channel-title {
    font-family: var(--font-mono); color: var(--accent); font-size: .9rem;
    letter-spacing: .06em; max-width: 40vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.theme-switch { display: flex; align-items: center; gap: 8px; }
.theme-switch-label { font-family: var(--font-mono); font-size: .68rem; letter-spacing: .2em; color: var(--muted); }
#theme {
    background: var(--panel-2); color: var(--text);
    border: 1px solid var(--border); border-radius: 4px;
    padding: 6px 10px; font-family: var(--font-mono); font-size: .82rem; cursor: pointer;
}
#theme:hover { border-color: var(--accent); }

/* ---------- Layout ----------
   The page is a flex column (header / layout / footer). The layout fills the middle and
   only .messages scrolls — so the footer stays pinned to the bottom. That needs min-height:0
   on every nested flex/grid child (defaults to auto, which would let content push past the
   viewport and slide under the footer). */
.layout { flex: 1 1 auto; display: grid; grid-template-columns: 300px 1fr; grid-template-rows: minmax(0, 1fr); min-height: 0; }

/* ---------- Sidebar ---------- */
.sidebar {
    border-right: 1px solid var(--border);
    background: linear-gradient(180deg, var(--panel), transparent);
    display: flex; flex-direction: column; min-height: 0;
}
.sidebar-head {
    font-family: var(--font-mono); font-size: .72rem; letter-spacing: .24em; color: var(--muted);
    padding: 14px 16px 8px; border-bottom: 1px solid var(--border);
}
.channel-list { overflow-y: auto; padding: 8px 0; }
.chan-guild {
    font-family: var(--font-mono); font-size: .68rem; letter-spacing: .16em; text-transform: uppercase;
    color: var(--accent-dim); padding: 14px 16px 6px;
}
.chan {
    display: flex; align-items: baseline; gap: 8px; justify-content: space-between;
    padding: 7px 16px 7px 22px; cursor: pointer; border-left: 3px solid transparent;
    color: var(--text); text-decoration: none;
}
.chan:hover { background: var(--panel-2); }
.chan.active {
    background: color-mix(in srgb, var(--accent) 12%, transparent);
    border-left-color: var(--accent);
}
.chan-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chan-name .hash { color: var(--accent-dim); margin-right: 2px; }
.chan.active .chan-name .hash { color: var(--accent); }
.chan-count { font-family: var(--font-mono); font-size: .72rem; color: var(--muted); flex: none; }
.chan-live { color: var(--ok); }

/* ---------- Messages ---------- */
.viewer { min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.messages { overflow-y: auto; padding: 16px 22px 40px; flex: 1 1 auto; min-height: 0; }

.empty { text-align: center; margin-top: 12vh; }
.empty-title {
    font-family: var(--font-mono); letter-spacing: .2em; color: var(--accent);
    text-shadow: 0 0 14px color-mix(in srgb, var(--accent) 40%, transparent);
}

.day-sep {
    display: flex; align-items: center; gap: 12px; margin: 18px 0 8px;
    font-family: var(--font-mono); font-size: .7rem; letter-spacing: .16em; color: var(--muted);
}
.day-sep::before, .day-sep::after { content: ""; height: 1px; background: var(--border); flex: 1; }

.msg {
    display: grid; grid-template-columns: 150px 60px 1fr; gap: 12px; align-items: baseline;
    padding: 5px 10px; border-radius: 5px;
}
.msg:hover { background: var(--panel); }
.msg-meta { display: flex; flex-direction: column; }
.msg-author {
    color: var(--accent); font-weight: 600; font-size: .9rem;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.msg-time { color: var(--muted); font-size: .72rem; font-variant-numeric: tabular-nums; font-family: var(--font-mono); }
.msg-kind {
    font-family: var(--font-mono); font-size: .62rem; text-transform: uppercase; letter-spacing: .06em;
    color: var(--muted); align-self: center;
}
.msg-content { white-space: pre-wrap; word-break: break-word; }
.msg-content .edited { color: var(--muted); font-size: .74rem; }

.msg-atts { margin-top: 6px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.att-img {
    max-width: 340px; max-height: 260px; border-radius: 6px;
    border: 1px solid var(--border); display: block; background: var(--panel-2);
}
a.att-img-link:hover .att-img { border-color: var(--accent); }
.att-file {
    display: inline-block; padding: 5px 10px; background: var(--panel-2);
    border: 1px solid var(--border); border-radius: 6px; font-size: .84rem;
    color: var(--text); text-decoration: none;
}
a.att-file:hover { border-color: var(--accent); }

/* ---------- Fault / footer ---------- */
.fault { flex: 1; display: grid; place-items: center; padding: 40px; }
.fault-box {
    border: 1px solid var(--danger); border-radius: 8px; padding: 22px 28px; text-align: center;
    background: color-mix(in srgb, var(--danger) 12%, transparent); max-width: 620px;
}
.fault-code { font-family: var(--font-mono); letter-spacing: .16em; color: var(--danger); margin-top: 0; }

.footer {
    padding: 10px 22px; border-top: 1px solid var(--border);
    font-family: var(--font-mono); font-size: .72rem; letter-spacing: .04em;
    background: var(--panel);
}

/* ---------- Scrollbars ---------- */
.channel-list::-webkit-scrollbar, .messages::-webkit-scrollbar { width: 10px; }
.channel-list::-webkit-scrollbar-thumb, .messages::-webkit-scrollbar-thumb {
    background: var(--border); border-radius: 6px;
}
.channel-list::-webkit-scrollbar-thumb:hover, .messages::-webkit-scrollbar-thumb:hover { background: var(--accent-dim); }

/* ---------- Lightbox ---------- */
.lb { position: fixed; inset: 0; z-index: 1000; display: none; align-items: center; justify-content: center; background: rgba(0,0,0,.9); }
.lb.open { display: flex; }
.lb-fig { margin: 0; max-width: 94vw; max-height: 94vh; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.lb-img { max-width: 94vw; max-height: 86vh; object-fit: contain; border-radius: 6px; border: 1px solid var(--border); box-shadow: 0 10px 50px rgba(0,0,0,.75); background: var(--panel); }
.lb-cap { color: var(--muted); font-family: var(--font-mono); font-size: .82rem; letter-spacing: .04em; text-align: center; max-width: 90vw; }
.lb-close, .lb-nav { position: fixed; background: color-mix(in srgb, var(--panel-2) 80%, transparent); color: var(--text); border: 1px solid var(--border); cursor: pointer; border-radius: 8px; padding: 0; }
.lb-close:hover, .lb-nav:hover { border-color: var(--accent); color: var(--accent); }
.lb-close { top: 14px; right: 20px; width: 40px; height: 40px; font-size: 1.5rem; line-height: 1; }
.lb-nav { top: 50%; transform: translateY(-50%); width: 46px; height: 66px; font-size: 2rem; line-height: 1; }
.lb-prev { left: 16px; } .lb-next { right: 16px; }

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
    .layout { grid-template-columns: 1fr; }
    .sidebar { border-right: none; border-bottom: 1px solid var(--border); max-height: 34vh; }
    .channel-title { display: none; }
    .msg { grid-template-columns: 1fr; gap: 2px; }
    .msg-meta { flex-direction: row; gap: 10px; align-items: baseline; }
    .msg-kind { display: none; }
}

/* ============================================================================
   OUTPOST.NET SITE CHROME — applied only under [data-theme="opnet"].
   Replicates outpost2.net's skin verbatim (its stylesheet + bundled images in
   assets/op2/) so the archive reads as just another section of the site:
     • black starfield body (op2skin_background.png tile)
     • logo/nav header: #642121→#0c0c0c gradient, 2px #4a4a4a rule, white 14px
       links 60px apart, gold text-shadow on hover, bold on the selected item
     • "Extinction is not an option" band (#171a1a + heading_bg.png texture)
     • content as .content_float cards: 10px radius, #4f4f4f border, maroon
       20px lip fading to a #282828 body
   The .site-head markup exists on the page for every theme; it only displays
   here. All other themes are untouched.
   ============================================================================ */

/* hidden unless the opnet theme is active */
.site-head { display: none; }

/* One knob for the chrome's content width. The real site is a fixed 960px column; we go
   wider so the chat pane gets room, keeping nav/cards/footer aligned to the same width. */
[data-theme="opnet"] { --site-w: 1600px; }

[data-theme="opnet"] body {
    background: #000 url(op2/op2skin_background.png);
}
[data-theme="opnet"] .scanlines { display: none; }   /* the real site has no CRT overlay */

/* --- logo + nav bar (the site's #header) --- */
[data-theme="opnet"] .site-head {
    display: block;
    background: linear-gradient(to bottom, #642121 0%, #0c0c0c 100%);
    border-bottom: 2px solid #4a4a4a;
}
.site-nav-inner {
    max-width: var(--site-w, 990px); margin: 0 auto; padding: 14px 10px;
    display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px;
}
.site-logo img { height: 30px; display: block; }
.site-nav { display: flex; align-items: center; list-style: none; margin: 0; padding: 0; flex-wrap: wrap; }
.site-nav li { margin: 0 0 0 60px; }
.site-nav li:first-child { margin-left: 0; }
.site-nav li a { color: #fdfdfd; font-size: 14px; line-height: 30px; text-decoration: none; }
.site-nav li a:hover { text-shadow: 1px 1px 1px #f2e38f; }
.site-nav li.selected a { font-weight: bold; }

/* --- the tagline band (the site's highlight strip); the topbar becomes it --- */
[data-theme="opnet"] .topbar {
    background: #171a1a url(op2/heading_bg.png) repeat-x left top;
    border-bottom: 2px solid #4a4a4a;
    box-shadow: none;
    min-height: 62px;
}
[data-theme="opnet"] .brand { display: none; }
[data-theme="opnet"] .topbar::before {
    content: "Extinction is not an option";
    color: #7c7c7c; font-size: 26px; font-style: italic;
    text-shadow: 3px 3px 6px #121413;
    font-family: var(--font-ui);
}
[data-theme="opnet"] .channel-title { font-family: var(--font-ui); font-style: italic; }

/* --- content as centred .content_float cards --- */
[data-theme="opnet"] .layout {
    max-width: var(--site-w, 990px); width: 100%; margin: 15px auto 0; padding: 0 10px;
    grid-template-columns: 250px 1fr; gap: 15px;
}
[data-theme="opnet"] .sidebar,
[data-theme="opnet"] .viewer {
    border: 1px solid #4f4f4f;
    border-radius: 10px;
    background: linear-gradient(to bottom, #642121 0px, #0c0c0c 20px, #282828 21px);
    overflow: hidden;
}
[data-theme="opnet"] .sidebar-head {
    font-family: var(--font-ui); font-style: italic; font-weight: bold;
    font-size: 15px; letter-spacing: .04em; color: #f0f0f0;
    border-bottom: 1px solid #4f4f4f;
}
[data-theme="opnet"] .msg-author { color: #fdfdfd; }        /* site links are near-white */
[data-theme="opnet"] .msg-author:hover { color: #ddddff; }
[data-theme="opnet"] .chan-guild { color: #addcfe; }
[data-theme="opnet"] .empty-title {
    font-family: var(--font-ui); font-style: italic; letter-spacing: normal;
    color: #f0f0f0; font-size: 25px; text-shadow: none;
}

/* --- footer as the site's rounded translucent footer_float --- */
[data-theme="opnet"] .footer {
    max-width: var(--site-w, 990px); width: calc(100% - 20px); margin: 0 auto 12px;
    background: rgba(0, 0, 0, 0.5); border-top: none; border-radius: 15px;
    color: #7890a1; text-align: center;
    font-family: var(--font-ui); font-size: 12px; letter-spacing: normal;
}
[data-theme="opnet"] .footer .muted { color: #7890a1; }
