/* Booking page. Built on styles.css: its type, tokens, hairlines, pills and
   paper grain. The open times are a dot chart drawn the way the home hero
   draws the GitHub year (field.js): days across, half hours down, one dot per
   slot, with the caption top right. The heading and the details form sit
   beside it. Colour stays out of it except --brand, which marks the
   visitor's chosen time. */

.cal { padding-top: 56px; padding-bottom: 96px; }
.cal__sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

.cal__layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 560px); gap: 32px 72px; align-items: start; }
.cal__title { margin: 0 0 14px; font-size: clamp(40px, 6vw, 64px); line-height: 1.02; letter-spacing: -0.04em; font-weight: 600; }
.cal__sub { margin: 0; max-width: 32em; font-size: 18px; color: var(--muted); }

/* The time zone select reads as part of the sentence, with a caret. cal.js
   sizes it to the chosen zone's text; field-sizing does the same where
   supported, before the script runs. */
.cal__select {
  max-width: 100%; min-width: 0; margin: -3px 0; padding: 2px 24px 2px 6px; field-sizing: content;
  font: inherit; font-weight: 600; color: var(--ink-2);
  border: 0; border-radius: 6px; cursor: pointer; text-overflow: ellipsis;
  -webkit-appearance: none; appearance: none;
  background: transparent url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23737373' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='m6 9 6 6 6-6'/></svg>") no-repeat right 5px center / 14px;
  box-shadow: inset 0 -1px 0 var(--line-strong);
  transition: background-color 0.15s;
}
.cal__select:hover { background-color: var(--surface-2); }
.cal__select:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

/* Status line: quiet unless it has something to say. */
.cal__status { margin: 20px 0 0; font-size: 15px; font-weight: 600; color: var(--muted); }
.cal__status:empty { display: none; }
.cal__status.is-error { color: #9c3557; }

/* ---------- The chart ---------- */

.cal__chart { margin: 0; padding-top: 6px; }
.cal__readout {
  min-height: 18px; margin: 0 0 14px; text-align: right;
  font-size: 12px; font-weight: 500; color: rgba(10, 10, 10, 0.55); font-variant-numeric: tabular-nums;
}
.cal__readout.is-point { color: var(--ink); }
.cal__grid { --pitch: 24px; --dot: 13px; display: grid; grid-template-columns: 52px repeat(var(--days, 8), minmax(0, 1fr)); }
.cal__axis, .cal__day { display: flex; flex-direction: column; min-width: 0; }
.cal__dayname {
  height: 40px; display: flex; flex-direction: column; align-items: center; gap: 1px;
  font-size: 12px; font-weight: 500; line-height: 1.2; color: rgba(10, 10, 10, 0.55); white-space: nowrap;
}
.cal__dayname b { font-size: 14px; font-weight: 650; color: var(--ink); font-variant-numeric: tabular-nums; }
.cal__tick { height: var(--pitch); font-size: 12px; font-weight: 500; line-height: var(--pitch); color: rgba(10, 10, 10, 0.55); white-space: nowrap; font-variant-numeric: tabular-nums; }
/* Where the rows jump past the hours with nothing in them. */
.cal__break { height: 14px; flex: none; }
.cal__cell { height: var(--pitch); display: grid; place-items: center; }
.cal__off { width: 4px; height: 4px; border-radius: 50%; background: var(--ink); opacity: 0.2; }
.cal__dot { position: relative; width: 100%; height: 100%; padding: 0; border: 0; background: none; cursor: pointer; }
.cal__dot::before {
  content: ''; position: absolute; left: 50%; top: 50%; width: var(--dot); height: var(--dot); translate: -50% -50%;
  border-radius: 50%; background: var(--ink); opacity: 0.78;
  transition: scale 0.2s var(--ease), opacity 0.15s, background-color 0.15s;
}
.cal__dot:hover::before { scale: 1.3; opacity: 1; }
.cal__dot[aria-pressed="true"]::before { background: var(--brand-ink); opacity: 1; scale: 1.35; }
.cal__dot:focus-visible { outline: none; }
.cal__dot:focus-visible::after {
  content: ''; position: absolute; left: 50%; top: 50%; width: calc(var(--dot) + 12px); height: calc(var(--dot) + 12px); translate: -50% -50%;
  border-radius: 50%; box-shadow: 0 0 0 2px var(--ink);
}
/* The first time the week is drawn, the dots pop in column by column, as the hero's do. */
.cal__grid.is-sweep .cal__dot::before { animation: cal-pop 0.55s cubic-bezier(0.34, 1.56, 0.64, 1) backwards; animation-delay: calc(240ms + var(--c) * 70ms + var(--r) * 9ms); }
@keyframes cal-pop { from { scale: 0; } }

/* Once booked (or when booking is down) the chart steps aside. */
.cal:is([data-step="done"], [data-step="down"]) .cal__layout { grid-template-columns: minmax(0, 1fr); }
.cal:is([data-step="done"], [data-step="down"]) .cal__chart { display: none; }

/* ---------- Details, done, down ---------- */

.cal__form, .cal__done, .cal__down { margin-top: 48px; padding-top: 28px; border-top: 1px solid var(--line); }
.cal__form { display: grid; gap: 16px; align-content: start; }
.cal__form[hidden], .cal__done[hidden], .cal__down[hidden], .cal__chosen[hidden], .cal__turnstile[hidden], .cal__hint[hidden] { display: none; }
.cal__formhead { margin: 0; font-size: 16px; font-weight: 600; letter-spacing: -0.01em; color: var(--ink-2); outline: none; }
.cal__formbody { display: grid; gap: 16px; min-width: 0; max-width: 520px; }
.cal__chosen-when { margin: 0; font-size: clamp(19px, 2vw, 22px); line-height: 1.35; letter-spacing: -0.02em; font-weight: 600; color: var(--ink); }
.cal__chosen-sub { margin: 4px 0 0; font-size: 14px; font-weight: 500; color: var(--muted); }
.cal__chosen-sub:empty { display: none; }
.cal__field { display: grid; gap: 6px; min-width: 0; }
.cal__label { font-size: 14px; font-weight: 600; color: var(--ink-2); }
.cal__label span { color: var(--faint); font-weight: 500; }
.cal__input {
  width: 100%; min-width: 0; height: 48px; padding: 0 16px;
  font: inherit; font-size: 16px; color: var(--ink);
  background: #fff; border: 0; border-radius: var(--radius-sm);
  box-shadow: inset 0 0 0 1px var(--line-strong);
  transition: box-shadow 0.15s;
  -webkit-appearance: none; appearance: none;
}
.cal__input:hover { box-shadow: inset 0 0 0 1px var(--faint); }
.cal__input:focus { outline: none; box-shadow: inset 0 0 0 1.5px var(--ink); }
.cal__input[aria-invalid="true"] { box-shadow: inset 0 0 0 1.5px #9c3557; }
.cal__textarea { height: auto; min-height: 104px; padding: 12px 16px; line-height: 1.55; resize: vertical; }
.cal__err { margin: 0; font-size: 13px; font-weight: 600; color: #9c3557; }
.cal__err:empty { display: none; }

.cal__actions { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.cal__book { height: 48px; padding: 0 26px; font-size: 15px; }
/* Greyed out until a time is chosen: the site's surface and faint ink, no hover. */
.cal__book:disabled { background: var(--surface-2); color: var(--muted); box-shadow: inset 0 0 0 1px var(--line-strong); cursor: not-allowed; transform: none; }
.cal__book.is-busy:disabled { background: var(--ink-2); color: #fff; box-shadow: none; cursor: progress; }
.cal__hint { margin: 0; font-size: 13px; color: var(--muted); }

.cal__donehead { margin: 0 0 10px; font-size: clamp(22px, 2.6vw, 28px); line-height: 1.3; letter-spacing: -0.02em; font-weight: 600; outline: none; }
.cal__donetime { margin: 0; font-size: clamp(18px, 2vw, 22px); line-height: 1.35; letter-spacing: -0.02em; font-weight: 600; color: var(--ink-2); }
.cal__donesub { margin: 6px 0 0; font-size: 15px; color: var(--muted); }
.cal__donesub:empty { display: none; }
.cal__meetlink { margin-top: 24px; height: 44px; padding: 0 20px; font-size: 15px; }
.cal__meeturl { overflow-wrap: anywhere; font-size: 13px; }
.cal__down p { margin: 0 0 16px; color: var(--ink-2); }

.cal__book:focus-visible, .cal__meetlink:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

/* A new step rises in like .hydrate. */
.cal .is-fresh > *, .cal .is-fresh > .cal__formbody > * { animation: hydrate 0.45s var(--ease) both; }

/* ---------- Narrower: heading, chart, then the details below it ---------- */

@media (max-width: 1040px) {
  .cal__layout { grid-template-columns: minmax(0, 1fr); gap: 40px; }
  .cal__side { display: contents; }
  .cal__title { margin-bottom: -26px; }
  .cal__status { order: 1; margin-top: -20px; }
  .cal__chart { order: 2; }
  .cal__form, .cal__done, .cal__down { order: 3; margin-top: 0; }
}
@media (max-width: 720px) {
  .cal { padding-top: 32px; }
  .cal__grid { --pitch: 26px; --dot: 12px; grid-template-columns: 40px repeat(var(--days, 8), minmax(0, 1fr)); }
  .cal__tick { font-size: 11px; }
}

@media (prefers-reduced-motion: reduce) {
  .cal .is-fresh > *, .cal .is-fresh > .cal__formbody > *, .cal__grid.is-sweep .cal__dot::before { animation: none; }
  .cal__dot::before, .cal__input, .cal__select { transition: none; }
  .cal__dot:hover::before { scale: 1; }
  .cal__dot[aria-pressed="true"]::before { scale: 1.35; }
}

/* ---------- Pointing at a time ---------- */

.cal__chart { position: relative; }
.cal__tip {
  position: absolute; z-index: 3; left: 0; top: 0; pointer-events: none; white-space: nowrap;
  display: flex; flex-direction: column; gap: 1px; padding: 7px 12px; border-radius: 8px;
  background: var(--ink); color: #fff; font-variant-numeric: tabular-nums;
  box-shadow: 0 10px 24px -12px rgba(0, 0, 0, 0.5);
  opacity: 0; transition: opacity 0.12s;
}
.cal__tip.is-on { opacity: 1; }
.cal__tip b { font-size: 14px; font-weight: 650; letter-spacing: -0.01em; }
.cal__tip span { font-size: 12px; font-weight: 500; color: rgba(255, 255, 255, 0.65); }
/* A bar as long as the call, running down from the dot. */
.cal__cell { position: relative; }
.cal__cell::after {
  content: ''; position: absolute; z-index: 1; left: 50%; top: 50%; width: 3px; margin-left: -1.5px;
  height: calc(var(--len, 2) * var(--pitch)); border-radius: 0 0 2px 2px; background: var(--ink);
  opacity: 0; transition: opacity 0.12s; pointer-events: none;
}
.cal__cell:has(.cal__dot:hover)::after, .cal__cell:has(.cal__dot:focus-visible)::after { opacity: 1; }
/* Its hour and its day, lit on the axes. */
.cal__tick.is-at, .cal__dayname.is-at { color: var(--ink); font-weight: 650; }
.cal__tick.is-at:empty::before { content: attr(data-at); }
@media (hover: none) { .cal__tip { display: none; } }
@media (prefers-reduced-motion: reduce) { .cal__tip, .cal__cell::after { transition: none; } }
