/* Gifts (library/Gifts.php, assets/js/gifts.js): the gift sheet, the gift
 * strip and highlighted messages on posts, the profile's supporters and
 * shelf, and the "gift sent" celebration. Colours come from sb_theme.css's
 * tokens, so light and dark both work; each gift brings its own accent. */

:root {
    --sbg-grad: linear-gradient(135deg, #ff7a59 0%, #e5345b 45%, #8e44ad 100%);
    --sbg-radius: 18px;
}

/* ---- buttons -------------------------------------------------------------- */
.sbg-btn {
    display: inline-flex; align-items: center; gap: 6px;
    border: 0; border-radius: 999px; padding: 6px 14px;
    background: var(--sbg-grad); color: #fff !important;
    font-weight: 700; font-size: 13px; line-height: 1.4; cursor: pointer;
    box-shadow: 0 2px 8px rgba(229, 52, 91, .25);
    transition: transform .15s ease, box-shadow .15s ease;
    text-decoration: none !important; white-space: nowrap;
}
.sbg-btn:hover { transform: translateY(-1px); box-shadow: 0 4px 14px rgba(229, 52, 91, .35); }
.sbg-btn:focus-visible { outline: 3px solid rgba(229, 52, 91, .45); outline-offset: 2px; }
.sbg-btn .sbg-btn-icon { font-size: 15px; line-height: 1; }
.sbg-btn-ghost {
    background: transparent; color: var(--sb-text) !important; box-shadow: none;
    border: 1px solid var(--sb-border);
}
.sbg-btn-ghost:hover { box-shadow: none; background: rgba(127,127,127,.08); }

/* ---- strip on a post -------------------------------------------------------- */
.sbg-strip {
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    padding: 6px 4px 2px; min-height: 34px;
}
.sbg-summary {
    display: inline-flex; align-items: center; gap: 8px; min-width: 0;
    background: none; border: 0; padding: 2px 4px; color: var(--sb-text-muted);
    font-size: 13px; cursor: pointer; border-radius: 10px;
}
.sbg-summary:hover { background: rgba(127,127,127,.08); color: var(--sb-text); }
.sbg-emojis { font-size: 17px; letter-spacing: -3px; }
.sbg-avatars { display: inline-flex; }
.sbg-avatars img {
    width: 22px; height: 22px; border-radius: 50%; object-fit: cover;
    border: 2px solid var(--sb-surface); margin-left: -7px;
}
.sbg-avatars img:first-child { margin-left: 0; }
.sbg-summary-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sbg-summary-text b { color: var(--sb-text); }

/* Highlighted gift messages (pinned while highlight_until is ahead). */
.sbg-highlights { display: flex; flex-direction: column; gap: 6px; padding: 4px 4px 6px; }
.sbg-highlight {
    --accent: #e5345b;
    position: relative; display: flex; gap: 10px; align-items: flex-start;
    padding: 8px 12px 8px 10px; border-radius: 14px;
    background: color-mix(in srgb, var(--accent) 10%, var(--sb-surface));
    border: 1px solid color-mix(in srgb, var(--accent) 45%, transparent);
    font-size: 13px; color: var(--sb-text);
}
.sbg-highlight::before {
    content: ''; position: absolute; left: 0; top: 10px; bottom: 10px; width: 3px;
    border-radius: 3px; background: var(--accent);
}
.sbg-highlight-emoji { font-size: 22px; line-height: 1; padding-top: 2px; }
.sbg-highlight-body { min-width: 0; }
.sbg-highlight-who { font-weight: 700; }
.sbg-highlight-who small { font-weight: 500; color: var(--sb-text-muted); }
.sbg-highlight-note { word-break: break-word; }
.sbg-pin { margin-left: auto; color: var(--sb-text-muted); font-size: 11px; white-space: nowrap; }

/* ---- the sheet -------------------------------------------------------------- */
.sbg-backdrop {
    position: fixed; inset: 0; z-index: 10050;
    background: rgba(10, 12, 20, .55); backdrop-filter: blur(3px);
    display: flex; align-items: center; justify-content: center;
    opacity: 0; transition: opacity .2s ease;
}
.sbg-backdrop.is-open { opacity: 1; }
.sbg-backdrop[hidden] { display: none; }
.sbg-sheet {
    position: relative; width: 100%; max-width: 440px; max-height: calc(100vh - 32px); overflow-y: auto;
    background: var(--sb-surface); color: var(--sb-text);
    border-radius: var(--sbg-radius); padding: 20px 18px 16px;
    box-shadow: 0 24px 60px rgba(0,0,0,.35);
    transform: translateY(16px) scale(.98); transition: transform .25s cubic-bezier(.2,.9,.3,1.2);
}
.sbg-backdrop.is-open .sbg-sheet { transform: none; }
@media (max-width: 600px) {
    .sbg-backdrop { align-items: flex-end; }
    .sbg-sheet { max-width: none; border-radius: var(--sbg-radius) var(--sbg-radius) 0 0; transform: translateY(100%); padding-bottom: 22px; }
}
.sbg-close {
    position: absolute; top: 10px; right: 12px; width: 32px; height: 32px; border-radius: 50%;
    border: 0; background: rgba(127,127,127,.12); color: var(--sb-text); font-size: 20px; line-height: 32px; cursor: pointer;
}
.sbg-head { display: flex; align-items: center; gap: 12px; margin: 0 36px 14px 0; }
.sbg-head img { width: 44px; height: 44px; border-radius: 50%; object-fit: cover; box-shadow: 0 0 0 3px rgba(229,52,91,.25); }
.sbg-title { margin: 0; font-size: 18px; font-weight: 800; color: var(--sb-text); }
.sbg-sub { margin: 2px 0 0; font-size: 13px; color: var(--sb-text-muted); }

.sbg-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.sbg-tile {
    --accent: #e5345b;
    display: flex; flex-direction: column; align-items: center; gap: 2px;
    padding: 12px 6px 10px; border-radius: 16px; cursor: pointer;
    border: 2px solid var(--sb-border); background: var(--sb-surface); color: var(--sb-text);
    transition: transform .15s ease, border-color .15s ease, background .15s ease;
}
.sbg-tile:hover { transform: translateY(-2px); border-color: color-mix(in srgb, var(--accent) 50%, var(--sb-border)); }
.sbg-tile:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 50%, transparent); outline-offset: 2px; }
.sbg-tile.is-selected {
    border-color: var(--accent);
    background: color-mix(in srgb, var(--accent) 12%, var(--sb-surface));
    box-shadow: 0 6px 18px color-mix(in srgb, var(--accent) 30%, transparent);
}
.sbg-tile-emoji { font-size: 34px; line-height: 1.15; }
.sbg-tile.is-selected .sbg-tile-emoji { animation: sbg-wiggle .6s ease; }
.sbg-tile-name { font-size: 12px; font-weight: 700; text-align: center; }
.sbg-tile-price { font-size: 12px; color: var(--sb-text-muted); }

.sbg-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 14px; }
.sbg-label { font-size: 13px; font-weight: 700; }
.sbg-qty { display: inline-flex; gap: 6px; }
.sbg-qty button {
    min-width: 46px; padding: 5px 10px; border-radius: 999px; cursor: pointer;
    border: 1px solid var(--sb-border); background: transparent; color: var(--sb-text); font-weight: 700;
}
.sbg-qty button.is-selected { background: var(--sb-text); color: var(--sb-surface); border-color: var(--sb-text); }
.sbg-note {
    width: 100%; margin-top: 12px; min-height: 64px; resize: vertical; padding: 10px 12px;
    border-radius: 12px; border: 1px solid var(--sb-border); background: transparent; color: var(--sb-text); font-size: 14px;
}
.sbg-note-meta { display: flex; justify-content: space-between; font-size: 12px; color: var(--sb-text-muted); margin-top: 4px; }
.sbg-anon { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; font-weight: 500; margin: 0; }
.sbg-send {
    width: 100%; margin-top: 14px; padding: 12px 16px; border: 0; border-radius: 14px; cursor: pointer;
    background: var(--sbg-grad); color: #fff; font-size: 15px; font-weight: 800;
    box-shadow: 0 8px 22px rgba(229, 52, 91, .3);
}
.sbg-send[disabled] { opacity: .6; cursor: progress; }
.sbg-fine { margin: 10px 0 0; font-size: 11.5px; color: var(--sb-text-muted); text-align: center; }
.sbg-error { margin-top: 10px; color: var(--sb-danger); font-size: 13px; text-align: center; }

/* The list of senders (strip → sheet). */
.sbg-list { list-style: none; margin: 0; padding: 0; }
.sbg-list li { display: flex; align-items: center; gap: 10px; padding: 9px 2px; border-bottom: 1px solid var(--sb-border); }
.sbg-list li:last-child { border-bottom: 0; }
.sbg-list img, .sbg-list .sbg-anon-avatar { width: 38px; height: 38px; border-radius: 50%; object-fit: cover; flex: none; }
.sbg-anon-avatar { display: inline-flex; align-items: center; justify-content: center; background: rgba(127,127,127,.15); font-size: 18px; }
.sbg-list-body { flex: 1; min-width: 0; font-size: 13px; }
.sbg-list-body b { display: block; }
.sbg-list-note { color: var(--sb-text-muted); word-break: break-word; }
.sbg-list-gift { font-size: 22px; }
.sbg-thank { padding: 4px 10px; font-size: 12px; }

/* ---- celebration -------------------------------------------------------------- */
.sbg-celebrate {
    position: fixed; inset: 0; z-index: 10060; pointer-events: none;
    display: flex; align-items: center; justify-content: center; overflow: hidden;
}
.sbg-celebrate-card {
    pointer-events: auto; text-align: center; padding: 26px 26px 20px; max-width: 340px; width: calc(100% - 32px);
    background: var(--sb-surface); color: var(--sb-text); border-radius: 24px;
    box-shadow: 0 30px 80px rgba(0,0,0,.4); animation: sbg-pop .5s cubic-bezier(.2,.9,.3,1.35) both;
}
.sbg-celebrate-emoji { font-size: 84px; line-height: 1; display: inline-block; animation: sbg-float 1.6s ease-in-out infinite; }
.sbg-celebrate-emoji.is-big { font-size: 112px; filter: drop-shadow(0 8px 24px rgba(242,183,5,.55)); }
.sbg-celebrate h3 { margin: 12px 0 4px; font-size: 20px; font-weight: 800; }
.sbg-celebrate p { margin: 0 0 16px; color: var(--sb-text-muted); font-size: 14px; }
.sbg-burst {
    position: absolute; left: 50%; top: 50%; font-size: 26px;
    animation: sbg-burst 1.4s cubic-bezier(.15,.7,.3,1) forwards;
}
.sbg-confetti {
    position: absolute; top: -12px; width: 8px; height: 14px; border-radius: 2px;
    animation: sbg-fall linear forwards;
}

@keyframes sbg-wiggle { 0%,100% { transform: none; } 25% { transform: rotate(-12deg) scale(1.15); } 60% { transform: rotate(10deg) scale(1.1); } }
@keyframes sbg-pop { from { opacity: 0; transform: scale(.6) translateY(30px); } to { opacity: 1; transform: none; } }
@keyframes sbg-float { 0%,100% { transform: translateY(0) rotate(-3deg); } 50% { transform: translateY(-10px) rotate(3deg); } }
@keyframes sbg-burst {
    0% { opacity: 1; transform: translate(-50%, -50%) scale(.4); }
    100% { opacity: 0; transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(1.3) rotate(var(--rot)); }
}
@keyframes sbg-fall { to { transform: translateY(110vh) rotate(720deg); } }

/* ---- profile ------------------------------------------------------------------- */
.sbg-profile { padding: 12px 14px; }
.sbg-profile h4 { margin: 0 0 8px; font-size: 14px; font-weight: 800; }
.sbg-supporters { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 4px; }
.sbg-supporter { display: flex; flex-direction: column; align-items: center; gap: 3px; width: 64px; font-size: 11.5px; text-align: center; color: var(--sb-text) !important; }
.sbg-supporter img { width: 46px; height: 46px; border-radius: 50%; object-fit: cover; }
.sbg-supporter:first-child img { box-shadow: 0 0 0 3px #f2b705; }
.sbg-supporter span { width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sbg-shelf { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.sbg-shelf-item { display: inline-flex; align-items: center; gap: 4px; padding: 4px 10px; border-radius: 999px; background: rgba(127,127,127,.1); font-size: 13px; font-weight: 700; }

/* ---- earnings page ---------------------------------------------------------------- */
.sbg-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.sbg-card { padding: 14px 16px; border-radius: 16px; background: var(--sb-surface); border: 1px solid var(--sb-border); }
.sbg-card small { display: block; color: var(--sb-text-muted); font-weight: 600; }
.sbg-card strong { display: block; font-size: 22px; font-weight: 800; margin-top: 2px; }
.sbg-card.is-primary { background: var(--sbg-grad); color: #fff; border: 0; }
.sbg-card.is-primary small { color: rgba(255,255,255,.85); }

@media (prefers-reduced-motion: reduce) {
    .sbg-sheet, .sbg-backdrop, .sbg-tile, .sbg-btn { transition: none; }
    .sbg-celebrate-card, .sbg-celebrate-emoji, .sbg-tile.is-selected .sbg-tile-emoji { animation: none; }
    .sbg-burst, .sbg-confetti { display: none; }
}
