/* calendar: page styles. WORKING page: tone and space, no boxes. One live state in the accent: how soon the next event is. */

.cal .page-title { font-size: var(--fs-2); line-height: 1.08; letter-spacing: -.012em; }
.cal-lead { max-width: 46ch; }
.cal-place { display: inline; padding: 0; color: var(--ink); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 4px;
  text-decoration-color: var(--ink-faint); transition: text-decoration-color var(--touch) var(--shutter); }
.cal-place:hover { text-decoration-color: var(--accent); }

/* Red night mode: the live accent comes from the sky and can carry green; here it follows the red ink instead. */
html[data-mode='red'] .cal { --accent: var(--ink); }

/* the next event: big, one sentence, one action */
.cal-next { margin-top: var(--sp-9); max-width: 60rem; min-height: 18rem; }
.cal-next-when { font-size: var(--fs-lead); line-height: 1.3; font-stretch: 112%; color: var(--accent); font-variant-numeric: tabular-nums; }
.cal-next-title { margin-top: var(--sp-3); font-size: var(--fs-1); font-weight: 450; font-stretch: var(--wide); line-height: var(--lh-tight); letter-spacing: -.015em; max-width: 15ch; }
.cal-next-title span { display: inline-block; transform-origin: left center; }
.cal-next-sum { margin-top: var(--sp-5); font-size: var(--fs-lead); line-height: 1.35; max-width: 34ch; }
.cal-next-vis { margin-top: var(--sp-4); color: var(--ink-soft); max-width: 52ch; }
.cal-next-acts { margin-top: var(--sp-6); }
.act svg, .ev-add svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; flex: none; }

/* the list */
.cal-list { margin-top: var(--sp-10); display: grid; grid-template-columns: minmax(0, 15rem) minmax(0, 1fr); column-gap: clamp(32px, 5vw, 96px); align-items: start; }
.cal-filters { grid-row: 1 / span 4; position: sticky; top: calc(var(--bar-h) + var(--sp-5)); display: flex; flex-direction: column; align-items: flex-start; gap: var(--sp-1); }
.cal-chip { min-height: 44px; padding: 0 var(--sp-4); margin-left: calc(-1 * var(--sp-4)); border-radius: 999px; color: var(--ink-soft); text-align: left;
  transition: background var(--touch) var(--shutter), color var(--touch) var(--shutter), transform var(--sheet) var(--hand); }
.cal-chip:hover { color: var(--ink); background: var(--ground-up); }
.cal-chip:active { transform: scale(.96); }
.cal-chip[aria-pressed='true'] { color: var(--ink); background: var(--ground-hi); font-weight: 600; }
.cal-months, .cal-past, .cal-end { grid-column: 2; min-width: 0; }

/* rows out of view skip layout and paint: a page change lays out only what is on screen */
.ev { content-visibility: auto; contain-intrinsic-size: auto 150px; }
.cal-month + .cal-month { margin-top: var(--sp-8); }
.cal-month-title { font-size: var(--fs-3); font-weight: 470; font-stretch: var(--wide); line-height: 1.15; letter-spacing: -.008em; padding-bottom: var(--sp-3); }
.cal-month-title span, .ev-title span { display: inline-block; transform-origin: left center; }

.ev { position: relative; display: grid; grid-template-columns: 7.5rem minmax(0, 1fr) auto; column-gap: var(--sp-5); align-items: start;
  padding: var(--sp-5) var(--sp-4); margin: 0 calc(-1 * var(--sp-4)); border-radius: 18px; transition: background var(--touch) var(--shutter); }
.ev:hover { background: var(--ground-up); }
.ev-date { display: grid; gap: var(--sp-1); font-variant-numeric: tabular-nums; }
.ev-day { font-size: var(--fs-2); font-weight: 440; font-stretch: var(--wide); line-height: .95; letter-spacing: -.02em; }
.ev-wd { color: var(--ink-soft); }
.ev-wd > span { display: block; }
.ev-title { font-size: var(--fs-3); font-weight: 520; font-stretch: 112%; line-height: 1.18; }
.ev-title span { transition: transform var(--sheet) var(--shutter); }
.ev:hover .ev-title span { transform: scaleX(1.035); }
.ev-sum { margin-top: var(--sp-2); max-width: 58ch; }
.ev-vis { margin-top: var(--sp-2); max-width: 58ch; color: var(--ink-soft); }
.ev-wait { display: block; height: 1em; width: min(36ch, 80%); margin-top: .25em; border-radius: 6px; background: var(--ground-up); }
.ev:hover .ev-wait { background: var(--ground-hi); }
.ev-add { display: inline-flex; align-items: center; gap: var(--sp-2); min-height: 44px; min-width: 44px; padding: 0 var(--sp-4); border-radius: 999px; color: var(--ink-soft);
  justify-content: center; transition: background var(--touch) var(--shutter), color var(--touch) var(--shutter), transform var(--sheet) var(--hand); }
.ev-add:hover, .ev-add:focus-visible { background: var(--ground-hi); color: var(--ink); }
.ev-add:active { transform: scale(.94); }

.cal-past { margin-top: var(--sp-8); }
.cal-past-toggle { min-height: 48px; padding: 0 var(--sp-5); border-radius: 999px; background: var(--ground-up); color: var(--ink); transition: background var(--touch) var(--shutter), transform var(--sheet) var(--hand); }
.cal-past-toggle:hover { background: var(--ground-hi); }
.cal-past-toggle:active { transform: scale(.96); }
.cal-past-list:not(:empty) { margin-top: var(--sp-7); }
.cal-past-list .ev { opacity: .78; }

.cal-end { margin-top: var(--sp-9); padding-top: var(--sp-7); }
.cal-end-line { font-size: var(--fs-lead); line-height: 1.32; font-stretch: 112%; max-width: 30ch; }
.cal-end .act { margin-top: var(--sp-5); }
.act:disabled { opacity: .5; cursor: default; }

.cal-empty, .cal-error p { font-size: var(--fs-lead); line-height: 1.32; max-width: 34ch; }
.cal-error .act { margin-top: var(--sp-5); }

/* loading: tone shaped like what comes */
.cal-skel i { display: block; border-radius: 8px; background: var(--ground-up); }
.cal-skel--next i:nth-child(1) { width: 14ch; height: 1.3em; }
.cal-skel--next i:nth-child(2) { width: min(11ch, 70%); height: calc(var(--fs-1) * .95); margin-top: var(--sp-4); font-size: var(--fs-1); }
.cal-skel--next i:nth-child(3) { width: min(34ch, 90%); height: 1.4em; margin-top: var(--sp-5); }
.cal-skel-row { display: grid; grid-template-columns: 7.5rem minmax(0, 1fr); gap: var(--sp-5); padding: var(--sp-5) 0; }
.cal-skel-row i:first-child { height: 2.4em; }
.cal-skel-row i:last-child { height: 4.2em; }

/* filtering redraws the titles: they draw out sideways, like a trail, then rest */
.js .cal-list.is-redrawing .cal-months [data-draw] { animation: draw var(--sheet) var(--shutter) both; animation-delay: calc(min(var(--i, 0), 9) * 28ms); }
.js .cal-list.is-redrawing .cal-month-title [data-draw] { animation-delay: 0ms; }

@media (max-width: 1023px) {
  .cal-list { grid-template-columns: minmax(0, 1fr); }
  .cal-filters { grid-row: auto; position: static; flex-direction: row; flex-wrap: wrap; gap: var(--sp-2); margin-bottom: var(--sp-7); }
  .cal-chip { margin-left: 0; background: var(--ground-up); }
  .cal-chip[aria-pressed='true'] { background: var(--ground-hi); box-shadow: inset 0 0 0 2px var(--ground-hi); }
  .cal-months, .cal-past, .cal-end { grid-column: 1; }
}
@media (max-width: 640px) {
  .cal-next { margin-top: var(--sp-8); min-height: 0; }
  .cal-list { margin-top: var(--sp-9); }
  .ev { grid-template-columns: 3.6rem minmax(0, 1fr) auto; column-gap: var(--sp-3); padding: var(--sp-4) var(--sp-3); margin: 0 calc(-1 * var(--sp-3)); }
  .ev-day { font-size: 34px; }
  .ev-wd { font-size: 15px; }
  .ev-add { padding: 0; width: 44px; }
  .ev-add-word { display: none; }
  .cal-skel-row { grid-template-columns: 3.6rem minmax(0, 1fr); }
  .cal-filters { flex-wrap: nowrap; overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: none; margin-inline: calc(-1 * var(--edge)); padding-inline: var(--edge); }
  .cal-filters::-webkit-scrollbar { display: none; }
  .cal-chip { flex: none; }
  .cal-end .act { width: 100%; }
}
@media (hover: none) { .ev:hover { background: none; } .ev:hover .ev-title span { transform: none; } }

/* without scripts the prebuilt list stands alone: no skeleton waiting for the next event, no button that cannot work */
html:not(.js) .cal-next, html:not(.js) .cal-end { display: none; }
