/**
 * 3task Calendar - Frontend Styles (1.3.0)
 *
 * Three designs: default ("Clear"), accent ("Accent"), dark ("Night").
 * Colors come from variables: --tc-accent is set per calendar, --tc-ev per event
 * (category color). Fonts are inherited from the theme.
 */

/* ==========================================================================
   Design tokens
   ========================================================================== */
.threecal-wrapper,
.threecal-event-list,
.threecal-upcoming,
.threecal-single-event,
.threecal-post-date,
.threecal-no-events {
    --tc-accent: #4f46e5;
    --tc-accent-ink: #ffffff;
    --tc-surface: #ffffff;
    --tc-surface-2: #f5f6fa;
    --tc-surface-3: #eceef5;
    --tc-text: #141824;
    --tc-muted: #646b7d;
    --tc-border: #e6e8ef;
    --tc-radius: 18px;
    --tc-radius-sm: 10px;
    --tc-shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 10px 30px rgba(16, 24, 40, 0.06);
    --tc-shadow-lg: 0 24px 60px rgba(16, 24, 40, 0.18);
    --tc-cell-height: 118px;
    color: var(--tc-text);
    font-family: inherit;
    line-height: 1.5;
}

.threecal-wrapper *,
.threecal-event-list *,
.threecal-upcoming *,
.threecal-single-event *,
.threecal-post-date,
.threecal-post-date * {
    box-sizing: border-box;
}

.threecal-wrapper .screen-reader-text {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(1px, 1px, 1px, 1px);
    white-space: nowrap;
}

.threecal-icon {
    display: inline-block;
    flex: 0 0 auto;
    vertical-align: -0.2em;
}

/* ==========================================================================
   Calendar shell
   ========================================================================== */
.threecal-wrapper {
    position: relative;
    max-width: 100%;
    margin: 0 0 1.5em;
    padding: 24px;
    background: var(--tc-surface);
    border: 1px solid var(--tc-border);
    border-radius: var(--tc-radius);
    box-shadow: var(--tc-shadow);
}

.threecal-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 14px 20px;
    margin-bottom: 18px;
}

.threecal-wrapper .threecal-title {
    margin: 0;
    padding: 0;
    font-size: clamp(1.4rem, 1.1rem + 1.2vw, 1.9rem);
    font-weight: 750;
    line-height: 1.1;
    letter-spacing: -0.02em;
    color: var(--tc-text);
}

.threecal-title-year {
    font-weight: 400;
    color: var(--tc-muted);
}

.threecal-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
}

.threecal-navgroup,
.threecal-view-switcher {
    display: inline-flex;
    align-items: stretch;
    padding: 3px;
    background: var(--tc-surface-2);
    border: 1px solid var(--tc-border);
    border-radius: 999px;
}

.threecal-wrapper .threecal-navgroup button,
.threecal-wrapper .threecal-view-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 36px;
    margin: 0;
    padding: 0 14px;
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: var(--tc-text);
    font: inherit;
    font-size: 14px;
    font-weight: 600;
    line-height: 1;
    cursor: pointer;
    box-shadow: none;
    transition: background-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.threecal-wrapper .threecal-nav {
    width: 36px;
    padding: 0;
}

.threecal-wrapper .threecal-navgroup button:hover,
.threecal-wrapper .threecal-view-btn:hover {
    background: var(--tc-surface);
    color: var(--tc-accent);
}

.threecal-wrapper .threecal-view-btn.active {
    background: var(--tc-accent);
    color: var(--tc-accent-ink);
    box-shadow: 0 4px 12px color-mix(in srgb, var(--tc-accent) 35%, transparent);
}

.threecal-filters {
    margin: -4px 0 16px;
}

.threecal-wrapper .threecal-category-filter {
    min-height: 40px;
    min-width: 220px;
    max-width: 100%;
    padding: 0 38px 0 14px;
    border: 1px solid var(--tc-border);
    border-radius: var(--tc-radius-sm);
    background-color: var(--tc-surface);
    color: var(--tc-text);
    font: inherit;
    font-size: 14px;
}

/* ==========================================================================
   Month grid
   ========================================================================== */
.threecal-calendar {
    position: relative;
    transition: opacity 0.2s ease;
}

.threecal-calendar.threecal-loading {
    opacity: 0.45;
    pointer-events: none;
}

.threecal-wrapper .threecal-month-grid {
    width: 100%;
    margin: 0;
    table-layout: fixed;
    border-collapse: separate;
    border-spacing: 0;
    border: 0;
    background: transparent;
}

.threecal-wrapper .threecal-month-grid th {
    padding: 0 8px 10px;
    border: 0;
    background: transparent;
    color: var(--tc-muted);
    font-size: 12px;
    font-weight: 650;
    letter-spacing: 0.06em;
    text-align: left;
    text-transform: uppercase;
}

.threecal-wrapper .threecal-month-grid td {
    height: var(--tc-cell-height);
    padding: 8px;
    border: 0;
    border-top: 1px solid var(--tc-border);
    vertical-align: top;
    background: transparent;
}

.threecal-wrapper .threecal-month-grid td + td {
    border-left: 1px solid var(--tc-border);
}

.threecal-wrapper .threecal-month-grid .threecal-weekend {
    background: color-mix(in srgb, var(--tc-surface-2) 70%, transparent);
}

.threecal-wrapper .threecal-month-grid .threecal-day-empty {
    background: repeating-linear-gradient(135deg, transparent 0 6px, color-mix(in srgb, var(--tc-border) 45%, transparent) 6px 7px);
}

.threecal-day-header {
    display: flex;
    justify-content: flex-start;
    margin-bottom: 6px;
}

.threecal-day-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    height: 28px;
    padding: 0 6px;
    border-radius: 999px;
    color: var(--tc-text);
    font-size: 13px;
    font-weight: 650;
    font-variant-numeric: tabular-nums;
}

.threecal-is-today .threecal-day-number {
    background: var(--tc-accent);
    color: var(--tc-accent-ink);
    box-shadow: 0 4px 12px color-mix(in srgb, var(--tc-accent) 40%, transparent);
}

.threecal-day-events {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.threecal-wrapper .threecal-event-dot {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    min-width: 0;
    padding: 4px 8px;
    border-left: 3px solid var(--tc-ev, var(--tc-accent));
    border-radius: 6px;
    background: var(--tc-surface-2);
    background: color-mix(in srgb, var(--tc-ev, var(--tc-accent)) 13%, var(--tc-surface));
    color: var(--tc-text);
    color: color-mix(in srgb, var(--tc-ev, var(--tc-accent)) 55%, var(--tc-text));
    font-size: 12px;
    font-weight: 600;
    line-height: 1.35;
    text-decoration: none;
    transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.threecal-wrapper .threecal-event-dot:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 10px color-mix(in srgb, var(--tc-ev, var(--tc-accent)) 25%, transparent);
}

.threecal-wrapper .threecal-event-continues {
    border-left-style: dashed;
    opacity: 0.85;
}

.threecal-event-time {
    font-size: 10.5px;
    font-weight: 750;
    font-variant-numeric: tabular-nums;
    opacity: 0.85;
}

.threecal-event-dot .threecal-event-title {
    display: -webkit-box;
    overflow: hidden;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow-wrap: break-word;
    hyphens: auto;
}

.threecal-wrapper .threecal-more-events {
    align-self: flex-start;
    padding: 2px 6px;
    border-radius: 6px;
    color: var(--tc-muted);
    font-size: 12px;
    font-weight: 600;
    text-decoration: none;
}

.threecal-wrapper .threecal-more-events:hover {
    background: var(--tc-surface-2);
    color: var(--tc-accent);
}

/* ==========================================================================
   List view (inside the calendar)
   ========================================================================== */
.threecal-list-view {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.threecal-list-day {
    border: 1px solid var(--tc-border);
    border-radius: var(--tc-radius-sm);
    overflow: hidden;
    background: var(--tc-surface);
}

.threecal-list-day-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 14px;
    background: var(--tc-surface-2);
    border-bottom: 1px solid var(--tc-border);
}

.threecal-list-day-name {
    font-weight: 700;
}

.threecal-list-day-date {
    color: var(--tc-muted);
    font-size: 13px;
}

.threecal-list-event {
    display: flex;
    align-items: stretch;
    gap: 12px;
    padding: 12px 14px;
    cursor: pointer;
    transition: background-color 0.15s ease;
}

.threecal-list-event + .threecal-list-event {
    border-top: 1px solid var(--tc-border);
}

.threecal-list-event:hover {
    background: color-mix(in srgb, var(--tc-ev, var(--tc-accent)) 6%, var(--tc-surface));
}

.threecal-list-event-color {
    flex: 0 0 4px;
    border-radius: 4px;
    background: var(--tc-ev, var(--tc-accent));
}

.threecal-list-event-content {
    min-width: 0;
}

.threecal-list-event-title,
.threecal-event-card .threecal-event-title,
.threecal-upcoming-title {
    font-weight: 650;
    overflow-wrap: anywhere;
}

.threecal-list-event-time {
    color: var(--tc-muted);
    font-size: 13px;
}

.threecal-no-events {
    padding: 28px 16px;
    color: var(--tc-muted);
    text-align: center;
}

.threecal-load-error {
    margin: 0 0 12px;
    padding: 10px 14px;
    border-left: 4px solid #d63638;
    border-radius: 6px;
    background: #fcf0f1;
    color: #1d2327;
    font-size: 14px;
}

/* ==========================================================================
   Footer: legend and subscription
   ========================================================================== */
.threecal-footer {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px 20px;
    margin-top: 18px;
    padding-top: 16px;
    border-top: 1px solid var(--tc-border);
}

.threecal-wrapper .threecal-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.threecal-legend-item {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    padding: 4px 12px 4px 8px;
    border-radius: 999px;
    background: color-mix(in srgb, var(--tc-ev, var(--tc-accent)) 10%, var(--tc-surface));
    font-size: 13px;
    font-weight: 600;
}

.threecal-legend-color {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--tc-ev, var(--tc-accent));
}

.threecal-subscribe {
    font-size: 14px;
}

.threecal-subscribe-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--tc-accent);
    font-weight: 650;
    cursor: pointer;
    list-style: none;
}

.threecal-subscribe-link::-webkit-details-marker {
    display: none;
}

.threecal-subscribe-panel {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-width: 460px;
    margin-top: 10px;
    padding: 14px;
    border: 1px solid var(--tc-border);
    border-radius: var(--tc-radius-sm);
    background: var(--tc-surface-2);
}

.threecal-wrapper .threecal-subscribe-open {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--tc-accent);
    font-weight: 650;
    text-decoration: none;
}

.threecal-subscribe-hint {
    color: var(--tc-muted);
    font-size: 13px;
}

.threecal-subscribe-url {
    padding: 6px 8px;
    border-radius: 6px;
    background: var(--tc-surface);
    color: var(--tc-text);
    font-size: 12px;
    overflow-wrap: anywhere;
    user-select: all;
}

/* ==========================================================================
   Buttons
   ========================================================================== */
.threecal-button,
a.threecal-button {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 42px;
    padding: 0 18px;
    border: 1px solid var(--tc-accent);
    border-radius: 999px;
    background: var(--tc-accent);
    color: var(--tc-accent-ink);
    font-size: 14px;
    font-weight: 650;
    text-decoration: none;
    transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.threecal-button:hover,
a.threecal-button:hover {
    color: var(--tc-accent-ink);
    transform: translateY(-1px);
    box-shadow: 0 8px 20px color-mix(in srgb, var(--tc-accent) 35%, transparent);
}

.threecal-button-ghost,
a.threecal-button-ghost {
    background: transparent;
    color: var(--tc-accent);
}

.threecal-button-ghost:hover,
a.threecal-button-ghost:hover {
    color: var(--tc-accent);
    box-shadow: none;
    background: color-mix(in srgb, var(--tc-accent) 8%, transparent);
}

/* ==========================================================================
   Event popup
   ========================================================================== */
.threecal-modal {
    position: fixed;
    inset: 0;
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(10, 14, 26, 0.55);
    backdrop-filter: blur(4px);
}

.threecal-modal-content {
    position: relative;
    width: 100%;
    max-width: 540px;
    max-height: 88vh;
    overflow-y: auto;
    padding: 28px;
    border-radius: var(--tc-radius);
    background: var(--tc-surface);
    color: var(--tc-text);
    box-shadow: var(--tc-shadow-lg);
    animation: threecal-pop 0.18s ease-out;
}

@keyframes threecal-pop {
    from { opacity: 0; transform: translateY(8px) scale(0.98); }
    to { opacity: 1; transform: none; }
}

.threecal-wrapper .threecal-modal-close {
    position: absolute;
    top: 14px;
    right: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: var(--tc-surface-2);
    color: var(--tc-text);
    cursor: pointer;
}

.threecal-wrapper .threecal-modal-close:hover {
    background: var(--tc-surface-3);
}

.threecal-modal-event-image img {
    display: block;
    width: 100%;
    height: auto;
    margin-bottom: 18px;
    border-radius: var(--tc-radius-sm);
}

.threecal-wrapper .threecal-modal-event-title {
    margin: 0 44px 12px 0;
    padding: 0;
    color: var(--tc-text);
    font-size: 1.35rem;
    font-weight: 750;
    line-height: 1.25;
}

.threecal-modal-event-categories,
.threecal-event-categories {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 14px;
}

.threecal-modal-category-tag,
.threecal-category-tag {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 999px;
    background: color-mix(in srgb, var(--tc-ev, var(--tc-accent)) 14%, var(--tc-surface));
    color: color-mix(in srgb, var(--tc-ev, var(--tc-accent)) 60%, var(--tc-text));
    font-size: 12px;
    font-weight: 700;
}

.threecal-modal-event-meta {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 16px;
    padding: 14px 16px;
    border-radius: var(--tc-radius-sm);
    background: var(--tc-surface-2);
}

.threecal-modal-meta-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    font-size: 14px;
}

.threecal-modal-meta-item .threecal-icon {
    margin-top: 2px;
    color: var(--tc-accent);
}

.threecal-modal-meta-item a {
    color: var(--tc-accent);
}

.threecal-modal-event-description {
    margin-bottom: 18px;
    font-size: 15px;
}

.threecal-modal-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

/* ==========================================================================
   Event cards ([threecal_events])
   ========================================================================== */
.threecal-event-list {
    margin: 0 0 1.5em;
}

.threecal-cards {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.threecal-cards.threecal-grid {
    display: grid;
    grid-template-columns: repeat(var(--tc-cols, 3), minmax(0, 1fr));
}

.threecal-grid-1 { --tc-cols: 1; }
.threecal-grid-2 { --tc-cols: 2; }
.threecal-grid-3 { --tc-cols: 3; }
.threecal-grid-4 { --tc-cols: 4; }

.threecal-event-card {
    display: flex;
    gap: 18px;
    padding: 18px;
    border: 1px solid var(--tc-border);
    border-radius: var(--tc-radius);
    background: var(--tc-surface);
    box-shadow: var(--tc-shadow);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.threecal-event-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 2px 4px rgba(16, 24, 40, 0.05), 0 16px 36px rgba(16, 24, 40, 0.1);
}

.threecal-grid .threecal-event-card {
    flex-direction: column;
}

.threecal-date-badge {
    display: flex;
    flex: 0 0 68px;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    align-self: flex-start;
    min-height: 76px;
    padding: 8px 6px;
    border-radius: 14px;
    background: color-mix(in srgb, var(--tc-ev, var(--tc-accent)) 12%, var(--tc-surface));
    color: color-mix(in srgb, var(--tc-ev, var(--tc-accent)) 70%, var(--tc-text));
    line-height: 1;
    text-align: center;
}

.threecal-date-badge-month {
    font-size: 11px;
    font-weight: 750;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.threecal-date-badge-day {
    margin: 4px 0;
    font-size: 26px;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
}

.threecal-date-badge-weekday {
    font-size: 11px;
    font-weight: 600;
    opacity: 0.8;
}

.threecal-date-badge-small {
    flex-basis: 48px;
    min-height: 52px;
    border-radius: 12px;
}

.threecal-date-badge-small .threecal-date-badge-day {
    font-size: 19px;
    margin: 2px 0 0;
}

.threecal-event-content {
    flex: 1 1 auto;
    min-width: 0;
}

.threecal-event-image img {
    display: block;
    width: 100%;
    height: auto;
    margin-bottom: 12px;
    border-radius: var(--tc-radius-sm);
}

.threecal-event-card .threecal-event-title {
    margin: 0 0 8px;
    padding: 0;
    color: var(--tc-text);
    font-size: 1.15rem;
    font-weight: 750;
    line-height: 1.3;
}

.threecal-event-card .threecal-event-title a {
    color: inherit;
    text-decoration: none;
}

.threecal-event-card .threecal-event-title a:hover {
    color: var(--tc-accent);
}

.threecal-event-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 16px;
    margin-bottom: 8px;
    color: var(--tc-muted);
    font-size: 14px;
}

.threecal-event-meta > span {
    display: inline-flex;
    align-items: flex-start;
    gap: 6px;
}

.threecal-event-meta .threecal-icon {
    margin-top: 2px;
    color: var(--tc-ev, var(--tc-accent));
}

.threecal-event-excerpt {
    margin: 0 0 10px;
    color: var(--tc-text);
    font-size: 15px;
}

.threecal-event-ics,
a.threecal-event-ics {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--tc-accent);
    font-size: 14px;
    font-weight: 650;
    text-decoration: none;
}

.threecal-event-ics:hover {
    text-decoration: underline;
}

.threecal-is-cancelled .threecal-event-title,
.threecal-is-cancelled .threecal-poster-title,
.threecal-is-cancelled .threecal-post-date-value,
.threecal-is-cancelled .threecal-list-event-title,
.threecal-is-cancelled .threecal-upcoming-title,
.threecal-modal-event-title.threecal-is-cancelled {
    text-decoration: line-through;
    text-decoration-thickness: 2px;
}

.threecal-event-dot.threecal-is-cancelled,
.threecal-list-event.threecal-is-cancelled,
.threecal-upcoming-item.threecal-is-cancelled,
.threecal-event-card.threecal-is-cancelled {
    opacity: 0.75;
}

/* Badge for cancelled events, not struck through itself */
.threecal-cancelled-badge {
    display: inline-block;
    margin-right: 4px;
    padding: 1px 6px;
    border-radius: 4px;
    background: #b91c1c;
    color: #fff;
    font-size: 0.72em;
    font-weight: 700;
    letter-spacing: 0.02em;
    line-height: 1.5;
    text-transform: uppercase;
    vertical-align: middle;
    text-decoration: none;
    opacity: 1;
}

.threecal-event-dot .threecal-cancelled-badge {
    display: block;
    width: max-content;
    margin: 0 0 2px;
    background: rgba(15, 23, 42, 0.55);
    color: #ffffff;
    font-size: 9px;
}

.threecal-pagination {
    margin-top: 18px;
}

.threecal-nav-pagination {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.threecal-nav-pagination a,
.threecal-nav-pagination span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    min-height: 40px;
    padding: 0 12px;
    border: 1px solid var(--tc-border);
    border-radius: 999px;
    background: var(--tc-surface);
    color: var(--tc-text);
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
}

.threecal-nav-pagination a:hover {
    border-color: var(--tc-accent);
    color: var(--tc-accent);
}

.threecal-nav-pagination .threecal-page-current {
    border-color: var(--tc-accent);
    background: var(--tc-accent);
    color: var(--tc-accent-ink);
}

.threecal-wrapper .threecal-nav-pagination span.threecal-page-gap,
.threecal-nav-pagination span.threecal-page-gap {
    min-width: 20px;
    border-color: transparent;
    background: none;
    box-shadow: none;
    color: var(--tc-muted);
}

/* ==========================================================================
   Upcoming events ([threecal_upcoming])
   ========================================================================== */
.threecal-upcoming {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin: 0 0 1.5em;
    padding: 0;
    list-style: none;
}

.threecal-upcoming-item {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 0;
    padding: 10px;
    border: 1px solid var(--tc-border);
    border-radius: 14px;
    background: var(--tc-surface);
}

.threecal-upcoming-content {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.threecal-upcoming-title {
    overflow: hidden;
    font-weight: 700;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.threecal-upcoming-date,
.threecal-upcoming-location {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: var(--tc-muted);
    font-size: 13px;
}

/* ==========================================================================
   Single event ([threecal_event])
   ========================================================================== */
.threecal-single-event {
    margin: 0 0 1.5em;
    padding: 28px;
    border: 1px solid var(--tc-border);
    border-top: 5px solid var(--tc-ev, var(--tc-accent));
    border-radius: var(--tc-radius);
    background: var(--tc-surface);
    box-shadow: var(--tc-shadow);
}

.threecal-event-featured-image img {
    display: block;
    width: 100%;
    height: auto;
    margin-bottom: 20px;
    border-radius: var(--tc-radius-sm);
}

.threecal-single-event .threecal-event-title {
    margin: 0 0 18px;
    padding: 0;
    color: var(--tc-text);
    font-size: 1.6rem;
    font-weight: 800;
    line-height: 1.2;
}

.threecal-event-details {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 14px;
    margin-bottom: 18px;
    padding: 16px;
    border-radius: var(--tc-radius-sm);
    background: var(--tc-surface-2);
}

.threecal-detail-row {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    font-size: 15px;
}

.threecal-detail-row .threecal-icon {
    margin-top: 2px;
    color: var(--tc-ev, var(--tc-accent));
}

.threecal-detail-row a {
    color: var(--tc-accent);
}

.threecal-event-description {
    margin-bottom: 18px;
}

.threecal-event-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

/* ==========================================================================
   Design 2: Accent
   ========================================================================== */
.threecal-wrapper.threecal-theme-accent {
    padding: 0;
    overflow: hidden;
    border: 0;
}

.threecal-theme-accent .threecal-toolbar {
    margin: 0;
    padding: 26px 26px 22px;
    background:
        radial-gradient(120% 140% at 100% 0%, color-mix(in srgb, #ffffff 22%, transparent) 0%, transparent 55%),
        linear-gradient(135deg, var(--tc-accent) 0%, color-mix(in srgb, var(--tc-accent) 55%, #0ea5e9) 100%);
    color: var(--tc-accent-ink);
}

.threecal-theme-accent .threecal-title,
.threecal-theme-accent .threecal-title-year {
    color: var(--tc-accent-ink);
}

.threecal-theme-accent .threecal-title-year {
    opacity: 0.75;
}

.threecal-theme-accent .threecal-navgroup,
.threecal-theme-accent .threecal-view-switcher {
    background: rgba(255, 255, 255, 0.16);
    border-color: rgba(255, 255, 255, 0.28);
}

.threecal-wrapper.threecal-theme-accent .threecal-navgroup button,
.threecal-wrapper.threecal-theme-accent .threecal-view-btn {
    color: var(--tc-accent-ink);
}

.threecal-wrapper.threecal-theme-accent .threecal-navgroup button:hover,
.threecal-wrapper.threecal-theme-accent .threecal-view-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    color: var(--tc-accent-ink);
}

.threecal-wrapper.threecal-theme-accent .threecal-view-btn.active {
    background: #ffffff;
    color: var(--tc-accent);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.15);
}

.threecal-theme-accent .threecal-filters {
    margin: 0;
    padding: 16px 26px 0;
}

.threecal-theme-accent .threecal-calendar {
    padding: 18px 20px 4px;
}

.threecal-theme-accent .threecal-footer {
    margin: 0;
    padding: 16px 26px 22px;
}

.threecal-wrapper.threecal-theme-accent .threecal-month-grid {
    border-spacing: 6px;
}

.threecal-wrapper.threecal-theme-accent .threecal-month-grid th {
    padding: 0 6px 4px;
    text-align: center;
}

.threecal-wrapper.threecal-theme-accent .threecal-month-grid td,
.threecal-wrapper.threecal-theme-accent .threecal-month-grid td + td {
    border: 0;
    border-radius: 14px;
    background: var(--tc-surface-2);
}

.threecal-wrapper.threecal-theme-accent .threecal-month-grid .threecal-weekend {
    background: var(--tc-surface-3);
}

.threecal-wrapper.threecal-theme-accent .threecal-month-grid .threecal-day-empty {
    background: transparent;
}

.threecal-wrapper.threecal-theme-accent .threecal-month-grid .threecal-is-today {
    background: var(--tc-surface);
    box-shadow: inset 0 0 0 2px var(--tc-accent), 0 10px 24px color-mix(in srgb, var(--tc-accent) 22%, transparent);
}

.threecal-wrapper.threecal-theme-accent .threecal-event-dot {
    border-left: 0;
    border-radius: 10px;
    padding: 4px 9px;
    background: var(--tc-ev, var(--tc-accent));
    color: var(--tc-ev-ink, var(--tc-accent-ink));
    box-shadow: 0 3px 8px color-mix(in srgb, var(--tc-ev, var(--tc-accent)) 30%, transparent);
}

.threecal-wrapper.threecal-theme-accent .threecal-event-continues {
    opacity: 0.7;
}

.threecal-theme-accent .threecal-date-badge {
    background: var(--tc-ev, var(--tc-accent));
    color: var(--tc-ev-ink, var(--tc-accent-ink));
    box-shadow: 0 8px 18px color-mix(in srgb, var(--tc-ev, var(--tc-accent)) 30%, transparent);
}

.threecal-theme-accent .threecal-category-tag,
.threecal-theme-accent .threecal-modal-category-tag {
    background: var(--tc-ev, var(--tc-accent));
    color: var(--tc-ev-ink, var(--tc-accent-ink));
}

.threecal-event-list.threecal-theme-accent .threecal-event-card,
.threecal-upcoming.threecal-theme-accent .threecal-upcoming-item {
    border: 0;
    background: var(--tc-surface-2);
    box-shadow: none;
}

/* ==========================================================================
   Design 3: Night
   ========================================================================== */
.threecal-theme-dark {
    --tc-surface: #0d1424;
    --tc-surface-2: #131c31;
    --tc-surface-3: #1a2540;
    --tc-text: #e7ebf5;
    --tc-muted: #93a0bb;
    --tc-border: #222e4a;
    --tc-accent-ink: #06121f;
    --tc-shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 18px 40px rgba(2, 6, 23, 0.45);
    --tc-shadow-lg: 0 30px 80px rgba(0, 0, 0, 0.6);
}

.threecal-wrapper.threecal-theme-dark {
    background:
        radial-gradient(90% 60% at 100% 0%, color-mix(in srgb, var(--tc-accent) 16%, transparent) 0%, transparent 60%),
        var(--tc-surface);
}

.threecal-theme-dark .threecal-is-today .threecal-day-number {
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--tc-accent) 25%, transparent), 0 0 18px color-mix(in srgb, var(--tc-accent) 60%, transparent);
}

.threecal-wrapper.threecal-theme-dark .threecal-event-dot {
    background: color-mix(in srgb, var(--tc-ev, var(--tc-accent)) 22%, var(--tc-surface));
    color: color-mix(in srgb, var(--tc-ev, var(--tc-accent)) 45%, #ffffff);
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--tc-ev, var(--tc-accent)) 30%, transparent);
}

.threecal-wrapper.threecal-theme-dark .threecal-event-dot:hover {
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--tc-ev, var(--tc-accent)) 60%, transparent), 0 0 16px color-mix(in srgb, var(--tc-ev, var(--tc-accent)) 35%, transparent);
}

.threecal-theme-dark .threecal-date-badge,
.threecal-theme-dark .threecal-category-tag,
.threecal-theme-dark .threecal-modal-category-tag,
.threecal-theme-dark .threecal-legend-item {
    background: color-mix(in srgb, var(--tc-ev, var(--tc-accent)) 20%, var(--tc-surface));
    color: color-mix(in srgb, var(--tc-ev, var(--tc-accent)) 40%, #ffffff);
}

.threecal-theme-dark .threecal-event-card,
.threecal-theme-dark .threecal-upcoming-item,
.threecal-theme-dark .threecal-single-event,
.threecal-theme-dark .threecal-list-day {
    background: var(--tc-surface);
}

.threecal-theme-dark .threecal-modal-content {
    border: 1px solid var(--tc-border);
}

.threecal-wrapper.threecal-theme-dark .threecal-category-filter {
    background-color: var(--tc-surface-2);
}

.threecal-theme-dark .threecal-load-error {
    background: #3a1d22;
    color: #fde2e4;
}

/* ==========================================================================
   Small screens
   ========================================================================== */
@media (max-width: 782px) {
    .threecal-cards.threecal-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 600px) {
    .threecal-wrapper {
        padding: 16px;
        --tc-cell-height: 56px;
    }

    .threecal-wrapper.threecal-theme-accent {
        padding: 0;
    }

    .threecal-theme-accent .threecal-toolbar {
        padding: 18px 16px;
    }

    .threecal-theme-accent .threecal-calendar {
        padding: 12px 8px 0;
    }

    .threecal-theme-accent .threecal-filters,
    .threecal-theme-accent .threecal-footer {
        padding-left: 16px;
        padding-right: 16px;
    }

    .threecal-toolbar,
    .threecal-controls {
        width: 100%;
    }

    .threecal-controls {
        justify-content: space-between;
    }

    .threecal-view-btn span {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip: rect(1px, 1px, 1px, 1px);
    }

    .threecal-wrapper .threecal-month-grid th {
        padding: 0 2px 6px;
        font-size: 10px;
        text-align: center;
    }

    .threecal-wrapper .threecal-month-grid td {
        padding: 4px 2px;
        text-align: center;
    }

    .threecal-wrapper.threecal-theme-accent .threecal-month-grid {
        border-spacing: 3px;
    }

    .threecal-day-header {
        justify-content: center;
        margin-bottom: 2px;
    }

    .threecal-day-number {
        min-width: 24px;
        height: 24px;
        font-size: 12px;
    }

    .threecal-day-events {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
        gap: 3px;
    }

    .threecal-wrapper .threecal-event-dot,
    .threecal-wrapper.threecal-theme-accent .threecal-event-dot {
        width: 9px;
        height: 9px;
        padding: 0;
        border: 0;
        border-radius: 50%;
        background: var(--tc-ev, var(--tc-accent));
        box-shadow: none;
    }

    .threecal-wrapper .threecal-event-dot > span {
        display: none;
    }

    .threecal-wrapper .threecal-event-extra {
        display: none !important;
    }

    .threecal-wrapper .threecal-more-events {
        padding: 0;
        font-size: 10px;
    }

    .threecal-cards.threecal-grid {
        grid-template-columns: minmax(0, 1fr);
    }

    .threecal-event-card {
        gap: 14px;
        padding: 14px;
    }

    .threecal-date-badge {
        flex-basis: 56px;
        min-height: 64px;
    }

    .threecal-modal {
        align-items: flex-end;
        padding: 0;
    }

    .threecal-modal-content {
        max-height: 92vh;
        border-radius: var(--tc-radius) var(--tc-radius) 0 0;
    }

    .threecal-single-event {
        padding: 20px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .threecal-wrapper *,
    .threecal-event-card,
    .threecal-modal-content {
        animation: none !important;
        transition: none !important;
    }
}

/* ==========================================================================
   Keyboard focus
   ========================================================================== */
.threecal-wrapper button:focus-visible,
.threecal-wrapper select:focus-visible,
.threecal-wrapper summary:focus-visible,
.threecal-event-dot:focus-visible,
.threecal-more-events:focus-visible,
.threecal-list-event:focus-visible,
.threecal-button:focus-visible,
.threecal-event-ics:focus-visible,
.threecal-nav-pagination a:focus-visible {
    outline: 2px solid var(--tc-accent);
    outline-offset: 2px;
}

/* ==========================================================================
   Dates from posts (1.4.0): box in the post, postponed note, poster view
   ========================================================================== */
.threecal-post-date {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 14px 18px;
    margin: 0 0 1.5em;
    padding: 16px 18px;
    border: 1px solid var(--tc-border);
    border-left: 4px solid var(--tc-accent);
    border-radius: var(--tc-radius-sm);
    background: var(--tc-surface);
    box-shadow: var(--tc-shadow);
}

.threecal-post-date-icon {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    width: 46px;
    height: 46px;
    border-radius: 12px;
    background: color-mix(in srgb, var(--tc-accent) 12%, var(--tc-surface));
    color: var(--tc-accent);
}

.threecal-post-date-text {
    display: flex;
    flex: 1 1 220px;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.threecal-post-date-label {
    color: var(--tc-muted);
    font-size: 0.78em;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.threecal-post-date-value {
    color: var(--tc-text);
    font-size: 1.12em;
    font-weight: 700;
    line-height: 1.3;
}

.threecal-post-date .threecal-post-date-ics {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    border-radius: 999px;
    background: var(--tc-accent);
    color: var(--tc-accent-ink);
    font-weight: 700;
    line-height: 1.2;
    text-decoration: none;
    white-space: nowrap;
}

.threecal-post-date .threecal-post-date-ics:hover {
    color: var(--tc-accent-ink);
    filter: brightness(1.08);
    text-decoration: none;
}

.threecal-post-date .threecal-post-date-ics:focus-visible {
    outline: 2px solid var(--tc-accent);
    outline-offset: 3px;
}

.threecal-post-date.threecal-theme-accent {
    border: 0;
    background: linear-gradient(135deg, var(--tc-accent) 0%, color-mix(in srgb, var(--tc-accent) 55%, #0ea5e9) 100%);
}

.threecal-post-date.threecal-theme-accent .threecal-post-date-label,
.threecal-post-date.threecal-theme-accent .threecal-post-date-value,
.threecal-post-date.threecal-theme-accent .threecal-postponed {
    color: var(--tc-accent-ink);
}

.threecal-post-date.threecal-theme-accent .threecal-post-date-icon {
    background: rgba(255, 255, 255, 0.18);
    color: var(--tc-accent-ink);
}

.threecal-post-date.threecal-theme-accent .threecal-post-date-ics,
.threecal-post-date.threecal-theme-accent .threecal-post-date-ics:hover {
    background: var(--tc-surface);
    color: var(--tc-text);
}

.threecal-post-date-placeholder {
    margin: 0;
    padding: 14px 16px;
    border: 1px dashed #c3c4c7;
    border-radius: 8px;
    color: #646970;
    font-size: 13px;
}

/* Postponed date */
.threecal-postponed {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin: 4px 0 0;
    color: #b45309;
    font-size: 0.88em;
    font-weight: 600;
}

.threecal-postponed .threecal-icon {
    flex: 0 0 auto;
}

.threecal-theme-dark .threecal-postponed {
    color: #fbbf24;
}

/* Poster view */
.threecal-cards.threecal-poster-grid {
    display: grid;
    grid-template-columns: repeat(var(--tc-cols, 4), minmax(0, 1fr));
    gap: 22px;
}

.threecal-poster-card {
    display: flex;
    flex-direction: column;
    min-width: 0;
    overflow: hidden;
    border: 1px solid var(--tc-border);
    border-radius: var(--tc-radius-sm);
    background: var(--tc-surface);
    box-shadow: var(--tc-shadow);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.threecal-poster-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--tc-shadow-lg);
}

.threecal-poster-media {
    position: relative;
    display: block;
    aspect-ratio: 2 / 3;
    overflow: hidden;
    background: color-mix(in srgb, var(--tc-ev, var(--tc-accent)) 14%, var(--tc-surface-2));
}

.threecal-poster-media img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.threecal-poster-placeholder {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--tc-ev, var(--tc-accent));
    opacity: 0.55;
}

.threecal-poster-date {
    position: absolute;
    top: 10px;
    left: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 48px;
    padding: 6px 8px;
    border-radius: 10px;
    background: var(--tc-ev, var(--tc-accent));
    color: var(--tc-ev-ink, var(--tc-accent-ink));
    line-height: 1.05;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.25);
}

.threecal-poster-day {
    font-size: 1.35em;
    font-weight: 800;
}

.threecal-poster-month {
    font-size: 0.72em;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.threecal-poster-body {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    gap: 4px;
    padding: 12px 14px 14px;
}

.threecal-poster-title {
    margin: 0;
    font-size: 1em;
    font-weight: 700;
    line-height: 1.3;
}

.threecal-poster-title a {
    color: var(--tc-text);
    text-decoration: none;
}

.threecal-poster-title a:hover,
.threecal-poster-title a:focus-visible {
    color: var(--tc-ev, var(--tc-accent));
}

.threecal-poster-when {
    margin: 0;
    color: var(--tc-muted);
    font-size: 0.88em;
}

.threecal-poster-body .threecal-event-ics {
    margin-top: auto;
    padding-top: 6px;
    font-size: 0.88em;
}

.threecal-poster-card.threecal-is-cancelled .threecal-poster-media img {
    opacity: 0.6;
    filter: grayscale(1);
}

@media (max-width: 960px) {
    .threecal-cards.threecal-poster-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (max-width: 720px) {
    .threecal-cards.threecal-poster-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 14px;
    }

    .threecal-post-date .threecal-post-date-ics {
        width: 100%;
        justify-content: center;
    }
}

@media (prefers-reduced-motion: reduce) {
    .threecal-poster-card {
        transition: none;
    }

    .threecal-poster-card:hover {
        transform: none;
    }
}

/* ==========================================================================
   Only the month is known: "Date to be announced" (since 1.6.0)
   ========================================================================== */
.threecal-tba {
    display: inline-block;
    padding: 1px 8px;
    border-radius: 999px;
    background: color-mix(in srgb, var(--tc-ev, var(--tc-accent)) 12%, var(--tc-surface, #ffffff));
    color: color-mix(in srgb, var(--tc-ev, var(--tc-accent)) 70%, var(--tc-text, #141824));
    font-size: 0.85em;
    font-weight: 650;
    line-height: 1.5;
    white-space: nowrap;
}

.threecal-month-tba {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 12px;
    margin: 0 0 12px;
    padding: 10px 12px;
    border: 1px dashed var(--tc-border);
    border-radius: var(--tc-radius-sm);
    background: var(--tc-surface);
}

.threecal-month-tba-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--tc-muted);
    font-size: 13px;
    font-weight: 650;
}

.threecal-month-tba-events {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    min-width: 0;
}

.threecal-wrapper .threecal-tba-event {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    max-width: 100%;
    min-width: 0;
    padding: 4px 10px;
    border-left: 3px solid var(--tc-ev, var(--tc-accent));
    border-radius: 6px;
    background: color-mix(in srgb, var(--tc-ev, var(--tc-accent)) 13%, var(--tc-surface));
    color: color-mix(in srgb, var(--tc-ev, var(--tc-accent)) 55%, var(--tc-text));
    font-size: 12px;
    font-weight: 600;
    line-height: 1.35;
    text-decoration: none;
    overflow-wrap: anywhere;
}

.threecal-wrapper .threecal-tba-event:hover {
    box-shadow: 0 4px 10px color-mix(in srgb, var(--tc-ev, var(--tc-accent)) 25%, transparent);
}

.threecal-wrapper .threecal-tba-event:focus-visible {
    outline: 2px solid var(--tc-accent);
    outline-offset: 2px;
}

.threecal-wrapper .threecal-tba-event.threecal-is-cancelled .threecal-event-title {
    text-decoration: line-through;
}

.threecal-date-badge-tba .threecal-date-badge-day {
    font-size: 17px;
}

.threecal-date-badge-small.threecal-date-badge-tba .threecal-date-badge-day {
    font-size: 13px;
}

.threecal-poster-date-tba .threecal-poster-day {
    font-size: 1em;
    text-transform: uppercase;
}
