/* Shared FastWebTools — logo, topbar, language switcher */

/* ── Product Hunt featured badge (top bar) ── */
.fw-ph-banner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1100;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 70px;
    padding: 8px 44px 8px 12px;
    background: #ffffff;
    border-bottom: 1px solid #e2e8f0;
    box-sizing: border-box;
}

.fw-ph-banner__link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    line-height: 0;
}

.fw-ph-banner__link:hover .fw-ph-banner__badge,
.fw-ph-banner__link:focus-visible .fw-ph-banner__badge {
    opacity: 0.92;
}

.fw-ph-banner__badge {
    display: block;
    width: 250px;
    max-width: calc(100vw - 88px);
    height: auto;
}

.fw-ph-banner__close {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 32px;
    height: 32px;
    margin: 0;
    padding: 0;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: #64748b;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
}

.fw-ph-banner__close:hover {
    background: #f1f5f9;
    color: #334155;
}

.fw-ph-banner__close:focus-visible {
    outline: 2px solid #64748b;
    outline-offset: 2px;
}

body.has-fw-ph-banner {
    --fw-ph-banner-h: 70px;
    padding-top: calc(56px + var(--fw-ph-banner-h)) !important;
}

body.fastpdf-page.has-fw-ph-banner {
    padding-top: calc(48px + var(--fw-ph-banner-h)) !important;
}

@media (max-width: 640px) {
    .fw-ph-banner {
        min-height: 62px;
        padding-right: 40px;
    }

    .fw-ph-banner__badge {
        width: min(220px, calc(100vw - 72px));
    }

    body.has-fw-ph-banner {
        --fw-ph-banner-h: 62px;
    }
}

/* ── Fixed top bar ── */
.site-topbar {
    position: fixed;
    top: var(--fw-ph-banner-h, 0px);
    left: 0;
    right: 0;
    z-index: 1000;
    height: 48px;
    background: rgba(255, 255, 255, 0.72);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid rgba(226, 232, 240, 0.65);
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
}

.site-topbar-inner {
    max-width: 1200px;
    height: 100%;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.site-topbar-actions {
    flex-shrink: 0;
    margin-left: auto;
}

/* ── PWA custom install button ── */
.pwa-install-btn {
    display: none;
    align-items: center;
    gap: 8px;
    max-width: min(100%, 420px);
    padding: 6px 14px 6px 10px;
    border: 1px solid rgba(30, 64, 175, 0.35);
    border-radius: 999px;
    background: linear-gradient(135deg, #1e3a8a 0%, #1e40af 55%, #2563eb 100%);
    color: #f8fafc;
    font-size: 12px;
    font-weight: 600;
    font-family: inherit;
    line-height: 1.25;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(30, 64, 175, 0.28);
    transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
}

.pwa-install-btn:not([hidden]) {
    display: inline-flex;
}

.pwa-install-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(30, 64, 175, 0.35);
}

.pwa-install-btn:active {
    transform: translateY(0);
}

.pwa-install-btn-icon {
    flex-shrink: 0;
    width: 22px;
    height: 22px;
    border-radius: 6px;
    object-fit: cover;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.2);
}

.pwa-install-btn-text {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pwa-install-toast {
    position: fixed;
    left: 50%;
    bottom: 24px;
    z-index: 1100;
    max-width: min(92vw, 420px);
    padding: 14px 18px;
    border-radius: 12px;
    background: #0f172a;
    color: #f8fafc;
    font-size: 14px;
    font-weight: 500;
    line-height: 1.45;
    text-align: center;
    box-shadow: 0 12px 32px rgba(15, 23, 42, 0.28);
    opacity: 0;
    transform: translate(-50%, 12px);
    pointer-events: none;
    transition: opacity 0.25s ease, transform 0.25s ease;
}

.pwa-install-toast.is-visible {
    opacity: 1;
    transform: translate(-50%, 0);
}

/* ── Home brand banner (logo + wordmark, card-style — not plain text link) ── */
.home-brand-banner {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin: 0 auto 12px;
    padding: 10px 22px 10px 14px;
    background: linear-gradient(135deg, #ffffff 0%, #f8fafc 55%, #f1f5f9 100%);
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    box-shadow:
        0 4px 14px rgba(15, 23, 42, 0.06),
        inset 0 1px 0 rgba(255, 255, 255, 0.95);
    text-decoration: none;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
    max-width: 100%;
    box-sizing: border-box;
}

.home-brand-banner,
.home-brand-banner:link,
.home-brand-banner:visited,
.home-brand-banner:active {
    color: #0f172a;
    text-decoration: none;
}

.home-brand-banner:hover {
    transform: translateY(-2px);
    border-color: rgba(99, 102, 241, 0.35);
    box-shadow:
        0 12px 28px rgba(99, 102, 241, 0.12),
        inset 0 1px 0 rgba(255, 255, 255, 0.95);
}

.home-brand-banner--static {
    cursor: default;
    pointer-events: none;
}

.home-brand-banner--static:hover {
    transform: none;
    border-color: #e2e8f0;
    box-shadow:
        0 4px 14px rgba(15, 23, 42, 0.06),
        inset 0 1px 0 rgba(255, 255, 255, 0.95);
}

.home-brand-logo {
    width: 52px;
    height: 52px;
    border-radius: 12px;
    object-fit: contain;
    flex-shrink: 0;
    display: block;
}

.home-brand-text {
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -0.5px;
    line-height: 1;
    white-space: nowrap;
}

/* ── Language switcher (top-right pill) ── */
.lang-switcher {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 6px 10px 6px 12px;
    background: linear-gradient(145deg, #ffffff 0%, #f1f5f9 100%);
    border: 1px solid rgba(203, 213, 225, 0.8);
    border-radius: 999px;
    box-shadow:
        0 1px 2px rgba(15, 23, 42, 0.05),
        inset 0 1px 0 rgba(255, 255, 255, 0.9);
    transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.15s ease;
}

.lang-switcher:hover {
    border-color: rgba(99, 102, 241, 0.4);
    box-shadow:
        0 4px 14px rgba(99, 102, 241, 0.12),
        inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

.lang-switcher:focus-within {
    border-color: #6366f1;
    box-shadow:
        0 0 0 3px rgba(99, 102, 241, 0.14),
        0 4px 14px rgba(99, 102, 241, 0.1);
}

.lang-switcher-icon {
    display: flex;
    align-items: center;
    color: #6366f1;
    flex-shrink: 0;
    opacity: 0.9;
}

.lang-select {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    border: none;
    background: transparent;
    padding: 2px 20px 2px 0;
    margin: 0;
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    color: #334155;
    cursor: pointer;
    line-height: 1.3;
    min-width: 88px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 2px center;
    background-size: 12px;
}

.lang-select:focus {
    outline: none;
}

.lang-select option {
    font-weight: 500;
    color: #1e293b;
    background: #fff;
}

@media (max-width: 640px) {
    .site-topbar {
        height: 44px;
    }

    .site-topbar-inner {
        padding: 0 14px;
        gap: 8px;
    }

    .pwa-install-btn {
        padding: 5px 10px 5px 8px;
        font-size: 10px;
        max-width: calc(100vw - 120px);
    }

    .pwa-install-btn-icon {
        width: 18px;
        height: 18px;
    }

    .lang-switcher {
        padding: 5px 8px 5px 10px;
        gap: 5px;
    }

    .lang-select {
        font-size: 12px;
        min-width: 76px;
    }

    .home-brand-banner {
        padding: 8px 16px 8px 12px;
        gap: 10px;
    }

    .home-brand-logo {
        width: 44px;
        height: 44px;
    }

    .home-brand-text {
        font-size: 24px;
    }
}

/* ── Global ad pipeline (ads.js + utils.render_ad) — CLS reserved ── */
[data-fw-ad-slot] {
    display: block;
    width: 100%;
    max-width: 728px;
    margin: 0 auto 20px;
    min-height: 90px;
    box-sizing: border-box;
}

[data-fw-ad-slot][data-fw-ad-reserved="off"] {
    min-height: 0 !important;
    margin: 0 !important;
}

.fw-ad-slot {
    width: 100%;
    max-width: 728px;
    margin: 0 auto 20px;
    box-sizing: border-box;
}

.fw-ad-slot.fw-ad-fixed_90px {
    width: 728px;
    max-width: 95%;
    min-height: 100px;
    height: 90px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    margin-bottom: 30px;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}

.fw-ad-slot.fw-ad-auto {
    width: 100%;
    max-width: 728px;
    margin: 20px auto;
    min-height: 120px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.fw-ad-empty {
    display: none !important;
    height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
}

/* ── Offline ad fallback — minimal logo + status ── */
.fw-ad-offline--simple {
    min-height: 72px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 14px 18px;
    box-sizing: border-box;
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    border: 1px solid #e2e8f0;
    border-radius: 14px;
}

.fw-offline-logo {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    object-fit: contain;
    flex-shrink: 0;
}

.fw-offline-msg {
    color: #334155;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.45;
}

/* legacy calcrecipe banner (footer only) */
.fw-ad-offline {
    min-height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px 16px;
    box-sizing: border-box;
}

.fw-ad-offline-banner {
    display: block;
    width: 100%;
    max-width: 680px;
    padding: 14px 18px;
    border-radius: 14px;
    background: linear-gradient(135deg, #ecfdf5 0%, #f0f9ff 100%);
    border: 1px solid #a7f3d0;
    color: #065f46;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.55;
    text-align: center;
    text-decoration: none;
    box-shadow: 0 4px 14px rgba(16, 185, 129, 0.12);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.fw-ad-offline-banner:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 20px rgba(16, 185, 129, 0.18);
    color: #047857;
}

/* ── Offline K-EDU modal ── */
.fw-offline-modal-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 10000;
    background: rgba(15, 23, 42, 0.55);
    align-items: center;
    justify-content: center;
    padding: 20px;
    box-sizing: border-box;
}

.fw-offline-modal-backdrop.is-open {
    display: flex;
}

.fw-offline-modal {
    background: #fff;
    border-radius: 18px;
    padding: 28px 24px;
    max-width: 400px;
    width: 100%;
    box-shadow: 0 24px 48px rgba(15, 23, 42, 0.2);
    text-align: center;
}

.fw-offline-modal-title {
    margin: 0 0 12px;
    font-size: 18px;
    font-weight: 700;
    color: #0f172a;
}

.fw-offline-modal-body {
    margin: 0 0 20px;
    font-size: 15px;
    line-height: 1.6;
    color: #475569;
}

.fw-offline-modal-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 120px;
    padding: 11px 20px;
    border: none;
    border-radius: 12px;
    background: #0f172a;
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}

.fw-offline-modal-btn:hover {
    background: #1e293b;
}

/* ── Smart sliding footer ── */
:root {
    --fw-footer-peek: 36px;
}

body.has-fw-slide-footer {
    padding-bottom: calc(var(--fw-footer-peek) + env(safe-area-inset-bottom, 0px));
}

.fw-slide-footer {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 9999;
    pointer-events: none;
    padding-bottom: env(safe-area-inset-bottom, 0px);
}

.fw-slide-footer__sheet {
    pointer-events: auto;
    background: #0b1329;
    border-top: 1px solid rgba(226, 232, 240, 0.08);
    box-shadow: 0 -10px 32px rgba(15, 23, 42, 0.28);
    transform: translateY(calc(100% - var(--fw-footer-peek)));
    transition: transform 0.3s ease-out;
    will-change: transform;
}

.fw-slide-footer__peek {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    margin: 0;
    padding: 0;
    border: none;
    background: transparent;
    cursor: pointer;
    font-family: inherit;
    -webkit-tap-highlight-color: transparent;
}

.fw-slide-footer__peek-bar {
    display: block;
    width: 100%;
    height: 8px;
    background: linear-gradient(90deg, #6366f1 0%, #2563eb 45%, #10b981 100%);
    flex-shrink: 0;
}

.fw-slide-footer__peek-label {
    display: block;
    width: 100%;
    padding: 5px 16px 7px;
    font-size: 11px;
    font-weight: 600;
    color: #94a3b8;
    text-align: center;
    letter-spacing: 0.02em;
    line-height: 1.3;
}

.fw-slide-footer__body {
    max-width: 1200px;
    margin: 0 auto;
    padding: 4px 24px 0;
    font-family: 'Inter', system-ui, sans-serif;
}

.fw-slide-footer__details {
    margin-bottom: 10px;
    border: 1px solid rgba(148, 163, 184, 0.15);
    border-radius: 10px;
    background: rgba(15, 23, 42, 0.45);
    padding: 10px 14px;
}

.fw-slide-footer__details--muted {
    border-color: rgba(148, 163, 184, 0.12);
    background: rgba(15, 23, 42, 0.3);
    margin-bottom: 12px;
}

.fw-slide-footer__summary {
    color: #94a3b8;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    list-style: none;
}

.fw-slide-footer__details--muted .fw-slide-footer__summary {
    font-size: 12px;
    color: #64748b;
}

.fw-slide-footer__summary::-webkit-details-marker {
    display: none;
}

.fw-slide-footer__about {
    color: #cbd5e1;
    font-size: 12px;
    line-height: 1.65;
    margin: 10px 0 4px;
    font-weight: 400;
}

.fw-slide-footer__nav {
    margin-bottom: 10px;
}

.fw-slide-footer__nav-label {
    color: #64748b;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.4px;
    text-transform: uppercase;
    margin-bottom: 6px;
}

.fw-slide-footer__links {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 2px 0;
    font-size: 12px;
    font-weight: 500;
    line-height: 1.8;
}

.fw-slide-footer__links--sub {
    font-size: 11px;
    margin-top: 2px;
}

.fw-slide-footer__sep {
    color: #334155;
    margin: 0 4px;
}

.fw-slide-footer__link {
    color: #94a3b8;
    text-decoration: none;
    transition: color 0.2s ease;
}

.fw-slide-footer__link:hover {
    color: #6366f1;
}

.fw-slide-footer__tool-list {
    margin: 8px 0 4px;
    padding-left: 16px;
    color: #94a3b8;
    font-size: 11px;
    line-height: 1.6;
}

.fw-slide-footer__tool-list strong {
    color: #cbd5e1;
}

.fw-slide-footer__bar {
    width: 100%;
    padding: 0 0 calc(12px + env(safe-area-inset-bottom, 0px));
    box-sizing: border-box;
}

.fw-slide-footer__bar-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}

.fw-slide-footer__copy {
    color: #64748b;
    font-size: 13px;
    font-weight: 500;
}

.fw-slide-footer__copy strong {
    color: #f1f5f9;
    font-weight: 600;
}

.fw-slide-footer__meta {
    display: flex;
    gap: 20px;
    align-items: center;
    font-size: 13px;
    font-weight: 500;
}

.fw-slide-footer__meta-sep {
    color: #334155;
}

.fw-slide-footer__powered {
    color: #475569;
    font-size: 11px;
    letter-spacing: 0.5px;
}

/* Desktop: hover to expand */
@media (hover: hover) and (pointer: fine) {
    .fw-slide-footer:hover .fw-slide-footer__sheet,
    .fw-slide-footer:focus-within .fw-slide-footer__sheet {
        transform: translateY(0);
    }
}

/* Touch: JS toggles .is-expanded */
.fw-slide-footer.is-expanded .fw-slide-footer__sheet {
    transform: translateY(0);
}

@media (max-width: 640px) {
    .fw-slide-footer__body {
        padding: 4px 16px 0;
    }

    .fw-slide-footer__bar-inner {
        padding: 0 16px;
        flex-direction: column;
        align-items: flex-start;
    }

    .fw-slide-footer__meta {
        flex-wrap: wrap;
        gap: 10px;
    }
}
