/**
 * Pinklove Economic Calendar — TV-like layout, dark chrome for chart app.
 * Mobile-first; denser desktop columns from 900px up.
 */

#plCalendarOverlay {
  /* Dark overrides of calendar-assets/tokens.css */
  --pl-cal-bg: #0c0e15;
  --pl-cal-bg-muted: #131722;
  --pl-cal-bg-hover: #1e222d;
  --pl-cal-bg-today: #2a2e39;
  --pl-cal-border: #2a2e39;
  --pl-cal-divider: #1e222d;
  --pl-cal-text: #d1d4dc;
  --pl-cal-text-secondary: #9598a1;
  --pl-cal-text-muted: #787b86;
  --pl-cal-imp-off: #434651;
  --pl-cal-tab-idle-bg: #1e222d;
  --pl-cal-tab-idle-fg: #d1d4dc;
  --pl-cal-tab-active-bg: #d1d4dc;
  --pl-cal-tab-active-fg: #131722;
  --pl-cal-live-soft: rgba(242, 54, 69, 0.12);

  position: absolute;
  inset: 0;
  inset-inline-end: var(--pl-rail-w, 48px);
  z-index: 31;
  display: none;
  flex-direction: column;
  background: var(--pl-cal-bg);
  color: var(--pl-cal-text);
  font-family: var(--pl-cal-font);
  font-size: var(--pl-cal-fs-body);
  border-inline-end: 1px solid var(--pl-cal-border);
  overflow: hidden;
}

#plCalendarOverlay.is-open {
  display: flex;
}

.pl-cal-top {
  flex: 0 0 auto;
  padding: 12px 16px 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  border-bottom: 1px solid var(--pl-cal-divider);
}

.pl-cal-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 36px;
}

.pl-cal-title-row h1 {
  margin: 0;
  font-family: var(--pl-cal-font-display);
  font-size: var(--pl-cal-fs-title);
  font-weight: var(--pl-cal-fw-title);
  letter-spacing: -0.01em;
  color: var(--pl-cal-text);
  line-height: 1.15;
}

.pl-cal-title-row .pl-cal-close {
  margin-inline-start: auto;
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--pl-cal-text-secondary);
  width: 36px;
  height: 36px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 22px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.pl-cal-title-row .pl-cal-close:hover {
  background: var(--pl-cal-bg-hover);
  color: var(--pl-cal-text);
}

/* Week toolbar */
.pl-cal-weekbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 8px;
  padding-bottom: 4px;
}

.pl-cal-weekbar .pl-cal-chip {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--pl-cal-text);
  height: 32px;
  padding: 0 10px;
  border-radius: 6px;
  font: 500 13px/1 var(--pl-cal-font);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.pl-cal-weekbar .pl-cal-chip:hover,
.pl-cal-weekbar .pl-cal-nav:hover {
  background: var(--pl-cal-bg-hover);
}

.pl-cal-weekbar .pl-cal-nav {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--pl-cal-text);
  width: 32px;
  height: 32px;
  border-radius: 6px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.pl-cal-weekbar .pl-cal-nav img,
.pl-cal-weekbar .pl-cal-chip img {
  width: 18px;
  height: 18px;
  opacity: 0.85;
  filter: invert(1);
}

.pl-cal-weekbar .pl-cal-range {
  font: 500 13px/1.2 var(--pl-cal-font);
  color: var(--pl-cal-text);
  white-space: nowrap;
}

.pl-cal-weekbar .pl-cal-date-hidden {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  width: 0;
  height: 0;
}

/* Week strip */
.pl-cal-strip {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 4px 0 12px;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  /* TV-like thin dark scrollbars */
  scrollbar-width: thin;
  scrollbar-color: #363a45 transparent;
}

.pl-cal-strip::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

.pl-cal-strip::-webkit-scrollbar-track {
  background: transparent;
}

.pl-cal-strip::-webkit-scrollbar-thumb {
  background: #363a45;
  border-radius: 4px;
  border: 2px solid transparent;
  background-clip: padding-box;
}

.pl-cal-strip::-webkit-scrollbar-thumb:hover {
  background: #50535e;
  background-clip: padding-box;
  border: 2px solid transparent;
}

.pl-cal-strip::-webkit-scrollbar-corner {
  background: transparent;
}

.pl-cal-day {
  flex: 0 0 auto;
  min-width: 108px;
  max-width: 140px;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--pl-cal-text);
  cursor: pointer;
  text-align: start;
  font-family: var(--pl-cal-font);
}

.pl-cal-day:hover {
  background: var(--pl-cal-bg-hover);
}

.pl-cal-day.is-today {
  background: var(--pl-cal-bg-today);
}

.pl-cal-day.is-selected {
  border-color: var(--pl-cal-brand);
  background: var(--pl-cal-bg-hover);
}

.pl-cal-day .pl-cal-day-name {
  font: 500 12px/1.2 var(--pl-cal-font);
  color: var(--pl-cal-text-secondary);
  margin-bottom: 4px;
}

.pl-cal-day .pl-cal-day-date {
  font: 600 15px/1.2 var(--pl-cal-font-display);
  margin-bottom: 8px;
}

.pl-cal-day .pl-cal-day-counts {
  display: grid;
  gap: 2px;
  font: 400 11px/1.35 var(--pl-cal-font);
  color: var(--pl-cal-text-muted);
}

.pl-cal-day .pl-cal-day-counts strong {
  color: var(--pl-cal-text-secondary);
  font-weight: 500;
}

/* Tabs + filters */
.pl-cal-tabs-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--pl-cal-divider);
}

.pl-cal-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.pl-cal-tab {
  appearance: none;
  border: 0;
  height: 28px;
  padding: 0 12px;
  border-radius: 14px;
  background: var(--pl-cal-tab-idle-bg);
  color: var(--pl-cal-tab-idle-fg);
  font: 500 13px/1 var(--pl-cal-font);
  cursor: pointer;
  white-space: nowrap;
}

.pl-cal-tab.is-active {
  background: var(--pl-cal-tab-active-bg);
  color: var(--pl-cal-tab-active-fg);
}

.pl-cal-filters {
  margin-inline-start: auto;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
}

.pl-cal-filter {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--pl-cal-text-secondary);
  height: 32px;
  padding: 0 8px;
  border-radius: 6px;
  font: 500 12px/1 var(--pl-cal-font);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.pl-cal-filter:hover,
.pl-cal-filter.is-on {
  background: var(--pl-cal-bg-hover);
  color: var(--pl-cal-text);
}

.pl-cal-filter.is-on {
  color: var(--pl-cal-brand);
}

.pl-cal-filter img {
  width: 18px;
  height: 18px;
  filter: invert(0.75);
}

.pl-cal-filter.is-on img {
  filter: none;
}

/* Event list */
.pl-cal-body {
  flex: 1 1 auto;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  position: relative;
  /* TV-like thin dark scrollbars */
  scrollbar-width: thin;
  scrollbar-color: #363a45 transparent;
}

.pl-cal-body::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

.pl-cal-body::-webkit-scrollbar-track {
  background: transparent;
}

.pl-cal-body::-webkit-scrollbar-thumb {
  background: #363a45;
  border-radius: 4px;
  border: 2px solid transparent;
  background-clip: padding-box;
}

.pl-cal-body::-webkit-scrollbar-thumb:hover {
  background: #50535e;
  background-clip: padding-box;
  border: 2px solid transparent;
}

.pl-cal-body::-webkit-scrollbar-corner {
  background: transparent;
}

.pl-cal-pop {
  scrollbar-width: thin;
  scrollbar-color: #363a45 transparent;
}

.pl-cal-pop::-webkit-scrollbar {
  width: 8px;
}

.pl-cal-pop::-webkit-scrollbar-thumb {
  background: #363a45;
  border-radius: 4px;
  border: 2px solid transparent;
  background-clip: padding-box;
}

.pl-cal-filters {
  scrollbar-width: thin;
  scrollbar-color: #363a45 transparent;
}

.pl-cal-filters::-webkit-scrollbar {
  height: 6px;
}

.pl-cal-filters::-webkit-scrollbar-thumb {
  background: #363a45;
  border-radius: 3px;
}

.pl-cal-status {
  padding: 28px 16px;
  text-align: center;
  color: var(--pl-cal-text-secondary);
  font: 400 14px/1.4 var(--pl-cal-font);
}

.pl-cal-day-group {
  border-bottom: 1px solid var(--pl-cal-divider);
}

.pl-cal-day-head {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--pl-cal-bg-muted);
  padding: 8px 16px;
  font: 600 12px/1.2 var(--pl-cal-font);
  color: var(--pl-cal-text-secondary);
  letter-spacing: 0.02em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--pl-cal-divider);
}

.pl-cal-row {
  display: grid;
  grid-template-columns: 64px 36px minmax(0, 1.4fr) 72px 88px 72px;
  gap: 8px;
  align-items: center;
  padding: 10px 12px;
  border-bottom: 1px solid var(--pl-cal-divider);
  min-height: 48px;
  box-sizing: border-box;
}

.pl-cal-row:hover {
  background: var(--pl-cal-bg-hover);
}

.pl-cal-row.is-live {
  background: var(--pl-cal-live-soft);
}

.pl-cal-c-time {
  font: 500 12px/1.2 var(--pl-cal-font);
  color: var(--pl-cal-text-secondary);
  white-space: nowrap;
}

.pl-cal-c-time.is-live,
.pl-cal-c-time.is-soon {
  color: var(--pl-cal-live);
  font-weight: 600;
}

.pl-cal-c-flag {
  width: var(--pl-cal-flag-size);
  height: var(--pl-cal-flag-size);
  border-radius: 50%;
  overflow: hidden;
  display: block;
  background: var(--pl-cal-bg-hover);
  object-fit: cover;
  flex-shrink: 0;
}

.pl-cal-c-flag-fallback {
  width: var(--pl-cal-flag-size);
  height: var(--pl-cal-flag-size);
  border-radius: 50%;
  background: var(--pl-cal-bg-today);
  color: var(--pl-cal-text-secondary);
  font: 600 8px/18px var(--pl-cal-font);
  text-align: center;
  display: block;
}

.pl-cal-c-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.pl-cal-c-country {
  font: 400 11px/1.2 var(--pl-cal-font);
  color: var(--pl-cal-text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

.pl-cal-c-title {
  font: 500 13px/1.25 var(--pl-cal-font);
  color: var(--pl-cal-text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pl-cal-c-imp {
  display: inline-flex;
  align-items: center;
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.pl-cal-c-imp svg {
  width: 18px;
  height: 18px;
  display: block;
}

.pl-cal-c-actual,
.pl-cal-c-forecast,
.pl-cal-c-prior {
  font: 500 12px/1.2 var(--pl-cal-font);
  color: var(--pl-cal-text);
  text-align: end;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.pl-cal-c-actual.is-soon {
  color: var(--pl-cal-live);
  font-weight: 600;
}

.pl-cal-c-forecast,
.pl-cal-c-prior {
  color: var(--pl-cal-text-secondary);
}

.pl-cal-col-labels {
  display: none;
  grid-template-columns: 64px 36px minmax(0, 1.4fr) 72px 88px 72px;
  gap: 8px;
  padding: 6px 12px;
  font: 500 11px/1 var(--pl-cal-font);
  color: var(--pl-cal-text-muted);
  border-bottom: 1px solid var(--pl-cal-divider);
  position: sticky;
  top: 0;
  z-index: 3;
  background: var(--pl-cal-bg);
}

.pl-cal-col-labels span:nth-child(n + 4) {
  text-align: end;
}

/* Popovers */
.pl-cal-pop {
  position: absolute;
  z-index: 40;
  min-width: 200px;
  max-width: min(280px, 92vw);
  max-height: 280px;
  overflow: auto;
  background: var(--pl-cal-bg-muted);
  border: 1px solid var(--pl-cal-border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  padding: 6px;
  display: none;
}

.pl-cal-pop.is-open {
  display: block;
}

.pl-cal-pop button {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--pl-cal-text);
  width: 100%;
  text-align: start;
  padding: 8px 10px;
  border-radius: 4px;
  font: 400 13px/1.2 var(--pl-cal-font);
  cursor: pointer;
}

.pl-cal-pop button:hover,
.pl-cal-pop button.is-active {
  background: var(--pl-cal-bg-hover);
}

.pl-cal-pop button.is-active {
  color: var(--pl-cal-brand);
}

/* —— Responsive —— */
@media (max-width: 899px) {
  #plCalendarOverlay {
    inset-inline-end: 0;
    /* leave room for collapsed/expanded rail via same var when present */
    inset-inline-end: var(--pl-rail-w, 0px);
  }

  .pl-cal-top {
    padding: 10px 12px 0;
  }

  .pl-cal-title-row h1 {
    font-size: 20px;
  }

  .pl-cal-tabs-row {
    padding: 8px 12px;
    gap: 8px;
  }

  .pl-cal-filters {
    margin-inline-start: 0;
    width: 100%;
    overflow-x: auto;
    flex-wrap: nowrap;
    padding-bottom: 2px;
  }

  .pl-cal-row {
    grid-template-columns: 52px 28px minmax(0, 1fr) 64px;
    grid-template-areas:
      "time flag main actual"
      "time flag main forecast";
    gap: 4px 8px;
    padding: 10px 12px;
  }

  .pl-cal-c-time {
    grid-area: time;
    align-self: start;
    padding-top: 2px;
  }

  .pl-cal-c-flag,
  .pl-cal-c-flag-fallback {
    grid-area: flag;
    align-self: start;
    margin-top: 2px;
  }

  .pl-cal-c-main {
    grid-area: main;
  }

  .pl-cal-c-actual {
    grid-area: actual;
    align-self: end;
  }

  .pl-cal-c-forecast {
    grid-area: forecast;
    align-self: start;
    font-size: 11px;
  }

  .pl-cal-c-prior,
  .pl-cal-c-imp-desk {
    display: none;
  }

  .pl-cal-c-country .pl-cal-imp {
    display: inline-flex;
  }

  .pl-cal-day {
    min-width: 96px;
    padding: 8px 10px;
  }
}

@media (min-width: 900px) {
  .pl-cal-col-labels {
    display: grid;
  }

  .pl-cal-row {
    grid-template-columns: 72px 28px 22px minmax(140px, 1.6fr) 96px 88px 80px;
  }

  .pl-cal-col-labels {
    grid-template-columns: 72px 28px 22px minmax(140px, 1.6fr) 96px 88px 80px;
  }

  .pl-cal-c-country {
    /* country name sits under title on desktop too for density */
  }

  .pl-cal-c-imp-desk {
    display: inline-flex;
  }

  .pl-cal-c-country .pl-cal-imp {
    display: none;
  }

  .pl-cal-day {
    flex: 1 1 0;
    max-width: none;
    min-width: 0;
  }
}

@media (max-width: 480px) {
  .pl-cal-weekbar .pl-cal-range {
    width: 100%;
    order: 5;
    padding: 2px 2px 6px;
  }

  .pl-cal-day .pl-cal-day-counts span:nth-child(n + 3) {
    display: none;
  }
}

/* Safe areas (notched phones) */
@supports (padding: max(0px)) {
  #plCalendarOverlay {
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
}
