/* ===========================================================================
 * profile-deferred.css — non-critical styles for /{username} pages.
 *
 * Loaded asynchronously via preload+onload swap. Everything in this file
 * styles content that is either:
 *   - hidden by default (modals, toasts), or
 *   - only reachable after user interaction (share modal, crop modal).
 *
 * Cannot cause CLS on initial paint because the elements it targets aren't
 * part of the initial layout.
 * ========================================================================= */


/* ---------------------------------------------------------------------------
 * Copy-to-clipboard toast (hidden by default; fires on URL copy).
 * ------------------------------------------------------------------------- */
.copy-notification {
    color: #ffffff;
    -webkit-transition: all 0.4s ease-in-out !important;
    transition: all 0.4s ease-in-out !important;
    background: #183b56;
    padding: 20px;
    border-radius: 30px;
    position: fixed;
    top: 50%;
    left: 50%;
    margin-top: -30px;
    margin-left: -85px;
    display: none;
    text-align: center;
    z-index: 10000;
}
.copy { cursor: pointer; }


/* ---------------------------------------------------------------------------
 * Avatar cropping modal (owner view, opens on avatar upload).
 * ------------------------------------------------------------------------- */
.crop-modal {
    display: none;
    position: fixed;
    z-index: 2001;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.9);
}
.crop-container {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}
.crop-area {
    max-width: 90%;
    max-height: 80vh;
    margin: 20px auto;
}
.crop-controls {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.8);
    padding: 15px;
    border-radius: 10px;
    display: flex;
    gap: 10px;
}
.crop-controls button {
    padding: 8px 15px;
    border: none;
    border-radius: 5px;
    background: #4477ff;
    color: white;
    cursor: pointer;
}
.crop-controls button:hover { background: #31e7fa; }

@media screen and (max-width: 768px) {
    .share_icon {
        width: 80px !important;
        position: absolute;
        right: 0;
        top: 130px;
    }
}


/* ===========================================================================
 * Share modal (opens on click of hero H1 / share button).
 * Everything below this line is inside the modal and hidden until triggered.
 * ========================================================================= */

.share-modal-body {
    padding: 20px 25px 25px;
    overflow-y: auto;
    max-height: calc(75vh - 90px);
}
.share-modal-body .copy {
    display: flex; align-items: center; justify-content: space-between;
    gap: 12px; padding: 12px 16px;
    border: 2px solid #e2eef1; border-radius: 10px;
    cursor: pointer; user-select: all;
    transition: border-color .2s ease, background .2s ease;
}
.share-modal-body .copy:hover { border-color: #566ffe; background: #f8f9ff; }
.share-modal-body .copy span:first-child {
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    font-weight: 500;
}

/* Two-column layout: social tiles on the left, always-visible QR on the right.
   Desktop: left column is capped so the 6 platform tiles fall into a clean 3×2
   grid; space-between pushes QR to the right edge of the modal body.
   Mobile: flex-column so QR stacks below the grid. */
.share-layout {
    display: flex;
    gap: 20px;
    align-items: flex-start;
    justify-content: space-between;
    margin-top: 18px;
}
.share-layout-left  { flex: 0 1 auto; min-width: 0; }
.share-layout-right {
    flex: 0 0 140px;
    text-align: center;
}
@media (max-width: 540px) {
    .share-layout { flex-direction: column; justify-content: flex-start; }
    .share-layout-left  { flex: 1 1 auto; width: 100%; }
    .share-layout-right { flex: 0 0 auto; align-self: center; }
}

.share-grid-heading {
    font-size: 11px; font-weight: 600; color: #6f7d95;
    text-transform: uppercase; letter-spacing: .8px;
    margin: 0 0 12px 4px;
}

/* Flex (not grid) so the last row centers when it's under-full — matters most
   on mobile where native-share pushes the count to 7 (4+3).
   Desktop: max-width caps the grid at 3 tiles per row so 6 platforms render as
   a clean 3×2 instead of an awkward 5+1 orphan. Math: 3×76 + 2×8 = 244. */
.share-grid {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 16px 8px;
    max-width: 248px;
}
@media (max-width: 540px) {
    .share-grid { max-width: none; }
}

.share-tile {
    flex: 0 0 76px;
    display: flex; flex-direction: column; align-items: center; gap: 6px;
    text-decoration: none; color: inherit;
    padding: 4px 2px; border-radius: 12px;
    background: transparent; border: 0;
    cursor: pointer;
    transition: transform .15s ease;
}
.share-tile:hover { transform: translateY(-2px); text-decoration: none; color: inherit; }
.share-tile:hover .share-tile-icon { box-shadow: 0 6px 18px rgba(24,59,86,.18); }
.share-tile:focus { outline: none; }
.share-tile:focus-visible .share-tile-icon {
    box-shadow: 0 0 0 3px rgba(86,111,254,.35);
}

.share-tile-icon {
    width: 52px; height: 52px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    color: #fff;
    transition: box-shadow .15s ease;
}
.share-tile-icon i   { font-size: 24px; line-height: 1; }
.share-tile-icon svg { width: 22px; height: 22px; }

.share-tile-label {
    font-size: 11px; font-weight: 500; color: #183b56;
    text-align: center; line-height: 1.2;
    max-width: 72px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* Mobile: shrink the modal header so long profile names like
   "Compartir Joan Capdevila" don't push the close button off-screen. */
@media (max-width: 540px) {
    #shareModal .last-visited-header { padding: 14px 18px; }
    #shareModal .last-visited-header h3 {
        font-size: 15px;
        gap: 8px;
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    #shareModal .last-visited-header h3 i { font-size: 16px; flex-shrink: 0; }
}

/* Per-brand backgrounds. Colors are the platforms' own, so they read the
   same in light and dark mode — no dark-mode override needed for these. */
.st-native    .share-tile-icon { background: radial-gradient(100% 100% at 53.13% 0%, #31e7fa 0%, #4477ff 52.6%, #db74ff 100%); }
.st-facebook  .share-tile-icon { background: #1877F2; }
.st-x         .share-tile-icon { background: #000; }
.st-whatsapp  .share-tile-icon { background: #25D366; }
.st-telegram  .share-tile-icon { background: #229ED9; }
.st-messenger .share-tile-icon { background: linear-gradient(135deg, #00B2FF 0%, #006AFF 50%, #B64FFF 100%); }
.st-email     .share-tile-icon { background: #EA4335; }
.st-qr        .share-tile-icon { background: linear-gradient(135deg, #183b56, #566ffe); }

/* QR (always visible, right column of .share-layout). */
.share-qr-img {
    display: block;
    width: 140px; height: 140px;
    margin: 0 auto;
    background: #fff;
    border: 1px solid #e2eef1;
    border-radius: 10px;
    padding: 6px;
}
@media (max-width: 540px) {
    .share-qr-img { width: 160px; height: 160px; }
}
.share-qr-caption {
    margin-top: 8px; font-size: 11px; color: #6f7d95;
    line-height: 1.3;
    max-width: 160px; margin-left: auto; margin-right: auto;
}

/* Embed demoted from a primary button to a small text toggle. */
.share-embed-toggle {
    display: inline-flex; align-items: center; gap: 4px;
    margin-top: 18px;
    background: transparent; border: 0;
    color: #566ffe; font-size: 13px; font-weight: 500;
    cursor: pointer; padding: 4px 0;
}
.share-embed-toggle:hover { text-decoration: underline; }
.share-embed-toggle i { transition: transform .2s ease; font-size: 16px; }
.share-embed-toggle.open i { transform: rotate(90deg); }

.share-embed-content { margin-top: 4px; }
