/* Base (Light theme) */
:root {
    --bg-image: url('ffm-bkg-white.webp');
    --text-color: #333333;
    --glass-bg: rgba(2, 99, 131, 0.7);
    --glass-border: rgba(255, 255, 255, 0.2);
    --header-bg: #ffffff;
    --accent: #026383;
}

/* Dark theme */
[data-theme="dark"] {
    --bg-image: url('ffm-bkg-dark.webp');
    --text-color: #e0e0e0;
    --glass-bg: rgba(2, 99, 131, 0.4);
    --header-bg: #1e1e1e;
}

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    
    /* background-color */
    background-image: var(--bg-image);
    background-size: cover;          
    background-position: center;
    background-attachment: fixed;
    
    color: var(--text-color);
    transition: background-image 0.4s ease-in-out, background-color 0.4s ease-in-out;
}

/* Fixed header */
.header {
    position: fixed;
    top: 0;
    width: 100%;
    height: 60px;
    background-color: var(--header-bg);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    z-index: 1000;
    box-sizing: border-box;
}

.logo img {
    height: 40px;
}

.age-badge {
    position: absolute; /* Делает элемент независимым */
    top: 11px;          /* Должно быть таким же, как у вашей кнопки темы */
    right: 75px;        /* Отодвигаем левее кнопки темы (подгоните цифру при необходимости) */
    
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px; 
    height: 36px;
    border-radius: 50%;
    
    background: rgba(128, 128, 128, 0.15);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    
    color: var(--text-color);
    font-size: 0.9rem;
    font-weight: bold;
    user-select: none; 
    z-index: 1000;
}

/* Icon and buttons */
.icon-btn {
    background: transparent;
    color: var(--text-color);
    padding: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    transition: background 0.3s, color 0.3s;
}
.icon-btn:hover {
    background: rgba(150, 150, 150, 0.2);
}
.play-main-btn {
    color: #fff;
    background: var(--accent);
    width: 60px;
    height: 60px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
}
.play-main-btn:hover {
    background: #024f69;
}

/* Content with header */
.main-content {
    margin-top: 100px;
    max-width: 800px;
    margin-left: auto;
    margin-right: auto;
    padding: 0 20px 20px 20px;
}

/* --- STORIES --- */
/* Icons */
.stories-wrapper {
    margin-bottom: 25px;
    width: 100%;
}
.stories-track {
    display: flex;
    gap: 15px;
    overflow-x: auto;
    padding-bottom: 10px;
    scrollbar-width: none; /* Firefox */
}
.stories-track::-webkit-scrollbar {
    display: none; /* Chrome and Safari */
}
.story-thumb {
    flex: 0 0 85px;
    height: 85px;
    border-radius: 22px; 
    border: 3px solid #3c82f6; 
    background-size: cover;
    background-position: center;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
    transition: transform 0.2s;
    padding: 2px;
    background-clip: content-box;
}
.story-thumb:hover { transform: scale(1.05); }

/* Fullscreen */
.story-modal {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    z-index: 9999;
    display: none;
    justify-content: center;
    align-items: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}
.story-modal.is-active {
    display: flex;
    opacity: 1;
}
/* blur and fullscreen */
.story-modal-overlay {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px); /* Safari iOS */
}

/* No scroll */
body.no-scroll {
    overflow: hidden;
}
.story-content-container {
    position: relative;
    width: 100%;
    max-width: 450px;
    height: 90vh;
    max-height: 850px;
    background-size: cover;
    background-position: center;
    border-radius: 15px;
    overflow: hidden;
    box-shadow: 0 10px 40px rgba(0,0,0,0.5);
}
.story-progress-container {
    position: absolute;
    top: 10px; left: 10px; right: 10px;
    display: flex;
    gap: 5px;
    z-index: 10;
}
.story-progress-bar {
    flex: 1;
    height: 3px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 2px;
    overflow: hidden;
}
.story-progress-fill {
    height: 100%;
    width: 0%;
    background: #ffffff;
}
.story-close-btn {
    position: absolute;
    top: 25px; right: 15px;
    background: rgba(255, 255, 255, 0.3);
    border: none; color: #fff;
    width: 30px; height: 30px;
    border-radius: 50%;
    font-size: 20px;
    cursor: pointer;
    z-index: 10;
    display: flex; justify-content: center; align-items: center;
}
.story-click-area {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    z-index: 5;
    /* select none */
    user-select: none;
    -webkit-user-select: none;
}
.story-action-container {
    position: absolute;
    bottom: 30px; left: 0; width: 100%;
    display: flex; justify-content: center;
    z-index: 10;
}
/* 026383 color */
.story-action-btn {
    background: #026383 !important;
    color: #ffffff !important;
    text-decoration: none;
    padding: 15px 40px;
    border-radius: 30px;
    font-weight: bold;
    font-size: 1.1rem;
    display: none;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    transition: transform 0.2s, background 0.3s;
}
.story-action-btn.is-active {
    display: block;
}
.story-action-btn:hover {
    transform: scale(1.05);
}

/* Thumb of stories */
.story-thumb {
    position: relative;
    flex: 0 0 85px;
    height: 85px;
    border-radius: 22px;
    border: 3px solid #3c82f6;
    background-size: cover;
    background-position: center;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
    transition: transform 0.2s;
    overflow: hidden; 
}
.story-thumb:hover { 
    transform: scale(1.05); 
}

/* title of thumb */
.story-thumb-title {
    position: absolute;
    bottom: 0; left: 0; right: 0;
    background: linear-gradient(to top, rgba(0,0,0,0.8) 0%, transparent 100%);
    color: #ffffff !important;
    font-size: 0.75rem;
    font-weight: bold;
    padding: 25px 6px 8px 6px;
    text-shadow: 1px 1px 3px rgba(0,0,0,1);
    text-align: center;
    line-height: 1.1;
    pointer-events: none;
}

/* Animations for switching stories */
@keyframes slideInRight {
    from { transform: translateX(100%); opacity: 0.5; }
    to { transform: translateX(0); opacity: 1; }
}
@keyframes slideInLeft {
    from { transform: translateX(-100%); opacity: 0.5; }
    to { transform: translateX(0); opacity: 1; }
}
.animate-right {
    animation: slideInRight 0.35s cubic-bezier(0.25, 1, 0.5, 1);
}
.animate-left {
    animation: slideInLeft 0.35s cubic-bezier(0.25, 1, 0.5, 1);
}

/* Top margin for the timer on iOS */
.story-progress-container {
    position: absolute;
    top: 15px; left: 10px; right: 10px;
    display: flex;
    gap: 5px;
    z-index: 10;
}
/* Story transition animations */
.story-slide-next {
    animation: slideNext 0.4s cubic-bezier(0.25, 1, 0.5, 1) forwards;
}
.story-slide-prev {
    animation: slidePrev 0.4s cubic-bezier(0.25, 1, 0.5, 1) forwards;
}

@keyframes slideNext {
    0% { transform: translateX(100%); opacity: 0; }
    100% { transform: translateX(0); opacity: 1; }
}
@keyframes slidePrev {
    0% { transform: translateX(-100%); opacity: 0; }
    100% { transform: translateX(0); opacity: 1; }
}

/* Glassmorphism */
.glass {
    background: var(--glass-bg);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 20px;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.1);
    color: #fff;
    margin-bottom: 30px;
}

/* RadioPlayer */
.player-widget {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}
.player-cover img {
    width: 250px;
    height: 250px;
    border-radius: 10px;
    object-fit: cover;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
}
.player-info h2 { margin: 15px 0 5px 0; font-size: 1.5rem; }
.player-info h3 { margin: 0 0 20px 0; font-weight: normal; opacity: 0.8; }
.player-controls {
    display: flex;
    gap: 15px;
    align-items: center;
    flex-wrap: wrap;
    justify-content: center;
}
.volume-control { display: flex; align-items: center; gap: 10px; }

/* Quality */
.quality-toggle {
    position: relative;
    display: flex;
    align-items: center;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--glass-border);
    border-radius: 30px;
    width: 120px;
    height: 36px;
    cursor: pointer;
    overflow: hidden;
}
.quality-thumb {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 56px;
    height: 30px;
    background: var(--accent);
    border-radius: 28px;
    transition: transform 0.3s ease;
    z-index: 1;
}
.quality-toggle.is-96 .quality-thumb { transform: translateX(58px); }
.quality-label {
    flex: 1;
    text-align: center;
    z-index: 2;
    font-size: 0.85rem;
    font-weight: bold;
    color: #fff;
    user-select: none;
}

/* History Widget (Collapse/Expand) */
.history-widget { transition: all 0.3s ease; }

/* Tabs are hidden by default. */
.history-tabs {
    display: none;
    overflow-x: auto;
    gap: 10px;
    margin-bottom: 20px;
    padding-bottom: 10px;
    scrollbar-width: thin;
    scrollbar-color: var(--accent) transparent;
}
.history-tabs::-webkit-scrollbar { height: 6px; }
.history-tabs::-webkit-scrollbar-thumb { background-color: var(--accent); border-radius: 10px; }

.tab-btn {
    background: transparent;
    color: #fff;
    border: 1px solid var(--glass-border);
    padding: 8px 15px;
    border-radius: 20px;
    white-space: nowrap;
    cursor: pointer;
}
.tab-btn.active { background: #fff; color: var(--accent); border-color: #fff; }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* History list (Scrolling hidden by default) */
.history-list {
    overflow: hidden;
    padding-right: 10px;
    margin-bottom: 15px;
    transition: max-height 0.3s ease;
}

/* When the widget is expanded (the "Show Full History" button has been clicked) */
.history-widget.is-expanded .history-tabs { display: flex; }
.history-widget.is-expanded .history-list {
    overflow-y: auto;
    max-height: 380px; /* Fits ~7 tracks; scrolling follows */
}
.history-widget.is-expanded .history-list::-webkit-scrollbar { width: 6px; }
.history-widget.is-expanded .history-list::-webkit-scrollbar-thumb { background-color: #fff; border-radius: 10px; }

.history-item.hidden { display: none; }
.history-item {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 10px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--glass-border);
}
.history-item img.itunes-cover { width: 50px; height: 50px; border-radius: 5px; }

.toggle-history-btn {
    background: transparent;
    border: 1px solid #fff;
    color: #fff;
    padding: 8px 15px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: bold;
    display: block;
    margin: 0 auto;
}

/* social media (Follow us!) */
.social-section { text-align: center; margin-bottom: 30px; }
.social-title { font-size: 1.2rem; font-weight: bold; margin-bottom: 15px; letter-spacing: 1px; }
.social-links { display: flex; justify-content: center; gap: 20px; }
.social-links img {
    width: 50px; height: 50px; object-fit: cover;
    border-radius: 12px; transition: transform 0.2s;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
}
.social-links img:hover { transform: scale(1.1); }

/* Footer */
.footer { background-color: var(--accent); color: #fff; padding: 30px 20px; text-align: center; }
.footer-content { display: flex; flex-direction: column; align-items: center; gap: 15px; }
.footer-logo img { height: 40px; }

/* spinner animation */
.spinner {
    width: 20px; height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 1s ease-in-out infinite;
    display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }