/* ============================================================
   LWN iCal Calendar — Front-End Styles
   ============================================================ */

/* ── Base Container ─────────────────────────────────────────── */
.lwn-calendar {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    width: 100%;
    max-width: 100%;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,.06);
    margin-bottom: 32px;
    color: #1a202c;
}

/* ── Month View Header ──────────────────────────────────────── */
.lwn-cal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 24px;
    background: #fff;
    border-bottom: 1px solid #e2e8f0;
}

.lwn-cal-title {
    margin: 0;
    font-size: 1.2rem;
    font-weight: 700;
    color: #1a202c;
    letter-spacing: -.01em;
}

.lwn-cal-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    color: #4a5568;
    text-decoration: none;
    transition: background .15s, color .15s;
    border: 1px solid #e2e8f0;
}

.lwn-cal-nav:hover {
    background: #f7fafc;
    color: #2d3748;
    border-color: #cbd5e0;
}

/* ── Day-of-Week Row ────────────────────────────────────────── */
.lwn-cal-dow-row {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    background: #f7fafc;
    border-bottom: 1px solid #e2e8f0;
}

.lwn-cal-dow {
    padding: 10px 4px;
    text-align: center;
    font-size: .72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: #718096;
}

/* ── Grid ────────────────────────────────────────────────────── */
.lwn-cal-grid {
    display: grid;
    /* minmax(0, 1fr) keeps all 7 columns equal-width; a plain 1fr track has an
       implicit min-width:auto and would stretch to fit long event titles. */
    grid-template-columns: repeat(7, minmax(0, 1fr));
    border-left: 1px solid #e2e8f0;
}

/* ── Day Cells ───────────────────────────────────────────────── */
.lwn-cal-day {
    min-height: 110px;
    min-width: 0;              /* allow the cell to shrink so wrapped events stay contained */
    padding: 6px 6px 8px;
    border-right: 1px solid #e2e8f0;
    border-bottom: 1px solid #e2e8f0;
    background: #fff;
    position: relative;
    transition: background .1s;
}

.lwn-cal-day--empty {
    background: #fafafa;
    min-height: 110px;
}

.lwn-cal-day--today .lwn-cal-day-num {
    background: #E55A2B;
    color: #fff;
    border-radius: 50%;
    width: 26px;
    height: 26px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
}

.lwn-cal-day-num {
    display: inline-block;
    font-size: .82rem;
    font-weight: 600;
    color: #4a5568;
    margin-bottom: 4px;
    width: 26px;
    height: 26px;
    line-height: 26px;
    text-align: center;
}

/* ── Events inside cells ────────────────────────────────────── */
.lwn-cal-events {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.lwn-cal-event {
    padding: 3px 6px;
    border-radius: 4px;
    font-size: .72rem;
    font-weight: 500;
    color: #fff;
    /* Wrap long titles onto multiple lines instead of overflowing the cell.
       Cap at 3 lines so one long event can't dominate the row; clicking the
       pill toggles .is-expanded to reveal the full title in place. */
    white-space: normal;
    overflow-wrap: break-word;
    word-break: break-word;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    cursor: pointer;
    transition: filter .15s, transform .1s;
    line-height: 1.3;
}

/* Clicked-open pill: drop the clamp and show the whole title in place. */
.lwn-cal-event.is-expanded {
    -webkit-line-clamp: unset;
    display: block;
    overflow: visible;
}

.lwn-cal-event:hover,
.lwn-cal-event:focus {
    filter: brightness(.9);
    outline: none;
    transform: translateY(-1px);
}

.lwn-cal-event--more {
    background: #e2e8f0 !important;
    border: none !important;
    color: #718096 !important;
    font-size: .68rem;
    cursor: pointer;
}

.lwn-cal-event--more:hover {
    background: #cbd5e0 !important;
    color: #4a5568 !important;
}

.lwn-event-time {
    opacity: .85;
    font-size: .68rem;
}

/* Responsive Month Grid */
@media (max-width: 700px) {
    .lwn-cal-day { min-height: 60px; padding: 4px; }
    .lwn-cal-day-num { font-size: .75rem; }
    .lwn-cal-event { font-size: .65rem; padding: 1px 4px; }
    .lwn-cal-title { font-size: 1rem; }
    .lwn-event-time { display: none; }
}

@media (max-width: 480px) {
    .lwn-cal-dow { font-size: .6rem; padding: 6px 2px; }
    .lwn-cal-header { padding: 12px 14px; }
    .lwn-cal-day { min-height: 44px; }
    .lwn-cal-events { display: none; }
    .lwn-cal-day--has-events::after {
        content: '';
        display: block;
        width: 6px;
        height: 6px;
        border-radius: 50%;
        background: #E55A2B;
        margin: 2px auto 0;
    }
}

/* ── List View ───────────────────────────────────────────────── */
.lwn-calendar--list {
    padding: 0;
    overflow: visible;
}

.lwn-list-date-group {
    padding: 0;
}

.lwn-list-date-header {
    padding: 12px 24px 10px;
    font-size: .78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .07em;
    color: #718096;
    background: #f7fafc;
    border-bottom: 1px solid #e2e8f0;
    position: sticky;
    top: 0;
    z-index: 1;
}

.lwn-list-event {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 14px 24px;
    border-bottom: 1px solid #e2e8f0;
    border-left: 4px solid transparent;
    cursor: pointer;
    transition: background .15s;
}

.lwn-list-event:hover,
.lwn-list-event:focus {
    background: #f7fafc;
    outline: none;
}

.lwn-list-event-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
    margin-top: 5px;
}

.lwn-list-event-body {
    flex: 1;
}

.lwn-list-event-title {
    font-size: .95rem;
    font-weight: 600;
    color: #1a202c;
    margin-bottom: 4px;
}

.lwn-list-event-meta {
    font-size: .8rem;
    color: #718096;
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    align-items: center;
    margin-bottom: 4px;
}

.lwn-meta-sep { color: #cbd5e0; }

.lwn-list-event-desc {
    font-size: .82rem;
    color: #4a5568;
    line-height: 1.5;
    margin-top: 2px;
}

.lwn-cal-empty {
    padding: 40px 24px;
    text-align: center;
    color: #718096;
}

/* ── Event Detail Modal ──────────────────────────────────────── */
.lwn-cal-modal {
    position: fixed;
    inset: 0;
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.lwn-cal-modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,.45);
    cursor: pointer;
}

.lwn-cal-modal-panel {
    position: relative;
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 20px 60px rgba(0,0,0,.25);
    max-width: 480px;
    width: 100%;
    overflow: hidden;
    animation: lwnModalIn .2s ease;
}

@keyframes lwnModalIn {
    from { opacity:0; transform:translateY(12px) scale(.97); }
    to   { opacity:1; transform:none; }
}

.lwn-cal-modal-color-bar {
    height: 6px;
    width: 100%;
}

.lwn-cal-modal-close {
    position: absolute;
    top: 14px;
    right: 16px;
    background: none;
    border: none;
    font-size: 22px;
    line-height: 1;
    color: #718096;
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
    transition: color .15s, background .15s;
    z-index: 1;
}

.lwn-cal-modal-close:hover { color: #2d3748; background: #f7fafc; }

.lwn-cal-modal-body {
    padding: 20px 24px 24px;
}

.lwn-cal-modal-title {
    margin: 0 0 14px;
    font-size: 1.15rem;
    font-weight: 700;
    color: #1a202c;
    line-height: 1.3;
    padding-right: 30px;
}

.lwn-cal-modal-meta {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 14px;
}

.lwn-cal-modal-meta > div {
    font-size: .85rem;
    color: #4a5568;
    display: flex;
    align-items: flex-start;
    gap: 8px;
}

.lwn-cal-modal-meta > div:empty { display: none; }

.lwn-cal-modal-meta > div::before {
    font-size: 14px;
    margin-top: 1px;
    flex-shrink: 0;
}

.lwn-cal-modal-time::before     { content: '🕐'; }
.lwn-cal-modal-location::before { content: '📍'; }
.lwn-cal-modal-feed::before     { content: '📅'; }

.lwn-cal-modal-description {
    font-size: .88rem;
    color: #4a5568;
    line-height: 1.6;
    white-space: pre-line;
    padding-top: 14px;
    border-top: 1px solid #e2e8f0;
    margin-bottom: 14px;
}

.lwn-cal-modal-description:empty { display: none; }

.lwn-cal-modal-link a {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: .85rem;
    font-weight: 600;
    color: #E55A2B;
    text-decoration: none;
    padding: 8px 14px;
    border: 1px solid #E55A2B;
    border-radius: 8px;
    transition: background .15s, color .15s;
}

.lwn-cal-modal-link a:hover {
    background: #E55A2B;
    color: #fff;
}

.lwn-cal-modal-link:empty { display: none; }
