/*
 * The calendar of the appointment form, field [mz_days]. Theme colours are used when they exist; the values after
 * the commas are for any other theme. Contact Form 7 fields are not blocks, so Gutenberg has no setting for this.
 */
.mz-days {
  --mz-days-accent: var(--wp--preset--color--green, #3f7d20);
  --mz-days-line: var(--wp--custom--control--border, #ccc);
  --mz-days-radius: var(--wp--custom--control--radius, 0.5rem);

  position: relative;
  display: block;
}

/* The button looks like the other fields, with a calendar on the right */
.mz-days__trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 0.625rem 0.75rem;
  font: inherit;
  color: inherit;
  text-align: start;
  background: var(--wp--preset--color--white, #fff);
  border: 1px solid var(--mz-days-line);
  border-radius: var(--mz-days-radius);
  cursor: pointer;
}

.mz-days__trigger::after {
  flex: none;
  width: 1.125rem;
  height: 1.125rem;
  margin-inline-start: 0.75rem;
  content: "";
  background: currentColor;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2'%3E%3Crect x='3' y='5' width='18' height='16' rx='2'/%3E%3Cpath d='M3 10h18M8 3v4M16 3v4'/%3E%3C/svg%3E")
    center / contain no-repeat;
}

/* Same hint colour as the other empty fields, given by the theme */
.mz-days__trigger.is-empty span {
  color: var(--mz-hint, color-mix(in srgb, currentColor 55%, transparent));
}

.mz-days__trigger:focus-visible,
.mz-days.is-open .mz-days__trigger {
  border-color: var(--mz-days-accent);
  outline: 2px solid var(--mz-days-accent);
  outline-offset: 0;
}

.mz-days__chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.mz-days__chips:not(:empty) {
  margin-block-start: 0.5rem;
}

.mz-days__chip {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.125rem 0.25rem 0.125rem 0.625rem;
  font-size: 0.875rem;
  background: color-mix(in srgb, var(--mz-days-accent) 12%, transparent);
  border-radius: 999px;
}

.mz-days__chip button {
  width: 1.5rem;
  height: 1.5rem;
  padding: 0;
  font: inherit;
  line-height: 1;
  color: inherit;
  background: none;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
}

.mz-days__chip button:hover,
.mz-days__chip button:focus-visible {
  background: color-mix(in srgb, var(--mz-days-accent) 25%, transparent);
}

/* The calendar opens under the button, over what follows */
.mz-days__popup {
  position: absolute;
  inset-block-start: calc(100% + 0.25rem);
  inset-inline-start: 0;
  z-index: 20;
  width: 21rem;
  max-width: 100%;
  padding: 0.75rem;
  background: var(--wp--preset--color--white, #fff);
  border: 1px solid var(--mz-days-line);
  border-radius: var(--mz-days-radius);
  box-shadow: 0 12px 32px -12px rgb(0 0 0 / 25%);
}

/*
 * On a phone it rises from the bottom of the screen, within reach of the thumb, over the bars the theme fixes
 * at the bottom (z-index up to 55) and with the page dimmed behind it.
 */
@media (width < 40rem) {
  .mz-days__popup {
    position: fixed;
    inset: auto 0 0;
    z-index: 100;
    outline: 100vmax solid rgb(0 0 0 / 40%);
    width: auto;
    max-width: none;
    max-height: 90vh;
    padding: 1rem 1rem calc(1rem + env(safe-area-inset-bottom));
    overflow-y: auto;
    border-radius: 1rem 1rem 0 0;
    box-shadow: 0 -12px 32px -12px rgb(0 0 0 / 30%);
  }
}

.mz-days__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-block-end: 0.5rem;
}

.mz-days__month {
  margin: 0;
  font-weight: 600;
  text-transform: capitalize;
}

.mz-days__nav {
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  font-size: 1.25rem;
  line-height: 1;
  color: inherit;
  background: none;
  border: 1px solid var(--mz-days-line);
  border-radius: 50%;
  cursor: pointer;
}

.mz-days__nav:disabled {
  opacity: 0.3;
  cursor: default;
}

.mz-days__grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 0.25rem;
  text-align: center;
}

.mz-days__weekday {
  padding-block: 0.25rem;
  font-size: 0.75rem;
  text-transform: capitalize;
  opacity: 0.6;
}

.mz-days__day {
  aspect-ratio: 1;
  padding: 0;
  font: inherit;
  font-variant-numeric: tabular-nums;
  color: inherit;
  background: color-mix(in srgb, var(--mz-days-accent) 10%, transparent);
  border: 1px solid transparent;
  border-radius: 50%;
  cursor: pointer;
}

.mz-days__day:hover:not([aria-disabled="true"]) {
  border-color: var(--mz-days-accent);
}

.mz-days__day.is-today {
  box-shadow: inset 0 0 0 2px currentColor;
}

/* A day that cannot be asked for: crossed out, but still reached with the arrows */
.mz-days__day[aria-disabled="true"] {
  text-decoration: line-through;
  background: none;
  opacity: 0.35;
  cursor: not-allowed;
}

.mz-days__day[aria-pressed="true"] {
  font-weight: 600;
  color: var(--wp--preset--color--white, #fff);
  background: var(--mz-days-accent);
}

.mz-days__popup button:focus-visible {
  outline: 2px solid var(--mz-days-accent);
  outline-offset: 1px;
}

.mz-days__footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-block-start: 0.75rem;
}

.mz-days__legend {
  display: flex;
  gap: 0.75rem;
  margin: 0;
  padding: 0;
  font-size: 0.75rem;
  list-style: none;
}

.mz-days__legend li::before {
  display: inline-block;
  width: 0.75rem;
  height: 0.75rem;
  margin-inline-end: 0.25rem;
  vertical-align: -0.0625rem;
  content: "";
  border-radius: 50%;
}

.mz-days__legend .is-open::before {
  background: color-mix(in srgb, var(--mz-days-accent) 20%, transparent);
}

.mz-days__legend .is-closed::before {
  border: 1px solid var(--mz-days-line);
}

.mz-days__legend .is-chosen::before {
  background: var(--mz-days-accent);
}

.mz-days__actions {
  display: flex;
  gap: 0.5rem;
}

.mz-days__action {
  padding: 0.375rem 0.875rem;
  font: inherit;
  font-size: 0.875rem;
  color: inherit;
  background: none;
  border: 1px solid var(--mz-days-line);
  border-radius: 999px;
  cursor: pointer;
}

.mz-days__action.is-primary {
  font-weight: 600;
  color: var(--wp--preset--color--white, #fff);
  background: var(--mz-days-accent);
  border-color: var(--mz-days-accent);
}
