/**
 * YouTube Government Access Channel - Frontend Styles
 * 
 * CSS Custom Properties set by plugin:
 * --yga-primary: Primary brand color
 * --yga-secondary: Secondary/accent color
 */

/* ===================================
   CSS Variables & Base
   =================================== */

:root {
    --yga-primary: #1a365d;
    --yga-secondary: #2b6cb0;
    --yga-text: #1a202c;
    --yga-text-light: #4a5568;
    --yga-bg: #ffffff;
    --yga-bg-alt: #f7fafc;
    --yga-border: #e2e8f0;
    --yga-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    --yga-shadow-lg: 0 4px 6px rgba(0, 0, 0, 0.1);
    --yga-radius: 8px;
    --yga-radius-sm: 4px;
    --yga-transition: 0.2s ease;
}

/* ===================================
   Section Titles
   =================================== */

.yga-section-title {
    color: var(--yga-primary);
    font-size: 1.5rem;
    font-weight: 600;
    margin: 0 0 1rem 0;
    padding: 0;
    line-height: 1.3;
}

/* ===================================
   Video Container (Responsive Embed)
   =================================== */

.yga-video-container {
    position: relative;
    width: 100%;
    padding-bottom: 56.25%; /* 16:9 aspect ratio */
    height: 0;
    overflow: hidden;
    background: #000;
    border-radius: var(--yga-radius);
}

.yga-video-container iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: 0;
}

/* ===================================
   Live Stream
   =================================== */

.yga-live-stream-wrapper {
    margin-bottom: 2rem;
}

.yga-live-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
    font-size: 0.875rem;
    color: var(--yga-text-light);
}

.yga-live-indicator {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #a0aec0;
    transition: background var(--yga-transition);
}

.yga-live-status.is-live .yga-live-indicator {
    background: #e53e3e;
    animation: yga-pulse 1.5s infinite;
}

.yga-live-status.is-live .yga-live-text {
    color: #e53e3e;
    font-weight: 600;
}

@keyframes yga-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.yga-offline-message {
    text-align: center;
    padding: 3rem 2rem;
    background: var(--yga-bg-alt);
    border-radius: var(--yga-radius);
    border: 1px solid var(--yga-border);
}

.yga-offline-icon {
    margin-bottom: 1rem;
}

.yga-offline-icon svg {
    width: 48px;
    height: 48px;
    color: var(--yga-text-light);
}

.yga-offline-message p {
    margin: 0 0 1rem;
    color: var(--yga-text);
}

.yga-subscribe-prompt {
    font-size: 0.875rem;
    color: var(--yga-text-light);
}

/* ===================================
   Video Grid
   =================================== */

.yga-video-grid {
    display: grid;
    gap: 1.5rem;
}

.yga-columns-1 { grid-template-columns: 1fr; }
.yga-columns-2 { grid-template-columns: repeat(2, 1fr); }
.yga-columns-3 { grid-template-columns: repeat(3, 1fr); }
.yga-columns-4 { grid-template-columns: repeat(4, 1fr); }

@media (max-width: 1024px) {
    .yga-columns-4 { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 768px) {
    .yga-columns-3,
    .yga-columns-4 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 480px) {
    .yga-columns-2,
    .yga-columns-3,
    .yga-columns-4 { grid-template-columns: 1fr; }
}

/* ===================================
   Video Card
   =================================== */

.yga-video-card {
    background: var(--yga-bg);
    border-radius: var(--yga-radius);
    overflow: hidden;
    box-shadow: var(--yga-shadow);
    transition: transform var(--yga-transition), box-shadow var(--yga-transition);
}

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

.yga-video-link {
    display: block;
    text-decoration: none;
    color: inherit;
}

.yga-video-link:hover,
.yga-video-link:focus {
    text-decoration: none;
    color: inherit;
}

.yga-thumbnail-wrapper {
    position: relative;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    background: #000;
}

.yga-thumbnail-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform var(--yga-transition);
}

.yga-video-card:hover .yga-thumbnail-wrapper img {
    transform: scale(1.05);
}

.yga-duration {
    position: absolute;
    bottom: 8px;
    right: 8px;
    background: rgba(0, 0, 0, 0.85);
    color: #fff;
    font-size: 0.75rem;
    font-weight: 500;
    padding: 2px 6px;
    border-radius: var(--yga-radius-sm);
}

.yga-video-info {
    padding: 1rem;
}

.yga-video-title {
    font-size: 0.9375rem;
    font-weight: 600;
    line-height: 1.4;
    margin: 0 0 0.5rem;
    color: var(--yga-text);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.yga-video-date {
    display: block;
    font-size: 0.8125rem;
    color: var(--yga-text-light);
}

/* ===================================
   List View
   =================================== */

.yga-video-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.yga-video-list .yga-video-card {
    display: flex;
    flex-direction: row;
}

.yga-video-list .yga-thumbnail-wrapper {
    flex-shrink: 0;
    width: 240px;
    aspect-ratio: 16 / 9;
}

.yga-video-list .yga-video-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

@media (max-width: 600px) {
    .yga-video-list .yga-video-card {
        flex-direction: column;
    }
    
    .yga-video-list .yga-thumbnail-wrapper {
        width: 100%;
    }
}

/* ===================================
   Archive Controls
   =================================== */

.yga-archive-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.5rem;
    align-items: center;
}

.yga-search-box {
    display: flex;
    flex: 1;
    min-width: 200px;
    max-width: 400px;
}

.yga-search-input {
    flex: 1;
    padding: 0.625rem 1rem;
    border: 1px solid var(--yga-border);
    border-right: none;
    border-radius: var(--yga-radius) 0 0 var(--yga-radius);
    font-size: 0.9375rem;
    background: var(--yga-bg);
    color: var(--yga-text);
}

.yga-search-input:focus {
    outline: none;
    border-color: var(--yga-secondary);
}

.yga-search-button {
    padding: 0.625rem 1rem;
    background: var(--yga-secondary);
    border: 1px solid var(--yga-secondary);
    border-radius: 0 var(--yga-radius) var(--yga-radius) 0;
    color: #fff;
    cursor: pointer;
    transition: background var(--yga-transition);
}

.yga-search-button:hover {
    background: var(--yga-primary);
    border-color: var(--yga-primary);
}

.yga-filter-select {
    padding: 0.625rem 2rem 0.625rem 1rem;
    border: 1px solid var(--yga-border);
    border-radius: var(--yga-radius);
    font-size: 0.9375rem;
    background: var(--yga-bg);
    color: var(--yga-text);
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%234a5568' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
}

.yga-view-toggle {
    display: flex;
    gap: 0;
    margin-left: auto;
}

.yga-view-btn {
    padding: 0.5rem 0.75rem;
    background: var(--yga-bg);
    border: 1px solid var(--yga-border);
    color: var(--yga-text-light);
    cursor: pointer;
    transition: all var(--yga-transition);
}

.yga-view-btn:first-child {
    border-radius: var(--yga-radius) 0 0 var(--yga-radius);
}

.yga-view-btn:last-child {
    border-radius: 0 var(--yga-radius) var(--yga-radius) 0;
    border-left: none;
}

.yga-view-btn.active,
.yga-view-btn:hover {
    background: var(--yga-secondary);
    border-color: var(--yga-secondary);
    color: #fff;
}

@media (max-width: 600px) {
    .yga-archive-controls {
        flex-direction: column;
        align-items: stretch;
    }
    
    .yga-search-box {
        max-width: none;
    }
    
    .yga-view-toggle {
        margin-left: 0;
        justify-content: flex-end;
    }
}

/* ===================================
   Buttons
   =================================== */

.yga-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    background: var(--yga-secondary);
    color: #fff;
    border: none;
    border-radius: var(--yga-radius);
    font-size: 0.9375rem;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    transition: background var(--yga-transition);
}

.yga-button:hover {
    background: var(--yga-primary);
    color: #fff;
    text-decoration: none;
}

.yga-subscribe-button {
    background: #c4302b;
}

.yga-subscribe-button:hover {
    background: #a82621;
}

/* ===================================
   Pagination & Load More
   =================================== */

.yga-pagination {
    margin-top: 2rem;
    text-align: center;
}

.yga-load-more {
    min-width: 200px;
}

/* ===================================
   Playlist Footer
   =================================== */

.yga-playlist-footer {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--yga-border);
}

.yga-view-all-link {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    color: var(--yga-secondary);
    text-decoration: none;
    font-size: 0.9375rem;
    font-weight: 500;
}

.yga-view-all-link:hover {
    color: var(--yga-primary);
    text-decoration: underline;
}

/* ===================================
   Single Video
   =================================== */

.yga-single-video-wrapper {
    margin-bottom: 2rem;
}

.yga-single-title {
    margin-bottom: 1rem;
}

.yga-video-description {
    margin-top: 1rem;
    padding: 1rem;
    background: var(--yga-bg-alt);
    border-radius: var(--yga-radius);
    font-size: 0.9375rem;
    line-height: 1.6;
    color: var(--yga-text);
    white-space: pre-wrap;
}

.yga-video-meta {
    margin-top: 1rem;
}

.yga-watch-youtube {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    color: var(--yga-text-light);
    text-decoration: none;
    font-size: 0.875rem;
}

.yga-watch-youtube:hover {
    color: var(--yga-secondary);
}

/* ===================================
   Loading States
   =================================== */

.yga-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    grid-column: 1 / -1;
}

.yga-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--yga-border);
    border-top-color: var(--yga-secondary);
    border-radius: 50%;
    animation: yga-spin 0.8s linear infinite;
}

@keyframes yga-spin {
    to { transform: rotate(360deg); }
}

/* ===================================
   Error & Empty States
   =================================== */

.yga-error {
    padding: 1rem 1.5rem;
    background: #fed7d7;
    border: 1px solid #fc8181;
    border-radius: var(--yga-radius);
    color: #c53030;
    font-size: 0.9375rem;
}

.yga-no-results {
    text-align: center;
    padding: 3rem 2rem;
    background: var(--yga-bg-alt);
    border-radius: var(--yga-radius);
    color: var(--yga-text-light);
}

.yga-noscript-message {
    padding: 2rem;
    background: var(--yga-bg-alt);
    border-radius: var(--yga-radius);
    text-align: center;
}

.yga-noscript-message a {
    color: var(--yga-secondary);
}

/* ===================================
   Carousel
   =================================== */

.yga-layout-carousel .yga-video-carousel {
    position: relative;
    overflow: hidden;
}

.yga-carousel-track {
    display: flex;
    gap: 1rem;
    transition: transform 0.3s ease;
}

.yga-carousel-track .yga-video-card {
    flex-shrink: 0;
    width: calc(33.333% - 0.667rem);
}

@media (max-width: 768px) {
    .yga-carousel-track .yga-video-card {
        width: calc(50% - 0.5rem);
    }
}

@media (max-width: 480px) {
    .yga-carousel-track .yga-video-card {
        width: 100%;
    }
}

.yga-carousel-controls {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 1rem;
}

.yga-carousel-prev,
.yga-carousel-next {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--yga-bg);
    border: 1px solid var(--yga-border);
    border-radius: 50%;
    cursor: pointer;
    transition: all var(--yga-transition);
}

.yga-carousel-prev:hover,
.yga-carousel-next:hover {
    background: var(--yga-secondary);
    border-color: var(--yga-secondary);
    color: #fff;
}

.yga-carousel-prev svg,
.yga-carousel-next svg {
    width: 20px;
    height: 20px;
}

/* ===================================
   Accessibility
   =================================== */

.screen-reader-text {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.yga-video-link:focus,
.yga-button:focus,
.yga-search-input:focus,
.yga-filter-select:focus,
.yga-view-btn:focus {
    outline: 2px solid var(--yga-secondary);
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .yga-video-card {
        border: 2px solid var(--yga-text);
    }
    
    .yga-button {
        border: 2px solid currentColor;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Print styles */
@media print {
    .yga-video-container,
    .yga-live-stream-wrapper,
    .yga-archive-controls {
        display: none;
    }
    
    .yga-video-grid {
        display: block;
    }
    
    .yga-video-card {
        page-break-inside: avoid;
        margin-bottom: 1rem;
        box-shadow: none;
        border: 1px solid #000;
    }
}
