/**
 * Humor Pack - Public Styles
 * @version 1.1.0
 */

/* ============================================
   CSS Variables
   ============================================ */
.humor-pack {
    --hp-primary: #f59e0b;
    --hp-primary-dark: #d97706;
    --hp-secondary: #f43f5e;
    --hp-secondary-dark: #e11d48;
    --hp-success: #10b981;
    --hp-bg: #f8fafc;
    --hp-surface: #ffffff;
    --hp-text: #1e293b;
    --hp-text-muted: #64748b;
    --hp-border: #e2e8f0;
    --hp-border-light: #f1f5f9;
    --hp-radius: 1rem;
    --hp-radius-lg: 1.5rem;
    --hp-shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.04);
    --hp-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.08), 0 1px 2px -1px rgba(0, 0, 0, 0.04);
    --hp-shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
    --hp-transition: 200ms cubic-bezier(0.4, 0, 0.2, 1);
    --hp-font: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
}

/* ============================================
   Base Styles
   ============================================ */
.humor-pack {
    font-family: var(--hp-font);
    color: var(--hp-text);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    max-width: 1100px;
    margin: 0 auto;
    padding: 1rem;
    box-sizing: border-box;
}

.humor-pack *,
.humor-pack *::before,
.humor-pack *::after {
    box-sizing: border-box;
}

.humor-pack p {
    margin: 0;
}

/* SEO H1 - скрытый визуально, доступный SEO */
.hp-seo-title {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

/* ============================================
   Hero Section
   ============================================ */
.hp-hero {
    position: relative;
    background: linear-gradient(135deg, #f59e0b 0%, #f97316 50%, #f43f5e 100%);
    border-radius: var(--hp-radius-lg);
    padding: 2rem;
    margin-bottom: 1.5rem;
    overflow: hidden;
    box-shadow: 0 20px 40px -15px rgba(245, 158, 11, 0.4);
    color: #fff;
}

.hp-hero-bg {
    position: absolute;
    top: -30%;
    right: -10%;
    width: 50%;
    height: 160%;
    background: rgba(255, 255, 255, 0.12);
    border-radius: 50%;
    filter: blur(60px);
    pointer-events: none;
}

.hp-hero-content {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

@media (min-width: 768px) {
    .hp-hero {
        padding: 2.5rem;
    }
    .hp-hero-content {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
    }
}

.hp-hero-text {
    flex: 1;
    max-width: 700px;
}

.hp-hero-label {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
    font-size: 0.8125rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: rgba(255, 255, 255, 0.92);
}

.hp-icon-sparkle {
    width: 1.125rem;
    height: 1.125rem;
}

.hp-hero-quote {
    position: relative;
    padding-left: 1.75rem;
}

.hp-quote-icon {
    position: absolute;
    left: 0;
    top: 0.25rem;
    width: 1.25rem;
    height: 1.25rem;
    color: rgba(255, 255, 255, 0.55);
}

.hp-hero-joke-text {
    font-size: 1.25rem;
    font-weight: 600;
    line-height: 1.55;
    color: #fff;
    transition: opacity 250ms ease, transform 250ms ease;
}

.hp-hero-joke-text p {
    margin: 0 0 0.5rem 0;
}

.hp-hero-joke-text p:last-child {
    margin-bottom: 0;
}

@media (min-width: 768px) {
    .hp-hero-joke-text {
        font-size: 1.4rem;
    }
}

.hp-hero-action {
    flex-shrink: 0;
}

/* ============================================
   Buttons (Hero)
   ============================================ */
.hp-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.875rem 1.25rem;
    font-size: 0.9375rem;
    font-weight: 600;
    font-family: inherit;
    border-radius: var(--hp-radius);
    border: 1px solid rgba(255, 255, 255, 0.35);
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
    cursor: pointer;
    transition: all var(--hp-transition);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.hp-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-1px);
}

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

.hp-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.hp-icon {
    width: 1.125rem;
    height: 1.125rem;
    flex-shrink: 0;
}

.hp-icon-refresh {
    transition: transform 0.5s ease;
}

.hp-btn-refresh.spinning .hp-icon-refresh {
    animation: hp-spin 0.8s linear infinite;
}

@keyframes hp-spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* ============================================
   Controls
   ============================================ */
.hp-controls {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

@media (min-width: 640px) {
    .hp-controls {
        flex-direction: row;
        align-items: center;
    }
}

.hp-search {
    position: relative;
    flex: 1;
}

.hp-search-icon {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    width: 1.125rem;
    height: 1.125rem;
    color: var(--hp-text-muted);
    pointer-events: none;
}

.hp-search-input {
    width: 100%;
    padding: 0.875rem 1rem 0.875rem 2.75rem;
    font-size: 0.9375rem;
    font-family: inherit;
    background: var(--hp-surface);
    border: 1px solid var(--hp-border);
    border-radius: var(--hp-radius);
    color: var(--hp-text);
    transition: all var(--hp-transition);
    box-shadow: var(--hp-shadow-sm);
    outline: none;
}

.hp-search-input:focus {
    border-color: var(--hp-primary);
    box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.15);
}

.hp-search-input::placeholder {
    color: var(--hp-text-muted);
}

.hp-sort-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.875rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    font-family: inherit;
    background: var(--hp-surface);
    border: 1px solid var(--hp-border);
    border-radius: var(--hp-radius);
    color: var(--hp-text-muted);
    cursor: pointer;
    transition: all var(--hp-transition);
    white-space: nowrap;
    box-shadow: var(--hp-shadow-sm);
}

.hp-sort-btn:hover {
    border-color: var(--hp-primary);
    color: var(--hp-text);
}

/* ============================================
   Categories
   ============================================ */
.hp-categories {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.625rem;
    margin-bottom: 2rem;
}

@media (min-width: 480px) {
    .hp-categories {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (min-width: 640px) {
    .hp-categories {
        grid-template-columns: repeat(4, 1fr);
    }
}

@media (min-width: 900px) {
    .hp-categories {
        grid-template-columns: repeat(7, 1fr);
    }
}

.hp-category-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 1rem 0.5rem;
    font-size: 0.75rem;
    font-weight: 600;
    font-family: inherit;
    background: var(--hp-surface);
    border: 1px solid var(--hp-border-light);
    border-radius: var(--hp-radius);
    color: var(--hp-text-muted);
    cursor: pointer;
    transition: all var(--hp-transition);
    text-align: center;
    line-height: 1.3;
    min-height: 84px;
}

.hp-category-btn:hover {
    border-color: rgba(245, 158, 11, 0.4);
    color: var(--hp-text);
    transform: translateY(-2px);
    box-shadow: var(--hp-shadow);
}

.hp-category-btn.active {
    background: var(--hp-primary);
    border-color: var(--hp-primary);
    color: #fff;
    box-shadow: 0 6px 20px -5px rgba(245, 158, 11, 0.5);
}

.hp-category-btn.active:hover {
    transform: translateY(-2px);
}

.hp-category-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.hp-category-icon svg {
    width: 1.5rem;
    height: 1.5rem;
    color: currentColor;
}

.hp-category-btn:not(.active) .hp-category-icon svg {
    color: var(--hp-primary);
}

.hp-category-name {
    display: block;
}

/* ============================================
   Section Title
   ============================================ */
.hp-section-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--hp-text);
    margin: 0 0 1rem 0;
    line-height: 1.2;
}

@media (min-width: 768px) {
    .hp-section-title {
        font-size: 1.875rem;
    }
}

/* ============================================
   Favorites Toggle
   ============================================ */
.hp-favorites-toggle {
    margin-bottom: 1.25rem;
}

.hp-btn-favorites {
    background: var(--hp-surface);
    border: 1px solid var(--hp-border);
    color: var(--hp-text-muted);
    padding: 0.625rem 1rem;
    font-size: 0.875rem;
    box-shadow: var(--hp-shadow-sm);
    backdrop-filter: none;
}

.hp-btn-favorites:hover {
    border-color: var(--hp-secondary);
    color: var(--hp-secondary);
    background: rgba(244, 63, 94, 0.05);
    transform: translateY(-1px);
}

.hp-btn-favorites.active {
    background: var(--hp-secondary);
    border-color: var(--hp-secondary);
    color: #fff;
}

.hp-btn-favorites.active svg {
    fill: currentColor;
}

.hp-favorites-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.375rem;
    height: 1.375rem;
    padding: 0 0.375rem;
    font-size: 0.75rem;
    font-weight: 700;
    background: rgba(0, 0, 0, 0.08);
    border-radius: 999px;
    line-height: 1;
}

.hp-btn-favorites.active .hp-favorites-count {
    background: rgba(255, 255, 255, 0.25);
}

/* ============================================
   Jokes Grid
   ============================================ */
.hp-jokes-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.25rem;
}

@media (min-width: 768px) {
    .hp-jokes-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ============================================
   Joke Card
   ============================================ */
.hp-joke-card {
    background: var(--hp-surface);
    border: 1px solid var(--hp-border-light);
    border-radius: var(--hp-radius-lg);
    padding: 1.5rem;
    transition: box-shadow var(--hp-transition), transform var(--hp-transition);
    box-shadow: var(--hp-shadow-sm);
    
    /* Анимация появления */
    opacity: 0;
    animation: hp-card-in 400ms cubic-bezier(0.16, 1, 0.3, 1) forwards;
    will-change: opacity, transform;
}

@keyframes hp-card-in {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.hp-joke-card:hover {
    box-shadow: var(--hp-shadow-lg);
    transform: translateY(-2px);
}

.hp-joke-card.hp-removing {
    animation: hp-card-out 300ms ease forwards;
}

@keyframes hp-card-out {
    to {
        opacity: 0;
        transform: translateY(-10px) scale(0.95);
    }
}

.hp-joke-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.hp-joke-category {
    display: inline-flex;
    padding: 0.375rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 600;
    background: rgba(245, 158, 11, 0.1);
    color: var(--hp-primary-dark);
    border-radius: 999px;
    border: 1px solid rgba(245, 158, 11, 0.2);
}

.hp-joke-favorite {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.25rem;
    height: 2.25rem;
    padding: 0;
    background: transparent;
    border: none;
    border-radius: 50%;
    color: var(--hp-text-muted);
    cursor: pointer;
    transition: all var(--hp-transition);
}

.hp-joke-favorite svg {
    width: 1.125rem;
    height: 1.125rem;
}

.hp-joke-favorite:hover {
    background: rgba(244, 63, 94, 0.08);
    color: var(--hp-secondary);
    transform: scale(1.1);
}

.hp-joke-favorite.active {
    color: var(--hp-secondary);
    background: rgba(244, 63, 94, 0.1);
}

.hp-joke-favorite.active svg {
    fill: currentColor;
}

.hp-joke-content {
    color: var(--hp-text);
    font-size: 1rem;
    line-height: 1.65;
    margin-bottom: 1.25rem;
    font-weight: 450;
}

.hp-joke-content p {
    margin: 0 0 0.5rem 0;
}

.hp-joke-content p:last-child {
    margin-bottom: 0;
}

.hp-joke-footer {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    padding-top: 1rem;
    border-top: 1px solid var(--hp-border-light);
}

.hp-vote-buttons {
    display: flex;
    gap: 0.375rem;
}

.hp-vote-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    font-weight: 600;
    font-family: inherit;
    background: transparent;
    border: 1px solid var(--hp-border);
    border-radius: 0.5rem;
    color: var(--hp-text-muted);
    cursor: pointer;
    transition: all var(--hp-transition);
    user-select: none;
}

.hp-vote-btn svg {
    width: 1rem;
    height: 1rem;
}

.hp-vote-btn span {
    font-variant-numeric: tabular-nums;
}

.hp-vote-btn:hover {
    border-color: currentColor;
    transform: translateY(-1px);
}

.hp-vote-btn:active {
    transform: scale(0.95);
}

.hp-vote-btn.like:hover {
    color: var(--hp-success);
    background: rgba(16, 185, 129, 0.06);
}

.hp-vote-btn.like.active {
    background: var(--hp-success);
    border-color: var(--hp-success);
    color: #fff;
}

.hp-vote-btn.dislike:hover {
    color: var(--hp-secondary);
    background: rgba(244, 63, 94, 0.06);
}

.hp-vote-btn.dislike.active {
    background: var(--hp-secondary);
    border-color: var(--hp-secondary);
    color: #fff;
}

/* ============================================
   Share Buttons
   ============================================ */
.hp-share-buttons {
    display: flex;
    gap: 0.375rem;
}

.hp-share-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.25rem;
    height: 2.25rem;
    padding: 0;
    background: transparent;
    border: 1px solid var(--hp-border);
    border-radius: 0.5rem;
    color: var(--hp-text-muted);
    cursor: pointer;
    transition: all var(--hp-transition);
    text-decoration: none;
    font-family: inherit;
}

.hp-share-btn svg {
    width: 1rem;
    height: 1rem;
}

.hp-share-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--hp-shadow);
}

.hp-share-btn.telegram:hover {
    color: #fff;
    background: #26a5e4;
    border-color: #26a5e4;
}

.hp-share-btn.whatsapp:hover {
    color: #fff;
    background: #25d366;
    border-color: #25d366;
}

.hp-share-btn.viber:hover {
    color: #fff;
    background: #7360f2;
    border-color: #7360f2;
}

/* ============================================
   Empty State
   ============================================ */
.hp-empty {
    text-align: center;
    padding: 3rem 2rem;
    background: var(--hp-surface);
    border: 1px solid var(--hp-border-light);
    border-radius: var(--hp-radius-lg);
    animation: hp-card-in 300ms ease forwards;
}

.hp-empty-icon {
    width: 3.5rem;
    height: 3.5rem;
    color: var(--hp-text-muted);
    opacity: 0.4;
    margin: 0 auto 1rem;
    display: block;
}

.hp-empty h3 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--hp-text);
    margin: 0 0 0.5rem 0;
}

.hp-empty p {
    color: var(--hp-text-muted);
    margin: 0;
}

/* ============================================
   Error
   ============================================ */
.humor-pack-error {
    font-family: var(--hp-font);
}

/* ============================================
   Responsive
   ============================================ */
@media (max-width: 480px) {
    .humor-pack {
        padding: 0.5rem;
    }
    
    .hp-hero {
        padding: 1.5rem;
    }
    
    .hp-hero-joke-text {
        font-size: 1.0625rem;
    }
    
    .hp-joke-footer {
        gap: 0.5rem;
    }
    
    .hp-vote-btn {
        padding: 0.5rem 0.625rem;
        font-size: 0.8125rem;
    }
    
    .hp-share-btn {
        width: 2rem;
        height: 2rem;
    }
}

/* ============================================
   Print
   ============================================ */
@media print {
    .hp-hero,
    .hp-controls,
    .hp-favorites-toggle,
    .hp-categories,
    .hp-joke-footer {
        display: none !important;
    }
    
    .hp-joke-card {
        break-inside: avoid;
        box-shadow: none;
        border: 1px solid #ddd;
        animation: none;
        opacity: 1;
    }
}

/* ============================================
   Reduce Motion
   ============================================ */
@media (prefers-reduced-motion: reduce) {
    .humor-pack *,
    .humor-pack *::before,
    .humor-pack *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
