/*
 * Events page (/events). Loaded only on that page.
 * Built on the shared tokens in custom.css (:root and html[data-theme="dark"]),
 * so light and dark mode follow the site automatically.
 * Logical properties only (RTL/LTR), 4/8px spacing, no letter-spacing on Persian.
 */

.ev {
    /* Type scale. Persian script renders visually smaller and needs more line height,
       so it gets its own scale instead of inheriting the German one. */
    --ev-small: 0.875rem;
    --ev-text: 1rem;
    --ev-title: 1.0625rem;
    --ev-lead: 1.125rem;
    --ev-line: 1.65;

    max-inline-size: 960px;
    margin-inline: auto;
    padding: var(--space-5) var(--space-3) 80px;
    color: var(--text-primary);
    font-size: var(--ev-text);
    line-height: var(--ev-line);
}

html[lang="fa"] .ev {
    --ev-small: 0.96875rem;
    --ev-text: 1.0625rem;
    --ev-title: 1.1875rem;
    --ev-lead: 1.3125rem;
    --ev-line: 1.95;
}

/* ---- Header ------------------------------------------------------------ */

.ev-header {
    padding-block: var(--space-4) var(--space-3);
}

.ev-header h1 {
    margin: 0 0 var(--space-2);
    font-size: clamp(2.25rem, 6vw, 3.5rem);
    font-weight: 800;
    line-height: 1.15;
    color: var(--text-primary);
}

html[lang="fa"] .ev-header h1 {
    line-height: 1.4;
}

.ev-lead {
    max-inline-size: 56ch;
    margin: 0;
    color: var(--text-secondary);
    font-size: var(--ev-lead);
}

.ev-rhythm {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2) var(--space-4);
    margin: var(--space-4) 0 0;
    padding: var(--space-3) 0 0;
    border-block-start: 1px solid var(--border-light);
    list-style: none;
    color: var(--text-secondary);
    font-size: var(--ev-small);
}

.ev-rhythm li {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
}

.ev-rhythm i,
.ev-meta i {
    color: var(--swiss-red);
}

.ev-rhythm a {
    color: inherit;
    text-decoration: underline;
    text-decoration-color: var(--border-light);
    text-underline-offset: 4px;
}

.ev-rhythm a:hover {
    text-decoration-color: currentColor;
}

/* ---- Next event -------------------------------------------------------- */

.ev-next {
    display: grid;
    margin-block-start: var(--space-4);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    background: var(--surface);
    box-shadow: var(--shadow-md);
    overflow: hidden;
}

.ev-next-date {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: var(--space-1);
    padding: var(--space-4);
    border-block-end: 1px solid var(--border-light);
    background: var(--surface-muted);
}

.ev-next-weekday {
    color: var(--text-secondary);
    font-size: var(--ev-small);
    font-weight: 600;
}

.ev-next-day {
    color: var(--swiss-red);
    font-size: clamp(3.5rem, 14vw, 5.5rem);
    font-weight: 800;
    line-height: 1;
}

.ev-next-month {
    color: var(--text-primary);
    font-size: var(--ev-title);
    font-weight: 700;
}

.ev-next-body {
    display: grid;
    align-content: center;
    gap: var(--space-3);
    padding: var(--space-4);
}

.ev-eyebrow {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    margin: 0;
    color: var(--text-secondary);
    font-size: var(--ev-small);
    font-weight: 600;
}

.ev-eyebrow::before {
    content: "";
    flex: 0 0 8px;
    inline-size: 8px;
    block-size: 8px;
    border-radius: 50%;
    background: var(--swiss-red);
}

.ev-next-body h2 {
    margin: 0;
    color: var(--text-primary);
    font-size: clamp(1.5rem, 3.5vw, 2rem);
    font-weight: 800;
    line-height: 1.3;
}

.ev-next-desc {
    max-inline-size: 60ch;
    margin: 0;
    color: var(--text-secondary);
}

.ev-meta {
    display: grid;
    gap: var(--space-2);
    margin: 0;
    padding: 0;
    list-style: none;
    color: var(--text-secondary);
    font-size: var(--ev-small);
}

.ev-meta li {
    display: flex;
    align-items: flex-start;
    gap: var(--space-2);
}

.ev-meta i {
    flex: 0 0 1.25em;
    margin-block-start: 0.4em;
    text-align: center;
}

.ev-actions {
    margin: 0;
}

@media (min-width: 768px) {
    .ev-next {
        grid-template-columns: 260px minmax(0, 1fr);
    }

    .ev-next-date {
        padding: var(--space-5);
        border-block-end: 0;
        border-inline-end: 1px solid var(--border-light);
    }

    .ev-next-body {
        padding: var(--space-5);
    }
}

/* ---- Sections and month groups ---------------------------------------- */

.ev-section {
    margin-block-start: 64px;
}

.ev-section-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: var(--space-3);
    margin-block-end: var(--space-3);
}

.ev-section-head h2 {
    margin: 0;
    color: var(--text-primary);
    font-size: clamp(1.5rem, 3vw, 1.875rem);
    font-weight: 800;
    line-height: 1.3;
}

.ev-count {
    color: var(--text-secondary);
    font-size: var(--ev-small);
    font-weight: 500;
}

.ev-month + .ev-month,
.ev-month + .ev-fold,
.ev-fold-body > .ev-month:first-child {
    margin-block-start: var(--space-4);
}

.ev-month-title {
    display: flex;
    align-items: baseline;
    gap: var(--space-2);
    margin: 0 0 var(--space-2);
    padding-inline: var(--space-1);
    color: var(--text-primary);
    font-size: var(--ev-title);
    font-weight: 700;
}

.ev-month-title span {
    color: var(--text-secondary);
    font-weight: 500;
}

.ev-list {
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    background: var(--surface);
    overflow: hidden;
}

/* ---- Rows -------------------------------------------------------------- */

.ev-row + .ev-row {
    border-block-start: 1px solid var(--border-light);
}

.ev-summary {
    display: grid;
    grid-template-columns: 64px minmax(0, 1fr) auto;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3);
    list-style: none;
    cursor: pointer;
    transition: background-color 0.15s ease;
}

.ev-summary::-webkit-details-marker {
    display: none;
}

.ev-summary:hover,
.ev-row[open] > .ev-summary {
    background: var(--surface-muted);
}

.ev-summary:focus-visible,
.ev-fold > summary:focus-visible {
    outline: 3px solid var(--swiss-gold);
    outline-offset: -3px;
}

.ev-row-date {
    display: grid;
    justify-items: center;
    gap: var(--space-1);
    line-height: 1;
}

.ev-row-day {
    color: var(--text-primary);
    font-size: 1.75rem;
    font-weight: 800;
}

.ev-row-weekday {
    color: var(--text-secondary);
    font-size: 0.8125rem;
    font-weight: 500;
}

html[lang="fa"] .ev-row-weekday {
    font-size: 0.875rem;
}

.ev-row-main {
    display: grid;
    gap: var(--space-1);
    min-inline-size: 0;
}

.ev-row-title {
    color: var(--text-primary);
    font-size: var(--ev-title);
    font-weight: 600;
}

.ev-row-sub {
    display: flex;
    flex-wrap: wrap;
    gap: 0 var(--space-3);
    color: var(--text-secondary);
    font-size: var(--ev-small);
}

.ev-chevron {
    color: var(--text-secondary);
    transition: transform 0.2s ease;
}

.ev-row[open] .ev-chevron,
.ev-fold[open] > summary .ev-chevron {
    transform: rotate(180deg);
}

.ev-details {
    display: grid;
    gap: var(--space-3);
    padding: 0 var(--space-3) var(--space-3);
    padding-inline-start: calc(var(--space-3) * 2 + 64px);
    background: var(--surface-muted);
    color: var(--text-secondary);
}

.ev-details p {
    max-inline-size: 60ch;
    margin: 0;
}

.ev-row--past .ev-row-day,
.ev-row--past .ev-row-title {
    color: var(--text-secondary);
}

@media (max-width: 575px) {
    .ev-summary {
        grid-template-columns: 52px minmax(0, 1fr) auto;
        gap: var(--space-2);
        padding: var(--space-3) var(--space-2);
    }

    .ev-details {
        padding-inline: var(--space-3);
    }
}

/* ---- Folded groups (later dates, archive) ------------------------------ */

.ev-fold {
    margin-block-start: var(--space-4);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    background: var(--surface);
}

.ev-fold > summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    padding: var(--space-3);
    border-radius: var(--radius-md);
    list-style: none;
    color: var(--text-primary);
    font-size: var(--ev-text);
    font-weight: 700;
    cursor: pointer;
}

.ev-fold > summary::-webkit-details-marker {
    display: none;
}

.ev-fold > summary:hover {
    background: var(--surface-muted);
}

.ev-fold-body {
    padding: 0 var(--space-3) var(--space-3);
}

/* ---- Empty state ------------------------------------------------------- */

.ev-empty {
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
    padding: var(--space-4);
    border: 1px dashed var(--border-light);
    border-radius: var(--radius-md);
    background: var(--surface-muted);
    color: var(--text-secondary);
}

.ev-empty i {
    margin-block-start: 0.35em;
    color: var(--swiss-red);
}

.ev-empty p {
    margin: 0;
}

@media (prefers-reduced-motion: reduce) {
    .ev-summary,
    .ev-chevron {
        transition: none;
    }
}
