/* event-styles.css - Event Page Specific Styles */

/* --- EVENTS SECTION (extends .content-container) --- */
.events-section {
    margin-top: 0;
    /* Override: nie nachodzi na hero */
    margin-bottom: 40px;
    /* Override: dodatkowy margines na dole */
}

.events-section h2 {
    font-family: 'Roboto Mono', monospace;
    color: var(--md-sys-color-primary);
    font-size: 2rem;
    margin-bottom: 24px;
    display: inline-block;
}

.events-section h2:first-child {
    margin-top: 0;
}

.events-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 24px;
}

.event-card {
    background-color: var(--md-sys-color-surface);
    border-radius: 16px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.08);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    display: flex;
    flex-direction: column;
    height: 100%;
    /* overflow: visible is default, but ensuring it here explicitly */
    overflow: visible;
}

.event-card:hover {
    z-index: 50;
    position: relative;
    /* Ensure z-index applies if not grid item, though it is */
}

.event-image {
    position: relative;
    height: 200px;
    border-top-left-radius: 16px;
    border-top-right-radius: 16px;
    background-color: var(--surface-variant);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2;
    /* overflow: visible is default */
    overflow: visible;
}

.event-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
    border-top-left-radius: 16px;
    border-top-right-radius: 16px;
}

/* --- NEW RIBBON --- */
/* Wrapper handles clipping to the corner so it doesn't spill out */
.new-ribbon-wrapper {
    position: absolute;
    top: 0;
    left: 0;
    width: 85px;
    height: 85px;
    z-index: 200;
    /* Above everything else on image */
    overflow: hidden;
    /* Clips the ribbon ends */
    border-top-left-radius: 16px;
    /* Matches card corner */
    pointer-events: none;
    /* Let clicks pass through */
}

.new-ribbon {
    position: absolute;
    width: 120px;
    background-color: var(--md-sys-color-error);
    /* High contrast color */
    color: var(--md-sys-color-on-error);
    text-align: center;
    font-family: 'Roboto Mono', monospace;
    font-weight: 700;
    font-size: 0.75rem;
    line-height: 20px;
    transform: rotate(-45deg) translateY(-50%);
    /* Positioning logic for diagonal center */
    top: 22px;
    left: -28px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    padding: 2px 0;
    letter-spacing: 1px;
}

.event-image img[src*="event.svg"] {
    object-fit: contain;
    width: 60%;
    height: 60%;
    transition: filter 0.3s ease;
}

[data-theme="dark"] .event-image img[src*="event.svg"] {
    /* Ustawienie "pstrokatego" niebieskiego (#90CAF9) poprzez podmianę pliku */
    content: url('./assets/icon/event-dark.svg');
    /* Resetujemy filtr, jeśli byłby dziedziczony */
    filter: none;
}

/* --- EVENT TYPES (BADGES) --- */
.event-types-wrapper {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 100;
    /* Grid Strategy for perfect overlap and sizing */
    display: grid;
    grid-template-areas: "stack";
    justify-items: end;
}

.event-type {
    grid-area: stack;
    width: 100%;
    /* Fill the grid cell (sized by ghost) */
    text-align: center;
    /* Center content when width > text */

    background-color: var(--md-sys-color-primary);
    color: var(--md-sys-color-on-primary);
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 0.8rem;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    white-space: nowrap;
    cursor: default;

    /* Transitions for smooth hover effects */
    transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.2s ease;
}

/* --- GHOST ELEMENT --- */
/* Invisible, but sets the width of the grid container */
.event-type-ghost {
    visibility: hidden;
    pointer-events: none;
    z-index: -10;
    position: relative;
    background-color: transparent;
    color: transparent;
    border: none;
    padding: 4px 12px;
    /* Ensure padding matches exactly */
}

/* --- STATE MANAGEMENT --- */

/* 1. Main Tag (First visible real tag) */
.event-type:first-child {
    z-index: 20;
    position: relative;
    transform: translateY(0);
}

/* 2. Secondary Tags (Hidden visually by default, but present for sizing if grid allows) */
/* Targeted specifically to avoid ghost selection */
.event-type:nth-child(n+2):not(.event-type-ghost) {
    opacity: 0;
    /* Visually hidden but structurally present */
    transform: translateY(0);
    pointer-events: none;
    z-index: 10;
    /* Below main pill (20) but above everything else */
}

/* --- HOVER LOGIC --- */

/* Idle State: Add "+" to main pill if multiple */
.event-types-wrapper.has-multiple .event-type:first-child::after {
    content: ' ...';
    /* font-weight: 700; Moved to logic, but + sign needs own style if not using class? 
       Actually previously it was content: ' +' on pseudo. 
       We inherit font styles. */
    font-weight: 700;

    /* Animation Props */
    display: inline-block;
    opacity: 1;
    max-width: 20px;
    /* Adjust if needed */
    overflow: hidden;
    vertical-align: bottom;
    transition: opacity 0.3s ease, max-width 0.3s ease;
    white-space: pre;
}

/* Hover State: Remove "+" from main pill */
/* Animate width to 0 to make text slide to center */
.event-types-wrapper:hover .event-type:first-child::after {
    /* content property is NOT changed so animation works */
    opacity: 0;
    max-width: 0;
}

/* Hover State: Expand secondary pills */
.event-types-wrapper:hover .event-type:nth-child(n+2):not(.event-type-ghost) {
    opacity: 1;
    /* Slide down based on index (100% height per item + 4px gap) */
    transform: translateY(calc((100% + 4px) * var(--index)));
    pointer-events: auto;
}

/* --- SAFE AREA FOR HOVER --- */
/* Creates a bridge so cursor doesn't leave the wrapper during transition */
.event-types-wrapper::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    /* Extend height to cover the maximum possible expansion area */
    /* Assuming max 10 items * (100% + gap) roughly */
    height: 1200%;
    z-index: -1;
    display: none;
}

.event-types-wrapper:hover::before {
    display: block;
}

/* Utility Class for JS injected styled elements */
.plus-sign {
    font-weight: 700;
}

/* --- CSP COMPLIANCE: INDEX MAPPING --- */
/* Since inline styles are blocked by CSP (style-src 'self'), we map indices here manually. */
.event-type:nth-child(1) {
    --index: 0;
}

.event-type:nth-child(2) {
    --index: 1;
}

.event-type:nth-child(3) {
    --index: 2;
}

.event-type:nth-child(4) {
    --index: 3;
}

.event-type:nth-child(5) {
    --index: 4;
}

.event-type:nth-child(6) {
    --index: 5;
}

.event-type:nth-child(7) {
    --index: 6;
}

.event-type:nth-child(8) {
    --index: 7;
}

.event-type:nth-child(9) {
    --index: 8;
}

.event-type:nth-child(10) {
    --index: 9;
}

/* --- CONTENT SECTION --- */
.event-content {
    padding: 24px;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    border-bottom-left-radius: 16px;
    border-bottom-right-radius: 16px;
    position: relative;
    z-index: 1;
}

.event-meta-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.event-content time {
    display: block;
    color: var(--md-sys-color-primary);
    font-weight: 500;
    font-size: 0.9rem;
}

.event-language {
    font-size: 1rem;
    line-height: 1.2;
    cursor: default;
    background-color: var(--md-sys-color-surface-variant);
    color: var(--md-sys-color-on-surface-variant);
    padding: 2px 8px;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.event-location {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--md-sys-color-on-surface-variant);
    font-size: 0.85rem;
    margin-bottom: 12px;
    opacity: 0.9;
}

.event-location .material-icons {
    font-size: 1.1rem;
    color: var(--md-sys-color-primary);
}

.event-content h3 {
    margin: 0 0 12px 0;
    font-size: 1.25rem;
    line-height: 1.4;
    color: var(--md-sys-color-on-surface);
    font-weight: 500;
    font-family: 'Roboto Mono', monospace;
}

.event-content p {
    margin: 0 0 12px 0;
    color: var(--md-sys-color-on-surface);
    opacity: 0.8;
    line-height: 1.6;
}

.event-content p:last-of-type {
    margin-bottom: 24px;
}

.event-content .event-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.event-content .btn {
    align-self: flex-start;
    /* margin-top: auto; handled by .event-actions now */
    background-color: var(--md-sys-color-primary);
    color: var(--md-sys-color-on-primary);
    text-decoration: none;
    padding: 10px 24px;
    border-radius: 24px;
    font-size: 0.9rem;
    font-weight: 500;
    transition: background-color 0.2s, filter 0.2s;
    border: none;
    cursor: pointer;
    box-shadow: var(--elevation-1);

    /* Icon alignment */
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.event-content .btn.btn-icon-only {
    padding: 10px;
    /* Equal padding for square/circle look */
    border-radius: 50%;
    /* Circle shape */
    aspect-ratio: 1 / 1;
    justify-content: center;
    /* Center icon horizontally */
}

.event-content .btn .material-icons {
    font-size: 1.1rem;
}

.event-content .btn:hover {
    background-color: var(--md-sys-color-primary);
    filter: brightness(1.15);
    box-shadow: var(--elevation-1);
}

/* --- EXPAND/COLLAPSE (Description Toggle) --- */

/* Collapsed: limit first paragraph to 5 visible lines */
.event-description-body.collapsed p:first-child {
    display: -webkit-box;
    -webkit-line-clamp: 5;
    line-clamp: 5;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Collapsed: completely hide secondary description paragraphs */
.event-description-body.collapsed p:nth-child(n+2) {
    display: none;
}

/* Toggle link — blue text with arrow, not a traditional button */
.expand-toggle {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: none;
    border: none;
    padding: 0;
    margin: 0 0 16px 0;
    margin-top: auto;
    cursor: pointer;
    color: var(--md-sys-color-primary);
    font-size: 0.875rem;
    font-weight: 500;
    font-family: inherit;
    transition: opacity 0.2s ease;
}

.expand-toggle:hover {
    opacity: 0.75;
}

.expand-toggle .material-icons {
    font-size: 1.1rem;
}

/* JS hides toggle when content doesn't overflow */
.expand-toggle.hidden {
    display: none;
}

/* --- EVENT DETAIL MODAL --- */

/* Prevent body scroll when modal is open */
body.event-detail-open {
    overflow: hidden;
}

/* Dark backdrop */
.event-detail-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1000;
    background-color: rgba(0, 0, 0, 0.5);
    justify-content: center;
    align-items: center;
    opacity: 0;
    transition: opacity 0.3s ease;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.event-detail-backdrop.show {
    opacity: 1;
}

/* Centered modal container */
.event-detail-modal {
    position: relative;
    width: min(600px, 90vw);
    max-height: 85vh;
    overflow-y: auto;
    border-radius: 16px;
    background-color: var(--md-sys-color-surface);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
    transform: scale(0.95);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.event-detail-backdrop.show .event-detail-modal {
    transform: scale(1);
}

[data-theme="dark"] .event-detail-modal {
    outline: 2px solid rgba(255, 255, 255, 0.15);
}

/* Card inside modal — override grid-inherited height */
.event-detail-modal .event-card {
    height: auto;
    box-shadow: none;
}

/* Detail link hidden in grid — accessible only via modal */
.event-card .btn-detail-link {
    display: none;
}

.event-detail-modal .btn-detail-link {
    display: inline-flex;
}

/* Close button pinned to the right edge of the actions row */
.event-content .btn-close {
    margin-left: auto;
}



/* --- RWD --- */
@media (max-width: 768px) {
    .events-section h2 {
        font-size: 1.5rem;
    }
}

@media (max-width: 480px) {
    .event-image {
        height: 180px;
    }
}

/* --- NO EVENTS MESSAGE --- */
.no-events-msg {
    text-align: center;
    font-size: 1.3rem;
    color: var(--md-sys-color-on-surface);
    opacity: 0.8;
    margin: 60px auto;
    width: 100%;
    font-family: 'Roboto Mono', monospace;
    grid-column: 1 / -1;
}

/* --- NO EVENTS PLACEHOLDER --- */
.no-events-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 48px 24px;
    background: var(--md-sys-color-surface);
    border-radius: 24px;
    grid-column: 1 / -1;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.08);
    margin-bottom: 24px;
}

.no-events-icon {
    font-size: 48px;
    color: var(--md-sys-color-primary);
    margin-bottom: 16px;
}

.no-events-title {
    font-size: 1.5rem;
    font-weight: 600;
    font-family: 'Roboto Mono', monospace;
    color: var(--md-sys-color-on-surface);
    margin: 0 0 8px 0;
}

.no-events-subtitle {
    font-size: 1.1rem;
    color: var(--md-sys-color-on-surface);
    opacity: 0.7;
    margin: 0 0 24px 0;
}

.no-events-actions {
    display: flex;
    gap: 16px;
}

.action-link {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--md-sys-color-surface-variant);
    color: var(--md-sys-color-primary);
    transition: background 0.2s ease, color 0.2s ease;
}

.action-link svg {
    width: 20px;
    height: 20px;
}

.action-link--dc:hover {
    background: #5865F2;
    color: white;
}

.action-link--fb:hover {
    background: #1877F2;
    color: white;
}

.action-link--photos:hover {
    background: linear-gradient(45deg, #f09433, #e6683c, #dc2743, #cc2366, #bc1888);
    color: white;
}