/* The Calendar (web/lib/ui/calendar.js): a plain table. Month is Mon–Sun rows of weeks, Week is seven
   columns, and the picked day sits in a panel beside the table (below it on narrower screens).
   On a phone the month is a compact grid with dots and Week is a list of the seven days.
   Soft Focus tokens come from app.css; everything is scoped under .la like the rest of the app.
   No transitions or animations here on purpose. */

/* ---- head: title, ‹ Today ›, Month | Week ---- */
.la .cal-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .7rem 1.2rem; min-width: 0; padding-top: .5rem; }
.la .cal-title { margin: 0; min-width: 0; font: var(--display-w) 1.65rem/1.1 var(--f-display); letter-spacing: var(--display-track); color: var(--display-ink); }
.la .cal-ctl { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem 1rem; }
.la .cal-nav { display: flex; gap: .3rem; }
.la .cal-nav .btn { background: var(--card); }
.la .cal-head .seg button { background: var(--card); }
.la .cal-head .seg button[aria-pressed="true"] { background: var(--accent); }

/* ---- layout: table + day panel ---- */
.la .cal-wrap { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1rem; align-items: start; min-width: 0; }
@media (min-width: 1100px) { .la .cal-wrap:not(.phone) { grid-template-columns: minmax(0, 1fr) minmax(17rem, 22rem); } }

/* ---- the table ---- */
.la .cal-frame.card { padding: 0; overflow: hidden; border-radius: 14px; }
.la .cal-table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.la .cal-table th {
  padding: .55rem .6rem; text-align: left; font: 600 .78rem/1 var(--f-body); color: var(--ink-2);
  border-bottom: 1px solid var(--line); background: var(--card-2);
}
.la .cal-table td { vertical-align: top; padding: .3rem .35rem .4rem; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); cursor: pointer; min-width: 0; }
.la .cal-table th + th { border-left: 1px solid var(--line); }
.la .cal-table td:last-child { border-right: 0; }
.la .cal-table tbody tr:last-child td { border-bottom: 0; }
.la .cal-table td:hover { background: color-mix(in srgb, var(--card-2) 60%, var(--card)); }
.la .cal-table td.out { background: color-mix(in srgb, var(--card-2) 55%, var(--card)); }
.la .cal-table td.sel, .la .cal-table th.sel { background: color-mix(in srgb, var(--accent) 8%, var(--card)); }

/* the date number (a button: it picks the day) */
.la .cal-dn {
  display: inline-grid; place-items: center; min-width: 1.75rem; height: 1.75rem; padding: 0 .3rem; border: 0; border-radius: 999px;
  background: none; color: var(--ink); font: 600 .85rem/1 var(--f-body); font-variant-numeric: tabular-nums; cursor: pointer;
}
.la td.out .cal-dn { color: var(--ink-3); font-weight: 500; }
.la .today .cal-dn, .la td.today .cal-dn { background: var(--accent); color: var(--accent-ink); }

/* Month (wide): rows share the screen's height, a few entries per day */
.la .cal-month td { height: max(5.8rem, calc((100dvh - var(--top-h, 3.6rem) - 10.5rem) / var(--weeks, 5))); }
.la .cal-es { display: flex; flex-direction: column; gap: 2px; margin-top: .15rem; min-width: 0; }

/* an entry */
.la .cal-e {
  display: flex; align-items: center; gap: .35rem; width: 100%; min-width: 0; padding: .16rem .4rem; border: 0; border-radius: 5px;
  background: none; color: var(--ink); font: 500 .8rem/1.3 var(--f-body); text-align: left; cursor: pointer;
}
.la .cal-e .t { flex: 1 1 auto; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.la .cal-e .tm { flex: none; font: 500 .72rem/1 var(--f-mono); opacity: .75; font-variant-numeric: tabular-nums; }
.la .cal-e.event { background: hsl(var(--h, 200) var(--tint-s) var(--tint-l)); color: hsl(var(--h, 200) var(--tone-s) var(--tone-l)); }
.la .cal-e.event.plain { background: var(--card-2); color: var(--ink); }
.la .cal-e.action .mk {
  flex: none; width: .72rem; height: .72rem; border-radius: 50%; border: 1.5px solid hsl(var(--h, 200) 55% var(--dot-l));
  display: grid; place-items: center; font-size: .5rem; line-height: 1; color: hsl(var(--h, 200) 55% var(--dot-l));
}
.la .cal-e.action.plain .mk { border-color: var(--ink-2); color: var(--ink-2); }
.la .cal-e.action .mk.st { border: 0; width: auto; height: auto; font-size: .78rem; }
.la .cal-e:hover { box-shadow: inset 0 0 0 1px currentColor; }
.la .cal-e.action:hover { box-shadow: none; background: var(--card-2); }
.la .cal-e[data-done] .t { text-decoration: line-through; color: var(--ink-2); }
.la .cal-more { align-self: flex-start; border: 0; background: none; color: var(--ink-2); font: 600 .76rem/1 var(--f-body); padding: .2rem .4rem; cursor: pointer; border-radius: 5px; }
.la .cal-more:hover { color: var(--ink); background: var(--card-2); }

/* Week (wide): seven columns, each day's things listed in full */
.la .cal-week th { padding: 0; }
.la .cal-wd { display: flex; align-items: center; gap: .45rem; width: 100%; padding: .5rem .6rem; border: 0; background: none; color: var(--ink-2); font: 600 .8rem/1 var(--f-body); cursor: pointer; text-align: left; }
.la .cal-wd .cal-dn { cursor: inherit; }
.la .cal-week td { height: max(22rem, calc(100dvh - var(--top-h, 3.6rem) - 13rem)); padding: .45rem .4rem; }
.la .cal-week .cal-es { gap: .3rem; margin: 0; }
.la .cal-week .cal-e { align-items: flex-start; padding: .3rem .45rem; }
.la .cal-week .cal-e .t { white-space: normal; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; }
.la .cal-week .cal-e .tm { padding-top: .2rem; }
.la .cal-week .cal-e.action .mk { margin-top: .22rem; }

/* Month (phone): a compact grid with dots */
.la .cal-month.small th { padding: .5rem 0; text-align: center; }
.la .cal-month.small th + th { border-left: 0; }
.la .cal-month.small td { height: 3.3rem; padding: .25rem 0 .2rem; text-align: center; border-right: 0; }
.la .cal-month.small td.sel .cal-dn { box-shadow: 0 0 0 2px var(--accent); }
.la .cal-month.small td.sel, .la .cal-month.small td.out { background: none; }
.la .cal-month.small td:hover { background: none; }
.la .cal-dots { display: flex; gap: 3px; justify-content: center; margin-top: .2rem; height: .4rem; }

/* dots: an event is a filled dot in its area's colour, an action a ring */
.la .cal-dot { flex: none; display: inline-block; width: .42rem; height: .42rem; border-radius: 50%; background: hsl(var(--h, 200) 62% var(--dot-l)); }
.la .cal-dot.plain { background: var(--ink-2); }
.la .cal-dot.action { background: none; border: 1.5px solid hsl(var(--h, 200) 55% var(--dot-l)); }
.la .cal-dot.action.plain { border-color: var(--ink-2); }

/* ---- the picked day ---- */
.la .cal-panel.card { display: flex; flex-direction: column; gap: .6rem; border-radius: 14px; padding: 1rem 1.1rem 1.1rem; min-width: 0; }
.la .cal-ph { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.la .cal-pt { margin: 0; font: var(--title-w) var(--title-size)/1.2 var(--f-title); letter-spacing: var(--title-track); }
.la .cal-rows { display: flex; flex-direction: column; min-width: 0; }
.la .cal-row { display: grid; grid-template-columns: 3.8rem .6rem minmax(0, 1fr); align-items: start; gap: .55rem; padding: .45rem 0; border-bottom: 1px solid var(--line); }
.la .cal-row:last-child { border-bottom: 0; }
.la .cal-row .cal-dot { width: .6rem; height: .6rem; margin-top: .42rem; }
.la .cal-row .cal-when { padding-top: .22rem; }
.la .cal-when { font: 500 .78rem/1.2 var(--f-mono); color: var(--ink-2); font-variant-numeric: tabular-nums; white-space: nowrap; }
.la .cal-rmain { display: flex; flex-direction: column; min-width: 0; }
.la .cal-rt { border: 0; background: none; padding: 0; text-align: left; font: 400 1rem/1.35 var(--f-body); color: var(--ink); cursor: pointer; overflow-wrap: anywhere; }
.la .cal-rt:hover { text-decoration: underline; }
.la .cal-rt[data-done] { text-decoration: line-through; color: var(--ink-2); }
.la .cal-rmain .path { font-size: calc(var(--label-size) * .88); padding: .15rem 0 0; }
.la .cal-none { color: var(--ink-2); margin: 0; padding: .2rem 0; }

/* add an event */
.la .cal-add { display: flex; flex-direction: column; gap: .5rem; padding-top: .3rem; }
.la .cal-add .edit.box { width: 100%; }
.la .cal-add-row { display: flex; gap: .5rem; align-items: center; }
.la .cal-add-row .cal-time { flex: 1 1 auto; width: auto; max-width: 11rem; min-height: 2.3rem; }
.la .cal-add-row .btn { flex: none; min-width: 4.5rem; margin-left: auto; }
.la .cal-tag { padding: .25rem .55rem; border-radius: 999px; background: var(--mark); color: var(--mark-ink); font: 600 .74rem/1 var(--f-body); white-space: nowrap; }

/* Week (phone): the seven days as a list */
.la .cal-wlist { display: flex; flex-direction: column; gap: .6rem; }
.la .cal-lday.card { padding: 0; border-radius: 14px; overflow: hidden; }
.la .cal-lh {
  display: flex; align-items: center; gap: .55rem; width: 100%; min-height: 3rem; padding: .7rem 1rem; border: 0; background: none;
  color: var(--ink); font: 600 1rem/1.2 var(--f-body); text-align: left; cursor: pointer;
}
.la .cal-lday.sel .cal-lh { background: color-mix(in srgb, var(--accent) 8%, var(--card)); }
.la .cal-lday.today .cal-lt { color: var(--accent); }
.la .cal-lc { margin-left: auto; min-width: 1.5rem; padding: .2rem .45rem; border-radius: 999px; background: var(--card-2); color: var(--ink-2); font: 600 .78rem/1 var(--f-body); text-align: center; }
.la .cal-lday .cal-rows { padding: 0 1rem; border-top: 1px solid var(--line); }
.la .cal-lday .cal-add { padding: .6rem 1rem 1rem; border-top: 1px solid var(--line); }

@media (max-width: 720px) {
  .la .cal-head { gap: .6rem; }
  .la .cal-title { flex-basis: 100%; font-size: 1.4rem; }
  .la .cal-ctl { flex: 1 1 auto; justify-content: space-between; }
  .la .cal-frame.card { border-radius: 12px; }
}
