/* YLIH archive — dark theme, full-bleed.
 * Masonry-ish tiling on /list, /tag, /search, /popular via CSS grid +
 * JS-computed grid-row-end spans. Index page uses a separate "wall-back"
 * tile field as a translucent backdrop.
 */

:root {
    --col-w: 220px;
    --bg: #14151a;
    --bg-elev: #1c1e26;
    --bg-elev-2: #252833;
    --border: #2a2d38;
    --border-strong: #3a3e4a;
    --fg: #d8d8e0;
    --fg-dim: #8a8d99;
    --fg-faint: #5a5d68;
    --accent: #7cacf8;
    --accent-strong: #4a76a8;
    --accent-soft: #93cfeb;
    --tag-bg: #2d4f78;
    --tag-bg-hover: #3d6494;
    --danger: #c44;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { background: var(--bg); color: var(--fg); min-height: 100%; }
html { color-scheme: dark; }
body {
    font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Trebuchet MS", Helvetica, sans-serif;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

a, a:visited { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-soft); text-decoration: underline; }

img { color: transparent; } /* hide alt text flash before lazy-load */

/* --- Sticky top nav ----------------------------------------------------- */

.nav {
    position: sticky; top: 0; z-index: 100;
    background: rgba(28, 30, 38, 0.92);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
    padding: 8px 16px;
    display: flex; align-items: center; gap: 10px;
    flex-wrap: wrap;
}
.brand { font-size: 16px; font-weight: 600; white-space: nowrap; }
.brand a, .brand a:visited { color: var(--fg); }
.brand a:hover { color: var(--accent); text-decoration: none; }
.brand small { color: var(--fg-dim); font-weight: 400; font-size: .75em; margin-left: .3em; }

.nav-btn {
    background: var(--bg-elev-2); color: var(--fg);
    border: 1px solid var(--border-strong);
    border-radius: 4px;
    padding: 4px 12px;
    cursor: pointer; font-size: 13px;
    text-decoration: none; display: inline-block;
}
.nav-btn:hover { background: var(--bg-elev); color: var(--fg); text-decoration: none; }
.nav-btn.active { background: var(--accent-strong); border-color: var(--accent-strong); color: white; }
.nav-btn.active:hover { color: white; }

.innervoice, .nav-custom { font-size: 12px; color: var(--fg-dim); font-style: italic; white-space: nowrap; }
.lastid { font-size: 12px; color: var(--fg-dim); margin-left: auto; }
.lastid a { color: var(--fg-dim); }
.lastid a:hover { color: var(--accent); text-decoration: none; }

.nav-search { margin: 0; }
.search {
    background: var(--bg-elev-2); color: var(--fg);
    border: 1px solid var(--border-strong);
    border-radius: 4px;
    padding: 4px 8px; font-size: 13px;
    width: 200px;
}
.search:focus { outline: none; border-color: var(--accent); }
.search::placeholder { color: var(--fg-faint); }

.sep { width: 1px; height: 20px; background: var(--border); }

.scale-slider { width: 110px; vertical-align: middle; cursor: pointer; accent-color: var(--accent); }
.scale-label { font-size: 12px; color: var(--fg-dim); }

/* --- Page container — full width, modest side gutter ------------------ */

.page { width: 100%; padding: 16px 24px 48px; }
.page h2 { font-weight: 600; font-size: 1.5em; margin: 0 0 .8em; }
.page h3 { font-weight: 600; font-size: .85em; color: var(--fg-dim); text-transform: uppercase; letter-spacing: .08em; margin: 1.4em 0 .6em; }

/* --- Index: wall-back + hero --------------------------------------------*/

body.mod-index { overflow-x: hidden; }

.wall-back {
    position: fixed; inset: 0;
    z-index: 0;
    pointer-events: none;
    overflow: hidden;
    padding: 0;
    columns: 180px;
    column-gap: 4px;
    opacity: .35;
    mask-image: radial-gradient(circle at 50% 35%, black 0%, black 30%, rgba(0,0,0,.6) 65%, rgba(0,0,0,.2) 100%);
    -webkit-mask-image: radial-gradient(circle at 50% 35%, black 0%, black 30%, rgba(0,0,0,.6) 65%, rgba(0,0,0,.2) 100%);
}
.wall-back .wall-tile {
    display: block;
    margin: 0 0 4px;
    break-inside: avoid;
    -webkit-column-break-inside: avoid;
    border-radius: 2px;
    overflow: hidden;
    pointer-events: auto;
    filter: saturate(.8);
    transition: filter .3s, transform .3s;
}
.wall-back .wall-tile:hover {
    filter: saturate(1) brightness(1.1);
    transform: scale(1.02);
}
.wall-back .wall-tile img {
    width: 100%; display: block;
}

.mod-index-page {
    position: relative;
    z-index: 1;
    min-height: 70vh;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    padding: 4vh 24px 8vh;
}

.hero {
    text-align: center;
    background: rgba(20, 21, 26, .82);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 36px 40px;
    max-width: 700px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, .5);
}
.hero-title {
    font-size: 56px;
    font-weight: 200;
    letter-spacing: -0.04em;
    color: var(--fg);
    margin: 0 0 8px;
}
.hero-sub {
    color: var(--fg-dim);
    font-size: 15px;
    line-height: 1.6;
    margin: 0 0 24px;
}
.hero-actions {
    display: flex; gap: 8px;
    justify-content: center;
    flex-wrap: wrap;
}
.bigbtn {
    display: inline-block;
    padding: 10px 22px;
    background: var(--bg-elev-2);
    color: var(--fg);
    border: 1px solid var(--border-strong);
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    transition: background .15s, transform .15s;
}
.bigbtn:hover {
    background: var(--accent-strong);
    border-color: var(--accent-strong);
    color: white;
    text-decoration: none;
    transform: translateY(-1px);
}

.cloud-wrap {
    position: relative;
    z-index: 1;
    max-width: 1100px;
    margin: 36px auto 0;
    background: rgba(20, 21, 26, .82);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 24px 32px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, .5);
}
.cloud-h {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .12em;
    color: var(--fg-dim);
    margin: 0 0 12px;
    text-align: center;
}

/* --- Tag cloud (used on /, also in narrow context) ---------------------- */

.tagcloud {
    line-height: 2.2;
    text-align: center;
}
.tagcloud .ctag {
    display: inline-block;
    margin: 2px 8px;
    color: var(--accent);
    opacity: .82;
    transition: opacity .15s, color .15s, transform .15s;
}
.tagcloud .ctag:hover {
    color: var(--accent-soft);
    opacity: 1;
    text-decoration: none;
    transform: translateY(-1px);
}

/* --- Grid masonry: real one ------------------------------------------- */

#ilist {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(var(--col-w), 1fr));
    grid-auto-rows: 4px;
    gap: 0 8px;
    margin: 0;
}

.ithumb {
    position: relative;
    background: var(--bg-elev);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 8px;
    grid-row-end: span 60; /* fallback before JS sets the real span */
    display: block;
}
.ithumb img { width: 100%; display: block; }
.ithumb:hover { outline: 2px solid var(--accent); outline-offset: -2px; }
.ithumb.hidden::after {
    content: "hidden";
    position: absolute; top: 6px; right: 6px;
    background: rgba(196, 68, 68, .85);
    color: white; font-size: 10px;
    padding: 1px 6px; border-radius: 2px;
    z-index: 2;
}

.empty { text-align: center; color: var(--fg-dim); padding: 4em 0; font-style: italic; }

/* --- Pagination --------------------------------------------------------- */

.pagination { text-align: center; margin: 1.5em 0; }
.pagination ul { display: inline-flex; flex-wrap: wrap; gap: 2px; list-style: none; padding: 0; justify-content: center; }
.pagination li { display: inline-block; }
.pagination a {
    display: inline-block;
    padding: 5px 11px;
    background: var(--bg-elev);
    color: var(--fg);
    border-radius: 3px;
    min-width: 32px;
    text-align: center;
}
.pagination a:hover { background: var(--bg-elev-2); text-decoration: none; }
.pagination li.active a { background: var(--accent-strong); color: white; font-weight: 600; }
.pagination .current { display: inline-block; padding: 5px 14px; font-size: 1.2em; font-weight: 600; color: var(--fg); }

/* --- Viewer ------------------------------------------------------------- */

.viewer-image {
    display: block;
    text-align: center;
    margin: 1.5em auto;
    background: var(--bg-elev);
    padding: 12px;
    border-radius: 4px;
}
#theimage {
    max-width: 100%; height: auto;
    display: inline-block;
    border-radius: 2px;
}

/* --- Tag chips (viewer) ------------------------------------------------- */

#tagviewer { margin: 0 0 1.5em; }
.tv-block { display: inline-block; }
.tv-tag {
    background: var(--tag-bg);
    display: inline-block;
    padding: 3px 10px; margin: 0 4px 4px 0;
    border-radius: 3px; font-size: .9em;
}
.tv-tag:hover { background: var(--tag-bg-hover); }
.tv-tag a, .tv-tag a:visited { color: white; }
.tv-tag a:hover { text-decoration: none; }

/* --- All tags page ----------------------------------------------------- */

#full_taglist {
    columns: 240px; column-gap: 24px;
    list-style: none;
    margin: 1em 0;
}
#full_taglist li { list-style: none; padding: 1px 0; break-inside: avoid; }
#full_taglist li.letter {
    margin: 1.5em 0 .4em;
    font-weight: 600; font-size: 1.3em;
    color: var(--fg-dim);
    border-bottom: 1px solid var(--border);
    padding-bottom: 4px;
}
#full_taglist li.letter:first-child { margin-top: 0; }
#full_taglist a small { color: var(--fg-dim); margin-left: 4px; }
#full_taglist a.lonely { color: var(--fg-dim); font-style: italic; }
#full_taglist a.significant { font-weight: 600; }
#full_taglist a.powerful { font-weight: 700; font-size: 1.15em; color: var(--accent-soft); }

/* --- Share-URL table --------------------------------------------------- */

.linkorz {
    border: 0;
    margin: 1em 0;
    padding: 0;
    font-size: .9em;
    width: 100%;
    max-width: 900px;
}
.linkorz td { padding: 4px 8px 4px 0; }
.linkorz td:first-child { color: var(--fg-dim); width: 220px; }
.linkorz input {
    width: 100%;
    background: var(--bg-elev);
    color: var(--fg);
    border: 1px solid var(--border-strong);
    border-radius: 3px;
    padding: 4px 8px;
    font-family: ui-monospace, "SF Mono", Monaco, Menlo, Consolas, monospace;
    font-size: .85em;
}
.linkorz input:focus { border-color: var(--accent); outline: none; }

/* --- 404 ---------------------------------------------------------------- */

#eh { font-size: 64px; margin: .5em 0 .3em; color: var(--accent); font-weight: 200; }

/* --- Lightbox ---------------------------------------------------------- */

.lightbox {
    display: none;
    position: fixed; inset: 0;
    z-index: 200;
    background: rgba(0, 0, 0, .95);
    align-items: center; justify-content: center;
}
.lightbox.open { display: flex; }
.lightbox img { max-width: 95vw; max-height: 95vh; object-fit: contain; }
.lightbox-close {
    position: absolute; top: 12px; right: 16px;
    color: white; font-size: 28px;
    cursor: pointer; background: none; border: none;
    z-index: 201;
}
.lightbox-nav {
    position: absolute; top: 50%; transform: translateY(-50%);
    color: white; font-size: 36px;
    cursor: pointer;
    background: rgba(0, 0, 0, .4);
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    z-index: 201;
}
.lightbox-nav:hover { background: rgba(255, 255, 255, .15); }
.lightbox-prev { left: 12px; }
.lightbox-next { right: 12px; }
.lightbox-info {
    position: absolute; bottom: 12px; left: 50%;
    transform: translateX(-50%);
    color: #ccc; font-size: 13px;
    background: rgba(0, 0, 0, .6);
    padding: 6px 14px; border-radius: 4px;
    z-index: 201;
    text-align: center;
}
.lightbox-info a { color: var(--accent); }

/* --- Scroll-to-top ----------------------------------------------------- */

.scroll-top {
    position: fixed; bottom: 24px; right: 24px;
    z-index: 150;
    background: var(--accent-strong); color: white;
    border: none; border-radius: 50%;
    width: 44px; height: 44px;
    font-size: 22px; cursor: pointer;
    opacity: 0; pointer-events: none;
    transition: opacity .3s;
    box-shadow: 0 2px 8px rgba(0, 0, 0, .4);
    display: flex; align-items: center; justify-content: center;
}
.scroll-top.visible { opacity: 1; pointer-events: auto; }
.scroll-top:hover { background: #5b8bbf; }

/* --- Footer ----------------------------------------------------------- */

.copy {
    font-size: .8em;
    color: var(--fg-dim);
    margin: 3em 0 0;
    padding: 1.5em;
    border-top: 1px solid var(--border);
    text-align: center;
    position: relative;
    z-index: 2;
    background: var(--bg);
}
body.mod-index .copy { background: rgba(20, 21, 26, .8); }

.sentinel { height: 1px; }

/* --- Admin tiles ------------------------------------------------------- *
 * Selectors include the id (#ilist.admin-grid) so they beat the default
 * #ilist masonry rules (which would otherwise win by specificity and shrink
 * admin tiles to 4px-row heights). */

#ilist.admin-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(var(--col-w), 1fr));
    grid-auto-rows: auto;
    gap: 10px;
}
#ilist.admin-grid .ithumb {
    grid-row-end: auto;
    margin-bottom: 0;
    background: var(--bg-elev);
    padding: 6px;
    display: flex;
    flex-direction: column;
    overflow: visible;
}
#ilist.admin-grid .ithumb a {
    display: block;
    background: var(--bg);
    border-radius: 2px;
    overflow: hidden;
}
#ilist.admin-grid .ithumb img {
    width: 100%;
    height: auto;
    display: block;
}
#ilist.admin-grid .ithumb.review { outline: 2px solid var(--danger); outline-offset: -2px; }
#ilist.admin-grid .ithumb.hidden { opacity: .55; }
#ilist.admin-grid .ithumb.hidden::after { display: none; }

.adm-meta {
    display: flex;
    gap: 4px;
    align-items: center;
    font-size: 11px;
    color: var(--fg-dim);
    margin: 4px 0;
    flex-wrap: wrap;
}
.badge {
    background: var(--bg-elev-2);
    padding: 1px 5px;
    border-radius: 2px;
    font-size: 10px;
}
.badge-review { background: rgba(196, 68, 68, .8); color: white; }
.badge-hidden { background: rgba(255, 255, 255, .1); }

.adm-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
    margin-top: auto;
}
.adm-actions form { margin: 0; display: inline; }
.adm-btn {
    background: var(--bg-elev-2);
    color: var(--fg);
    border: 1px solid var(--border-strong);
    border-radius: 3px;
    padding: 3px 8px;
    cursor: pointer;
    font-size: 11px;
}
.adm-btn:hover { background: var(--border-strong); }
.adm-btn-danger:hover { background: var(--danger); color: white; border-color: var(--danger); }

/* --- Mobile ----------------------------------------------------------- */

@media (max-width: 700px) {
    :root { --col-w: 150px; }
    .nav { padding: 6px 8px; gap: 6px; }
    .search { width: 140px; }
    .scale-slider { width: 70px; }
    .page { padding: 12px; }
    .hero { padding: 24px 20px; }
    .hero-title { font-size: 40px; }
    .cloud-wrap { padding: 18px 16px; margin-left: 8px; margin-right: 8px; }
    .linkorz td:first-child { width: auto; display: block; }
    .linkorz td { display: block; padding: 2px 0; }
    .wall-back { columns: 110px; }
}
