/* Homepage Telegram channel popup (components/home/tg-popup.php). One layout for every breakpoint.
 * Native <dialog> in the top layer, so it sits above the nav, tab bar and live chat without z-index.
 * Focus uses a box-shadow ring: the header's critical guards strip outlines with !important. */

.tgp {
    --tgp-fg: 255 255 255;
    --tgp-card: #0e0e10;
    --tgp-line: rgb(255 255 255 / 0.16);
    --tgp-join-bg: #ffffff;
    --tgp-join-fg: #000000;
    --tgp-dim: rgb(0 0 0 / 0.62);
    width: min(380px, 100% - 32px);
    max-width: none;
    max-height: calc(100dvh - 32px);
    margin: auto;
    padding: 0;
    border: 0;
    background: transparent;
    color: rgb(var(--tgp-fg));
    overflow: visible;
    overscroll-behavior: contain;
}
html[data-theme="light"] .tgp {
    --tgp-fg: 8 7 6;
    --tgp-card: #f8f6f4;
    --tgp-line: rgb(8 7 6 / 0.12);
    --tgp-join-bg: #080706;
    --tgp-join-fg: #ffffff;
    --tgp-dim: rgb(24 18 10 / 0.42);
}
@media (min-width: 768px) {
    /* Desktop light mode fills primary actions with the v5 accent blue. */
    html[data-theme="light"] .tgp { --tgp-join-bg: rgb(29 78 216); }
}
.tgp:focus { outline: none; }
.tgp::backdrop {
    background: var(--tgp-dim);
    -webkit-backdrop-filter: blur(3px);
    backdrop-filter: blur(3px);
}

.tgp__card {
    position: relative;
    max-height: calc(100dvh - 32px);
    overflow-y: auto;
    padding: 28px 24px 20px;
    border-radius: 22px;
    border: 1px solid var(--tgp-line);
    background: var(--tgp-card);
    box-shadow: 0 24px 60px rgb(0 0 0 / 0.45);
    font-family: Satoshi, 'Noto Sans Arabic', system-ui, sans-serif;
    -webkit-font-smoothing: antialiased;
}
html[data-theme="light"] .tgp__card { box-shadow: 0 24px 60px rgb(46 36 22 / 0.22); }
.tgp__edge {
    position: absolute;
    top: -1px;
    left: 14%;
    right: 14%;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgb(var(--tgp-fg) / 0.55), transparent);
}

.tgp__x {
    position: absolute;
    top: 14px;
    inset-inline-end: 14px;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border-radius: 50%;
    border: 1px solid var(--tgp-line);
    background: rgb(var(--tgp-fg) / 0.04);
    color: rgb(var(--tgp-fg) / 0.75);
    font-size: 15px;
    cursor: pointer;
    transition: background .2s ease, color .2s ease;
}
.tgp__x:hover { background: rgb(var(--tgp-fg) / 0.1); color: rgb(var(--tgp-fg)); }

.tgp__mark {
    width: 56px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 16px;
    background: #229ed9;
    color: #ffffff;
    font-size: 30px;
}
.tgp__eyebrow {
    margin: 20px 0 0;
    font-size: 12.5px;
    font-weight: 500;
    letter-spacing: 0.02em;
    color: rgb(var(--tgp-fg) / 0.55);
}
html[data-theme="light"] .tgp__eyebrow { color: rgb(var(--tgp-fg) / 0.62); }
.tgp__title {
    margin: 6px 0 0;
    font-family: Sora, 'Noto Sans Arabic', system-ui, sans-serif;
    font-size: 22px;
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: -0.03em;
    color: rgb(var(--tgp-fg));
    text-wrap: balance;
}
.tgp__body {
    margin: 10px 0 0;
    font-size: 14.5px;
    line-height: 1.6;
    color: rgb(var(--tgp-fg) / 0.64);
    text-wrap: pretty;
}
html[data-theme="light"] .tgp__body { color: rgb(var(--tgp-fg) / 0.74); }

.tgp__join,
.tgp__later {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    border-radius: 999px;
    text-decoration: none;
    cursor: pointer;
    transition: transform .2s ease, background .2s ease, opacity .2s ease;
}
.tgp__join {
    margin-top: 22px;
    height: 50px;
    padding: 0 20px;
    background: var(--tgp-join-bg);
    color: var(--tgp-join-fg);
    font-family: Sora, 'Noto Sans Arabic', system-ui, sans-serif;
    font-size: 15px;
    font-weight: 600;
}
.tgp__join .fa-telegram { font-size: 18px; }
.tgp__out { font-size: 13px; }
html[dir="rtl"] .tgp__out { transform: scaleX(-1); }
.tgp__join:hover { opacity: 0.88; }
.tgp__join:active,
.tgp__later:active { transform: scale(0.98); }
.tgp__later {
    margin-top: 10px;
    height: 46px;
    padding: 0 18px;
    border: 1px solid var(--tgp-line);
    background: rgb(var(--tgp-fg) / 0.03);
    color: rgb(var(--tgp-fg) / 0.82);
    font: inherit;
    font-size: 14px;
    font-weight: 500;
}
.tgp__later:hover { background: rgb(var(--tgp-fg) / 0.08); }
.tgp__later .fa-clock { font-size: 15px; }

.tgp__x:focus-visible,
.tgp__join:focus-visible,
.tgp__later:focus-visible {
    box-shadow: 0 0 0 2px var(--tgp-card), 0 0 0 4px rgb(var(--tgp-fg));
}
.tgp__sr {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Open / close motion; the script waits for tgp-out before calling close(). */
@keyframes tgp-in { from { opacity: 0; transform: translateY(14px) scale(0.97); } to { opacity: 1; transform: none; } }
@keyframes tgp-out { to { opacity: 0; transform: translateY(8px) scale(0.98); } }
@keyframes tgp-fade-in { from { opacity: 0; } }
@keyframes tgp-fade-out { to { opacity: 0; } }
@media (prefers-reduced-motion: no-preference) {
    .tgp[open] .tgp__card { animation: tgp-in .42s cubic-bezier(0.22, 1, 0.36, 1); }
    .tgp[open]::backdrop { animation: tgp-fade-in .3s ease; }
    .tgp.is-closing .tgp__card { animation: tgp-out .2s ease forwards; }
    .tgp.is-closing::backdrop { animation: tgp-fade-out .2s ease forwards; }
}

@media (max-width: 360px) {
    .tgp__card { padding: 24px 18px 16px; }
    .tgp__title { font-size: 20px; }
}
