/* ============================================================
   MORGEN THEME SYSTEM — CSS Custom Properties
   Default = Dark theme (current design)
   Overridden per-user via JS in common.js
   ============================================================ */

/* Flush html/body to viewport — eliminates any browser-default gap at the top */
html, body { margin: 0 !important; padding: 0 !important; border: none !important; }

/* Remove browser tap highlight and click outlines globally */
* { -webkit-tap-highlight-color: transparent; }
button:focus:not(:focus-visible),
a:focus:not(:focus-visible),
input:focus:not(:focus-visible),
textarea:focus:not(:focus-visible),
select:focus:not(:focus-visible) { outline: none; }

:root {
    /* Backgrounds */
    --bg-primary:    #0b0b0b;
    --bg-secondary:  #0f0f0f;
    --bg-card:       #111111;
    --bg-card-alt:   #151515;
    --bg-input:      #1a1a1a;
    --bg-hover:      #131313;
    --bg-border:     #1a1a1a;
    --bg-border-alt: #222222;

    /* Text */
    --text-primary:   #eeeeee;
    --text-secondary: #888888;
    --text-tertiary:  #555555;
    --text-muted:     #404040;

    /* Accent — the user's personal color */
    --accent:        #ffffff;
    --accent-dim:    rgba(255,255,255,0.08);
    --accent-text:   #000000;

    /* Semantic */
    --like-color:    #ff4d6d;
    --link-color:    #4d9fff;
    --danger:        #ff3b30;
    --success:       #34c759;

    /* UI shape */
    --radius-sm:   8px;
    --radius-md:   12px;
    --radius-lg:   16px;
    --radius-xl:   20px;
    --radius-full: 999px;

    /* Nav */
    --nav-bg:     #111111;
    --nav-border: #111111;
    --nav-icon-filter:        brightness(0) invert(0.4);
    --nav-icon-active-filter: brightness(0) invert(1);

    /* Story ring */
    --story-ring-active: conic-gradient(#fff, #ccc, #fff);
    --story-ring-seen:   conic-gradient(#383838, #2a2a2a, #383838);

    /* Font */
    --font-body: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;

    /* Supporter-only extras (no-op by default) */
    --profile-bg-image:   none;
    --profile-bg-color:   transparent;
    --profile-bg-opacity: 0;
    --name-effect:        none;
    --name-neon-color:    #ffffff;
    --name-grad-a:        #ff006e;
    --name-grad-b:        #7c3aed;
    --avatar-shape:       50%;      /* circle by default */
    --msg-bubble-out:     #1e1e1e;
    --msg-bubble-in:      #161616;
}

/* ── Name effects ───────────────────────────────────────────── */
h1.name-neon {
    text-shadow:
        0 0 6px var(--name-neon-color),
        0 0 18px var(--name-neon-color),
        0 0 36px var(--name-neon-color);
    color: var(--name-neon-color);
}

h1.name-gradient {
    background: linear-gradient(135deg, var(--name-grad-a), var(--name-grad-b));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* ── Preset: Midnight ────────────────────────────────────── */
[data-theme="midnight"] {
    --bg-primary:    #05050f;
    --bg-secondary:  #0a0a1a;
    --bg-card:       #0d0d20;
    --bg-card-alt:   #111128;
    --bg-input:      #151530;
    --bg-hover:      #121225;
    --bg-border:     #1a1a35;
    --bg-border-alt: #222244;
    --text-primary:  #e8e8ff;
    --text-secondary:#8888bb;
    --text-tertiary: #444466;
    --accent:        #7c7cff;
    --accent-dim:    rgba(124,124,255,0.1);
    --accent-text:   #ffffff;
    --nav-bg:        #0a0a1a;
    --nav-border:    #1a1a35;
    --story-ring-active: conic-gradient(#7c7cff, #bb88ff, #7c7cff);
    --story-ring-seen:   conic-gradient(#222244, #1a1a35, #222244);
}

/* ── Preset: Forest ──────────────────────────────────────── */
[data-theme="forest"] {
    --bg-primary:    #060e08;
    --bg-secondary:  #0a1a0c;
    --bg-card:       #0d1f10;
    --bg-card-alt:   #112614;
    --bg-input:      #162e18;
    --bg-hover:      #132018;
    --bg-border:     #1a2e1c;
    --bg-border-alt: #223a24;
    --text-primary:  #e0f0e0;
    --text-secondary:#7a9e7a;
    --text-tertiary: #3a5c3a;
    --accent:        #4caf50;
    --accent-dim:    rgba(76,175,80,0.1);
    --accent-text:   #ffffff;
    --nav-bg:        #0a1a0c;
    --nav-border:    #1a2e1c;
    --story-ring-active: conic-gradient(#4caf50, #81c784, #4caf50);
    --story-ring-seen:   conic-gradient(#1a2e1c, #223a24, #1a2e1c);
}

/* ── Preset: Sakura ──────────────────────────────────────── */
[data-theme="sakura"] {
    --bg-primary:    #0f080a;
    --bg-secondary:  #180c10;
    --bg-card:       #1e0f14;
    --bg-card-alt:   #251318;
    --bg-input:      #2a161c;
    --bg-hover:      #221014;
    --bg-border:     #2e1520;
    --bg-border-alt: #3a1c28;
    --text-primary:  #ffe8ee;
    --text-secondary:#cc88aa;
    --text-tertiary: #774455;
    --accent:        #ff6b9d;
    --accent-dim:    rgba(255,107,157,0.1);
    --accent-text:   #ffffff;
    --nav-bg:        #180c10;
    --nav-border:    #2e1520;
    --story-ring-active: conic-gradient(#ff6b9d, #ffaacc, #ff6b9d);
    --story-ring-seen:   conic-gradient(#2e1520, #3a1c28, #2e1520);
}

/* ── Preset: Light ───────────────────────────────────────── */
[data-theme="light"] {
    --bg-primary:    #f5f5f5;
    --bg-secondary:  #efefef;
    --bg-card:       #ffffff;
    --bg-card-alt:   #f8f8f8;
    --bg-input:      #eeeeee;
    --bg-hover:      #e8e8e8;
    --bg-border:     #e0e0e0;
    --bg-border-alt: #d0d0d0;
    --text-primary:  #111111;
    --text-secondary:#555555;
    --text-tertiary: #999999;
    --text-muted:    #bbbbbb;
    --accent:        #111111;
    --accent-dim:    rgba(0,0,0,0.07);
    --accent-text:   #ffffff;
    --nav-bg:        #ffffff;
    --nav-border:    #e0e0e0;
    --nav-icon-filter:        brightness(0) invert(0.6);
    --nav-icon-active-filter: brightness(0) invert(0);
    --story-ring-active: conic-gradient(#111, #555, #111);
    --story-ring-seen:   conic-gradient(#ddd, #ccc, #ddd);
    --msg-bubble-out: #e8e8e8;
    --msg-bubble-in:  #f0f0f0;
}

/* ── Preset: Cyberpunk ───────────────────────────────────── */
[data-theme="cyberpunk"] {
    --bg-primary:    #050508;
    --bg-secondary:  #08080e;
    --bg-card:       #0c0c14;
    --bg-card-alt:   #10101a;
    --bg-input:      #14141e;
    --bg-hover:      #111118;
    --bg-border:     #1a1a28;
    --bg-border-alt: #22223a;
    --text-primary:  #e0e0ff;
    --text-secondary:#8888cc;
    --text-tertiary: #333366;
    --accent:        #00f5ff;
    --accent-dim:    rgba(0,245,255,0.08);
    --accent-text:   #000000;
    --nav-bg:        #08080e;
    --nav-border:    #1a1a28;
    --like-color:    #ff006e;
    --story-ring-active: conic-gradient(#00f5ff, #ff006e, #00f5ff);
    --story-ring-seen:   conic-gradient(#1a1a28, #22223a, #1a1a28);
}

/* ══════════════════════════════════════════════════════
   GLOBAL NAV — floating pill style, applies to every page
   ══════════════════════════════════════════════════════ */

body { padding-bottom: calc(56px + env(safe-area-inset-bottom)) !important; }

.bottom-nav {
    position: fixed !important; bottom: 0 !important; left: 0 !important; right: 0 !important;
    width: 100% !important; height: calc(52px + env(safe-area-inset-bottom)) !important;
    padding: 0 0 env(safe-area-inset-bottom) !important;
    background: var(--nav-bg) !important;
    border: none !important; border-radius: 0 !important;
    display: flex !important; justify-content: space-around !important; align-items: center !important;
    z-index: 100 !important; box-sizing: border-box !important;
    transition: transform .3s cubic-bezier(0.4, 0, 0.2, 1) !important;
}
.bottom-nav button {
    background: none !important; border: none !important; cursor: pointer !important;
    padding: 0 16px !important; height: 52px !important;
    display: flex !important; align-items: center !important; justify-content: center !important;
}
.bottom-nav img {
    width: 23px !important; height: 23px !important;
    filter: var(--nav-icon-filter); transition: filter .15s ease;
}
@media (max-width: 767px) {
    .bottom-nav.nav-hidden {
        transform: translateY(calc(100% + env(safe-area-inset-bottom, 0px))) !important;
    }
}
.bottom-nav button.active img,
.bottom-nav button:hover img { filter: var(--nav-icon-active-filter) !important; }
.nav-badge-wrap { position: relative; display: inline-flex; }
.nav-badge {
    position: absolute; top: -3px; right: -3px;
    background: var(--danger); color: #fff;
    font-size: 9px; font-weight: 700; min-width: 14px; height: 14px;
    border-radius: 7px; padding: 0 3px; display: flex; align-items: center;
    justify-content: center; border: 1.5px solid var(--nav-bg); line-height: 1;
}

/* ══════════════════════════════════════════════════════
   GLOBAL RESPONSIVE LAYOUT — affects all pages
   Bottom nav → side nav on desktop
   ══════════════════════════════════════════════════════ */

@media (min-width: 768px) {
    body {
        padding-bottom: 0 !important;
        padding-left: 72px !important;
    }
    .bottom-nav {
        bottom: auto !important; top: 0 !important;
        left: 0 !important; right: auto !important;
        width: 72px !important; height: 100vh !important;
        background: var(--nav-bg) !important;
        align-items: center !important;
        flex-direction: column !important;
        justify-content: flex-start !important;
        padding: 20px 0 !important;
        gap: 4px !important;
    }
    .bottom-nav button {
        width: 72px !important; height: 40px !important;
        display: flex !important; justify-content: center !important; padding: 9px 0 !important;
    }
}

/* Morgen logo at top of sidebar on desktop */
@media (min-width: 768px) {
    .bottom-nav::before {
        content: 'M';
        display: flex;
        align-items: center;
        justify-content: center;
        width: 72px;
        height: 40px;
        font-size: 20px;
        font-weight: 900;
        color: var(--text-primary);
        letter-spacing: -1px;
        margin-bottom: 12px;
        flex-shrink: 0;
    }
}

/* ══════════════════════════════════════════════════════
   REMOVE SEPARATOR LINES GLOBALLY — modern borderless UI
   ══════════════════════════════════════════════════════ */

/* Headers */
.header, .srv-header, .comm-header, .server-header, .cs-topbar,
.ae-header, .cp-header, .grp-header, .groups-header, .settings-header,
.id-header, .search-bar, .smp-header, .sheet-title,
.canal-header, .notif-header { border: none !important; }

/* Nav (already none but reinforce) */
.bottom-nav { border-top: none !important; }

/* Tab bars — keep active indicator, remove underline of the bar itself */
.channel-list, .channel-tabs, .tabs-bar, .profile-tabs-bar,
.groups-tabs, .admin-tabs, .ae-tabs, .id-tabs,
.topic-filter { border-bottom: none !important; }

/* List items */
.city-list-item, .group-list-card, .srv-row-item, .message-item,
.search-result, .group-item, .admin-post-row, .id-mini-post,
.event-card, .music-result-item { border-bottom: none !important; }

/* Section dividers */
.posts-section, .user-stats, .members-section,
.people-strip, .section-header, .poi-filter-bar,
.public-banner, .id-preview-band, .id-marks-banner,
.grp-banner-picker, .modal-header, .profile-modal-header,
.cp-actions-divider, .comments-header { border-bottom: none !important; border-top: none !important; }

/* Compose / input rows */
.compose-bar, .chat-input-row, .chat-footer, .comments-input-row,
.chat-input, .comments-list,
.chat-input-bar, .reply-bar, .push-banner,
.comments-modal-input-row { border-top: none !important; }

/* Card internals */
.srv-card-last-msg, .poi-card-rows { border-top: none !important; }

/* Sheets */
.invite-panel .sheet-title, .create-server-panel .sheet-title { border-bottom: none !important; }

/* Top-of-page rogue lines — some elements add border-top on their first child */
body > *:first-child,
.page > *:first-child { border-top: none !important; }

/* ══════════════════════════════════════════════════════
   SKELETON LOADERS
   ══════════════════════════════════════════════════════ */
@keyframes _sk-shimmer {
    0%   { background-position: -200% 0; }
    100% { background-position:  200% 0; }
}
.sk {
    background: linear-gradient(90deg, var(--bg-card) 25%, var(--bg-card-alt) 50%, var(--bg-card) 75%);
    background-size: 200% 100%;
    animation: _sk-shimmer 1.4s ease infinite;
    border-radius: 8px;
    display: block;
}

/* ══════════════════════════════════════════════════════
   TOAST NOTIFICATIONS
   ══════════════════════════════════════════════════════ */
.toast-wrap {
    position: fixed;
    bottom: calc(60px + env(safe-area-inset-bottom, 0px));
    left: 50%; transform: translateX(-50%);
    z-index: 9000;
    display: flex; flex-direction: column-reverse; gap: 8px;
    align-items: center; pointer-events: none;
}
.toast {
    padding: 10px 20px; border-radius: 22px;
    font-size: 13px; font-weight: 600; line-height: 1.3;
    white-space: nowrap; max-width: min(320px, 88vw);
    box-shadow: 0 4px 24px rgba(0,0,0,0.4);
    opacity: 0; transform: translateY(10px) scale(0.95);
    transition: opacity 0.22s, transform 0.22s;
    background: var(--bg-card-alt); color: var(--text-primary);
    border: 1px solid var(--bg-border-alt);
}
.toast.show { opacity: 1; transform: translateY(0) scale(1); }
.toast.success { background: rgba(20,83,45,0.95); color: #4ade80; border-color: rgba(74,222,128,0.25); }
.toast.error   { background: rgba(69,10,10,0.95);  color: #f87171; border-color: rgba(248,113,113,0.25); }

/* ══════════════════════════════════════════════════════
   PULL-TO-REFRESH INDICATOR
   ══════════════════════════════════════════════════════ */
.ptr-indicator {
    position: fixed; top: 64px; left: 50%;
    transform: translateX(-50%) translateY(-80px);
    width: 36px; height: 36px; border-radius: 50%;
    background: var(--bg-card); border: 1px solid var(--bg-border-alt);
    box-shadow: 0 2px 16px rgba(0,0,0,0.3);
    display: flex; align-items: center; justify-content: center;
    z-index: 28; transition: transform 0.28s cubic-bezier(0.34,1.56,0.64,1);
    color: var(--text-secondary); pointer-events: none;
}
.ptr-indicator.visible { transform: translateX(-50%) translateY(0); }
@keyframes _ptr-spin { to { transform: rotate(360deg); } }
.ptr-spinning { animation: _ptr-spin 0.7s linear infinite; }

/* ── Shared reel player (used by both /search and feed) ───────────────────── */
.reel-player {
    position: fixed; inset: 0; background: #000; z-index: 100;
    display: flex; align-items: center; justify-content: center;
}
.reel-player.hidden { display: none !important; }
.reel-player video { width: 100%; height: 100%; object-fit: cover; }
.reel-back-btn {
    position: absolute; top: 16px; left: 16px; z-index: 10;
    background: rgba(0,0,0,0.4); border: none; border-radius: 50%;
    width: 36px; height: 36px; display: flex; align-items: center; justify-content: center;
    color: #fff; cursor: pointer;
}
.reel-overlay {
    position: absolute; bottom: 0; left: 0; right: 0;
    padding: 20px 16px; background: linear-gradient(transparent, rgba(0,0,0,0.7));
    display: flex; align-items: flex-end; justify-content: space-between;
}
.reel-avatar { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; }
.reel-username { color: #fff; font-weight: 700; font-size: 14px; }
.reel-caption { color: rgba(255,255,255,0.8); font-size: 13px; margin-top: 2px; }
.reel-user-info { display: flex; align-items: center; gap: 10px; flex: 1; }
.reel-actions { display: flex; flex-direction: column; gap: 16px; align-items: center; }
.reel-action-btn {
    background: none; border: none; color: #fff; cursor: pointer;
    display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 12px;
}
