/* =========================================================================
   Hours Block — Direction D (today-first, three-layer)

   Layer 1 (Right now)  — banner, title, today panel, topics row
   Layer 2 (Reference)  — weekly schedule, upcoming exceptions, contact bar
   Layer 3 (Disclosure) — "About this service" collapse
   Ported from hours-design-v1/hours-block.css (sections "shared tokens" +
   "DIRECTION D"). Other-direction CSS (A/B/C) is intentionally excluded.
   ========================================================================= */

.ucla-hours {
  /* brand */
  --hb-blue:        #2774AE;
  --hb-blue-dark:   #003B5C;
  --hb-blue-mid:    #005587;
  --hb-blue-tint:   #DAEBFE;
  --hb-gold:        #FFD100;
  --hb-gold-dark:   #B8860B;

  /* neutrals */
  --hb-text:        #1F2937;
  --hb-text-muted:  #4D4D4D;
  --hb-text-faint:  #6B7280;
  --hb-rule:        #E5E7EB;
  --hb-rule-strong: #CCCCCC;
  --hb-surface:     #FFFFFF;

  /* status pill — three states */
  --hb-state-open-bg:    #E6F7EC;
  --hb-state-open-fg:    #1E5631;
  --hb-state-open-mark:  #16A34A;

  --hb-state-soft-bg:    #FFF4D6;          /* amber — ≤30 min closing-soon */
  --hb-state-soft-fg:    #6B4A00;
  --hb-state-soft-mark:  #B8860B;

  --hb-state-closed-bg:  #FCE4E4;
  --hb-state-closed-fg:  #8A1F11;
  --hb-state-closed-mark:#B91C1C;

  /* mode badge palette */
  --hb-mode-dropin-bg:  #DAEBFE;  --hb-mode-dropin-fg:  #003B5C;
  --hb-mode-walkin-bg:  #E1E8DA;  --hb-mode-walkin-fg:  #3F5A2E;
  --hb-mode-appt-bg:    #FFF4D6;  --hb-mode-appt-fg:    #6B4A00;
  --hb-mode-virtual-bg: #DCEFF7;  --hb-mode-virtual-fg: #045A82;
  --hb-mode-fcfs-bg:    #FBE5DF;  --hb-mode-fcfs-fg:    #7A2C18;
  --hb-mode-closed-bg:  #FCE4E4;  --hb-mode-closed-fg:  #8A1F11;

  font-family: Helvetica, Arial, Roboto, system-ui, -apple-system, sans-serif;
  color: var(--hb-text);
  background: var(--hb-surface);
  font-size: 16px;
  line-height: 1.5;
  box-sizing: border-box;
}
.ucla-hours *, .ucla-hours *::before, .ucla-hours *::after { box-sizing: border-box; }

/* ===========================================================================
   DIRECTION D
   =========================================================================== */
.ucla-hours--D {
  border: 1px solid var(--hb-rule);
  border-radius: 4px;
  padding: 0;
  margin: 24px 0;
  overflow: hidden;
}
.ucla-hours--D > .hbd-today:first-of-type,
.ucla-hours--D > .hbd-banner + .hbd-today {
  margin-top: 16px;
}

/* Today banner (when today is a non-closed exception) */
.ucla-hours--D .hbd-banner {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 20px;
  font-size: 14px; font-weight: 500;
  background: var(--hb-state-closed-bg);
  color: var(--hb-state-closed-fg);
  border-bottom: 1px solid var(--hb-rule);
}
.ucla-hours--D .hbd-banner.is-modified {
  background: var(--hb-state-soft-bg);
  color: var(--hb-state-soft-fg);
}
.ucla-hours--D .hbd-banner svg { flex-shrink: 0; }
.ucla-hours--D .hbd-banner strong { font-weight: 700; margin-right: 4px; }

/* Layer 1 — title */
.ucla-hours--D .hbd-head {
  padding: 20px 24px 12px;
}
.ucla-hours--D .hbd-title {
  font-size: 22px; font-weight: 700; line-height: 1.15; letter-spacing: -0.005em;
  color: var(--hb-blue-dark); margin: 0;
}

/* TODAY panel.
   The 4 px left "rail" is drawn as a layered background-image on the
   panel itself rather than a ::before pseudo-element — axe-core's
   color-contrast rule bails with "could not be determined due to a
   pseudo element" the moment it finds a styled pseudo on the element or
   any text-bearing ancestor, regardless of descendants' explicit
   background. background-image avoids that path entirely. */
.ucla-hours--D .hbd-today {
  --hb-panel-bg: #ECF3F9;
  position: relative;
  margin: 0 24px;
  padding: 14px 18px 14px 22px;
  background-color: var(--hb-panel-bg);
  background-image: linear-gradient(180deg, var(--hb-blue-dark) 0%, var(--hb-blue) 100%);
  background-size: 4px 100%;
  background-repeat: no-repeat;
  background-position: 0 0;
  background-clip: border-box;
  border: 1px solid var(--hb-blue-tint);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  flex-wrap: wrap;
}
.ucla-hours--D .hbd-today[data-state="closed"] {
  --hb-panel-bg: #FBF2F2;
  background-image: linear-gradient(180deg, #6B1410 0%, var(--hb-state-closed-mark) 100%);
  border-color: #F0CFCF;
}
.ucla-hours--D .hbd-today[data-state="closing-soon"] {
  --hb-panel-bg: #FCF5DD;
  background-image: linear-gradient(180deg, var(--hb-state-soft-mark) 0%, #E0A800 100%);
  border-color: #EDD89A;
}
.ucla-hours--D .hbd-today-body { flex: 1 1 auto; min-width: 0; }
/* Belt-and-suspenders explicit bg on each text-bearing span — axe walks
   the parent chain only as far as the first solid-bg ancestor; setting
   bg here means the resolved value is independent of any pseudo-element
   on .hbd-today itself. Visually identical (the value matches the panel
   bg per state). */
.ucla-hours--D .hbd-today-body,
.ucla-hours--D .hbd-today-status,
.ucla-hours--D .hbd-today-verb,
.ucla-hours--D .hbd-today-suffix,
.ucla-hours--D .hbd-today-hours,
.ucla-hours--D .hbd-today-tag,
.ucla-hours--D .hbd-today-time,
.ucla-hours--D .hbd-today-guidance,
.ucla-hours--D .hbd-today-closed-text {
  background-color: var(--hb-panel-bg);
}

.ucla-hours--D .hbd-today-status {
  display: flex; align-items: center; gap: 4px 8px;
  flex-wrap: wrap;
  font-size: 15px; font-weight: 700; line-height: 1.2;
  color: var(--hb-state-open-fg);
  margin-bottom: 4px;
}
/* At skinny widths let the suffix ("· Closes at midnight") drop to its own
   full-width line instead of squeezing in beside the verb and breaking
   mid-phrase. */
.ucla-hours--D .hbd-today-suffix { white-space: nowrap; }
.ucla-hours--D .hbd-today-status-icon { color: var(--hb-state-open-mark); display: inline-flex; }
/* Suffix carries the same state foreground as the verb — distinguished by
   font-weight (400 vs 700). Avoid opacity so accessibility scanners can
   compute deterministic contrast per state. */
.ucla-hours--D .hbd-today-suffix { font-weight: 400; }
.ucla-hours--D .hbd-today[data-state="closing-soon"] .hbd-today-status { color: var(--hb-state-soft-fg); }
.ucla-hours--D .hbd-today[data-state="closing-soon"] .hbd-today-status-icon { color: var(--hb-state-soft-mark); }
.ucla-hours--D .hbd-today[data-state="closed"] .hbd-today-status { color: var(--hb-state-closed-fg); }
.ucla-hours--D .hbd-today[data-state="closed"] .hbd-today-status-icon { color: var(--hb-state-closed-mark); }

.ucla-hours--D .hbd-today-hours {
  font-size: 14px;
  color: var(--hb-text);
  font-variant-numeric: tabular-nums;
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 6px;
}
/* Today chip — small uppercase "TODAY" label with a thin outline.
   Each state declares an explicit color so accessibility scanners can
   verify contrast against the panel background. Colors are slightly
   muted vs the verb-text foreground but still pass WCAG AA against the
   per-state panel surface. Border inherits the same color via
   currentColor. */
.ucla-hours--D .hbd-today-tag {
  display: inline-flex; align-items: center;
  font-size: 10px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase;
  color: #325F80; /* AA on panel #ECF3F9 — 5.98:1 */
  padding: 2px 7px;
  border: 1px solid currentColor;
  border-radius: 2px;
  margin-right: 4px;
}
.ucla-hours--D .hbd-today[data-state="closing-soon"] .hbd-today-tag {
  color: #6B4A00; /* AA on panel #FCF5DD — 7.91:1 */
}
.ucla-hours--D .hbd-today[data-state="closed"] .hbd-today-tag {
  color: #8A1F11; /* AA on panel #FBF2F2 — 7.40:1 */
}
.ucla-hours--D .hbd-today-guidance {
  color: var(--hb-text-muted);
  font-style: italic;
}
.ucla-hours--D .hbd-today-closed-text { color: var(--hb-state-closed-fg); font-weight: 500; }

.ucla-hours--D .hbd-cta {
  flex: 0 0 auto;
  display: inline-flex; align-items: center; gap: 6px;
  padding: 10px 16px;
  background: var(--hb-blue);
  color: #FFFFFF;
  font-size: 14px; font-weight: 700;
  text-decoration: none;
  border-radius: 4px;
  transition: background 200ms cubic-bezier(.2,.7,.2,1);
  white-space: nowrap;
}
.ucla-hours--D .hbd-cta:hover { background: var(--hb-blue-dark); color: #FFFFFF; }
.ucla-hours--D .hbd-cta:focus-visible { outline: 2px solid var(--hb-gold); outline-offset: 2px; }

/* Notes — single short paragraph (1 sentence) directly under the TODAY
   panel. Replaces the v1 "Helpful for" topic chips per the v2 spec. */
.ucla-hours--D .hbd-notes {
  padding: 14px 24px 4px;
  margin: 0;
  font-size: 14.5px; line-height: 1.55;
  color: var(--hb-text);
  max-width: none;
}

/* Location — promoted into Layer 1 (above the schedule) so it stays visible
   on blocks with a long exception list. */
.ucla-hours--D .hbd-location {
  display: flex; align-items: center; gap: 8px;
  margin: 0;
  padding: 12px 24px 0;
  font-size: 15px; font-weight: 600; line-height: 1.4;
  color: var(--hb-text);
}
.ucla-hours--D .hbd-location svg { color: var(--hb-blue); flex-shrink: 0; }
.ucla-hours--D .hbd-location-link {
  color: var(--hb-blue-mid); text-decoration: underline; text-underline-offset: 3px;
}
.ucla-hours--D .hbd-location-link:hover { color: var(--hb-blue-dark); }
.ucla-hours--D .hbd-location-link svg { color: var(--hb-blue-mid); }
/* Host site themes add a background-color highlight on a:hover; that turns the
   hours-block text links into dark-on-mid-blue (~1.5:1). Neutralise it so the
   hover state stays high-contrast — the color shift + underline signal hover.
   The CTA button (.hbd-cta) keeps its own background and is excluded. */
.ucla-hours--D .hbd-location-link,
.ucla-hours--D .hbd-location-link:hover,
.ucla-hours--D .hbd-location-link:focus,
.ucla-hours--D .hbd-contact a,
.ucla-hours--D .hbd-contact a:hover,
.ucla-hours--D .hbd-contact a:focus,
.ucla-hours--D .hbd-show-more,
.ucla-hours--D .hbd-show-more:hover {
  background-color: transparent;
}

/* Layer 2 — reference */
.ucla-hours--D .hbd-reference {
  padding: 20px 24px 8px;
  margin-top: 12px;
  border-top: 1px solid var(--hb-rule);
}
.ucla-hours--D .hbd-ref-section + .hbd-ref-section { margin-top: 18px; }
.ucla-hours--D .hbd-section-label {
  display: block;
  font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--hb-text-faint);
  margin-bottom: 8px;
}

/* Seasonal schedule note — shown above the weekly grid when the schedule is
   bounded to a date-range (field_schedule_start/end). */
.ucla-hours--D .hbd-range-note {
  display: flex; align-items: center; gap: 6px;
  margin: 0 0 10px;
  font-size: 13px; color: var(--hb-text-muted);
}
.ucla-hours--D .hbd-range-note svg { color: var(--hb-blue); flex-shrink: 0; }
.ucla-hours--D .hbd-range-note strong { color: var(--hb-text); font-weight: 700; }

.ucla-hours--D .hbd-weekly {
  display: grid;
  grid-template-columns: minmax(7rem, auto) 1fr;
  column-gap: 20px; row-gap: 4px;
  margin: 0;
  font-size: 14px;
}
.ucla-hours--D .hbd-day {
  margin: 0;
  font-weight: 500; color: var(--hb-text-muted);
  background-color: var(--hb-surface);
}
.ucla-hours--D .hbd-day.is-today {
  color: var(--hb-blue-dark); font-weight: 700;
  /* Explicit background so axe-core can compute a deterministic contrast for
     the bold label text — the ::before marker below carries no text and never
     sits behind it. */
  background-color: var(--hb-surface);
}
/* Today-row marker — a ::before pseudo on the today row, drawn with an empty
   content string. No pseudo-text means axe-core's color-contrast rule has no
   marker text to evaluate (the gold dot is decorative), while the day label
   keeps its own explicit background above. Unlike an empty <span>, a
   pseudo-element survives the Entity Embed HTML-normalization pass that strips
   empty inline elements — which is why the dot vanished in embedded blocks. */
.ucla-hours--D .hbd-day.is-today::before {
  content: "";
  display: inline-block;
  width: 6px; height: 6px;
  background-color: var(--hb-gold);
  border-radius: 999px;
  margin-right: 8px;
  vertical-align: 1px;
}
.ucla-hours--D .hbd-times {
  margin: 0;
  color: var(--hb-text-muted);
  font-variant-numeric: tabular-nums;
  background-color: var(--hb-surface);
}
.ucla-hours--D .hbd-times.is-closed { color: var(--hb-mode-closed-fg); }
.ucla-hours--D .hbd-time-part {
  display: inline-flex; align-items: baseline; gap: 6px;
  white-space: nowrap; margin-right: 8px;
}
.ucla-hours--D .hbd-mode-mini {
  font-size: 11px; font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--hb-blue-mid);
  padding-right: 4px;
  border-right: 1px solid var(--hb-rule);
  margin-right: 2px;
}

.ucla-hours--D .hbd-exceptions {
  display: grid;
  grid-template-columns: minmax(7rem, auto) 1fr;
  column-gap: 20px; row-gap: 6px;
  margin: 0;
  font-size: 14px;
}
.ucla-hours--D .hbd-ex-date { margin: 0; font-weight: 700; color: var(--hb-text); }
.ucla-hours--D .hbd-ex-body { margin: 0; display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; }
.ucla-hours--D .hbd-ex-chip {
  display: inline-flex; align-items: center;
  font-size: 11px; font-weight: 700; letter-spacing: 0.04em;
  padding: 2px 8px; border-radius: 2px;
  background: var(--hb-state-closed-bg);
  color: var(--hb-state-closed-fg);
  white-space: nowrap;
}
.ucla-hours--D .hbd-ex-chip.ex-chip-reduced {
  background: var(--hb-state-soft-bg);
  color: var(--hb-state-soft-fg);
}
.ucla-hours--D .hbd-ex-chip.ex-chip-extended {
  background: var(--hb-blue-tint);
  color: var(--hb-blue-dark);
}
.ucla-hours--D .hbd-ex-time { color: var(--hb-text); font-variant-numeric: tabular-nums; }
.ucla-hours--D .hbd-ex-label { color: var(--hb-text-faint); font-style: italic; }

.ucla-hours--D .hbd-show-more {
  margin-top: 10px;
  background: none; border: 0; padding: 0;
  font: inherit; font-size: 13px; font-weight: 700;
  color: var(--hb-blue-mid); text-decoration: underline; text-underline-offset: 3px;
  cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
}
.ucla-hours--D .hbd-show-more:hover { color: var(--hb-blue-dark); }
.ucla-hours--D .hbd-show-more svg { transition: transform 150ms cubic-bezier(.2,.7,.2,1); }
.ucla-hours--D .hbd-show-more[aria-expanded="true"] svg { transform: rotate(180deg); }

/* Contact (compact) */
.ucla-hours--D .hbd-contact {
  display: flex; flex-wrap: wrap; gap: 6px 18px;
  margin-top: 18px; padding-top: 14px;
  border-top: 1px dashed var(--hb-rule);
  font-size: 13px; color: var(--hb-text-muted);
}
.ucla-hours--D .hbd-contact-item { display: inline-flex; align-items: center; gap: 6px; }
.ucla-hours--D .hbd-contact-item svg { color: var(--hb-blue); }
.ucla-hours--D .hbd-contact a { color: var(--hb-blue-mid); text-decoration: underline; text-underline-offset: 3px; }
.ucla-hours--D .hbd-contact a:hover { color: var(--hb-blue-dark); }

/* Layer 3 — disclosure */
.ucla-hours--D .hbd-about {
  background: #FAFAFA;
  border-top: 1px solid var(--hb-rule);
  margin-top: 16px;
}
.ucla-hours--D .hbd-about-toggle {
  background: transparent; border: 0; padding: 14px 24px;
  font: inherit; font-size: 13px; font-weight: 700;
  letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--hb-blue-mid);
  cursor: pointer;
  width: 100%; text-align: left;
  display: flex; align-items: center; justify-content: space-between;
}
.ucla-hours--D .hbd-about-toggle svg { transition: transform 150ms cubic-bezier(.2,.7,.2,1); }
.ucla-hours--D .hbd-about-toggle[aria-expanded="true"] svg { transform: rotate(180deg); }
.ucla-hours--D .hbd-about-toggle:hover { background: #F0F2F4; }
.ucla-hours--D .hbd-about-toggle:focus-visible { outline: 2px solid var(--hb-gold); outline-offset: -2px; }

.ucla-hours--D .hbd-about-body {
  display: grid;
  grid-template-columns: minmax(8rem, auto) 1fr;
  column-gap: 20px; row-gap: 8px;
  margin: 0;
  padding: 8px 24px 20px;
  font-size: 14px;
  border-top: 1px solid var(--hb-rule);
}
.ucla-hours--D .hbd-about-body[hidden],
.ucla-hours--D .hbd-exceptions .is-collapsed[hidden] {
  display: none;
}
.ucla-hours--D .hbd-about-body dt {
  font-weight: 700; color: var(--hb-blue-dark); margin: 0;
  font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase;
  align-self: baseline;
}
.ucla-hours--D .hbd-about-body dd {
  margin: 0; color: var(--hb-text);
}

/* Mobile */
@media (max-width: 600px) {
  .ucla-hours--D .hbd-today {
    align-items: stretch;
  }
  .ucla-hours--D .hbd-cta {
    align-self: flex-start;
  }
  .ucla-hours--D .hbd-weekly,
  .ucla-hours--D .hbd-exceptions,
  .ucla-hours--D .hbd-about-body { grid-template-columns: 1fr; row-gap: 4px; }
}
