/**
 * 5alas unified tooltips — CSS [tooltip] + Bootstrap 5 .tooltip
 * Light card style, brand-aligned arrow accent, readable typography.
 */

/* -------------------------------------------------------------------------
   Native attribute tooltips: [tooltip] + [flow]
   ------------------------------------------------------------------------- */
[tooltip] {
    position: relative;
}

[tooltip]::before,
[tooltip]::after {
    text-transform: none;
    font-size: 13px;
    font-weight: 500;
    line-height: 1.45;
    letter-spacing: 0.01em;
    user-select: none;
    pointer-events: none;
    position: absolute;
    display: none;
    opacity: 0;
    z-index: 1080;
}

[tooltip]::before {
    content: '';
    border: 6px solid transparent;
    z-index: 1081;
}

[tooltip]::after {
    content: attr(tooltip);
    font-family: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    text-align: center;
    min-width: auto;
    max-width: min(280px, 90vw);
    white-space: nowrap;
    padding: 10px 14px;
    color: #0f172a;
    background: #EEE0CC;
    border-radius: 10px;
    border: 1px solid rgba(15, 23, 42, 0.08);
    box-shadow:
        0 12px 32px rgba(15, 23, 42, 0.12),
        0 4px 12px rgba(15, 23, 42, 0.06);
}

/* FLOW: default / UP */
[tooltip]:not([flow])::before,
[tooltip][flow^="up"]::before {
    bottom: 100%;
    border-bottom-width: 0;
    border-top-color: #EEE0CC;
    filter: drop-shadow(0 -1px 0 rgba(15, 23, 42, 0.06));
}

[tooltip]:not([flow])::after,
[tooltip][flow^="up"]::after {
    bottom: calc(100% + 6px);
}

[tooltip]:not([flow])::before,
[tooltip]:not([flow])::after,
[tooltip][flow^="up"]::before,
[tooltip][flow^="up"]::after {
    left: 50%;
    transform: translate(-50%, -4px);
}

/* FLOW: DOWN */
[tooltip][flow^="down"]::before {
    top: 100%;
    border-top-width: 0;
    border-bottom-color: #EEE0CC;
    filter: drop-shadow(0 1px 0 rgba(15, 23, 42, 0.06));
}

[tooltip][flow^="down"]::after {
    top: calc(100% + 6px);
}

[tooltip][flow^="down"]::before,
[tooltip][flow^="down"]::after {
    left: 50%;
    transform: translate(-50%, 4px);
}

/* FLOW: LEFT */
[tooltip][flow^="left"]::before {
    top: 50%;
    border-right-width: 0;
    border-left-color: #EEE0CC;
    left: calc(0em - 6px);
    transform: translate(-4px, -50%);
}

[tooltip][flow^="left"]::after {
    top: 50%;
    right: calc(100% + 6px);
    transform: translate(-4px, -50%);
}

/* FLOW: RIGHT */
[tooltip][flow^="right"]::before {
    top: 50%;
    border-left-width: 0;
    border-right-color: #EEE0CC;
    right: calc(0em - 6px);
    transform: translate(4px, -50%);
}

[tooltip][flow^="right"]::after {
    top: 50%;
    left: calc(100% + 6px);
    transform: translate(4px, -50%);
}

[tooltip]:hover::before,
[tooltip]:hover::after,
[tooltip]:focus-visible::before,
[tooltip]:focus-visible::after,
[tooltip]:focus::before,
[tooltip]:focus::after,
[tooltip]:active::before,
[tooltip]:active::after {
    display: block;
    opacity: 1;
}

[tooltip]:not([flow]):hover::before,
[tooltip]:not([flow]):hover::after,
[tooltip][flow^="up"]:hover::before,
[tooltip][flow^="up"]:hover::after,
[tooltip][flow^="down"]:hover::before,
[tooltip][flow^="down"]:hover::after {
    animation: tooltip-5alas-fade 0.2s ease-out forwards;
}

[tooltip][flow^="left"]:hover::before,
[tooltip][flow^="left"]:hover::after,
[tooltip][flow^="right"]:hover::before,
[tooltip][flow^="right"]:hover::after {
    animation: tooltip-5alas-fade 0.2s ease-out forwards;
}

[tooltip='']::before,
[tooltip='']::after {
    display: none !important;
}

@keyframes tooltip-5alas-fade {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* Mosque directory / listing cards — corner actions: tooltip above icon, single line */
.mosque-card-actions [tooltip]::after {
    text-align: left;
    max-width: none;
    width: max-content;
    white-space: nowrap;
    z-index: 1200;
}

.mosque-card-actions [tooltip]::before {
    z-index: 1201;
}

/* Mobile header: keep tap targets clean */
@media (max-width: 991.98px) {
    .classicHeader .icons-col [tooltip]::before,
    .classicHeader .icons-col [tooltip]::after {
        display: none !important;
        content: none !important;
        animation: none !important;
    }
}

/* -------------------------------------------------------------------------
   Bootstrap 5 tooltips (Popper)
   ------------------------------------------------------------------------- */
.tooltip {
    --bs-tooltip-zindex: 1090;
}

.tooltip .tooltip-inner {
    max-width: min(320px, 92vw);
    padding: 10px 14px;
    color: #0f172a;
    text-align: left;
    background-color: #EEE0CC;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 500;
    line-height: 1.45;
    letter-spacing: 0.01em;
    box-shadow:
        0 12px 32px rgba(15, 23, 42, 0.12),
        0 4px 12px rgba(15, 23, 42, 0.06);
    border: 1px solid rgba(15, 23, 42, 0.08);
}

.bs-tooltip-top .tooltip-arrow::before,
.bs-tooltip-top .arrow::before,
.bs-tooltip-auto[data-popper-placement^="top"] .tooltip-arrow::before {
    border-top-color: #EEE0CC !important;
}

.bs-tooltip-bottom .tooltip-arrow::before,
.bs-tooltip-bottom .arrow::before,
.bs-tooltip-auto[data-popper-placement^="bottom"] .tooltip-arrow::before {
    border-bottom-color: #EEE0CC !important;
}

.bs-tooltip-start .tooltip-arrow::before,
.bs-tooltip-start .arrow::before,
.bs-tooltip-auto[data-popper-placement^="left"] .tooltip-arrow::before {
    border-left-color: #EEE0CC !important;
}

.bs-tooltip-end .tooltip-arrow::before,
.bs-tooltip-end .arrow::before,
.bs-tooltip-auto[data-popper-placement^="right"] .tooltip-arrow::before {
    border-right-color: #EEE0CC !important;
}

/* Optional wrapper class for extra specificity */
.tooltip-5alas {
    background: transparent !important;
    border: none !important;
    padding: 0 !important;
    box-shadow: none !important;
}

@media (prefers-reduced-motion: reduce) {
    [tooltip]:not([flow]):hover::before,
    [tooltip]:not([flow]):hover::after,
    [tooltip][flow^="up"]:hover::before,
    [tooltip][flow^="up"]:hover::after,
    [tooltip][flow^="down"]:hover::before,
    [tooltip][flow^="down"]:hover::after,
    [tooltip][flow^="left"]:hover::before,
    [tooltip][flow^="left"]:hover::after,
    [tooltip][flow^="right"]:hover::before,
    [tooltip][flow^="right"]:hover::after {
        animation: none !important;
    }
}
