/* Universal box-sizing for predictable layouts */
* {
    box-sizing: border-box;
}

html, body {
    touch-action: manipulation;
}

/* --- NEW: Fixed Header Logic --- */
body.light-theme {
    background: #f0f2f5;
    color: #1c1c1e;
    overflow-x: hidden; /* Prevent all horizontal scrolling */
}

#header-placeholder {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    height: 80px; /* Desktop header height */
    transition: transform 0.3s ease-in-out; /* Add transition for hiding/showing */
}
#header-placeholder.header-hidden {
    transform: translateY(-100%);
}
@media (max-width: 768px) {
    #header-placeholder {
        height: 70px; /* Mobile header height */
    }
}


/* Header styles - applied after component loads */
body.light-theme #header-placeholder header {
    background: rgba(240, 242, 245, 0.85) !important;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

body.light-theme #header-placeholder .header-logo {
    filter: none !important;
}

body.light-theme #header-placeholder .burger-btn {
    color: #1c1c1e;
}
body.light-theme #header-placeholder .burger-btn:hover {
     background-color: rgba(0,0,0,0.05);
}

body.light-theme #footer-placeholder footer {
    background: #f0f2f5;
    color: #6c757d;
}

/* Base container for all news pages */
.news-container, .article-container, .news-admin-container, .news-editor-container {
    max-width: 960px;
    margin: 0 auto;
    padding: 2rem 1.5rem; 
    width: 100%;
    position: relative; /* Ensure proper stacking context */
    z-index: 1; /* Fix for burger menu overlay issue */
}

/*
  KEY CHANGE: margin-top is removed. It will be handled by padding-top in the inline
  style of news.html to allow for smooth transform-based animation.
*/

.article-container {
    margin-top: 90px;
}

@media (max-width: 768px) {
     .article-container {
        margin-top: 80px;
    }
}


/* Specific adjustment for the article page title as requested */
.article-container {
    background: #ffffff;
    border-radius: 26px; /* iOS 26 style */
    box-shadow: 0 4px 20px rgba(0,0,0,0.08);
}

/* New Filter Bar */
.filter-bar {
    position: sticky;
    /* top is now handled by inline styles in news.html */
    z-index: 100;
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 2.5rem; /* Space between filters and grid */
    padding: 0.75rem 0;
    background-color: rgba(240, 242, 245, 0.85);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.search-container {
    display: flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 50px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
    transition: width 0.3s ease-in-out;
    height: 44px; /* Fixed height */
}

.search-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    background: transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #8e8e93;
    flex-shrink: 0;
}
.search-btn:hover {
    color: #1c1c1e;
}

#news-search-input {
    border: none;
    background: transparent;
    outline: none;
    padding: 0;
    width: 0;
    opacity: 0;
    font-size: 1rem;
    transition: width 0.3s ease-in-out, opacity 0.3s ease-in-out, padding 0.3s ease-in-out;
}
.search-container.active #news-search-input {
    width: 250px;
    opacity: 1;
    padding: 0.5rem 1rem 0.5rem 0;
}

.tags-filter {
    display: flex;
    flex-wrap: nowrap; /* Prevent wrapping */
    gap: 0.75rem;
    overflow-x: auto; /* Allow horizontal scrolling on small screens */
    /* Hide scrollbar */
    -ms-overflow-style: none;  /* IE and Edge */
    scrollbar-width: none;  /* Firefox */
}
.tags-filter::-webkit-scrollbar {
    display: none; /* Webkit */
}

.tag-btn {
    height: 44px; /* Match search container */
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(0, 0, 0, 0.08);
    color: #007aff;
    padding: 0 1.5rem;
    border-radius: 22px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
}

.tag-btn:hover {
    background-color: rgba(229, 229, 234, 0.8);
}

.tag-btn.active {
    background-color: #007aff;
    color: white;
    border-color: #007aff;
}

.news-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 2.5rem 1.5rem;
}

.news-card {
    background: transparent;
    box-shadow: none;
    display: flex;
    flex-direction: column;
    text-decoration: none;
    color: inherit;
    transition: opacity 0.2s;
}
.news-card:hover {
    opacity: 0.7;
}

.news-card-content {
    padding: 0; /* No padding on the content wrapper itself */
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

.news-card-meta {
    font-size: 0.9rem;
    font-weight: 500;
    color: #8a8a8e;
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.important-news-icon img {
    width: 16px;
    height: 16px;
    filter: invert(56%) sepia(52%) saturate(4529%) hue-rotate(331deg) brightness(100%) contrast(102%);
}

.news-card-title {
    font-family: 'Bebas Neue Pro Bold', sans-serif;
    font-size: 2.2rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: -0.02em;
    line-height: 1.15;
    margin: 0 0 1rem 0;
    color: #1c1c1e;
}

.news-photo-strip {
    height: 20px;
    width: 100%;
    border-radius: 10px;
    background-size: cover;
    background-position: center;
    margin-bottom: 1rem;
}


.news-card-snippet {
    font-size: 0.95rem;
    line-height: 1.5;
    color: #3c3c43;
    flex-grow: 1;
    margin-bottom: 1.5rem;
    /* Multiline text truncation */
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 4;
    overflow: hidden;
    text-overflow: ellipsis;
}

.news-card-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-top: auto; /* Pushes tags to the bottom */
}
.news-card-tags .tag {
    background: rgba(229, 229, 234, 0.85);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    color: #3c3c43;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 500;
}

.loader, .error-message {
    grid-column: 1 / -1;
    text-align: center;
    color: #6c757d;
    font-size: 1.1rem;
    padding: 2rem;
}

/* Article Page: news_article.html */
.article-header {
    margin-bottom: 2rem;
    padding: 1rem;
}
.article-back-link {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: #007aff;
    text-decoration: none;
    font-weight: 500;
    margin-bottom: 2.5rem;
    padding: 0.5rem;
    margin-left: -0.5rem;
    border-radius: 8px;
}
.article-back-link:hover {
    background-color: rgba(0, 122, 255, 0.1);
}

.article-meta {
    color: #8a8a8e;
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
    font-weight: 500;
    text-transform: uppercase;
}

.article-title {
    font-size: clamp(2rem, 5vw, 3rem);
    font-weight: 800;
    line-height: 1.0;
    margin-bottom: 1.5rem;
    overflow-wrap: break-word;
    text-transform: uppercase;
    letter-spacing: -0.03em;
}

.photo-indicator-strip {
    height: 20px;
    width: 100%;
    background: #e5e5ea;
    border-radius: 10px;
    margin-bottom: 1.5rem;
}

.article-content {
    font-size: 1.1rem;
    line-height: 1.4;
    color: #3c3c43;
    padding: 0 1rem;
}
.article-content p {
    margin: 0;
    overflow-wrap: break-word; /* Prevent long text from overflowing */
}
.article-content img {
    max-width: 100%;
    border-radius: 16px;
    margin: 2rem 0;
}
.article-content h3 {
    font-size: 1.4rem;
    font-weight: 700;
    line-height: 1.4;
    margin: 2rem 0 1rem 0;
}

/* --- NEW SLIDER STYLES --- */
.slider-container {
    position: relative;
    overflow: hidden;
    border-radius: 16px;
    margin: 2rem 0;
    background-color: #e5e5ea; /* Placeholder color */
}
/* NEW: Aspect ratio classes for dynamic sizing */
.slider-container.aspect-4-3 {
    aspect-ratio: 4 / 3;
}
.slider-container.aspect-16-9 {
    aspect-ratio: 16 / 9;
}
.slider-container.aspect-9-16 {
    aspect-ratio: 9 / 16;
}

.slider-wrapper {
    display: flex;
    height: 100%;
    transition: transform 0.3s ease-in-out;
}
.slide {
    flex: 0 0 100%;
    width: 100%;
    height: 100%;
    overflow: hidden;
}
/* More specific rule to override general .article-content img styles */
#article-container .article-content .slider-container .slide img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
    margin: 0;
    border-radius: 0;
    max-width: none;
}
.slider-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0,0,0,0.4);
    color: white;
    border: none;
    border-radius: 50%;
    width: 44px;
    height: 44px;
    font-size: 1.5rem;
    cursor: pointer;
    transition: background-color 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}
.slider-btn:hover {
    background: rgba(0,0,0,0.6);
}
.slider-btn.prev {
    left: 10px;
}
.slider-btn.next {
    right: 10px;
}
.slider-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}
.slide-counter {
    position: absolute;
    bottom: 10px;
    right: 10px;
    background: rgba(0,0,0,0.6);
    color: white;
    padding: 5px 12px;
    border-radius: 16px;
    font-size: 0.9rem;
    font-weight: 500;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.article-footer {
    margin-top: 3rem;
    padding: 1.5rem;
    border-top: 1px solid #e5e5ea;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.article-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}
.article-tags .tag {
    background: rgba(229, 229, 234, 0.85);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    color: #3c3c43;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 500;
}

.article-actions {
    display: flex;
    gap: 1rem;
}
.article-actions .btn-action {
    background: #f0f2f5;
    border: none;
    border-radius: 50%; /* iOS style circular buttons */
    width: 48px;
    height: 48px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: background-color 0.2s;
    color: #1c1c1e;
}
.article-actions .btn-action span {
    display: none; /* Hide text, only show icons */
}
.article-actions .btn-action:hover {
    background-color: #dcdce0;
}
.article-actions .btn-action svg {
    width: 24px;
    height: 24px;
}
.btn-like.liked {
    background-color: #ff3b30;
    color: white;
}
.btn-like.liked:hover {
    background-color: #e02a1f;
}

/* Admin page buttons */
.btn.btn-primary, .btn-save {
    display: inline-block;
    background: #007aff;
    color: white;
    text-decoration: none;
    padding: 0.8rem 1.5rem;
    border-radius: 26px; /* iOS 26 style */
    border: none;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    transition: background-color 0.2s;
}
.btn.btn-primary:hover, .btn-save:hover {
    background: #005bb5;
}
.btn-save:disabled {
    background-color: #a5d6a7;
    cursor: not-allowed;
}

@font-face {
    font-family: 'Bebas Neue Pro Bold';
    src: url('../fonts/bebas/Bebas Neue Pro Bold.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

@media (max-width: 768px) {
    .article-title { font-size: 1.8rem; }
    .news-container, .article-container { padding: 1rem; }
    .search-container.active #news-search-input { width: 150px; }
    .filter-bar {
        /* top is now handled by inline styles in news.html */
    }
}

.slider-btn img {
    width: 20px;
    height: 20px;
    filter: brightness(0) invert(1);
}

/* === СТИЛИ ДЛЯ СТАТЬИ === */
.article-content blockquote {
    margin: 1.5em 0;
    padding-left: 1em;
    border-left: 2px solid #FF4D4D; /* Coral */
    border-radius: 2px;
    font-style: italic;
    color: #6c757d; /* text-secondary */
}

.article-content ul {
    margin: 1.5em 0;
    padding-left: 2em;
    list-style: disc;
}

.article-content ul li {
    margin-bottom: 0.75em;
}