/* Cortex planner ("At a glance"). Builds on styles.css tokens. */
.planner-page {
  --grid: rgba(67, 217, 255, 0.09);
  --accent-soft: rgba(67, 217, 255, 0.12);
  --crit-soft: rgba(255, 107, 120, 0.12);
  --ev: #0f3149;
  --ev-edge: var(--cyan-soft);
  --big-edge: var(--violet);
  --hr: 48px;
  --gut: 56px;
  font-size: 16px;
}
html:has(.planner-page) { scroll-padding-top: 88px; }
/* Screen reader only text (same as .visually-hidden) */
.sr {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.wrap { max-width: 1720px; margin: 0 auto; padding: var(--gap) clamp(16px, 2.5vw, 32px) 64px; }
header.top { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: 12px 24px; margin-bottom: 16px; }
.planner-page h1 {
  font-family: var(--font-display); font-weight: 800; font-size: clamp(1.4rem, 2.6vw, 2rem); line-height: 1.1;
  letter-spacing: 0.16em; text-transform: uppercase; color: #f2fcff; text-shadow: 0 0 16px rgba(67, 217, 255, 0.4);
}
.date { color: var(--muted); margin-top: 6px; font-family: var(--font-display); font-size: 13px; letter-spacing: 0.12em; text-transform: uppercase; }

nav.jump ul { display: flex; flex-wrap: wrap; gap: 8px; }
nav.jump a {
  display: inline-flex; align-items: center; min-height: 40px; padding: 6px 14px;
  border: 1px solid var(--line-strong); border-radius: 999px; text-decoration: none; color: var(--text);
  background: rgba(8, 22, 36, 0.8); font-family: var(--font-display); font-size: 11px; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase;
}
nav.jump a:hover { border-color: var(--cyan); background: rgba(67, 217, 255, 0.1); }
/* Phones: the four section links share one row as a segmented bar. Long labels wrap inside their segment. */
@media (max-width: 600px) {
  nav.jump { width: 100%; }
  nav.jump ul {
    display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 3px; padding: 3px;
    border: 1px solid var(--line-strong); border-radius: 999px; background: rgba(8, 22, 36, 0.8);
  }
  nav.jump a {
    display: flex; justify-content: center; text-align: center; width: 100%; min-height: 44px; padding: 4px 6px;
    border: 0; border-radius: 999px; background: transparent; font-size: 10px; letter-spacing: 0.06em; line-height: 1.15;
  }
}

#status { margin: 0 0 16px; color: var(--muted); font-family: var(--font-mono); font-size: 13px; }
#status.note { color: #ffe2b5; background: rgba(255, 181, 71, 0.08); border: 1px solid rgba(255, 181, 71, 0.45); padding: 10px 14px; border-radius: var(--radius); font-family: var(--font-ui); font-size: 16px; }
#keyform { display: none; gap: 8px; align-items: end; flex-wrap: wrap; margin-bottom: 16px; }
#keyform.on { display: flex; }
#keyform label { display: grid; gap: 4px; font-weight: 600; }
#keyform input {
  min-height: 42px; padding: 8px 12px; min-width: 16rem;
  background: rgba(2, 8, 14, 0.7); border: 1px solid var(--line-strong); border-radius: var(--radius);
}

.layout { display: grid; gap: var(--gap); grid-template-columns: minmax(0, 1fr); }
@media (min-width: 960px) { .layout { grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); } .full { grid-column: 1 / -1; } }
.layout > .panel { min-width: 0; }
.panel > header { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 12px; margin-bottom: 14px; }
.panel > header h2 { font-family: var(--font-display); font-size: 13px; font-weight: 700; letter-spacing: 0.24em; text-transform: uppercase; color: var(--cyan); }
.sub { color: var(--muted); font-family: var(--font-mono); font-size: 13px; }

/* ---------- Tasks ---------- */
.group + .group { margin-top: 16px; padding-top: 16px; border-top: 1px dashed var(--line); }
.group h3 { display: flex; gap: 10px; align-items: baseline; font-family: var(--font-display); font-size: 12px; font-weight: 700; letter-spacing: 0.18em; text-transform: uppercase; }
.group h3 .count { font-family: var(--font-mono); font-size: 13px; color: var(--muted); letter-spacing: 0; }
.group .hint { margin: 2px 0 8px; color: var(--muted); font-size: 15px; }
.tasks { display: grid; gap: 6px; }
.task { padding: 8px 12px; border-radius: 4px; border: 1px solid rgba(67, 217, 255, 0.1); border-left: 4px solid var(--line-strong); background: rgba(67, 217, 255, 0.04); }
.crit .task { border-left-color: var(--red); background: var(--crit-soft); }
.quick .task { border-left-color: var(--cyan); }
.big .task { border-left-color: var(--big-edge); }
.task a { color: var(--text); font-weight: 600; text-decoration: none; }
.task a:hover { color: var(--cyan-soft); text-decoration: underline; }
.meta { margin-top: 2px; display: flex; flex-wrap: wrap; gap: 4px 14px; color: var(--muted); font-family: var(--font-mono); font-size: 12px; }
.pri { font-weight: 600; color: var(--amber); }
.pri.p1 { color: var(--red); }
.overdue { color: var(--red); font-weight: 600; }
.planner-page .empty { color: var(--muted); font-size: 15px; }
.planner-page details summary { cursor: pointer; min-height: 32px; display: flex; align-items: center; font-family: var(--font-display); font-size: 12px; font-weight: 700; letter-spacing: 0.18em; text-transform: uppercase; color: var(--cyan-soft); }
.planner-page details[open] summary { margin-bottom: 8px; }
/* Long lists scroll inside their own box: first five tasks show, the sixth peeks out under a fade. */
.task-scroll {
  overflow-y: auto; overscroll-behavior: contain; position: relative; max-height: 26rem;
  padding-right: 6px; border-radius: 4px; scrollbar-color: var(--cyan-deep) transparent;
}
/* Fade is an overlay, not a mask, so the focus ring is never clipped. */
.task-scroll::after {
  content: ""; position: sticky; bottom: 0; display: block; height: 44px; margin-top: -44px;
  background: linear-gradient(rgba(6, 16, 26, 0), var(--panel-solid)); pointer-events: none; opacity: 0;
}
.task-scroll.fade::after { opacity: 1; }
.task-scroll:focus-visible { outline-offset: 2px; }
.more-cue { margin-top: 6px; color: var(--muted); font-family: var(--font-mono); font-size: 12px; }

/* ---------- Timelines ---------- */
.scroll {
  overflow: auto; position: relative; max-height: min(32rem, 70vh);
  border: 1px solid var(--line); border-radius: var(--radius); background: rgba(2, 8, 14, 0.45);
  scrollbar-color: var(--cyan-deep) transparent;
}
.allday { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 10px; }
.chip { font-size: 14px; font-weight: 600; padding: 2px 10px; border-radius: 999px; background: var(--accent-soft); border: 1px solid var(--line-strong); }
.tl { display: grid; grid-template-columns: var(--gut) minmax(0, 1fr); }
.tl, .wk-body { --hours: 16; } /* hours drawn; Today sets 24 inline */
.gutter { position: relative; height: calc(var(--hr) * var(--hours)); border-right: 1px solid var(--line); }
.gutter span { position: absolute; right: 8px; transform: translateY(-50%); font-family: var(--font-mono); font-size: 12px; color: var(--muted); white-space: nowrap; }
.gutter span:first-child { transform: none; }
.gutter span:last-child { transform: translateY(-100%); }
.track { position: relative; height: calc(var(--hr) * var(--hours)); background-image: linear-gradient(var(--grid) 1px, transparent 1px); background-size: 100% var(--hr); }
.track ol { position: absolute; inset: 0 4px; }
.ev, .open { position: absolute; border-radius: 4px; padding: 2px 6px; overflow: hidden; font-size: 13px; line-height: 1.25; }
.ev { background: var(--ev); border-left: 3px solid var(--ev-edge); box-shadow: inset 0 0 0 1px rgba(143, 233, 255, 0.18); }
.ev-t { font-weight: 700; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ev-time { color: var(--muted); font-family: var(--font-mono); font-size: 11px; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ev.short { display: flex; gap: 6px; align-items: center; }
.ev.short .ev-t, .ev.short .ev-time { display: inline; }
.open {
  left: 0; right: 0; display: flex; align-items: center;
  border: 1.5px dashed var(--cyan); background: var(--accent-soft); color: var(--cyan-soft);
  font-family: var(--font-display); font-size: 11px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase;
}
.now { position: absolute; left: 0; right: 0; height: 2px; background: var(--amber); box-shadow: 0 0 8px var(--amber); z-index: 3; pointer-events: none; }
.now::before { content: ""; position: absolute; left: -5px; top: -4px; width: 10px; height: 10px; border-radius: 50%; background: var(--amber); }
.outside { margin-top: 8px; font-size: 14px; color: var(--muted); }
.outside:empty { display: none; }

/* To do and Today: the timeline shows at least 12 hours (6 AM to 6 PM) before it scrolls. */
#day-scroll { max-height: none; height: calc(var(--hr) * 12 + 28px); }
/* Side by side, both panels share one height that fills the screen under the top bar,
   and each scrolls inside itself. Today's timeline stretches to the bottom of its panel. */
@media (min-width: 960px) {
  #tasks, #day {
    display: flex; flex-direction: column;
    height: clamp(720px, calc(100dvh - 88px - var(--ticker-h) - var(--gap)), 1100px);
  }
  #tasks > header, #day > header, #day > .allday, #day > .outside { flex: none; }
  #task-groups { flex: 1 1 0; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding-right: 6px; scrollbar-color: var(--cyan-deep) transparent; }
  #task-groups:focus-visible { outline-offset: 2px; }
  #day-scroll { flex: 1 1 0; min-height: calc(var(--hr) * 12 + 28px); height: auto; }
}

/* ---------- Week ---------- */
.wk { min-width: 760px; }
.wk-head {
  position: sticky; top: 0; z-index: 4; display: grid; grid-template-columns: var(--gut) repeat(7, minmax(0, 1fr));
  background: var(--panel-solid); border-bottom: 1px solid var(--line-strong);
}
.wk-day { padding: 6px 6px 4px; border-left: 1px solid var(--line); font-family: var(--font-display); font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
.wk-day strong { font-size: 18px; margin-left: 6px; color: var(--text); letter-spacing: 0; }
.wk-day[aria-current="date"] { background: rgba(67, 217, 255, 0.14); box-shadow: inset 0 -3px 0 var(--cyan); color: var(--cyan-soft); }
.wk-day ul { margin-top: 4px; display: grid; gap: 2px; }
.wk-day li { font-family: var(--font-ui); font-size: 12px; font-weight: 600; letter-spacing: 0; text-transform: none; color: var(--text); background: var(--accent-soft); border-radius: 3px; padding: 1px 5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wk-body { display: grid; grid-template-columns: var(--gut) repeat(7, minmax(0, 1fr)); }
.wk-body .track { border-left: 1px solid var(--line); }
.wk-body .track ol { inset: 0 2px; }
.wk-body .ev { font-size: 12px; padding: 2px 4px; }
.wk-body .today { background-color: rgba(67, 217, 255, 0.05); }

/* ---------- Month ---------- */
.mwrap { overflow-x: auto; position: relative; } /* keeps hidden screen reader text inside the scroller */
.mwrap:focus-visible, .scroll:focus-visible { outline-offset: 2px; }
table.month { width: 100%; min-width: 640px; border-collapse: collapse; table-layout: fixed; }
.month th { font-family: var(--font-display); font-size: 11px; font-weight: 700; letter-spacing: 0.16em; text-transform: uppercase; text-align: left; padding: 6px 8px; color: var(--muted); }
.month abbr { text-decoration: none; }
.month td { vertical-align: top; border: 1px solid var(--line); height: 6.5rem; padding: 4px 6px; }
/* Four day states, each told apart by more than colour (hidden labels in the markup):
   this month upcoming = normal; this month past = dimmed cell, muted text;
   other month = hatched, darker cell with a dimmer date (past ones also mute their events);
   a cyan line marks where the month changes. All text stays above 4.5:1. */
.month td.past { background: rgba(2, 8, 14, 0.5); color: var(--muted); }
.month td.past .dnum { font-weight: 500; }
.month td.past li.all { color: var(--muted); }
.month td.other {
  --other-date: #8fa9b5;
  background: repeating-linear-gradient(135deg, rgba(0, 2, 5, 0.86) 0 6px, rgba(10, 26, 40, 0.86) 6px 7px);
}
.month td.other .dnum { color: var(--other-date); font-weight: 500; }
.month td.other:not(.past) li.all { color: var(--cyan-soft); }
.month td.mb-l { border-left: 2px solid var(--cyan); }
.month td.mb-t { border-top: 2px solid var(--cyan); }
.month td[aria-current="date"] { background: rgba(67, 217, 255, 0.12); outline: 2px solid var(--cyan); outline-offset: -2px; }
.dnum { font-family: var(--font-display); font-weight: 700; font-size: 14px; }
.month td[aria-current="date"] .dnum { color: var(--cyan-soft); }
.month ul { margin-top: 2px; display: grid; gap: 2px; }
.month li { font-size: 13px; line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.month li.all { color: var(--cyan-soft); font-weight: 700; }
.more { font-family: var(--font-mono); font-size: 11px; color: var(--muted); }

@media (max-width: 760px) {
  .wrap { padding-bottom: var(--gap); }
}
@media (prefers-reduced-motion: reduce) {
  html:has(.planner-page) { scroll-behavior: auto !important; }
}
/* Tasks in Everything else with no size label (@quick or @deep in config/topics.json) */
.needs-size { color: var(--amber); font-weight: 600; border: 1px solid currentColor; border-radius: 3px; padding: 0 6px; }
