/*! Hawks Calendar 1.0 styles. Theme it by setting these on :root or on any ancestor of a date field:
 *   --cal-bg          popup background            --cal-fg         text
 *   --cal-muted       weekday names, other months --cal-line       borders and dividers
 *   --cal-accent      selected day, focus ring    --cal-accent-fg  text on the accent
 *   --cal-hover       day hover background        --cal-today      ring on today's date
 *   --cal-radius      popup corners               --cal-day-radius day / option corners
 *   --cal-font        body font                   --cal-title-font month title font
 *   --cal-shadow      popup shadow                --cal-backdrop   phone sheet backdrop
 */
.hcal {
  --_bg: var(--cal-bg, #ffffff);
  --_fg: var(--cal-fg, #111827);
  --_muted: var(--cal-muted, #6b7280);
  --_line: var(--cal-line, rgba(17, 24, 39, 0.1));
  --_accent: var(--cal-accent, #f99c00);
  --_accent-fg: var(--cal-accent-fg, #111827);
  --_hover: var(--cal-hover, rgba(17, 24, 39, 0.06));
  --_today: var(--cal-today, var(--_accent));
  --_day-r: var(--cal-day-radius, 999px);
  position: fixed;
  z-index: 2147483000;
  display: flex;
  gap: 0;
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  max-width: calc(100vw - 16px);
  background: var(--_bg);
  color: var(--_fg);
  border: 1px solid var(--_line);
  border-radius: var(--cal-radius, 16px);
  box-shadow: var(--cal-shadow, 0 24px 60px -18px rgba(0, 0, 0, 0.35), 0 2px 8px rgba(0, 0, 0, 0.06));
  font-family: var(--cal-font, inherit);
  font-size: 14px;
  line-height: 1.2;
  text-align: left;
  -webkit-font-smoothing: antialiased;
  animation: hcal-in 140ms cubic-bezier(0.16, 1, 0.3, 1);
  color-scheme: light dark;
}
.hcal *, .hcal *::before, .hcal *::after { box-sizing: border-box; }
.hcal button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  margin: 0;
  padding: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.hcal button:disabled { cursor: default; }
.hcal button:focus { outline: none; }
.hcal button:focus-visible { outline: 2px solid var(--_accent); outline-offset: 1px; }

.hcal-main { padding: 12px 12px 10px; width: 300px; max-width: 100%; }
.hcal-head { display: flex; align-items: center; justify-content: space-between; gap: 4px; margin-bottom: 6px; }
.hcal-title {
  flex: 1;
  padding: 7px 8px !important;
  border-radius: 10px;
  font-family: var(--cal-title-font, inherit) !important;
  font-size: 15px !important;
  font-weight: 600;
  letter-spacing: 0.01em;
  text-align: center;
}
.hcal-title:hover { background: var(--_hover) !important; }
.hcal-nav {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: var(--_day-r);
  color: var(--_fg);
}
.hcal-nav:hover:not(:disabled) { background: var(--_hover) !important; }
.hcal-nav:disabled { opacity: 0.28; }

.hcal-grid { width: 100%; border-collapse: separate; border-spacing: 2px; table-layout: fixed; }
.hcal-grid th {
  padding: 6px 0 4px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--_muted);
  text-align: center;
}
.hcal-grid td { padding: 0; text-align: center; }
.hcal-day {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 100%;
  max-width: 38px;
  aspect-ratio: 1;
  border-radius: var(--_day-r);
  font-variant-numeric: tabular-nums;
  font-size: 13.5px;
  transition: background-color 120ms ease, color 120ms ease, transform 120ms ease;
}
.hcal-day:hover:not(:disabled):not(.hcal-on) { background: var(--_hover) !important; }
.hcal-day.hcal-out { color: var(--_muted); opacity: 0.55; }
.hcal-day:disabled { opacity: 0.25; text-decoration: line-through; text-decoration-thickness: 1px; }
.hcal-day.hcal-today:not(.hcal-on) { box-shadow: inset 0 0 0 1.5px var(--_today); font-weight: 600; }
.hcal-day.hcal-on, .hcal-month.hcal-on, .hcal-opt.hcal-on {
  background: var(--_accent) !important;
  color: var(--_accent-fg) !important;
  font-weight: 700;
}
.hcal-day:active:not(:disabled) { transform: scale(0.94); }

.hcal-months { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; padding: 4px 2px 6px; }
.hcal-month { padding: 12px 0 !important; border-radius: 10px; font-weight: 500; }
.hcal-month:hover:not(:disabled):not(.hcal-on) { background: var(--_hover) !important; }
.hcal-month:disabled { opacity: 0.3; }

.hcal-foot {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 6px;
  padding-top: 8px;
  border-top: 1px solid var(--_line);
}
.hcal-link { padding: 7px 10px !important; border-radius: 8px; font-size: 13px; font-weight: 600; color: var(--_fg); }
.hcal-link:hover:not(:disabled) { background: var(--_hover) !important; }
.hcal-link:disabled { opacity: 0.3; }
.hcal-done {
  margin-left: auto !important;
  padding: 8px 16px !important;
  border-radius: var(--_day-r);
  background: var(--_accent) !important;
  color: var(--_accent-fg) !important;
  font-size: 13px;
  font-weight: 700;
}

.hcal-time { display: flex; flex-direction: column; padding: 12px 12px 10px 4px; border-left: 1px solid var(--_line); }
.hcal-time-label {
  padding: 9px 0 8px;
  text-align: center;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--_muted);
}
.hcal-cols { display: flex; gap: 4px; flex: 1; min-height: 0; }
.hcal-col {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 2px;
  width: 52px;
  height: 268px;
  padding: 2px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
}
.hcal-opt { padding: 7px 0 !important; border-radius: 8px; font-variant-numeric: tabular-nums; text-align: center; flex: none; }
.hcal-opt:hover:not(.hcal-on) { background: var(--_hover) !important; }

/* phones: a bottom sheet */
.hcal-backdrop { display: none; }
.hcal-backdrop.hcal-show {
  display: block;
  position: fixed;
  inset: 0;
  z-index: 2147482999;
  background: var(--cal-backdrop, rgba(0, 0, 0, 0.4));
  animation: hcal-fade 160ms ease;
}
.hcal.hcal-sheet {
  left: 0 !important;
  right: 0;
  bottom: 0;
  top: auto !important;
  max-width: none;
  width: 100%;
  flex-direction: column;
  border-radius: var(--cal-radius, 16px) var(--cal-radius, 16px) 0 0;
  border-bottom: 0;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  max-height: 92vh;
  overflow-y: auto;
  animation: hcal-up 200ms cubic-bezier(0.16, 1, 0.3, 1);
}
.hcal-sheet .hcal-main { width: 100%; max-width: 420px; margin: 0 auto; padding: 16px 16px 20px; }
.hcal-sheet .hcal-day { max-width: 46px; font-size: 15px; }
.hcal-sheet .hcal-time { border-left: 0; border-top: 1px solid var(--_line); padding: 4px 16px 16px; }
.hcal-sheet .hcal-cols { justify-content: center; }
.hcal-sheet .hcal-col { height: 168px; width: 72px; }

@keyframes hcal-in { from { opacity: 0; transform: translateY(-4px) scale(0.985); } }
@keyframes hcal-up { from { transform: translateY(100%); } }
@keyframes hcal-fade { from { opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  .hcal, .hcal-backdrop.hcal-show, .hcal.hcal-sheet { animation: none; }
  .hcal-day { transition: none; }
}

/* the field: the themed button that replaces the system picker. These are defaults in the base layer, so
   the site's own classes on the field (Tailwind utilities, a .form-input rule, ...) always win. */
@layer base {
  .hcal-trigger {
    display: inline-flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    text-align: left;
    cursor: pointer;
    white-space: nowrap;
    font: inherit;
    color: inherit;
  }
  .hcal-trigger:disabled { cursor: not-allowed; opacity: 0.6; }
  .hcal-trigger .hcal-value { overflow: hidden; text-overflow: ellipsis; }
  .hcal-trigger .hcal-icon { flex: none; opacity: 0.65; }
  .hcal-trigger:hover:not(:disabled) .hcal-icon { opacity: 1; }
  .hcal-placeholder { opacity: 0.55; }
}
/* text + icon row inside the field: its own element, so a display class on the field (block, inline-block)
   can't break the layout */
.hcal-row { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; width: 100%; min-width: 0; }
.hcal-row .hcal-value { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hcal-trigger.hcal-invalid { outline: 2px solid #dc2626; outline-offset: 1px; }

/* the real input stays in the form (name, value, required) but off screen */
.hcal-native {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  min-width: 0 !important;
  min-height: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
  border: 0 !important;
  opacity: 0 !important;
  pointer-events: none !important;
  clip-path: inset(50%) !important;
}
