/**
 * DiabloDesign News Ticker - Stylesheet
 * Red-White-Black color scheme with dashed borders
 * @package     mod_news_ticker
 * @copyright   Copyright (C) 2025 DiabloDesign. All rights reserved.
 */

/* Main container */
.news-ticker {
    --main-color: #c60000;
    --hover-color: #ff1a1a;
    --background-color: #ffffff;
    --text-color: #1a1a1a;
    --border-color: #c60000;
    --columns: 1;
    
    position: relative;
    width: 100%;
    background: transparent;
    padding: 0;
    margin: 20px 0;
    display: flex;
    gap: 20px;
    align-items: flex-start;
}

/* News container - holds all news items */
.news-container {
    position: relative;
    width: 100%;
    padding: 4px;
    box-sizing: border-box;
    transition: min-height 0.3s ease;
    overflow: visible !important;
}

/* Grid layout for multiple columns */
.news-container.news-columns-2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 30px;
}

.news-container.news-columns-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 30px;
}

.news-container.news-columns-4 {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 30px;
}

/* News items - base state with DiabloDesign borders */
.news-item {
    background: var(--background-color);
    padding: 0;
    display: none;
    opacity: 0;
    border: 2px dashed var(--border-color);
    transition: opacity 1.2s ease, transform 0.3s ease, box-shadow 0.3s ease;
    will-change: transform;
    position: relative;
    cursor: pointer;
}

/* Clickable overlay covering entire box */
.news-item::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1;
}

.news-item.visible {
    display: block !important;
    opacity: 1;
    animation: fadeInSmooth 1.2s ease forwards;
}

.news-item.hidden {
    display: none !important;
    opacity: 0;
}

.news-item:hover {
    transform: scale(1.02);
    box-shadow: 0 4px 12px rgba(198, 0, 0, 0.15);
}

/* Slide animations - for all layouts */
.news-item.slide-up {
    animation: slideUpSmooth 1.2s ease forwards !important;
}

.news-item.slide-down {
    animation: slideDownSmooth 1.2s ease forwards !important;
}

/* Fade animation */
.news-item.fade-in {
    animation: fadeInOnly 1.2s ease forwards !important;
}

/* Cascade animation - from left */
.news-item.cascade-in {
    animation: cascadeFromLeft 1.2s ease forwards !important;
}

/* Bouncing animation */
.news-item.bouncing-in {
    animation: bouncingIn 1.2s cubic-bezier(0.34, 1.56, 0.64, 1) forwards !important;
}

/* Single column - absolute positioning */
.news-columns-1 .news-item {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
}

.news-columns-1 .news-item.visible {
    position: static;
    margin-bottom: 30px;
}

.news-columns-1 .news-item.visible:last-child {
    margin-bottom: 0;
}

/* News image container */
.news-image {
    position: relative;
    width: 100%;
    height: 300px;
    overflow: hidden;
    margin-bottom: 4px;
}

/* Category badge on image - DiabloDesign style */
.category-badge {
    position: absolute;
    top: 12px;
    left: 12px;
    background: rgba(255, 255, 255, 0.92);
    color: var(--main-color);
    padding: 6px 14px;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    border: 2px dashed var(--main-color);
    z-index: 10;
    transition: all 0.3s ease;
    box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}

.news-item:hover .category-badge {
    background: var(--main-color);
    color: white;
    border-color: white;
}

/* News image link wrapper */
.news-image a {
    display: block;
    width: 100%;
    height: 100%;
    position: relative;
    overflow: hidden;
}

/* Shine effect overlay - one time animation on hover */
.news-image a::before {
    content: '';
    position: absolute;
    top: 0;
    left: -75%;
    z-index: 2;
    display: block;
    width: 50%;
    height: 100%;
    background: linear-gradient(
        to right,
        rgba(255, 255, 255, 0) 0%,
        rgba(255, 255, 255, 0.3) 50%,
        rgba(255, 255, 255, 0) 100%
    );
    transform: skewX(-25deg);
}

.news-item:hover .news-image a::before {
    animation: shine 0.7s ease-in-out forwards;
}

@keyframes shine {
    from {
        left: -75%;
    }
    to {
        left: 125%;
    }
}

.news-image img {
    transition: transform 0.3s ease, opacity 0.4s ease;
}

.news-columns-1 .news-image {
    border: none;
    border-bottom: 2px dashed var(--border-color);
    margin-bottom: 0;
    padding: 4px;
}

.news-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: top center;
    transition: transform 0.3s ease, opacity 0.4s ease;
}

.news-item:hover .news-image img {
    transform: scale(1.05);
}

/* Lazy loading states */
.news-image img.lazy {
    opacity: 0.3;
}

.news-image img.loaded {
    opacity: 1;
}

.news-image img.error {
    opacity: 0.5;
    background: linear-gradient(135deg, #f0f0f0 25%, #e0e0e0 25%, #e0e0e0 50%, #f0f0f0 50%, #f0f0f0 75%, #e0e0e0 75%);
}

/* News content */
.news-content {
    padding: 20px;
}

/* News title */
.news-title {
    margin: 0 0 10px 0;
    font-size: 22px;
    font-weight: 700;
    line-height: 1.3;
}

.news-title a {
    color: var(--text-color);
    text-decoration: none;
    transition: color 0.3s ease;
}

.news-title a:hover {
    color: var(--main-color);
}

/* News date */
.news-date {
    color: #666;
    font-size: 13px;
    margin-bottom: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* News intro text */
.news-intro {
    color: #444;
    font-size: 15px;
    line-height: 1.6;
    margin-bottom: 15px;
}

/* Read more link - with red dashed border */
.news-readmore {
    display: inline-block;
    color: var(--main-color);
    text-decoration: none;
    font-weight: 600;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    transition: all 0.3s ease;
    border: 2px dashed var(--main-color);
    padding: 8px 15px;
}

.news-readmore:hover {
    color: white;
    background: var(--hover-color);
    border-color: var(--hover-color);
    transform: translateX(5px);
}

/* Navigation - OUTSIDE container, on the right */
.news-navigation {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 0;
    z-index: 100;
    background: transparent;
    flex-shrink: 0;
}

/* Navigation position variants - side (vertical) */
.news-navigation.nav-position-side-right {
    flex-direction: column;
    justify-content: flex-start;
}

/* Navigation position variants - bottom (horizontal) */
.news-navigation.nav-position-bottom-left,
.news-navigation.nav-position-bottom-center,
.news-navigation.nav-position-bottom-right {
    flex-direction: row;
    width: 100%;
    order: 1;
}

.news-navigation.nav-position-bottom-left {
    justify-content: flex-start;
}

.news-navigation.nav-position-bottom-center {
    justify-content: center;
}

.news-navigation.nav-position-bottom-right {
    justify-content: flex-end;
}

/* Adjust ticker flex when navigation is at bottom */
.news-ticker:has(.news-navigation.nav-position-bottom-left),
.news-ticker:has(.news-navigation.nav-position-bottom-center),
.news-ticker:has(.news-navigation.nav-position-bottom-right) {
    flex-direction: column;
}

.news-ticker:has(.news-navigation.nav-position-bottom-left) .news-container,
.news-ticker:has(.news-navigation.nav-position-bottom-center) .news-container,
.news-ticker:has(.news-navigation.nav-position-bottom-right) .news-container {
    order: 0;
}

/* Navigation arrows - back to original style */
.nav-arrow {
    width: 40px;
    height: 40px;
    background: var(--main-color);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.nav-arrow:hover {
    background: var(--hover-color);
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(198, 0, 0, 0.3);
}

.nav-arrow:active {
    transform: scale(0.95);
}

.nav-arrow svg {
    fill: white;
    width: 24px;
    height: 24px;
}

/* Counter */
.news-counter {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-color);
    padding: 8px 12px;
    background: white;
    border: 2px dashed var(--border-color);
    min-width: 60px;
    text-align: center;
}

.news-counter .current {
    color: var(--main-color);
    font-weight: 700;
}

/* Animations - smooth and slow */
@keyframes fadeInSmooth {
    from {
        opacity: 0;
        transform: scale(0.98);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Disable all animations when turned off */
.news-ticker.no-animations .news-item {
    animation: none !important;
    transition: opacity 0.3s ease, transform 0.3s ease, box-shadow 0.3s ease !important;
}

.news-ticker.no-animations .news-item.visible {
    opacity: 1;
}

.news-ticker.no-animations .news-item.hidden {
    opacity: 0;
}

@keyframes slideUpSmooth {
    from {
        opacity: 0;
        transform: translateY(60px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideDownSmooth {
    from {
        opacity: 0;
        transform: translateY(-60px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInOnly {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes cascadeFromLeft {
    from {
        opacity: 0;
        transform: translateX(-40px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateX(0) scale(1);
    }
}

@keyframes bouncingIn {
    0% {
        opacity: 0;
        transform: translateY(20px) scale(0.92);
    }
    35% {
        opacity: 1;
        transform: translateY(-8px) scale(1.02);
    }
    55% {
        transform: translateY(4px) scale(0.99);
    }
    75% {
        transform: translateY(-2px) scale(1.005);
    }
    90% {
        transform: translateY(1px) scale(1.002);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Staggered delays for multi-column */
.news-columns-2 .news-item.visible:nth-child(1),
.news-columns-3 .news-item.visible:nth-child(1) {
    animation-delay: 0s;
}

.news-columns-2 .news-item.visible:nth-child(2),
.news-columns-3 .news-item.visible:nth-child(2) {
    animation-delay: 0.15s;
}

.news-columns-3 .news-item.visible:nth-child(3) {
    animation-delay: 0.3s;
}

/* Responsive Design */

/* Large tablets and small desktops (1200px and below) */
@media (max-width: 1200px) {
    .news-ticker {
        gap: 15px;
    }
    
    .news-container.news-columns-2,
    .news-container.news-columns-3,
    .news-container.news-columns-4 {
        gap: 25px;
    }
    
    /* 4 kolumny -> 3 kolumny na średnich ekranach */
    .news-container.news-columns-4 {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .news-title {
        font-size: 20px;
    }
}

/* Tablets landscape (992px and below) */
@media (max-width: 992px) {
    .news-ticker {
        gap: 15px;
    }
    
    .news-container.news-columns-3,
    .news-container.news-columns-4 {
        grid-template-columns: repeat(2, 1fr);
        gap: 20px;
    }
    
    .news-title {
        font-size: 19px;
    }
    
    .news-intro {
        font-size: 14px;
    }
    
    .news-image {
        height: 280px;
    }
}

/* Tablets portrait (768px and below) */
@media (max-width: 768px) {
    .news-ticker {
        flex-direction: column;
        gap: 20px;
    }
    
    .news-container.news-columns-2,
    .news-container.news-columns-3,
    .news-container.news-columns-4 {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .news-navigation {
        flex-direction: row;
        margin-top: 0;
        width: 100%;
        order: -1;
    }
    
    /* Use nav position on mobile too */
    .news-navigation.nav-position-left {
        justify-content: flex-start;
    }
    
    .news-navigation.nav-position-center {
        justify-content: center;
    }
    
    .news-navigation.nav-position-right {
        justify-content: flex-end;
    }
    
    .news-image {
        height: 250px;
    }
    
    .news-title {
        font-size: 20px;
    }
    
    .news-content {
        padding: 15px;
    }
    
    .nav-arrow {
        width: 45px;
        height: 45px;
    }
    
    .news-counter {
        padding: 10px 15px;
        font-size: 15px;
    }
}

/* Mobile landscape (576px and below) */
@media (max-width: 576px) {
    .news-ticker {
        margin: 15px 0;
    }
    
    .news-container {
        padding: 2px;
    }
    
    .news-title {
        font-size: 18px;
        margin-bottom: 8px;
    }
    
    .news-intro {
        font-size: 14px;
        line-height: 1.5;
        margin-bottom: 12px;
    }
    
    .news-date {
        font-size: 12px;
        margin-bottom: 10px;
    }
    
    .news-content {
        padding: 12px;
    }
    
    .news-image {
        height: 200px;
    }
    
    .news-readmore {
        font-size: 13px;
        padding: 6px 12px;
    }
    
    .nav-arrow {
        width: 40px;
        height: 40px;
    }
    
    .nav-arrow svg {
        width: 22px;
        height: 22px;
    }
    
    .news-counter {
        padding: 8px 10px;
        font-size: 13px;
        min-width: 50px;
    }
    
    .news-navigation {
        gap: 8px;
    }
}

/* Mobile portrait (400px and below) */
@media (max-width: 400px) {
    .news-title {
        font-size: 16px;
    }
    
    .news-intro {
        font-size: 13px;
    }
    
    .news-content {
        padding: 10px;
    }
    
    .news-image {
        height: 180px;
    }
    
    .news-readmore {
        font-size: 12px;
        padding: 5px 10px;
    }
    
    .nav-arrow {
        width: 35px;
        height: 35px;
    }
    
    .nav-arrow svg {
        width: 20px;
        height: 20px;
    }
    
    .news-counter {
        font-size: 12px;
        padding: 6px 8px;
    }
    
    .news-columns-1 .news-item.visible {
        margin-bottom: 20px;
    }
}
