/*
 * The look of the dialog. To restyle it, change the values in :root: no rule
 * below them names a colour, a font or a corner. The file is served as it
 * is, with no build step, so it is written for the oldest browsers the
 * website supports (iOS Safari 15.4, Chrome 88): no nesting, no :has(),
 * no color-mix(), media queries as min-width at 40 and 64rem only.
 *
 * The page is laid out by the width it is given, which in a frame is the
 * width of the frame: one column, then calendar and times side by side
 * (40rem), then everything in one row (64rem).
 */

/* Inter and Sora, SIL Open Font License 1.1 (public/fonts/LICENSE-*.txt). */
@font-face {
  font-family: "Inter Variable";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("/fonts/inter-latin-wght-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329,
    U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "Inter Variable";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("/fonts/inter-latin-ext-wght-normal.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF,
    U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
  font-family: "Sora Variable";
  font-style: normal;
  font-weight: 100 800;
  font-display: swap;
  src: url("/fonts/sora-latin-wght-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329,
    U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "Sora Variable";
  font-style: normal;
  font-weight: 100 800;
  font-display: swap;
  src: url("/fonts/sora-latin-ext-wght-normal.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF,
    U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* Arial with Inter's measures, so the text keeps its place when Inter arrives. */
@font-face {
  font-family: "Inter Fallback";
  src: local("Arial");
  size-adjust: 107.12%;
  ascent-override: 90.44%;
  descent-override: 22.54%;
  line-gap-override: 0%;
}

:root {
  /* The portal's colours (client-dashboard, app/components/theme.ts). */
  --color-blue: #0b808a;
  --color-dark: #11363e;
  --color-red: #f64302;
  --color-bg: #f7f9fc;
  --color-black: #17191a;
  --color-text: #5e6668;
  --color-line: #d5d9db;
  --color-white: #ffffff;

  /* What the dialog uses them for. */
  --color-page: var(--color-bg);
  --color-surface: var(--color-white);
  --color-heading: var(--color-black);
  --color-accent: var(--color-blue);
  /* The chosen day and the button that confirms, and the text on them. */
  --color-fill: var(--color-dark);
  --color-on-fill: var(--color-white);
  /* Days that can be booked: --color-dark at 8% on white, worked out by hand. */
  --color-tint: #eceff0;
  /* Days that cannot. */
  --color-muted: #9aa1a3;
  /* Marked text: --color-blue at 25% on white, worked out by hand. On the dark fill it is the white's turn. */
  --color-selection: #c2dfe2;
  --color-error: var(--color-red);

  --font-heading: "Sora Variable", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-body: "Inter Variable", "Inter Fallback", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  /* Under the list of time zones. */
  --shadow: 0 0.5rem 1.5rem rgb(17 54 62 / 0.14);

  /* Corners are square. */
  --radius: 0;
  /* On a wide screen the dialog is this tall at every step, so it never changes size. */
  --booker-height: 32rem;
  --press-scale: 0.98;

  color-scheme: light;
}

/* The base: element rules at no specificity, so every rule below wins. */

:where(*, *::before, *::after) {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

:where(html) {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  /* The press and the hover are the feedback. */
  -webkit-tap-highlight-color: transparent;
}

::selection {
  background: var(--color-selection);
  color: var(--color-heading);
}

:where(body) {
  display: flex;
  min-height: 100vh;
  margin: 0;
  padding: 1rem;
  background: var(--color-page);
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.5;
  font-synthesis: style small-caps;
}

@supports (min-height: 100dvh) {
  :where(body) {
    min-height: 100dvh;
  }
}

:where(h1, h2, p, ul, ol, dl, dd, table) {
  margin: 0;
}

:where(ul, ol) {
  padding: 0;
  list-style: none;
}

:where(h1, h2) {
  color: var(--color-heading);
  font-family: var(--font-heading);
  font-weight: 600;
  line-height: 1.25;
}

:where(h1) {
  font-size: 1.5rem;
}

:where(h2) {
  font-size: 1rem;
}

:where(a) {
  color: var(--color-accent);
}

:where(a, button, select) {
  touch-action: manipulation;
}

:where(input, select, textarea, button) {
  color: inherit;
  font: inherit;
  letter-spacing: inherit;
}

:where(button, select) {
  text-transform: inherit;
}

:where(:focus-visible) {
  outline: 0.125rem solid var(--color-accent);
  outline-offset: 0.125rem;
}

:where(svg) {
  flex: none;
  width: 1.125em;
  height: 1.125em;
}

/* For screen readers only. */
.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* The dialog and its panes. */

.booker {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-content: start;
  width: 100%;
  max-width: 26rem;
  margin: auto;
  border: 1px solid var(--color-line);
  border-radius: var(--radius);
  background: var(--color-surface);
}

.booker > section {
  min-width: 0;
  padding: 1.25rem;
}

.booker > [data-pane="calendar"],
.booker > [data-pane="times"],
.booker > [data-pane="details"] {
  border-top: 1px solid var(--color-line);
}

/*
 * The dialog has one width at every step, and from 64rem one height too
 * (the month always has six rows), so it does not change size between
 * months or between steps.
 */

@media (min-width: 40rem) {
  .booker {
    max-width: 44rem;
  }

  .booker > section {
    padding: 1.5rem;
  }

  .booker[data-step="pick"] {
    grid-template-columns: minmax(0, 1fr) 14rem;
  }

  .booker[data-step="pick"] > [data-pane="meta"] {
    grid-column: 1 / -1;
  }

  .booker[data-step="pick"] > [data-pane="times"] {
    border-left: 1px solid var(--color-line);
  }

  .booker[data-step="details"] {
    grid-template-columns: 16rem minmax(0, 1fr);
  }

  .booker[data-step="details"] > [data-pane="details"] {
    border-top: 0;
    border-left: 1px solid var(--color-line);
  }
}

@media (min-width: 64rem) {
  .booker {
    align-content: stretch;
    max-width: 62rem;
    min-height: var(--booker-height);
  }

  .booker[data-step="pick"] {
    grid-template-columns: 17rem minmax(0, 1fr) 15rem;
  }

  .booker[data-step="details"] {
    grid-template-columns: 17rem minmax(0, 1fr);
  }

  .booker[data-step="pick"] > [data-pane="meta"] {
    grid-column: auto;
  }

  .booker[data-step="pick"] > [data-pane="calendar"] {
    border-top: 0;
    border-left: 1px solid var(--color-line);
  }

  .booker[data-step="pick"] > [data-pane="times"] {
    border-top: 0;
  }

  .booker[data-step="booked"],
  .booker[data-step="message"] {
    align-content: center;
  }
}

/*
 * In a frame the dialog is the frame: no page around it, no outline, and it
 * is as wide and as tall as the frame at every step. The last pane takes the
 * height that is left.
 */

:root[data-framed] body {
  padding: 0;
  background: var(--color-surface);
}

:root[data-framed] .booker {
  max-width: none;
  min-height: 100vh;
  border: 0;
}

:root[data-framed] .booker[data-step="pick"] {
  grid-template-rows: auto auto 1fr;
}

:root[data-framed] .booker[data-step="details"] {
  grid-template-rows: auto 1fr;
}

:root[data-framed] .booker[data-step="booked"],
:root[data-framed] .booker[data-step="message"] {
  align-content: center;
}

@media (min-width: 40rem) {
  :root[data-framed] .booker[data-step="pick"] {
    grid-template-rows: auto 1fr;
  }

  :root[data-framed] .booker[data-step="details"] {
    grid-template-rows: 1fr;
  }
}

@media (min-width: 64rem) {
  :root[data-framed] .booker[data-step="pick"] {
    grid-template-rows: 1fr;
  }
}

/* Who, what, how long, where. */

.organizer {
  font-size: 0.875rem;
  font-weight: 500;
}

[data-pane="meta"] > h1 {
  margin-top: 0.25rem;
}

.description {
  margin-top: 0.75rem;
  font-size: 0.9375rem;
}

.facts {
  display: grid;
  gap: 0.75rem;
  margin-top: 1.25rem;
  color: var(--color-heading);
  font-size: 0.875rem;
  font-weight: 500;
}

.facts > li {
  display: flex;
  gap: 0.625rem;
  align-items: flex-start;
}

.facts > li > svg {
  margin-top: 0.125rem;
  color: var(--color-text);
}

.facts > li > span {
  flex: 1;
  min-width: 0;
}

/* The time zone: a select, and a button for browsers without JavaScript. */

.zone {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  /* The field is taller than a line of text: keep its text on the icon's line. */
  margin-top: -0.375rem;
}

.select {
  position: relative;
  flex: 1 1 10rem;
  min-width: 0;
  /* The arrow stays near the name where the pane is wide. */
  max-width: 18rem;
}

/* The arrow, drawn: two edges of a small square, turned. */
.select::after {
  position: absolute;
  top: 50%;
  right: 0.25rem;
  width: 0.4375rem;
  height: 0.4375rem;
  margin-top: -0.3125rem;
  border-right: 1.5px solid var(--color-text);
  border-bottom: 1.5px solid var(--color-text);
  pointer-events: none;
  content: "";
  transform: rotate(45deg);
}

/*
 * The select the server draws, and the field to type in that the script puts
 * in its place: one look, one size, and no box, like the facts above it.
 */
.select > select,
.select > input {
  display: block;
  width: 100%;
  height: 2.125rem;
  margin: 0;
  padding: 0 1.5rem 0 0;
  border: 0;
  border-radius: var(--radius);
  background: var(--color-surface);
  font-size: 0.875rem;
  font-weight: 500;
  text-overflow: ellipsis;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}

/* The field holds what is typed. The zone in use is its placeholder, and steps back while the list is open. */
.select > input::placeholder {
  color: var(--color-heading);
  opacity: 1;
  text-overflow: ellipsis;
}

.select > input[aria-expanded="true"] {
  cursor: text;
}

.select > input[aria-expanded="true"]::placeholder {
  color: var(--color-text);
}

/* No ring around the field: the caret and the open list show where the focus is. */
.select > input:focus {
  outline: 0;
}

/*
 * iOS zooms into a field with text under 16px, and stays zoomed. There the
 * text is 1rem (16px, or more with a larger text size) and the field is drawn
 * at 0.875 of its size, which looks the same as 0.875rem: it is laid out
 * that much larger and takes the room it would have had.
 */
@supports (-webkit-touch-callout: none) {
  .select > select,
  .select > input {
    width: calc(100% / 0.875);
    height: calc(2.125rem / 0.875);
    margin-bottom: calc(2.125rem - 2.125rem / 0.875);
    padding-right: calc(1.5rem / 0.875);
    font-size: max(1rem, 16px);
    transform: scale(0.875);
    transform-origin: 0 0;
  }
}

/* The list of zones under the field. It may be wider than the field. */
.zones {
  position: absolute;
  z-index: 2;
  top: calc(100% + 0.25rem);
  left: 0;
  width: max-content;
  min-width: 100%;
  max-width: min(22rem, calc(100vw - 4rem));
  max-height: 17rem;
  overflow-y: auto;
  overscroll-behavior: contain;
  border: 1px solid var(--color-line);
  background: var(--color-surface);
  box-shadow: var(--shadow);
  font-weight: 400;
}

.zones > li {
  display: flex;
  gap: 1rem;
  justify-content: space-between;
  padding: 0.5rem 0.75rem;
  color: var(--color-heading);
  cursor: pointer;
}

/* The short name: "CET". */
.zones > li > span + span {
  color: var(--color-text);
  white-space: nowrap;
}

.zones > li[data-active] {
  background: var(--color-tint);
}

.zones > li[aria-selected="true"] {
  font-weight: 600;
}

.zones > .none {
  color: var(--color-text);
  cursor: default;
}

/* A choice between a few: the clock, the lengths. */

.choice {
  display: inline-flex;
  border: 1px solid var(--color-line);
  font-size: 0.75rem;
  font-weight: 500;
}

.choice > a {
  padding: 0.25rem 0.5rem;
  color: var(--color-text);
  text-decoration: none;
}

.choice > a[aria-current] {
  background: var(--color-tint);
  color: var(--color-heading);
}

/* The month. */

[data-pane="calendar"] > header,
[data-pane="times"] > header {
  display: flex;
  gap: 1rem;
  align-items: center;
  justify-content: space-between;
  min-height: 2.5rem;
}

/* The year, and the number of the day. */
[data-pane="calendar"] > header > h2 > span,
[data-pane="times"] > header > h2 span > span {
  color: var(--color-text);
  font-weight: 400;
}

[data-pane="calendar"] > header > nav {
  display: flex;
  gap: 0.25rem;
  margin-right: -0.5rem;
}

[data-pane="calendar"] > header > nav > * {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  color: var(--color-heading);
}

/* No month to go to. */
[data-pane="calendar"] > header > nav > a:not([href]) {
  color: var(--color-line);
}

[data-pane="calendar"] > header > nav > a[href]:hover {
  background: var(--color-tint);
}

/* In a wide pane the month keeps a size, and its heading stays above it. */
[data-pane="calendar"] > header,
.days {
  max-width: 28rem;
  margin-right: auto;
  margin-left: auto;
}

.days {
  width: 100%;
  margin-top: 0.75rem;
  border-spacing: 0;
  table-layout: fixed;
  text-align: center;
}

.days th {
  padding: 0.25rem 0 0.5rem;
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.days td {
  padding: 0.125rem;
}

.days td > * {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 1;
  border-radius: var(--radius);
  color: var(--color-muted);
  font-size: 0.875rem;
  font-variant-numeric: tabular-nums;
  text-decoration: none;
}

.days td > a {
  background: var(--color-tint);
  color: var(--color-heading);
  font-weight: 600;
}

.days td > a:hover {
  box-shadow: inset 0 0 0 0.125rem var(--color-fill);
}

.days td > a[aria-current] {
  background: var(--color-fill);
  color: var(--color-on-fill);
}

/* Today: a short line under the number, drawn as a border so it stays one thickness. */
.days td > [data-today]::after {
  position: absolute;
  bottom: 18%;
  left: 50%;
  width: 0.75rem;
  height: 0;
  margin-left: -0.375rem;
  border-top: 0.125rem solid currentColor;
  content: "";
}

/* The times of the chosen day. */

[data-pane="times"] {
  display: flex;
  flex-direction: column;
  /* A link to a day ends in #times: leave some air above. */
  scroll-margin-top: 1rem;
}

.slots {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.slots a {
  display: block;
  padding: 0.625rem 0.5rem;
  border: 1px solid var(--color-line);
  border-radius: var(--radius);
  color: var(--color-heading);
  font-size: 0.875rem;
  font-variant-numeric: tabular-nums;
  font-weight: 500;
  text-align: center;
  text-decoration: none;
  /* Inside the scrolling list an outline outside the box would be cut off. */
  outline-offset: -0.125rem;
}

.slots a:hover {
  border-color: var(--color-fill);
  box-shadow: inset 0 0 0 1px var(--color-fill);
}

.empty {
  font-size: 0.875rem;
}

@media (min-width: 40rem) {
  /* Beside the calendar the list is as tall as the calendar and scrolls in itself. */
  .scroller {
    position: relative;
    flex: 1;
    min-height: 18rem;
    margin-top: 0.75rem;
  }

  .slots {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    grid-template-columns: minmax(0, 1fr);
    align-content: start;
    margin: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
  }
}

/* The form. */

.fields {
  display: grid;
  gap: 1rem;
  /* In a wide frame the fields stay a width one can read. */
  max-width: 32rem;
}

.field {
  display: grid;
  gap: 0.375rem;
}

.field > label {
  color: var(--color-heading);
  font-size: 0.875rem;
  font-weight: 500;
}

.field > label > span {
  color: var(--color-text);
  font-weight: 400;
}

.field > input,
.field > textarea {
  width: 100%;
  padding: 0.625rem 0.75rem;
  border: 1px solid var(--color-line);
  border-radius: var(--radius);
  background: var(--color-surface);
  color: var(--color-heading);
  /* Never under 1rem: iOS zooms into a smaller field. */
  font-size: 1rem;
  -webkit-appearance: none;
  appearance: none;
}

.field > textarea {
  min-height: 6rem;
  resize: vertical;
}

.field > [aria-invalid="true"] {
  border-color: var(--color-error);
}

.error {
  color: var(--color-heading);
  font-size: 0.875rem;
}

.notice {
  margin-bottom: 1rem;
  padding: 0.75rem 1rem;
  border-left: 0.1875rem solid var(--color-error);
  background: var(--color-page);
  color: var(--color-heading);
  font-size: 0.875rem;
}

.actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
  margin-top: 0.5rem;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.75rem;
  padding: 0.5rem 1.25rem;
  border: 1px solid var(--color-fill);
  border-radius: var(--radius);
  background-color: var(--color-fill);
  color: var(--color-on-fill);
  font-size: 1rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: scale 0.15s ease-out;
}

.button:not([data-quiet])::selection,
.days td > a[aria-current]::selection {
  background: var(--color-on-fill);
  color: var(--color-fill);
}

/* The hover is a light layer over whatever colour the button has. */
.button:hover {
  background-image: linear-gradient(rgb(255 255 255 / 0.12) 0 0);
}

.button:active:not(:disabled) {
  scale: var(--press-scale);
  transition-duration: 0s;
}

.button[data-quiet] {
  border-color: transparent;
  background-color: transparent;
  color: var(--color-heading);
}

.button[data-quiet]:hover {
  background-color: var(--color-tint);
  background-image: none;
}

.button[data-small] {
  min-height: 0;
  padding: 0.25rem 0.75rem;
  font-size: 0.875rem;
}

/* While the form is on its way (public/booking.js). */
.button[aria-busy="true"] {
  opacity: 0.6;
  cursor: progress;
}

/* Booked, and the pages that only say something. */

[data-pane="booked"],
[data-pane="message"] {
  display: grid;
  gap: 0.75rem;
  justify-items: center;
  justify-self: center;
  width: 100%;
  max-width: 30rem;
  text-align: center;
}

.booker > [data-pane="booked"],
.booker > [data-pane="message"] {
  padding: 2rem 1.5rem;
}

.badge {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 3rem;
  height: 3rem;
  background: var(--color-tint);
  color: var(--color-accent);
  font-size: 1.5rem;
}

.summary {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 0.75rem 1.5rem;
  width: 100%;
  margin-top: 0.75rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--color-line);
  font-size: 0.875rem;
  text-align: left;
}

.summary > dt {
  color: var(--color-heading);
  font-weight: 600;
}

/* From one step to the next, where the browser can: a short fade, no script. */
@media (prefers-reduced-motion: no-preference) {
  @view-transition {
    navigation: auto;
  }
}
