/* ═══════════════════════════════════════════════════════════
   SKYRISE ATOLL CODES — the clickable "N7.0 / S1.5" chips

   Shared by pages/atoll-distances.php (decoder, bands, tables)
   and pages/stays.php (card chips + transfer teaser), so the
   code looks and behaves the same everywhere it is printed.

   Markup:
     <a class="atoll-code" href="…" title="N7.0 — about 7 h …">
         <code>N7.0</code>
         <span class="atoll-code__name">North Haa</span>
         <span class="atoll-code__reading">≈ 7 h north of Malé</span>
         <span class="atoll-code__tip">N7.0 — about 7 h …</span>
     </a>

   Only the parts you need are required. `__tip` is a tooltip that
   opens on hover/focus, and on click when the chip carries
   `data-atoll-pop` (see main.js). Inside cards that clip
   (overflow:hidden) use `__tip--above` so the popup stays within
   the card, and keep the title attribute for everyone else.
   ═══════════════════════════════════════════════════════════ */

.atoll-code {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.25rem 0.65rem;
    border-radius: 50px;
    border: 1px solid rgba(var(--accent-rgb), 0.28);
    background: rgba(var(--accent-rgb), 0.08);
    color: var(--accent-dark, #005f6b);
    font-size: 0.8rem;
    font-weight: 600;
    line-height: 1.3;
    text-decoration: none;
    transition: background 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.atoll-code:hover,
.atoll-code:focus-visible {
    background: rgba(var(--accent-rgb), 0.16);
    border-color: var(--accent);
    color: var(--accent-dark, #005f6b);
    text-decoration: none;
    transform: translateY(-1px);
}

.atoll-code code {
    padding: 0;
    background: transparent;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.86em;
    font-weight: 700;
    letter-spacing: 0.04em;
    color: inherit;
}

.atoll-code__name {
    font-weight: 600;
}

.atoll-code__reading {
    font-weight: 500;
    color: var(--text-secondary);
}

.atoll-code--sm {
    gap: 0.3rem;
    padding: 0.15rem 0.5rem;
    font-size: 0.72rem;
}

.atoll-code--ghost {
    background: rgba(var(--accent-rgb), 0.04);
    border-color: rgba(var(--accent-rgb), 0.18);
}

/* Hover/focus/click tooltip: the full plain-English reading of the code */
.atoll-code__tip {
    position: absolute;
    top: calc(100% + 0.55rem);
    left: 50%;
    z-index: 30;
    width: max-content;
    max-width: min(18rem, 72vw);
    padding: 0.5rem 0.7rem;
    border-radius: 10px;
    background: rgba(15, 23, 42, 0.96);
    color: #ffffff;
    font-size: 0.75rem;
    font-weight: 500;
    line-height: 1.4;
    text-align: left;
    white-space: normal;
    box-shadow: 0 12px 30px rgba(15, 23, 42, 0.28);
    opacity: 0;
    visibility: hidden;
    transform: translate(-50%, -6px);
    transition: opacity 0.18s ease, transform 0.18s ease, visibility 0.18s;
    pointer-events: none;
}

.atoll-code:hover .atoll-code__tip,
.atoll-code:focus-visible .atoll-code__tip,
.atoll-code.is-open .atoll-code__tip {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, 0);
}

/* Inside cards that clip (overflow:hidden) the popup opens above the
   chip instead of below, so the card border never cuts it off. */
.atoll-code__tip--above {
    top: auto;
    bottom: calc(100% + 0.55rem);
    transform: translate(-50%, 6px);
}

.atoll-code:hover .atoll-code__tip--above,
.atoll-code:focus-visible .atoll-code__tip--above,
.atoll-code.is-open .atoll-code__tip--above {
    transform: translate(-50%, 0);
}

@media (hover: none) {
    /* Touch devices have no hover — the popup only appears when the
       chip was explicitly opened by tap (see main.js). */
    .atoll-code:not(.is-open) .atoll-code__tip {
        display: none;
    }
}

@media (max-width: 767.98px) {
    .atoll-code__reading {
        font-size: 0.7rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    .atoll-code,
    .atoll-code:hover {
        transition: none;
        transform: none;
    }

    .atoll-code__tip,
    .atoll-code:hover .atoll-code__tip,
    .atoll-code:focus-visible .atoll-code__tip,
    .atoll-code.is-open .atoll-code__tip {
        transition: none;
        transform: translate(-50%, 0);
    }
}
