/* Calendar (calendar.js): EventCalendar (vendor/event-calendar) dressed in the tokens, so light and dark
   follow tokens.css. Rules: DESIGN.md. Each item wears whose it is (--k, its wash --kw: one person's ink,
   or household green when it's for several); the source is a glyph, never colour alone. */

.view.cal { max-width: 1280px; }
.main:has(.view.cal) { padding-bottom: var(--s4); }
.cal-i { width: 14px; height: 14px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.cal-i.cal-dots { fill: currentColor; stroke: none; }
.cal-sheet .pj-icon .cal-i { width: 18px; height: 18px; }

/* the toolbar: the period as the page title, then Today, ‹ ›, the views, whose, ⋯ */
.cal-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: var(--s2) var(--s4); margin-bottom: var(--s4); }
.cal-title { margin: 0; font-size: var(--step-3); white-space: nowrap; }
.cal-tools { display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; }
.cal-tools .pj-icon .cal-i { width: 18px; height: 18px; }
.cal-today:disabled { opacity: 1; color: var(--ink-3); cursor: default; }
.cal-step { display: inline-flex; }
.cal-views { display: inline-flex; padding: 2px; gap: 2px; background: var(--sunk); border-radius: var(--r-ctl); }
.cal-views button { border: 0; background: none; color: var(--ink-2); font: inherit; font-size: var(--step--1); font-weight: 500; padding: 5px 12px; border-radius: calc(var(--r-ctl) - 2px); cursor: pointer; }
.cal-views button:hover { color: var(--ink); }
.cal-views button[aria-pressed="true"] { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: 0 0 0 1px var(--line); }
.cal-filter { display: inline-flex; align-items: center; gap: 4px; border: 0; background: none; color: var(--ink-2); font: inherit; font-size: var(--step--1); padding: 6px 8px; border-radius: var(--r-chip); cursor: pointer; }
.cal-filter:hover { background: var(--sunk); color: var(--ink); }
.cal-filter .cal-i { width: 14px; height: 14px; }
.cal :focus-visible { outline: 2px solid var(--me); outline-offset: 2px; }

/* EventCalendar on the tokens */
.cal-ec .ec, .ec {
  color-scheme: inherit;
  --ec-color-400: var(--ink-3);
  --ec-color-300: var(--line);
  --ec-color-200: var(--sunk);
  --ec-color-100: var(--paper);
  --ec-color-50: var(--paper);
  --ec-bg-color: var(--surface);
  --ec-text-color: var(--ink);
  --ec-border-color: var(--line);
  --ec-button-bg-color: var(--surface);
  --ec-button-border-color: var(--line);
  --ec-button-text-color: var(--ink);
  --ec-button-active-bg-color: var(--sunk);
  --ec-button-active-border-color: var(--line);
  --ec-button-active-text-color: var(--ink);
  --ec-today-bg-color: var(--surface);
  --ec-highlight-color: var(--me-wash);
  --ec-event-bg-color: var(--sunk);
  --ec-event-text-color: var(--ink);
  --ec-bg-event-color: var(--sunk);
  --ec-event-col-gap: 3px;
  --ec-now-indicator-color: var(--me);
  --ec-popup-bg-color: var(--surface);
  font-size: var(--step--1);
}
.cal-ec .ec { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); overflow: hidden; }
.cal-ec .ec-toolbar { display: none; }
.cal-ec .ec-main { border: 0; }
.cal-ec .ec-header { background: var(--surface); }
.cal-ec .ec-day-head, .cal-ec .ec-col-head { color: var(--ink-2); font-weight: 500; }
.cal-ec .ec-header .ec-today, .cal-ec .ec-today .ec-day-head time { color: var(--me); font-weight: 700; }
.cal-ec .ec-day-grid.ec-month-view .ec-day-head time { font-variant-numeric: tabular-nums; }
.cal-ec .ec-day-grid.ec-month-view .ec-day.ec-today .ec-day-head time { display: inline-grid; place-items: center; min-width: 22px; height: 22px; padding: 0 4px; border-radius: 999px; background: var(--me); color: var(--on-ink, #fff); }
.cal-ec .ec-sidebar, .cal-ec .ec-slot { color: var(--ink-3); font-variant-numeric: tabular-nums; }
.cal-ec .ec-all-day .ec-sidebar { font-size: 11px; }
.cal-ec .ec-other-month { background: var(--paper); }
.cal-ec .ec-popup { border-radius: var(--r-ctl); box-shadow: var(--lift); border-color: var(--line); }
.cal-ec .ec-popup .ec-day-head a { color: var(--ink-3); }
.cal-ec .ec-day-foot a, .cal-ec .ec-more-link { color: var(--ink-2); font-weight: 500; }
.cal-ec .ec-now-indicator:before { width: 9px; height: 9px; margin-block-start: -5.5px; margin-inline-start: -5px; }
.cal-ec .ec-preview, .cal-ec .ec-event.ec-pointer { background: var(--me-wash); color: var(--ink); box-shadow: inset 0 0 0 1px var(--me); }

/* an item: an event is a block in its owner's wash; a to-do is a checkbox and its words */
.ec .cal-item { background: var(--kw); color: var(--ink); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--k) 28%, transparent); border-radius: 6px; padding: 1px 4px; cursor: pointer; }
.ec .cal-item:hover { box-shadow: inset 0 0 0 1px var(--k); }
.ec .cal-item.is-todo { background: transparent; box-shadow: none; }
.ec .cal-item.is-todo:hover { background: var(--sunk); }
.ec-time-grid .ec-body .cal-item.is-todo { background: var(--surface); box-shadow: inset 0 0 0 1px var(--line); }
.cal-ev { display: flex; align-items: flex-start; gap: 4px; min-width: 0; width: 100%; }
.cal-ec .ec-event-body { min-width: 0; }
.cal-ev-body { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.ec-day-grid .cal-ev-body, .ec-all-day .cal-ev-body { flex-direction: row; align-items: baseline; gap: 4px; }
.cal-ev .ec-event-time { color: color-mix(in srgb, var(--k) 80%, var(--ink)); font-weight: 600; font-variant-numeric: tabular-nums; margin: 0; }
.cal-ev .ec-event-title { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; position: static; }
.ec-time-grid .ec-body .cal-item.is-event .ec-event-title { white-space: normal; }
.ec-time-grid .ec-body .cal-ev.is-short .cal-ev-body { flex-direction: row; align-items: baseline; gap: 4px; }
.ec-time-grid .ec-body .cal-ev.is-short .ec-event-title { white-space: nowrap; }
.ec-time-grid .ec-body .cal-ev.is-short .ec-event-time { font-weight: 500; }
.cal-src { flex: none; display: inline-flex; color: var(--ink-3); margin-top: 2px; }
.cal-src .cal-i { width: 11px; height: 11px; stroke-width: 2; }
.cal-late { margin-right: 3px; color: var(--danger); font-weight: 800; }

/* the checkbox: a ring in whose ink; filled and ticked when done */
.cal-check { flex: none; width: 18px; height: 18px; margin: 1px 1px 0 0; padding: 0; display: grid; place-items: center; border: 0; background: none; cursor: pointer; border-radius: 50%; }
.cal-check span { width: 13px; height: 13px; border-radius: 50%; border: 1.6px solid var(--k, var(--ink-3)); display: grid; place-items: center; transition: background .15s; }
.cal-check:hover span { background: var(--kw, var(--sunk)); }
.cal-check:disabled { cursor: default; opacity: .6; }
.cal-check[aria-checked="true"] span { background: var(--k, var(--me)); border-color: var(--k, var(--me)); }
.cal-check[aria-checked="true"] span::after { content: ""; width: 6px; height: 3px; border: 1.6px solid var(--surface); border-top: 0; border-right: 0; transform: translateY(-1px) rotate(-45deg); }
.cal-check.big { width: 28px; height: 28px; margin: 0; }
.cal-check.big span { width: 20px; height: 20px; border-width: 1.8px; }
.cal-check.big[aria-checked="true"] span::after { width: 9px; height: 5px; border-width: 2px; }
.is-overdue .cal-check span { border-color: var(--danger); }

/* done: struck through and dimmed */
.ec .cal-item.is-done { opacity: .55; }
.ec .cal-item.is-done .ec-event-title { text-decoration: line-through; }

/* Agenda (the list view) */
.cal-ec .ec-list .ec-main { grid-template-columns: minmax(0, 1fr); }
.cal-ec .ec-list .ec-day-head { padding: var(--s2) var(--s4); background: var(--paper); color: var(--ink); font-weight: 600; font-size: var(--step--1); }
.cal-ec .ec-list .ec-day-head time:last-child { color: var(--ink-3); font-weight: 500; }
.cal-ec .ec-list .ec-event { background: transparent; box-shadow: none; padding: 7px var(--s4); border-radius: 0; align-items: flex-start; }
.cal-ec .ec-list .ec-event:hover { background: var(--sunk); }
.cal-ec .ec-list .ec-event + .ec-event { border-top: 1px solid var(--line); }
.cal-ec .ec-list .ec-event-tag { background: var(--k) !important; inline-size: 8px; block-size: 8px; border-radius: 50%; margin: 7px var(--s3) 0 0; flex: none; }
.cal-ec .ec-list .ec-event-time { font-size: var(--step--1); color: var(--ink-2); width: 5.75rem; flex: none; font-variant-numeric: tabular-nums; margin: 2px var(--s2) 0 0; font-weight: 500; }
.cal-ec .ec-list .is-overdue .ec-event-time { color: var(--danger); font-weight: 600; }
.cal-ec .ec-list .ec-today .ec-day-head { color: var(--me); }
.cal-ec .ec-list .ec-event-title { font-size: var(--step-0); }
.cal-ec .ec-list .cal-ev .ec-event-title { white-space: normal; }
.cal-ev-sub { font-size: var(--step--1); color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-ev-sub:empty { display: none; }
.cal-ec .ec-list .cal-check { margin-top: 2px; }
.cal-check-slot { flex: none; width: 19px; }
.cal-ec .ec-list .cal-src { margin-top: 4px; }
.cal-ec .ec-list .cal-src .cal-i { width: 13px; height: 13px; }

/* the new-item popover */
.cal-pop { width: 320px; }
.cal-pop input[name="text"] { width: 100%; box-sizing: border-box; font-size: var(--step-0); }
.cal-prev { margin: calc(-1 * var(--s2)) 0 0; font-size: var(--step--1); color: var(--ink-2); min-height: 1.4em; overflow-wrap: anywhere; }
.cal-prev:empty { display: none; }
.cal-prev strong { color: var(--ink); font-weight: 600; }
.cal-seg { display: inline-flex; padding: 2px; gap: 2px; background: var(--sunk); border-radius: var(--r-chip); justify-self: start; }
.cal-seg label { position: relative; cursor: pointer; }
.cal-seg input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.cal-seg span { display: block; padding: 4px 12px; border-radius: 6px; font-size: var(--step--1); color: var(--ink-2); font-weight: 500; }
.cal-seg input:checked + span { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: 0 0 0 1px var(--line); }
.cal-seg input:focus-visible + span { outline: 2px solid var(--me); outline-offset: 1px; }
.cal-seg.wide { display: flex; justify-self: stretch; }
.cal-seg.wide label { flex: 1; text-align: center; }

/* the item sheet (items.js's sheet at the side) */
.cal-sheet .it-head { align-items: center; }
.cal-sheet .it-head .cal-check { --k: var(--me); --kw: var(--me-wash); }
.cal-sheet.is-done .it-head h2, .cal-sheet.is-done .cal-title-in { text-decoration: line-through; color: var(--ink-3); }
.cal-facts { list-style: none; margin: var(--s4) 0 0; padding: 0; display: grid; gap: var(--s3); color: var(--ink-2); }
.cal-facts li { display: flex; align-items: flex-start; gap: var(--s3); line-height: 1.4; overflow-wrap: anywhere; }
.cal-facts .cal-i { width: 16px; height: 16px; margin-top: 1px; color: var(--ink-3); }
.cal-facts li.late, .cal-facts li.late .cal-i { color: var(--danger); }
.cal-facts li.ink { color: var(--k); font-weight: 500; }
.cal-facts li.ink .cal-i { color: var(--k); }
.cal-facts li.shared { color: var(--shared); font-weight: 500; }
.cal-facts li.shared .cal-i { color: var(--shared); }
.cal-edit form { display: grid; gap: 10px; }
.cal-title-in { flex: 1; min-width: 0; resize: none; field-sizing: content; overflow: hidden; font: inherit; font-size: var(--step-2); font-weight: 600; line-height: 1.25; color: var(--ink); border: 0; border-bottom: 1px solid transparent; background: none; padding: 2px 0; border-radius: 0; }
.cal-title-in:hover { border-bottom-color: var(--line); }
.cal-title-in:focus { outline: none; border-bottom-color: var(--me); }
.cal-edit .it-head { padding-right: var(--s7); margin-bottom: var(--s1); }
.cal-allday { display: flex; align-items: center; gap: var(--s2); font-size: var(--step--1); color: var(--ink-2); }
.cal-allday input { accent-color: var(--me); width: 16px; height: 16px; margin: 0; }
.cal-row { display: grid; grid-template-columns: 3.6rem minmax(0, 1fr) 7.2rem; gap: var(--s2); align-items: center; }
.cal-lbl { font-size: var(--step--1); font-weight: 600; color: var(--ink-2); }
.cal-row input[hidden] { display: none; }
.cal-row:has(input[name$="time"][hidden]) { grid-template-columns: 3.6rem minmax(0, 1fr); }
.cal-f { display: grid; gap: 4px; font-size: var(--step--1); font-weight: 600; color: var(--ink-2); }
.cal-edit input:not([type="checkbox"]):not([type="radio"]), .cal-edit select, .cal-edit textarea:not(.cal-title-in) {
  font: inherit; font-size: var(--step-0); font-weight: 400; color: var(--ink); width: 100%; box-sizing: border-box; min-height: 36px;
  padding: 6px 10px; border: 1px solid var(--line); border-radius: var(--r-chip); background: var(--paper); }
.cal-edit input:focus, .cal-edit select:focus, .cal-edit textarea:not(.cal-title-in):focus { outline: 2px solid var(--me); outline-offset: -1px; }
.cal-edit textarea:not(.cal-title-in) { resize: vertical; min-height: 56px; }
.cal-two { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s3); }
.cal-foot { display: flex; justify-content: space-between; gap: var(--s2); padding-top: var(--s2); position: sticky; bottom: 0; background: var(--surface); }

@media (max-width: 820px) {
  .cal-title { font-size: var(--step-2); }
  .cal-head { align-items: flex-start; }
  .cal-ec .ec-list .ec-event { padding-inline: var(--s3); }
  .cal-ec .ec-list .ec-event-time { width: 4.5rem; white-space: normal; }
}
@media (prefers-reduced-motion: reduce) { .cal-check span { transition: none; } }
@media (max-width: 700px) { .ec-time-grid .cal-src, .ec-day-grid .cal-src { display: none; } }

/* Day, Week, Month and Agenda over the whole window, opened from Home (openCalendarOverlay). Under the item
   sheet (45), menus (60) and the toast, so they stay in reach. */
.cal-overlay { position: fixed; inset: 0; z-index: 28; background: var(--paper); padding: var(--s5) var(--s6) var(--s4); overflow: hidden; animation: cal-in .16s ease-out; }
.cal-overlay .view.cal { max-width: none; margin: 0 auto; }
.cal-close { margin-left: var(--s2); }
.cal-close .cal-i { width: 18px; height: 18px; }
@keyframes cal-in { from { opacity: 0; transform: translateY(6px); } }
@media (prefers-reduced-motion: reduce) { .cal-overlay { animation: none; } }
@media (max-width: 820px) { .cal-overlay { padding: var(--s4) var(--s3) var(--s3); } }
