/* Fun fakty — karta losowania + motyw neon */
.fun-fakty-page .info-tab {
    max-width: 720px;
}

.fun-fakty-page .page-hero {
    text-align: center;
    margin-bottom: 0;
    padding-bottom: 0;
}

/* Keep the underline squiggle close to the title so the gap to the
   category picker below stays even (no double spacing). */
.fun-fakty-page .page-hero::after {
    margin-top: 16px;
}

.funfact-stage {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-top: 28px;
    padding: 8px 0 12px;
}

.funfact-stage::before {
    content: '';
    position: absolute;
    inset: -40px -20px auto;
    height: 280px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(37, 99, 235, 0.1), transparent 68%);
    pointer-events: none;
    z-index: 0;
}

[data-theme='dark'] .funfact-stage::before {
    background: radial-gradient(circle, rgba(37, 99, 235, 0.22), rgba(128, 0, 0, 0.08) 45%, transparent 72%);
    filter: blur(2px);
}

.funfact-card {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 580px;
    min-height: 340px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: 20px;
    padding: 44px 40px 36px;
    border-radius: var(--radius-xl, 28px);
    border: 1px solid var(--border);
    background: linear-gradient(155deg, var(--surface) 0%, var(--surface-cool) 100%);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    transition: transform 0.35s var(--ease-out), box-shadow 0.35s var(--ease-out);
}

.funfact-card::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    padding: 1px;
    background: linear-gradient(135deg, rgba(37, 99, 235, 0.35), rgba(128, 0, 0, 0.25), rgba(37, 99, 235, 0.15));
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    pointer-events: none;
    opacity: 0.65;
}

[data-theme='dark'] .funfact-card {
    background: linear-gradient(155deg, rgba(26, 35, 56, 0.96) 0%, rgba(18, 26, 46, 0.92) 55%, rgba(34, 28, 40, 0.88) 100%);
    border-color: rgba(147, 197, 253, 0.22);
    box-shadow:
        0 24px 56px rgba(0, 0, 0, 0.45),
        0 0 0 1px rgba(59, 130, 246, 0.1),
        0 0 48px rgba(37, 99, 235, 0.08);
}

[data-theme='dark'] .funfact-card::before {
    background: linear-gradient(135deg, rgba(96, 165, 250, 0.55), rgba(240, 160, 160, 0.45), rgba(147, 197, 253, 0.35));
    opacity: 0.85;
    animation: funfact-border-pulse 4s ease-in-out infinite;
}

@keyframes funfact-border-pulse {
    0%, 100% { opacity: 0.65; }
    50% { opacity: 1; }
}

.funfact-card-glow {
    position: absolute;
    width: 220px;
    height: 220px;
    border-radius: 50%;
    background: radial-gradient(circle, var(--primary-glow), transparent 70%);
    top: -60px;
    right: -40px;
    pointer-events: none;
    opacity: 0.35;
}

[data-theme='dark'] .funfact-card-glow {
    opacity: 0.55;
    background: radial-gradient(circle, rgba(37, 99, 235, 0.35), rgba(128, 0, 0, 0.2) 50%, transparent 72%);
    animation: funfact-glow-drift 6s ease-in-out infinite alternate;
}

@keyframes funfact-glow-drift {
    from { transform: translate(0, 0) scale(1); }
    to { transform: translate(-24px, 18px) scale(1.12); }
}

.funfact-card.is-reveal {
    animation: funfact-card-pop 0.42s var(--ease-spring);
}

@keyframes funfact-card-pop {
    0% { transform: scale(0.98); }
    55% { transform: scale(1.015); }
    100% { transform: scale(1); }
}

.funfact-emoji {
    position: relative;
    z-index: 1;
    font-size: 3.2rem;
    line-height: 1;
    filter: drop-shadow(0 6px 14px rgba(15, 23, 42, 0.12));
    transition: transform 0.35s var(--ease-spring), opacity 0.2s ease;
}

[data-theme='dark'] .funfact-emoji {
    filter: drop-shadow(0 0 18px rgba(147, 197, 253, 0.35));
}

.funfact-emoji.is-rolling {
    transform: scale(0.85) rotate(-8deg);
    opacity: 0.4;
}

.funfact-text {
    position: relative;
    z-index: 1;
    font-size: 1.32rem;
    line-height: 1.58;
    font-weight: 600;
    margin: 0;
    max-width: 480px;
    color: var(--text-dark);
    transition: opacity 0.18s ease, transform 0.28s var(--ease-out);
}

.funfact-text.is-rolling {
    opacity: 0.25;
    transform: translateY(6px);
}

[data-theme='dark'] .funfact-text {
    text-shadow: 0 0 28px rgba(147, 197, 253, 0.06);
}

.funfact-tag {
    position: relative;
    z-index: 1;
    padding: 6px 16px;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    color: var(--accent);
    border: 1px solid rgba(37, 99, 235, 0.22);
    background: rgba(37, 99, 235, 0.07);
}

[data-theme='dark'] .funfact-tag {
    color: var(--accent-soft);
    border-color: rgba(147, 197, 253, 0.32);
    background: rgba(37, 99, 235, 0.16);
    box-shadow: 0 0 16px rgba(37, 99, 235, 0.12);
}

.funfact-tag[data-cat='Białko'] {
    color: #b91c1c;
    border-color: rgba(185, 28, 28, 0.25);
    background: rgba(185, 28, 28, 0.08);
}

[data-theme='dark'] .funfact-tag[data-cat='Białko'] {
    color: #fca5a5;
    border-color: rgba(252, 165, 165, 0.35);
    background: rgba(128, 0, 0, 0.28);
    box-shadow: 0 0 14px rgba(240, 160, 160, 0.15);
}

.funfact-tag[data-cat='Odchudzanie'] {
    color: #0d9488;
    border-color: rgba(13, 148, 136, 0.25);
    background: rgba(13, 148, 136, 0.08);
}

[data-theme='dark'] .funfact-tag[data-cat='Odchudzanie'] {
    color: #5eead4;
    border-color: rgba(94, 234, 212, 0.32);
    background: rgba(13, 148, 136, 0.2);
    box-shadow: 0 0 14px rgba(94, 234, 212, 0.12);
}

.funfact-tag[data-cat='Trening'] {
    color: #7c3aed;
    border-color: rgba(124, 58, 237, 0.25);
    background: rgba(124, 58, 237, 0.08);
}

[data-theme='dark'] .funfact-tag[data-cat='Trening'] {
    color: #c4b5fd;
    border-color: rgba(196, 181, 253, 0.32);
    background: rgba(124, 58, 237, 0.22);
    box-shadow: 0 0 14px rgba(196, 181, 253, 0.12);
}

.funfact-tag[data-cat='Odżywianie'] {
    color: #ca8a04;
    border-color: rgba(202, 138, 4, 0.28);
    background: rgba(202, 138, 4, 0.08);
}

[data-theme='dark'] .funfact-tag[data-cat='Odżywianie'] {
    color: #fde047;
    border-color: rgba(253, 224, 71, 0.32);
    background: rgba(202, 138, 4, 0.18);
    box-shadow: 0 0 14px rgba(253, 224, 71, 0.1);
}

.funfact-meta {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 580px;
    margin-top: 20px;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 12px;
}

.funfact-progress-no {
    flex: 0 0 auto;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    font-variant-numeric: tabular-nums;
    color: var(--text-muted);
    white-space: nowrap;
}

[data-theme='dark'] .funfact-progress-no {
    color: var(--accent-soft);
}

.funfact-progress {
    flex: 1 1 auto;
    height: 6px;
    border-radius: 999px;
    background: var(--surface-muted);
    border: 1px solid var(--border-soft);
    overflow: hidden;
}

[data-theme='dark'] .funfact-progress {
    background: rgba(18, 26, 46, 0.8);
    border-color: rgba(147, 197, 253, 0.15);
}

.funfact-progress-bar {
    height: 100%;
    width: 0%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--accent-soft), var(--primary));
    transition: width 0.45s var(--ease-out);
}

[data-theme='dark'] .funfact-progress-bar {
    background: linear-gradient(90deg, var(--accent-hot), var(--primary), var(--accent-soft));
    box-shadow: 0 0 12px rgba(37, 99, 235, 0.45);
}


.funfact-controls {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 22px;
}

.funfact-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 13px 24px;
    border-radius: var(--radius-md, 16px);
    font: inherit;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.2s var(--ease-soft), box-shadow 0.2s var(--ease-soft), background 0.2s ease;
}

.funfact-btn--primary {
    border: 1px solid transparent;
    color: #fff;
    background: linear-gradient(135deg, var(--accent) 0%, var(--primary-dark) 100%);
    box-shadow: 0 10px 24px rgba(30, 58, 138, 0.22), 0 4px 12px var(--primary-glow);
}

[data-theme='dark'] .funfact-btn--primary {
    color: #121a2e;
    background: linear-gradient(135deg, var(--accent-hot) 0%, var(--primary) 55%, var(--primary-dark) 100%);
    box-shadow: 0 10px 32px rgba(37, 99, 235, 0.35), 0 0 24px var(--primary-glow);
}

.funfact-btn--primary:hover,
.funfact-btn--primary:focus-visible {
    transform: translateY(-2px);
    box-shadow: 0 14px 28px rgba(30, 58, 138, 0.28), 0 6px 16px var(--primary-glow);
}

[data-theme='dark'] .funfact-btn--primary:hover,
[data-theme='dark'] .funfact-btn--primary:focus-visible {
    box-shadow: 0 14px 36px rgba(37, 99, 235, 0.42), 0 0 32px var(--primary-glow);
}

/* Secondary action ("Kopiuj fakt") — deliberately tiny and low-key.
   It must never compete with the main roll button, so it gets a smaller
   pill shape, muted colour and no shadow until hovered/focused. */
.funfact-btn--ghost {
    padding: 5px 12px;
    gap: 6px;
    border-radius: 999px;
    font-size: 0.74rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    line-height: 1.4;
    border: 1px solid var(--border);
    color: var(--text-muted);
    background: transparent;
    box-shadow: none;
    opacity: 0.7;
}

[data-theme='dark'] .funfact-btn--ghost {
    border-color: rgba(147, 197, 253, 0.2);
    color: var(--text-muted);
    background: transparent;
}

.funfact-btn--ghost:hover,
.funfact-btn--ghost:focus-visible {
    transform: none;
    opacity: 1;
    border-color: var(--accent-soft);
    color: var(--accent);
    background: var(--surface-hover);
    box-shadow: none;
}

[data-theme='dark'] .funfact-btn--ghost:hover,
[data-theme='dark'] .funfact-btn--ghost:focus-visible {
    border-color: rgba(147, 197, 253, 0.5);
    color: var(--accent-soft);
    background: rgba(26, 35, 56, 0.6);
}

/* Park the tiny "Kopiuj fakt" action in the card's top-right corner so it
   never shifts the main "Losuj kolejny" button, which stays dead-centre
   under the fact. */
.funfact-copy-corner {
    position: absolute;
    top: 14px;
    right: 14px;
    z-index: 3;
}

.funfact-btn-icon {
    font-size: 1.1rem;
    line-height: 1;
}

.funfact-btn.is-spinning .funfact-btn-icon {
    display: inline-block;
    animation: funfact-dice-spin 0.55s ease-in-out;
}

@keyframes funfact-dice-spin {
    0% { transform: rotate(0deg) scale(1); }
    45% { transform: rotate(180deg) scale(1.15); }
    100% { transform: rotate(360deg) scale(1); }
}

.funfact-cats-wrap {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 620px;
    margin: 24px auto 30px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.funfact-cats {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    width: 100%;
}

.funfact-cats-rest {
    display: flex;
    flex-wrap: nowrap;
    justify-content: flex-start;
    justify-content: safe center;
    align-items: center;
    gap: 6px;
    width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 2px 0;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
}

.funfact-cats-rest::-webkit-scrollbar {
    display: none;
}

/* Give the category strip a bit more room on desktop so every category
   (except the featured "Wszystkie") fits on a single line. The strip is
   centred on the page, extending symmetrically past the narrow card. */
@media (min-width: 768px) {
    .funfact-cats-wrap {
        width: min(920px, 92vw);
        max-width: none;
        margin-left: 50%;
        transform: translateX(-50%);
    }
}

.funfact-cat {
    padding: 7px 9px;
    border-radius: 999px;
    font: inherit;
    font-size: 0.78rem;
    font-weight: 600;
    line-height: 1;
    cursor: pointer;
    color: var(--text-muted);
    border: 1px solid var(--border-soft);
    background: var(--surface);
    transition: color 0.2s ease, border-color 0.2s ease, background 0.2s ease, transform 0.2s var(--ease-out, ease), box-shadow 0.2s ease;
}

.funfact-cat:hover {
    color: var(--accent);
    border-color: rgba(37, 99, 235, 0.35);
    transform: translateY(-1px);
}

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

.funfact-cat.is-active {
    color: #fff;
    border-color: transparent;
    background: linear-gradient(135deg, var(--accent-soft), var(--primary));
    box-shadow: 0 6px 18px rgba(37, 99, 235, 0.28);
}

[data-theme='dark'] .funfact-cat {
    border-color: rgba(147, 197, 253, 0.14);
    background: rgba(26, 35, 56, 0.55);
    color: var(--text-muted);
}

[data-theme='dark'] .funfact-cat:hover {
    color: var(--accent-soft);
    border-color: rgba(147, 197, 253, 0.4);
}

[data-theme='dark'] .funfact-cat.is-active {
    color: #0b1020;
    background: linear-gradient(135deg, var(--accent-hot), var(--accent-soft));
    box-shadow: 0 0 20px rgba(37, 99, 235, 0.35);
}

/* Featured "Wszystkie" chip — own row, more prominent. */
.funfact-cat--all {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    padding: 12px 26px;
    font-size: 0.98rem;
    font-weight: 800;
    letter-spacing: 0.02em;
    color: var(--accent);
    border: 1px solid rgba(37, 99, 235, 0.4);
    background: linear-gradient(135deg, rgba(37, 99, 235, 0.12), rgba(128, 0, 0, 0.08));
    box-shadow: 0 8px 22px rgba(37, 99, 235, 0.16);
}

.funfact-cat--all:hover {
    color: var(--accent);
    border-color: rgba(37, 99, 235, 0.62);
    transform: translateY(-1px);
    box-shadow: 0 10px 26px rgba(37, 99, 235, 0.22);
}

.funfact-cat--all.is-active {
    color: #fff;
    border-color: transparent;
    background: linear-gradient(135deg, var(--accent-soft), var(--primary));
    box-shadow: 0 12px 28px rgba(37, 99, 235, 0.34);
}

.funfact-cat-star {
    font-size: 0.9em;
    line-height: 1;
    opacity: 0.85;
}

.funfact-cat-count {
    padding: 2px 10px;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 800;
    background: rgba(37, 99, 235, 0.14);
    color: inherit;
}

.funfact-cat--all.is-active .funfact-cat-count {
    background: rgba(255, 255, 255, 0.24);
}

[data-theme='dark'] .funfact-cat--all {
    color: var(--accent-soft);
    border-color: rgba(147, 197, 253, 0.4);
    background: linear-gradient(135deg, rgba(37, 99, 235, 0.2), rgba(128, 0, 0, 0.18));
    box-shadow: 0 0 22px rgba(37, 99, 235, 0.2);
}

[data-theme='dark'] .funfact-cat--all:hover {
    color: var(--accent-soft);
    border-color: rgba(147, 197, 253, 0.62);
}

[data-theme='dark'] .funfact-cat--all.is-active {
    color: #0b1020;
    background: linear-gradient(135deg, var(--accent-hot), var(--accent-soft));
    box-shadow: 0 0 26px rgba(37, 99, 235, 0.42);
}

[data-theme='dark'] .funfact-cat--all .funfact-cat-count {
    background: rgba(255, 255, 255, 0.2);
}

.funfact-counter {
    margin: 10px 0 0;
    text-align: center;
    font-size: 0.82rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    color: var(--text-muted);
}

[data-theme='dark'] .funfact-counter {
    color: var(--text-muted);
}


.fun-fakty-page .info-callout {
    margin-top: 32px;
}

@media (max-width: 767px) {
    .funfact-card {
        min-height: 300px;
        padding: 32px 22px 28px;
    }

    .funfact-emoji {
        font-size: 2.6rem;
    }

    .funfact-text {
        font-size: 1.12rem;
    }

    .funfact-btn {
        width: 100%;
    }

    /* Keep the tiny secondary action small even when the primary button goes full-width. */
    .funfact-btn--ghost {
        width: auto;
        padding: 5px 12px;
    }

    .funfact-controls {
        flex-direction: column;
    }

    /* Single-line category strip: keep it on one line and let it scroll
       horizontally instead of wrapping onto a second row. */
    .funfact-cats-wrap {
        margin-top: 20px;
        margin-bottom: 24px;
    }

    .funfact-cats {
        gap: 12px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .funfact-card.is-reveal,
    .funfact-btn.is-spinning .funfact-btn-icon,
    [data-theme='dark'] .funfact-card::before,
    [data-theme='dark'] .funfact-card-glow {
        animation: none;
    }
}
