/* ==========================================================================
   header.css — the bar, its two progress bars, the visitor's panel, and the
   contact section the bars travel towards.

   Mobile first. The call to action sits in the exact centre of the bar (a
   three-column grid with equal outer columns), because the bars meet there.
   ========================================================================== */

/* ---------- the bar ----------------------------------------------------- */

.topbar {
  position: fixed;
  inset-block-start: 0;
  inset-inline: 0;
  z-index: 80;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  height: var(--topbar-h);
  padding-inline: clamp(10px, 2.2vw, 28px);
  /* on the way down the bar slides up out of view and only its progress
     line stays, at the top edge (the bars hang just under the bar); on the
     way up it slides back. Driven by --bar-y, the same value the stuck
     pieces use, so they move as one. */
  transform: translateY(calc(var(--bar-y) - var(--topbar-h)));
  background: color-mix(in oklab, var(--paper) 92%, transparent);
  backdrop-filter: blur(18px) saturate(120%);
  -webkit-backdrop-filter: blur(18px) saturate(120%);
}

.topbar__left,
.topbar__right {
  display: flex;
  align-items: center;
  gap: clamp(8px, 1.4vw, 18px);
  min-width: 0;
}
.topbar__left { position: relative; justify-self: start; }
.topbar__right { justify-self: end; }

.topbar__brand {
  display: none;                       /* the phone keeps menu, button, you */
  font-family: var(--font-display);
  font-size: 1.125rem;
  font-weight: 520;
  letter-spacing: -0.02em;
  color: var(--ink);
  text-decoration: none;
  white-space: nowrap;
}

/* ---------- the menu button: three lines, then a cross (sitemenu.js) ---- */

.topbar__menu {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  margin-inline-start: -8px;
  padding: 0;
  border: 0;
  border-radius: 10px;
  background: none;
  color: var(--ink);
  cursor: pointer;
}
.topbar__menu:hover { background: color-mix(in oklab, var(--ink) 8%, transparent); }
.topbar__menu:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.topbar__burger { display: grid; gap: 5px; width: 22px; }
.topbar__burger i {
  display: block;
  height: 2px;
  border-radius: 1px;
  background: currentColor;
  transition: transform var(--phrase, 420ms) var(--md-sys-motion-easing-emphasized, ease), opacity var(--beat, 160ms);
}
.topbar__menu[aria-expanded="true"] .topbar__burger i:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.topbar__menu[aria-expanded="true"] .topbar__burger i:nth-child(2) { opacity: 0; }
.topbar__menu[aria-expanded="true"] .topbar__burger i:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ---------- the call to action, in the middle --------------------------- */

.topbar__cta {
  justify-self: center;
  display: inline-grid;
  align-items: center;
  height: 40px;
  padding-inline: 16px;
  border-radius: 0 8px 8px 8px;   /* a speech bubble: the top-left corner square */
  background: var(--primary);     /* the site's UI colour, never themed */
  color: var(--on-primary);
  font-family: var(--font-small);   /* buttons: Montserrat semibold, 14px */
  font-size: 0.875rem;
  font-weight: 600;
  letter-spacing: 0;
  text-decoration: none;
  white-space: nowrap;
  transition: box-shadow 260ms ease, transform 260ms ease;
}
.topbar__cta:hover { box-shadow: 0 0 0 4px color-mix(in oklab, var(--primary) 40%, transparent); }
/* both labels share one cell, so the button never changes width (and the
   meeting point never moves) when the label changes */
.topbar__cta > span { grid-area: 1 / 1; text-align: center; transition: opacity 220ms ease, transform 220ms ease; }
.topbar__cta-b { opacity: 0; transform: translateY(6px); }
.topbar.is-met .topbar__cta-a { opacity: 0; transform: translateY(-6px); }
.topbar.is-met .topbar__cta-b { opacity: 1; transform: none; }
.topbar__cta-name { display: none; }
html[data-visitor="named"] .topbar__cta-name { display: inline; }

/* the moment the bars meet: the button takes them in, once */
@keyframes cta-meet {
  0%   { box-shadow: 0 0 0 0 color-mix(in oklab, var(--primary) 70%, transparent); transform: scale(1); }
  35%  { transform: scale(1.07); }
  100% { box-shadow: 0 0 0 14px color-mix(in oklab, var(--primary) 0%, transparent); transform: scale(1); }
}
.topbar.is-meeting .topbar__cta { animation: cta-meet 700ms cubic-bezier(0.2, 0, 0, 1); }

/* ---------- the two bars ----------------------------------------------- */

.topbar__bars {
  position: absolute;
  inset-inline: 0;
  inset-block-start: 100%;
  height: 3px;
  pointer-events: none;
}
.topbar__bar {
  position: absolute;
  inset-block: 0;
  width: 0;
  background: color-mix(in oklab, var(--accent) 62%, var(--paper));   /* the visitor's theme: their choice shows on every page */
  transition: background-color 300ms ease;
}
.topbar__bar--l { inset-inline-start: 0; width: var(--bar-l, 0px); }
.topbar__bar--r { inset-inline-end: 0; width: var(--bar-r, 0px); }
.topbar.is-met .topbar__bar { background: var(--accent); }

/* ---------- themes ----------------------------------------------------- */

.topbar__themes { display: none; gap: 2px; }

.swatch {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  cursor: pointer;
}
.swatch__dot {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  transition: transform 180ms ease, box-shadow 180ms ease;
}
.swatch__dot[data-sw="1"] { background: var(--aqua); }
.swatch__dot[data-sw="2"] { background: var(--lime); }
.swatch__dot[data-sw="3"] { background: var(--periwinkle); }
.swatch__dot[data-sw="4"] { background: var(--caramel); }
.swatch:hover .swatch__dot { transform: scale(1.12); }
.swatch[aria-pressed="true"] .swatch__dot { box-shadow: 0 0 0 2px var(--paper), 0 0 0 4px var(--ink); }

/* ---------- the visitor ------------------------------------------------- */

.avatar {
  --face-ink: var(--dark);
  --face-iris-shade: oklch(from var(--accent) calc(l - 0.30) calc(c + 0.05) h);
  --face-iris: oklch(from var(--accent) calc(l - 0.12) calc(c + 0.05) h);
  --face-iris-light: var(--accent);
  --face-shine: white;
  --face-blush: var(--caramel-deep);
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--light);
  color: var(--dark);
  cursor: pointer;
  transition: box-shadow 180ms ease;
}
/* the ring, always there (as on a Google account avatar): a hairline of the
   bar between the photo and a ring of the site's primary colour. Opened
   (clicked) or focused, a lighter halo of the same blue joins it. */
.avatar {
  position: relative;
  box-shadow: 0 0 0 2px var(--dark), 0 0 0 4px var(--primary);
  transition: box-shadow 180ms ease;
}
.avatar[aria-expanded="true"],
.avatar:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--dark), 0 0 0 4px var(--primary),
              0 0 0 8px color-mix(in oklab, var(--primary) 45%, transparent);
}

/* the name on hover: a small label under the avatar, right-aligned to it so
   it never runs off the screen */
.avatar__tip {
  position: absolute;
  top: calc(100% + 12px);
  right: -4px;
  max-width: 14rem;
  padding: 6px 10px;
  border-radius: 6px;
  background: var(--light);
  color: var(--dark);
  font-family: var(--font-small);
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
  z-index: 2;                            /* over the progress bars, which come later in the bar */
  opacity: 0;
  transform: translateY(-3px);
  transition: opacity 140ms ease, transform 140ms ease;
}
.avatar:hover .avatar__tip,
.avatar:focus-visible .avatar__tip { opacity: 1; transform: none; transition-delay: 250ms; }
.avatar[aria-expanded="true"] .avatar__tip { opacity: 0; transition-delay: 0ms; }
@media (prefers-reduced-motion: reduce) { .avatar__tip { transform: none; } }
.avatar__initials {
  display: none;
  font-family: var(--font-small);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  line-height: 1;
}
.avatar__face { width: 21px; height: auto; }
.avatar__face rect, .you .px rect { stroke: none; }
.avatar__face .px-k { fill: var(--face-ink); }
.avatar__face .px-G { fill: var(--face-iris-shade); }
.avatar__face .px-g { fill: var(--face-iris); }
.avatar__face .px-h { fill: var(--face-iris-light); }
.avatar__face .px-w { fill: var(--face-shine); }
.avatar__face .px-p { fill: var(--face-blush); }
html[data-visitor="named"] .avatar__initials { display: block; }
html[data-visitor="named"] .avatar__face { display: none; }

/* ---------- the visitor's panel ---------------------------------------- */

/* The visitor's menu, after Material 3 (and a Google account menu): a
   rounded sheet one step above the ground, no border, a deeper shadow;
   items in the bar's dark, grouped with large outer and small inner corners,
   a shade lighter than the sheet on hover. */
.you {
  --you-sheet: color-mix(in oklab, var(--light) 7%, var(--surface));
  --you-item: var(--dark);
  --you-item-hover: color-mix(in oklab, var(--light) 13%, var(--surface));
  position: fixed;
  z-index: 85;
  inset-block-start: calc(var(--topbar-h) + 8px);
  inset-inline-end: clamp(10px, 2.2vw, 28px);
  width: min(380px, calc(100vw - 20px));
  max-height: calc(100svh - var(--topbar-h) - 24px);
  overflow-y: auto;
  padding: 52px 14px 16px;
  border-radius: 28px;
  background: var(--you-sheet);
  color: var(--ink);
  box-shadow: 0 28px 72px -12px rgb(0 0 0 / 0.85), 0 6px 18px rgb(0 0 0 / 0.45);
}
.you[hidden] { display: none; }
.you__hi { display: none; }
html[data-visitor="named"] .you__hi { display: inline; }
html[data-visitor="named"] .you__anon { display: none; }

.you__close {
  position: absolute;
  inset-block-start: 8px;
  inset-inline-end: 10px;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--ink);
  cursor: pointer;
}
.you__close:hover { background: var(--you-item-hover); }
.you__close .icon { width: 22px; height: 22px; fill: currentColor; }

/* a group: 24px outer corners, 4px between, 2px of sheet showing */
.you__group { display: grid; gap: 2px; }
.you__item {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  min-height: 56px;
  padding: 10px 20px;
  border: 0;
  border-radius: 4px;
  background: var(--you-item);
  color: var(--ink);
  font-family: var(--font-small);
  font-size: 0.875rem;
  font-weight: 600;
  text-align: start;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 150ms ease;
}
.you__group > .you__item:first-child { border-start-start-radius: 24px; border-start-end-radius: 24px; }
.you__group > .you__item:last-child { border-end-start-radius: 24px; border-end-end-radius: 24px; }
a.you__item:hover, button.you__item:hover { background: var(--you-item-hover); }
.you__item:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }
.you__item--head { display: block; padding: 22px 20px 20px; cursor: default; }
.you__title {
  font-family: var(--font-display);
  font-size: 1.625rem;
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: -0.02em;
}
.you__line { margin-top: 6px; color: var(--ink-soft); font-family: var(--font-small); font-size: 0.8125rem; font-weight: 500; line-height: 1.45; }
.you__icon { flex: none; width: 22px; height: 22px; fill: currentColor; }
.you__icon--accent { fill: var(--accent); }

.you__section {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin: 18px 6px 8px;
  font-family: var(--font-small);
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--ink);
}
.you__count { font-size: 0.75rem; font-weight: 500; color: var(--ink-soft); }

/* the moving-type switch, after the Material 3 switch: a 52 × 32 track; off
   is an outlined track with a small handle, on fills the track in the
   site's primary and grows the handle around a check */
.you__item--switch { justify-content: space-between; }
.you__switch-text { display: grid; gap: 2px; }
.you__switch-text small { font-size: 0.75rem; font-weight: 500; color: var(--ink-soft); }
.m3-switch {
  position: relative;
  flex: none;
  width: 52px;
  height: 32px;
  border-radius: 999px;
  background: var(--you-item-hover);
  box-shadow: inset 0 0 0 2px var(--ink-faint);
  transition: background-color 200ms ease, box-shadow 200ms ease;
}
.m3-switch__handle {
  position: absolute;
  inset-block-start: 50%;
  inset-inline-start: 8px;
  display: grid;
  place-items: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--ink-faint);
  transform: translateY(-50%);
  transition: inset-inline-start 200ms var(--md-sys-motion-easing-emphasized), width 200ms ease, height 200ms ease, background-color 200ms ease;
}
.m3-switch__handle .icon { width: 16px; height: 16px; fill: var(--primary); opacity: 0; transition: opacity 150ms ease; }
.you__item--switch[aria-checked="true"] .m3-switch { background: var(--primary); box-shadow: none; }
.you__item--switch[aria-checked="true"] .m3-switch__handle {
  inset-inline-start: 24px;
  width: 24px;
  height: 24px;
  background: var(--on-primary);
}
.you__item--switch[aria-checked="true"] .m3-switch__handle .icon { opacity: 1; }
.you__item--switch:active .m3-switch__handle { width: 28px; height: 28px; }
.you__item--switch:active[aria-checked="true"] .m3-switch__handle { inset-inline-start: 22px; }
.you__item--switch:active[aria-checked="false"] .m3-switch__handle { inset-inline-start: 2px; }

.you__item--themes { gap: 6px; cursor: default; }
@media (prefers-reduced-motion: reduce) {
  .m3-switch, .m3-switch__handle, .m3-switch__handle .icon { transition: none; }
}

/* ---------- the contact section: where the bars meet ------------------- */

.contact-end {
  padding-block: clamp(80px, 12vw, 180px) clamp(64px, 9vw, 130px);
  margin-bottom: var(--card-gap);
}
.contact-end__inner { display: grid; justify-items: center; text-align: center; }
.contact-end__kicker {
  font-family: var(--font-small);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-faint);
}
.contact-end__title {
  margin-top: 14px;
  font-family: var(--font-display);
  font-size: clamp(2.6rem, 8vw, 7rem);
  font-weight: 500;
  line-height: 0.95;
  letter-spacing: -0.045em;
  text-wrap: balance;
}
.contact-end__name { color: var(--accent); }
.contact-end__comma { color: var(--ink); }
.contact-end__name { display: none; }
html[data-visitor="named"] .contact-end__name { display: inline; }
.contact-end__line {
  max-width: 34ch;
  margin-top: 18px;
  font-size: clamp(1rem, 1.5vw, 1.125rem);
  line-height: 1.5;
  color: var(--ink-soft);
}
.contact-end__cta { margin-top: 28px; height: 52px; padding-inline: 1.8rem; font-size: 0.875rem; }
.contact-end__cta .icon { width: 20px; height: 20px; fill: currentColor; }
.contact-end__details {
  display: grid;
  gap: 14px 40px;
  margin: clamp(40px, 6vw, 72px) 0 0;
  padding: 0;
  list-style: none;
  font-family: var(--font-small);
  font-size: 0.875rem;
}
.contact-end__details li { display: grid; gap: 2px; }
.contact-end__k {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-faint);
}
.contact-end__details a { color: var(--ink); text-underline-offset: 0.25em; }
.contact-end__details a:hover { color: var(--accent); }

/* ---------- wider ------------------------------------------------------- */

@media (min-width: 761px) {
  .topbar__brand { display: inline; }
  .topbar__themes { display: inline-flex; }
  .you__item--themes { display: none; }
  #youMotion { border-end-start-radius: 24px; border-end-end-radius: 24px; }   /* the themes row is gone: the switch closes the group */
  .contact-end__details { grid-auto-flow: column; }
}

@media (prefers-reduced-motion: reduce) {
  .topbar.is-meeting .topbar__cta { animation: none; }
  .topbar__cta > span, .topbar__burger i { transition: none; }
}
