/* Fluent 2 page styles — calendar module. Uses only tokens from fluent-tokens.css (no hex, no raw px for
   spacing/type). Loaded after styles.css. Owned by the calendar pages; keep selectors scoped to them. */

/* ============================================================
   Calendar page (#calendar) — Outlook-style, Fluent 2.
   Canvas: page title + filters (compact dropdowns) at the inline-end of the title row.
   ONE white card (.cal-surface): command bar → month grid / week·day timeline → legend.
   Markup: loadCalendar() and the cal* render functions in app.js.
   ============================================================ */

/* ---------- Page head (on the canvas) ---------- */
@media (min-width:769px){#calendar .cal-pagehead{align-items:center}}
#calendar .cal-filters{display:flex;flex-wrap:wrap;align-items:center;gap:var(--spacingHorizontalS);margin-inline-start:0}
#calendar .cal-filter-icon{color:var(--colorNeutralForeground3);font-size:var(--fontSizeBase300);margin-inline-end:var(--spacingHorizontalXXS)}
#calendar .cal-filter{width:auto;min-width:0;max-width:200px;padding-inline:var(--spacingHorizontalS);font-size:var(--fontSizeBase300);text-overflow:ellipsis}
/* an active filter reads as "on" (brand tint), like a selected Fluent filter pill */
#calendar .cal-filter.cal-filter-on{background:var(--colorBrandBackground2);border-color:var(--colorBrandStroke2);border-bottom-color:var(--colorCompoundBrandStroke);color:var(--colorBrandForeground2);font-weight:var(--fontWeightSemibold)}

/* ---------- The calendar card ---------- */
#calendar .cal-surface{background:var(--colorNeutralBackground1);border-radius:var(--borderRadiusLarge);box-shadow:var(--shadow4);overflow:hidden;margin-bottom:var(--spacingVerticalM)}
#calendar .cal-viewport{overflow:visible}

/* Command bar: [Today] [‹] [›] Period title ........ [Month | Week | Day] */
#calendar .cal-toolbar{display:flex;flex-wrap:wrap;align-items:center;justify-content:space-between;gap:var(--spacingVerticalS) var(--spacingHorizontalL);margin:0;padding:var(--spacingVerticalM) var(--spacingHorizontalL);border-bottom:var(--strokeWidthThin) solid var(--colorNeutralStroke2)}
#calendar .cal-nav{display:flex;align-items:center;gap:var(--spacingHorizontalXXS);min-width:0}
#calendar .cal-todaybtn{display:inline-flex;align-items:center;gap:var(--spacingHorizontalSNudge);height:var(--controlHeightMedium);padding:0 var(--spacingHorizontalM);margin-inline-end:var(--spacingHorizontalXS);font-size:var(--fontSizeBase300);line-height:var(--lineHeightBase300);font-weight:var(--fontWeightSemibold);white-space:nowrap}
#calendar .cal-todaybtn i{color:var(--colorBrandForeground1)}
#calendar .cal-navbtn{display:inline-flex;align-items:center;justify-content:center;gap:var(--spacingHorizontalXS);flex:0 0 auto;min-width:var(--controlHeightMedium);height:var(--controlHeightMedium);padding:0 var(--spacingHorizontalS);border-color:transparent;background:transparent;color:var(--colorNeutralForeground2);font-size:var(--fontSizeBase300)}
#calendar .cal-navbtn:hover{background:var(--colorSubtleBackgroundHover);border-color:transparent;color:var(--colorNeutralForeground2Hover)}
#calendar .cal-navbtn:active{background:var(--colorSubtleBackgroundPressed)}
#calendar .cal-title{margin:0;margin-inline-start:var(--spacingHorizontalS);min-width:0;font-size:var(--fontSizeBase500);line-height:var(--lineHeightBase500);font-weight:var(--fontWeightSemibold);color:var(--colorNeutralForeground1);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}

/* View switcher: a segmented control (one bordered group, selected segment brand-tinted) */
#calendar .cal-views{display:inline-flex;align-items:center;gap:var(--spacingHorizontalXXS);padding:var(--spacingVerticalXXS);border:var(--strokeWidthThin) solid var(--colorNeutralStroke1);border-radius:var(--borderRadiusMedium);background:var(--colorNeutralBackground1)}
#calendar .cal-viewbtn{height:26px;padding:0 var(--spacingHorizontalM);gap:var(--spacingHorizontalSNudge);border-radius:var(--borderRadiusSmall);font-size:var(--fontSizeBase300);line-height:var(--lineHeightBase300);color:var(--colorNeutralForeground2);white-space:nowrap}
#calendar .cal-viewbtn::after{display:none}
#calendar .cal-viewbtn i{font-size:var(--fontSizeBase200);color:var(--colorNeutralForeground3)}
#calendar .cal-viewbtn:hover{background:var(--colorSubtleBackgroundHover);color:var(--colorNeutralForeground1)}
#calendar .cal-viewbtn:active{background:var(--colorSubtleBackgroundPressed)}
#calendar .cal-viewbtn.active,#calendar .cal-viewbtn.active:hover{background:var(--colorBrandBackground2);color:var(--colorBrandForeground2);font-weight:var(--fontWeightSemibold)}
#calendar .cal-viewbtn.active i{color:inherit}

/* ---------- Legend: small dots in the card footer ---------- */
#calendar .cal-legend{display:flex;flex-wrap:wrap;align-items:center;gap:var(--spacingVerticalXS) var(--spacingHorizontalL);margin:0;padding:var(--spacingVerticalMNudge) var(--spacingHorizontalL);border-top:var(--strokeWidthThin) solid var(--colorNeutralStroke2);font-size:var(--fontSizeBase200);line-height:var(--lineHeightBase200);color:var(--colorNeutralForeground3)}
#calendar .cal-leg{gap:var(--spacingHorizontalSNudge)}
#calendar .cal-legend .cal-dot{width:8px;height:8px;border-radius:var(--borderRadiusCircular);background:currentColor}

/* ---------- Month grid: one surface, hairline cell dividers ---------- */
#calendar .cal-dow-row{gap:0;margin:0;border-bottom:var(--strokeWidthThin) solid var(--colorNeutralStroke2)}
#calendar .cal-dow{padding:var(--spacingVerticalS) var(--spacingHorizontalS);text-align:start;font-size:var(--fontSizeBase200);line-height:var(--lineHeightBase200);font-weight:var(--fontWeightSemibold);color:var(--colorNeutralForeground3)}
#calendar .cal-dow-short{display:none}
/* the 1px gaps show the grid's stroke colour → hairlines between cells, none on the card edge */
#calendar .cal-grid{gap:var(--strokeWidthThin);background:var(--colorNeutralStroke2)}
#calendar .cal-cell{min-width:0;min-height:112px;padding:var(--spacingVerticalXS) var(--spacingHorizontalXS) var(--spacingVerticalS);border:0;border-radius:0;background:var(--colorNeutralBackground1);gap:var(--spacingVerticalXXS)}
/* out-of-month and closed days: subtle fill. Cell hover only with a real pointer (no "stuck" hover after a tap). */
#calendar .cal-cell.cal-cell-empty,#calendar .cal-cell.cal-cell-empty:hover{background:var(--colorNeutralBackground2);border:0;min-height:0}
#calendar .cal-cell:hover,#calendar .cal-today,#calendar .cal-today:hover{border:0;background:var(--colorNeutralBackground1)}
#calendar .cal-cell.cal-offday,#calendar .cal-cell.cal-offday:hover{background:var(--colorNeutralBackground2)}
@media (hover:hover){
    #calendar .cal-cell:not(.cal-cell-empty):hover{background:var(--colorNeutralBackground1Hover)}
    #calendar .cal-cell.cal-offday:hover{background:var(--colorNeutralBackground2Hover)}
}
/* day number: a small round button (opens the day); today = filled brand circle */
#calendar .cal-cell-head{display:flex;align-items:center;min-height:var(--controlHeightSmall)}
#calendar .cal-daynum{display:inline-flex;align-items:center;justify-content:center;min-width:var(--controlHeightSmall);height:var(--controlHeightSmall);padding:0 var(--spacingHorizontalXS);border:0;border-radius:var(--borderRadiusCircular);background:transparent;color:var(--colorNeutralForeground2);font-size:var(--fontSizeBase300);line-height:var(--lineHeightBase300);font-weight:var(--fontWeightRegular);font-variant-numeric:tabular-nums;cursor:pointer;transition:background-color var(--durationFaster) var(--curveEasyEase),color var(--durationFaster) var(--curveEasyEase)}
#calendar .cal-daynum:hover{background:var(--colorBrandBackground2);color:var(--colorBrandForeground1)}
#calendar .cal-today .cal-daynum{background:var(--colorBrandBackground);color:var(--colorNeutralForegroundOnBrand);font-weight:var(--fontWeightSemibold)}
#calendar .cal-today .cal-daynum:hover{background:var(--colorBrandBackgroundHover);color:var(--colorNeutralForegroundOnBrand)}
/* event chips: tinted pills — status dot, time, name */
#calendar .cal-chips{gap:var(--spacingVerticalXXS);min-width:0}
#calendar .cal-chip{display:flex;align-items:center;gap:var(--spacingHorizontalXS);min-width:0;min-height:20px;padding:0 var(--spacingHorizontalS);border:0;border-radius:var(--borderRadiusCircular);font-size:var(--fontSizeBase200);line-height:var(--lineHeightBase200);overflow:hidden;transition:box-shadow var(--durationFaster) var(--curveEasyEase)}
#calendar .cal-chip::before{content:"";flex:0 0 auto;width:6px;height:6px;border-radius:var(--borderRadiusCircular);background:currentColor}
#calendar .cal-chip:hover{filter:none;box-shadow:inset 0 0 0 var(--strokeWidthThin) currentColor}
#calendar .cal-chip-t{flex:0 0 auto;font-weight:var(--fontWeightSemibold);font-variant-numeric:tabular-nums;unicode-bidi:isolate}
#calendar .cal-chip-n{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
#calendar .cal-chip-n i{font-size:var(--fontSizeBase100)}
#calendar .cal-more{align-self:flex-start;padding:0 var(--spacingHorizontalS);border-radius:var(--borderRadiusMedium);font-size:var(--fontSizeBase200);line-height:var(--lineHeightBase200)}
#calendar .cal-more:hover{background:var(--colorBrandBackground2);text-decoration:none}

/* ---------- Week / day timeline ---------- */
#calendar .cal-timeline{overflow-x:auto}
#calendar .cal-tl-inner{min-width:720px}
#calendar .cal-day .cal-tl-inner{min-width:0}
/* hour gutter stays put while a narrow screen scrolls the week sideways */
#calendar .cal-tl-gutter{flex:0 0 60px;position:sticky;inset-inline-start:0;z-index:6;background:var(--colorNeutralBackground1)}
#calendar .cal-tl-corner,#calendar .cal-tl-colhead{height:64px;flex:0 0 64px;border-bottom:var(--strokeWidthThin) solid var(--colorNeutralStroke2)}
#calendar .cal-tl-colhead{gap:var(--spacingVerticalXXS);font-size:var(--fontSizeBase200);line-height:var(--lineHeightBase200);font-weight:var(--fontWeightRegular);color:var(--colorNeutralForeground3)}
#calendar .cal-tl-date{display:inline-flex;align-items:center;justify-content:center;min-width:32px;height:32px;padding:0 var(--spacingHorizontalXS);border:0;border-radius:var(--borderRadiusCircular);background:transparent;font-size:var(--fontSizeBase500);line-height:var(--lineHeightBase500);font-weight:var(--fontWeightSemibold);color:var(--colorNeutralForeground1);font-variant-numeric:tabular-nums}
#calendar button.cal-tl-date{cursor:pointer;transition:background-color var(--durationFaster) var(--curveEasyEase)}
#calendar button.cal-tl-date:hover{background:var(--colorBrandBackground2);color:var(--colorBrandForeground1)}
#calendar .cal-tl-todayhead{color:var(--colorBrandForeground1);font-weight:var(--fontWeightSemibold)}
#calendar .cal-tl-todayhead .cal-tl-date,#calendar .cal-tl-todayhead button.cal-tl-date:hover{background:var(--colorBrandBackground);color:var(--colorNeutralForegroundOnBrand)}
#calendar .cal-tl-col{border-inline-start:var(--strokeWidthThin) solid var(--colorNeutralStroke2)}
#calendar .cal-tl-todaycol .cal-tl-body{background:transparent}
#calendar .cal-tl-offcol .cal-tl-body{background:var(--colorNeutralBackground2)}
/* hour lines (hairline) + a dotted half-hour line, as in Outlook */
#calendar .cal-tl-line{border-top:var(--strokeWidthThin) solid var(--colorNeutralStroke2);background-image:linear-gradient(to left,var(--colorNeutralStroke2) 50%,transparent 50%);background-size:6px 1px;background-position:0 50%;background-repeat:repeat-x}
#calendar .cal-tl-line:first-child{border-top-color:transparent}
#calendar .cal-tl-hour span{top:-8px;inset-inline-end:var(--spacingHorizontalS);font-size:var(--fontSizeBase200);line-height:var(--lineHeightBase200);color:var(--colorNeutralForeground3);font-variant-numeric:tabular-nums}
#calendar .cal-tl-corner + .cal-tl-hour span{top:var(--spacingVerticalXXS)}
/* events: tinted blocks, a hairline of the surface colour separates neighbours */
#calendar .cal-ev{border:0;border-radius:var(--borderRadiusMedium);padding:var(--spacingVerticalXXS) var(--spacingHorizontalSNudge);font-size:var(--fontSizeBase200);line-height:var(--lineHeightBase200);box-shadow:0 0 0 var(--strokeWidthThin) var(--colorNeutralBackground1);z-index:1}
#calendar .cal-ev:hover{box-shadow:inset 0 0 0 var(--strokeWidthThin) currentColor,var(--shadow8);z-index:5}
#calendar .cal-ev-time{font-weight:var(--fontWeightSemibold);font-variant-numeric:tabular-nums;unicode-bidi:isolate;white-space:nowrap}
#calendar .cal-ev-short{display:flex;align-items:center;gap:var(--spacingHorizontalXS);padding-block:0}
#calendar .cal-ev-short .cal-ev-name{min-width:0}
/* teacher busy blocks: fine hatch on a recessed fill */
#calendar .cal-break{background:repeating-linear-gradient(-45deg,var(--colorNeutralStroke2) 0 1px,transparent 1px 7px),var(--colorNeutralBackground3);border-radius:var(--borderRadiusMedium);opacity:1}
/* "now" line in today's column */
#calendar .cal-now{position:absolute;inset-inline:0;height:0;border-top:var(--strokeWidthThick) solid var(--colorStatusDangerBorder2);z-index:4;pointer-events:none}
#calendar .cal-now::before{content:"";position:absolute;inset-inline-start:-5px;top:-6px;width:10px;height:10px;border-radius:var(--borderRadiusCircular);background:var(--colorStatusDangerBorder2)}

/* ---------- Tablet / phone ---------- */
@media (max-width:768px){
    /* title at the start (right), not flex-end: the page-layout rule outranks the mobile column rule */
    #calendar .cal-pagehead{align-items:stretch}
    #calendar .cal-pagehead .cal-filters{width:100%;flex-wrap:nowrap}
    #calendar .cal-filter-icon{display:none}
    #calendar .cal-filter{flex:1 1 0;max-width:none}
    #calendar .cal-toolbar{padding:var(--spacingVerticalS) var(--spacingHorizontalM)}
    #calendar .cal-title{font-size:var(--fontSizeBase400);line-height:var(--lineHeightBase400)}
    #calendar .cal-views{width:100%}
    #calendar .cal-viewbtn{flex:1 1 0}
    #calendar .cal-cell{min-height:92px}
    #calendar .cal-legend{padding:var(--spacingVerticalS) var(--spacingHorizontalM);gap:var(--spacingVerticalXS) var(--spacingHorizontalM)}
    #calendar .cal-tl-inner{min-width:560px}
    #calendar .cal-tl-gutter{flex-basis:52px}
}
@media (max-width:640px){
    /* month: short weekday names, centred day numbers, time-only chips */
    #calendar .cal-dow-long{display:none}
    #calendar .cal-dow-short{display:inline}
    #calendar .cal-dow{padding:var(--spacingVerticalS) 0;text-align:center;font-size:var(--fontSizeBase100);line-height:var(--lineHeightBase100)}
    #calendar .cal-cell{min-height:76px;padding:var(--spacingVerticalXXS)}
    #calendar .cal-cell-head{justify-content:center}
    #calendar .cal-daynum{font-size:var(--fontSizeBase200)}
    #calendar .cal-chip{justify-content:center;min-height:18px;padding:0 var(--spacingHorizontalXXS);font-size:var(--fontSizeBase100);line-height:var(--lineHeightBase100)}
    #calendar .cal-chip::before,#calendar .cal-chip-n{display:none}
    #calendar .cal-more{align-self:stretch;padding:0;text-align:center;font-size:var(--fontSizeBase100);line-height:var(--lineHeightBase100)}
    #calendar .cal-more-l{display:none}
    #calendar .cal-todaybtn i{display:none}
    #calendar .cal-title{font-size:var(--fontSizeBase300);line-height:var(--lineHeightBase300);white-space:normal}
    #calendar .cal-tl-gutter{flex-basis:48px}
    #calendar .cal-tl-hour span{inset-inline-end:var(--spacingHorizontalXS)}
    #calendar .cal-tl-date{min-width:28px;height:28px;font-size:var(--fontSizeBase400);line-height:var(--lineHeightBase400)}
}
@media (pointer:coarse){
    #calendar .cal-todaybtn{height:var(--controlHeightLarge)}
    #calendar .cal-navbtn{min-width:var(--controlHeightLarge);height:var(--controlHeightLarge)}
    #calendar .cal-viewbtn{height:34px}
}
@media (forced-colors:active){
    #calendar .cal-viewbtn.active{outline:var(--strokeWidthThick) solid Highlight}
    #calendar .cal-today .cal-daynum,#calendar .cal-tl-todayhead .cal-tl-date{forced-color-adjust:none;background:Highlight;color:HighlightText}
    #calendar .cal-chip,#calendar .cal-ev{border:var(--strokeWidthThin) solid CanvasText}
}

/* ============================================================
   Lesson detail dialog (openLessonDetail → shared #modal).
   Fluent Dialog: summary (who + status), key/value list, actions at the end.
   ============================================================ */
#modal .modal-content:has(.cal-detail){max-width:560px}
#modalBody .cal-detail{display:block;margin:0}
#modalBody .cal-detail-head{display:flex;align-items:center;justify-content:space-between;gap:var(--spacingHorizontalM);padding:var(--spacingVerticalXS) 0 var(--spacingVerticalL)}
#modalBody .cal-detail-who{display:flex;align-items:center;gap:var(--spacingHorizontalM);min-width:0}
#modalBody .cal-detail-avatar{flex:0 0 auto;display:inline-flex;align-items:center;justify-content:center;width:40px;height:40px;border-radius:var(--borderRadiusCircular);font-size:var(--fontSizeBase400)}
#modalBody .cal-detail-name{display:flex;flex-direction:column;min-width:0}
#modalBody .cal-detail-cap{font-size:var(--fontSizeBase200);line-height:var(--lineHeightBase200);color:var(--colorNeutralForeground3)}
#modalBody .cal-detail-title{font-size:var(--fontSizeBase400);line-height:var(--lineHeightBase400);font-weight:var(--fontWeightSemibold);color:var(--colorNeutralForeground1);overflow-wrap:anywhere}
#modalBody .cal-detail-badge{flex:0 0 auto;align-self:center;margin:0;padding:var(--spacingVerticalXXS) var(--spacingHorizontalS);border-radius:var(--borderRadiusCircular);font-size:var(--fontSizeBase200);line-height:var(--lineHeightBase200);font-weight:var(--fontWeightSemibold);white-space:nowrap}
#modalBody .cal-detail-list{margin:0;border-top:var(--strokeWidthThin) solid var(--colorNeutralStroke2)}
#modalBody .cal-detail-row{display:flex;align-items:flex-start;gap:var(--spacingHorizontalM);min-height:44px;margin:0;padding:var(--spacingVerticalMNudge) 0;border-bottom:var(--strokeWidthThin) solid var(--colorNeutralStroke2);font-size:var(--fontSizeBase300);line-height:var(--lineHeightBase300)}
#modalBody .cal-detail-row:last-child{border-bottom:0}
#modalBody .cal-detail-k{flex:0 0 132px;display:flex;align-items:center;gap:var(--spacingHorizontalS);margin:0;color:var(--colorNeutralForeground3);font-weight:var(--fontWeightRegular)}
#modalBody .cal-detail-k i{width:16px;text-align:center;font-size:var(--fontSizeBase300);color:var(--colorNeutralForeground3)}
#modalBody .cal-detail-v{flex:1 1 auto;min-width:0;margin:0;color:var(--colorNeutralForeground1);font-weight:var(--fontWeightRegular);text-align:start;overflow-wrap:anywhere;white-space:pre-line;font-variant-numeric:tabular-nums}
#modalBody .cal-detail-link{display:inline-flex;align-items:center;gap:var(--spacingHorizontalXS);color:var(--colorBrandForegroundLink);font-weight:var(--fontWeightSemibold);text-decoration:none}
#modalBody .cal-detail-link:hover{color:var(--colorBrandForegroundLinkHover);text-decoration:underline}
#modalBody .cal-detail-actions{display:flex;flex-wrap:wrap;justify-content:flex-end;gap:var(--spacingHorizontalS);margin-top:var(--spacingVerticalXL)}
/* destructive action apart, at the start of the row: secondary button with a red icon, red tint on hover */
#modalBody .cal-act-delete{order:-1;margin-inline-end:auto}
#modalBody .cal-act-delete i{color:var(--colorStatusDangerForeground1)}
#modalBody .cal-act-delete:hover{background:var(--tint-danger-bg);border-color:var(--tint-danger-border);color:var(--colorNeutralForeground1)}
@media (max-width:480px){
    #modalBody .cal-detail-head{flex-wrap:wrap}
    #modalBody .cal-detail-k{flex-basis:104px}
    #modalBody .cal-detail-actions .btn{flex:1 1 auto}
}

/* Touch screens: day numbers are real buttons with a full tap area (UX_PLAN 5). */
@media (pointer:coarse){#calendar .cal-daynum{min-width:var(--touchTarget);min-height:var(--touchTarget)}}

/* UX pass: lessons are real buttons showing their state in words; a visible line says how to open a day. */
#calendar .cal-hint{display:flex;align-items:center;gap:var(--spacingHorizontalS);margin:0;padding:var(--spacingVerticalS) var(--spacingHorizontalL);font-size:var(--fontSizeBase200);line-height:var(--lineHeightBase200);color:var(--colorNeutralForeground2)}
#calendar button.cal-chip,#calendar button.cal-ev,#calendar button.cal-more{font-family:inherit;text-align:start;cursor:pointer}
#calendar button.cal-chip{width:100%}
#calendar button.cal-more{border:0;background:transparent;color:var(--colorBrandForegroundLink)}
#calendar button.cal-ev{display:flex;flex-direction:column;align-items:stretch;overflow:hidden}
#calendar button.cal-ev.cal-ev-short{flex-direction:row;align-items:center}
#calendar .cal-chip-s{flex:0 0 auto;margin-inline-start:auto;font-size:var(--fontSizeBase100);font-weight:var(--fontWeightSemibold);white-space:nowrap}
#calendar .cal-ev-time,#calendar .cal-ev-name{display:block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
#calendar .cal-break-l{display:block;padding:var(--spacingVerticalXXS) var(--spacingHorizontalS);font-size:var(--fontSizeBase100);color:var(--colorNeutralForeground3);overflow:hidden;white-space:nowrap}
@media(max-width:640px){#calendar .cal-chip-s{display:none}}

/* Touch screens: every lesson and calendar control is a 44px target (mobile review). Month chips are 44px tall (two a
   day, then «+N»); the week/day timelines draw taller hours and a 44px minimum per lesson (app.js#calTimelineHtml). */
@media (pointer:coarse){
    #calendar .cal-chip,#calendar .cal-more{min-height:var(--touchTarget)}
    #calendar .cal-tl-date{min-width:var(--touchTarget);min-height:var(--touchTarget)}
    #calendar .cal-navbtn,#calendar .cal-todaybtn{height:var(--touchTarget);min-width:var(--touchTarget)}
}
/* narrow touch screens: the month chips use the whole day column, so they are 44px wide too */
@media (pointer:coarse) and (max-width:640px){#calendar .cal-cell{padding-inline:0}}
