/* Buyer coin picker (pay-picker.js): one selectable tile per currency.
   Loads after market.css and only builds on its dark-theme tokens. */

.pp {
    --pp-bg: var(--bg-2, #171f27);
    --pp-bg-hover: var(--bg-3, #1e2830);
    --pp-line: var(--border, #232d37);
    --pp-line-hover: #34424e;
    --pp-text: var(--text, #ffffff);
    --pp-dim: var(--text-dim, #aab4bf);
    --pp-muted: var(--text-muted, #6b7684);
    --pp-soft: #8a96a4; /* small text: lighter than --text-muted so it stays readable at 11px */
    --pp-accent: var(--accent, #3b82f6);
    --pp-accent-soft: var(--accent-soft, rgba(59, 130, 246, 0.14));
    --pp-green: var(--green, #1fbf6b);
    position: relative;
    width: 100%;
    min-width: 0;
}

/* Visually hidden, still read by screen readers */
.pp-sr {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

/* ---- the grid: 1 column on phones, 2+ once there is room ---- */

.pp-grid {
    display: grid;
    grid-template-columns: 1fr;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 200px), 1fr));
    gap: 10px;
}

/* ---- a coin tile ---- */

.pp-tile {
    position: relative;
    display: grid;
    grid-template-columns: 40px minmax(0, 1fr);
    column-gap: 12px;
    align-items: start;
    width: 100%;
    min-width: 0;
    margin: 0;
    padding: 13px;
    text-align: left;
    font: inherit;
    color: var(--pp-text);
    background: var(--pp-bg);
    border: 1.5px solid var(--pp-line);
    border-radius: 14px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: border-color 0.16s ease, background-color 0.16s ease, box-shadow 0.16s ease, transform 0.16s ease;
}

@media (hover: hover) {
    .pp-tile:hover {
        border-color: var(--pp-line-hover);
        background-color: var(--pp-bg-hover);
        transform: translateY(-1px);
    }
}

.pp-tile:active { transform: scale(0.99); }

/* Keep the browser default ring where :focus-visible is unsupported; hide it for mouse clicks elsewhere */
.pp-tile:focus:not(:focus-visible) { outline: none; }

.pp-tile:focus-visible {
    outline: 2px solid var(--pp-accent);
    outline-offset: 2px;
}

/* Selected: blue border + glow, tinted background, filled check badge */
.pp-tile[aria-checked="true"] {
    border-color: var(--pp-accent);
    background:
        linear-gradient(180deg, var(--pp-accent-soft) 0%, rgba(59, 130, 246, 0.04) 100%),
        var(--pp-bg);
    box-shadow: 0 0 0 3px var(--pp-accent-soft), 0 10px 26px rgba(59, 130, 246, 0.12);
}

.pp-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    overflow: hidden;
    display: grid;
    place-items: center;
    background: var(--pp-bg-hover);
}

.pp-img {
    display: block;
    width: 100%;
    height: 100%;
}

/* Letter badge: shown when a coin has no icon or its icon fails to load */
.pp-avatar {
    width: 100%;
    height: 100%;
    display: grid;
    place-items: center;
    font-size: 17px;
    font-weight: 800;
    color: #fff;
    background: hsl(var(--pp-h, 215), 48%, 38%);
}

.pp-body {
    min-width: 0;
    display: block;
}

/* Name + ticker; the right padding keeps them clear of the check badge */
.pp-head {
    display: flex;
    align-items: baseline;
    gap: 6px;
    min-width: 0;
    padding-right: 26px;
    line-height: 1.3;
}

.pp-name {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 14px;
    font-weight: 700;
}

.pp-sym {
    flex-shrink: 0;
    font-size: 11.5px;
    font-weight: 700;
    letter-spacing: 0.03em;
    color: var(--pp-soft);
}

/* Network chip + fee hint */
.pp-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 5px 8px;
    margin-top: 7px;
}

.pp-net {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    padding: 2px 9px;
    border: 1px solid var(--pp-line);
    border-radius: 999px;
    background: var(--pp-bg-hover);
    font-size: 10.5px;
    font-weight: 700;
    line-height: 1.5;
    color: var(--pp-dim);
    transition: border-color 0.16s ease, background-color 0.16s ease, color 0.16s ease;
}

.pp-tile[aria-checked="true"] .pp-net {
    border-color: rgba(59, 130, 246, 0.45);
    background: var(--pp-accent-soft);
    color: #d4e3ff;
}

.pp-fee {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    font-weight: 600;
    line-height: 1.4;
    color: var(--pp-soft);
    overflow-wrap: anywhere;
}

.pp-fee svg { flex-shrink: 0; opacity: 0.85; }

/* Estimate line */
.pp-est {
    display: block;
    margin-top: 9px;
    padding-top: 8px;
    border-top: 1px solid var(--pp-line);
    font-size: 13px;
    font-weight: 800;
    line-height: 1.35;
    color: var(--pp-dim);
    font-variant-numeric: tabular-nums;
    overflow-wrap: anywhere;
    transition: color 0.16s ease;
}

.pp-est[hidden] { display: none; }

.pp-tile[aria-checked="true"] .pp-est { color: var(--pp-green); }

/* While rates are still loading: a soft bar that keeps the tile height steady */
.pp-est.is-pending::after {
    content: "";
    display: block;
    width: 64%;
    height: 13px;
    margin: 2px 0;
    border-radius: 6px;
    background: var(--pp-bg-hover);
    animation: pp-pulse 1.4s ease-in-out infinite;
}

/* The choice badge (top right) */
.pp-radio {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 20px;
    height: 20px;
    display: grid;
    place-items: center;
    color: #fff;
    border: 1.5px solid #3a4856;
    border-radius: 50%;
    transition: background-color 0.16s ease, border-color 0.16s ease;
}

.pp-radio svg {
    width: 12px;
    height: 12px;
    opacity: 0;
    transform: scale(0.6);
    transition: opacity 0.16s ease, transform 0.16s ease;
}

.pp-tile[aria-checked="true"] .pp-radio {
    background: var(--pp-accent);
    border-color: var(--pp-accent);
}

.pp-tile[aria-checked="true"] .pp-radio svg {
    opacity: 1;
    transform: none;
}

/* ---- under the tiles: what's selected + the estimate note ---- */

.pp-foot {
    display: grid;
    gap: 5px;
    margin-top: 12px;
}

.pp-summary,
.pp-note { margin: 0; }

.pp-summary {
    font-size: 12.5px;
    line-height: 1.5;
    color: var(--pp-dim);
    overflow-wrap: anywhere;
}

.pp-summary strong {
    font-weight: 700;
    color: var(--pp-text);
}

.pp-note {
    display: flex;
    align-items: flex-start;
    gap: 6px;
    font-size: 11.5px;
    line-height: 1.45;
    color: var(--pp-soft);
}

.pp-note svg {
    flex-shrink: 0;
    margin-top: 1px;
}

/* ---- error and empty states reuse .settings-notice from market.css ---- */

.pp-error {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px 14px;
    margin-bottom: 0;
}

.pp-error > span {
    flex: 1 1 180px;
    min-width: 0;
}

.pp-retry {
    flex-shrink: 0;
    padding: 7px 14px;
}

.pp-empty { margin-bottom: 0; }

/* ---- loading skeleton ---- */

.pp-grid-skel {
    pointer-events: none;
    user-select: none;
}

.pp-skel {
    position: relative;
    height: 112px; /* about the height of a real tile, so nothing jumps when they arrive */
    overflow: hidden;
    border: 1.5px solid var(--pp-line);
    border-radius: 14px;
    background: var(--pp-bg);
}

.pp-skel::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(105deg, transparent 30%, rgba(255, 255, 255, 0.05) 50%, transparent 70%);
    transform: translateX(-100%);
    animation: pp-sweep 1.5s ease-in-out infinite;
}

.pp-sk {
    position: absolute;
    border-radius: 6px;
    background: var(--pp-bg-hover);
}

.pp-sk-icon { top: 13px; left: 13px; width: 40px; height: 40px; border-radius: 50%; }
.pp-sk-a { top: 15px; left: 65px; width: 42%; height: 14px; }
.pp-sk-b { top: 39px; left: 65px; width: 34%; height: 20px; border-radius: 999px; }
.pp-sk-c { top: 79px; left: 65px; width: 56%; height: 14px; }

@keyframes pp-sweep {
    to { transform: translateX(100%); }
}

@keyframes pp-pulse {
    0%, 100% { opacity: 0.55; }
    50% { opacity: 1; }
}

/* ---- narrow phones: tighter tiles ---- */

@media (max-width: 400px) {
    .pp-tile { padding: 11px; column-gap: 10px; }
    .pp-radio { top: 10px; right: 10px; }
    .pp-skel { height: 108px; }
}

/* ---- accessibility ---- */

@media (prefers-reduced-motion: reduce) {
    .pp-tile,
    .pp-net,
    .pp-est,
    .pp-radio,
    .pp-radio svg { transition: none; }
    .pp-tile:hover,
    .pp-tile:active { transform: none; }
    .pp-skel::after { display: none; }
    .pp-est.is-pending::after { animation: none; }
}

@media (forced-colors: active) {
    .pp-tile[aria-checked="true"] {
        outline: 2px solid Highlight;
        outline-offset: 0;
    }
    .pp-radio { border-color: CanvasText; }
    .pp-tile[aria-checked="true"] .pp-radio {
        background: Highlight;
        border-color: Highlight;
    }
}
