/* ============================ FRIENDS & SHARING ============================
 * Mobile-first. Every rule uses the app's tokens so light/dark both work.
 * Rules that matter:
 *  - interactive rows/buttons are >=44px tall (touch target rule)
 *  - presses answer immediately (PRESS rule) and are disabled under reduced motion
 *  - no fixed widths; the board is a CSS grid that reflows on content width
 */

.ax-frd { display: flex; flex-direction: column; gap: 14px; }

/* ---------- header ---------- */
.ax-frd-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.ax-frd-head h2 { margin: 0; }
.ax-frd-head .ax-sub { margin: 4px 0 0; }
.ax-frd-sharebtn { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; }
.ax-frd-sharebtn svg { flex: 0 0 auto; }

/* ---------- search ---------- */
.ax-frd-searchwrap { position: relative; }
.ax-frd-search {
    display: flex; align-items: center; gap: 10px; min-height: 48px;
    padding: 0 10px 0 14px; border-radius: 14px;
    background: var(--card); border: 1px solid var(--border);
    transition: border-color .16s, box-shadow .18s, background .16s;
}
.ax-frd-search:focus-within {
    border-color: var(--accent-a);
    box-shadow: 0 0 0 3px rgba(34, 211, 238, .13);
}
.ax-frd-search-ico { display: inline-flex; color: var(--muted); flex: 0 0 auto; }
.ax-frd-search input {
    flex: 1 1 auto; min-width: 0; min-height: 44px;
    background: none; border: 0; outline: 0; color: var(--text);
    font: inherit; font-size: 15px;
}
.ax-frd-search input::placeholder { color: var(--muted); }
/* iOS renders its own clear button; ours is the one that answers the PRESS rule */
.ax-frd-search input::-webkit-search-cancel-button { -webkit-appearance: none; appearance: none; }
.ax-frd-clear {
    display: inline-flex; align-items: center; justify-content: center;
    width: 34px; height: 34px; flex: 0 0 auto; border-radius: 50%;
    background: transparent; border: 0; color: var(--muted); cursor: pointer;
}
.ax-frd-clear:hover { background: rgba(127, 127, 140, .14); color: var(--text); }

.ax-frd-results:not(:empty) {
    margin-top: 10px; border-radius: 14px; overflow: hidden;
    background: var(--card); border: 1px solid var(--border);
    /* a long result list must never push the page into a horizontal scroll */
    max-height: 46vh; overflow-y: auto;
}

/* ---------- board ---------- */
.ax-frd-board {
    display: grid; gap: 14px;
    grid-template-columns: minmax(0, 1fr);
    align-items: start;
}
@media (min-width: 900px) {
    .ax-frd-board { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.ax-frd-card {
    background: var(--card); border: 1px solid var(--border);
    border-radius: 16px; padding: 6px 6px 8px; min-width: 0;
}
.ax-frd-card > header { padding: 10px 12px 6px; }
.ax-frd-card h3 {
    margin: 0; font-size: 13px; font-weight: 700; letter-spacing: .04em;
    text-transform: uppercase; color: var(--muted);
    display: flex; align-items: center; gap: 8px;
}
.ax-frd-pill {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px;
    background: var(--grad); color: #04141a; font-size: 11px; font-weight: 800;
    letter-spacing: 0;
}
.ax-frd-list { display: flex; flex-direction: column; gap: 2px; }

/* ---------- row ---------- */
.ax-frd-row {
    display: flex; align-items: center; gap: 10px;
    min-height: 56px; padding: 7px 10px; border-radius: 12px;
    transition: background-color .14s ease;
}
.ax-frd-row:hover { background: rgba(127, 127, 140, .08); }
.ax-frd-row-txt { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.ax-frd-row-txt strong {
    font-size: 14px; font-weight: 600; color: var(--text);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ax-frd-row-txt span {
    font-size: 12px; color: var(--muted);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ax-frd-row-acts { display: flex; align-items: center; gap: 6px; flex: 0 0 auto; }

/* ---------- avatar ---------- */
.ax-frd-av {
    display: inline-flex; align-items: center; justify-content: center;
    flex: 0 0 auto; border-radius: 50%; line-height: 1;
    background: color-mix(in srgb, var(--av) 22%, transparent);
    color: var(--av); font-weight: 700;
    border: 1px solid color-mix(in srgb, var(--av) 38%, transparent);
}
.ax-frd-cover {
    width: 44px; height: 44px; flex: 0 0 auto; border-radius: 10px;
    object-fit: cover; background: var(--elevated);
}
.ax-frd-cover--empty {
    display: inline-flex; align-items: center; justify-content: center;
    color: var(--muted); border: 1px dashed var(--border);
}

/* ---------- buttons ---------- */
.ax-frd-act, .ax-frd-icon {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    min-height: 38px; padding: 0 12px; border-radius: 10px;
    background: transparent; color: var(--text);
    border: 1px solid var(--border); font: inherit; font-size: 13px; font-weight: 600;
    cursor: pointer; white-space: nowrap;
    transition: transform .12s cubic-bezier(.2,.9,.3,1), background .15s, border-color .15s, opacity .15s;
}
.ax-frd-act:hover { background: rgba(127, 127, 140, .1); border-color: color-mix(in srgb, var(--text) 22%, transparent); }
.ax-frd-act:active, .ax-frd-icon:active { transform: scale(.96); }
.ax-frd-act[disabled] { opacity: .55; cursor: default; }
.ax-frd-act.is-busy { position: relative; color: transparent; }
.ax-frd-act.is-busy::after {
    content: ''; position: absolute; width: 15px; height: 15px; border-radius: 50%;
    border: 2px solid currentColor; border-top-color: transparent;
    color: var(--text); animation: axFrdSpin .7s linear infinite;
}
.ax-frd-act--primary {
    background: var(--grad); color: #04141a; border-color: transparent;
}
.ax-frd-act--primary:hover { filter: brightness(1.08); background: var(--grad); }
.ax-frd-act--danger { color: #f87171; border-color: color-mix(in srgb, #f87171 40%, transparent); }
.ax-frd-act--danger:hover { background: rgba(248, 113, 113, .12); }
.ax-frd-icon { width: 38px; height: 38px; padding: 0; }

.ax-frd-state {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 0 10px; min-height: 30px; border-radius: 999px;
    font-size: 12px; font-weight: 600; color: var(--muted);
    background: rgba(127, 127, 140, .12);
}
.ax-frd-state--ok { color: var(--accent-a); background: color-mix(in srgb, var(--accent-a) 14%, transparent); }

/* ---------- empty / skeleton ---------- */
.ax-frd-empty {
    display: flex; flex-direction: column; align-items: center; text-align: center;
    gap: 4px; padding: 22px 16px; color: var(--muted);
}
.ax-frd-empty-ico { color: var(--muted); opacity: .6; margin-bottom: 2px; }
.ax-frd-empty strong { color: var(--text); font-size: 14px; font-weight: 600; }
.ax-frd-empty span { font-size: 12.5px; max-width: 34ch; line-height: 1.45; }

.ax-frd-row--skel { pointer-events: none; }
.ax-skel-av { width: 40px; height: 40px; border-radius: 50%; background: rgba(127, 127, 140, .16); }
.ax-skel-line {
    flex: 1 1 auto; height: 12px; border-radius: 6px;
    background: linear-gradient(90deg, rgba(127,127,140,.13), rgba(127,127,140,.24), rgba(127,127,140,.13));
    background-size: 200% 100%;
    animation: axFrdShimmer 1.3s ease-in-out infinite;
}

/* ---------- blocked disclosure ---------- */
.ax-frd-blocked-wrap {
    background: var(--card); border: 1px solid var(--border);
    border-radius: 14px; padding: 2px 6px;
}
.ax-frd-blocked-wrap > summary {
    min-height: 48px; display: flex; align-items: center; gap: 8px;
    padding: 0 10px; cursor: pointer; font-size: 13px; font-weight: 600; color: var(--muted);
    list-style: none;
}
.ax-frd-blocked-wrap > summary::-webkit-details-marker { display: none; }
.ax-frd-blocked-wrap > summary:hover { color: var(--text); }
.ax-frd-blocked-wrap > summary:active { transform: scale(.995); }

/* ---------- contextual menu ---------- */
.ax-frd-menu {
    position: fixed; z-index: 400; width: 210px; padding: 6px;
    background: var(--elevated); border: 1px solid var(--border);
    border-radius: 13px; box-shadow: 0 12px 34px rgba(0, 0, 0, .45);
    opacity: 0; transform: translateY(-4px) scale(.98);
    transition: opacity .14s ease, transform .14s cubic-bezier(.2,.9,.3,1);
}
.ax-frd-menu.is-open { opacity: 1; transform: none; }
.ax-frd-menu button {
    display: flex; align-items: center; gap: 10px; width: 100%;
    min-height: 42px; padding: 0 10px; border-radius: 9px;
    background: transparent; border: 0; color: var(--text);
    font: inherit; font-size: 13.5px; text-align: left; cursor: pointer;
}
.ax-frd-menu button:hover { background: rgba(127, 127, 140, .14); }
.ax-frd-menu button:active { transform: scale(.98); }
.ax-frd-menu button.is-danger { color: #f87171; }

/* ---------- share modal ---------- */
.ax-share-head { display: flex; align-items: center; gap: 12px; padding-bottom: 12px; }
.ax-share-ico {
    display: inline-flex; align-items: center; justify-content: center;
    width: 40px; height: 40px; flex: 0 0 auto; border-radius: 12px;
    background: color-mix(in srgb, var(--accent-a) 15%, transparent); color: var(--accent-a);
}
.ax-share-meta { display: flex; flex-direction: column; min-width: 0; }
.ax-share-meta strong { font-size: 14.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.ax-share-search {
    display: flex; align-items: center; gap: 8px; min-height: 44px;
    padding: 0 12px; margin-bottom: 8px; border-radius: 12px;
    background: var(--surface); border: 1px solid var(--border);
    transition: border-color .16s, box-shadow .18s;
}
.ax-share-search:focus-within { border-color: var(--accent-a); box-shadow: 0 0 0 3px rgba(34,211,238,.13); }
.ax-share-search-ico { display: inline-flex; color: var(--muted); }
.ax-share-search input {
    flex: 1 1 auto; min-width: 0; min-height: 42px; border: 0; outline: 0;
    background: none; color: var(--text); font: inherit; font-size: 14px;
}

.ax-share-list {
    display: flex; flex-direction: column; gap: 2px;
    max-height: min(46vh, 340px); overflow-y: auto; overscroll-behavior: contain;
}
.ax-share-row {
    display: flex; align-items: center; gap: 10px; width: 100%;
    min-height: 52px; padding: 6px 10px; border-radius: 11px;
    background: transparent; border: 1px solid transparent; color: var(--text);
    font: inherit; text-align: left; cursor: pointer;
    transition: background .14s, border-color .14s, transform .12s cubic-bezier(.2,.9,.3,1);
}
.ax-share-row:hover { background: rgba(127, 127, 140, .09); }
.ax-share-row:active { transform: scale(.985); }
.ax-share-row.is-on {
    background: color-mix(in srgb, var(--accent-a) 11%, transparent);
    border-color: color-mix(in srgb, var(--accent-a) 45%, transparent);
}
.ax-share-row-txt { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.ax-share-row-txt strong { font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ax-share-row-txt span { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ax-share-tick {
    display: inline-flex; align-items: center; justify-content: center;
    width: 22px; height: 22px; flex: 0 0 auto; border-radius: 50%;
    border: 1.5px solid var(--border); color: transparent;
    transition: background .14s, border-color .14s, color .14s;
}
.ax-share-row.is-on .ax-share-tick { background: var(--accent-a); border-color: var(--accent-a); color: #04141a; }

/* ---------- share choice (friends vs public link) ---------- */
.ax-share-opts { display: flex; flex-direction: column; gap: 8px; }
.ax-share-opt {
    display: flex; align-items: center; gap: 12px; width: 100%;
    min-height: 64px; padding: 10px 12px; border-radius: 13px;
    background: var(--surface); border: 1px solid var(--border); color: var(--text);
    font: inherit; text-align: left; cursor: pointer;
    transition: background .15s, border-color .15s, transform .12s cubic-bezier(.2,.9,.3,1);
}
.ax-share-opt:hover { border-color: color-mix(in srgb, var(--accent-a) 45%, transparent); background: color-mix(in srgb, var(--accent-a) 7%, var(--surface)); }
.ax-share-opt:active { transform: scale(.985); }
@media (prefers-reduced-motion: reduce) { .ax-share-opt:active { transform: none; } }

/* ---------- nav badge ---------- */
.ax-nav-badge {
    margin-left: auto; display: inline-flex; align-items: center; justify-content: center;
    min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px;
    background: var(--accent-b); color: #fff; font-size: 10.5px; font-weight: 800; line-height: 1;
}
.ax-bottomnav .ax-nav-badge { position: absolute; top: 2px; right: 50%; transform: translateX(16px); }

/* ---------- motion ---------- */
@keyframes axFrdSpin { to { transform: rotate(360deg); } }
@keyframes axFrdShimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

@media (prefers-reduced-motion: reduce) {
    .ax-frd-act:active, .ax-frd-icon:active, .ax-share-row:active,
    .ax-frd-menu button:active, .ax-frd-blocked-wrap > summary:active { transform: none; }
    .ax-skel-line { animation: none; }
    .ax-frd-menu { transition: none; }
}

/* ---------- small phones (320-390) ---------- */
@media (max-width: 420px) {
    .ax-frd-head { flex-direction: column; align-items: stretch; }
    .ax-frd-sharebtn { justify-content: center; width: 100%; }
    .ax-frd-row { gap: 8px; padding: 6px 8px; }
    .ax-frd-row-acts { gap: 4px; }
    .ax-frd-act { padding: 0 10px; font-size: 12.5px; }
    .ax-frd-icon { width: 36px; height: 36px; }
    /* On a narrow phone three buttons + avatar + name in one line crushes the name to nothing:
       let the actions wrap under the text instead of truncating to "A…". */
    .ax-frd-row-acts { flex-wrap: wrap; justify-content: flex-end; }
}
