/* NARA Datepicker v1.1 — uses the NARA theme tokens, with literal fallbacks for any other theme.
   Day states mirror the site calendar (.nara-cal). Colour pairs are the spec's pre-verified AA pairs:
   success/success-soft 5.23, white/success 6.05, white/fuksia 5.34, white/fuksia-hover 7.23,
   ink-soft/white 7.92, ink-soft/hatch 4.84-6.91, ink/white 17.86. */

.nara-dp { position: relative; }

/* Trigger: looks exactly like the other form inputs */
.nara-dp__trigger {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  width: 100%; min-height: 52px; margin: 0; padding: 12px 16px;
  border: 2px solid var(--x-c-field, #8B82A3); border-radius: var(--r-md, 16px);
  background: var(--c-bg, #fff); color: var(--c-ink, #1B1230);
  font: inherit; font-family: var(--f-body, inherit); font-size: 16px; line-height: 1.3; text-align: left;
  cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.nara-dp__trigger:hover { border-color: var(--c-ink-soft, #564C6D); }
.nara-dp.is-open .nara-dp__trigger,
.nara-dp__trigger:focus-visible { border-color: var(--c-primary, #CC1477); }
.nara-dp__trigger:focus-visible { outline: 3px solid var(--x-focus, #1B1230); outline-offset: 2px; }
.nara-dp__value { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nara-dp__value.is-placeholder { color: var(--x-c-placeholder, #6E6688); }
.nara-dp__icon { flex: none; width: 20px; height: 20px; color: var(--c-ink, #1B1230); }
.nara-dp.has-value .nara-dp__icon { color: var(--c-primary, #CC1477); }

/* Popover: a speech bubble growing out of the field (small corner top-left).
   z-index stays below the sticky site header (50) so it scrolls under it like other content. */
.nara-dp__pop {
  position: absolute; z-index: 40; top: calc(100% + 8px); left: 0;
  width: max(100%, 300px); max-width: min(384px, calc(100vw - 32px));
  padding: 16px; box-sizing: border-box;
  background: var(--c-bg, #fff); color: var(--c-ink, #1B1230);
  border: 2px solid var(--c-line, #E1DBEE); border-radius: 4px 24px 24px 24px;
  box-shadow: var(--sh-md, 0 18px 40px -12px rgba(27, 18, 48, .28));
}
.nara-dp__pop[hidden] { display: none !important; }
.nara-dp__pop:focus { outline: none; } /* only reached by clicks on blank areas */

.nara-dp__head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 0 0 8px; }
.nara-dp__title {
  margin: 0; font-family: var(--f-display, inherit); font-weight: 800; font-stretch: 110%;
  font-size: 1.25rem; line-height: 1.1; letter-spacing: -.01em; color: var(--c-ink, #1B1230);
}
.nara-dp__year { margin-inline-start: 2px; font-weight: 600; font-stretch: 100%; font-size: .9em; color: var(--c-ink-soft, #564C6D); }
.nara-dp__nav {
  flex: none; display: grid; place-items: center; width: 44px; height: 44px; margin: 0; padding: 0;
  border: 2px solid var(--c-line, #E1DBEE); border-radius: 999px;
  background: var(--c-bg, #fff); color: var(--c-ink, #1B1230); cursor: pointer;
}
.nara-dp__nav svg { width: 20px; height: 20px; }
.nara-dp__nav:hover:not([aria-disabled="true"]) { border-color: var(--c-ink, #1B1230); }
.nara-dp__nav[aria-disabled="true"] { opacity: .35; cursor: default; }

/* Grid */
.nara-dp__grid {
  width: calc(100% + 8px); margin: 0 -4px; table-layout: fixed;
  border-collapse: separate; border-spacing: 4px;
}
.nara-dp__grid th {
  padding: 2px 0 4px; font-size: .75rem; font-weight: 700; line-height: 1.2;
  color: var(--c-ink-soft, #564C6D); text-align: center;
}
.nara-dp__grid th.is-weekend { color: var(--c-ink, #1B1230); }
.nara-dp__grid th.is-weekend > span[aria-hidden] {
  text-decoration: underline 3px var(--c-accent, #FFC530); text-underline-offset: 5px;
}
.nara-dp__grid td { padding: 0; text-align: center; vertical-align: middle; }

.nara-dp__day {
  position: relative; display: grid; place-items: center;
  width: 100%; aspect-ratio: 1 / 1; min-height: 36px; margin: 0; padding: 0;
  border: 0; border-radius: var(--r-sm, 8px); background: transparent;
  color: var(--c-ink, #1B1230); font: inherit; font-family: var(--f-body, inherit);
  font-size: .9375rem; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums;
  cursor: pointer; -webkit-tap-highlight-color: transparent;
  transition: background-color var(--x-dur-1, 160ms) var(--x-ease, ease), color var(--x-dur-1, 160ms) var(--x-ease, ease);
}
/* Free: mint fill, green digits, a dot hanging just under the digits */
.nara-dp__day.is-free { background: var(--c-success-soft, #D9F5E6); color: var(--c-success, #0B7148); }
.nara-dp__day.is-free::after {
  content: ""; position: absolute; left: 50%; top: calc(50% + .45em + 2px); width: 4px; height: 4px; margin-left: -2px;
  border-radius: 50%; background: currentColor;
}
.nara-dp__day.is-free:hover { background: var(--c-success, #0B7148); color: #fff; }
/* Busy: the site calendar's hatch + strike; still selectable */
.nara-dp__day.is-busy {
  background: repeating-linear-gradient(-45deg, var(--x-c-hatch, #CFC6E2) 0 1.5px, var(--x-c-hatch-bg, #F1EEF8) 1.5px 6px);
  color: var(--c-ink-soft, #564C6D); font-weight: 500;
}
.nara-dp__day.is-busy .nara-dp__num { text-decoration: line-through 2px; }
.nara-dp__day.is-busy:hover { box-shadow: inset 0 0 0 2px var(--c-ink-soft, #564C6D); }
/* Past: plain ink-soft like the site calendar (7.92:1), not selectable */
.nara-dp__day.is-past { color: var(--c-ink-soft, #564C6D); font-weight: 400; background: none; cursor: default; }
.nara-dp__day.is-today { box-shadow: inset 0 0 0 2px var(--c-ink, #1B1230); }
/* Selected */
.nara-dp__day.is-selected,
.nara-dp__day.is-selected:hover { background: var(--c-primary, #CC1477); color: #fff; box-shadow: none; }
.nara-dp__day.is-selected .nara-dp__num { text-decoration: none; }
.nara-dp__day.is-selected::after { background: #fff; }
/* A selected BUSY day keeps both busy cues: hatch (in fuksia tones) and strike */
.nara-dp__day.is-selected.is-busy,
.nara-dp__day.is-selected.is-busy:hover {
  background: repeating-linear-gradient(-45deg, var(--x-c-primary-hover, #A8105F) 0 2px, var(--c-primary, #CC1477) 2px 7px);
}
.nara-dp__day.is-selected.is-busy .nara-dp__num { text-decoration: line-through 2px; }
/* Occasion notch: same shape as the site calendar's party-hat triangle */
.nara-dp__occ {
  position: absolute; top: 3px; right: 3px; width: 8px; height: 8px;
  background: var(--c-primary, #CC1477); clip-path: polygon(50% 0, 100% 100%, 0 100%);
}
.nara-dp__day.is-selected .nara-dp__occ,
.nara-dp__day.is-free:hover .nara-dp__occ,
.nara-dp__day.is-free:focus-visible .nara-dp__occ { background: #fff; }

/* Footer: legend + actions */
.nara-dp__foot {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px;
  margin-top: 10px; padding-top: 10px; border-top: 2px solid var(--c-line, #E1DBEE);
}
.nara-dp__legend {
  display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 0; padding: 0; list-style: none;
  font-size: .8125rem; line-height: 1.3; color: var(--c-ink-soft, #564C6D);
}
.nara-dp__legend li { display: flex; align-items: center; gap: 6px; margin: 0; }
.nara-dp__sw { position: relative; display: inline-block; width: 14px; height: 14px; border-radius: 4px; }
.nara-dp__sw.is-free { background: var(--c-success-soft, #D9F5E6); box-shadow: inset 0 0 0 1px var(--c-success, #0B7148); }
.nara-dp__sw.is-free::after {
  content: ""; position: absolute; left: 5px; top: 5px; width: 4px; height: 4px; border-radius: 50%;
  background: var(--c-success, #0B7148);
}
.nara-dp__sw.is-busy { background: repeating-linear-gradient(-45deg, var(--x-c-hatch, #CFC6E2) 0 1.5px, var(--x-c-hatch-bg, #F1EEF8) 1.5px 4px); }
.nara-dp__actions { display: flex; flex-wrap: wrap; gap: 2px; margin-left: auto; }
.nara-dp__btn {
  min-height: 44px; margin: 0; padding: 0 12px; border: 0; border-radius: 999px;
  background: transparent; color: var(--c-ink, #1B1230);
  font: inherit; font-family: var(--f-body, inherit); font-size: .9375rem; font-weight: 700; cursor: pointer;
  text-decoration: underline 2px var(--c-primary, #CC1477); text-underline-offset: 5px; /* text-link look at rest */
}
.nara-dp__btn:hover { text-decoration-color: var(--x-c-primary-hover, #A8105F); }
.nara-dp__btn--close { border: 2px solid var(--c-ink, #1B1230); padding: 0 16px; text-decoration: none; }
.nara-dp__btn--close:hover { background: var(--c-ink, #1B1230); color: #fff; }
.nara-dp__btn[hidden] { display: none !important; }

/* Focus everywhere inside the picker */
.nara-dp__nav:focus-visible,
.nara-dp__day:focus-visible,
.nara-dp__btn:focus-visible { outline: 3px solid var(--x-focus, #1B1230); outline-offset: 2px; position: relative; z-index: 1; }

/* Narrow phones */
@media (max-width: 420px) {
  .nara-dp__pop { padding: 12px; border-radius: 4px 20px 20px 20px; }
  .nara-dp__grid { width: calc(100% + 6px); margin: 0 -3px; border-spacing: 3px; }
  .nara-dp__day { min-height: 34px; }
  .nara-dp__title { font-size: 1.125rem; }
}
@media (max-width: 359px) {
  .nara-dp__day { font-size: .875rem; }
}

/* Motion (one gentle entrance; none under reduced motion) */
@media (prefers-reduced-motion: no-preference) {
  .nara-dp__pop:not([hidden]) { animation: nara-dp-in 160ms cubic-bezier(.2, .8, .2, 1); }
  @keyframes nara-dp-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
}
@media (prefers-reduced-motion: reduce) {
  .nara-dp__day { transition: none; }
}

/* Windows high contrast / forced colours */
@media (forced-colors: active) {
  .nara-dp__pop { border: 2px solid CanvasText; }
  .nara-dp__day { border: 1px solid CanvasText; }
  .nara-dp__day.is-past { border-style: dotted; }
  .nara-dp__day.is-selected { background: Highlight; color: HighlightText; forced-color-adjust: none; }
  .nara-dp__day.is-today { box-shadow: none; border: 2px solid Highlight; } /* outline stays free for focus */
  .nara-dp__day:focus-visible { outline: 3px solid CanvasText; outline-offset: 2px; }
  .nara-dp__day.is-free::after { background: CanvasText; }
  .nara-dp__day.is-selected::after { background: HighlightText; }
  .nara-dp__day.is-busy .nara-dp__num { text-decoration: line-through; }
  .nara-dp__occ { forced-color-adjust: none; background: CanvasText; }
  .nara-dp__day.is-selected .nara-dp__occ { background: HighlightText; }
  .nara-dp__sw { forced-color-adjust: none; background: Canvas; box-shadow: inset 0 0 0 1px CanvasText; }
  .nara-dp__sw.is-free::after { background: CanvasText; }
  .nara-dp__sw.is-busy { background: repeating-linear-gradient(-45deg, CanvasText 0 1px, Canvas 1px 4px); }
  .nara-dp__nav[aria-disabled="true"] { opacity: 1; color: GrayText; border-color: GrayText; }
}
