/* =========================================================================
   GÆSTEBILLEDER — upload + galleri
   -------------------------------------------------------------------------
   Shared by /Galleri/ and /admin/. Deliberately uses the existing design
   tokens (--accent-gold, --font-heading, …) instead of redeclaring them, so
   it inherits whichever page stylesheet loaded first.
   ========================================================================= */

/* An explicit `display` beats the UA stylesheet's [hidden] rule, so anything
   below that both sets display and gets toggled via .hidden needs this. */
.wed-upload [hidden] {
    display: none;
}

/* =====================
   UPLOADER
   ===================== */
.wed-upload {
    margin: 2.5rem auto 0;
    max-width: 620px;
    padding: 0 1.2rem;
    text-align: center;
}

/* Who the photos will be credited to. Read-only: it comes from the
   invitation, so there is nothing to fill in. */
.wed-credit {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    margin-bottom: 1.6rem;
}

.wed-credit[hidden] {
    display: none;
}

.wed-credit-label {
    font-size: 0.82rem;
    color: var(--text-light);
}

.wed-credit-name {
    font-family: var(--font-heading);
    font-size: 1.15rem;
    color: var(--text);
}

/* Shared with the admin login's email and password fields, which are the
   only text inputs left in here. */
.wed-name-input {
    width: 100%;
    max-width: 320px;
    padding: 0.85rem 1.1rem;
    border: 1px solid rgba(196, 162, 101, 0.25);
    border-radius: 14px;
    font-size: 1rem;
    font-family: var(--font-body);
    color: var(--text);
    background: rgba(255, 255, 255, 0.6);
    text-align: center;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.wed-name-input:focus {
    outline: none;
    border-color: var(--accent-gold);
    box-shadow: 0 0 0 3px rgba(196, 162, 101, 0.15);
}

.wed-file-input {
    display: none;
}

.upload-cta {
    display: block;
    width: 100%;
    min-height: 56px;
    padding: 1rem 2.5rem;
    border: none;
    border-radius: 50px;
    background-color: var(--accent-gold);
    color: #fff;
    font-family: var(--font-body);
    font-size: 1rem;
    font-weight: 500;
    letter-spacing: 1px;
    text-transform: uppercase;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(196, 162, 101, 0.3);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.3s ease, background-color 0.3s ease;
}

.upload-cta:hover:not(:disabled) {
    transform: translateY(-3px);
    background-color: #b8925a;
    box-shadow: 0 8px 24px rgba(196, 162, 101, 0.4);
}

.upload-cta:active:not(:disabled) {
    transform: translateY(0);
}

.upload-cta:disabled {
    opacity: 0.5;
    cursor: default;
    box-shadow: none;
}

.wed-hint {
    margin-top: 0.8rem;
    font-size: 0.85rem;
    color: var(--text-light);
}

.wed-banner {
    margin-top: 1.2rem;
    padding: 0.9rem 1.1rem;
    border-radius: 14px;
    font-size: 0.9rem;
    line-height: 1.6;
}

.wed-banner.warn {
    background: rgba(196, 162, 101, 0.12);
    border: 1px solid rgba(196, 162, 101, 0.3);
    color: var(--text);
}

.wed-banner.error {
    background: rgba(201, 164, 160, 0.15);
    border: 1px solid rgba(201, 164, 160, 0.4);
    color: var(--text);
}

.wed-summary {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 1rem;
    margin-top: 1.8rem;
    font-size: 0.9rem;
    color: var(--text-light);
    letter-spacing: 1px;
}

.wed-retry-all {
    padding: 0.5rem 1.4rem;
    border: 1px solid var(--accent-gold);
    border-radius: 50px;
    background: none;
    color: var(--accent-gold);
    font-family: var(--font-body);
    font-size: 0.82rem;
    letter-spacing: 1px;
    text-transform: uppercase;
    cursor: pointer;
    transition: background-color 0.3s ease, color 0.3s ease;
}

.wed-retry-all:hover {
    background: var(--accent-gold);
    color: #fff;
}

/* --- Per-file cards --- */
.wed-list {
    list-style: none;
    margin: 1.2rem 0 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.7rem;
}

.upload-card {
    display: flex;
    align-items: center;
    gap: 0.9rem;
    padding: 0.7rem;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.65);
    border: 1px solid rgba(196, 162, 101, 0.18);
    text-align: left;
}

.upload-card.is-done {
    border-color: rgba(138, 154, 120, 0.45);
}

.upload-card.is-failed {
    border-color: rgba(201, 164, 160, 0.55);
}

.upload-thumb {
    width: 56px;
    height: 56px;
    flex-shrink: 0;
    object-fit: cover;
    border-radius: 10px;
    background: rgba(196, 162, 101, 0.1);
}

.upload-meta {
    flex: 1;
    min-width: 0;
}

.upload-status {
    font-size: 0.85rem;
    line-height: 1.5;
    color: var(--text-light);
}

.upload-card.is-done .upload-status {
    color: var(--accent-sage);
}

.upload-card.is-failed .upload-status {
    color: var(--text);
}

.progress {
    margin-top: 0.45rem;
    height: 3px;
    border-radius: 3px;
    background: rgba(196, 162, 101, 0.18);
    overflow: hidden;
}

.progress span {
    display: block;
    width: 0;
    height: 100%;
    background: var(--accent-gold);
    transition: width 0.25s ease;
}

.upload-card.is-done .progress span {
    background: var(--accent-sage);
}

.upload-retry {
    margin-top: 0.5rem;
    padding: 0.35rem 1rem;
    border: 1px solid var(--accent-gold);
    border-radius: 50px;
    background: none;
    color: var(--accent-gold);
    font-family: var(--font-body);
    font-size: 0.78rem;
    letter-spacing: 0.5px;
    cursor: pointer;
}

.upload-retry:hover {
    background: var(--accent-gold);
    color: #fff;
}

/* --- Success card (matches the RSVP success idiom) --- */
.wed-success {
    margin-top: 1.5rem;
    padding: 2rem 1.5rem;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.7);
    border: 1px solid rgba(196, 162, 101, 0.25);
}

.wed-success h3 {
    font-family: var(--font-heading);
    font-size: 1.6rem;
    font-weight: 400;
    font-style: italic;
    margin-bottom: 0.2rem;
}

.wed-success p {
    font-size: 1rem;
    color: var(--text-light);
}

.wed-more {
    margin-top: 1.4rem;
    padding: 0.7rem 1.8rem;
    border: 1px solid var(--accent-gold);
    border-radius: 50px;
    background: none;
    color: var(--accent-gold);
    font-family: var(--font-body);
    font-size: 0.85rem;
    letter-spacing: 1px;
    text-transform: uppercase;
    cursor: pointer;
    transition: background-color 0.3s ease, color 0.3s ease;
}

.wed-more:hover {
    background: var(--accent-gold);
    color: #fff;
}

/* --- Locked until the countdown reaches zero --- */
.wed-locked {
    margin-top: 1.5rem;
    padding: 2.4rem 1.5rem;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.7);
    border: 1px solid rgba(196, 162, 101, 0.25);
    text-align: center;
}

.wed-locked h3 {
    font-family: var(--font-heading);
    font-size: 1.6rem;
    font-weight: 400;
    font-style: italic;
    margin-bottom: 0.2rem;
}

.wed-locked p {
    font-size: 1rem;
    color: var(--text-light);
    max-width: 34rem;
    margin-inline: auto;
}

/* --- Video: not here, use WeTransfer --- */
.wed-video {
    margin-top: 2.4rem;
    padding-top: 1.6rem;
    border-top: 1px solid rgba(196, 162, 101, 0.28);
}

.wed-video-lead {
    font-size: 0.95rem;
    line-height: 1.7;
    color: var(--text-light);
}

.wed-video-lead a {
    color: var(--accent-gold);
    text-underline-offset: 3px;
}

.wed-video-guide {
    margin-top: 0.8rem;
    font-size: 0.85rem;
    color: var(--text-light);
}

.wed-video-guide summary {
    cursor: pointer;
    letter-spacing: 0.5px;
    color: var(--accent-gold);
}

.wed-video-guide ol {
    margin: 0.9rem 0 0;
    /* Numbers outside the text block would sit under the centred column on
       the content pages, so keep the list left-aligned in its own box. */
    padding-left: 1.4rem;
    text-align: left;
    max-width: 30rem;
    margin-inline: auto;
}

.wed-video-guide li {
    margin-bottom: 0.5rem;
    line-height: 1.65;
}

.wed-video-guide .wed-fineprint {
    margin-top: 1rem;
    font-size: 0.8rem;
    line-height: 1.7;
}

/* =====================
   GALLERY
   ===================== */
.wed-gallery {
    margin: 2.5rem auto 0;
    max-width: 1100px;
    padding: 0 1.2rem 3rem;
}

.gallery-count {
    margin-bottom: 1.2rem;
    font-size: 0.85rem;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: var(--text-light);
}

/* --- Whose photos: alle / fotografen / gæsterne --- */
.gallery-filters {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1.2rem;
}

.gallery-filter {
    padding: 0.5rem 1.2rem;
    border: 1px solid rgba(196, 162, 101, 0.5);
    border-radius: 50px;
    background: none;
    color: var(--text-light);
    font-family: var(--font-body);
    font-size: 0.78rem;
    letter-spacing: 1px;
    text-transform: uppercase;
    cursor: pointer;
    transition: background-color 0.25s ease, color 0.25s ease;
}

.gallery-filter:hover {
    color: var(--text);
}

.gallery-filter.is-active {
    background: var(--accent-gold);
    border-color: var(--accent-gold);
    color: #fff;
}

/* --- Whose photos, by name --- */
.gallery-people {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    margin-bottom: 1.2rem;
}

.gallery-people[hidden] {
    display: none;
}

.gallery-people-label {
    font-size: 0.72rem;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--text-light);
    white-space: nowrap;
}

.gallery-people-select {
    max-width: 15rem;
    padding: 0.5rem 2rem 0.5rem 0.9rem;
    border: 1px solid rgba(196, 162, 101, 0.5);
    border-radius: 50px;
    background-color: transparent;
    color: var(--text);
    font-family: var(--font-body);
    font-size: 0.85rem;
    cursor: pointer;

    /* The native arrow varies wildly between platforms and none of them suit
       the rest of this. Drawn here as a data URI so it costs no request. */
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%23c4a265' stroke-width='1.6' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.85rem center;
    background-size: 0.7rem;
    text-overflow: ellipsis;
}

.gallery-people-select:focus-visible {
    outline: 2px solid var(--accent-gold);
    outline-offset: 2px;
}

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

.photo-tile {
    padding: 0;
    border: none;
    border-radius: 10px;
    overflow: hidden;
    cursor: pointer;
    background: rgba(196, 162, 101, 0.08);
    aspect-ratio: 1;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);

    /* With the photographer's images the grid runs to several thousand tiles.
       This lets the browser skip layout and paint for everything off screen,
       which is most of the win of a virtualised list for none of the risk —
       and it simply does nothing on browsers that don't support it.
       contain-intrinsic-size must be given, or skipped tiles collapse to zero
       height and the scrollbar jumps around as you scroll. */
    content-visibility: auto;
    contain-intrinsic-size: auto 200px;
}

.photo-tile:hover {
    transform: scale(1.02);
}

.photo-tile img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0;
    transition: opacity 0.5s ease;
}

.photo-tile.is-loaded img {
    opacity: 1;
}

/* --- Video tiles ---
   The tile is a poster frame like any other thumbnail; these three overlays
   are the only thing that says otherwise. Nothing here loads an MP4. */

.photo-tile.is-video {
    position: relative;
}

.photo-tile.is-video::after {
    /* Darkens the bottom half so the title and duration stay readable over a
       bright frame. */
    content: "";
    position: absolute;
    inset: 40% 0 0;
    background: linear-gradient(to bottom, rgba(26, 23, 23, 0), rgba(26, 23, 23, 0.75));
    pointer-events: none;
}

.tile-play {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 46px;
    height: 46px;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    background: rgba(26, 23, 23, 0.55);
    border: 1.5px solid rgba(255, 255, 255, 0.85);
    pointer-events: none;
    z-index: 1;
}

.tile-play::before {
    /* A triangle made of borders — no extra request for an icon. Nudged right
       because a triangle's optical centre sits left of its bounding box. */
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-40%, -50%);
    border-style: solid;
    border-width: 8px 0 8px 13px;
    border-color: transparent transparent transparent #fff;
}

.tile-duration {
    position: absolute;
    right: 0.5rem;
    bottom: 0.45rem;
    z-index: 1;
    padding: 0.1rem 0.35rem;
    border-radius: 4px;
    background: rgba(26, 23, 23, 0.65);
    color: #fff;
    font-size: 0.7rem;
    font-variant-numeric: tabular-nums;
    pointer-events: none;
}

.tile-title {
    position: absolute;
    left: 0.55rem;
    right: 3.2rem;
    bottom: 0.45rem;
    z-index: 1;
    color: #fff;
    font-size: 0.72rem;
    text-align: left;
    line-height: 1.25;
    /* Two lines, then ellipsis — a long speech title must not push the
       duration off the tile. */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    pointer-events: none;
}

.gallery-sentinel {
    min-height: 2.5rem;
    margin-top: 1.8rem;
    text-align: center;
    font-size: 0.85rem;
    color: var(--text-light);
}

/* =====================
   LIGHTBOX
   ===================== */
body.lightbox-open {
    overflow: hidden;
}

.lightbox {
    width: 100vw;
    max-width: 100vw;
    height: 100svh;
    max-height: 100svh;
    padding: 0;
    border: none;
    background: rgba(26, 23, 23, 0.96);
    overflow: hidden;
}

.lightbox::backdrop {
    background: rgba(26, 23, 23, 0.9);
}

.lightbox-figure {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 3.5rem 1rem 2.5rem;
}

.lightbox-img,
.lightbox-video {
    max-width: 100%;
    max-height: calc(100svh - 8rem);
    object-fit: contain;
    border-radius: 6px;
}

.lightbox-video {
    /* Without a width a <video> with no loaded metadata collapses to its
       300x150 default and the poster sits in a small box in the middle of the
       screen — preload="none" means metadata is exactly what we don't have.
       The real aspect ratio is set per video from the row, in show(). */
    width: 100%;
    height: auto;
    background: #000;
}

.lightbox-img[hidden],
.lightbox-video[hidden] {
    display: none;
}

.lightbox-caption {
    font-family: var(--font-heading);
    font-style: italic;
    font-size: 0.95rem;
    color: rgba(255, 255, 255, 0.75);
    min-height: 1.4em;
}

.lightbox-close,
.lightbox-nav {
    position: absolute;
    border: none;
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    cursor: pointer;
    line-height: 1;
    transition: background-color 0.3s ease;
}

.lightbox-close:hover,
.lightbox-nav:hover {
    background: rgba(255, 255, 255, 0.2);
}

.lightbox-close {
    top: 1rem;
    right: 1rem;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    font-size: 1.6rem;
}

.lightbox-nav {
    top: 50%;
    transform: translateY(-50%);
    width: 48px;
    height: 72px;
    border-radius: 8px;
    font-size: 2rem;
}

.lightbox-nav.prev {
    left: 0.5rem;
}

.lightbox-nav.next {
    right: 0.5rem;
}

/* --- Lightbox toolbar: download / delete --- */
.lightbox-bar {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 0.6rem;
    padding: 0.9rem 1rem calc(0.9rem + env(safe-area-inset-bottom, 0px));
    background: linear-gradient(to top, rgba(26, 23, 23, 0.85), rgba(26, 23, 23, 0));
}

.lightbox-action {
    padding: 0.5rem 1.3rem;
    border: 1px solid rgba(255, 255, 255, 0.35);
    border-radius: 50px;
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    font-family: var(--font-body);
    font-size: 0.82rem;
    letter-spacing: 1px;
    text-transform: uppercase;
    text-decoration: none;
    cursor: pointer;
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.lightbox-action:hover {
    background: rgba(255, 255, 255, 0.2);
}

.lightbox-action.danger {
    border-color: rgba(201, 164, 160, 0.6);
    color: #e8c9c5;
}

.lightbox-action.danger:hover {
    background: rgba(201, 164, 160, 0.25);
}

.lightbox-action.confirm {
    background: rgba(201, 164, 160, 0.9);
    border-color: transparent;
    color: #3a3535;
}

.lightbox-action:disabled {
    opacity: 0.45;
    cursor: default;
}

.lightbox-action[hidden] {
    display: none;
}

.lightbox-note {
    width: 100%;
    text-align: center;
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.7);
}

/* Leave room for the toolbar so it never covers the photo. */
.lightbox-figure {
    padding-bottom: 5.5rem;
}

.lightbox-img,
.lightbox-video {
    max-height: calc(100svh - 12rem);
}

/* Tiles a guest has removed — only ever visible to a signed-in admin. */
.photo-tile.is-deleted {
    opacity: 0.45;
    outline: 2px dashed rgba(201, 164, 160, 0.7);
    outline-offset: -2px;
}

/* =====================
   ADMIN
   ===================== */
.wed-admin {
    max-width: 620px;
    margin: 2rem auto 0;
    padding: 0 1.2rem;
    text-align: center;
}

.wed-admin-form {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.9rem;
}

.wed-admin-form .wed-name-input {
    max-width: 320px;
}

.wed-admin-form .upload-cta {
    max-width: 320px;
}

.wed-admin-error {
    font-size: 0.88rem;
    color: #a8706a;
    min-height: 1.3em;
}

.wed-admin-status {
    font-size: 0.9rem;
    color: var(--text-light);
    margin-bottom: 1rem;
}

.wed-admin-row {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 1.2rem;
}

.wed-admin-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.88rem;
    color: var(--text-light);
    cursor: pointer;
}

.wed-admin-toggle input {
    width: 16px;
    height: 16px;
    accent-color: var(--accent-gold);
}

.wed-fineprint {
    margin-top: 0.6rem;
    font-size: 0.82rem;
    color: var(--text-light);
}

/* =====================
   RESPONSIVE
   ===================== */
@media (max-width: 640px) {
    .photo-grid {
        gap: 0.35rem;
        grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    }

    .wed-gallery {
        padding: 0 0.8rem 2.5rem;
    }

    /* Arrows sit under the thumb on a phone; swiping is the primary gesture. */
    .lightbox-nav {
        width: 40px;
        height: 60px;
        font-size: 1.6rem;
    }

    /* Four tabs overflow 375 px by a hair and wrap 3+1, which reads as a
       mistake rather than a layout. Half-width pills wrap 2+2 on purpose —
       and shrinking them to fit one row would have put every tab under the
       thumb size, which is the wrong trade on the device most guests use. */
    .gallery-filter {
        flex: 0 1 calc(50% - 0.25rem);
        padding: 0.65rem 0.5rem;
        font-size: 0.72rem;
        letter-spacing: 0.5px;
    }

    /* The label above rather than beside it, so a long name has the whole
       width of the phone instead of sharing a line. */
    .gallery-people {
        flex-direction: column;
        gap: 0.4rem;
    }

    .gallery-people-select {
        width: 100%;
        max-width: none;
        /* Comfortably past the thumb-size threshold — this is a menu of forty
           names on a moving bus. */
        padding: 0.7rem 2rem 0.7rem 1rem;
        font-size: 0.9rem;
    }

    /* --- Video tiles on a phone ---
       Measured, not guessed: on a 375 px screen the grid lands on two columns
       of ~153 px, so there is more room here than the 110 px minimum suggests.
       The badge comes down a little; the text mostly needs the width back. */
    .tile-play {
        width: 38px;
        height: 38px;
    }

    .tile-play::before {
        border-width: 7px 0 7px 11px;
    }

    /* Duration moves to the top corner so the title gets the whole width of
       the tile rather than sharing a line with it. */
    .tile-duration {
        top: 0.35rem;
        right: 0.35rem;
        bottom: auto;
        padding: 0.08rem 0.3rem;
        font-size: 0.66rem;
    }

    .tile-title {
        left: 0.4rem;
        right: 0.4rem;
        bottom: 0.35rem;
        font-size: 0.68rem;
        line-height: 1.25;
    }

    /* The scrim only needs to cover the title now. */
    .photo-tile.is-video::after {
        inset: 55% 0 0;
    }

    /* A tall video would otherwise push the caption and the download button
       off the bottom of the screen. */
    .lightbox-video {
        max-height: calc(100svh - 14rem);
    }
}

@media (prefers-reduced-motion: reduce) {

    .upload-cta,
    .photo-tile,
    .photo-tile img,
    .progress span {
        transition: none;
    }
}
