/* ScoutCal – Frontend
   Scoped under .pfk to avoid clashing with theme styles. Mobile-first. */

.pfk {
    --pfk-color: #1a6e3c;
    --pfk-radius: 14px;
    --pfk-gap: 14px;
    --pfk-border: #e6e8eb;
    --pfk-ink: #1f2429;
    --pfk-muted: #6b7280;
    --pfk-bg: #ffffff;
    --pfk-accent: #9D2632;
    --pfk-shadow: 0 1px 3px rgba(16, 24, 40, .08), 0 1px 2px rgba(16, 24, 40, .06);
    color: var(--pfk-ink);
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    line-height: 1.45;
    box-sizing: border-box;
}
.pfk *, .pfk *::before, .pfk *::after { box-sizing: inherit; }

.pfk a { color: var(--pfk-color); text-decoration: none; }
.pfk a:hover { text-decoration: underline; }

.pfk-empty {
    padding: 18px;
    border: 1px dashed var(--pfk-border);
    border-radius: var(--pfk-radius);
    color: var(--pfk-muted);
    text-align: center;
}

/* ------------------------------------------------------------------ Events list */

.pfk-events-title { margin: 0 0 12px; font-size: 1.3rem; }

.pfk-event-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: var(--pfk-gap);
}

.pfk-event {
    --pfk-color: #1a6e3c;
    position: relative;
    display: grid;
    grid-template-columns: 58px 1fr auto;
    gap: 14px;
    align-items: start;
    padding: 14px 16px;
    background: var(--pfk-bg);
    border: 1px solid var(--pfk-border);
    border-left: 5px solid var(--pfk-color);
    border-radius: var(--pfk-radius);
    box-shadow: var(--pfk-shadow);
    transition: transform .12s ease, box-shadow .12s ease;
}
.pfk-event:hover { transform: translateY(-1px); box-shadow: 0 6px 18px rgba(16,24,40,.10); }
/* Lift the card whose add-to-calendar dropdown is open above following cards. */
.pfk-event:has(.pfk-add[open]) { z-index: 30; }

.pfk-event-date {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 8px 4px;
    border-radius: 10px;
    background: #eef3f0;
    background: color-mix(in srgb, var(--pfk-color) 12%, white);
    color: var(--pfk-color);
    line-height: 1;
}
.pfk-event-day { font-size: 1.5rem; font-weight: 700; }
.pfk-event-mon { font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; margin-top: 2px; }

.pfk-event-body { min-width: 0; }
.pfk-event-cal {
    display: inline-block;
    font-size: .68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .03em;
    color: #fff;
    padding: 2px 8px;
    border-radius: 999px;
    margin-bottom: 6px;
}
.pfk-event-name { margin: 0 0 4px; font-size: 1.05rem; font-weight: 600; }
.pfk-event-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 14px;
    color: var(--pfk-muted);
    font-size: .85rem;
}
.pfk-event-loc { display: inline-flex; align-items: center; gap: 4px; }
.pfk-event-loc svg { flex: none; }
.pfk-event-desc { margin: 8px 0 0; color: #4b5563; font-size: .9rem; }

/* Add-to-calendar dropdown (native <details>) */
.pfk-add { position: relative; justify-self: end; }
.pfk-add > summary {
    list-style: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 10px;
    border: 1px solid var(--pfk-border);
    border-radius: 10px;
    background: #f8fafc;
    color: var(--pfk-ink);
    font-size: .82rem;
    white-space: nowrap;
}
.pfk-add > summary::-webkit-details-marker { display: none; }
.pfk-add > summary:hover { background: #eef2f6; }
.pfk-add-menu {
    position: absolute;
    right: 0;
    top: calc(100% + 6px);
    z-index: 20;
    min-width: 200px;
    background: #fff;
    border: 1px solid var(--pfk-border);
    border-radius: 12px;
    box-shadow: 0 12px 30px rgba(16,24,40,.16);
    padding: 6px;
    display: flex;
    flex-direction: column;
}
.pfk-add-menu a {
    padding: 9px 10px;
    border-radius: 8px;
    color: var(--pfk-ink);
    font-size: .88rem;
}
.pfk-add-menu a:hover { background: #f1f5f9; text-decoration: none; }

/* Subscribe dropdown */
.pfk-subscribe { margin: 0 0 16px; }
.pfk-subscribe > summary {
    list-style: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 14px;
    border: 1px solid var(--pfk-border);
    border-radius: 999px;
    background: #f8fafc;
    font-weight: 600;
    font-size: .9rem;
}
.pfk-subscribe > summary::-webkit-details-marker { display: none; }
.pfk-subscribe-list { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.pfk-subscribe-list li {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 12px; border: 1px solid var(--pfk-border); border-radius: 10px;
}
.pfk-sub-name { flex: 1; font-weight: 500; }
.pfk-dot { width: 12px; height: 12px; border-radius: 50%; flex: none; }
.pfk .pfk-sub-link {
    font-size: .85rem;
    font-weight: 600;
    color: #9D2632;
    border-bottom: 0.5px dotted #9D2632;
    text-decoration: none;
}
.pfk .pfk-sub-link:hover { text-decoration: underline; color: #9D2632; }
.pfk-sub-secondary { color: #9D2632; }

@media (max-width: 480px) {
    .pfk-event { grid-template-columns: 48px 1fr; }
    .pfk-add { grid-column: 1 / -1; justify-self: start; margin-top: 4px; }
    .pfk-add-menu { left: 0; right: auto; }
}

/* ------------------------------------------------------------------ Calendar */

.pfk-calendar-wrap { background: transparent; }
.pfk-cal-loading { padding: 40px; text-align: center; color: var(--pfk-muted); }

.pfk-cal-header {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}
.pfk-cal-title { font-size: 1.25rem; font-weight: 700; margin: 0; flex: 1; min-width: 160px; text-align: center; }
/* View switcher group: pinned to the start of the header so it never shifts. */
.pfk-cal-views { display: inline-flex; gap: 6px; align-items: center; flex: none; }
.pfk-cal-btn {
    cursor: pointer;
    border: 1px solid var(--pfk-border);
    background: #fff;
    color: var(--pfk-ink);
    border-radius: 9px;
    padding: 7px 12px;
    font-size: .85rem;
    font-weight: 600;
    line-height: 1;
}
.pfk-cal-btn:hover { background: #f1f5f9; }
.pfk-cal-btn[aria-pressed="true"] { background: var(--pfk-accent); color: #fff; border-color: var(--pfk-accent); }
.pfk-cal-nav { display: inline-flex; }
.pfk-cal-nav .pfk-cal-btn { padding: 7px 11px; }

/* Subscribe sits below the main calendar view as a compact icon button whose
   list opens as a popover. Desktop: the popover is only as wide as its content
   and each calendar stays on a single line. Mobile: full width. */
.pfk-cal-sub { position: relative; display: inline-block; margin: 16px 0 0; }
.pfk-cal-sub .pfk-subscribe-list {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    z-index: 20;
    width: max-content;
    max-width: min(92vw, 360px);
    margin: 0;
    padding: 6px;
    gap: 2px;
    background: #fff;
    border: 1px solid var(--pfk-border);
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(15, 23, 42, .12);
}
/* Borderless single-line rows with a subtle hover (no stacked boxes). */
.pfk-cal-sub .pfk-subscribe-list li {
    border: 0;
    border-radius: 8px;
    padding: 7px 10px;
    gap: 12px;
}
.pfk-cal-sub .pfk-subscribe-list li:hover { background: #f3f4f6; }
.pfk-cal-sub .pfk-sub-name {
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.pfk-cal-sub .pfk-sub-link { flex: none; white-space: nowrap; }
.pfk-sub-ico { flex: none; }
.pfk-sub-chev { display: inline-flex; margin-left: 2px; transition: transform .15s ease; }
.pfk-subscribe[open] > summary .pfk-sub-chev { transform: rotate(180deg); }

/* Mobile: the popover spans the full width of the calendar container. */
@media (max-width: 600px) {
    .pfk-cal-sub { display: block; }
    .pfk-cal-sub .pfk-subscribe-list {
        left: 0;
        right: 0;
        width: auto;
        max-width: none;
    }
}

/* Agenda: calendar + "recurring" tags share one aligned row */
.pfk-event-tags {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 6px;
}
.pfk-event-tags .pfk-event-cal,
.pfk-event-tags .pfk-tag-recurring { margin: 0; }
.pfk-tag-recurring {
    display: inline-flex;
    align-items: center;
    font-size: .64rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--pfk-color);
    background: #eef3f0;
    background: color-mix(in srgb, var(--pfk-color) 14%, white);
    border: 1px solid var(--pfk-border);
    padding: 2px 8px;
    border-radius: 999px;
    line-height: 1.4;
}
.pfk-agenda-more {
    margin-top: 6px;
    font-size: .82rem;
    color: var(--pfk-muted);
}

.pfk-cal-grid { background: var(--pfk-bg); border: 1px solid var(--pfk-border); border-radius: var(--pfk-radius); overflow: hidden; }

.pfk-cal-weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    background: #f8fafc;
    border-bottom: 1px solid var(--pfk-border);
}
.pfk-cal-weekdays span {
    padding: 8px 6px;
    text-align: center;
    font-size: .72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .03em;
    color: var(--pfk-ink);
}

.pfk-cal-week { display: grid; grid-template-columns: repeat(7, 1fr); }
.pfk-cal-week:not(:last-child) { border-bottom: 1px solid var(--pfk-border); }

.pfk-cal-day {
    position: relative;
    min-height: 92px;
    padding: 6px 6px 8px;
    border-right: 1px solid var(--pfk-border);
    cursor: pointer;
    overflow: hidden;
}
.pfk-cal-day:last-child { border-right: 0; }
.pfk-cal-day:hover { background: #f9fafb; }
.pfk-cal-day.pfk-cal-other { background: #fbfcfd; color: #b6bcc4; }
.pfk-cal-day.pfk-cal-selected { background: #eef3f0; background: color-mix(in srgb, var(--pfk-color) 9%, white); }
.pfk-cal-daynum { font-size: .82rem; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; width: 26px; height: 26px; border-radius: 50%; }
.pfk-cal-today .pfk-cal-daynum { background: var(--pfk-color); color: #fff; }

.pfk-cal-events { margin-top: 4px; display: flex; flex-direction: column; gap: 3px; }
.pfk-cal-chip {
    --c: var(--pfk-color);
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: .74rem;
    line-height: 1.25;
    padding: 2px 6px;
    border-radius: 6px;
    background: #eef2f6;
    background: color-mix(in srgb, var(--c) 15%, white);
    color: #1f2937;
    border-left: 3px solid var(--c);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.pfk-cal-chip .pfk-chip-time { font-weight: 700; color: var(--c); }
.pfk-cal-more { font-size: .72rem; color: var(--pfk-muted); padding: 1px 6px; font-weight: 600; }

/* Week view */
.pfk-cal-weekgrid { display: grid; grid-template-columns: repeat(7, 1fr); background: var(--pfk-bg); border: 1px solid var(--pfk-border); border-radius: var(--pfk-radius); overflow: hidden; }
.pfk-cal-col { border-right: 1px solid var(--pfk-border); min-height: 220px; }
.pfk-cal-col:last-child { border-right: 0; }
.pfk-cal-colhead {
    padding: 8px 6px; text-align: center; border-bottom: 1px solid var(--pfk-border);
    background: #f8fafc; font-size: .8rem; cursor: pointer;
}
.pfk-cal-colhead .pfk-col-dow { display: block; font-size: .68rem; text-transform: uppercase; color: var(--pfk-ink); font-weight: 700; }
.pfk-cal-colhead .pfk-col-num { font-weight: 700; }
.pfk-cal-colhead.pfk-cal-today .pfk-col-num { color: var(--pfk-color); }
.pfk-cal-colbody { padding: 6px; display: flex; flex-direction: column; gap: 4px; }

/* Day detail panel */
.pfk-cal-detail {
    margin-top: 16px;
    border: 1px solid var(--pfk-border);
    border-radius: var(--pfk-radius);
    padding: 14px 16px;
}
.pfk-detail-date { margin: 0 0 10px; font-size: 1.05rem; font-weight: 700; }
.pfk-detail-list { display: flex; flex-direction: column; gap: 10px; }
.pfk-detail-event {
    padding: 14px 16px;
    background: var(--pfk-bg);
    border: 1px solid var(--pfk-border);
    border-left: 5px solid var(--pfk-color);
    border-radius: var(--pfk-radius);
    box-shadow: var(--pfk-shadow);
}
.pfk-detail-event .pfk-d-title { font-weight: 600; }
.pfk-detail-event .pfk-d-meta { font-size: .85rem; color: var(--pfk-muted); margin-top: 2px; }
.pfk-detail-event .pfk-d-desc { font-size: .88rem; color: #4b5563; margin-top: 6px; white-space: pre-line; }
.pfk-detail-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.pfk-detail-actions a {
    font-size: .8rem; font-weight: 600;
    padding: 6px 10px; border: 1px solid var(--pfk-border); border-radius: 8px;
    color: var(--pfk-ink);
}
.pfk-detail-actions a:hover { background: #f1f5f9; text-decoration: none; }
.pfk-detail-empty { color: var(--pfk-muted); }

/* Legend */
.pfk-legend { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 14px; }
.pfk-legend-item { display: inline-flex; align-items: center; gap: 6px; font-size: .82rem; color: var(--pfk-muted); }
/* When there is more than one calendar the legend doubles as a filter. */
.pfk-legend-filter { gap: 8px; }
.pfk-legend-filter .pfk-legend-item {
    cursor: pointer;
    border: 1px solid var(--pfk-border);
    background: #fff;
    color: var(--pfk-ink);
    border-radius: 999px;
    padding: 4px 11px;
    margin: 0;
    font: inherit;
    font-size: .82rem;
    line-height: 1.25;
    transition: opacity .12s ease, background .12s ease;
}
.pfk-legend-filter .pfk-legend-item:hover { background: #f1f5f9; }
.pfk-legend-filter .pfk-legend-item.is-off { opacity: .45; }

/* Mobile: month grid becomes dot-based */
@media (max-width: 600px) {
    .pfk-cal-day { min-height: 56px; padding: 4px; }
    .pfk-cal-daynum { width: 22px; height: 22px; font-size: .76rem; }
    .pfk-cal-chip { display: none; }
    .pfk-cal-dots { display: flex; gap: 3px; flex-wrap: wrap; margin-top: 3px; }
    .pfk-cal-dot { width: 7px; height: 7px; border-radius: 50%; }
    .pfk-cal-more { display: none; }
    .pfk-cal-weekgrid { grid-template-columns: 1fr; }
    .pfk-cal-col { border-right: 0; border-bottom: 1px solid var(--pfk-border); min-height: 0; }
    .pfk-cal-colhead { text-align: left; display: flex; gap: 8px; align-items: baseline; }
}
@media (min-width: 601px) {
    .pfk-cal-dots { display: none; }
}

/* Disclaimer */
.pfk-disclaimer {
    margin: 8px 0 0;
    text-align: right;
    font-size: .72rem;
    color: var(--pfk-muted);
    font-style: italic;
}

/* Location links */
.pfk-event-loc a,
.pfk-loc-link {
    color: inherit;
    text-decoration: none;
}
.pfk-event-loc a:hover,
.pfk-loc-link:hover {
    text-decoration: underline;
}
