/* ============================================================
   Catchup — modern-minimal daily activity visualizer
   ============================================================ */

:root {
  --bg: #f7f8fa;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --border: #e3e6ea;
  --border-strong: #d2d7dd;
  --text: #1a1d21;
  --text-muted: #687078;
  --text-faint: #9aa1a9;
  --accent: #4f46e5;
  --accent-soft: #ecebfc;
  --accent-text: #4338ca;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.06);
  --shadow-md: 0 6px 24px rgba(16, 24, 40, 0.10);
  --radius: 10px;
  --radius-sm: 7px;
  --topbar-h: auto;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial,
    "Apple Color Emoji", "Segoe UI Emoji", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --surface: #171a20;
    --surface-2: #1f232b;
    --border: #272c35;
    --border-strong: #343a45;
    --text: #e8eaed;
    --text-muted: #9aa1ab;
    --text-faint: #6b727c;
    --accent: #7c75ff;
    --accent-soft: #20223a;
    --accent-text: #b5b0ff;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 6px 24px rgba(0, 0, 0, 0.5);
  }
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ===================== Top bar ===================== */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-areas:
    "brand controls"
    "chips chips";
  gap: 12px 20px;
  align-items: center;
  padding: 14px 24px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--border);
}

.topbar__brand {
  grid-area: brand;
  display: flex;
  align-items: center;
  gap: 12px;
}
.topbar__logo {
  font-size: 22px;
  color: var(--accent);
  line-height: 1;
}
.topbar__title {
  margin: 0;
  font-size: 17px;
  font-weight: 650;
  letter-spacing: -0.01em;
}
.topbar__subtitle {
  margin: 0;
  font-size: 12.5px;
  color: var(--text-muted);
}

.topbar__controls {
  grid-area: controls;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.chips {
  grid-area: chips;
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}
.chips:empty { display: none; }

/* ===================== Dropdown ===================== */
.dropdown { position: relative; }

.dropdown__toggle,
.datebtn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  padding: 0 13px;
  font: inherit;
  font-size: 13.5px;
  font-weight: 550;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.dropdown__toggle:hover,
.datebtn:hover { border-color: var(--accent); }
.dropdown__toggle[aria-expanded="true"] {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.dropdown__caret { color: var(--text-muted); }

.dropdown__panel {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  width: 320px;
  max-width: 80vw;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 10px;
  z-index: 50;
}
.dropdown__search input {
  width: 100%;
  height: 34px;
  padding: 0 10px;
  font: inherit;
  font-size: 13.5px;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.dropdown__search input:focus {
  outline: none;
  border-color: var(--accent);
}
.dropdown__actions {
  display: flex;
  justify-content: flex-end;
  padding: 6px 2px 4px;
}
.linkbtn {
  font: inherit;
  font-size: 12.5px;
  color: var(--accent-text);
  background: none;
  border: none;
  cursor: pointer;
  padding: 2px 4px;
}
.linkbtn:hover { text-decoration: underline; }

.dropdown__list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 320px;
  overflow-y: auto;
}
.dropdown__item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13.5px;
}
.dropdown__item:hover { background: var(--surface-2); }
.dropdown__item.is-hidden { display: none; }
.dropdown__item input { accent-color: var(--accent); width: 15px; height: 15px; }
.dropdown__item .repo-org { color: var(--text-faint); }

/* ===================== Chips ===================== */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 11px;
  font-size: 12.5px;
  font-weight: 550;
  color: var(--text-muted);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  cursor: pointer;
  transition: all .14s;
  white-space: nowrap;
}
.chip:hover { border-color: var(--accent); color: var(--text); }
.chip.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.chip__check { font-size: 10px; opacity: 0; transition: opacity .12s; }
.chip.is-active .chip__check { opacity: 1; }

/* Selected-developer chips are static (span) with a remove button */
.chip.is-active { cursor: default; }
.chip__remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  padding: 0;
  margin-right: -4px;
  color: rgba(255, 255, 255, 0.75);
  background: rgba(255, 255, 255, 0.18);
  border: none;
  border-radius: 50%;
  cursor: pointer;
}
.chip__remove svg { display: block; }
.chip__remove:hover { color: #fff; background: rgba(255, 255, 255, 0.32); }

/* ===================== Segmented toggle ===================== */
.segmented {
  display: inline-flex;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 2px;
}
.segmented__btn {
  font: inherit;
  font-size: 12.5px;
  font-weight: 550;
  color: var(--text-muted);
  background: none;
  border: none;
  padding: 6px 12px;
  border-radius: 5px;
  cursor: pointer;
}
.segmented__btn.is-active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

/* ===================== Layout ===================== */
.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 312px;
  gap: 28px;
  max-width: 1320px;
  margin: 0 auto;
  padding: 26px 24px 64px;
  align-items: start;
}

/* ===================== Feed ===================== */
.feed-col { min-width: 0; }
.feed { min-width: 0; }

.feed-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
}
.feed-bar__label {
  font-size: 12.5px;
  font-weight: 550;
  color: var(--text-muted);
}

.repo-section { margin-bottom: 26px; }
.repo-section__head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.repo-section__org { color: var(--text-faint); font-weight: 500; }
.repo-section__name {
  font-size: 16px;
  font-weight: 650;
  letter-spacing: -0.01em;
}
.repo-section__meta {
  margin-left: auto;
  font-size: 12px;
  color: var(--text-faint);
}

.dev-block {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 10px;
  box-shadow: var(--shadow-sm);
}
.dev-block__head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 9px;
}
.avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 650;
  color: #fff;
  flex: none;
}
.dev-block__name { font-weight: 600; font-size: 14px; }
.dev-block__login { font-size: 12px; color: var(--text-faint); }
.badge {
  margin-left: auto;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--accent-text);
  background: var(--accent-soft);
  padding: 2px 9px;
  border-radius: 999px;
  white-space: nowrap;
}

.bullets { list-style: none; margin: 0; padding: 0; }
.bullets li {
  display: flex;
  gap: 9px;
  padding: 4px 0;
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--text);
}
.bullets .b-emoji { flex: none; }
.bullets .b-text { color: var(--text); }

/* ===================== Empty / loading states ===================== */
.state {
  text-align: center;
  color: var(--text-muted);
  padding: 64px 20px;
  font-size: 14px;
}
.state__icon { font-size: 30px; display: block; margin-bottom: 10px; opacity: .6; }
.state__sub { font-size: 12.5px; color: var(--text-faint); margin-top: 6px; }

/* ===================== Sidebar / calendar ===================== */
.sidebar {
  position: sticky;
  top: 92px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow-sm);
}
.sidebar__heading {
  margin: 0 0 12px;
  font-size: 12px;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
}
.sidebar__hint {
  margin: 12px 0 0;
  font-size: 11.5px;
  color: var(--text-faint);
  text-align: center;
}

/* The date button + scrim only matter on mobile */
.datebtn { display: none; }
.scrim {
  position: fixed;
  inset: 0;
  background: rgba(10, 12, 16, 0.45);
  z-index: 60;
}

/* ===================== flatpickr theming ===================== */
.flatpickr-calendar.inline {
  box-shadow: none;
  width: 100%;
  max-width: 100%;
  background: transparent;
}
.flatpickr-calendar.inline .flatpickr-days,
.flatpickr-calendar.inline .dayContainer { width: 100%; max-width: 100%; }
.flatpickr-day.selected,
.flatpickr-day.selected:hover {
  background: var(--accent);
  border-color: var(--accent);
}
.flatpickr-day:not(.flatpickr-disabled):not(.selected):hover {
  background: var(--accent-soft);
  border-color: var(--accent-soft);
}
/* Available (enabled) days get a subtle dot */
.flatpickr-day:not(.flatpickr-disabled):not(.selected) {
  font-weight: 550;
}
.flatpickr-day.flatpickr-disabled,
.flatpickr-day.flatpickr-disabled:hover {
  color: var(--text-faint);
  opacity: .35;
}
@media (prefers-color-scheme: dark) {
  .flatpickr-calendar,
  .flatpickr-months .flatpickr-month,
  .flatpickr-weekdays,
  span.flatpickr-weekday {
    background: transparent;
    color: var(--text);
    fill: var(--text);
  }
  .flatpickr-day { color: var(--text); }
  .flatpickr-current-month input.cur-year,
  .flatpickr-monthDropdown-months { color: var(--text); }
  .flatpickr-months .flatpickr-prev-month svg,
  .flatpickr-months .flatpickr-next-month svg { fill: var(--text-muted); }
}

/* ===================== Responsive ===================== */
@media (max-width: 900px) {
  .topbar {
    grid-template-columns: 1fr;
    grid-template-areas:
      "brand"
      "controls"
      "chips";
    padding: 12px 16px;
  }
  .topbar__controls { justify-content: flex-start; }
  .layout {
    grid-template-columns: 1fr;
    padding: 18px 16px 56px;
  }
  .datebtn { display: inline-flex; }

  /* Calendar becomes a centered popover, hidden until opened */
  .sidebar {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: min(360px, 92vw);
    z-index: 70;
    box-shadow: var(--shadow-md);
  }
  .sidebar.is-open { display: block; }
  .sidebar__heading { display: none; }
}

@media (min-width: 901px) {
  /* On desktop the sidebar is always visible; scrim never shows */
  .scrim { display: none !important; }
  .sidebar { display: block !important; }
}
