/* The plan view (public/js/ui/views/plan.js). Linked from index.html; its rules live here and nowhere else (never in styles.css).

   Everything is native controls, so this file only lays them out and dresses them. It has to hold at 320 px with the root font size
   at 200 %: a fieldset's default minimum width is its content's width, so every fieldset gets `min-width: 0`, the chip rows and
   grids wrap, and long unit titles break inside their label instead of widening the page. Nothing here animates or transitions
   (the widget tests assert that no page rule does), and every colour is a token from styles.css, so both themes are covered. */

/* The plan page is a settings page with grids of cards, so on a wide screen its column is wider than the 760 px of the reading
   pages (in px, not rem: at large text the column is the window anyway). */
@media (min-width: 1000px) { main.page:has(> .plan) { max-width: 1040px; } }

/* ---- the hero ---- */
.hero--plan h1 { width: fit-content; max-width: 100%; }
.hero--plan h1::after { content: ''; display: block; height: 4px; margin-top: 0.35rem; border-radius: 99px; background: linear-gradient(90deg, var(--accent), var(--neon-2)); }
.hero--plan .kicker { width: fit-content; max-width: 100%; padding: 0.2rem 0.7rem; border-radius: 999px; background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent); }
/* The jump buttons: a row that wraps, each at least 44 px tall (.plan .btn below). They are buttons, never #anchor links. */
.plan-jump { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 1rem; }
.plan-jump-btn { flex: 0 1 auto; }

/* ---- fieldsets as cards ---- */
.plan fieldset {
  min-width: 0; margin: 0; padding: 0.9rem 1rem 1rem; border: 1px solid var(--border); border-radius: 14px;
  display: flex; flex-direction: column; gap: 0.7rem;
}
/* The legend is the card's title, inside the card (a floated legend is not the "rendered legend" that sits on the border). A
   legend can hold typed text (a test's name), so a long word in it breaks instead of widening the page. */
.plan fieldset > legend { float: left; width: 100%; max-width: 100%; padding: 0; font-weight: 800; overflow-wrap: anywhere; }
.plan .plan-day, .plan .plan-test, .plan form.plan-add { background: var(--surface-2); }
.plan .plan-sub { gap: 0.2rem; padding-top: 0.7rem; border-color: transparent; background: var(--surface); }
.plan .plan-sub > legend { font-size: 0.9rem; color: var(--muted); margin-bottom: 0.2rem; }
.plan .plan-add h3 { font-size: 1.05rem; margin: 0; }
.plan .plan-add h3::before { content: '＋ '; content: '＋ ' / ''; color: var(--accent); }

/* Grids of cards: one column on a phone, two or three where there is room. The track minimum is in rem, so large text still
   gives one column. */
.plan-grid, .plan-tests { display: grid; gap: 0.8rem; grid-template-columns: repeat(auto-fill, minmax(min(100%, 17rem), 1fr)); align-items: start; }
.plan-subjects { grid-template-columns: repeat(auto-fill, minmax(min(100%, 20rem), 1fr)); }
.plan-tests { grid-template-columns: repeat(auto-fill, minmax(min(100%, 19rem), 1fr)); }
.plan-none { grid-column: 1 / -1; }

/* A day with no school: dimmed with a dashed edge and quiet words. The time can still be set, so nothing is faded out (an
   opacity would take the contrast of the controls with it). */
.plan .plan-day--off { background: transparent; border-style: dashed; }
.plan .plan-day--off > legend { color: var(--muted); }

/* ---- checkboxes and radios ---- */
/* A checkbox or radio with its text: the whole row is the target, at least 44 px tall. */
.plan-checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 11rem), 1fr)); gap: 0.1rem 0.6rem; }
.plan-check { display: flex; align-items: flex-start; gap: 0.6rem; min-height: 44px; padding: 0.4rem 0.2rem; cursor: pointer; overflow-wrap: anywhere; }
.plan-check input { flex: none; width: 1.3rem; height: 1.3rem; margin: 0.1rem 0 0; accent-color: var(--accent); }
.plan-choices .plan-check { grid-column: 1 / -1; }

/* Toggle chips: the native checkbox is stretched over its label and made see-through, so a click or a tap anywhere on the chip
   is the checkbox's own, and the keyboard and screen readers get a real checkbox. The chip is drawn from the label: a ring that
   fills with a tick when the box is checked (a shape and a fill, not only a colour), and the focus ring from :has(:focus-visible). */
.plan-chips { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.plan-chip {
  position: relative; display: inline-flex; align-items: center; gap: 0.45rem; max-width: 100%; min-height: 44px; padding: 0.35rem 0.9rem 0.35rem 0.65rem;
  border: 1.5px solid var(--border); border-radius: 999px; background: var(--surface); color: var(--text); font-weight: 600;
}
.plan-chip input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.plan-chip::before {
  content: ''; flex: none; width: 1.15rem; height: 1.15rem; border: 2px solid var(--muted); border-radius: 50%;
  display: grid; place-items: center; font-size: 0.75rem; line-height: 1; font-weight: 900;
}
.plan-chip:hover { border-color: var(--accent); }
.plan-chip:has(:checked) { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.plan-chip:has(:checked)::before { content: '✓'; content: '✓' / ''; border-color: var(--accent-text); }
.plan-chip:has(:focus-visible) { outline: 3px solid var(--glow-ring); outline-offset: 2px; }
.plan-chip input:focus-visible { outline: none; }

/* Priority: a segmented control. The radios stay (arrow keys move through them, and save each stop); each label is a segment, and
   the checked one is filled. The segments share the row and wrap under each other when the text is large. */
.plan .plan-segmented { flex-direction: row; flex-wrap: wrap; align-items: stretch; gap: 0.4rem; }
.plan .plan-segmented > legend { flex: 0 0 100%; }
.plan-seg {
  position: relative; flex: 1 1 5rem; align-items: center; justify-content: center; margin: 0; padding: 0.3rem 0.6rem; text-align: center;
  border: 1.5px solid var(--border); border-radius: 12px; background: var(--bg); font-weight: 600;
}
.plan-seg input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.plan-seg:hover { border-color: var(--accent); }
.plan-seg:has(:checked) { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 800; }
/* A tick on the checked segment, as the chips have: in forced-colors mode (Windows High Contrast) the browser sets every segment's
   background, border and text to the same system colours, so the fill is gone and only content still tells the checked one apart. */
.plan-seg:has(:checked)::before { content: '✓'; content: '✓' / ''; flex: none; }
.plan-seg:has(:focus-visible) { outline: 3px solid var(--glow-ring); outline-offset: 2px; }
.plan-seg input:focus-visible { outline: none; }

/* ---- fields ---- */
/* A label above its control. The time and date inputs sit next to their "No session" and "Clear date" buttons and wrap under them. */
.plan-field { display: flex; flex-direction: column; gap: 0.35rem; min-width: 0; }
.plan-field > label { font-weight: 600; }
.plan-inline { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }
.plan-input {
  font: inherit; min-height: 44px; max-width: 100%; padding: 0.45rem 0.7rem;
  border: 1.5px solid var(--border); border-radius: 10px; background: var(--bg); color: var(--text);
}
.plan-input:focus { border-color: var(--accent); }
.plan-field > .plan-input { align-self: flex-start; }
.plan-field > input[type="text"] { align-self: stretch; }
.plan .btn { min-height: 44px; }

/* ---- tests ---- */
/* The date as a badge (month on a band, the day big) and how far away it is as a chip. Both are for the eye: the date input is the
   control and the legend names the test. */
.plan-test-head { display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem; }
.plan-date-badge {
  display: grid; justify-items: center; min-width: 3.2rem; overflow: hidden; text-align: center;
  border: 1.5px solid var(--border); border-radius: 12px; background: var(--surface);
}
.plan-date-month { width: 100%; padding: 0.05rem 0.4rem; font-size: 0.7rem; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase; background: var(--accent); color: var(--accent-text); }
.plan-date-day { padding: 0.1rem 0.4rem 0.2rem; font-size: 1.4rem; font-weight: 800; line-height: 1.15; }
.plan-when { max-width: 100%; padding: 0.2rem 0.75rem; overflow-wrap: anywhere; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); font-size: 0.85rem; font-weight: 700; }
.plan-when--soon { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 45%, transparent); color: var(--accent); }
.plan-when--today { background: var(--cta); border-color: var(--cta); color: var(--cta-text); }
.plan-when--past { color: var(--muted); font-weight: 600; }
/* The form for a new test: a highlighted dashed card. */
.plan form.plan-add { border: 2px dashed color-mix(in srgb, var(--accent) 65%, var(--border)); background: var(--accent-soft); margin-top: 0.2rem; }

.plan-note { color: var(--muted); font-size: 0.875rem; font-weight: 400; }
.plan-note--block { margin: 0; padding: 0.5rem 0.7rem; border-radius: 10px; background: var(--warn-soft); color: var(--text); }
.plan-prompt { margin: 0; padding: 0.5rem 0.7rem; border-radius: 10px; background: var(--accent-soft); }

/* ---- subjects ---- */
/* A card per subject, with a stripe in its group's colour on top (the groups of the Lessons page's tiles). */
.plan .plan-subject { --grp: var(--accent); border-top: 4px solid var(--grp); }
.plan .plan-subject[data-group="stem"] { --grp: var(--grp-stem); }
.plan .plan-subject[data-group="languages"] { --grp: var(--grp-lang); }
.plan .plan-subject[data-group="gesellschaft"] { --grp: var(--grp-soc); }
.plan .plan-subject[data-group="arts-sport"] { --grp: var(--grp-arts); }

/* ---- calendar ---- */
.plan-calendar h2 { display: flex; align-items: center; gap: 0.6rem; }
/* The heading's words wrap next to the icon instead of running past the card (a flex item will not shrink below its longest word). */
.plan-calendar h2 > span { min-width: 0; overflow-wrap: anywhere; }
.plan-icon { flex: none; width: 1.5rem; height: 1.5rem; fill: none; stroke: var(--accent); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
/* A focused heading (after a jump button) shows the ring but no extra box. */
.plan h2:focus-visible { outline-offset: 4px; border-radius: 6px; }

/* ---- about and reset ---- */
.plan .about { margin-top: 0; color: var(--text); font-size: 1rem; }
.plan .about summary { display: flex; align-items: center; gap: 0.6rem; min-height: 44px; margin: 0; list-style: none; cursor: pointer; }
.plan .about summary::-webkit-details-marker { display: none; }
.plan .about summary::before { content: '▸'; content: '▸' / ''; flex: none; color: var(--accent); }
.plan .about[open] > summary::before { content: '▾'; content: '▾' / ''; }
.plan .about[open] > summary { margin-bottom: 0.6rem; }
.plan .about p { color: var(--muted); font-size: 0.92rem; }
.plan .about .btn { align-self: flex-start; }

/* ---- the status line ---- */
/* One line that says what happened to the last change, as a pill that floats above the page. It stays at the bottom of the window,
   so a change made far down the page can still be seen being saved. It always holds a sentence, so the live region is never empty or
   hidden. The room under it is kept as scroll padding so a control focused from the keyboard is never hidden behind it. */
.plan-status {
  position: sticky; bottom: 0.75rem; z-index: 2; align-self: center; width: fit-content; max-width: 100%; padding: 0.6rem 1.1rem;
  border: 1.5px solid color-mix(in srgb, var(--accent) 55%, var(--border)); border-radius: 1.4rem;
  background: var(--surface-2); box-shadow: var(--shadow), 0 12px 24px -12px color-mix(in srgb, var(--accent) 60%, transparent), 0 0 0 4px color-mix(in srgb, var(--bg) 70%, transparent);
  overflow-wrap: anywhere; text-align: center;
}
.plan-status-text { margin: 0; font-weight: 600; }
.plan-status-text--bad { color: var(--bad); font-weight: 700; }
:root:has(.plan-status) { scroll-padding-bottom: 9rem; }

/* The calendar button when there is nothing to put in a calendar yet: it looks switched off but stays reachable from the
   keyboard (it is aria-disabled, not disabled), and pressing it says why in the status line. */
.plan .btn[aria-disabled="true"] { opacity: 0.55; cursor: not-allowed; }
/* It does not brighten under the pointer like an active button (styles.css does that for a hovered .btn-primary). */
.plan .btn[aria-disabled="true"]:hover { filter: none; }
