/*
 * Public Page Common Styles
 * Shared styles for all public-facing pages (not admin).
 * Load after common.css, before page-specific <style>.
 *
 * Usage: <%= stylesheet_link_tag "public_common" %>
 *
 * Components:
 *   1. Semantic color variables (medals, trophies, badges)
 *   2. Breadcrumb (URL-hierarchy based, fixed rule)
 *   3. Section header (border-left accent + icon + h2)
 *   4. Ad slot (separator line + "sponsor" label)
 *   5. Share section (social buttons + URL copy)
 *   6. Guest CTA (accent gradient)
 *   7. Level filter (image-based, CloudFront)
 *   8. Sort / filter controls
 */

/* ===================================================
   1. Semantic Color Variables
   =================================================== */
:root {
  --youtube-red: #ff0000;
  --medal-gold: #ffd700;
  --medal-gold-dim: #f0c800;
  --medal-gold-shadow: rgba(255, 215, 0, 0.3);
  --medal-gold-text: #5a3e00;
  --medal-silver: #c0c0c0;
  --medal-silver-dim: #e8e8e8;
  --medal-silver-text: #444;
  --medal-bronze: #cd7f32;
  --medal-bronze-dim: #e8a060;
  --trophy-gold: #ffb700;
  --trophy-silver: #d0d0d0;
  --trophy-bronze: #b8722c;
  --success-green: #22c55e;
  --badge-popular-bg: rgba(255, 59, 48, 0.12);
  --badge-popular-fg: #e53e3e;
  --badge-beginner-bg: rgba(72, 187, 120, 0.12);
  --badge-beginner-fg: #38a169;
  --badge-expert-bg: rgba(159, 122, 234, 0.12);
  --badge-expert-fg: #805ad5;
}

/* ===================================================
   2. Breadcrumb
   Fixed URL-hierarchy rule (not navigation-based):
     /                    -> (none)
     /movies/:id          -> Home > (title)
     /channels            -> Home > Channels
     /channels/:slug      -> Home > Channels > (name)
     /discover            -> Home > Discover
     /discover/:list      -> Home > Discover > (list)
     /kids                -> Home > Kids
   =================================================== */
.pub-breadcrumb {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.75rem;
    margin-bottom: 1rem;
    color: var(--text-muted);
}

.pub-breadcrumb a {
    color: var(--text-secondary);
    text-decoration: none;
    transition: color 0.2s;
    padding: 4px 2px;
}

.pub-breadcrumb a:hover {
    color: var(--accent);
}

.pub-breadcrumb .breadcrumb-sep {
    font-size: 0.6rem;
    opacity: 0.5;
}

.pub-breadcrumb .breadcrumb-current {
    color: var(--text-primary);
    font-weight: 500;
}

/* ===================================================
   3. Section Header (border-left accent)
   Pattern: icon + h2 + optional count badge
   =================================================== */
.pub-section-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    padding-left: 0.75rem;
    border-bottom: 1px solid var(--border-color);
    border-left: 3px solid var(--accent);
}

.pub-section-header i {
    color: var(--accent);
    font-size: 1.1rem;
}

.pub-section-header h2 {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

.pub-section-header .section-count {
    margin-left: auto;
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 600;
}

/* ===================================================
   4. Ad Slot
   Separator line + "sponsor" label + dashed placeholder
   =================================================== */
.pub-ad {
    margin-top: 2rem;
    margin-bottom: 2rem;
    padding-top: 1.5rem;
    position: relative;
}

.pub-ad::before {
    content: '';
    position: absolute;
    top: 0;
    left: 5%;
    right: 5%;
    height: 1px;
    background: var(--border-color);
    opacity: 0.4;
}

.pub-ad-label {
    text-align: center;
    font-size: 0.65rem;
    color: var(--text-muted);
    margin-bottom: 0.375rem;
    opacity: 0.5;
    letter-spacing: 0.05em;
}

.pub-ad-space {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
    padding: 1.5rem;
    border: 2px dashed var(--border-color);
    border-radius: var(--card-radius);
    color: var(--text-muted);
    font-size: 0.78rem;
    text-align: center;
    min-height: 90px;
    opacity: 0.6;
}

.pub-ad-space i {
    font-size: 1.25rem;
    opacity: 0.5;
}

.pub-ad-space-sm {
    min-height: 80px;
}

/* Mobile: tighter ad margins */
@media (max-width: 640px) {
    .pub-ad {
        margin-top: 1.25rem;
        margin-bottom: 1.25rem;
        padding-top: 1rem;
    }

    .pub-ad-space {
        min-height: 50px;
        padding: 1rem;
        font-size: 0.7rem;
    }
}

/* --- Player Overlay Ad Slot (dark theme) --- */
.player-ad-slot {
    margin: 1rem auto;
    padding: 0.75rem;
    max-width: 480px;
}

.player-ad-slot .pub-ad {
    margin: 0;
    padding-top: 0;
}

.player-ad-slot .pub-ad::before {
    display: none;
}

.player-ad-slot .pub-ad-label {
    color: rgba(255,255,255,0.35);
}

.player-ad-slot .pub-ad-space {
    border-color: rgba(255,255,255,0.15);
    color: rgba(255,255,255,0.3);
    min-height: 70px;
    padding: 1rem;
    background: rgba(255,255,255,0.03);
}

/* --- Player Error Back Button --- */
.player-error-back-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 2rem;
    margin-top: 1rem;
    border: 1px solid rgba(255,255,255,0.25);
    border-radius: 8px;
    background: rgba(255,255,255,0.08);
    color: rgba(255,255,255,0.7);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
}

.player-error-back-btn:hover {
    background: rgba(255,255,255,0.15);
    border-color: rgba(255,255,255,0.4);
    color: #fff;
}

/* ===================================================
   5. Share Section
   Social buttons (X, FB, LINE) + URL copy
   =================================================== */
.pub-share {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem 1rem;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--card-radius);
    margin-bottom: 1.5rem;
}

.pub-share-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    white-space: nowrap;
}

.pub-share-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 1px solid var(--border-color);
    background: transparent;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.9rem;
    transition: all 0.2s;
    cursor: pointer;
}

.pub-share-btn:hover {
    border-color: rgba(var(--accent-rgb), 0.3);
    color: var(--accent);
}

.pub-share-url {
    flex: 1;
    min-width: 0;
    padding: 0.375rem 0.5rem;
    font-size: 0.72rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background: var(--body-bg);
    color: var(--text-muted);
    font-family: monospace;
}

@media (max-width: 640px) {
    .pub-share {
        flex-wrap: wrap;
    }
}

/* ===================================================
   6. Guest CTA
   Accent gradient background + action button
   =================================================== */
.pub-guest-cta {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.25rem;
    background: linear-gradient(135deg,
        rgba(var(--accent-rgb), 0.08) 0%,
        rgba(var(--accent-rgb), 0.02) 100%
    );
    border: 1px solid rgba(var(--accent-rgb), 0.2);
    border-radius: var(--card-radius);
    margin-bottom: 1.5rem;
}

.pub-guest-cta-icon {
    font-size: 2rem;
    color: var(--accent);
    flex-shrink: 0;
}

.pub-guest-cta-body {
    flex: 1;
    min-width: 0;
}

.pub-guest-cta-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.pub-guest-cta-text {
    font-size: 0.8rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

.pub-guest-cta-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.5rem 1.25rem;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
    text-decoration: none;
    transition: opacity 0.2s, transform 0.2s;
    flex-shrink: 0;
}

.pub-guest-cta-btn:hover {
    opacity: 0.85;
    transform: translateY(-1px);
}

@media (max-width: 640px) {
    .pub-guest-cta {
        flex-direction: column;
        text-align: center;
        padding: 1rem;
    }

    .pub-guest-cta-btn {
        width: 100%;
        justify-content: center;
    }
}

/* ===================================================
   7. Level Filter (image-based, CloudFront)
   Consistent with top page (index.html)
   =================================================== */
.pub-level-filter-bar {
    margin-bottom: 1rem;
}

.pub-level-filter-wrapper {
    display: flex;
    gap: 0.5rem;
    overflow-x: auto;
    scrollbar-width: none;
    padding: 0.25rem 0;
}

.pub-level-filter-wrapper::-webkit-scrollbar { display: none; }

.pub-level-filter-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0.25rem;
    border: none;
    background: none;
    cursor: pointer;
    transition: all 0.2s ease;
    width: 15%;
    min-width: 80px;
}

.pub-level-filter-btn:hover {
    transform: scale(1.05);
}

.pub-level-filter-btn img {
    width: 100%;
    max-width: 120px;
    height: auto;
    display: block;
}

.pub-level-filter-btn .level-img-active { display: none; }
.pub-level-filter-btn .level-img-inactive { display: block; }
.pub-level-filter-btn.active .level-img-active,
.pub-level-filter-btn:hover .level-img-active { display: block; }
.pub-level-filter-btn.active .level-img-inactive,
.pub-level-filter-btn:hover .level-img-inactive { display: none; }

@media (max-width: 640px) {
    .pub-level-filter-wrapper { gap: 0.25rem; }
    .pub-level-filter-btn { min-width: 60px; }
}

/* ===================================================
   8. Sort / Filter Controls
   =================================================== */
.pub-filter-sort-row {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.pub-filter-sort-row label {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 600;
}

.pub-filter-select {
    padding: 0.375rem 0.75rem;
    font-size: 0.78rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--card-bg);
    color: var(--text-primary);
    cursor: pointer;
    appearance: auto;
}

/* ===================================================
   9. Support Box (FANBOX)
   Reusable component for FANBOX support links
   =================================================== */
.support-box {
    display: flex;
    gap: 1rem;
    padding: 1.25rem;
    margin-bottom: 1.5rem;
    background: linear-gradient(135deg, rgba(var(--accent-rgb), 0.08) 0%, rgba(var(--accent-rgb), 0.04) 100%);
    border: 1px solid rgba(var(--accent-rgb), 0.2);
    border-radius: var(--card-radius);
}

.support-box-icon {
    flex-shrink: 0;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: #ff4757;
    background: rgba(255, 71, 87, 0.1);
    border-radius: 50%;
}

.support-box-icon i {
    animation: heartbeat 1.5s ease-in-out infinite;
}

@keyframes heartbeat {
    0%, 100% {
        transform: scale(1);
    }
    10%, 30% {
        transform: scale(1.1);
    }
    20% {
        transform: scale(1);
    }
}

.support-box-content {
    flex: 1;
    min-width: 0;
}

.support-box-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.support-box-description {
    font-size: 0.8rem;
    line-height: 1.5;
    color: var(--text-secondary);
    margin-bottom: 0.875rem;
}

.support-box-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 1.125rem;
    font-size: 0.8125rem;
    font-weight: 600;
    color: #fff;
    background: linear-gradient(135deg, #ff4757 0%, #ff6348 100%);
    border: none;
    border-radius: 8px;
    text-decoration: none;
    cursor: pointer;
    transition: opacity 0.15s, transform 0.15s, box-shadow 0.15s;
    box-shadow: 0 2px 6px rgba(255, 71, 87, 0.25);
}

.support-box-btn:hover {
    opacity: 0.9;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(255, 71, 87, 0.35);
}

.support-box-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 6px rgba(255, 71, 87, 0.25);
}

.support-box-btn i {
    font-size: 0.875rem;
}

@media (max-width: 640px) {
    .support-box {
        flex-direction: column;
        text-align: center;
        padding: 1rem;
    }

    .support-box-icon {
        margin: 0 auto;
    }

    .support-box-btn {
        width: 100%;
        justify-content: center;
    }
}
