/* The almanac: the regime of every published session as a calendar. Every selector is scoped under .m-almanac. */
.m-almanac {
  /* Regime fills: tints of the status inks for the two trends, plain neutral for chop, amber hatching for volatility,
     stippling for an unclear tape. The trends also carry a heavy edge (top for up, bottom for down) so they never
     rely on hue alone. */
  --al-bull: color-mix(in srgb, var(--green) 30%, var(--paper));
  --al-bear: color-mix(in srgb, var(--red) 26%, var(--paper));
  --al-range: color-mix(in srgb, var(--ink) 12%, var(--paper));
  --al-other: color-mix(in srgb, var(--muted) 45%, var(--paper));
  --al-vol-bg: color-mix(in srgb, var(--amber) 9%, var(--paper));
  --al-hatch: repeating-linear-gradient(135deg, var(--al-hatch-ink) 0 1.06px, transparent 1.06px 4.243px);
  --al-hatch-ink: var(--amber);
  --al-stipple: radial-gradient(circle at 50% 50%, var(--muted) 0 .75px, transparent 1.05px);
}
@media (prefers-color-scheme: dark) {
  .m-almanac { --al-hatch-ink: color-mix(in srgb, var(--amber) 72%, var(--paper)); --al-vol-bg: color-mix(in srgb, var(--amber) 7%, var(--paper)); }
}
.m-almanac .al-n { font: 400 .9em/1 var(--mono); font-style: normal; letter-spacing: -.02em; color: var(--ink); }
.m-almanac.story-sec > h2 { text-wrap: balance; }
.m-almanac .dek { max-width: 760px; text-wrap: pretty; }

/* ---------- Fills (shared by the calendar squares, the key and the readout) ---------- */
.m-almanac .al-sw { box-sizing: border-box; }
.m-almanac .k-bull { background: var(--al-bull); border-top: 2px solid var(--green); }
.m-almanac .k-bear { background: var(--al-bear); border-bottom: 2px solid var(--red); }
.m-almanac .k-range { background: var(--al-range); }
.m-almanac .k-vol { background: var(--al-hatch), var(--al-vol-bg); }
.m-almanac .k-unclear { background: var(--al-stipple) 0 0 / 4px 4px, var(--paper); border: 1px dotted var(--muted); }
.m-almanac .k-other { background: var(--al-other); }
.m-almanac .k-none { background: transparent; border: 1px solid var(--rule); }

/* ---------- The calendar ---------- */
.m-almanac .al-fig { margin: 26px 0 0; }
.m-almanac .al-plate { position: relative; }
.m-almanac .al-scroll { overflow-x: auto; overflow-y: hidden; overscroll-behavior-x: contain; scroll-padding-left: 34px; scrollbar-width: thin; scrollbar-color: var(--rule) transparent; }
.m-almanac .al-scroll.is-scroll { padding-bottom: 6px; }
.m-almanac .al-cal { --pitch: 20px; --inset: 2px; --lab: 34px; --tail: 16px; width: max-content; }
.m-almanac .al-row,
.m-almanac .al-line { display: grid; grid-template-columns: var(--lab) repeat(var(--weeks), var(--pitch)) var(--tail); }
.m-almanac .al-scroll.is-scroll { scroll-snap-type: x mandatory; }
.m-almanac .al-line--mo + .al-row .al-gc { scroll-snap-align: start; }
.m-almanac .al-row { height: var(--pitch); }

/* Weekday names and the empty corner cells stay put while the weeks scroll under them. */
.m-almanac .al-wd, .m-almanac .al-corner { position: sticky; left: 0; z-index: 3; background: var(--paper); }
.m-almanac .al-wd { font: 600 9.5px/var(--pitch) var(--sans); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }

.m-almanac .al-line--yr { height: 16px; }
.m-almanac .al-line--mo { height: 22px; margin-bottom: 2px; }
.m-almanac .al-yr, .m-almanac .al-mo, .m-almanac .al-note { grid-row: 1; min-width: 0; white-space: nowrap; }
.m-almanac .al-yr { position: sticky; left: 34px; z-index: 1; justify-self: start; padding: 0 6px 0 3px; background: var(--paper); font: 500 11px/16px var(--mono); color: var(--muted); }
.m-almanac .al-yr .al-n { font-size: 11px; color: var(--muted); }
.m-almanac .al-mo {
  position: relative; align-self: end; padding: 0 0 6px 4px; overflow: clip;
  font: 600 10.5px/1 var(--sans); letter-spacing: .12em; text-transform: uppercase; color: var(--ink);
  border-left: 1px solid var(--ink);
}

/* A month's name rides along while its weeks pass under the day names. */
.m-almanac .al-mo > span { display: inline-block; position: sticky; left: 38px; }
.m-almanac .al-gc { display: block; position: relative; width: var(--pitch); height: var(--pitch); }
.m-almanac .al-gc[aria-selected="true"] { z-index: 2; }
.m-almanac .al-day {
  position: absolute; inset: 0; display: block; width: 100%; height: 100%; margin: 0; padding: 0;
  border: 0; background: none; color: inherit; cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent;
}
.m-almanac .al-day .al-sw { position: absolute; inset: var(--inset); }

/* Month boundaries: a hairline step drawn through the gutters between squares. */
.m-almanac .al-day.bl::before,
.m-almanac .al-day.bt::after { content: ''; position: absolute; background: var(--ink); pointer-events: none; }
.m-almanac .al-day.bl::before { left: -.5px; top: 0; bottom: 0; width: 1px; }
.m-almanac .al-day.bt::after { top: -.5px; left: -.5px; right: -.5px; height: 1px; }

/* ENTER: a vermilion dot on a paper ring, its area growing with the number of candidates. */
.m-almanac .al-dot {
  position: absolute; left: 50%; top: 50%; width: calc(var(--pitch) * var(--d)); height: calc(var(--pitch) * var(--d));
  box-sizing: content-box; border: 1.5px solid var(--paper); border-radius: 50%; background: var(--accent);
  transform: translate(-50%, -50%); pointer-events: none;
}
.m-almanac .al-dot.n1 { --d: .22; }
.m-almanac .al-dot.n2 { --d: .311; }
.m-almanac .al-dot.n3 { --d: .381; }
.m-almanac .al-dot.n4 { --d: .44; }

/* Hover, selection and keyboard focus ring the square itself. */
.m-almanac .al-day:hover .al-sw { outline: 1px solid var(--ink); outline-offset: 1px; }
.m-almanac .al-day.is-sel .al-sw { outline: 2px solid var(--ink); outline-offset: 1px; }
.m-almanac .al-day:focus-visible { outline: none; }
.m-almanac .al-day:focus-visible .al-sw { outline: 2px solid var(--accent); outline-offset: 1px; }

/* Picking out one row of the key: everything else recedes to a ghost. */
.m-almanac .al-day.is-dim .al-sw { opacity: .14; }
.m-almanac .al-day.is-dim .al-dot { opacity: .2; }
.m-almanac .al-day.is-dim.is-sel .al-sw { opacity: .5; }

/* Annotations under the calendar */
.m-almanac .al-line--notes { height: 30px; }
.m-almanac .al-note { position: relative; padding-top: 11px; font: italic 400 13px/1.2 var(--serif); color: var(--muted); }
.m-almanac .al-note::before { content: ''; position: absolute; top: 2px; width: 1px; height: 7px; background: var(--ink); }
.m-almanac .al-note--end { text-align: right; }
.m-almanac .al-note--end::before { right: calc(var(--pitch) / 2 - .5px); }
.m-almanac .al-note--start::before { left: calc(var(--pitch) / 2 - .5px); }
.m-almanac .al-note > span { position: relative; z-index: 1; background: var(--paper); }

/* Tooltip (mouse and pen) */
.m-almanac .al-tip { left: 0; top: 0; display: grid; gap: 1px; }
.m-almanac .al-tip[hidden] { display: none; }
.m-almanac .al-tip b { font: 500 12px/1.35 var(--mono); }
.m-almanac .al-tip .al-tip-e { color: var(--muted); }
.m-almanac .al-tip .al-n { font-size: 12px; }

.m-almanac .al-swipe { margin: 4px 0 0; font: italic 13px/1.3 var(--serif); color: var(--muted); }
.m-almanac .al-swipe[hidden] { display: none; }

/* ---------- The readout for the selected day ---------- */
.m-almanac .al-detail {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 20px; min-height: 52px;
  margin: 12px 0 0; padding: 12px 0 13px; border-top: 1px solid var(--ink); border-bottom: 1px solid var(--rule);
}
.m-almanac .al-d-k { display: inline-flex; flex-wrap: wrap; align-items: baseline; gap: 2px 16px; }
.m-almanac .al-d-date { font: 500 13px/1.3 var(--mono); color: var(--ink); white-space: nowrap; }
.m-almanac .al-d-reg { font: 600 19px/1.25 var(--serif); letter-spacing: -.005em; }
.m-almanac .al-d-dec { font: italic 400 16px/1.4 var(--serif); color: var(--muted); }
.m-almanac .al-d-link {
  margin-left: auto; padding-bottom: 3px; white-space: nowrap;
  font: 600 11.5px/1 var(--sans); letter-spacing: .12em; text-transform: uppercase; color: var(--accent);
  text-decoration: none; border-bottom: 1.5px solid var(--accent);
}
.m-almanac .al-d-link::after { content: ' \2192'; letter-spacing: 0; }
.m-almanac .al-d-link:hover { color: var(--ink); border-color: var(--ink); }

/* Small swatches in running text and the key */
.m-almanac .al-sw--key { position: relative; display: inline-block; flex: none; width: 16px; height: 16px; margin-right: 9px; vertical-align: -2px; }
.m-almanac .al-sw--dot { --pitch: 24px; }
.m-almanac .al-dot--inline { --pitch: 22px; position: relative; display: inline-block; left: auto; top: auto; margin-right: 7px; vertical-align: 0; transform: none; }

/* ---------- The key: counts, shares and definitions ---------- */
.m-almanac .al-how { margin: 30px 0 8px; font: italic 400 14.5px/1.45 var(--serif); color: var(--muted); }
.m-almanac .al-key { width: 100%; border-collapse: collapse; border-top: 2px solid var(--ink); border-bottom: 1px solid var(--ink); font-size: 14px; }
.m-almanac .al-key th,
.m-almanac .al-key td { padding: 9px 18px 9px 0; vertical-align: middle; white-space: normal; border-bottom: 1px solid var(--rule); }
.m-almanac .al-key thead th { padding-top: 8px; padding-bottom: 7px; white-space: nowrap; border-bottom: 1px solid var(--ink); }
.m-almanac .al-key td:last-child, .m-almanac .al-key th:last-child { padding-right: 0; }
.m-almanac .al-key tbody tr:hover td { background: none; }
.m-almanac .al-key .al-kmarks tr:first-child > * { border-top: 1px solid var(--ink); }
.m-almanac .al-key tbody:last-child tr:last-child > * { border-bottom: 0; }
.m-almanac .al-kr { position: relative; }
.m-almanac .al-kname { width: 17.5rem; font: inherit; text-transform: none; letter-spacing: normal; color: var(--ink); }
.m-almanac .al-kn { width: 5.5rem; text-align: right; font-family: var(--mono); }
.m-almanac .al-kshare { width: 12rem; white-space: nowrap; }
.m-almanac .al-ke { width: 5.5rem; text-align: right; }
.m-almanac thead .al-kn, .m-almanac thead .al-ke { text-align: right; font-family: var(--sans); }
.m-almanac thead .al-kd { font: 600 10.5px/1.4 var(--sans); color: var(--muted); }
.m-almanac .al-kn .al-n, .m-almanac .al-ke .al-n { font-size: 15px; font-weight: 500; letter-spacing: 0; }
.m-almanac .al-kunit { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.m-almanac .al-kd { font: italic 400 14px/1.4 var(--serif); color: var(--muted); text-wrap: pretty; }
.m-almanac .al-kd .al-n { font-size: 13px; color: var(--muted); }

.m-almanac .al-kb {
  display: inline-flex; align-items: center; min-height: 32px; margin: 0; padding: 2px 0; border: 0; background: none;
  color: inherit; font: 600 16.5px/1.2 var(--serif); letter-spacing: -.005em; text-align: left; cursor: pointer;
}
.m-almanac .al-kb::after { content: ''; position: absolute; inset: 0; } /* the whole row is the hit target */
.m-almanac .al-kb:focus-visible { outline: none; }
.m-almanac .al-kb:focus-visible::after { outline: 2px solid var(--accent); outline-offset: -2px; }
.m-almanac .al-kb:disabled { cursor: default; color: var(--muted); }
.m-almanac .al-kr:has(.al-kb:not(:disabled)):hover > * { background: var(--paper2); }
.m-almanac .al-kr.is-on > * { background: var(--paper2); }
.m-almanac .al-kr.is-on .al-kb span { text-decoration: underline; text-decoration-color: var(--accent); text-decoration-thickness: 2px; text-underline-offset: 5px; }
.m-almanac .al-kr.is-zero .al-sw--key { opacity: .4; }
.m-almanac .al-kr.is-zero .al-n { color: var(--muted); }

.m-almanac .al-share { --track: 8.5rem; display: flex; align-items: center; gap: 7px; }
.m-almanac .al-bar { display: block; position: relative; flex: none; width: calc(var(--w) * var(--track)); height: 12px; border-left: 1px solid var(--ink); }
.m-almanac .al-bar i { position: absolute; inset: 0; box-sizing: border-box; transform-origin: left center; }
.m-almanac .al-bar .al-bar-enter { top: 4px; bottom: 4px; background: var(--accent); }
.m-almanac .al-kp { font: 400 13px/1 var(--mono); color: var(--muted); }

/* ---------- Records ---------- */
.m-almanac .al-recs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); margin: 34px 0 0; border-top: 2px solid var(--ink); border-bottom: 1px solid var(--rule); }
.m-almanac .al-rec { min-width: 0; padding: 12px 18px 15px; border-left: 1px solid var(--rule); }
.m-almanac .al-rec:first-child { padding-left: 0; border-left: 0; }
.m-almanac .al-rl { display: block; font: 600 11px/1.3 var(--sans); letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.m-almanac .al-rv { display: block; margin-top: 7px; font: 600 20px/1.15 var(--serif); }
.m-almanac .al-rv .al-n { font: 500 30px/1 var(--mono); letter-spacing: -.04em; margin-right: 2px; }
.m-almanac .al-rn { display: block; margin-top: 6px; font: italic 400 14.5px/1.4 var(--serif); color: var(--muted); }
.m-almanac .al-rn .al-n { font-size: 13.5px; color: var(--ink); }

.m-almanac .al-foot { margin: 14px 0 0; max-width: 780px; font: italic 400 13.5px/1.5 var(--serif); color: var(--muted); }
.m-almanac .al-foot .al-n { color: var(--muted); }

/* ---------- Empty state ---------- */
.m-almanac .al-empty { margin-top: 24px; border-top: 2px solid var(--ink); }
.m-almanac .al-empty h3 { margin: 12px 0 4px; }
.m-almanac .al-defs { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr)); gap: 0 32px; margin: 0; }
.m-almanac .al-def { padding: 10px 0 12px; border-bottom: 1px solid var(--rule); }
.m-almanac .al-def dt { display: flex; align-items: center; font: 600 16.5px/1.25 var(--serif); }
.m-almanac .al-def dd { margin: 4px 0 0 25px; font: italic 400 14.5px/1.45 var(--serif); color: var(--muted); }

/* ---------- Motion: the squares are inked in week by week, oldest first ---------- */
@keyframes al-wipe { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0 0 0 0); } }
@keyframes al-pop { from { transform: translate(-50%, -50%) scale(0); } to { transform: translate(-50%, -50%) scale(1); } }
.m-almanac.al-anim .al-plate:not(.is-in) .al-day .al-sw { clip-path: inset(0 100% 0 0); }
.m-almanac.al-anim .al-plate:not(.is-in) .al-day .al-dot { transform: translate(-50%, -50%) scale(0); }
.m-almanac.al-anim .al-plate.is-in .al-day .al-sw { animation: al-wipe .38s cubic-bezier(.3, .7, .3, 1) backwards; animation-delay: calc(var(--c) * 15ms); }
.m-almanac.al-anim .al-plate.is-in .al-day .al-dot { animation: al-pop .32s cubic-bezier(.3, 1.4, .5, 1) backwards; animation-delay: calc(var(--c) * 15ms + .3s); }
.m-almanac.al-anim .al-key:not(.is-in) .al-bar i { transform: scaleX(0); }
.m-almanac.al-anim .al-key.is-in .al-bar i { transition: transform .8s cubic-bezier(.3, .7, .3, 1) .1s; }
@media (prefers-reduced-motion: reduce) {
  .m-almanac .al-sw, .m-almanac .al-dot, .m-almanac .al-bar i { animation: none !important; transition: none !important; }
}

/* ---------- Narrow desks and tablets: definitions move under their row ---------- */
@media (min-width: 641px) and (max-width: 980px) {
  .m-almanac .al-key tr { display: grid; grid-template-columns: minmax(0, 1fr) 5.5rem 11rem 7rem; grid-template-areas: 'name n share ent' 'def def def def'; align-items: center; column-gap: 16px; border-bottom: 1px solid var(--rule); }
  .m-almanac .al-key thead tr { border-bottom: 1px solid var(--ink); }
  .m-almanac .al-key tbody:last-child tr:last-child { border-bottom: 0; }
  .m-almanac .al-key .al-kmarks tr:first-child { border-top: 1px solid var(--ink); }
  .m-almanac .al-key th, .m-almanac .al-key td { display: block; width: auto; padding: 0; border: 0 !important; }
  .m-almanac .al-key thead th { padding: 8px 0 7px; }
  .m-almanac .al-key thead .al-kd { display: none; }
  .m-almanac .al-key tbody th, .m-almanac .al-key tbody td:not(.al-kd) { padding-top: 7px; }
  .m-almanac .al-kname { grid-area: name; }
  .m-almanac .al-kn { grid-area: n; }
  .m-almanac .al-kshare { grid-area: share; }
  .m-almanac .al-ke { grid-area: ent; }
  .m-almanac .al-kd { grid-area: def; padding: 2px 0 11px 25px !important; max-width: 640px; }
  .m-almanac .al-kr.is-on, .m-almanac .al-kr:has(.al-kb:not(:disabled)):hover { background: var(--paper2); }
}

/* ---------- Phone ---------- */
@media (max-width: 640px) {
  .m-almanac .al-fig { margin-top: 20px; }
  .m-almanac .al-detail { gap: 6px 16px; }
  .m-almanac .al-d-k { width: 100%; justify-content: space-between; }
  .m-almanac .al-d-dec { width: 100%; }
  .m-almanac .al-d-link { margin-left: 0; padding-top: 6px; }

  .m-almanac .al-key thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .m-almanac .al-key tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: 'name n' 'share ent' 'def def'; align-items: center; column-gap: 12px; padding: 8px 0 11px; border-bottom: 1px solid var(--rule); }
  .m-almanac .al-key tbody:last-child tr:last-child { border-bottom: 0; }
  .m-almanac .al-key .al-kmarks tr:first-child { border-top: 1px solid var(--ink); }
  .m-almanac .al-key .al-kmarks tr:first-child > * { border-top: 0; }
  .m-almanac .al-key th, .m-almanac .al-key td { display: block; width: auto; padding: 0; border: 0; }
  .m-almanac .al-kname { grid-area: name; }
  .m-almanac .al-kn { grid-area: n; }
  .m-almanac .al-kshare { grid-area: share; padding-top: 4px !important; }
  .m-almanac .al-kshare:empty { display: none !important; }
  .m-almanac .al-ke { grid-area: ent; justify-self: end; padding-top: 4px !important; }
  .m-almanac .al-ke:empty { display: none !important; }
  .m-almanac .al-kunit { position: static; width: auto; height: auto; overflow: visible; clip: auto; font: 400 12.5px/1 var(--sans); color: var(--muted); }
  .m-almanac .al-ke .al-n { font-size: 13px; }
  .m-almanac .al-share { --track: calc(100vw - 14rem); }
  .m-almanac .al-kd { grid-area: def; padding-top: 5px !important; font-size: 14px; }
  .m-almanac .al-kr.is-on, .m-almanac .al-kr:has(.al-kb:not(:disabled)):hover { background: var(--paper2); }

  .m-almanac .al-recs { grid-template-columns: 1fr; }
  .m-almanac .al-rec, .m-almanac .al-rec:first-child { padding: 11px 0 13px; border-left: 0; }
  .m-almanac .al-rec + .al-rec { border-top: 1px solid var(--rule); }
}
