/* © 2026 MEK.txt. All rights reserved. Part of the MEK design system; not licensed for reuse. */
/* MEK design system · part: calendar
   A month as a grid of days, each a link (a day's page, a date to pick). Always six rows, so the box keeps one height
   every month. Weeks start on Sunday unless told otherwise (data-week-start). Under each number a mark row, always
   there whether a day has a mark or not: data-mark="dot" (a 4×4 square: something on that day) or "cross" (a 5×5 cross
   at 2×: a second, stronger mark; what each means is the page's). Today is a quiet box (aria-current="date"); the chosen day (aria-selected on its cell) is the
   view's one accent, the pages' rule under its number. Hover is the box's dissolve, a lift. js/calendar.js draws it,
   names the days and months in the page's language (Intl) and moves through it by keys.
   Opt-in: link it after mek.css, with js/calendar.js:
     <h2 id="cal-title"></h2>
     <table class="calendar" role="grid" id="cal" aria-labelledby="cal-title" data-calendar data-selected="2026-11-11"
       data-title="cal-title"></table>
     <nav class="pages" aria-label="Months"><button class="link pages-prev" type="button" data-calendar-prev="cal"></button>
       <span class="spacer"></span><button class="link pages-next" type="button" data-calendar-next="cal"></button></nav>
   Needs the core box, link and pagination (for its prev and next). In the mek.parts layer, so a project's CSS wins. */

@layer mek.parts {

/* ---------- Dials ---------- */
.calendar {
  --calendar-cell: 40px;                 /* a day: square, on the 4px grid */
  --calendar-gap: var(--space-1);        /* between days: 7 cells and 6 gaps, 304px */
  --calendar-mark: 10px;                 /* the mark row under each number, always kept; a cross fills it */
  --calendar-dot-size: 4px;              /* a dot: a 4×4 square */
  --calendar-head: 24px;                 /* the weekdays' line */
  --calendar-dot: var(--text-muted);     /* a dot's colour */
  --calendar-cross: var(--text-strong);  /* a cross's, and its day's number */
  --calendar-today: var(--line);         /* today's quiet box */
  --calendar-on: var(--text-muted);      /* the chosen day's edge */
  --calendar-rule: var(--pages-on);      /* the chosen day's rule: the view's accent */
  --calendar-cross-shape: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 5 5' shape-rendering='crispEdges'%3E%3Cpath d='M2 0h1v5h-1zM0 2h5v1h-5z'/%3E%3C/svg%3E");   /* 5×5, drawn at 2× */
  border-collapse: separate; border-spacing: var(--calendar-gap); margin: calc(-1 * var(--calendar-gap));
}

.calendar th, .calendar td { padding: 0; width: var(--calendar-cell); }
.calendar td { height: var(--calendar-cell); }   /* an empty row keeps its height: six rows every month */
.calendar th { font: var(--text-sm)/var(--calendar-head) var(--font-mono); font-weight: normal; color: var(--text-muted); text-align: center; }
.calendar caption { text-align: start; padding-bottom: var(--space-2); }

/* A day: a box with no line at rest (the ground's), lifted on hover; its number over its mark row. */
.calendar-day { --edge: var(--bg); --edge-to: var(--lift-edge); --fill-to: var(--lift-fill);
  display: grid; grid-template-rows: 1fr var(--calendar-mark); justify-items: center; align-items: end; box-sizing: border-box;
  width: var(--calendar-cell); height: var(--calendar-cell); padding-block: var(--space-1);
  font: var(--text-sm)/1 var(--font-mono); text-align: center; }
.calendar-n { text-decoration: underline var(--stroke) transparent; text-underline-offset: 3px; }
.calendar-mark { width: var(--calendar-mark); height: var(--calendar-mark); display: grid; place-items: center; }
.calendar-day[data-mark="dot"] .calendar-mark::before { content: ""; width: var(--calendar-dot-size); height: var(--calendar-dot-size); background: var(--calendar-dot); }
.calendar-day[data-mark="cross"] { --ink: var(--calendar-cross); }
.calendar-day[data-mark="cross"] .calendar-mark::before { content: ""; width: var(--calendar-mark); height: var(--calendar-mark); background: var(--calendar-cross);
  -webkit-mask: var(--calendar-cross-shape) 0 0 / 100% 100%; mask: var(--calendar-cross-shape) 0 0 / 100% 100%; }

/* Today, and the chosen day: an edge and a rule, nothing that changes a size. */
.calendar-day[aria-current="date"] { --edge: var(--calendar-today); }
.calendar [aria-selected="true"] > .calendar-day { --edge: var(--calendar-on); --edge-to: var(--calendar-on); --ink: var(--text-strong); }
.calendar [aria-selected="true"] > .calendar-day .calendar-n { text-decoration-color: var(--calendar-rule); }

}
