html,
body {
    min-height: 100%;
}

body {
    position: relative;
    min-height: 100vh;
    background-image: none !important;
    background-color: transparent !important;
    --gallery-bg-image: none;
    --gallery-bg-size: 30%;
}

.hand-menu-nav {
    position: sticky;
    top: 0;
    z-index: 130;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    flex-wrap: wrap;
    padding: 10px 12px;
    background: rgba(0, 0, 0, 0.28);
    backdrop-filter: blur(6px);
}

.hand-menu-signature {
    width: min(42vw, 280px);
    height: auto;
    display: block;
    filter: invert(1);
}

.hand-menu-buttons {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: nowrap;
}

.hand-menu-buttons img {
    width: min(17vw, 120px);
    height: auto;
    display: block;
    filter: invert(1);
}

.hand-menu-nav a:focus-visible img {
    animation: hand-menu-jiggle 0.45s ease-in-out;
    transform-origin: center;
}

@media (hover: hover) {
    .hand-menu-nav a:hover img {
        animation: hand-menu-jiggle 0.45s ease-in-out;
        transform-origin: center;
    }
}

@keyframes hand-menu-jiggle {
    0% { transform: rotate(0deg) translateX(0); }
    20% { transform: rotate(-4deg) translateX(-1px); }
    40% { transform: rotate(4deg) translateX(1px); }
    60% { transform: rotate(-3deg) translateX(-1px); }
    80% { transform: rotate(3deg) translateX(1px); }
    100% { transform: rotate(0deg) translateX(0); }
}

body::after {
    content: "";
    position: fixed;
    inset: 0;
    background-image: var(--gallery-bg-image);
    background-size: 30%;
    background-repeat: repeat;
    background-position: top left;
    pointer-events: none;
    z-index: -2;
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    pointer-events: none;
    z-index: -1;
}

#page {
    max-width: none;
    margin: 16px 20px 16px 20px;
    padding: 0;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
}

#page,
main,
#gallery,
footer {
    background: transparent !important;
    border: none !important;
}

footer {
    margin-top: 6px !important;
    padding-top: 0 !important;
    border-top: none !important;
}

#masthead {
    background: transparent;
    border-bottom: none;
    padding: 8px 0 16px;
}

#masthead h1,
#masthead .tagline,
#gallery h2,
#gallery p {
    color: #fff;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.55);
}

.thumbs {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(260px, 100%), 1fr));
    justify-items: center;
    align-items: start;
    gap: 28px;
}

@media (max-width: 900px) {
    #page {
        margin: 16px 12px 16px 12px;
    }
}

.thumbs .thumb {
    position: relative;
    width: auto;
    text-align: initial;
}

.thumbs a.thumb-photo {
    width: auto;
    text-align: initial;
}

.thumb .thumb-photo {
    display: block;
    position: relative;
    overflow: visible;
    background: transparent;
    padding: 0;
    border: none;
    box-shadow: 0 6px 14px rgba(0, 0, 0, 0.22);
    transform: rotate(-0.4deg);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    text-decoration: none;
}

.thumb:nth-child(even) .thumb-photo {
    transform: rotate(0.4deg);
}

.thumb .thumb-photo:focus-visible {
    transform: translateY(-4px) rotate(0deg);
    box-shadow: 0 14px 26px rgba(0, 0, 0, 0.32);
    outline: none;
}

@media (hover: hover) {
    .thumb .thumb-photo:hover {
        transform: translateY(-4px) rotate(0deg);
        box-shadow: 0 14px 26px rgba(0, 0, 0, 0.32);
    }
}

.thumb .thumb-photo img {
    width: auto;
    height: auto;
    display: block;
    object-fit: contain;
    border: 5px solid #fff;
    box-shadow: none;
    transition: filter 0.2s ease;
    filter: brightness(0.75);
    max-width: 100%;
}

/* Long edge of each tile; set by JS via .landscape / .portrait */
.thumbs .thumb .thumb-photo img.landscape {
    width: min(220px, 42vw);
    height: auto;
}

.thumbs .thumb .thumb-photo img.portrait {
    width: auto;
    height: min(220px, 42vw);
}

.thumb-lock {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 2;
    font-size: 18px;
    line-height: 1;
    padding: 6px;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.55);
    pointer-events: none;
}

.thumb-title {
    position: absolute;
    inset: 0;
    margin: 0;
    padding: 10px;
    font-size: 22px;
    font-weight: 700;
    color: #fff;
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    opacity: 1;
    transition: opacity 0.2s ease;
    pointer-events: none;
    z-index: 1;
}

#gallery-shadowbox {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.82);
    z-index: 1100;
    padding: 20px;
}

#gallery-shadowbox[hidden] {
    display: none;
}

#gallery-shadowbox img {
    max-width: min(96vw, 1200px);
    max-height: 84vh;
    max-height: 84dvh;
    width: auto;
    height: auto;
    border: 12px solid #fff;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.55);
    background: #fff;
}

#gallery-shadowbox .shadowbox-caption {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    color: #fff;
    background: rgba(0, 0, 0, 0.72);
    padding: 8px 12px;
    border-radius: 6px;
    white-space: nowrap;
    max-width: calc(100vw - 160px);
    overflow: hidden;
    text-overflow: ellipsis;
}

#gallery-shadowbox .shadowbox-close {
    position: fixed;
    top: 18px;
    right: 18px;
    border: 2px solid #ccc;
    background: #fff;
    border-radius: 6px;
    font-size: 26px;
    line-height: 1;
    padding: 4px 10px;
    min-width: 44px;
    min-height: 44px;
    color: #111;
    cursor: pointer;
}

#gallery-shadowbox .shadowbox-prev,
#gallery-shadowbox .shadowbox-next {
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    border: 2px solid #ccc;
    background: #fff;
    border-radius: 6px;
    font-size: 28px;
    line-height: 1;
    padding: 8px 12px;
    min-width: 44px;
    min-height: 44px;
    color: #111;
    cursor: pointer;
}

#gallery-shadowbox .shadowbox-prev { left: 18px; }
#gallery-shadowbox .shadowbox-next { right: 18px; }

body.shadowbox-open {
    overflow: hidden;
}

/* ---------- Phones ---------- */
@media (max-width: 600px) {
    #page {
        margin: 12px;
    }

    .thumbs {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 14px;
    }

    .thumb .thumb-photo img {
        border-width: 3px;
    }

    .thumb-title {
        font-size: 15px;
        padding: 6px;
    }

    .thumb-lock {
        top: 6px;
        right: 6px;
        font-size: 14px;
        padding: 4px;
    }

    #gallery-shadowbox {
        padding: 12px 8px 76px;
    }

    #gallery-shadowbox img {
        max-width: 94vw;
        max-height: 78vh;
        max-height: 78dvh;
        border-width: 4px;
    }

    #gallery-shadowbox .shadowbox-close {
        top: 10px;
        right: 10px;
    }

    /* Move arrows to the bottom corners so they don't cover the photo */
    #gallery-shadowbox .shadowbox-prev,
    #gallery-shadowbox .shadowbox-next {
        top: auto;
        bottom: 14px;
        transform: none;
    }

    #gallery-shadowbox .shadowbox-prev { left: 12px; }
    #gallery-shadowbox .shadowbox-next { right: 12px; }

    #gallery-shadowbox .shadowbox-caption {
        bottom: 20px;
        font-size: 13px;
        max-width: calc(100vw - 150px);
    }
}

/* ---------- Password-protected galleries ---------- */
.private-title {
    margin: 4px 0 18px;
    text-align: center;
    color: #fff;
    font-size: 28px;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.55);
}

.lock-card {
    max-width: 360px;
    margin: 8vh auto 40px;
    padding: 28px 24px;
    text-align: center;
    color: #fff;
    background: rgba(0, 0, 0, 0.55);
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 10px;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45);
}

.lock-card .lock-icon {
    font-size: 36px;
    line-height: 1;
}

.lock-card h1 {
    margin: 10px 0 6px;
    font-size: 24px;
    color: #fff;
}

.lock-card p {
    margin: 0 0 18px;
    color: #ddd;
    font-size: 14px;
}

.lock-card form {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.lock-card input {
    width: 100%;
    box-sizing: border-box;
    padding: 12px;
    font-size: 16px; /* 16px stops iOS from zooming in on focus */
    border: 2px solid #ccc;
    border-radius: 6px;
}

.lock-card button {
    min-height: 44px;
    font-size: 16px;
    font-weight: 700;
    border: 2px solid #ccc;
    border-radius: 6px;
    background: #fff;
    color: #111;
    cursor: pointer;
}

.lock-card button:disabled {
    opacity: 0.6;
    cursor: wait;
}

.lock-error {
    min-height: 1.2em;
    margin: 4px 0 0;
    color: #ffb3b3;
    font-size: 14px;
}

.lock-card.shake {
    animation: lock-shake 0.4s ease-in-out;
}

@keyframes lock-shake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-8px); }
    40% { transform: translateX(8px); }
    60% { transform: translateX(-5px); }
    80% { transform: translateX(5px); }
}

.photo-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 16px;
}

.photo-grid a {
    display: block;
    aspect-ratio: 3 / 2;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.12);
    border: 4px solid #fff;
    box-shadow: 0 6px 14px rgba(0, 0, 0, 0.22);
}

.photo-grid img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
    transition: transform 0.25s ease;
}

@media (hover: hover) {
    .photo-grid a:hover img {
        transform: scale(1.04);
    }
}

@media (max-width: 600px) {
    .private-title {
        font-size: 22px;
    }

    .lock-card {
        margin-top: 5vh;
        padding: 22px 18px;
    }

    .photo-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
    }

    .photo-grid a {
        border-width: 2px;
    }
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}
