/* =====================================================================
   Layout: header, sections, page heads, footer, phone navigation, and
   the transitions between sections.
   ===================================================================== */

/* ----------------------------------------------------------- header -- */
.topbar{
  position: sticky;
  top: 0;
  z-index: var(--z-header);
  background: color-mix(in srgb, var(--bg) 84%, transparent);
  -webkit-backdrop-filter: blur(14px) saturate(1.3);
  backdrop-filter: blur(14px) saturate(1.3);
  border-bottom: 1px solid transparent;
  transition: border-color var(--t) var(--ease), box-shadow var(--t) var(--ease), background var(--t) var(--ease);
  view-transition-name: topbar;
}
/* a thin progress line under the header shows how far down the page you are */
.topbar::after{
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: -1px;
  height: 2px;
  background: linear-gradient(90deg, var(--brand), var(--now));
  transform-origin: 0 50%;
  transform: scaleX(0);
  opacity: 0;
  pointer-events: none;
}
@supports (animation-timeline: scroll()){
  html:not(.reduce-motion) .topbar::after{ opacity: 1; animation: readLine linear both; animation-timeline: scroll(root); }
}
@keyframes readLine{ to{ transform: scaleX(1); } }
body.scrolled .topbar{
  border-bottom-color: var(--line);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  box-shadow: 0 8px 24px -22px rgba(28, 24, 48, .5);
}
.topbar-inner{
  max-width: var(--page-max);
  margin: 0 auto;
  height: var(--header-h);
  padding: 0 20px;
  display: flex;
  align-items: center;
  gap: 18px;
}

.brand{
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--ink);
  flex: none;
  border-radius: 12px;
}
.brand-mark{
  width: 40px; height: 40px;
  display: grid; place-items: center;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--sh-1);
  transition: transform var(--t) var(--spring);
}
.brand-mark img{ width: 28px; height: 28px; }
.brand:hover .brand-mark{ transform: rotate(-6deg) scale(1.05); }
.brand-txt{ display: flex; flex-direction: column; line-height: 1; }
.brand-txt b{
  font-family: var(--display);
  font-size: 1.32rem;
  font-weight: 800;
  letter-spacing: -.03em;
  color: var(--brand-ink);
}
.brand-txt small{
  font-size: .72rem;
  font-weight: 600;
  color: var(--ink-3);
  letter-spacing: .02em;
  margin-top: 3px;
}

/* the section switcher: a marker line slides under the active one */
nav.tabs{
  position: relative;
  display: flex;
  align-items: center;
  gap: 2px;
  margin: 0 auto;
  padding: 4px;
}
nav.tabs button{
  position: relative;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 40px;
  padding: 0 12px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--ink-3);
  font-weight: 650;
  font-size: .92rem;
  white-space: nowrap;
  transition: color var(--t-fast) var(--ease), background var(--t-fast) var(--ease);
}
nav.tabs button .ic{ width: 18px; height: 18px; }
nav.tabs button:hover{ color: var(--ink); background: var(--surface-3); }
nav.tabs button.active{ color: var(--brand-ink); }
nav.tabs button.active .ic{ stroke-width: 2.1; }
.tab-ink{
  position: absolute;
  left: 0;
  bottom: 1px;
  height: 3px;
  width: var(--ink-w, 0px);
  transform: translateX(var(--ink-x, 0px));
  border-radius: 3px;
  background: var(--brand);
  transition: transform .42s var(--ease-out), width .42s var(--ease-out);
}
.tab-count{
  min-width: 18px; height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--now);
  color: #fff;
  font-size: .68rem;
  font-weight: 800;
  line-height: 18px;
  text-align: center;
}

.hdr-right{ display: flex; align-items: center; gap: 6px; flex: none; }
.hdr-search{ width: auto !important; padding: 0 10px 0 11px !important; gap: 8px; }
.hdr-search .hs-lbl{ font-size: .88rem; font-weight: 600; color: var(--ink-3); }
.hdr-search kbd{ margin-left: 6px; }
.me-btn{
  width: 40px; height: 40px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  display: grid; place-items: center;
}
.me-btn .avatar{ --av: 38px; box-shadow: 0 0 0 2px var(--surface), 0 0 0 3.5px var(--line-strong); transition: box-shadow var(--t) var(--ease); }
.me-btn:hover .avatar{ box-shadow: 0 0 0 2px var(--surface), 0 0 0 3.5px var(--brand); }
.auth-who{ font-size: .85rem; color: var(--ink-3); }

/* ------------------------------------------------------- sidebar --
   On computers the header becomes a sidebar: grouped sections that always
   fit, whatever the screen width or zoom. It can shrink to an icon rail
   ([ key, or the arrow at the bottom), and does so on its own on narrow
   laptops. Phones keep the top bar and the bottom nav. */
.side-search, .nav-group, .topbar .rail-btn{ display: none; }
@media (min-width: 901px){
  :root{ --side-w: 244px; }
  html[data-rail="on"]{ --side-w: 78px; }
  body{ padding-left: var(--side-w); }
  html.booted body{ transition: padding-left .32s var(--ease-out); }
  .topbar{
    position: fixed;
    left: 0; top: 0; bottom: 0;
    width: var(--side-w);
    border-bottom: 0;
    border-right: 1px solid var(--line);
    background: color-mix(in srgb, var(--surface) 82%, transparent);
    transition: width .32s var(--ease-out);
  }
  body.scrolled .topbar{ border-bottom-color: transparent; box-shadow: none; background: color-mix(in srgb, var(--surface) 82%, transparent); }
  .topbar::after{ left: 100%; right: auto; width: 2px; height: 100%; bottom: auto; top: 0; transform-origin: 50% 0; transform: scaleY(0); }
  @keyframes readLine{ to{ transform: scaleY(1); } }
  .topbar-inner{
    height: 100%;
    max-width: none;
    margin: 0;
    padding: 18px 12px 12px;
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: none;
  }
  .topbar-inner::-webkit-scrollbar{ display: none; }
  .brand{ padding: 0 6px 10px; }
  .side-search{
    display: flex;
    flex: none;
    align-items: center;
    gap: 9px;
    height: 40px;
    padding: 0 10px 0 12px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--surface-2);
    color: var(--ink-3);
    font-size: .88rem;
    font-weight: 600;
    text-align: left;
    transition: border-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
  }
  .side-search:hover{ border-color: var(--brand-line); color: var(--ink); }
  .side-search .ic{ width: 17px; height: 17px; flex: none; }
  .side-search span{ flex: 1; }
  .side-search kbd{ font-size: .68rem; }
  .hdr-search{ display: none !important; }
  nav.tabs{ flex-direction: column; align-items: stretch; margin: 6px 0 0; padding: 0; gap: 2px; }
  nav.tabs .tab-ink{ display: none; }
  nav.tabs button{
    justify-content: flex-start;
    gap: 12px;
    height: 40px;
    padding: 0 12px;
    font-size: .93rem;
    text-align: left;
  }
  nav.tabs button .ic{ display: block !important; width: 19px; height: 19px; flex: none; }
  nav.tabs button .lbl{ flex: 1; }
  nav.tabs button.active{ background: var(--brand-soft); color: var(--brand-ink); }
  nav.tabs button.active::before{
    content: "";
    position: absolute;
    left: -12px; top: 9px; bottom: 9px;
    width: 4px;
    border-radius: 0 4px 4px 0;
    background: var(--brand);
    animation: navMark .35s var(--spring) both;
  }
  @keyframes navMark{ from{ transform: scaleY(0); } }
  nav.tabs .tab-count{ margin-left: auto; }
  .nav-group{ display: block; padding: 16px 12px 5px; font-size: .68rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-4); white-space: nowrap; }
  .hdr-right{
    margin-top: auto;
    padding-top: 12px;
    border-top: 1px solid var(--line);
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
  }
  .hdr-right .auth-btn{ flex: 1; justify-content: center; }
  .topbar .rail-btn{ display: grid; margin-left: auto; }
  .rail-btn .ic{ transition: transform .32s var(--ease-out); }
  /* the chat has its own place in the sidebar, so the floating button goes */
  body .chat-fab{ display: none; }
  body .to-top{ bottom: 24px; }
  html[data-chat="left"] .messenger{ left: calc(var(--side-w) + 16px); }
  body .custom-bar{ left: calc(50% + var(--side-w) / 2); }
}
/* the icon rail: chosen, or automatic on narrow laptops */
@media (min-width: 901px) and (max-width: 1099px){ :root{ --side-w: 78px; } }
@media (min-width: 901px){
  html[data-rail="on"] .topbar-inner{ padding: 18px 10px 12px; align-items: center; }
  html[data-rail="on"] .brand-txt,
  html[data-rail="on"] nav.tabs .lbl,
  html[data-rail="on"] .side-search span,
  html[data-rail="on"] .side-search kbd,
  html[data-rail="on"] .nav-group span{ display: none; }
  html[data-rail="on"] .brand{ padding: 0 0 10px; }
  html[data-rail="on"] .side-search{ width: 44px; padding: 0; justify-content: center; }
  html[data-rail="on"] nav.tabs{ align-items: center; }
  html[data-rail="on"] nav.tabs button{ width: 48px; padding: 0; justify-content: center; }
  html[data-rail="on"] nav.tabs button.active::before{ left: -10px; }
  html[data-rail="on"] nav.tabs .tab-count{ position: absolute; top: 3px; right: 2px; min-width: 16px; height: 16px; line-height: 16px; font-size: .62rem; }
  html[data-rail="on"] .nav-group{ width: 28px; height: 1px; padding: 0; margin: 12px auto 8px; background: var(--line-strong); }
  html[data-rail="on"] .hdr-right{ flex-direction: column; flex-wrap: nowrap; }
  html[data-rail="on"] .hdr-right .auth-btn{ padding: 0 10px; font-size: .75rem; }
  html[data-rail="on"] .rail-btn{ margin: 0; }
  html[data-rail="on"] .rail-btn .ic{ transform: rotate(180deg); }
}
/* short laptop screens: tighten the sidebar so it all fits without scrolling */
@media (min-width: 901px) and (max-height: 760px){
  .topbar-inner{ padding-top: 12px; gap: 4px; }
  .brand{ padding-bottom: 4px; }
  .brand-mark{ width: 34px; height: 34px; }
  nav.tabs button{ height: 35px; }
  .nav-group{ padding-top: 10px; padding-bottom: 3px; }
  .side-search{ height: 36px; }
  html[data-rail="on"] .side-search{ width: 40px; height: 36px; }
  html[data-rail="on"] .nav-group{ margin: 7px auto 5px; }
  .hdr-right{ padding-top: 8px; }
  .hdr-right .icon-btn{ width: 36px; height: 36px; }
}
@media (min-width: 901px) and (max-width: 1099px) and (max-height: 760px){ .nav-group{ margin: 7px auto 5px; } }
@media (min-width: 901px) and (max-width: 1099px){
  .topbar-inner{ padding: 18px 10px 12px; align-items: center; }
  .brand-txt, nav.tabs .lbl, .side-search span, .side-search kbd, .nav-group span{ display: none; }
  .brand{ padding: 0 0 10px; }
  .side-search{ width: 44px; padding: 0; justify-content: center; }
  nav.tabs{ align-items: center; }
  nav.tabs button{ width: 48px; padding: 0; justify-content: center; }
  nav.tabs button.active::before{ left: -10px; }
  nav.tabs .tab-count{ position: absolute; top: 3px; right: 2px; min-width: 16px; height: 16px; line-height: 16px; font-size: .62rem; }
  .nav-group{ width: 28px; height: 1px; padding: 0; margin: 12px auto 8px; background: var(--line-strong); }
  .hdr-right{ flex-direction: column; flex-wrap: nowrap; }
  .hdr-right .auth-btn{ padding: 0 10px; font-size: .75rem; }
  .topbar .rail-btn{ display: none; }
}

/* ---------------------------------------------------- notice bars -- */
.notice-bar{
  max-width: var(--page-max);
  margin: 10px auto 0;
  padding: 0 20px;
}
.notice-bar .inner{
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  border-radius: var(--r-ctl);
  background: var(--warn-soft);
  color: var(--ink);
  border: 1px solid color-mix(in srgb, var(--warn) 30%, transparent);
  font-size: .92rem;
}
.notice-bar.banner .inner{
  background: var(--brand-soft);
  border-color: var(--brand-line);
}
.notice-bar .txt{ flex: 1; }
.notice-bar .ic{ color: var(--brand-ink); }

/* ------------------------------------------------------------ page -- */
main.wrap{
  max-width: var(--page-max);
  margin: 0 auto;
  padding: 26px 20px 90px;
  view-transition-name: main;
}
html.booted main.wrap{ animation: pageIn .5s var(--ease-out) both; }
@keyframes pageIn{ from{ opacity: 0; transform: translateY(8px); } to{ opacity: 1; transform: none; } }

section.panel{ display: none; }
section.panel.active{ display: block; }
html:not(.vt-active) section.panel.active{ animation: panelIn .42s var(--ease-out) both; }
@keyframes panelIn{ from{ opacity: 0; transform: translateY(10px); } to{ opacity: 1; transform: none; } }

/* every section except Today opens with the same head */
.page-head{
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
  margin: 6px 0 22px;
}
.page-head h1{
  position: relative;
  display: inline-block;
  font-size: clamp(2.3rem, 4.6vw, 3.4rem);
  font-weight: 800;
  letter-spacing: -.035em;
  line-height: 1.02;
  padding-bottom: 10px;
}
/* a quick marker stroke under the title, drawn when the section opens */
.page-head h1::after{
  content: "";
  position: absolute;
  left: 2px;
  bottom: 0;
  width: min(100%, 150px);
  height: 10px;
  background: var(--now);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 150 10' preserveAspectRatio='none'%3E%3Cpath d='M2 6.5C30 3 62 2.6 90 4.4c20 1.3 38 .6 58-1.6' fill='none' stroke='black' stroke-width='4' stroke-linecap='round'/%3E%3C/svg%3E") center / 100% 100% no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 150 10' preserveAspectRatio='none'%3E%3Cpath d='M2 6.5C30 3 62 2.6 90 4.4c20 1.3 38 .6 58-1.6' fill='none' stroke='black' stroke-width='4' stroke-linecap='round'/%3E%3C/svg%3E") center / 100% 100% no-repeat;
  clip-path: inset(0 100% 0 0);
  animation: markerDraw .7s .15s var(--ease-out) forwards;
}
section.panel.active .page-head h1::after{ animation-name: markerDraw; }
@keyframes markerDraw{ to{ clip-path: inset(0 0 0 0); } }
.page-sub{
  margin: 10px 0 0;
  max-width: 62ch;
  color: var(--ink-2);
  font-size: 1.02rem;
}
.page-actions{ display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ---------------------------------------------------------- footer -- */
.site-foot{
  max-width: var(--page-max);
  margin: 0 auto;
  padding: 22px 20px 40px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  color: var(--ink-3);
  font-size: .86rem;
}
/* over a campus photo the credits get a pane of their own so they stay readable */
html.campus-on .site-foot{ margin-bottom: 28px; border-radius: 18px; background: color-mix(in srgb, var(--surface) 80%, transparent); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); padding: 18px 22px; width: calc(100% - 40px); }
html.campus-on.lite .site-foot{ background: var(--surface); }
.site-foot .credits{ display: flex; align-items: center; gap: 12px; max-width: 70ch; }
.site-foot .credits b{ display: block; color: var(--ink-2); font-family: var(--display); }
.site-foot .credits img{ opacity: .9; }
.site-foot .foot-photo{ display: block; margin-top: 4px; font-size: .78rem; color: var(--ink-3); }
.site-foot .foot-photo a{ color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.site-foot .foot-photo a:hover{ color: var(--ink-2); }
.site-foot .foot-photo .linkbtn{ display: inline; padding: 0; min-height: 0; font: inherit; color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.foot-actions{ display: flex; gap: 14px; }

/* ------------------------------------------------------- bottom nav -- */
.bottom-nav{ display: none; }

/* ---------------------------------------------- section transitions -- */
/* A directional glide between sections: forward slides left, back slides
   right. The header stays put. */
/* The old section steps back and blurs out of focus; the new one glides in
   from the side it lives on and comes into focus. */
::view-transition-old(main){ animation: vtOut .26s cubic-bezier(.4, 0, 1, 1) both; }
::view-transition-new(main){ animation: vtIn .55s cubic-bezier(.16, 1, .3, 1) both; }
html[data-dir="back"]::view-transition-old(main){ animation-name: vtOutBack; }
html[data-dir="back"]::view-transition-new(main){ animation-name: vtInBack; }
@keyframes vtOut{ to{ opacity: 0; transform: translateX(-30px) scale(.985); filter: blur(6px); } }
@keyframes vtIn{ from{ opacity: 0; transform: translateX(46px) scale(.99); filter: blur(8px); } }
@keyframes vtOutBack{ to{ opacity: 0; transform: translateX(30px) scale(.985); filter: blur(6px); } }
@keyframes vtInBack{ from{ opacity: 0; transform: translateX(-46px) scale(.99); filter: blur(8px); } }
::view-transition-old(topbar), ::view-transition-new(topbar){ animation: none; }

/* the light/dark switch is a circular wipe of the whole page, so nothing
   else should run its own transition at the same time */
html.theme-swap main.wrap,
html.theme-swap .topbar,
html.theme-swap .bottom-nav{ view-transition-name: none !important; }
html.theme-swap::view-transition-old(root),
html.theme-swap::view-transition-new(root){ animation: none; mix-blend-mode: normal; }

/* ------------------------------------------------------- responsive -- */

@media (max-width: 900px){
  :root{ --bottom-h: calc(66px + env(safe-area-inset-bottom)); --header-h: 58px; }
  nav.tabs{ display: none; }
  .hdr-search .hs-lbl, .hdr-search kbd{ display: none; }
  .hdr-search{ padding: 0 !important; width: 40px !important; }
  .topbar-inner{ padding: 0 14px; gap: 10px; justify-content: space-between; }
  #appsBtn{ display: none; }
  main.wrap{ padding: 18px 14px 40px; }
  .page-head{ margin-bottom: 16px; }
  .page-head h1{ font-size: 2.3rem; }
  .page-actions{ width: 100%; }
  .page-actions .btn{ flex: 1; justify-content: center; }
  .page-actions.cal-nav{ width: auto; }
  .page-actions.cal-nav .btn{ flex: none; }
  .notice-bar{ padding: 0 14px; }
  .site-foot{ padding: 18px 14px 26px; }

  /* the phone header is just brand + a few buttons, so it doesn't need to
     blur what's behind it (and a blurred parent would trap the fixed nav) */
  .topbar{ -webkit-backdrop-filter: none; backdrop-filter: none; background: color-mix(in srgb, var(--bg) 96%, transparent); }

  .bottom-nav{
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: var(--z-fab);
    height: var(--bottom-h);
    padding: 6px 6px env(safe-area-inset-bottom);
    background: color-mix(in srgb, var(--surface) 94%, transparent);
    -webkit-backdrop-filter: blur(14px);
    backdrop-filter: blur(14px);
    border-top: 1px solid var(--line);
    view-transition-name: bottomnav;
  }
  ::view-transition-old(bottomnav), ::view-transition-new(bottomnav){ animation: none; }
  .bottom-nav button{
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    border: 0;
    background: none;
    color: var(--ink-3);
    font-size: .7rem;
    font-weight: 650;
    border-radius: 12px;
  }
  .bottom-nav button .ic{
    width: 44px; height: 28px;
    padding: 4px 12px;
    border-radius: 14px;
    transition: background var(--t) var(--ease), color var(--t) var(--ease);
    box-sizing: border-box;
  }
  .bottom-nav button.active{ color: var(--brand-ink); }
  .bottom-nav button.active .ic{ background: var(--brand-soft); stroke-width: 2.1; }
  .bottom-nav button:active .ic{ transform: scale(.92); }
  .bn-badge{
    position: absolute;
    top: 2px; left: calc(50% + 6px);
    min-width: 18px; height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    background: var(--now);
    color: #fff;
    font-size: .66rem;
    line-height: 18px;
    text-align: center;
    box-shadow: 0 0 0 2px var(--surface);
  }
  .bn-dot{
    position: absolute;
    top: 6px; left: calc(50% + 10px);
    width: 8px; height: 8px;
    border-radius: 50%;
    background: var(--now);
    box-shadow: 0 0 0 2px var(--surface);
  }
}
@media (max-width: 420px){
  .brand-txt small{ display: none; }
}
