[x-cloak] {
    display: none !important;
}

/* 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 !important;
    padding-right: .75rem;
    list-style: none;
    font: 700 16px/1 sans-serif;
}

#main-nav menu a {
    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;
}

#main-nav menu a:hover,
#main-nav menu a[aria-current] {
    color: #fff;
}

/* Layout */
:root {
    --nav-h: 40px;
    --pico-font-family-monospace: "Consolas", "Courier New", "DejaVu Sans Mono", monospace;
}

.container {
    max-width: 1000px;
}

body {
    font-family: Verdana, Tahoma, "DejaVu Sans", sans-serif;
    background: url('/assets/bg.gif') repeat;
    margin: 0;
    padding-top: var(--nav-h);
    min-height: 100vh;
}

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

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

.tagline {
    position: absolute;
    bottom: 50%;
    right: 16%;
    font-size: 13px;
    color: yellow;
    rotate: -20deg;
    animation: pulse 0.7s ease-in-out infinite;
    pointer-events: none;
    z-index: 100;
}

.tagline, h4 {
    font-family: Minecraft, monospace;
    text-shadow: 4px 4px 1px #222;
}

@keyframes pulse {
    50% {
        scale: 1.25;
    }
}

.layout {
    display: grid;
    grid-template-columns: 200px 1fr;
    gap: var(--pico-spacing);
    align-items: start;
}

/* Dark mode variables */
[data-theme="dark"] {
    --card-bg: #2a2a2a;
    --card-shadow: 4px 4px 8px rgba(0, 0, 0, 0.6);
    --sidebar-link: #bbb;
    --sidebar-link-hover: #fff;
    --footer-text: #ccc;
    --footer-link: #e0d0d0;
    --scrollbar-track: #1a1a1a;
    --scrollbar-thumb: #444;
    --blockquote-bg: rgba(251, 255, 202, 0.08);
    --hr-border: rgba(68, 68, 68, 0.6);
    --selection-bg: rgba(228, 75, 0, 0.3);
}

/* 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 h2 {
    font-size: 1.2em;
    line-height: 1.3;
    margin: 0 0 .5em;
}

.sidebar ul {
    list-style: square;
    margin: 0;
    padding-left: 1.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(--sidebar-link, var(--pico-primary));
    text-decoration: underline;
}

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

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

/* 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="sm"] {
    width: 22px;
    height: 22px;
    font-size: 12px;
}

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

/* Custom Fonts */
@font-face {
    font-family: Minecraft;
    src: url(/assets/minecraft.woff2) format('woff2');
    font-display: swap;
}

.layout > div {
    --pico-color: var(--pico-contrast-hover);
    color: var(--pico-contrast-hover);
}

.layout > div > div > h2,  /* section headings: Forum/Wiki/Admin */
.layout article > div > h2, /* article titles */
.card h3                     /* card titles */
{
    font-family: Minecraft, system-ui, sans-serif;
}

/* Cards */
.layout > div > :is(article, div > article, div > div > article):not(article article):not(form article) {
    --pico-card-background-color: var(--card-bg);
    box-shadow: var(--card-shadow, none);
}

/* Preview Cards */
.preview-card {
    --pico-card-background-color: rgba(255, 255, 200, 0.06);
    border-inline-start: 3px solid var(--pico-primary);
}

/* Metadata separator */
.layout article > div > hgroup p,
.layout article > hgroup p {
    padding-bottom: 0.5em;
    border-bottom: 2px solid var(--pico-muted-border-color);
    margin-bottom: 0.75em;
}

/* Author pills */
.layout article hgroup p > span:nth-child(2),
.layout article > div > div > strong:first-child {
    background: rgba(187, 187, 187, 0.15);
    padding: 0.1em 0.45em;
    border-radius: 4px;
}

/* Content Links */
[data-theme="dark"] .layout article a:not([role="button"]):not(.outline) {
    color: #6cf;
}

[data-theme="dark"] .layout article a:not([role="button"]):not(.outline):hover {
    color: var(--pico-primary-hover, #cc7800);
}

/* Emoji Picker */
#emoji-picker {
    border: none;
    background: none;
    padding: 0;
}

.reaction-btn {
    all: unset;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    padding: .15rem .4rem;
    font-size: .9em;
    border-radius: var(--pico-border-radius);
    background: rgba(128, 128, 128, .05);
}

.reaction-btn img {
    display: inline;
    width: 1em;
    height: 1em;
    vertical-align: -.1em;
    margin: 0;
}

/* Markdown Content */
blockquote {
    background: var(--blockquote-bg, rgba(0, 0, 0, 0.03));
    border: 1px solid #444;
    border-inline-start: 4px solid var(--pico-primary);
    padding: 0.8em 1em;
    border-radius: var(--pico-border-radius);
}

hr {
    border-color: var(--hr-border, var(--pico-muted-border-color));
}

:not(pre) > code {
    font-size: 0.95em;
}

/* Selection & Highlight */
[data-theme="dark"] ::selection {
    background: var(--selection-bg);
    color: #fff;
}

main mark {
    background: rgba(255, 255, 0, 0.2);
    color: inherit;
    padding: 1px 3px;
    border-radius: 2px;
}

/* Nav Active/Pressed Polish */
#main-nav menu a:active {
    color: #d0d0e0;
}

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

/* 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);
}

/* Scrollbar */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--scrollbar-thumb, auto) var(--scrollbar-track, auto);
}

[data-theme="dark"] ::-webkit-scrollbar {
    width: 8px;
}

[data-theme="dark"] ::-webkit-scrollbar-track {
    background: var(--scrollbar-track);
}

[data-theme="dark"] ::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border-radius: 4px;
}

[data-theme="dark"] ::-webkit-scrollbar-thumb:hover {
    background: var(--pico-primary, #e44b00);
}

/* Dialog */
dialog::backdrop {
    background: rgba(0, 0, 0, 0.75);
}

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

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

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

/* Utility classes (Phase 6) */
.byline        { display: flex; align-items: center; gap: .5rem; }
.actions       { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.reaction-row  { display: flex; flex-wrap: wrap; gap: .25rem; align-items: center; }
.meta          { color: var(--pico-muted-color); font-size: .9em; }
.meta > span + span::before { content: ' · '; opacity: .6; margin: 0 .25rem; }
.err           { color: var(--pico-del-color); display: block; margin-top: .5rem; }
.ok            { color: var(--pico-ins-color); display: block; margin-top: .5rem; }
.body-preview  { margin-bottom: .4rem; color: var(--pico-muted-color); font-size: .9em; white-space: pre-wrap; }
.btn-sm        { padding: .2rem .5rem !important; font-size: .8em !important; }
.small         { font-size: .85em; }
.nav-user      { display: flex; align-items: center; gap: 6px; text-align: right; }
.notif-wrap    { position: relative; display: flex; align-items: center; }
.notif-btn     { display: block; width: 48px; height: 38px; padding: 0; border: none; background: url('/assets/notif.png') 0 0 / 48px 114px no-repeat; cursor: pointer; }
.notif-btn:hover  { background-position: 0 -38px; }
.notif-btn:active { background-position: 0 -76px; }
.notif-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); }
.view-desc     { color: var(--pico-muted-color); font-size: .95em; margin-bottom: .75rem; }
.content-iframe.fullscreen { height: calc(100vh - var(--nav-h)); border-radius: 0; }

.list-header          { display: flex; align-items: center; justify-content: space-between; margin-bottom: .5rem; }
.list-header h2       { margin: 0; }
.breadcrumb           { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; }
.breadcrumb a.outline { padding: .15rem .5rem; font-size: .85rem; }
.breadcrumb span      { color: var(--pico-muted-color); }
.section-divider { margin-top: 2rem; border-top: 1px solid var(--pico-muted-border-color); padding-top: 1rem; }
.actions > .spacer, .reaction-row.spacer { margin-left: auto; }

/* Mobile */
@media (max-width: 768px) {
    .layout {
        grid-template-columns: 1fr;
    }

    .layout aside {
        display: none;
    }
}

/* Global UI state — driven by data-attrs on <html> */
[data-fullscreen] :is(.sidebar, .banner, footer, .countdown-host, hr) { display: none; }
[data-fullscreen] main { width: 100%; max-width: none; margin: 0; padding: 0; overflow: auto; background: var(--pico-background-color); }
[data-fullscreen] .layout { grid-template-columns: 1fr; }
[data-fullscreen] .tab-bar { display: none; }
main:fullscreen {
  background: var(--pico-background-color);
  overflow: auto;
  padding: 0;
  max-width: none;
}
[data-auth="out"] [data-when="in"],
[data-auth="in"]  [data-when="out"] { display: none; }
[data-auth="pending"] [data-when] { visibility: hidden; }
[data-auth="pending"] { cursor: progress; }

.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); }

.card .card-link {
  display: block;
  color: inherit;
  text-decoration: none;
}
.card h3 {
  color: #e44b00;
  text-decoration: underline;
}
.card .card-link:hover h3 { color: var(--pico-primary); }

/* Utility (Action 11) */
.row-flex      { display: flex; align-items: center; gap: .75rem; padding: .5rem; }
.cluster       { display: flex; gap: .5rem; flex-wrap: wrap; }
.cluster-tight { display: flex; gap: .5rem; }
.flex-1        { flex: 1; }
.meta-right    { margin-left: auto; }
.muted         { opacity: .7; }
.admin-badge, .kind-badge { margin-left: .5rem; opacity: .7; }
.sentinel      { height: 1px; }
.clickable-img { cursor: pointer; display: block; margin: auto; }

/* Login dialog */
.login-dialog-buttons button { width: 100%; }

/* Home template */
.home-variant { text-align: center; }
.home-variant h4 { font-family: Minecraft, monospace; text-shadow: 4px 4px 1px #222; margin: 1em; color: white; }
.home-variant lite-youtube { display: block; }
.home-variant .clickable-img { cursor: pointer; display: block; margin: auto; }
.home-variant .outro { margin-top: 1rem; }

/* Dialog portal */
.dialog-portal { display: contents; }

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

.home-variant { view-transition-name: home-hero; }

::view-transition-old(root),
::view-transition-new(root),
::view-transition-old(home-hero),
::view-transition-new(home-hero) { animation-duration: 120ms; }

/* Edit-mode visual treatment (Action 14) */
article:not([data-editing]) [data-when-editing] { display: none; }
article[data-editing]        [data-when-viewing] { display: none; }
article[data-editing] {
  outline: 1px solid var(--pico-primary);
  background: color-mix(in oklch, var(--pico-primary) 4%, transparent);
}

/* Container queries (Action 15) */
.card,
.post,
.row-flex { container-type: inline-size; }

@container (max-width: 420px) {
  .cluster        { flex-direction: column; align-items: stretch; }
  .cluster-tight  { flex-direction: column; align-items: stretch; }
  .byline         { flex-wrap: wrap; }
}
