/* Darkside Booking, on the front of the site.
 *
 * Every color here reads a custom property first, and those properties are set
 * on the wrapper from Theme Settings, Elements - see DSBK_Theme. An unset color
 * is not written at all, so the fallback in each var() is what stands, and every
 * fallback follows the theme rather than inventing a palette.
 *
 * The three status colors are the exception and deliberately: green, amber and
 * red mean the same thing everywhere, and following a palette would make a
 * calendar you cannot read at a glance.
 */

.dsbk{
  --dsbk-bg: transparent;
  /* Whatever is written where the calendar is standing, not the colour
     the site writes body text in.
   *
     Those are the same thing on a page and different things inside
     anything that sets its own ground - a light panel or dialog on a
     dark site, which is where the account puts this. There the day
     numbers and the "12 free" under them came out in the site's light
     ink on pale green and could not be read at all. currentColor is the
     surface's own answer and is identical on a plain page. */
  --dsbk-text: currentColor;
  --dsbk-line: var(--ds-line, rgba(127,127,127,.28));
  --dsbk-dim: var(--ds-lo, rgba(127,127,127,.75));

  --dsbk-day-bg: transparent;
  --dsbk-day-text: var(--dsbk-text);
  --dsbk-day-hover-bg: rgba(127,127,127,.10);

  /* Closed. The same red the suite marks a fail in, at the weight the
     green beside it is drawn at - a day you cannot book should say so
     rather than only being fainter than the ones you can. */
  --dsbk-shut-bg: rgba(234,91,76,.10);

  /* The row the month and its arrows sit on. */
  --dsbk-head-bg: rgba(0,0,0,.1);

  --dsbk-free-bg: rgba(76,183,149,.12);
  --dsbk-free-text: var(--dsbk-text);
  --dsbk-free-hover-bg: rgba(76,183,149,.24);

  --dsbk-picked-bg: var(--ds-accent, #1d2327);
  --dsbk-picked-text: #fff;
  --dsbk-today-line: var(--ds-accent, currentColor);

  /* The theme's own Modal card first - Elements - Modal dresses this
     dialog the way it dresses every other modal on the site - then the
     theme modal's resting values where that card was never touched. */
  --dsbk-modal-bg: var(--ds-modal-bg, var(--ds-bg, #fff));
  --dsbk-modal-text: var(--ds-modal-ink, var(--dsbk-text));
  --dsbk-modal-line: var(--ds-modal-edge, var(--ds-line, rgba(127,127,127,.35)));

  --dsbk-time-bg: transparent;
  --dsbk-time-text: var(--dsbk-text);
  --dsbk-time-hover-bg: rgba(127,127,127,.12);
  --dsbk-time-on-bg: var(--ds-accent, #1d2327);
  --dsbk-time-on-text: #fff;

  --dsbk-button-bg: var(--ds-btn-bg, var(--ds-accent, #1d2327));
  --dsbk-button-text: var(--ds-btn-text, #fff);
  --dsbk-button-hover-bg: var(--dsbk-button-bg);
  --dsbk-button-hover-text: var(--dsbk-button-text);

  --dsbk-radius: 3px;
  --dsbk-cell: 74px;
  --dsbk-gap: 6px;

  background: var(--dsbk-bg);
  color: var(--dsbk-text);

  /* Measured against itself, not the window. A calendar in a 420px column has
     to stack whatever the screen is doing. */
  container-type: inline-size;
}

.dsbk-align-center{ margin-inline: auto }
.dsbk-align-right { margin-inline-start: auto }

.dsbk-said{ margin: 0 0 16px; font-size: 14px }
.dsbk-said.is-ok { color: #2f7d62 }
.dsbk-said.is-bad{ color: #b22222 }

/* --------------------------------------------------------------------------
 * The month
 * -------------------------------------------------------------------------- */

.dsbk-head{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 12px;
  /* A band of its own, so the month and its arrows read as the
     calendar's controls rather than as the first line of it. Padded,
     because a background with nothing between it and its contents is a
     colour stuck to the words. */
  padding: 6px 8px;
  border-radius: var(--dsbk-radius);
  background: var(--dsbk-head-bg);
}

.dsbk-month{
  margin: 0;
  font-size: clamp(18px, 2.4vw, 24px);
  line-height: 1.1;
  color: var(--ds-heading, var(--dsbk-text));
}

.dsbk-step{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--dsbk-line);
  border-radius: var(--dsbk-radius);
  color: inherit;
  text-decoration: none;
  font-size: 18px;
  line-height: 1;
}
/* Quiet until wanted, and no change of ground under the pointer.
 *
 * They sit back at just over half and come up to full on hover - the
 * same colour on the same background throughout, changing strength
 * rather than painting a grey box behind them, which on the month's
 * own band was a second background inside the first. Colour is stated
 * because a theme's link hover would otherwise repaint them. */
.dsbk-step{ opacity: .55 }
.dsbk-step:hover,
.dsbk-step:focus{ opacity: 1; background: var(--dsbk-day-bg); color: inherit }
.dsbk-step.is-off{ opacity: .3 }

.dsbk-grid{
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: var(--dsbk-gap);
}

.dsbk-wd{
  padding: 4px 0;
  font-size: 11px;
  letter-spacing: .06em;
  text-transform: uppercase;
  text-align: center;
  color: var(--dsbk-dim);
}

.dsbk-pad{ min-height: 0 }

.dsbk-day{
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-height: var(--dsbk-cell);
  padding: 8px;
  border: 1px solid var(--dsbk-line);
  border-radius: var(--dsbk-radius);
  background: var(--dsbk-day-bg);
  color: var(--dsbk-day-text);
  text-decoration: none;
  /* A day with nothing free is not a button and does not pretend to be one. */
  cursor: default;
}
.dsbk-day:not(.is-free){ background: var(--dsbk-shut-bg) }

/* The figure, not the cell. Fading the whole thing took the red down
   with it and left a day that was simply paler than the rest. */
.dsbk-day:not(.is-free) .dsbk-num{ opacity: .55 }

.dsbk-day.is-free{
  background: var(--dsbk-free-bg);
  color: var(--dsbk-free-text);
  cursor: pointer;
}
.dsbk-day.is-free:hover{ background: var(--dsbk-free-hover-bg) }

.dsbk-day.is-today{ border-color: var(--dsbk-today-line) }

.dsbk-day.is-picked{
  background: var(--dsbk-picked-bg);
  color: var(--dsbk-picked-text);
  border-color: var(--dsbk-picked-bg);
}

/* No weight added anywhere in the calendar: the markup's own <strong>
   and <th> included, which the browser bolds without being asked. */
.dsbk strong,
.dsbk b,
.dsbk th{ font-weight: inherit }

.dsbk-num{ font-size: 15px; line-height: 1.1 }
.dsbk-left{ font-size: 11px; opacity: .8 }

@container (max-width: 560px){
  .dsbk{ --dsbk-cell: 54px }
  .dsbk-day{ padding: 5px }
  .dsbk-left{ display: none }
}

/* --------------------------------------------------------------------------
 * One day
 * -------------------------------------------------------------------------- */

.dsbk-panel:empty{ display: none }
.dsbk-panel{ margin-top: 22px }

/* Except when it is standing in for the month rather than sitting under
   it. The gap holds the panel off the calendar above it, and inline
   there is no calendar above it - only the top of the box. */
.dsbk.dsbk-is-day .dsbk-panel{ margin-top: 0 }

/* Standing in for the month means the month steps aside. Without this
   the day's times were drawn below a grid that stayed put, which in a
   dialog sized to the month looks like nothing happened at all. */
.dsbk.dsbk-is-day .dsbk-head,
.dsbk.dsbk-is-day .dsbk-grid{ display: none }

/* And the form is not a card when the panel is standing in for the
   month. It is drawn as one so it reads as a thing on a page; inside a
   box that is already a box it is a border inside a border inside a
   dialog. The same stripping the plugin's own dialog does. */
.dsbk.dsbk-is-day .dsbk-book{
  margin: 0 0 18px;
  border: 0;
  padding: 0;
  background: none;
}
.dsbk.dsbk-is-day .dsbk-book + .dsbk-book{
  border-top: 1px solid var(--dsbk-modal-line);
  padding-top: 18px;
}

/* The day beside what is being booked, quieter than it. */
.dsbk-on{ opacity: .6 }
.dsbk-title .dsbk-on::before{ content: ", " }

.dsbk-dayhead{
  margin: 0 0 12px;
  font-size: 16px;
  line-height: 1.2;
  color: var(--ds-heading, var(--dsbk-text));
}

.dsbk-book{
  margin: 0 0 22px;
  padding: 16px;
  border: 1px solid var(--dsbk-modal-line);
  border-radius: var(--dsbk-radius);
  background: var(--dsbk-modal-bg);
  color: var(--dsbk-modal-text);
}

.dsbk-what{
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

/* No size written here: it is a heading, and the theme sizes headings.
   A number here is a number that stops matching the site. */
.dsbk-title{ margin: 0; line-height: 1.2 }
.dsbk-price{ margin: 0; font-size: 14px }

/* The word before the figure, quieter than it. */
.dsbk-price-word{ opacity: .55 }
.dsbk-blurb{ margin: 6px 0 0; font-size: 14px; color: var(--dsbk-dim) }

/* The times. Radios underneath, so the keyboard and a screen reader get a
   group of choices rather than a row of divs that happen to respond to a
   click. */
.dsbk-times{
  /* A grid, not a wrapped row: eight equal cells, 10px apart, the
     first against the left edge and the last against the right -
     whatever the dialog's width is. A flex row could never justify
     its last line. */
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 10px;
  margin: 14px 0 0;
  padding: 0;
  border: 0;
}

/* A phone's width carries four across instead. */
@media (max-width: 560px){
  .dsbk-times{ grid-template-columns: repeat(4, minmax(0, 1fr)) }
}

/* margin: the theme gives every label a margin for forms; here the
   grid's gap is the spacing, and the two together read as chips
   drifting apart and a last column that stops short of the edge.
   Two classes, because the theme's own label rule outranked one.
   The hand on the whole chip: the input underneath has one, but what
   somebody hovers is the label. */
.dsbk-times .dsbk-time,
.dsbk-time{ position: relative; margin: 0; min-width: 0; cursor: pointer }
.dsbk-times .dsbk-time{ margin: 0 }
.dsbk-time input{
  position: absolute;
  inset: 0;
  opacity: 0;
  margin: 0;
  cursor: pointer;
}
.dsbk-time span{
  display: block;
  /* The theme lays labels out as flex rows, which sizes a child to
     its words; the box is the cell's, not the word's. */
  flex: 1 1 auto;
  width: 100%;
  text-align: center;
  padding: 7px 4px;
  border: 1px solid var(--dsbk-modal-line);
  border-radius: var(--dsbk-radius);
  background: var(--dsbk-time-bg);
  color: var(--dsbk-time-text);
  font-size: 14px;
  line-height: 1.2;
}
.dsbk-time:hover span{ background: var(--dsbk-time-hover-bg) }
.dsbk-time input:checked + span{
  background: var(--dsbk-time-on-bg);
  color: var(--dsbk-time-on-text);
  border-color: var(--dsbk-time-on-bg);
}
/* The way back from a day, drawn as words that do something rather than
   a second button competing with Book. Under the title, which is where
   the script puts it. */
.dsbk-back{
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  color: inherit;
  cursor: pointer;
  font-size: var(--ds-text-small-size, .85rem);
  text-decoration: underline;
  text-underline-offset: .2em;
}
.dsbk-back .dsbk-chev{ width: .9em; height: .9em }

/* The row under the title: the way back on the left, the price on the
   right, both at the theme's small text. The price moves down here from
   beside the title when the way back exists to share the row with. */
.dsbk-subrow{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 8px 0 0;
}
.dsbk-subrow .dsbk-price{
  margin: 0;
  font-size: var(--ds-text-small-size, .85rem);
}

/* The day in two steps, script only: the times, then the form.
 *
 * The classes are the script's - a form it has stepped wears
 * dsbk-stepped, and dsbk-chosen once a time is picked. Without script
 * neither class exists and the day draws as one stacked form, so none
 * of this can hide anything from a reader who has no way to bring it
 * back. */
.dsbk-stepped .dsbk-after{ display: none }
.dsbk-stepped.dsbk-chosen .dsbk-times{ display: none }
.dsbk-stepped.dsbk-chosen .dsbk-after{
  display: block;
  animation: dsbk-rise .18s ease-out;
}

/* The chosen time on the left, the way back top right - the same words
   that lead out of a day, doing the same job one step deeper. */
.dsbk-stephead{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 14px;
}
.dsbk-picked{
  font-size: var(--ds-text-small-size, .85rem);
  opacity: .75;
}

@keyframes dsbk-rise{
  from{ opacity: 0; transform: translateY(4px) }
  to{ opacity: 1; transform: none }
}

@media (prefers-reduced-motion: reduce){
  .dsbk-stepped.dsbk-chosen .dsbk-after{ animation: none }
}

/* The ring belongs on the box somebody sees, not on the input behind it. */
.dsbk-time input:focus-visible + span{
  outline: 2px solid var(--ds-accent, currentColor);
  outline-offset: 1px;
}

.dsbk-fields{
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
  margin: 14px 0 0;
}

/* No gap of its own: the theme's label margin is the space between a
   label and its field, exactly as it is on every other form on the
   site. The fields and labels here carry no look of their own at all -
   the theme's global input, textarea, select and label rules dress
   them from Theme Settings. */
.dsbk-field{ display: flex; flex-direction: column; gap: 0; min-width: 0 }
.dsbk-wide{ margin-top: 10px }

/* The notes box opens at three lines, however tall the site's default
   textarea is set. */
.dsbk-book{ --ds-ta-rows: 3 }

.dsbk-fixed{ padding: 9px 0; font-size: 14px }

.dsbk-does{ margin: 14px 0 0 }

.dsbk-formsaid:empty{ display: none }
.dsbk-formsaid{ margin: 10px 0 0; font-size: 14px; color: #b22222 }

.dsbk-none{ margin: 0; color: var(--dsbk-dim) }

/* --------------------------------------------------------------------------
 * The dialog
 *
 * showModal() puts this in the browser's top layer, above every stacking
 * context on the page. A fixed overlay is clipped by any transformed ancestor
 * the theme happens to have, and the symptom is a modal that is in the markup,
 * fully opaque, and invisible.
 * -------------------------------------------------------------------------- */

/* Dressed exactly as the theme's own Modal element dresses a panel -
   the same properties, the same tokens, the same resting values where
   the Elements - Modal card was never touched - so this dialog and a
   builder modal on the same site are one kind of thing. */
.dsbk-modal{
  width: min(640px, calc(100vw - 32px));
  max-height: min(84svh, 900px);
  padding: var(--ds-modal-pad, max(24px, min(4vw, 48px), 2.5vw));
  border: var(--ds-modal-bw, 1px) solid
    var(--ds-modal-edge, var(--ds-line, rgba(255,255,255,.16)));
  border-radius: var(--ds-field-radius, 4px);
  background: var(--ds-modal-bg, var(--ds-bg, #0b0b0c));
  color: var(--ds-modal-ink, var(--ds-text, #f5f5f5));
  overflow: auto;
}
/* The scrim and its blur are the theme modal's, resting values included. */
.dsbk-modal::backdrop{
  background: var(--ds-modal-scrim, rgba(0,0,0,.72));
  backdrop-filter: blur(var(--ds-modal-blur, 14px));
  -webkit-backdrop-filter: blur(var(--ds-modal-blur, 14px)) }
/* A booking form is a card of its own below a calendar, and must not be one
   inside the dialog this plugin opens when a day is picked: that box already
   draws the border, the padding and the background, so the card put a second
   box inside the first. */
.dsbk-modal .dsbk-book{ border: 0; padding: 0; background: none }
.dsbk-modal .dsbk-book + .dsbk-book{ border-top: 1px solid var(--dsbk-modal-line); padding-top: 18px }

/* modalbody is the dialog's own content holder, not only the standalone
   modal's - the day dialog puts the day's panel inside one. Both of these
   were written for the standalone modal and dress the dialog as well, so
   they stay: taking them out with it would have moved the day panel up six
   pixels and thinned its price for no reason anybody asked for. */
.dsbk-modalbody{ margin-top: 6px }
.dsbk-modalbody .dsbk-price{ opacity: 1; white-space: nowrap }

/* The theme's field and label rules read their colors from the row they
   are on; a light dialog over a dark row would inherit light ink on a
   light box. Re-grounded to the dialog's own ink and line, while every
   measurement - padding, radius, type size, label case - stays whatever
   Theme Settings says. The fill mirrors the site's own filled, borderless
   fields: a wash of the ink that is actually on the dialog.

   Declared on the dialog for the classic modal and on the calendar root
   for the overlay - each the nearest element that actually carries the
   --dsbk-modal values, because a custom property referring to another
   resolves where it is declared, not where it is used. */
.dsbk-modal,
.dsbk-overlay .dsbk{
  --ds-field-line: var(--dsbk-modal-line);
  --ds-field-text: var(--dsbk-modal-text);
  --ds-field-bg: color-mix(in srgb, currentColor 8%, transparent);
  --ds-label-ink: var(--dsbk-modal-text);
}

.dsbk-x{
  float: right;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: var(--dsbk-radius);
  background: none;
  color: inherit;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}
.dsbk-x:hover{ background: var(--dsbk-day-hover-bg) }

/* While a booking is being taken. */
.dsbk.is-busy .dsbk-go{ pointer-events: none }

/* --------------------------------------------------------------------------
 * A visitor cancelling
 * -------------------------------------------------------------------------- */

.dsbk-portal{
  max-width: 640px;
  margin: 0 auto;
  padding: 40px 16px 60px;
}

.dsbk-ptitle{
  margin: 0 0 6px;
  font-size: clamp(26px, 5vw, 40px);
  line-height: 1.05;
}

.dsbk-pwhen{ margin: 0 0 22px; color: var(--ds-lo, rgba(127,127,127,.75)) }
.dsbk-note{ margin: 10px 0 0; font-size: 14px; color: var(--ds-lo, rgba(127,127,127,.75)) }
.dsbk-cancelform p{ margin: 0 0 12px }

/* The chevron on a month step.
 *
 * Sized against the button rather than against the text, because it is a
 * control and not a word. It replaced a single guillemet, which was drawn at
 * the text size of whatever it sat in and on a 34 pixel button came out a
 * speck - an arrow somebody has to lean in to read is not an arrow. */
.dsbk-chev{
  width: 55%;
  height: 55%;
  display: block;
}


/* The two-step panel, the chosen-time line, the Back button and the line
   saying how long a meeting is all went to Darkside CRM with the meetings.
   What is left here is the calendar, the day dialog and the booking form. */

/* --------------------------------------------------------------------------
 * The calendar in a dialog of its own, printed by the modal shortcode and
 * opened by anything on the page pointing at #darkside-booking. Sized to
 * the month, on the theme's surface, closed from its corner.
 * ------------------------------------------------------------------------ */
.dsbk-overlay{
  width: min(720px, 94vw);
  height: fit-content;
  max-height: 92vh;
  padding: 0;
  border: var(--ds-modal-bw, 1px) solid
    var(--ds-modal-edge, var(--ds-line, rgba(255,255,255,.16)));
  border-radius: var(--ds-field-radius, 8px);
  overflow: auto;
  background: var(--ds-modal-bg, var(--ds-bg, #0b0b0c));
  color: var(--ds-modal-ink, var(--ds-text, #f5f5f5));
}
.dsbk-overlay::backdrop{
  background: var(--ds-modal-scrim, rgba(0,0,0,.72));
  backdrop-filter: blur(var(--ds-modal-blur, 14px));
  -webkit-backdrop-filter: blur(var(--ds-modal-blur, 14px)) }
.dsbk-overlay-bar{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 10px 0 22px;
}

/* What is being booked, at the theme's paragraph size - a label on a
   dialog, not a heading competing with the page's. */
.dsbk-overlay-title{
  margin: 0;
  font-size: var(--ds-p-size, 1rem);
  line-height: 1.3;
}
.dsbk-overlay-body{ padding: 0 22px 22px }
.dsbk-overlay .dsbk{ color: inherit }
