/* Calendar navigation, timetable, cells and selection. */

#calendar {
  display: flex;
  flex-direction: column;
}

.navigation {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 10px 5px;
  border-bottom: 1px solid var(--line);
  background: var(--color-surface);
}

.jumpDate {
  position: relative;
  display: flex;
  align-items: flex-end;
  align-self: flex-end;
  justify-content: center;
  width: 48px;
  height: 58px;
  margin: 0 0 2px;
  flex: 0 0 auto;
  padding: 0 3px 6px;
  border: 0;
  background: transparent;
  color: var(--color-secondary);
}

.jumpDateFace {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid var(--neutral-200);
  border-radius: 11px;
  background: var(--neutral-50);
  pointer-events: none;
}

.jumpDate .icon {width:23px;height:23px;stroke-width:1.5;}
.jumpDate:hover:not(:disabled) .jumpDateFace,.jumpDate[aria-expanded=true] .jumpDateFace {background:var(--neutral-100);border-color:var(--neutral-400);}
.jumpDate:focus-visible {outline:none;}
.jumpDate:focus-visible .jumpDateFace {outline:2px solid var(--neutral-500);outline-offset:2px;}
.jumpDate:disabled {opacity:.5;cursor:default;}

.dateRail {
  min-width: 0;
  flex: 1;
}

.dateRailHeading {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 0 5px 4px;
  font-size: var(--font-xs);
  color: var(--color-placeholder);
  white-space: nowrap;
}

#dayCaption {
  font-weight: var(--weight-bold);
  color: var(--color-secondary);
  font-variant-numeric: tabular-nums;
}
.archiveToggle {display:inline-flex;align-items:center;gap:5px;cursor:pointer;color:var(--color-secondary);font-size:var(--font-xs);font-weight:400;flex-shrink:0;}
.archiveToggle input {width:15px;height:15px;margin:0;accent-color:var(--color-secondary);}
@media(max-width:760px){.dateRailHeading{padding-inline:2px;gap:4px}.archiveToggle{gap:3px;font-size:11px}.archiveToggle input{width:13px;height:13px}}

#dateStrip {
  position: relative;
  display: flex;
  gap: 3px;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
  padding: 2px;
  scroll-padding-inline: 3px;
}

#dateStrip::-webkit-scrollbar {
  display: none;
}

.dateButton {
  position: relative;
  flex: 0 0 44px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  border: 0;
  border-radius: var(--radius-panel);
  background: transparent;
  padding: 3px 3px 4px;
  color: var(--color-secondary);
  min-height: 58px;
}

.dateButton:hover {
  background: var(--color-hover);
}

.dateButton[aria-pressed=true] {
  background: var(--neutral-100);
  color: var(--color-heading);
}

.dateButton:focus-visible { outline-color: var(--neutral-500); outline-offset: -2px; }

.dateWeekday {
  font-size: var(--font-xs);
  line-height: 13px;
  font-weight: var(--weight-normal);
}

.weekend .dateWeekday {
  color: var(--color-weekend);
}

.dateButton.isPast, .dateButton.isPast .dateWeekday {
  color: var(--color-past-date);
}

.dateButton.isPast[aria-pressed=true] {
  background: var(--color-past-date-selected);
  color: var(--color-secondary);
}

.dateRing {
  position: relative;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  font-size: var(--font-table);
  font-weight: var(--weight-bold);
  font-variant-numeric: tabular-nums;
}

.dateRing canvas {
  position: absolute;
  inset: 0;
  width: 32px;
  height: 32px;
}

.dateNumber {
  position: relative;
}

.dateButton.isToday .dateNumber {
  text-decoration: underline;
  text-underline-offset: 3px;
}

#viewport {
  min-height: 0;
  overflow: auto;
  flex: 1;
  isolation: isolate;
  overflow-anchor: none;
  overscroll-behavior: contain;
  scrollbar-color: var(--color-border-strong) transparent;
  scrollbar-width: thin;
}

#viewport[aria-busy=true] {
  opacity: .65;
  pointer-events: none;
}

table {
  table-layout: fixed;
  border-spacing: 0;
  width: 100%;
  min-width: calc(var(--date-width) + var(--master-width) + 11 * var(--hour-width));
  font-size: var(--font-table);
}

th, td {
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 0;
}

thead th {
  position: sticky;
  top: 0;
  z-index: 3;
  height: 36px;
  background: var(--grid-time-header);
  color: var(--color-heading);
  font-weight: var(--weight-bold);
  font-variant-numeric: tabular-nums;
}

.dayCol, .masterCol {
  position: sticky;
  z-index: 2;
}

.dayCol {
  width: var(--date-width);
  left: 0;
  text-align: center;
  background: var(--grid-date-header);
  color: var(--color-heading);
}

.masterCol {
  width: var(--master-width);
  left: var(--date-width);
  background: var(--color-surface);
  border-right: 2px solid var(--color-border-strong);
  text-align: left;
  padding: 8px;
  font-weight: var(--weight-bold);
}

thead .dayCol, thead .masterCol {
  background: var(--color-page);
  z-index: 4;
  text-align: center;
  padding: 2px;
}

thead .dayCol {
  font-size: 9px;
  color: var(--color-secondary);
}

.firstRow > * {
  border-top: var(--day-gap) solid var(--color-day-gap);
  box-shadow: inset 0 1px 0 var(--color-day-divider);
}

.firstRow:first-child > * {
  border-top: 0;
  box-shadow: none;
}

.todayDate {
  background: var(--slot-today);
  color: var(--color-heading);
}

.pastDate {
  background: var(--grid-past-date-header);
  color: var(--color-secondary);
}

.pastDay > .masterCol {
  color: var(--slot-history-text);
}

.verticalDate {
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  font-weight: var(--weight-bold);
  letter-spacing: 0;
  font-size: var(--font-label);
}

td {
  position: relative;
  height: 58px;
  vertical-align: top;
}

td.free {
  background: var(--color-surface);
}

td.current {
  background: var(--slot-today);
}

td.upcoming {
  background: var(--slot-future);
}

td.elapsed {
  color: var(--slot-elapsed-text);
  background: var(--color-surface);
}

td.dayoff {
  vertical-align: middle;
  color: var(--slot-off-text);
  background: var(--slot-off);
}

td.history {
  color: var(--slot-history-text);
  background: var(--color-surface);
}

.cell {
  display: block;
  width: 100%;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  padding: 5px 4px;
  line-height: var(--leading-table);
  overflow-wrap: anywhere;
}

.cell:disabled {
  opacity: 1;
}

.cell::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 1;
}

.cell:focus-visible {
  outline: 0;
}

.cardLine {
  display: block;
  white-space: pre-wrap;
  font-weight: var(--weight-normal);
}

.cardLine b {
  font-weight: var(--weight-bold);
}

.cardFallback {
  display: none;
}

.cellAction {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%,-50%);
  width: 34px;
  height: 34px;
  z-index: 2;
  display: grid;
  place-items: center;
  border: 1px solid var(--color-border);
  border-radius: 50%;
  background: var(--color-cell-action-bg);
  color: var(--color-secondary);
  pointer-events: none;
  visibility: hidden;
  opacity: 0;
}

.cellAction .icon {
  width: var(--icon-size);
  height: var(--icon-size);
}

@media (hover:hover) {
  td:not(.chosen) .cell:enabled:hover::after {
    box-shadow: inset 0 0 0 2px var(--color-cell-hover-border);
  }
  .cell:enabled:hover .cellAction {
    visibility: visible;
    opacity: 1;
  }
}

.cell:enabled:focus-visible .cellAction {
  visibility: visible;
  opacity: 1;
}

td:not(.chosen) .cell:enabled:focus-visible::after {
  box-shadow: inset 0 0 0 3px var(--color-cell-selected-border);
  background: var(--color-cell-selected-tint);
}

td.chosen .cell::after {
  box-shadow: inset 0 0 0 3px var(--color-cell-selected-border);
  background: var(--color-cell-selected-tint);
}

@media(prefers-reduced-motion:no-preference) {
  .cellAction {
    transition: opacity var(--motion-fast);
  }
}

#loadState {
  padding: 18px;
  color: var(--color-muted);
  font-size: var(--font-label);
}

@media(max-width:760px) {
  .navigation {
    gap: 4px;
    padding: 5px 6px 4px;
  }
  .jumpDate {
    width: 40px;
    height: 50px;
    padding: 0 2px 4px;
  }
  .jumpDateFace {
    width:34px;
    height:34px;
    border-radius:10px;
  }
  .jumpDate .icon {
    width: 21px;
    height: 21px;
  }
  .dateRailHeading {
    font-size: 10px;
    padding-bottom: 2px;
  }
  .dateButton {
    flex-basis: 40px;
    min-height: 50px;
    padding: 4px 2px;
    gap: 2px;
  }
  .dateWeekday {
    font-size: 10px;
    line-height: 12px;
  }
  .dateRing, .dateRing canvas {
    width: 32px;
    height: 32px;
  }
  .dateRing {
    font-size: 12px;
  }
  #dateStrip {
    gap: 2px;
  }
  tbody .masterCol {
    font-size: var(--font-xs);
    padding: 6px 1px;
    text-align: center;
    vertical-align: middle;
  }
  .masterName {
    display: inline-block;
    writing-mode: vertical-rl;
    transform: rotate(180deg);
    white-space: nowrap;
  }
  thead th {
    height: 30px;
    font-size: 12px;
  }
  thead .masterCol {
    padding: 2px 0;
  }
  .masterHeading {
    display: none;
  }
  .verticalDate {
    font-size: 10px;
  }
  td {
    height: 52px;
  }
  .cell {
    padding: 5px 4px;
  }
  .cardLine.isEmpty {
    display: none;
  }
  .cardLine:not(.isEmpty) ~ .cardLine:not(.isEmpty) {
    margin-top: 2px;
  }
  .cardLine b {
    display: block;
    font-size: 11px;
    line-height: 1.2;
    font-weight: var(--weight-bold);
  }
  .cardValue {
    display: block;
    font-size: 12px;
    line-height: 1.2;
  }
  .cardFallback {
    display: block;
  }
}

#calendarHelp {
  margin: 0;
  font-size: var(--font-xs);
  color: var(--color-secondary);
}

#loadState[data-tone=error] {
  color: var(--color-danger);
}

.selectionTools {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  align-items: center;
  padding: 8px 12px;
  background: var(--color-surface);
  border-top: 1px solid var(--line);
}

.selectionTools .button {
  min-height: 38px;
  font-size: 12px;
}

.selecting .cell {
  user-select: none;
  -webkit-touch-callout: none;
}

#slots {
  user-select: none;
  -webkit-touch-callout: none;
}

@media(max-width:760px) {
  .selectionTools {
    flex: 0 0 auto;
    padding-bottom: max(8px,env(safe-area-inset-bottom));
  }
}

/* Brief feedback on changed content, without changing the booking status colour. */
.cellUpdated::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  box-shadow: inset 0 0 0 2px var(--color-action);
  background: rgb(55 89 155 / 10%);
}
@media(prefers-reduced-motion:no-preference) {
  .cellUpdated::before {animation: cell-updated 1200ms ease-out both;}
}
@keyframes cell-updated {
  0%,25% {opacity: 1;}
  100% {opacity: 0;}
}
