/* ==========================================================================
   site.css - loaded after styles.css. Gallery viewer, comets, login/admin,
   404 page and small fixes.
   ========================================================================== */

:root { --gold: #ffd700; --panel: rgba(18, 19, 26, 0.86); --line: rgba(255, 255, 255, 0.1); }

/* fix: the shimmer keyframe in styles.css had a typo so it never ran */
@keyframes windowShimmer {
    0%, 100% { opacity: 0.5; filter: brightness(0.9); }
    50% { opacity: 1; filter: brightness(1.3); box-shadow: 0 0 6px rgba(255, 255, 255, 0.4); }
}

:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.social-icons .icon { transition: transform 0.2s; }
.social-icons .icon:hover { transform: translateY(-3px); }

/* ---------- Comets ---------- */
.comet-container {
    position: fixed;
    width: 0; height: 0;
    transform-origin: 0 0;
    pointer-events: none;
    z-index: 1;
}
.comet-container .comet {
    position: absolute;
    left: -3px; top: -3px;
    width: 6px; height: 6px;
    border-radius: 50%;
    background: rgb(var(--head));
    box-shadow:
        0 0 4px 1px rgba(var(--head), 0.95),
        0 0 12px 4px rgba(var(--tail), 0.55),
        0 0 28px 8px rgba(var(--tail), 0.18);
}
.comet-tail {
    position: absolute;
    right: 0; top: -1.5px;
    width: var(--len); height: 3px;
    border-radius: 3px 0 0 3px;
    transform-origin: 100% 50%;
    background: linear-gradient(to right,
        rgba(var(--tail), 0) 0%,
        rgba(var(--tail), 0.25) 45%,
        rgba(var(--tail), 0.7) 82%,
        rgba(var(--head), 0.95) 100%);
    filter: blur(0.4px);
}
.comet-tail::after {
    /* thin bright core down the middle of the tail */
    content: "";
    position: absolute;
    right: 0; top: 1px;
    width: 55%; height: 1px;
    background: linear-gradient(to right, rgba(255, 255, 255, 0), rgba(255, 255, 255, 0.9));
}

/* ---------- Gallery ---------- */
#gallery { align-items: stretch; }
.gallery-header { position: relative; z-index: 30; text-align: center; margin-top: 70px; }
.gallery-header + #gallery { margin-top: 0; }
.gallery-status { grid-column: 1 / -1; text-align: center; color: #bbb; padding: 40px 0; }
.art-open {
    display: block; width: 100%;
    padding: 0 !important; margin: 0 0 10px;
    background: none !important;
    border: 0; border-radius: 8px;
    cursor: zoom-in;
    overflow: hidden;
}
.artwork-card .art-open img {
    display: block; width: 100%; height: auto; margin: 0;
    background: rgba(255, 255, 255, 0.06);
    opacity: 0; transition: opacity 0.35s;
}
.artwork-card .art-open img.loaded { opacity: 1; }

/* ---------- Full-screen viewer ---------- */
html.lb-open, html.lb-open body { overflow: hidden; }
.lb {
    --fade: 1;
    position: fixed; inset: 0;
    z-index: 10000;
    display: grid;
    grid-template-columns: 72px 1fr 72px;
    grid-template-rows: auto 1fr auto;
    background: rgba(8, 9, 14, calc(0.96 * var(--fade)));
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    opacity: 0; transition: opacity 0.2s;
    color: #fff;
    touch-action: pinch-zoom;
}
.lb.open { opacity: 1; }
.lb[hidden] { display: none; }
.lb-top { grid-column: 1 / -1; display: flex; justify-content: space-between; align-items: center; padding: 12px 14px 0 20px; }
.lb-count { font-size: 0.9em; color: #bbb; font-variant-numeric: tabular-nums; }
.lb-stage { grid-column: 2; grid-row: 2; position: relative; display: flex; align-items: center; justify-content: center; min-height: 0; min-width: 0; }
.lb-img {
    max-width: 100%; max-height: 100%;
    width: auto; height: auto;
    object-fit: contain;
    border-radius: 6px;
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.6);
    user-select: none; -webkit-user-drag: none;
    transition: transform 0.25s ease;
}
.lb-img.slide-l { animation: lbInL 0.25s ease; }
.lb-img.slide-r { animation: lbInR 0.25s ease; }
@keyframes lbInL { from { opacity: 0; transform: translateX(40px); } to { opacity: 1; transform: none; } }
@keyframes lbInR { from { opacity: 0; transform: translateX(-40px); } to { opacity: 1; transform: none; } }
.lb-spin {
    position: absolute; right: 12px; bottom: 12px;
    width: 22px; height: 22px;
    border: 3px solid rgba(255, 255, 255, 0.25); border-top-color: var(--gold);
    border-radius: 50%;
    animation: lbSpin 0.8s linear infinite;
    opacity: 0; transition: opacity 0.2s;
}
.lb.loading .lb-spin { opacity: 1; }
@keyframes lbSpin { to { transform: rotate(360deg); } }
.lb .lb-btn {
    display: grid; place-items: center;
    width: 48px !important; height: 48px;
    padding: 0 !important;
    border-radius: 50% !important;
    background: rgba(255, 255, 255, 0.08) !important;
    color: #fff; border: 1px solid rgba(255, 255, 255, 0.12) !important;
    cursor: pointer;
    transition: background 0.2s, color 0.2s, transform 0.15s;
}
.lb .lb-btn:hover { background: var(--gold) !important; color: #000; }
.lb .lb-btn:active { transform: scale(0.94); }
.lb-nav { grid-row: 2; align-self: center; justify-self: center; }
.lb-prev { grid-column: 1; }
.lb-next { grid-column: 3; }
.lb.single .lb-nav { visibility: hidden; }
.lb-cap { grid-column: 1 / -1; text-align: center; padding: 12px 20px calc(18px + env(safe-area-inset-bottom)); }
.lb-cap h2 { margin: 0 0 4px; font-size: 1.15em; }
.lb-cap p { margin: 0; color: #bbb; }
.lb-cap a { color: #add8e6; font-weight: bold; text-decoration: none; }
.lb-cap a:hover { text-decoration: underline; }

@media (max-width: 700px) {
    .lb { grid-template-columns: 0 1fr 0; }
    .lb-stage { padding: 0 6px; }
    .lb-nav { position: fixed; bottom: calc(14px + env(safe-area-inset-bottom)); width: 44px !important; height: 44px; z-index: 2; }
    .lb-prev { left: 14px; }
    .lb-next { right: 14px; }
    .lb-cap { padding-left: 70px; padding-right: 70px; }
}

/* ---------- Age check ---------- */
.age-popup .popup-content { background: var(--panel); border: 1px solid var(--line); backdrop-filter: blur(10px); padding: 28px 24px; width: 340px; border-radius: 14px; }
.age-popup h2 { margin: 0 0 6px; }
.age-note { margin: 0 0 20px; color: #aaa; font-size: 0.95em; }
.age-buttons { display: flex; flex-direction: column; gap: 10px; }
.age-buttons button { width: 100% !important; padding: 12px 16px !important; font-size: 15px; font-weight: bold; }
#ageConfirm { background: var(--gold) !important; color: #000 !important; }
.age-buttons .age-no { background: transparent !important; border: 1px solid rgba(255, 255, 255, 0.25) !important; color: #ddd !important; }

/* ---------- Login ---------- */
.auth-page, .admin-page { min-height: 100vh; }
.auth-page .main-content-wrap { align-items: center; justify-content: center; padding: 40px 16px 240px; box-sizing: border-box; }
.auth-card {
    position: relative; z-index: 25;
    width: 100%; max-width: 380px;
    padding: 32px 28px 24px;
    box-sizing: border-box;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 16px;
    backdrop-filter: blur(12px);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.55);
    text-align: center;
}
.auth-logo img { border-radius: 50%; box-shadow: 0 0 0 3px rgba(255, 215, 0, 0.35), 0 0 24px rgba(255, 215, 0, 0.25); }
.auth-card h1 { margin: 14px 0 4px; font-size: 1.5em; }
.auth-card .auth-subtitle { margin-bottom: 20px; }
.auth-card .custom-form { gap: 14px; }
.auth-msg { margin: 0 0 16px; padding: 10px 12px; border-radius: 8px; font-size: 0.9em; text-align: left; }
.auth-msg.error { background: rgba(255, 74, 74, 0.12); border: 1px solid rgba(255, 74, 74, 0.35); color: #ffb3b3; }
.auth-msg.ok { background: rgba(90, 200, 120, 0.12); border: 1px solid rgba(90, 200, 120, 0.35); color: #b8f0c6; }
.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 70px !important; }
.pw-wrap .pw-toggle {
    position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
    width: auto !important; padding: 6px 10px !important;
    background: transparent !important; color: #aaa; font-size: 13px; font-weight: bold;
}
.pw-wrap .pw-toggle:hover { color: var(--gold); }
.form-submit-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.auth-back { display: inline-block; margin-top: 18px; color: #888; font-size: 0.9em; text-decoration: none; }
.auth-back:hover { color: var(--gold); }
.slim-footer { padding: 0; margin: 0; position: fixed; bottom: 0; left: 0; height: 254px; pointer-events: none; z-index: 1; }

/* ---------- Admin ---------- */
.admin-wrap { position: relative; z-index: 25; width: 100%; max-width: 1100px; margin: 0 auto; padding: 20px 16px 60px; box-sizing: border-box; }
.admin-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.admin-title { display: flex; align-items: center; gap: 10px; }
.admin-title img { border-radius: 50%; }
.admin-title h1 { margin: 0; font-size: 1.4em; }
.admin-links { display: flex; gap: 8px; flex-wrap: wrap; }
.admin-links a { color: #ccc; text-decoration: none; padding: 7px 12px; border: 1px solid var(--line); border-radius: 8px; font-size: 0.9em; background: rgba(255, 255, 255, 0.03); }
.admin-links a:hover { color: var(--gold); border-color: rgba(255, 215, 0, 0.5); }
.admin-links .logout-link { color: #ff8a8a; border-color: rgba(255, 74, 74, 0.3); }

.admin-tabs { display: flex; gap: 6px; margin-bottom: 14px; }
.admin-tabs button {
    width: auto !important;
    background: rgba(255, 255, 255, 0.05) !important;
    color: #ccc; border: 1px solid var(--line) !important;
    padding: 10px 18px !important; border-radius: 10px !important;
    font-size: 15px; font-weight: bold;
}
.admin-tabs button[aria-selected="true"] { background: var(--gold) !important; color: #000; border-color: var(--gold) !important; }
.pill { display: inline-block; min-width: 1.6em; padding: 1px 6px; margin-left: 4px; border-radius: 99px; background: rgba(0, 0, 0, 0.25); font-size: 0.8em; }

.admin-panel { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 22px; backdrop-filter: blur(12px); box-shadow: 0 20px 50px rgba(0, 0, 0, 0.45); }
.add-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 24px; }
.drop {
    display: flex; align-items: center; justify-content: center;
    min-height: 340px;
    border: 2px dashed rgba(255, 255, 255, 0.2);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.02);
    cursor: pointer; text-align: center;
    transition: border-color 0.2s, background 0.2s;
    overflow: hidden;
}
.drop:hover, .drop.over { border-color: var(--gold); background: rgba(255, 215, 0, 0.05); }
.drop.has-file { border-style: solid; cursor: default; }
.drop-empty { display: flex; flex-direction: column; align-items: center; gap: 6px; color: #bbb; padding: 20px; }
.drop-empty svg { color: var(--gold); margin-bottom: 6px; }
.drop-empty strong { color: #fff; font-size: 1.1em; }
.drop-empty small { color: #777; margin-top: 6px; }
.drop-preview { width: 100%; height: 100%; display: flex; flex-direction: column; }
.drop-preview img { flex: 1; min-height: 0; width: 100%; max-height: 420px; object-fit: contain; background: rgba(0, 0, 0, 0.3); }
.drop-meta { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 12px; font-size: 0.85em; color: #aaa; border-top: 1px solid var(--line); }
.drop-meta span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link-btn { width: auto !important; background: none !important; padding: 0 !important; color: var(--gold); font-weight: bold; }
.add-fields { justify-content: center; }
.add-fields .opt { text-transform: none; letter-spacing: 0; font-weight: normal; color: #777; }
.hint { color: #8fd19e; font-size: 0.8em; min-height: 1em; }
.label { font-size: 0.85em; font-weight: bold; text-transform: uppercase; letter-spacing: 1px; color: #aaa; }

.seg { display: inline-flex; padding: 4px; gap: 4px; border-radius: 10px; background: rgba(255, 255, 255, 0.05); border: 1px solid var(--line); align-self: flex-start; }
.seg label { cursor: pointer; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: block; padding: 8px 16px; border-radius: 7px; color: #bbb; font-weight: bold; font-size: 0.9em; transition: background 0.15s, color 0.15s; }
.seg input:checked + span { background: var(--gold); color: #000; }
.seg input:focus-visible + span { outline: 2px solid var(--gold); outline-offset: 2px; }
.seg.small span { padding: 6px 12px; font-size: 0.85em; }

.progress { height: 6px; border-radius: 6px; background: rgba(255, 255, 255, 0.08); overflow: hidden; }
.progress i { display: block; height: 100%; width: 0; background: var(--gold); transition: width 0.15s; }
.form-msg { min-height: 1.2em; margin: 0; font-size: 0.9em; color: #8fd19e; }
.form-msg.bad { color: #ff9a9a; }

.manage-bar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.manage-bar input[type="search"] {
    flex: 1; min-width: 180px;
    background: rgba(255, 255, 255, 0.04); color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.15); border-radius: 8px;
    padding: 9px 12px; font-size: 14px;
}
.manage-bar input[type="search"]:focus { outline: none; border-color: var(--gold); }
.ghost-btn {
    width: auto !important;
    background: rgba(255, 255, 255, 0.06) !important;
    border: 1px solid rgba(255, 255, 255, 0.15) !important;
    color: #ddd; padding: 7px 12px !important; border-radius: 8px !important;
    font-size: 13px; font-weight: bold;
}
.ghost-btn:hover { border-color: var(--gold) !important; color: var(--gold); }
.ghost-btn.primary { background: var(--gold) !important; color: #000; border-color: var(--gold) !important; }
.ghost-btn.danger { color: #ff9a9a; }
.ghost-btn.danger:hover { border-color: #ff6b6b !important; color: #ff6b6b; }
.ghost-btn:disabled { opacity: 0.5; }
.icon-btn {
    width: 32px !important; height: 32px; padding: 0 !important;
    background: rgba(255, 255, 255, 0.06) !important;
    border: 1px solid rgba(255, 255, 255, 0.15) !important;
    color: #ddd; border-radius: 8px !important; font-size: 15px;
}
.icon-btn:hover { border-color: var(--gold) !important; color: var(--gold); }

.manage-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; }
.m-card { background: rgba(255, 255, 255, 0.04); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; display: flex; flex-direction: column; }
.m-img { position: relative; aspect-ratio: 1; background: rgba(0, 0, 0, 0.35); }
.m-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.m-tag { position: absolute; top: 8px; left: 8px; padding: 2px 7px; border-radius: 6px; font-size: 11px; font-weight: bold; background: #c2185b; color: #fff; }
.m-tag.warn { left: auto; right: 8px; background: rgba(0, 0, 0, 0.7); color: #ffd27a; }
.m-body { padding: 10px 12px 4px; }
.m-body h3 { margin: 0; font-size: 0.95em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.m-body p { margin: 2px 0 0; font-size: 0.85em; }
.m-actions { display: flex; gap: 6px; padding: 8px 12px 12px; margin-top: auto; flex-wrap: wrap; align-items: center; }
.confirm-q { width: 100%; font-size: 0.85em; color: #ffb3b3; }
.m-edit { padding: 10px 12px 0; gap: 8px !important; }
.m-edit label { display: flex; flex-direction: column; gap: 4px; font-size: 0.75em; color: #aaa; text-transform: uppercase; letter-spacing: 1px; font-weight: bold; }
.m-edit input[type="text"], .m-edit input:not([type]), .m-edit input[type="url"] { padding: 8px 10px !important; font-size: 14px !important; text-transform: none; letter-spacing: 0; }
.m-edit .seg label { text-transform: none; letter-spacing: 0; font-size: 1em; }
.m-edit .m-actions { padding: 4px 0 12px; }
.muted { color: #999; }
.center { text-align: center; grid-column: 1 / -1; }

.admin-toast {
    position: fixed; left: 50%; bottom: 24px;
    transform: translate(-50%, 20px);
    max-width: calc(100% - 32px);
    padding: 12px 18px; border-radius: 10px;
    background: #1d2b22; border: 1px solid rgba(90, 200, 120, 0.5); color: #c9f5d5;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    opacity: 0; pointer-events: none; transition: opacity 0.2s, transform 0.2s;
    z-index: 9000;
}
.admin-toast.show { opacity: 1; transform: translate(-50%, 0); }
.admin-toast.bad { background: #2b1d1d; border-color: rgba(255, 90, 90, 0.5); color: #ffc9c9; }

@media (max-width: 760px) {
    .add-grid { grid-template-columns: 1fr; }
    .drop { min-height: 200px; }
    .admin-panel { padding: 14px; }
    .manage-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
}
@media (max-width: 600px) {
    .admin-tabs button, .admin-wrap button, .auth-card button { width: auto; }
    .auth-card .form-submit-btn { width: 100% !important; }
}

/* ---------- 404 ---------- */
.nf-page .main-content-wrap { align-items: center; justify-content: flex-start; }
.nf-content { position: relative; z-index: 25; text-align: center; padding: 60px 16px 0; max-width: 560px; margin: 0 auto; }
.moon-scene { width: min(420px, 88vw); height: auto; display: block; margin: 0 auto -10px; overflow: visible; }
.moon-glow { animation: moonPulse 6s ease-in-out infinite; transform-origin: 190px 140px; }
@keyframes moonPulse { 0%, 100% { opacity: 0.8; transform: scale(1); } 50% { opacity: 1; transform: scale(1.04); } }
.swing { transform-origin: 352px 84px; animation: swing 4.5s ease-in-out infinite; }
@keyframes swing { 0%, 100% { transform: rotate(2.5deg); } 50% { transform: rotate(-2.5deg); } }
.fisher { animation: bob 4.5s ease-in-out infinite; transform-origin: 230px 186px; }
@keyframes bob { 0%, 100% { transform: rotate(0); } 50% { transform: rotate(-1.2deg); } }
.nf-content h1 { margin: 10px 0 8px; font-size: 2em; }
.nf-content p { color: #bbb; margin: 0 0 22px; line-height: 1.5; }
.nf-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.nf-btn { display: inline-block; padding: 12px 20px; border-radius: 8px; background: var(--gold); color: #000; font-weight: bold; text-decoration: none; transition: transform 0.15s, box-shadow 0.2s; }
.nf-btn:hover { transform: translateY(-2px); box-shadow: 0 6px 18px rgba(255, 215, 0, 0.3); }
.nf-btn.ghost { background: transparent; color: #ddd; border: 1px solid rgba(255, 255, 255, 0.25); }
.nf-btn.ghost:hover { color: var(--gold); border-color: var(--gold); box-shadow: none; }

@media (prefers-reduced-motion: reduce) {
    .swing, .fisher, .moon-glow, .star, .sparkle-window { animation: none !important; }
    .lb-img, .lb { transition: none; }
}

/* hidden parts of the drop zone must stay hidden (their display:flex was overriding it) */
.drop [hidden], .admin-panel[hidden] { display: none !important; }
.drop.has-file { align-items: stretch; }

/* skyline canvas draws its own sky glow, so the old box behind it isn't needed */
#buildings-container { background: none !important; }

/* phones: the home page fits the screen with no scrolling */
@media (max-width: 768px) {
    body.home { --sky: min(200px, 26vh); height: 100vh; height: 100dvh; min-height: 0; overflow: hidden; overscroll-behavior: none; }
    body.home .main-content-wrap { flex: 1 1 auto; min-height: 0; justify-content: center; padding: 60px 0 var(--sky); box-sizing: border-box; }
    body.home .centered-content { margin: 0 auto !important; }
    body.home .centered-content h1 { margin: 0 0 8px; }
    body.home .centered-content > p { margin: 0; }
    body.home .homepage-projects-grid { margin-top: 18px; gap: 12px; }
    body.home .homepage-project-card { padding: 14px 18px; }
    body.home .homepage-project-card h3 { margin-bottom: 6px; }
    body.home .homepage-project-card p { margin: 0 0 8px; }
    body.home footer { position: fixed; left: 0; bottom: 0; width: 100%; height: var(--sky); padding: 0; margin: 0; }
    body.home #buildings-container { height: var(--sky); }
    body.home .social-icons { bottom: 30px; }
}
@media (max-width: 768px) and (max-height: 700px) {
    body.home .main-content-wrap { padding-top: 70px; }
    body.home .centered-content > p { display: none; }
}
@media (max-width: 768px) and (max-height: 560px) {
    body.home .homepage-project-card p { display: none; }
}
/* three project cards: tighten things up so the phone home page still fits with no scrolling */
@media (max-width: 768px) {
    body.home .main-content-wrap { padding-top: 64px; }
    body.home .homepage-projects-grid { margin-top: 12px; gap: 9px; }
    body.home .homepage-project-card { padding: 10px 16px; }
    body.home .homepage-project-card h3 { margin-bottom: 4px; }
    body.home .homepage-project-card p { font-size: 14px; line-height: 1.3; margin: 0 0 5px; }
}
@media (max-width: 768px) and (max-height: 860px) { body.home .centered-content > p { display: none; } }
@media (max-width: 768px) and (max-height: 640px) { body.home .homepage-project-card p { display: none; } }