/* ==========================================================================
   Calendar page. Builds on css/site.css (tokens, trunk, limb, blade, board).
   Page-local only: month board, day panel, upcoming blades.
   ========================================================================== */

/* ---------- month board: an ivory board hanging off the trunk ---------- */
.limb--month { padding-top: clamp(48px, 7vw, 100px); padding-bottom: clamp(56px, 8vw, 110px); }
@media (min-width: 761px) { .limb--month .limb-label { top: clamp(48px, 7vw, 100px); } }
.limb > .cal { max-width: 1020px; padding-top: clamp(22px, 3vw, 40px); padding-bottom: clamp(18px, 2.4vw, 32px); }

.cal-head { display: flex; align-items: center; gap: 12px; margin-bottom: clamp(14px, 2vw, 26px); }
.cal-title {
    margin-right: auto;
    font-size: clamp(1.7rem, 3.6vw, 3rem); font-weight: 700; line-height: 1; letter-spacing: -.025em;
    color: var(--forest);
}
.cal-nav { display: flex; gap: 8px; }
.cal-nav-btn {
    display: flex; align-items: center; justify-content: center;
    width: 44px; height: 44px; padding: 0;
    border: 1px solid var(--sage); border-radius: 50%;
    background: none; color: var(--forest); cursor: pointer;
    transition: background .2s, color .2s, border-color .2s;
}
.cal-nav-btn:hover { background: var(--forest); border-color: var(--forest); color: var(--ivory); }
.cal-nav-btn svg { display: block; }

.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 0 4px; }
.cal-dow { padding: 0 0 8px 8px; font-size: .85rem; font-weight: 500; color: var(--forest-light); }
.day {
    position: relative;
    display: flex; flex-direction: column; align-items: flex-start; gap: 4px;
    min-width: 0; min-height: clamp(52px, 7.4vw, 104px); margin: 0; padding: 8px;
    border: 0; border-top: 1px solid var(--clay); border-radius: 0 0 3px 3px;
    background: none; color: var(--bark);
    font-family: inherit; font-size: 1rem; text-align: left;
}
button.day { cursor: pointer; transition: background .2s; }
button.day:hover { background: var(--sand); }
.day-num { display: flex; align-items: center; gap: 6px; font-weight: 600; line-height: 1.2; }
.day--other { color: var(--stone); }
.day--other .day-num { font-weight: 400; }
/* a sage dot marks a day with something on */
.day--has .day-num::after { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--sage); }
/* today: terracotta outline */
.day--today { border-radius: 3px; box-shadow: inset 0 0 0 2px var(--terracotta); }
.day--selected, button.day--selected:hover { background: var(--forest); color: var(--ivory); border-top-color: var(--forest); }
.day--selected.day--has .day-num::after { background: var(--sage-light); }
.day:focus-visible { z-index: 1; }

/* event names inside the cells: wide screens only, the dot carries it everywhere else */
.day-ev, .day-more { display: none; }
@media (min-width: 900px) {
    .day-ev, .day-more {
        display: block; max-width: 100%;
        overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
        font-size: .8rem; line-height: 1.25; color: var(--forest-light);
    }
    .day-ev b { font-weight: 600; color: var(--forest); }
    .day--selected .day-ev, .day--selected .day-more, .day--selected .day-ev b { color: var(--ivory); }
}

/* ---------- day panel: one leaf under the month ---------- */
.day-panel {
    position: relative; z-index: 2;
    width: min(74%, 780px); margin: 14px 0 0 var(--post);
    padding: clamp(18px, 2.4vw, 30px) clamp(40px, 7vw, 100px) clamp(18px, 2.4vw, 30px) calc(var(--pw) + var(--gap));
    border-radius: 0 clamp(40px, 7vw, 100px) 0 0;
    background: var(--forest); color: var(--ivory);
}
.day-panel :focus-visible { outline-color: var(--gold); }
.day-panel-title { margin-bottom: .5em; font-size: clamp(1.05rem, 1.7vw, 1.45rem); font-weight: 500; color: var(--gold); }
.day-panel-none { color: var(--sage-light); }
.day-item {
    display: block; width: 100%; padding: .7em 0;
    border: 0; border-top: 1px solid var(--forest-light);
    background: none; color: inherit; font-family: inherit; text-align: left; cursor: pointer;
}
.day-item-name {
    display: block;
    font-size: clamp(1.25rem, 2.3vw, 1.9rem); font-weight: 700; line-height: 1.1; letter-spacing: -.015em;
    overflow-wrap: anywhere;
    text-decoration: underline transparent 2px; text-underline-offset: 5px; transition: text-decoration-color .2s;
}
.day-item:hover .day-item-name { text-decoration-color: var(--terracotta); }
.day-item-meta { display: block; margin-top: .3em; font-size: .98rem; color: var(--sage-light); overflow-wrap: anywhere; }

/* ---------- upcoming: fingerpost blades, date leading, time and place trailing ---------- */
.up {
    display: grid; grid-template-columns: clamp(3.4em, 6vw, 4.6em) minmax(0, 1fr) minmax(0, auto);
    align-items: center; gap: 0 clamp(14px, 2vw, 30px);
    width: min(78%, 820px); margin-bottom: 12px;
    padding-top: .7em; padding-bottom: .7em; padding-right: 3.8em;
}
.up-date { display: flex; flex-direction: column; line-height: 1; color: var(--gold); }
.up-day { font-size: clamp(1.7rem, 3vw, 2.6rem); font-weight: 700; letter-spacing: -.02em; }
.up-month { margin-top: .25em; font-size: .92rem; font-weight: 500; }
.up-name { font-size: clamp(1.3rem, 2.5vw, 2.1rem); font-weight: 700; letter-spacing: -.015em; overflow-wrap: anywhere; }
.up-meta { max-width: 16em; font-size: .98rem; font-weight: 400; line-height: 1.35; text-align: right; color: var(--sage-light); overflow-wrap: anywhere; }
.up-meta span { display: block; }
.up-time { font-weight: 500; color: var(--ivory); }

/* ---------- tablet: the blades reach further across, so the frond stands clear at the edge ---------- */
@media (min-width: 761px) and (max-width: 1100px) {
    .limb--frond-end .frond--bottom { right: 2vw; width: 14vw; }
}

/* ---------- mobile ---------- */
@media (max-width: 760px) {
    .limb > .cal { margin-right: 10px; padding-left: 14px; padding-right: 12px; border-radius: 0 44px 0 0; }
    .cal-grid { gap: 0 2px; }
    .cal-dow { padding-left: 0; font-size: .74rem; text-align: center; }
    .day { align-items: center; min-height: 48px; padding: 8px 0 6px; }
    .day-num { flex-direction: column; gap: 4px; }
    .day--has .day-num::after { width: 6px; height: 6px; }

    .day-panel { width: auto; margin-right: 14px; padding-right: 40px; }

    .up { grid-template-columns: 3em minmax(0, 1fr); width: calc(100% - 14px); gap: 0 12px; padding-right: 2.6em; }
    .up-meta { grid-column: 2; max-width: none; margin-top: .3em; text-align: left; }
    .up-meta span { display: inline; }
    .up-time::after { content: ' \00b7 '; color: var(--sage-light); }
    .up-time:last-child::after { content: none; }
}

/* ---------- open layout: a bigger month, and the day panel as a light card under it ---------- */
.living--open .limb > .cal { max-width: none; margin-right: var(--edge); padding: clamp(24px, 3vw, 44px) clamp(22px, 3vw, 44px); }
.living--open .day { min-height: clamp(56px, 8.4vw, 128px); padding: 10px; font-size: 1.05rem; }
.living--open .cal-dow { font-size: .95rem; }
@media (min-width: 900px) { .living--open .day-ev, .living--open .day-more { font-size: .86rem; } }

.living--open .day-panel {
    width: auto; margin: 18px var(--edge) 0 var(--col);
    padding: clamp(22px, 2.8vw, 38px) clamp(24px, 3.4vw, 48px);
    border-radius: clamp(40px, 6vw, 90px) 0 clamp(40px, 6vw, 90px) 0;
    background: var(--ivory); color: var(--forest);
    box-shadow: 0 24px 50px -30px rgba(15, 37, 30, .45);
}
.living--open .day-panel :focus-visible { outline-color: var(--terracotta); }
.living--open .day-panel-title { color: var(--forest-light); font-weight: 600; }
.living--open .day-panel-none { color: var(--muted); }
.living--open .day-item { padding: .9em 0; border-top-color: var(--clay); }
.living--open .day-item-meta { color: var(--forest-light); }
@media (max-width: 760px) {
    .living--open .limb > .cal { margin-right: var(--edge); padding: 18px 12px; }
    .living--open .day { min-height: 50px; padding: 8px 0 6px; }
    .living--open .day-panel { margin-right: var(--edge); padding: 20px 22px; }
}

/* beside the photo on mid-size screens the row is narrow: put time and place under the name */
@media (max-width: 1100px) {
    .up { grid-template-columns: 3em minmax(0, 1fr); width: calc(100% - 14px); gap: 0 12px; padding-right: 2.6em; }
    .up-meta { grid-column: 2; max-width: none; margin-top: .3em; text-align: left; }
    .up-meta span { display: inline; }
    .up-time::after { content: ' \00b7 '; color: var(--sage-light); }
    .up-time:last-child::after { content: none; }
}
