/**
 * Radio Station Theme - Header Styles
 * Large animated play button and header layout
 * 
 * @package Radio_Station_Theme
 */

/* ==========================================================================
   Site Header
   ========================================================================== */

.site-header {
    position: relative;
    z-index: 100;
    background: #1a1a1a;
    transition: background-color 0.35s ease;
    min-height: var(--header-height, 200px);
}

/* Header sticky when menu is below */
body.menu-below .site-header {
    position: sticky;
    top: 0;
    z-index: 1000;
}

/* Header sticky below menu when menu is above */
body.menu-above .site-header {
    position: sticky;
    top: 60px; /* Approximate nav height */
    z-index: 999;
}

/* Admin bar offset */
body.admin-bar.menu-below .site-header {
    top: 32px;
}

body.admin-bar.menu-above .site-header {
    top: calc(32px + 60px);
}

@media screen and (max-width: 782px) {
    /* On mobile nav is off-canvas drawer, so both positions use same top */
    body.admin-bar.menu-below .site-header,
    body.admin-bar.menu-above .site-header {
        top: 46px;
    }
}

/* Header shrink state */
.site-header.shrink {
    min-height: var(--header-shrink-height, 80px);
}

/* Header background */
.header-background {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    /* Gradient se postavlja kroz customizer ako nema slike */
    background-size: cover;
    background-position: center;
    z-index: -1;
    transition: opacity 0.35s ease;
}

/* Header container */
.header-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
    padding-bottom: 0;
    position: relative;
    z-index: 1;
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 30px;
    min-height: 160px;
    transition: min-height 0.3s ease;
}

.site-header.shrink .header-content {
    min-height: 30px;
}

/* ==========================================================================
   Large Animated Play Button (Left Side)
   ========================================================================== */

.header-play-button-wrap {
    display: flex;
    align-items: center;
    gap: 20px;
    flex-shrink: 0;
    position: relative;
    z-index: 2;
}

.header-play-button {
    position: relative;
    width: 120px;
    height: 120px;
    border: none;
    background: transparent;
    cursor: pointer;
    padding: 0;
    transition: all 0.3s ease;
    z-index: 10;
}

/* Play button keeps original size when header shrinks */
/* .header-play-button.shrink {
    transform: scale(0.5) translateY(20px);
} */

/* Animated border with conic gradient */
.play-button-border-animation {
    position: absolute;
    inset: -4px;
    border-radius: 50%;
    padding: 4px;
    background: conic-gradient(
        from 0deg,
        #ff0080,
        #ff8c00,
        #40e0d0,
        #0080ff,
        #8000ff,
        #ff0080
    );
    animation: rotateBorder 3s linear infinite;
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
}

@keyframes rotateBorder {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

/* Play button inner circle */
.play-button-inner {
    position: relative;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    transition: all 0.3s ease;
}

.header-play-button:hover .play-button-inner {
    background: rgba(255, 255, 255, 1);
    transform: scale(1.05);
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.4);
}

.header-play-button:active .play-button-inner {
    transform: scale(0.95);
}

/* Play/Pause icons */
.header-play-button svg {
    width: 40px;
    height: 40px;
    color: #667eea;
    transition: all 0.3s ease;
}

.header-play-button.is-playing .play-icon {
    display: none;
}

.header-play-button.is-playing .pause-icon {
    display: block !important;
}

/* Loading state */
.header-play-button.is-loading .play-button-inner::after {
    content: '';
    position: absolute;
    inset: 8px;
    border-radius: 50%;
    border: 3px solid rgba(102, 126, 234, 0.3);
    border-top-color: #667eea;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.header-play-button.is-loading svg {
    opacity: 0.3;
}

/* Station info (next to button) */
.header-station-info {
    display: flex;
    flex-direction: column;
    gap: 5px;
    color: #fff;
}

.station-name {
    font-size: 24px;
    font-weight: bold;
    line-height: 1.2;
    transition: font-size 0.3s ease;
}

.station-status {
    font-size: 24px;
    color: rgba(255, 255, 255, 0.8);
    font-weight: 300;
    transition: font-size 0.3s ease;
}

.listener-count {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: rgba(255, 255, 255, 0.9);
    font-weight: 400;
    margin-top: 3px;
    transition: font-size 0.3s ease, opacity 0.3s ease;
}

.listener-count svg {
    opacity: 0.8;
    flex-shrink: 0;
}

.listener-count #listener-count-number {
    font-weight: 500;
}

.site-header.shrink .station-name {
    font-size: 18px;
}

.site-header.shrink .station-status {
    font-size: 24px;
}

.site-header.shrink .listener-count {
    font-size: 11px;
}

/* ==========================================================================
   Site Branding (Center/Right)
   ========================================================================== */

.site-branding {
    flex: 1;
    text-align: right;
    position: relative;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: flex-end;
}

.site-title {
    margin: 0;
    font-size: 32px;
    font-weight: bold;
}

.site-title a {
    color: #fff;
    text-decoration: none;
    transition: opacity 0.3s ease;
}

.site-title a:hover {
    opacity: 0.8;
}

.site-description {
    margin: 5px 0 0;
    font-size: 14px;
    color: rgba(255, 255, 255, 0.7);
}

.custom-logo-link {
    display: inline-block;
}

.custom-logo {
    max-width: 350px;
    max-height: none;
    width: auto;
    height: auto;
    transition: max-width 0.3s ease, transform 0.3s ease;
}

.site-header.shrink .custom-logo {
    max-width: 120px;
}

/* ==========================================================================
   Mobile Menu Toggle
   ========================================================================== */

.menu-toggle {
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    width: 44px;
    height: 44px;
    padding: 8px;
    background: transparent;
    border: none;
    cursor: pointer;
    z-index: 1001;
}

.hamburger {
    width: 28px;
    height: 20px;
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.hamburger-line {
    width: 100%;
    height: 3px;
    background-color: #fff;
    transition: all 0.3s ease;
    border-radius: 2px;
}

/* Animated hamburger to X */
.menu-toggle.active .hamburger-line:nth-child(1) {
    transform: translateY(8.5px) rotate(45deg);
}

.menu-toggle.active .hamburger-line:nth-child(2) {
    opacity: 0;
}

.menu-toggle.active .hamburger-line:nth-child(3) {
    transform: translateY(-8.5px) rotate(-45deg);
}

.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-width: 0;
}

/* ==========================================================================
   Header Widgets (Optional)
   ========================================================================== */

.header-widgets {
    padding: 20px;
    text-align: center;
}

/* Hide on mobile by default */
.header-widgets {
    display: none;
}

/* ==========================================================================
   Responsive Design
   ========================================================================== */

/* Mobile logo — hidden on desktop, shown in mobile media query below */
.mobile-header-logo-link {
    display: none;
}

@media (max-width: 782px) {
    .menu-toggle {
        display: flex;
        align-self: var(--mobile-menu-valign, center);
    }

    /* ---- Opaque header on mobile (no transparency) ---- */
    .site-header {
        background: #1a1a1a !important;
    }

    .header-background {
        opacity: 1 !important;
    }

    /* ---- Compact app-like header bar ---- */
    /* Mobile header height — always from CSS var, clamped to max 1/3 viewport */
    .site-header {
        min-height: min(var(--mobile-header-h, 60px), 33.33vh);
        display: flex;
        flex-direction: column;
    }

    .site-header.shrink {
        min-height: min(var(--mobile-header-h, 60px), 33.33vh);
    }

    .header-container {
        padding: 8px 15px;
        overflow: visible;  /* allow logo to overflow with negative margins */
        flex: 1;
        display: flex;
        flex-direction: column;
    }

    .header-content {
        overflow: visible;  /* allow logo to overflow with negative margins */
        min-height: 44px;
        gap: 10px;
        flex: 1;
    }

    .site-header.shrink .header-content {
        min-height: 40px;
    }

    /* Play button — custom size if set, otherwise default 44px */
    .header-play-button {
        width: var(--mobile-play-size, 44px);
        height: var(--mobile-play-size, 44px);
        margin: var(--mobile-play-pad, 0px);
    }

    .header-play-button svg {
        width: calc(var(--mobile-play-size, 44px) * 0.4);
        height: calc(var(--mobile-play-size, 44px) * 0.4);
    }

    .header-play-button-wrap {
        gap: 10px;
        align-self: var(--mobile-play-valign, center);
    }

    /* Compact station info */
    .station-name {
        font-size: 14px;
    }

    .station-status {
        font-size: 11px;
    }

    /* Override desktop shrink font sizes on mobile */
    .site-header.shrink .station-name {
        font-size: 13px;
    }

    .site-header.shrink .station-status {
        font-size: 10px;
    }

    /* Hide listener count on mobile */
    .listener-count {
        display: none;
    }

    /* Hide site branding on mobile — mobile logo takes its place */
    .site-branding {
        display: none;
    }

    /* Hide station info (name/status) next to play button on mobile */
    .header-station-info {
        display: none;
    }

    /* ---- Mobile Logo ---- */
    .mobile-header-logo-link {
        display: flex;
        align-items: center;
        flex-shrink: 0;
        margin: var(--mobile-logo-mt, 0px) var(--mobile-logo-mr, 0px) var(--mobile-logo-mb, 0px) var(--mobile-logo-ml, 0px);
        overflow: visible;
        align-self: var(--mobile-logo-valign, center);
    }

    /* When logo is after play button, push it right so text changes don't shift it */
    .mobile-header-logo-link.logo-after {
        margin-left: auto;
    }

    .mobile-header-logo {
        max-height: var(--mobile-logo-h, var(--mobile-header-h, 60px));
        width: var(--mobile-logo-w, auto);
        object-fit: contain;
        display: block;
        padding: var(--mobile-logo-pad, 0px);
    }

    /* Hide station info when customizer option enabled */
    body.mobile-hide-station-info .header-station-info {
        display: none;
    }

    /* Ensure header sticks regardless of menu position */
    body.menu-above .site-header {
        top: 0;
        z-index: 1000;
    }
}

@media (max-width: 600px) {
    .site-header {
        min-height: min(var(--mobile-header-h, 52px), 33.33vh);
    }

    .header-container {
        padding: 6px 12px;
    }

    .header-content {
        min-height: 40px;
        gap: 8px;
    }

    .header-play-button {
        width: var(--mobile-play-size, 38px);
        height: var(--mobile-play-size, 38px);
    }

    .header-play-button svg {
        width: calc(var(--mobile-play-size, 38px) * 0.4);
        height: calc(var(--mobile-play-size, 38px) * 0.4);
    }

    .station-name {
        font-size: 13px;
    }

    .station-status {
        font-size: 10px;
    }

    .site-header.shrink .station-name {
        font-size: 12px;
    }

    .site-header.shrink .station-status {
        font-size: 9px;
    }

    .mobile-header-logo {
        max-height: var(--mobile-logo-h, var(--mobile-header-h, 52px));
    }
}
