/* House Lights: the 4.0 look, layered over style.css.
   ----------------------------------------------------
   style.css already holds the 2.0 dark house palette. House Lights keeps it
   and adds what the 4.0 design guideline asks for on top: named motion and
   spacing tokens, one focus ring, quick press and state feedback, and the
   phone section bars (staff and student). Screen-to-screen motion lives in
   motion.css, which a kiosk, a check-in screen or a TV board leaves out.
   See docs/DESIGN_GUIDELINE.md sections 6 and 7, and
   docs/4.0/aesthetics-research.md for where each value comes from. */

:root {
  /* Motion. Press is felt, state is seen, screen is a change of place. */
  --ease: cubic-bezier(.2,.8,.2,1);
  --dur-press: 100ms; --dur-state: 180ms; --dur-screen: 320ms;
  /* Spacing steps, so new pages stop inventing their own. */
  --s1: 4px; --s2: 8px; --s3: 16px; --s4: 24px; --s5: 32px;
  --fs-sm: .875rem;
  /* Control borders need 3:1 against their surface (WCAG 1.4.11): 4.1:1 on
     the dark panel, 4.0:1 on the light one. */
  --ctl: #77777F;
  --tabbar-h: 58px;
}
@media (prefers-color-scheme: light) { html:not([data-theme]) { --ctl: #7C8088; } }
html[data-theme="light"] { --ctl: #7C8088; }
html[data-theme="contrast"] { --ctl: #ffffff; }

/* One focus ring everywhere: 3px in the focus colour, set off the control so
   it never sits on a fill. Fields keep theirs flush with the edge. */
button:focus-visible, .btn-link:focus-visible, a:focus-visible, summary:focus-visible,
[tabindex]:focus-visible { outline-width: 3px; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline-width: 3px; }
/* A page title takes focus after a screen change so a screen reader hears
   where it landed; it needs no ring for that. */
h1[tabindex="-1"]:focus { outline: none; }

/* Press and state feedback: a press answers at once, a colour change eases. */
button, .btn-link {
  transition: background-color var(--dur-state) var(--ease), border-color var(--dur-state) var(--ease),
    color var(--dur-state) var(--ease), opacity var(--dur-state) var(--ease),
    transform var(--dur-press) var(--ease), box-shadow var(--dur-state) var(--ease);
}
.btn-link.primary, button.primary { font-weight: 600; }

/* Times read in the call-sheet voice: mono, tabular. */
.time, .mono, time { font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------------------
   Staff phone section bar. Rendered by base.html for an ordinary staff
   account; shown only in the phone layout, where the eight links otherwise sit
   behind the menu button. Four sections and Menu, always under the thumb. */
.hl-tabbar { display: none; }
html[data-view="phone"] .hl-tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 1001;
  display: flex; background: var(--surface); border-top: 1px solid var(--line);
  padding: 0 env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
.hl-tabbar a, .hl-tabbar button {
  position: relative; flex: 1 1 0; min-width: 0; min-height: var(--tabbar-h);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  margin: 0; padding: 4px 2px; border: 0; border-radius: 0; background: none; box-shadow: none;
  color: var(--muted); font: 600 max(12px, .75rem)/1.2 inherit; text-decoration: none;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.hl-tabbar a:hover, .hl-tabbar button:hover { background: var(--hover); text-decoration: none; }
.hl-tabbar [aria-current], .hl-tabbar button[aria-expanded="true"] { color: var(--text); }
.hl-tabbar [aria-current]::before {
  content: ""; position: absolute; top: -1px; left: 28%; right: 28%; height: 3px;
  border-radius: 0 0 3px 3px; background: var(--text);
}
.hl-tabbar .icon { transition: transform var(--dur-press) var(--ease); }
.hl-tabbar a:active .icon, .hl-tabbar button:active .icon { transform: scale(.88); }
.hl-tabbar a:active, .hl-tabbar button:active { transform: none; }
.hl-tabbar a:focus-visible, .hl-tabbar button:focus-visible { outline-offset: -3px; border-radius: 0; }
/* The bar covers the bottom of the page, so the page ends above it. */
html[data-view="phone"] body.has-tabbar .app-footer {
  padding-bottom: calc(var(--tabbar-h) + 2rem + env(safe-area-inset-bottom)); }
html[data-view="phone"] body.has-tabbar main { padding-bottom: calc(var(--tabbar-h) + 1rem); }
/* With the bar there, the top menu button is a second way to the same sheet. */
html[data-view="phone"] body.has-tabbar .nav-toggle { display: none; }
/* Floating things that sat on the bottom edge move up above the bar. */
html[data-view="phone"] body.has-tabbar .toast,
html[data-view="phone"] body.has-tabbar .save-bar { bottom: calc(var(--tabbar-h) + 12px + env(safe-area-inset-bottom)); }

/* ---------------------------------------------------------------------------
   Student portal sections. On a laptop: one row of tabs under the header,
   always in view. On a phone: the same sections in a bar at the bottom. The
   once-in-a-while pages sit under More, which says where you are when you are
   inside one of them. */
/* portal.css loads after this file, so these rules name nav.portal-tabs to
   win over its plain .portal-tabs ones. */
nav.portal-tabs { overflow: visible; }
/* A tab's markup holds only its label; on a phone its icon is drawn above
   the label from these masks (the same strokes as _icons.html). */
.portal-i-calendar { --hl-ico: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.7' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3.4' y='5.2' width='17.2' height='15.6' rx='2.2'/%3E%3Cpath d='M3.4 10.2h17.2M8 3.2v4M16 3.2v4'/%3E%3C/svg%3E"); }
.portal-i-hammer { --hl-ico: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.7' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12.8 8.9 4.9 16.8a2.2 2.2 0 0 0 3.1 3.1l7.9-7.9'/%3E%3Cpath d='M10.2 5.9h7.4a2.2 2.2 0 0 1 2.2 2.2v1.8a2.2 2.2 0 0 1-2.2 2.2h-7.4Z'/%3E%3C/svg%3E"); }
.portal-i-ticket { --hl-ico: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.7' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3.4 8.6V6.4a1.6 1.6 0 0 1 1.6-1.6h14a1.6 1.6 0 0 1 1.6 1.6v2.2a3.4 3.4 0 0 0 0 6.8v2.2a1.6 1.6 0 0 1-1.6 1.6H5a1.6 1.6 0 0 1-1.6-1.6v-2.2a3.4 3.4 0 0 0 0-6.8Z'/%3E%3Cpath d='M14 5.4v13.2'/%3E%3C/svg%3E"); }
.portal-i-box { --hl-ico: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.7' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m12 2.8 8.4 4.4v9.6L12 21.2 3.6 16.8V7.2Z'/%3E%3Cpath d='M3.6 7.2 12 11.6l8.4-4.4M12 11.6v9.6'/%3E%3C/svg%3E"); }
.portal-i-list { --hl-ico: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.7' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M8 6h13M8 12h13M8 18h13M3.6 6h.01M3.6 12h.01M3.6 18h.01'/%3E%3C/svg%3E"); }
.portal-more > summary {
  flex: 1; min-height: 46px; justify-content: center; padding: 8px 12px; white-space: nowrap;
  border-radius: var(--control-radius); color: var(--muted); font-weight: 400;
}
.portal-more.is-current > summary { background: var(--selected); color: var(--text); box-shadow: inset 0 -2px var(--accent); }
nav.portal-tabs .portal-more-menu a { flex: none; justify-content: space-between; min-height: 44px; padding: 0 12px; color: var(--text); font-weight: 600; box-shadow: none; }
nav.portal-tabs .portal-more-menu a[aria-current="page"] { background: var(--selected); }
.portal-more { position: relative; display: flex; }
.portal-more > summary {
  display: inline-flex; align-items: center; gap: 4px; cursor: pointer; list-style: none;
  user-select: none;
}
.portal-more > summary::-webkit-details-marker { display: none; }
.portal-more-menu {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 60; min-width: 220px;
  display: grid; padding: 6px; background: var(--panel-raised); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-float);
}
.portal-more-menu a {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  min-height: 44px; padding: 0 12px; border-radius: var(--control-radius);
  color: var(--text); font-weight: 600; text-decoration: none; white-space: nowrap;
}
.portal-more-menu a:hover { background: var(--hover); text-decoration: none; }
.portal-more-menu a[aria-current="page"] { background: var(--selected); }
.portal-more[open] > summary { color: var(--text); }
.portal-more-menu { animation: hl-pop var(--dur-state) var(--ease) both; }

@media (max-width: 720px) {
  nav.portal-tabs {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 50; margin: 0;
    display: flex; gap: 0; overflow: visible; background: var(--surface);
    border: 0; border-top: 1px solid var(--line); border-radius: 0;
    padding: 0 env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  }
  nav.portal-tabs > a, nav.portal-tabs .portal-more > summary {
    position: relative; flex: 1 1 0; min-width: 0; min-height: var(--tabbar-h);
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    margin: 0; padding: 4px 2px; border: 0; border-radius: 0; background: none;
    color: var(--muted); font-size: max(12px, .75rem); font-weight: 600; white-space: nowrap;
  }
  .portal-more { flex: 1 1 0; min-width: 0; }
  .portal-more > summary { width: 100%; }
  nav.portal-tabs > a::after, nav.portal-tabs .portal-more > summary::after {
    content: ""; order: -1; width: 22px; height: 22px; flex: none;
    background: currentColor; -webkit-mask: var(--hl-ico) center / contain no-repeat; mask: var(--hl-ico) center / contain no-repeat;
  }
  nav.portal-tabs > a[aria-current="page"], nav.portal-tabs .portal-more.is-current > summary { color: var(--text); background: none; box-shadow: none; }
  .portal-tabs > a[aria-current="page"]::before, .portal-more.is-current > summary::before {
    content: ""; position: absolute; top: -1px; left: 28%; right: 28%; height: 3px;
    border-radius: 0 0 3px 3px; background: var(--text);
  }
  .portal-more-caret { display: none; }
  .portal-more-menu { top: auto; bottom: calc(100% + 8px); right: 8px; }
  .portal-tabs > a:focus-visible, .portal-more > summary:focus-visible { outline-offset: -3px; border-radius: 0; }
  body .portal-container { padding-bottom: calc(var(--tabbar-h) + 24px + env(safe-area-inset-bottom)); }
}

/* ---------------------------------------------------------------------------
   "Right now": the one thing that is on, at the top of a student's Today.
   It takes the rainbow edge, which a screen uses for what is live and for the
   strip under the header, and nothing else. */
.right-now {
  position: relative; display: grid; gap: 4px; margin: 0 0 var(--s4);
  padding: 16px 18px 16px 22px; background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden;
}
.right-now::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--rainbow-v); }
.right-now-label {
  justify-self: start; display: inline-flex; align-items: center; padding: 2px 9px;
  border-radius: 999px; background: var(--ink-fill); color: var(--ink-on);
  font-size: var(--fs-sm); font-weight: 700;
}
.right-now-title { margin: 6px 0 0; font-size: 1.35rem; font-weight: 800; line-height: 1.2; }
.right-now-sub { margin: 0; color: var(--muted); }
.right-now-next { margin: 4px 0 0; font-size: var(--fs-sm); color: var(--muted); }
.right-now-time { font-family: var(--mono); color: var(--text); }

@keyframes hl-pop { from { opacity: 0; transform: translateY(4px) scale(.98); } }
@media (prefers-reduced-motion: reduce) {
  button, .btn-link, .hl-tabbar .icon { transition: none; }
  .portal-more-menu { animation: none; }
}

/* Opened from the section bar's Menu, the sheet rises from the bottom, next to
   the thumb that opened it, instead of dropping from the top bar. */
html[data-view="phone"] body.has-tabbar .topbar .links {
  position: fixed; top: auto; bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  max-height: 72vh; max-height: 72dvh;
  border-top: 1px solid var(--line); border-bottom: 0; border-radius: var(--radius) var(--radius) 0 0;
  box-shadow: 0 -18px 40px rgba(0,0,0,.4);
}
html[data-view="phone"] body.has-tabbar .topbar .links.open { animation: hl-sheet var(--dur-state) var(--ease) both; }
@keyframes hl-sheet { from { opacity: 0; transform: translateY(12px); } }
@media (prefers-reduced-motion: reduce) { html[data-view="phone"] body.has-tabbar .topbar .links.open { animation: none; } }
