/* ============================================================
   Events module — public/events/*.php. Follows the same
   page-head-card/subnav pattern as Pages/Courses (see those
   modules' own CSS comments for the full rationale); this file
   only covers what's specific to events: the RSVP button row,
   the day-number date badge on list cards, and the month
   calendar grid, which none of the other modules need.
   ============================================================ */

/* No padding/margin/max-width here on purpose — matches how Pages/Courses
   handle this: the theme's own .page-content wrapper already provides
   max-width and padding (see themes/*/style.css), so adding a second,
   narrower constraint here would just shrink the section below what the
   rest of the site already allows. .ev-page exists only as a semantic
   grouping hook for descendant selectors. */
.ev-page {
}

/* ---- Subnav (Upcoming/Past/Mine/Calendar) — same shape as
   pg-subnav/cert-subnav: standalone bordered box, active tab gets
   a background tint + underline, icon before each label. ---- */
.ev-subnav {
    display: flex;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius, 5px);
    margin-bottom: 1.25rem;
    overflow-x: auto;
    scrollbar-width: none;
}
.ev-subnav::-webkit-scrollbar { display: none; }
.ev-subnav a {
    flex-shrink: 0;
    padding: .45rem .6rem;
    text-decoration: none;
    color: var(--ink-soft);
    font-weight: 600;
    font-size: .76rem;
    border-bottom: 2px solid transparent;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: .3rem;
}
.ev-subnav a.is-active {
    color: var(--indigo);
    border-bottom-color: var(--indigo);
    background: var(--indigo-soft, var(--paper));
}
.page-head-group .ev-subnav { margin-bottom: 0; border: none; border-radius: 0; }

.ev-search {
    display: flex;
    gap: .5rem;
    margin-bottom: 1rem;
}
.ev-search input {
    flex: 1;
    font-size: .88rem;
}

/* ---- List cards ---- */
.ev-list {
    display: flex;
    flex-direction: column;
    gap: .6rem;
}
.ev-card {
    display: flex;
    align-items: center;
    gap: .65rem;
    padding: .55rem .7rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius, 8px);
    text-decoration: none;
    color: inherit;
    transition: border-color .15s ease;
}
.ev-card:hover { border-color: var(--indigo); }
.ev-card-date {
    flex-shrink: 0;
    width: 42px;
    height: 42px;
    border-radius: 7px;
    background: var(--indigo-soft, var(--paper));
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    line-height: 1.1;
}
.ev-card-date-month {
    font-size: .62rem;
    font-weight: 700;
    letter-spacing: .04em;
    color: var(--indigo);
}
.ev-card-date-day {
    font-size: 1.2rem;
    font-weight: 800;
    color: var(--ink);
}
.ev-card-body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: .15rem;
}
.ev-card-title {
    font-weight: 700;
    font-size: .92rem;
    color: var(--ink);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.ev-card-meta {
    font-size: .76rem;
    display: flex;
    align-items: center;
    gap: .3rem;
    flex-wrap: wrap;
}
.ev-card-meta i { width: 12px; text-align: center; }
.ev-card-rsvp-badge {
    flex-shrink: 0;
    font-size: .68rem;
    font-weight: 700;
    padding: .25rem .55rem;
    border-radius: 20px;
    text-transform: uppercase;
    letter-spacing: .03em;
}
.ev-card-rsvp-going { background: color-mix(in srgb, #16a34a 16%, transparent); color: #15803d; }
.ev-card-rsvp-interested { background: color-mix(in srgb, #d97706 16%, transparent); color: #b45309; }
.ev-card-rsvp-not_going { background: color-mix(in srgb, #6b7280 16%, transparent); color: var(--ink-soft); }

/* ---- Detail page ---- */
.ev-detail { padding: 0; overflow: hidden; }
.ev-detail-cover-wrap { position: relative; }
.ev-detail-cover {
    display: block;
    width: 100%;
    max-height: 220px;
    object-fit: cover;
}

/* Kebab menu — Edit/Delete/Share consolidated into one dropdown, overlaid
   top-right of the cover photo (or top-right of the card if there's no
   cover) rather than sitting as separate buttons in the title row. The
   button itself needs a translucent dark background rather than the
   feed post menu's plain transparent one, since this sits on top of a
   photo of unknown brightness instead of a plain surface background. */
.ev-detail-menu { position: absolute; top: .6rem; right: .6rem; z-index: 10; }
.ev-detail-menu-btn {
    width: 32px; height: 32px; border-radius: 50%; border: none;
    background: rgba(0, 0, 0, .45); color: #fff; font-size: 1rem;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; transition: background .12s ease;
}
.ev-detail-menu-btn:hover, .ev-detail-menu.is-open .ev-detail-menu-btn { background: rgba(0, 0, 0, .65); }
.ev-detail-cover-wrap:not(:has(.ev-detail-cover)) .ev-detail-menu-btn {
    background: var(--paper); color: var(--ink-soft);
}
.ev-detail-cover-wrap:not(:has(.ev-detail-cover)) .ev-detail-menu-btn:hover,
.ev-detail-cover-wrap:not(:has(.ev-detail-cover)) .ev-detail-menu.is-open .ev-detail-menu-btn {
    background: var(--border); color: var(--ink);
}
.ev-detail-menu-dropdown {
    position: absolute; top: calc(100% + 4px); right: 0; z-index: 30;
    min-width: 140px; padding: .35rem;
    background: var(--surface); border: 1px solid var(--border); border-radius: 6px;
    box-shadow: 0 10px 28px -12px rgba(0, 0, 0, .3);
}
.ev-detail-menu-dropdown a, .ev-detail-menu-dropdown button, .ev-detail-menu-dropdown form {
    display: block; width: 100%;
}
.ev-detail-menu-dropdown a, .ev-detail-menu-dropdown button {
    padding: .5rem .6rem; border-radius: 5px; border: none; background: none;
    font-family: inherit; font-size: .84rem; font-weight: 600; text-align: left;
    color: var(--ink); text-decoration: none; cursor: pointer;
}
.ev-detail-menu-dropdown a:hover, .ev-detail-menu-dropdown button:hover { background: var(--paper); }
.ev-detail-menu-danger { color: var(--danger, #d6455a) !important; }
.ev-detail-menu-danger:hover { background: rgba(214, 69, 90, .1) !important; }
.ev-detail-community {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    font-size: .76rem;
    font-weight: 600;
    color: var(--indigo);
    text-decoration: none;
    margin: .75rem .85rem 0;
}
.ev-detail-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: .6rem;
    padding: .4rem .85rem 0;
}
.ev-detail-head h1 {
    font-size: 1.1rem;
    margin: 0;
    line-height: 1.3;
}
.ev-detail-meta {
    display: flex;
    flex-direction: column;
    gap: .5rem;
    padding: .7rem .85rem;
    margin: .6rem .85rem;
    background: var(--paper);
    border-radius: 7px;
}
.ev-detail-meta-row {
    display: flex;
    align-items: flex-start;
    gap: .5rem;
    font-size: .82rem;
}
.ev-detail-meta-row i { color: var(--indigo); width: 15px; text-align: center; margin-top: .2rem; }
.ev-detail-meta-row a { color: var(--indigo); }

.ev-full-note { padding: 0 .85rem; font-size: .78rem; }
.ev-rsvp-row {
    display: flex;
    gap: .4rem;
    padding: 0 .85rem;
    margin-bottom: .6rem;
}
.ev-rsvp-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .35rem;
    padding: .5rem .4rem;
    border: 1px solid var(--border);
    border-radius: 7px;
    background: var(--surface);
    color: var(--ink-soft);
    font-weight: 700;
    font-size: .78rem;
    cursor: pointer;
    transition: all .12s ease;
}
.ev-rsvp-btn:disabled { opacity: .5; cursor: not-allowed; }
.ev-rsvp-btn.ev-rsvp-going { background: #16a34a; border-color: #16a34a; color: #fff; }
.ev-rsvp-btn.ev-rsvp-interested { background: #d97706; border-color: #d97706; color: #fff; }
.ev-rsvp-btn.ev-rsvp-not-going { background: var(--ink-soft); border-color: var(--ink-soft); color: #fff; }

.ev-detail-counts {
    display: flex;
    gap: .85rem;
    padding: 0 .85rem .7rem;
    font-size: .8rem;
    color: var(--ink-soft);
    border-bottom: 1px solid var(--border);
    margin-bottom: .75rem;
}
.ev-detail-counts strong { color: var(--ink); }

/* ---------- BBCode display + editor (shared with blog/forum) -----------
   Event descriptions render through the same BBCode::render() blog/forum
   posts use, and the create/edit forms use the same shared toolbar +
   contenteditable rich editor — copied verbatim from forum-v2.css/
   blog-v2.css so an event looks and edits identically to a post anywhere
   else on the site, not like an unstyled, broken version of one. */
.bbcode-quote {
    border-left: 3px solid var(--indigo); background: var(--paper);
    padding: .6rem .9rem; margin: .75rem 0; border-radius: 0 6px 6px 0;
    font-style: italic; color: var(--ink-soft); white-space: normal;
}
.bbcode-quote cite {
    display: block; font-style: normal; font-weight: 700; font-size: .8rem;
    color: var(--indigo); margin-bottom: .3rem;
}
.bbcode-list { margin: .5rem 0; padding-left: 1.4rem; white-space: normal; }
.bbcode-list li { margin-bottom: .3rem; }
.bbcode-img { max-width: 100%; border-radius: 8px; margin: .5rem 0; display: block; }
.bbcode-table-wrap { overflow-x: auto; margin: .75rem 0; border: 1px solid var(--border); border-radius: 8px; }
.bbcode-table { width: 100%; border-collapse: collapse; font-size: .88rem; white-space: normal; }
.bbcode-table td { padding: .5rem .75rem; border: 1px solid var(--border); }
.bbcode-table tr:first-child td { background: var(--paper); font-weight: 700; }
.bbcode-code {
    margin: .75rem 0; padding: 1rem; border-radius: 8px; white-space: pre;
    background: #1e1e2e !important; overflow-x: auto; font-size: .85rem; line-height: 1.6;
}
.bbcode-code code {
    font-family: ui-monospace, 'Cascadia Code', 'Fira Code', monospace !important;
    background: none !important; white-space: pre !important;
}

.bbcode-help { margin: .5rem 0 1rem; border: 1px solid var(--border); border-radius: 6px; padding: .5rem .75rem; }
.bbcode-help summary { cursor: pointer; font-size: .82rem; font-weight: 700; color: var(--ink-soft); list-style: none; }
.bbcode-help summary::-webkit-details-marker { display: none; }
.bbcode-help[open] summary { margin-bottom: .5rem; }
.bbcode-help-grid { display: grid; gap: .35rem; font-size: .78rem; color: var(--ink-soft); }
.bbcode-help-grid code { background: var(--paper); padding: .1rem .35rem; border-radius: 4px; font-size: .76rem; }

.bbcode-toolbar {
    display: flex; flex-wrap: wrap; align-items: center; gap: .15rem;
    padding: .25rem; border: 1px solid var(--border); border-bottom: none;
    border-radius: 6px 6px 0 0; background: var(--paper);
}
.bbcode-toolbar button {
    width: 24px; height: 24px; display: flex; align-items: center; justify-content: center;
    border: none; background: none; border-radius: 4px; color: var(--ink-soft);
    cursor: pointer; font-size: .74rem; transition: background .12s ease, color .12s ease;
}
.bbcode-toolbar button:hover { background: var(--surface); color: var(--indigo); }
.bbcode-toolbar-sep { width: 1px; height: 15px; background: var(--border); margin: 0 .1rem; }
.bbcode-toolbar-code { display: flex; align-items: center; gap: .15rem; }
.bbcode-lang-select {
    font-size: .68rem; padding: .15rem .25rem; border-radius: 4px; height: 24px;
    border: 1px solid var(--border); background: var(--surface); color: var(--ink-soft);
}

.bbcode-rich-editor {
    min-height: 220px; max-height: 480px; overflow-y: auto;
    padding: .75rem .9rem; border: 1px solid var(--border); border-radius: 0 0 6px 6px;
    background: var(--surface); font-size: .92rem; line-height: 1.6;
}
.bbcode-rich-editor:focus { outline: 2px solid var(--indigo); outline-offset: -1px; }
.bbcode-rich-editor img { max-width: 100%; border-radius: 8px; margin: .35rem 0; display: block; }
.bbcode-upload-placeholder { color: var(--ink-soft); font-style: italic; }
editor-youtube-embed {
    display: block; padding: .5rem .75rem; margin: .5rem 0; border-radius: 6px;
    background: var(--paper); border: 1px dashed var(--border); color: var(--ink-soft); font-size: .85rem;
    user-select: none;
}

.ev-detail-description {
    padding: 0 .85rem;
    font-size: .86rem;
    line-height: 1.55;
    margin-bottom: .75rem;
}

.ev-attendees { padding: 0 .85rem .85rem; }
.ev-attendees h2 { font-size: .88rem; margin: 0 0 .5rem; }
.ev-attendees-grid {
    display: flex;
    flex-wrap: wrap;
    gap: .35rem;
}
.ev-attendee {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    overflow: hidden;
    display: block;
}
.ev-attendee img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ev-attendee-initial {
    width: 100%; height: 100%;
    display: flex; align-items: center; justify-content: center;
    background: var(--indigo-soft, var(--paper));
    color: var(--indigo);
    font-weight: 800;
    font-size: .85rem;
}

/* ---- Forms (create/edit) ---- */
.ev-form { display: flex; flex-direction: column; }

/* Groups related fields with a small uppercase label, rather than one long
   undifferentiated stack of fields — Basics / When & where / Details. */
.ev-form-section {
    padding: .75rem 0;
    border-bottom: 1px solid var(--border);
}
.ev-form-section:first-child { padding-top: 0; }
.ev-form-section:last-of-type { border-bottom: none; padding-bottom: .2rem; }
.ev-form-section-label {
    margin: 0 0 .6rem;
    font-size: .68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .07em;
    color: var(--indigo);
}

.ev-form label { display: block; margin-top: .65rem; font-weight: 600; font-size: .82rem; }
.ev-form-section > label:first-of-type,
.ev-form-section > .ev-form-row:first-child label { margin-top: 0; }

.ev-form input[type="text"],
.ev-form input[type="number"],
.ev-form input[type="datetime-local"],
.ev-form select,
.ev-form textarea {
    display: block;
    width: 100%;
    margin-top: .3rem;
    padding: .5rem .6rem;
    font-size: .86rem;
    font-family: inherit;
    color: var(--ink);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    transition: border-color .12s ease, box-shadow .12s ease;
}
.ev-form input:focus,
.ev-form select:focus,
.ev-form textarea:focus {
    outline: none;
    border-color: var(--indigo);
    box-shadow: 0 0 0 3px var(--indigo-soft, rgba(90, 130, 187, .2));
}

/* The backing <textarea> the rich editor actually submits stays hidden via
   the JS-set `hidden` attribute — but the display:block rule above (needed
   for the *visible* fields) has higher priority than the browser's default
   [hidden] styling, so without this override the hidden textarea shows up
   as a second, empty box above the real editor. */
.ev-form textarea[hidden] {
    display: none;
}

/* On a phone-width screen, the toolbar's dozen-plus icons can't fit in one
   row without shrinking to illegible size — this keeps them at full size
   in a single horizontally-swipeable strip instead of wrapping to a second
   row, matching Forum/Blog's identical touch-theme treatment. */
body.touch-theme .bbcode-toolbar {
    flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
body.touch-theme .bbcode-toolbar::-webkit-scrollbar { display: none; }
body.touch-theme .bbcode-toolbar button,
body.touch-theme .bbcode-toolbar-sep,
body.touch-theme .bbcode-toolbar-code { flex-shrink: 0; }

/* datetime-local's native picker otherwise renders inconsistently across
   dark/light contexts — color-scheme keeps it rendering in a light,
   predictable style consistent with the rest of the form. Deliberately not
   trying to recolor the icon itself via a CSS filter chain here: getting an
   exact hex match that way is unreliable without live browser testing to
   verify against, and a wrong guess would look worse than the plain default. */
.ev-form input[type="datetime-local"] {
    color-scheme: light;
}

.ev-form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: .75rem;
}
.ev-form button[type="submit"] { margin-top: 1.25rem; align-self: flex-start; }

/* ---- Calendar ---- */
.ev-cal-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-bottom: .75rem;
    font-size: .95rem;
}
.ev-cal-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
    background: var(--border);
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
}
.ev-cal-dow {
    background: var(--paper);
    text-align: center;
    font-size: .68rem;
    font-weight: 700;
    color: var(--ink-soft);
    padding: .35rem 0;
    text-transform: uppercase;
}
.ev-cal-cell {
    background: var(--surface);
    min-height: 54px;
    padding: .2rem;
    display: flex;
    flex-direction: column;
    gap: .1rem;
}
.ev-cal-cell.is-empty { background: var(--paper); }
.ev-cal-cell.is-today { background: var(--indigo-soft, var(--paper)); }
.ev-cal-daynum {
    font-size: .72rem;
    font-weight: 700;
    color: var(--ink-soft);
}
.ev-cal-cell.is-today .ev-cal-daynum { color: var(--indigo); }
.ev-cal-event {
    display: block;
    font-size: .62rem;
    line-height: 1.25;
    padding: 1px 3px;
    border-radius: 3px;
    background: var(--indigo-soft, var(--paper));
    color: var(--indigo);
    text-decoration: none;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.ev-cal-more {
    font-size: .6rem;
    color: var(--ink-soft);
    padding: 0 3px;
}

@media (max-width: 560px) {
    .ev-form-row { grid-template-columns: 1fr; }
    .ev-cal-cell { min-height: 42px; padding: .15rem; }
    .ev-cal-event { display: none; }
    .ev-cal-daynum { font-size: .68rem; }
    .ev-cal-cell:has(.ev-cal-event)::after {
        content: '';
        width: 5px; height: 5px; border-radius: 50%;
        background: var(--indigo);
        margin-top: 2px;
    }
}
