/* =========================================================
   FRONT PAGE BIRTHDAY PARTY  (css/birthday-party.css, with js/birthdayParty.js)
   ---------------------------------------------------------
   A tiny floating celebration (row or button) above the bottom doors, plus
   a popup with the full list, for three kinds of celebration that share it:
   welcome (new members), birthdays and anniversaries. All of it is created
   by js/birthdayParty.js inside #frontPage, only when there is something to
   celebrate, so otherwise nothing here is ever on the page.
   The popup's backdrop gif and gradient depend on the kind
   (.bp-modal[data-type]): assets/welcome.gif, assets/birthday.gif,
   assets/anniversary.gif.

   WHERE THINGS GO is decided by the script from measured positions (see
   chooseMode() in js/birthdayParty.js), which sets the row's left / right /
   bottom itself:
     side    row left of the centerpiece, just above the doors (wide screens);
             the popup also opens in that left space
     below   row in the strip between the centerpiece and the doors
             (phones, portrait tablets), left of the share button when that
             is above the doors
     button  no room for a row: #frontBirthdayButton, the same size as
             #frontShareButton and its horizontal mirror (left side)
   Only the button's own position is in this file, mirrored from
   #frontShareButton in css/front-page.css (keep them in step):
     wide      left:clamp(60px,5vw,20%)   bottom:0
     <=700px   left:clamp(5px,5vw,15%)    bottom:clamp(110px,20vw,25%)

   The row adapts to the width it is given (container query below):
   smaller gif and text, then a stacked layout.
   ========================================================= */

#frontBirthdayParty,
#frontBirthdayButton,
.bp-modal{
    --bp-gold:linear-gradient(135deg,#ffe27a 0%,#e3a82b 55%,#b9770e 100%);
    --bp-shadow:0 2px 3px rgba(0,0,0,.55), 0 0 10px rgba(0,0,0,.3);
    --bp-row-shadow:0 2px 3px rgba(0,0,0,.7), 0 0 10px rgba(0,0,0,.42);   /* the front-page text box: a touch stronger than the popup's */
}

#frontBirthdayParty[hidden],
#frontBirthdayButton[hidden],
.bp-modal[hidden]{display:none!important;}

/* ---------------------------------------------------------
   The row (left / right / bottom are set by the script)
   --------------------------------------------------------- */
#frontBirthdayParty{
    position:absolute;
    left:10px;
    bottom:0;
    z-index:150;                           /* above doors (20/50), below share button (200) */

    container:bp / inline-size;
    pointer-events:none;                   /* only the row itself is tappable */
    color:#fff;
    font-family:Inter,Arial,sans-serif;
}

/* between kinds (and before it fades in) the row is not tappable */
#frontBirthdayParty:not(.is-on) .bp-row{pointer-events:none;}

/* while the popup is open the row steps aside */
#frontBirthdayParty.is-hushed .bp-row{
    opacity:0!important;
    pointer-events:none;
}

#frontBirthdayParty .bp-row{
    --bp-gif:72px;
    --bp-title:16px;
    --bp-name:17px;

    display:flex;
    align-items:center;
    gap:10px;
    max-width:100%;
    margin:0;
    padding:0;
    border:0;
    border-radius:12px;
    background:transparent;                /* fully transparent, as asked */
    color:inherit;
    font:inherit;
    text-align:left;
    cursor:pointer;
    pointer-events:auto;
    appearance:none;
    -webkit-appearance:none;
    -webkit-tap-highlight-color:transparent;
    touch-action:manipulation;

    opacity:0;
    transform:translateY(8px);
    transition:opacity .45s ease, transform .45s ease;
}

#frontBirthdayParty.is-on .bp-row{
    opacity:1;
    transform:none;
}

#frontBirthdayParty .bp-row:focus-visible{
    outline:2px solid #fff;
    outline-offset:4px;
}

/* Gif box. The gifs are transparent, so nothing sits behind them;
   the gradient disc only appears if a gif cannot be loaded. */
#frontBirthdayParty .bp-gif{
    position:relative;
    flex:0 0 auto;
    width:var(--bp-gif);
    height:var(--bp-gif);
    border-radius:50%;
}

#frontBirthdayParty .bp-gif img{
    position:absolute;
    inset:0;
    display:block;
    width:100%;
    height:100%;
    object-fit:contain;
    opacity:1;
    filter:drop-shadow(0 1px 2px rgba(0,0,0,.35));
    transition:opacity .25s ease;
    user-select:none;
    -webkit-user-drag:none;
    pointer-events:none;
}

#frontBirthdayParty .bp-gif img.is-out{opacity:0;}

#frontBirthdayParty .bp-gif.is-fallback{
    background:var(--bp-gold);
    box-shadow:0 0 14px rgba(255,214,102,.6);
}
#frontBirthdayParty .bp-gif.is-fallback img{visibility:hidden;}

/* Text: white with a soft shadow, two stacked lines. */
#frontBirthdayParty .bp-text{
    display:flex;
    flex-direction:column;
    gap:2px;
    min-width:0;
    color:#fff;
    text-shadow:var(--bp-row-shadow);
}

#frontBirthdayParty .bp-title{
    transition:opacity .28s ease;
    position:relative;
    align-self:flex-start;
    padding-bottom:5px;                    /* room for the white line */
    font-size:var(--bp-title);
    font-weight:800;
    letter-spacing:.07em;
    line-height:1.15;
    white-space:nowrap;
}

#frontBirthdayParty .bp-title.is-out{opacity:0;}

/* white separator under the title, as long as the title, above the names */
#frontBirthdayParty .bp-title::after{
    content:"";
    position:absolute;
    left:0;
    right:0;
    bottom:0;
    height:2px;
    border-radius:2px;
    background:#fff;
    box-shadow:0 1px 2px rgba(0,0,0,.5);
}

#frontBirthdayParty .bp-name{
    display:flex;
    align-items:baseline;
    gap:.45em;
    min-height:1.3em;
    font-size:var(--bp-name);
    font-weight:600;
    letter-spacing:.035em;                 /* names a little more open for legibility (the title keeps .07em) */
    line-height:1.3;
    white-space:nowrap;
    overflow:hidden;
    transition:opacity .28s ease;
}
#frontBirthdayParty .bp-name.is-out{opacity:0;}

/* the name gives way (ellipsis) before the "3 years" / milestone text does */
#frontBirthdayParty .bp-name-main{
    min-width:0;
    overflow:hidden;
    text-overflow:ellipsis;
}
#frontBirthdayParty .bp-name-extra{flex:0 0 auto;}
#frontBirthdayParty .bp-name-extra:empty{display:none;}
#frontBirthdayParty .bp-name-extra::before{content:"\00B7";margin-right:.45em;}

/* Fit the row to the width it was given (see "WHERE THE ROW SITS").
   The selectors repeat #frontBirthdayParty so they outrank the defaults above. */
@container bp (max-width:299px){
    #frontBirthdayParty .bp-row{--bp-gif:60px;--bp-title:14px;--bp-name:15px;}
    /* the padding / negative margin keep the title's shadow from being clipped */
    #frontBirthdayParty .bp-title{
        max-width:calc(100% + 16px);
        margin:-8px;
        padding:8px 8px 13px;
        overflow:hidden;
        text-overflow:ellipsis;
    }
    #frontBirthdayParty .bp-title::after{left:8px;right:8px;bottom:8px;}
}
@container bp (max-width:219px){
    #frontBirthdayParty .bp-row{--bp-gif:48px;--bp-title:12px;--bp-name:13.5px;gap:8px;}
}
/* Very narrow strip: stack the gif above the text. */
@container bp (max-width:149px){
    #frontBirthdayParty .bp-row{--bp-gif:44px;--bp-title:11px;--bp-name:12.5px;flex-direction:column;gap:2px;text-align:center;}
    #frontBirthdayParty .bp-text{align-items:center;max-width:100%;}
    #frontBirthdayParty .bp-title{align-self:center;}
}
/* No room: stay out of the way. */
@container bp (max-width:99px){
    #frontBirthdayParty .bp-row{display:none;}
}

/* ---------------------------------------------------------
   The popup
   --------------------------------------------------------- */
.bp-modal{
    position:absolute;
    inset:0;
    z-index:310;                           /* above the share panel (300) */
    display:grid;
    place-items:center;
    padding:16px;
    box-sizing:border-box;
    visibility:hidden;
    pointer-events:none;
    font-family:Inter,"Segoe UI",Roboto,Arial,sans-serif;
}

.bp-modal.is-open{
    visibility:visible;
    pointer-events:auto;
}

.bp-modal-backdrop{
    position:absolute;
    inset:0;
    background:rgba(0,0,0,.5);
    opacity:0;
    transition:opacity .2s ease;
}
.bp-modal.is-open .bp-modal-backdrop{opacity:1;}

.bp-card{
    position:relative;
    display:flex;
    flex-direction:column;
    align-items:center;
    box-sizing:border-box;
    width:min(100%,400px);
    max-height:min(88dvh,640px);
    padding:20px 18px 18px;
    border-radius:22px;
    overflow:hidden;
    color:#fff;
    text-shadow:var(--bp-shadow);

    /* assets/birthday.gif over a teal gradient. The gradient is also the
       fallback: if the gif cannot be loaded the card simply stays teal. */
    background:
        url("../assets/birthday.gif") center / cover no-repeat,
        linear-gradient(160deg,#00897b 0%,#00606a 52%,#0e351f 100%);
    box-shadow:0 18px 50px rgba(0,0,0,.45), 0 0 0 1px rgba(255,255,255,.2);

    opacity:0;
    transform:translateY(10px) scale(.97);
    transition:opacity .2s ease, transform .2s ease;
}
.bp-modal.is-open .bp-card{
    opacity:1;
    transform:none;
}

/* welcome and anniversary: their own backdrop gif over their own gradient
   (the gradient is also the fallback if the gif cannot be loaded) */
.bp-modal[data-type="welcome"] .bp-card{
    background:
        url("../assets/welcome.gif") center / cover no-repeat,
        linear-gradient(160deg,#18a58a 0%,#0b7a74 52%,#0e351f 100%);
}
.bp-modal[data-type="anniversary"] .bp-card{
    background:
        url("../assets/anniversary.gif") center / cover no-repeat,
        linear-gradient(160deg,#d69a1c 0%,#a56a0b 52%,#5c3a05 100%);
}
.bp-modal[data-type="anniversary"] .bp-card-list{
    background:rgba(52,28,0,.5);
}

.bp-close{
    position:absolute;
    top:10px;
    right:10px;
    z-index:2;
    display:grid;
    place-items:center;
    width:36px;
    height:36px;
    margin:0;
    padding:0;
    border:0;
    border-radius:50%;
    background:rgba(255,255,255,.18);
    color:#fff;
    cursor:pointer;
    -webkit-tap-highlight-color:transparent;
}
.bp-close:hover{background:rgba(255,255,255,.3);}
.bp-close:focus-visible{outline:2px solid #fff;outline-offset:2px;}
.bp-close svg{width:18px;height:18px;display:block;}

.bp-card-gif{
    position:relative;
    flex:0 0 auto;
    width:132px;
    height:132px;
    margin-top:2px;
    border-radius:50%;
}
.bp-card-gif img{
    position:absolute;
    inset:0;
    display:block;
    width:100%;
    height:100%;
    object-fit:contain;
    user-select:none;
    -webkit-user-drag:none;
}
.bp-card-gif.is-fallback{
    background:var(--bp-gold);
    box-shadow:0 0 26px rgba(255,214,102,.55);
}
.bp-card-gif.is-fallback img{visibility:hidden;}

.bp-card-title{
    position:relative;
    flex:0 0 auto;
    margin:8px 0 14px;
    padding-bottom:10px;
    font-size:clamp(19px,5.6vw,24px);
    font-weight:800;
    letter-spacing:.07em;
    line-height:1.15;
    text-align:center;
    color:#fff;
}
.bp-card-title::after{
    content:"";
    position:absolute;
    left:20%;
    right:20%;
    bottom:0;
    height:3px;
    border-radius:2px;
    background:var(--bp-gold);
}

.bp-card-sub{
    flex:0 0 auto;
    margin:-4px 0 12px;
    font-size:14px;
    font-weight:500;
    letter-spacing:.04em;
    text-align:center;
}
.bp-card-sub[hidden]{display:none;}

.bp-card-list{
    flex:1 1 auto;
    box-sizing:border-box;
    width:100%;
    min-height:0;
    margin:0;
    padding:4px 16px;
    list-style:none;
    overflow-y:auto;
    overscroll-behavior:contain;
    border-radius:14px;
    background:rgba(0,40,44,.55);
    -webkit-overflow-scrolling:touch;
}
.bp-card-list li{
    padding:10px 4px;
    font-size:17px;
    font-weight:500;
    line-height:1.3;
    text-align:center;
    overflow-wrap:anywhere;
    border-bottom:1px solid rgba(255,255,255,.16);
}
.bp-card-list li:last-child{border-bottom:0;}
.bp-li-name{display:block;}
.bp-li-extra{
    display:block;
    margin-top:2px;
    font-size:13px;
    font-weight:500;
    opacity:.9;
}
/* 5, 10, 15 ... year anniversaries stand out */
.bp-card-list li.is-milestone .bp-li-name{font-weight:700;}
.bp-card-list li.is-milestone .bp-li-extra{
    color:#ffe27a;
    font-weight:700;
    opacity:1;
}

/* ---------------------------------------------------------
   The button: same size as #frontShareButton, mirrored to the left
   --------------------------------------------------------- */
#frontBirthdayButton{
    position:fixed;
    left:clamp(60px,5vw,20%);
    bottom:0;
    z-index:200;

    width:60px;
    height:60px;
    box-sizing:border-box;
    margin:0;
    padding:8px;

    display:flex;
    align-items:center;
    justify-content:center;

    border:none;
    border-radius:8px;
    background:transparent;

    cursor:pointer;
    pointer-events:auto;
    appearance:none;
    -webkit-appearance:none;
    -webkit-tap-highlight-color:transparent;
    touch-action:manipulation;

    opacity:0;
    transition:filter .2s ease, transform .2s ease, opacity .45s ease;
}

#frontBirthdayButton.is-on{opacity:1;}
#frontBirthdayButton:not(.is-on){pointer-events:none;}

#frontBirthdayButton .bp-btn-gif{
    position:relative;
    display:block;
    width:70%;
    height:70%;
    border-radius:50%;
    pointer-events:none;
}

#frontBirthdayButton .bp-btn-gif img{
    position:absolute;
    inset:0;
    display:block;
    width:100%;
    height:100%;
    margin:0;
    padding:0;
    object-fit:contain;
    user-select:none;
    -webkit-user-drag:none;
    pointer-events:none;
}

/* gif missing: gold gradient disc with a small white star */
#frontBirthdayButton .bp-btn-gif .bp-star{display:none;}
#frontBirthdayButton .bp-btn-gif.is-fallback{
    background:var(--bp-gold);
    box-shadow:0 0 12px rgba(255,214,102,.6);
}
#frontBirthdayButton .bp-btn-gif.is-fallback img{visibility:hidden;}
#frontBirthdayButton .bp-btn-gif.is-fallback .bp-star{
    display:block;
    position:absolute;
    inset:22%;
    width:56%;
    height:56%;
}

#frontBirthdayButton:hover{
    filter:brightness(1.12);
    transform:translateY(-2px);
}
#frontBirthdayButton:active{
    transform:translateY(0) scale(.96);
}
#frontBirthdayButton:focus-visible{
    outline:2px solid #fff;
    outline-offset:3px;
}

@media (max-width:700px){
    #frontBirthdayButton{
        left:clamp(5px,5vw,15%);
        bottom:clamp(110px,20vw,25%);
    }
}

/* ---------------------------------------------------------
   Popup placed beside the centerpiece (wide screens): the script sets
   --bp-side-left / -width / -top / -bottom. No dimming, so the
   centerpiece stays fully visible; tapping outside still closes it.
   --------------------------------------------------------- */
.bp-modal[data-placement="side"]{
    place-items:center start;
    padding:var(--bp-side-top) 0 var(--bp-side-bottom) var(--bp-side-left);
}
.bp-modal[data-placement="side"] .bp-modal-backdrop{
    background:transparent;
}
.bp-modal[data-placement="side"] .bp-card{
    width:var(--bp-side-width);
    max-height:100%;
}

@media (prefers-reduced-motion:reduce){
    #frontBirthdayParty .bp-row,
    #frontBirthdayParty .bp-gif img,
    #frontBirthdayParty .bp-name,
    #frontBirthdayButton,
    .bp-modal-backdrop,
    .bp-card{transition:none;}
}
