/* Gallery (booru-style grid + post page). Builds on comics.css for the sidebar. */

/* same width as the Comics page panel (comics.css); still scrolls with the wheel, but no visible bar */
.gallery-sidebar { scrollbar-width: none; -ms-overflow-style: none; }
.gallery-sidebar::-webkit-scrollbar { display: none; }
.gallery-search { margin-bottom: 10px; }
.gallery-search .tag-search-input { font-size: 13px; padding: 7px 8px; }
.gallery-search .tag-search-input::-webkit-search-cancel-button { filter: invert(1) hue-rotate(120deg); }
#tag-search-results { display: none; }
.tag-search-result.g-active { background-color: rgba(127, 255, 212, 0.12); }
.tag-meta .tag-name { color: #c9a0ff; }

.g-terms { display: flex; flex-wrap: wrap; gap: 4px; }
.g-terms .active-tag-chip { text-decoration: none; }
.g-term-neg { color: #ff9b8f !important; border-color: rgba(255, 155, 143, 0.4) !important; background: rgba(255, 155, 143, 0.08) !important; }

.g-tag-row { gap: 4px; justify-content: flex-start; }
.g-tag-row .tag-name, .g-meta-row .tag-name { text-decoration: none; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.g-tag-row .tag-name:hover, .g-meta-row .tag-name:hover { text-decoration: underline; }
.g-tag-op {
    color: rgba(127, 255, 212, 0.45);
    text-decoration: none;
    font-family: "jf_dot_ayu";
    font-size: 12px;
    width: 12px;
    text-align: center;
    flex: none;
}
.g-tag-op:hover { color: aquamarine; }
.g-meta-row .tag-name { color: #ccc; }
.g-meta-row .tag-count { color: #bbb; }
.g-rating-s .tag-name { color: #8fd694; }
.g-rating-q .tag-name { color: #f0c060; }
.g-rating-e .tag-name { color: #ff8a80; }

.g-link-button {
    background: none; border: none; padding: 3px 4px; cursor: pointer;
    font-family: "jf_dot_ayu"; font-size: 11px; color: rgba(127, 255, 212, 0.6); text-align: left;
}
.g-link-button:hover { color: aquamarine; text-decoration: underline; }
.g-danger { color: #ff8a80; }
.g-danger:hover { color: #ffb4ab; }
.g-age-inline { margin: 2px 0 0; }

.g-help { font-family: "jf_dot_ayu"; font-size: 10px; line-height: 1.6; color: #777; margin: 6px 0 12px; }
.g-help code { color: #aaa; font-family: inherit; }

.g-admin-links { display: flex; flex-direction: column; gap: 4px; border-top: 1px solid rgba(127, 255, 212, 0.1); padding-top: 8px; }
.g-admin-links a, .g-admin-link { font-family: "jf_dot_ayu"; font-size: 12px; color: aquamarine; text-decoration: none; }
.g-admin-links a:hover, .g-admin-link:hover { text-decoration: underline; }

/* ── grid ── */
.gallery-main { padding: 14px 18px 30px; }
.g-results-head { font-family: "jf_dot_ayu"; font-size: 12px; color: #888; margin: 0 0 10px; }
.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
    gap: 10px;
    list-style: none;
    margin: 0;
    padding: 0;
}
.g-item { display: flex; flex-direction: column; min-width: 0; }
.g-thumb {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 200px;
    background: #111312;
    border: 1px solid rgba(127, 255, 212, 0.15);
    overflow: hidden;
    transition: border-color 0.15s;
    box-sizing: border-box;
    width: 100%;
    padding: 0;
    font: inherit;
    cursor: pointer;
}
.g-thumb:hover, .g-thumb:focus-visible,
.g-item:hover .g-thumb { border-color: aquamarine; }
.g-thumb img { max-width: 100%; max-height: 100%; object-fit: contain; display: block; }
.g-comic .g-thumb { border-color: rgba(128, 170, 208, 0.45); }
.g-comic .g-thumb:hover, .g-comic .g-thumb:focus-visible, .g-comic:hover .g-thumb { border-color: aquamarine; }
.g-comic-thumb img { width: 100%; height: 100%; object-fit: cover; }
.g-badge {
    position: absolute; left: 0; right: 0; bottom: 0;
    font-family: "jf_dot_ayu"; font-size: 10px; letter-spacing: 1px; text-transform: uppercase;
    padding: 14px 6px 4px; text-align: center; color: #cfe3ff;
    background: linear-gradient(to top, rgba(10, 12, 12, 0.92), rgba(10, 12, 12, 0));
    text-shadow: 0 1px 2px #000;
}
.g-badge-ongoing-comic { color: #a8e6bd; }
.g-badge-image-set { color: #f5de8a; }
.g-caption {
    font-family: "jf_dot_ayu"; font-size: 12px; color: rgb(11, 190, 161); text-decoration: none;
    padding: 3px 2px 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: center;
}
.g-caption:hover { color: #fff; }
button.g-caption { background: none; border: none; cursor: pointer; width: 100%; }
.g-caption-locked { color: #c9a84a; }
.g-caption-locked:hover { color: #ffd43b; }
.g-lock-corner {
    position: absolute; top: 4px; right: 4px;
    color: #ffd43b; font-size: 14px; line-height: 1;
    background: rgba(10, 12, 12, 0.8); padding: 4px 5px; border-radius: 2px;
}
.g-lock-open { color: rgba(255, 212, 59, 0.6); }
.g-locked { flex-direction: column; gap: 8px; color: #ffd43b; background: #141615; isolation: isolate; }
/* the picture, blurred and dimmed, far behind */
.g-locked .g-teaser {
    position: absolute; inset: 0; z-index: -2;
    width: 100%; height: 100%; max-width: none; max-height: none;
    object-fit: cover;
    filter: blur(3.5px) brightness(0.62) saturate(0.85);
    transform: scale(1.1);   /* hide the blur's soft edges */
}
/* translucent stripes drifting across it; one stripe period is 16px / sin 45° = 22.63px sideways */
.g-locked::before {
    content: "";
    position: absolute; top: 0; bottom: 0; left: -23px; right: 0; z-index: -1;
    background: repeating-linear-gradient(45deg,
        rgba(20, 22, 21, 0.38) 0, rgba(20, 22, 21, 0.38) 8px,
        rgba(20, 22, 21, 0.08) 8px, rgba(20, 22, 21, 0.08) 16px);
    animation: g-stripes 1.6s linear infinite;
}
@keyframes g-stripes { from { transform: translateX(0); } to { transform: translateX(22.627px); } }
@media (prefers-reduced-motion: reduce) { .g-locked::before { animation: none; } }
.g-locked-icon { font-size: 34px; line-height: 1; filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.8)); }
.g-locked-tier { font-family: "jf_dot_ayu"; font-size: 11px; letter-spacing: 1px; text-transform: uppercase; color: #fff3c4; padding: 0 8px; text-align: center; text-shadow: 0 1px 2px #000; }

.g-notice {
    display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
    font-family: "jf_dot_ayu"; font-size: 13px; color: #ddd;
    border: 1px solid rgba(255, 138, 128, 0.35); background: rgba(255, 138, 128, 0.07);
    padding: 8px 12px; margin: 0 0 12px;
}
.g-notice-btn, .tag-apply-btn.g-inline { width: auto; }
.g-notice-btn {
    font-family: "jf_dot_ayu"; font-size: 12px; cursor: pointer;
    color: #ffb4ab; background: transparent; border: 1px solid rgba(255, 138, 128, 0.5); padding: 4px 10px;
}
.g-notice-btn:hover { background: rgba(255, 138, 128, 0.12); }

.g-empty { font-family: "jf_dot_ayu"; color: #aaa; padding: 30px 0; text-align: center; }
.g-empty a { color: aquamarine; }

.g-pager { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px; margin: 20px 0 0; font-family: "jf_dot_ayu"; font-size: 13px; }
.g-pager a, .g-pager span { padding: 4px 9px; border: 1px solid rgba(127, 255, 212, 0.2); color: aquamarine; text-decoration: none; }
.g-pager a:hover { background: rgba(127, 255, 212, 0.1); }
.g-pager .g-page-current { background: rgba(127, 255, 212, 0.15); color: #fff; }
.g-pager .g-page-gap { border-color: transparent; color: #666; }

/* ── post page ── */
.post-main { padding: 10px 18px 30px; display: flex; flex-direction: column; align-items: center; }
.g-post-nav { display: flex; justify-content: space-between; align-items: center; gap: 12px; width: 100%; max-width: 1000px; margin-bottom: 10px; font-family: "jf_dot_ayu"; font-size: 13px; }
.g-post-nav a { color: aquamarine; text-decoration: none; }
.g-post-nav a:hover { text-decoration: underline; }
.g-nav-off { color: #555; }
.g-nav-back { text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.g-saved { font-family: "jf_dot_ayu"; font-size: 12px; color: #7CFC9A; margin: 0 0 8px; }
.g-figure { margin: 0; display: flex; justify-content: center; width: 100%; }
.g-post-image {
    display: block;
    max-width: 100%;
    max-height: calc(100vh - var(--nav-h) - 70px);
    width: auto;
    height: auto;
    object-fit: contain;
    cursor: zoom-in;
    border: 1px solid rgba(127, 255, 212, 0.12);
}
.g-post-image.g-full { max-height: none; cursor: zoom-out; }
.g-post-text { width: 100%; max-width: 1000px; font-family: "jf_dot_ayu"; color: #ddd; margin-top: 12px; }
.g-post-text h1 { font-size: 20px; margin: 0 0 6px; color: aquamarine; }
.g-post-text p { white-space: pre-line; font-size: 14px; margin: 0; }

.g-info { margin: 0; font-family: "jf_dot_ayu"; font-size: 12px; }
.g-info > div { display: flex; gap: 6px; padding: 2px 4px; }
.g-info dt { color: #888; width: 64px; flex: none; }
.g-info dd { margin: 0; color: #ddd; min-width: 0; overflow-wrap: anywhere; }
.g-info a { color: aquamarine; text-decoration: none; }

.g-edit { margin-top: 8px; font-family: "jf_dot_ayu"; font-size: 12px; color: #ccc; }
.g-edit summary { cursor: pointer; color: aquamarine; }
.g-edit form { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.g-edit label { display: flex; flex-direction: column; gap: 2px; color: #999; font-size: 11px; }
.g-edit input, .g-edit select, .g-edit textarea {
    font-family: "jf_dot_ayu"; font-size: 12px; background: #111312; color: #eee;
    border: 1px solid rgba(127, 255, 212, 0.25); padding: 4px 6px;
}
.g-edit textarea { resize: vertical; }

.g-admin-tags { width: 100%; max-width: 1000px; margin-top: 14px; display: flex; gap: 10px; align-items: baseline; }
.g-admin-tags-label { font-family: "jf_dot_ayu"; font-size: 11px; letter-spacing: 1.5px; text-transform: uppercase; color: #888; flex: none; }

.g-gate {
    max-width: 420px; margin: 40px auto; padding: 24px; text-align: center;
    border: 1px solid rgba(127, 255, 212, 0.192); background: #151616; font-family: "jf_dot_ayu"; color: #ddd;
}
.g-gate h2 { margin: 0 0 10px; }
.g-gate p { font-size: 14px; }
.g-gate-locked h2 { color: #ffd43b; }
.g-gate-lock { color: #ffd43b; font-size: 40px; line-height: 1; margin-bottom: 8px; }
.g-gate .login-button {
    display: inline-block; padding: 10px 20px; background-color: #007bff; color: #fff;
    text-decoration: none; border: none; border-radius: 2px; cursor: pointer; font-family: "jf_dot_ayu"; font-size: 14px;
}
.g-gate .login-button:hover { background-color: #0069d9; }
.g-gate-fine { font-size: 12px !important; color: #999; margin-top: 14px; }
.g-gate-fine a, .g-gate a:not(.login-button) { color: aquamarine; }

@media (max-width: 700px) {
    .gallery-page { flex-direction: column; height: auto; }
    .gallery-sidebar { position: static; width: 100%; min-width: 0; height: auto; max-height: none; border-right: none; border-bottom: 1px solid rgba(127, 255, 212, 0.15); }
    .gallery-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
    .g-thumb { height: 170px; }
}

.g-bump-btn { margin-top: 10px; }
.g-date-src { color: #777; font-size: 10px; }
.g-edit input[type="datetime-local"] { color-scheme: dark; }

/* ── sets ── */
.g-set-badge {
    position: absolute; left: 4px; bottom: 4px;
    font-family: "jf_dot_ayu"; font-size: 10px; letter-spacing: 1px; text-transform: uppercase;
    color: #cfe3ff; background: rgba(10, 12, 12, 0.85); border: 1px solid rgba(128, 170, 208, 0.5);
    padding: 2px 6px; border-radius: 2px; line-height: 1.3;
}
.g-locked .g-set-badge { z-index: 1; }
.g-set { width: 100%; max-width: 1000px; margin-top: 10px; }
.g-set-head { display: flex; justify-content: center; align-items: center; gap: 14px; font-family: "jf_dot_ayu"; font-size: 13px; color: #aaa; margin-bottom: 6px; }
.g-set-arrow { color: aquamarine; text-decoration: none; font-size: 22px; line-height: 1; padding: 0 8px; }
.g-set-arrow:hover { color: #fff; }
.g-set-strip { position: relative; display: flex; gap: 6px; overflow-x: auto; padding: 4px 2px 8px; justify-content: safe center; scrollbar-width: thin; }
.g-set-thumb {
    position: relative; flex: none; width: 72px; height: 72px;
    display: flex; align-items: center; justify-content: center;
    background: #111312; border: 1px solid rgba(127, 255, 212, 0.15); overflow: hidden; opacity: 0.7;
    transition: opacity 0.15s, border-color 0.15s;
}
.g-set-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.g-set-thumb:hover { opacity: 1; border-color: aquamarine; }
.g-set-thumb.g-current { opacity: 1; border: 2px solid aquamarine; }
.g-set-locked img { filter: blur(2px) brightness(0.6); transform: scale(1.1); }
.g-set-lock { position: absolute; color: #ffd43b; font-size: 18px; line-height: 1; filter: drop-shadow(0 1px 2px #000); }
.g-set-tools { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.g-set-move { display: flex; gap: 6px; }
.g-set-move .tag-apply-btn { flex: 1; margin: 0; }
.g-set-tools .tag-apply-btn { margin: 0; }
.g-set-tools .tag-apply-btn:disabled { opacity: 0.35; cursor: default; }
.g-set-add { border-top: 1px solid rgba(127, 255, 212, 0.1); padding-top: 8px; margin-top: 8px !important; }
.g-set-add input[type=file] { font-size: 11px; max-width: 100%; }
.g-check { flex-direction: row !important; align-items: center; gap: 6px !important; }
.g-post-image.g-in-set { max-height: calc(100vh - var(--nav-h) - 70px - 120px); }   /* leave room for the set's thumbnail strip */
.g-post-image.g-in-set.g-full { max-height: none; }
.g-set-add-first { border-top: none; padding-top: 0; display: flex; flex-direction: column; gap: 6px; }
.g-set-locked-note { color: #c9a84a; }
.g-set-access { border-top: 1px solid rgba(127, 255, 212, 0.1); padding-top: 8px; }
.g-set-access label { display: flex; flex-direction: column; gap: 2px; color: #999; font-size: 11px; }
.g-set-arrow.g-nav-off { color: #444; cursor: default; }

@media (max-width: 700px) {
    .gallery-main { padding: 12px 12px 96px; }
    .gallery-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
    .g-thumb { height: auto; aspect-ratio: 1 / 1; }
    .g-caption { font-size: 13px; }
}

/* ── Phones: post page = picture first (fitted to the screen), then the set strip, text, tags and info ── */
@media (max-width: 700px) {
    .post-page .post-main { order: 1; padding: 8px 0 20px; }
    .post-page .gallery-sidebar { order: 2; border-bottom: none; border-top: 1px solid rgba(127, 255, 212, 0.15); }
    .post-page .g-post-nav { padding: 0 12px; box-sizing: border-box; margin-bottom: 8px; }
    .post-page .g-post-nav a, .post-page .g-nav-off { padding: 8px 0; font-size: 14px; }
    .post-page .g-figure { touch-action: pan-y pinch-zoom; }
    /* fitted to the screen, sets too (their thumbnail strip may start below the fold).
       svh = the height with the browser's address bar showing, which doesn't change while scrolling
       (dvh does, which made the picture resize as the bar slid in and out) */
    .post-page .g-post-image, .post-page .g-post-image.g-full,
    .post-page .g-post-image.g-in-set, .post-page .g-post-image.g-in-set.g-full {
        max-width: 100%;
        max-height: calc(100vh - var(--nav-h) - 52px);
        max-height: calc(100svh - var(--nav-h) - 52px);
        cursor: default; border-left: none; border-right: none;
    }
    .post-page .g-set { padding: 0 8px; box-sizing: border-box; }
    .post-page .g-set-head { font-size: 14px; }
    .post-page .g-set-arrow { padding: 6px 14px; font-size: 22px; }
    .post-page .g-post-text, .post-page .g-admin-tags { padding: 0 12px; box-sizing: border-box; }
}

/* Post page: clicking / tapping the picture (to flip through a set) shows no highlight or outline */
.g-figure, .g-post-image { -webkit-tap-highlight-color: transparent; -webkit-user-select: none; user-select: none; outline: none; }
.g-post-image { -webkit-touch-callout: default; }
