/* ── Navbar ─────────────────────────────────────────────────────────────── */

#main-nav {
    position: fixed;
    inset: 0 0 auto;
    z-index: 999;
    height: var(--nav-h);
    background: url("/assets/top-bg.gif");
    border-bottom: 2px solid #000;
    box-shadow: 0 3px 10px #333;
    opacity: .85;
}

#main-nav menu {
    display: flex;
    align-items: center;
    gap: 2px;
    max-width: 1000px;
    height: var(--nav-h);
    margin: 0 auto;
    padding-right: .75rem;
    list-style: none;
    font: 700 16px/1 sans-serif;
}

#main-nav menu a,
.sidebar-open-btn button {
    display: grid;
    place-items: center;
    height: var(--nav-h);
    padding-inline: 13px;
    color: #e0d0d0;
    font: inherit;
    text-decoration: none;
    text-shadow: 2px 2px 4px #000;
    background: none;
    border: none;
    cursor: pointer;
}

#main-nav menu a:hover,
#main-nav menu a[aria-current],
.sidebar-open-btn button:hover { color: #fff; }

#main-nav menu a:active { color: #d0d0e0; }

#main-nav menu a[aria-current] {
    border-bottom: 2px solid var(--pico-primary, #e44b00);
}

/* ── Banner ─────────────────────────────────────────────────────────────── */

.banner {
    position: relative;
    margin-bottom: 2em;
}

.banner img {
    width: 100%;
    display: block;
}

.tagline {
    position: absolute;
    bottom: 50%;
    right: 16%;
    font-size: 13px;
    font-family: Minecraft, monospace;
    color: yellow;
    rotate: -20deg;
    text-shadow: 4px 4px 1px #222;
    animation: pulse 0.7s ease-in-out infinite;
    pointer-events: none;
    z-index: 100;
}

/* ── Sidebar ────────────────────────────────────────────────────────────── */

.sidebar {
    font: 12.6px/1.43 Verdana, Tahoma, "Liberation Sans", "DejaVu Sans", "Noto Sans", Ubuntu, sans-serif;
    padding: 0;
}

.sidebar section {
    padding-top: 1em;
    margin-bottom: 1em;
    border-top: 1px solid #999;
}

.sidebar section:first-of-type { font: 1.5em system-ui, sans-serif; }

.sidebar h2 {
    font-size: 1.2em;
    line-height: 1.3;
    margin: 0 0 .5em;
}

.sidebar ul {
    list-style: square;
    margin: 0;
    padding-left: 0.25em;
}

.sidebar li {
    margin-bottom: .25em;
    padding: calc(var(--pico-nav-element-spacing-vertical) * .1) var(--pico-nav-element-spacing-horizontal);
}

.sidebar a { color: var(--pico-primary); }
.sidebar a:hover { color: var(--pico-primary-hover); }

.sidebar-identity { margin-bottom: .5em; }
.sidebar-identity a {
    justify-content: center;
    font-weight: 600;
}
.sidebar-identity user-avatar { width: 2em; height: 2em; }

.sidebar-avatars {
    display: flex;
    flex-wrap: wrap;
    gap: .3em;
    justify-content: center;
    margin-top: .6em;
}
.sidebar-avatars a { text-decoration: none; }
.sidebar-avatars user-avatar { width: 1.5em; height: 1.5em; }

.active-topics a.unread {
    color: var(--pico-primary);
    font-weight: 600;
}

/* ── Avatar ─────────────────────────────────────────────────────────────── */

user-avatar {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.5em;
    height: 1.5em;
    border-radius: 50%;
    background: hsl(var(--hue, 0) 50% 40%);
    color: #fff;
    font-weight: 700;
    vertical-align: middle;
    overflow: hidden;
    flex-shrink: 0;
}

user-avatar[size="lg"] {
    width: 3rem;
    height: 3rem;
    font-size: 1.25rem;
}

user-avatar img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.user-identity {
    display: flex;
    align-items: center;
    gap: .5rem;
    text-decoration: none;
    color: inherit;
}
.user-identity[data-size="sm"] span { font-size: .85em; }

/* ── Cards ──────────────────────────────────────────────────────────────── */

.layout article header.row a,
.layout article h3 a { text-decoration: none; }

.preview-card {
    --pico-card-background-color: rgba(255, 255, 200, 0.06);
    border-inline-start: 3px solid var(--pico-primary);
    max-height: min(24rem, 50vh);
    overflow-y: auto;
}

article[data-editing] {
    outline: 1px solid var(--pico-primary);
    background: color-mix(in oklch, var(--pico-primary) 4%, transparent);
}

/* ── Tab bar ────────────────────────────────────────────────────────────── */

.tab-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem 1.5rem;
    border-bottom: 2px solid var(--pico-muted-border-color);
    margin-bottom: 1rem;
}

.tab-bar button {
    background: none;
    border: none;
    box-shadow: none;
    border-radius: 0;
    border-bottom: 2px solid transparent;
    color: var(--pico-muted-color);
    padding: 0.4rem 0;
    font-size: 0.95em;
    font-weight: normal;
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s;
    margin-bottom: -1px;
}

.tab-bar button:hover { color: var(--pico-color); }

.tab-bar button[aria-pressed="true"] {
    color: var(--pico-primary);
    border-bottom-color: var(--pico-primary);
}

/* ── Reactions ──────────────────────────────────────────────────────────── */

#emoji-picker { border: none; background: none; padding: 0; }

.reactions { display: contents; }

.reaction-btn {
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    padding: calc(var(--pico-form-element-spacing-vertical) * 0.5) calc(var(--pico-form-element-spacing-horizontal) * 0.5);
    background: color-mix(in srgb, currentColor 5%, transparent);
}

.reaction-btn[aria-pressed="true"] {
    background: color-mix(in srgb, var(--pico-primary) 18%, transparent);
    outline: 1px solid color-mix(in srgb, var(--pico-primary) 35%, transparent);
    outline-offset: -1px;
}

.reaction-btn user-avatar {
    width: 1.4em;
    height: 1.4em;
    font-size: .75em;
    outline: 1.5px solid var(--pico-card-background-color, var(--pico-background-color));
    outline-offset: -1px;
}

.reaction-btn user-avatar + user-avatar { margin-inline-start: -.35em; }

.reaction-btn parsed-emoji img {
    display: inline;
    width: 1.2em;
    height: 1.2em;
    vertical-align: -.15em;
    margin: 0;
}

/* ── Forms ──────────────────────────────────────────────────────────────── */

form textarea { field-sizing: content; }

/* ── Dialog ─────────────────────────────────────────────────────────────── */

dialog::backdrop { background: rgba(0, 0, 0, 0.75); }
.dialog-portal { display: contents; }

/* ── Footer ─────────────────────────────────────────────────────────────── */

#footer {
    color: var(--pico-muted-color);
    font-family: Verdana, Tahoma, 'DejaVu Sans', sans-serif;
    font-size: 14px;
    line-height: 18px;
}

#footer a { color: var(--pico-primary); }

#footer > div {
    padding: 3em 0 40px;
    text-align: right;
    font-size: small;
    font-style: italic;
    color: #ccc;
}

/* ── Iframe ─────────────────────────────────────────────────────────────── */

.content-iframe {
    width: 100%;
    height: calc(100vh - 200px);
    border: none;
    border-radius: var(--pico-border-radius);
}

.content-iframe.fullscreen { height: calc(100vh - var(--nav-h)); border-radius: 0; }

/* ── Utility classes ────────────────────────────────────────────────────── */

.meta         { color: var(--pico-muted-color); font-size: .9em; }
.err          { color: var(--pico-del-color); }
.warn         { color: #e0a000; }
.ok           { color: var(--pico-ins-color); }
.body-preview { margin-bottom: .4rem; color: var(--pico-muted-color); font-size: .9em; }
.view-desc    { color: var(--pico-muted-color); font-size: .95em; margin-bottom: .75rem; }
.muted        { opacity: .7; }
.clickable-img { cursor: pointer; display: block; margin: auto; }

.btn-sm { padding: .2rem .5rem; font-size: .8em; }

button.danger, [role="button"].danger {
    --pico-background-color: red;
    --pico-border-color: red;
    --pico-color: #fff;
}
button.danger:hover, [role="button"].danger:hover {
    --pico-background-color: red;
    --pico-border-color: red;
}
button.outline.danger, [role="button"].outline.danger {
    --pico-color: red;
    --pico-border-color: red;
    background: transparent;
}

.link {
    background: none;
    border: 0;
    padding: 0;
    color: var(--pico-primary);
    cursor: pointer;
    font: inherit;
    text-decoration: underline;
}
.link:hover { color: var(--pico-primary-hover); }

/* ── Spoilers ───────────────────────────────────────────────────────────── */

.spoiler { background: var(--pico-muted-color); color: transparent; border-radius: 3px; cursor: pointer; user-select: none; padding: 0 .2em; transition: color .15s, background .15s; }
.spoiler:hover, .spoiler.revealed { color: inherit; background: var(--pico-card-background-color); }
.spoiler-body { filter: blur(5px); pointer-events: none; user-select: none; }

/* ── Breadcrumb ─────────────────────────────────────────────────────────── */

.breadcrumb { flex-wrap: nowrap; overflow: hidden; }
.breadcrumb a.outline {
    padding: .15rem .5rem;
    font-size: .85rem;
    white-space: nowrap;
    background-color: #eee;
    color: #000;
    box-shadow: 0 2px 6px color-mix(in srgb, var(--pico-primary) 40%, transparent);
}
.breadcrumb > span { color: var(--pico-muted-color); flex-shrink: 0; }
.breadcrumb > span:last-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ── Auth nav ───────────────────────────────────────────────────────────── */

.oauth-row { display: flex; gap: var(--pico-spacing); }
.oauth-row button { flex: 1; margin-bottom: 0; }
.auth-nav { display: flex; gap: 1rem; justify-content: center; }

/* ── Home hero ──────────────────────────────────────────────────────────── */

.home-variant {
    text-align: center;
    background: none;
    --pico-color: var(--pico-contrast-hover);
    color: var(--pico-contrast-hover);
}
.home-variant * { color: white; }
.home-variant h3 { font-family: Minecraft, monospace; text-shadow: 4px 4px 1px #222; margin-bottom: 1em; }
.home-variant lite-youtube { display: block; width: 100%; aspect-ratio: 16 / 9; }
.home-variant .outro { margin-top: 1rem; }

/* ── Notifications ──────────────────────────────────────────────────────── */

.hello-wrap    { position: relative; display: flex; align-items: center; }
.hello-btn     { display: block; width: 48px; height: 38px; padding: 0; border: none; background: url('/assets/notif.png') 0 0 / 48px 114px no-repeat; cursor: pointer; }
.hello-btn:hover  { background-position: 0 -38px; }
.hello-btn:active { background-position: 0 -76px; }
.hello-popover { position: absolute; top: calc(100% + 4px); left: 0; background: var(--pico-background-color); border: 1px solid var(--pico-muted-border-color); border-radius: var(--pico-border-radius); padding: .4rem .7rem; white-space: nowrap; z-index: 100; box-shadow: var(--pico-card-box-shadow); }

/* ── Draft items ────────────────────────────────────────────────────────── */

.draft-item    { display: flex; justify-content: space-between; align-items: baseline; }
.draft-discard { text-decoration: none; opacity: .45; flex-shrink: 0; margin-left: .4em; }
.draft-discard:hover { opacity: 1; }

/* ── Section title ──────────────────────────────────────────────────────── */

h2.section-title { margin-top: 0; }

/* ── Open externally ────────────────────────────────────────────────────── */

.open-externally { margin-left: auto; padding: .2rem .6rem; font-size: .85em; align-self: center; }

/* ── Vim keys ───────────────────────────────────────────────────────────── */

#vim-indicator {
    position: fixed;
    bottom: 1rem;
    right: 1rem;
    font: bold 0.75rem/1 monospace;
    background: var(--pico-primary);
    color: var(--pico-primary-inverse);
    padding: 0.25em 0.5em;
    border-radius: 0.25em;
    z-index: 9999;
    pointer-events: none;
}

[data-vim-card]:focus-visible {
    outline: 2px solid var(--pico-primary);
    outline-offset: 3px;
    border-radius: 0.2em;
}

#keys-help { max-width: 28rem; }
#keys-help td:first-child { white-space: nowrap; }

/* ── Compact density ────────────────────────────────────────────────────── */

article.card[data-expanded] .compact-meta    { display: none; }
article.card[data-expanded] .compact-prefix  { display: none; }
article.card[data-expanded] .compact-author  { display: none; }
article.card:not([data-expanded]) .compact-meta { display: block; font-size: 0.8em; color: var(--pico-muted-color); opacity: 0.75; }

.compact-actions {
    display: flex;
    align-items: center;
    gap: 0.2rem;
    position: absolute;
    top: 0.4rem;
    right: 0.75rem;
    z-index: 1;
    font-size: 0.85em;
}

[data-density="compact"] article.card { padding: 0.5rem 0.75rem; }

[data-density="compact"] article.card header,
[data-density="compact"] article.card .cluster { display: none; }

[data-density="compact"] article.card h3 {
    margin: 0 0 0.1rem;
    font-size: 0.95em;
    font-family: inherit;
}

[data-density="compact"] article.card .compact-prefix {
    display: inline;
    font-weight: normal;
    font-family: inherit;
    color: var(--pico-muted-color);
}

[data-density="compact"] article.card h3 a::after {
    content: '';
    position: absolute;
    inset: 0;
}

[data-density="compact"] article.card .body-preview {
    display: block;
    margin: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

[data-density="compact"] article.card .compact-meta {
    display: block;
    font-size: 0.8em;
    color: var(--pico-muted-color);
    opacity: 0.75;
}

[data-density="compact"] article.card[data-kind="message"] [data-when-viewing] {
    display: flex;
    align-items: baseline;
    gap: 0.35rem;
}

[data-density="compact"] article.card[data-kind="message"] .compact-author {
    display: inline;
    flex-shrink: 0;
}

[data-density="compact"] article.card[data-kind="message"] .body-preview {
    flex: 1;
    min-width: 0;
}

[data-density="compact"] article.card[data-kind="message"] .compact-meta {
    flex-shrink: 0;
    margin-left: auto;
}

/* ── Command palette ────────────────────────────────────────────────────── */

#cmd-dialog { max-width: 36rem; }

ul.cmd-results {
    list-style: none;
    padding: 0;
    margin: 0;
    max-height: min(60vh, 360px);
    overflow-y: auto;
}

ul.cmd-results li {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
    padding: 0.4rem 0.6rem;
    border-radius: var(--pico-border-radius);
    cursor: pointer;
}

ul.cmd-results li small {
    opacity: 0.5;
    min-width: 3rem;
    flex-shrink: 0;
}

ul.cmd-results li.cmd-sel {
    background: var(--pico-primary-background);
    color: var(--pico-primary-inverse);
}

ul.cmd-results li.cmd-sel small { opacity: 0.7; }
ul.cmd-results li.cmd-empty { opacity: 0.5; cursor: default; }
