/* Календарь мероприятий; разметку строит assets/js/events-calendar.js */

.ecal {
    --ecal-rgb: 201, 168, 106;
    position: relative;
    z-index: 5;
    padding: 22px;
    border: 1px solid rgba(34, 48, 65, 0.8);
    border-radius: var(--radius);
    background: rgba(20, 27, 36, 0.6);
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.35);
}

/* Цвет направления: встреча клуба — золото, IT — голубой, INVEST — зелёный,
   мастермайнд — сиреневый, бизнес-термы — коралловый */
.ecal [data-direction="it"] {
    --ecal-rgb: 127, 183, 255;
}

.ecal [data-direction="invest"] {
    --ecal-rgb: 127, 209, 160;
}

.ecal [data-direction="mastermind"] {
    --ecal-rgb: 178, 150, 255;
}

.ecal [data-direction="bath"] {
    --ecal-rgb: 255, 150, 120;
}

.ecal-today[hidden],
.ecal-note[hidden],
.ecal-pop[hidden] {
    display: none;
}

.ecal-sr {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* --- шапка --- */

.ecal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
}

.ecal-title {
    margin: 0;
    font-size: 22px;
    font-weight: 600;
    letter-spacing: 0.2px;
}

.ecal-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.ecal-nav,
.ecal-today {
    height: 40px;
    border: 1px solid rgba(127, 183, 255, 0.35);
    background: rgba(20, 27, 36, 0.6);
    color: var(--text);
    font: inherit;
    cursor: pointer;
    transition: border-color 0.2s ease, opacity 0.2s ease;
}

.ecal-nav {
    width: 40px;
    padding: 0;
    display: grid;
    place-items: center;
    border-radius: 50%;
}

.ecal-nav svg {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.ecal-today {
    padding: 0 16px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.3px;
}

.ecal-nav:hover:not(:disabled),
.ecal-today:hover {
    border-color: rgba(127, 183, 255, 0.75);
}

.ecal-nav:disabled {
    opacity: 0.3;
    cursor: default;
}

.ecal-nav:focus-visible,
.ecal-today:focus-visible,
.ecal-ev:focus-visible,
.ecal-more:focus-visible,
.ecal-jump:focus-visible,
.ecal-card-link:focus-visible {
    outline: 2px solid var(--accent-2);
    outline-offset: 2px;
}

/* --- сетка --- */

.ecal-weekdays,
.ecal-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 6px;
}

.ecal-weekdays {
    margin-bottom: 8px;
    font-size: 12px;
    letter-spacing: 0.6px;
    text-transform: uppercase;
    color: var(--muted);
}

.ecal-weekdays span {
    padding: 0 10px;
}

.ecal-weekdays span:nth-child(n + 6) {
    color: rgba(170, 180, 191, 0.55);
}

.ecal-day {
    position: relative;
    min-height: 112px;
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    overflow: hidden;
    border: 1px solid rgba(34, 48, 65, 0.55);
    border-radius: 12px;
    background: rgba(11, 15, 20, 0.45);
    transition: border-color 0.2s ease, background-color 0.2s ease;
}

.ecal-day.is-outside {
    border-color: rgba(34, 48, 65, 0.25);
    background: transparent;
}

.ecal-num {
    position: relative;
    z-index: 1;
    align-self: flex-start;
    min-width: 28px;
    height: 28px;
    padding: 0 7px;
    display: inline-grid;
    place-items: center;
    border-radius: 999px;
    font-size: 14px;
    font-weight: 600;
    line-height: 1;
    color: var(--muted);
}

.ecal-day.is-weekend .ecal-num {
    color: rgba(170, 180, 191, 0.6);
}

.ecal-day.is-outside .ecal-num {
    color: rgba(170, 180, 191, 0.25);
}

.ecal-day.has-events {
    border-color: rgba(var(--ecal-rgb), 0.45);
    background: rgba(var(--ecal-rgb), 0.07);
}

.ecal-day.has-events .ecal-num {
    color: var(--text);
}

.ecal-day.is-past {
    border-color: rgba(var(--ecal-rgb), 0.25);
    background: rgba(var(--ecal-rgb), 0.03);
}

.ecal-day.is-today .ecal-num {
    background: var(--accent);
    color: var(--bg);
}

.ecal-day.is-active {
    border-color: rgba(var(--ecal-rgb), 0.9);
}

/* Событие из соседнего месяца видно, но приглушено, пока на него не навели */
.ecal-day.is-outside.has-events {
    opacity: 0.55;
    transition: opacity 0.2s ease, border-color 0.2s ease, background-color 0.2s ease;
}

.ecal-day.is-outside.has-events.is-active,
.ecal-day.is-outside.has-events:focus-within {
    opacity: 1;
}

/* Обложка события — фоном ячейки */
.ecal-day-cover {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0;
    transition: opacity 0.4s ease;
}

.ecal-day-cover.is-ready {
    opacity: 0.45;
}

.ecal-day.is-past .ecal-day-cover.is-ready {
    opacity: 0.3;
}

.ecal-day.is-active .ecal-day-cover.is-ready {
    opacity: 0.6;
}

.ecal-day.has-cover::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(11, 15, 20, 0.15), rgba(11, 15, 20, 0.8));
    pointer-events: none;
}

.ecal-evs {
    position: relative;
    z-index: 1;
    margin-top: auto;
    display: grid;
    grid-template-columns: minmax(0, 1fr); /* иначе длинная подпись раздвигает ячейку */
    gap: 4px;
}

/* Курсор не задаём: у ссылки — рука, а кнопке без ссылки щёлкать некуда, карточку открывает наведение */
.ecal-ev,
.ecal-more {
    width: 100%;
    margin: 0;
    border: 0;
    font: inherit;
    text-align: left;
}

.ecal-ev {
    display: block;
    padding: 6px 8px;
    border-left: 2px solid rgb(var(--ecal-rgb));
    border-radius: 8px;
    background: rgba(var(--ecal-rgb), 0.16);
    color: var(--text);
    font-size: 12.5px;
    line-height: 1.3;
    transition: background-color 0.2s ease;
}

.ecal-day.has-cover .ecal-ev {
    background: rgba(11, 15, 20, 0.7);
}

.ecal-ev:hover,
.ecal-day.is-active .ecal-ev {
    background: rgba(var(--ecal-rgb), 0.28);
}

.ecal-day.is-past .ecal-ev {
    color: rgba(232, 237, 242, 0.72);
}

.ecal-ev-meta {
    display: block;
    margin-bottom: 2px;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.3px;
    color: rgb(var(--ecal-rgb));
}

.ecal-ev-title {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
    overflow: hidden;
    overflow-wrap: anywhere;
    hyphens: auto;
    font-weight: 600;
}

.ecal-more {
    padding: 2px 8px;
    background: none;
    color: var(--muted);
    font-size: 12px;
}

.ecal-more:hover {
    color: var(--text);
}

/* --- карточка события: во всплывающем окне и в списке на телефоне --- */

.ecal-pop {
    position: absolute;
    top: 0;
    left: 0;
    z-index: 10;
    width: clamp(260px, 30vw, 320px); /* на планшете должна помещаться сбоку от средней колонки */
    max-width: calc(100% - 16px);
    display: grid;
    gap: 10px;
    animation: ecal-pop-in 0.16s ease;
}

@keyframes ecal-pop-in {
    from {
        opacity: 0;
        transform: translateY(6px);
    }
}

.ecal-card {
    display: grid;
    align-content: start;
    overflow: hidden;
    border: 1px solid rgba(var(--ecal-rgb), 0.35);
    border-radius: 14px;
    background: var(--card);
}

.ecal-pop .ecal-card {
    box-shadow: var(--shadow);
}

.ecal-card-media {
    position: relative;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    background: var(--bg-2);
}

.ecal-card-media img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.ecal-card-media img.is-ready {
    opacity: 1;
}

.ecal-card-body {
    display: grid;
    gap: 6px;
    padding: 14px 16px 16px;
    overflow-wrap: anywhere;
}

.ecal-card-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.ecal-tag {
    padding: 3px 9px;
    border: 1px solid rgba(var(--ecal-rgb), 0.5);
    border-radius: 999px;
    font-size: 10.5px;
    font-weight: 600;
    letter-spacing: 0.4px;
    text-transform: uppercase;
    color: rgb(var(--ecal-rgb));
}

.ecal-tag.is-today {
    border-color: rgba(201, 168, 106, 0.6);
    color: var(--accent);
}

.ecal-tag.is-muted {
    border-color: rgba(170, 180, 191, 0.35);
    color: var(--muted);
}

.ecal-card-title {
    margin: 0;
    font-size: 17px;
    line-height: 1.3;
}

.ecal-card-sub {
    margin: -2px 0 0;
    font-size: 13.5px;
    line-height: 1.4;
    color: rgba(232, 237, 242, 0.82);
}

.ecal-card-when {
    margin: 2px 0 0;
    font-size: 13px;
    font-weight: 600;
    color: var(--accent);
}

.ecal-card-place {
    margin: -4px 0 0;
    font-size: 13px;
    color: var(--muted);
}

.ecal-card-text {
    margin: 0;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 4;
    overflow: hidden;
    font-size: 13px;
    line-height: 1.5;
    color: var(--muted);
}

.ecal-card-link {
    justify-self: start;
    margin-top: 6px;
    padding: 8px 16px;
    border: 1px solid rgba(201, 168, 106, 0.5);
    border-radius: 999px;
    background: linear-gradient(135deg, rgba(201, 168, 106, 0.22), rgba(201, 168, 106, 0.08));
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.3px;
    color: var(--text);
    transition: border-color 0.2s ease;
}

.ecal-card-link:hover {
    border-color: rgba(201, 168, 106, 0.85);
}

.ecal-card-soon {
    margin-top: 2px;
    font-size: 13px;
    color: var(--muted);
}

.ecal-list {
    display: none;
}

/* --- под сеткой --- */

.ecal-note {
    margin: 16px 0 0;
    font-size: 14px;
    color: var(--muted);
}

.ecal-jump {
    padding: 0;
    border: 0;
    border-bottom: 1px dashed rgba(201, 168, 106, 0.6);
    background: none;
    color: var(--text);
    font: inherit;
    text-align: left;
    cursor: pointer;
}

.ecal-jump:hover {
    border-bottom-style: solid;
}

.ecal .is-flash {
    animation: ecal-flash 1.4s ease;
}

@keyframes ecal-flash {
    30% {
        box-shadow: 0 0 0 3px rgba(var(--ecal-rgb), 0.6);
    }
}

@media (max-width: 1024px) {
    .ecal-weekdays span {
        padding: 0 6px;
    }

    .ecal-day {
        min-height: 104px;
        padding: 6px;
    }

    .ecal-ev {
        padding: 5px 6px;
        font-size: 12px;
    }
}

/* --- телефон: числа с отметкой, события месяца списком под сеткой --- */

@media (max-width: 720px) {
    .ecal {
        padding: 14px 12px;
    }

    .ecal-head {
        margin-bottom: 12px;
    }

    .ecal-title {
        font-size: 18px;
    }

    .ecal-controls {
        gap: 6px;
    }

    .ecal-nav,
    .ecal-today {
        height: 36px;
    }

    .ecal-nav {
        width: 36px;
    }

    .ecal-today {
        padding: 0 12px;
    }

    .ecal-weekdays,
    .ecal-grid {
        gap: 4px;
    }

    .ecal-weekdays {
        font-size: 11px;
        letter-spacing: 0.3px;
        text-align: center;
    }

    .ecal-weekdays span {
        padding: 0;
    }

    .ecal-day {
        min-height: 40px;
        aspect-ratio: 1 / 1;
        padding: 0;
        align-items: center;
        justify-content: center;
        border-radius: 10px;
    }

    .ecal-num {
        align-self: center;
        min-width: 26px;
        height: 26px;
        padding: 0 5px;
        font-size: 13px;
    }

    .ecal-evs {
        display: none;
    }

    .ecal-day.has-events {
        cursor: pointer;
    }

    .ecal-day.has-events .ecal-num {
        margin-bottom: 6px;
    }

    .ecal-day.has-events::before {
        content: "";
        position: absolute;
        z-index: 1;
        left: 50%;
        bottom: 4px;
        width: 5px;
        height: 5px;
        margin-left: -2.5px;
        border-radius: 50%;
        background: rgb(var(--ecal-rgb));
    }

    .ecal-list {
        display: grid;
        gap: 10px;
        margin-top: 14px;
    }

    .ecal-list .ecal-card.has-image {
        grid-template-columns: 96px minmax(0, 1fr);
    }

    .ecal-list .ecal-card-media {
        aspect-ratio: auto;
    }

    .ecal-list .ecal-card-body {
        padding: 12px 14px 14px;
    }

    .ecal-list .ecal-card-title {
        font-size: 16px;
    }

    .ecal-list .ecal-card-text {
        -webkit-line-clamp: 3;
    }

    .ecal-note {
        margin-top: 14px;
        font-size: 13px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .ecal-pop,
    .ecal .is-flash {
        animation: none;
    }

    .ecal-day-cover,
    .ecal-card-media img {
        transition: none;
    }
}
