/* ===== Custom GitHub contribution calendar (preview restyle) ===== */

/* Glass card to match the rest of the redesign */
.gh-box {
  border: 1px solid var(--border);
  background: var(--surface);
  backdrop-filter: blur(10px);
  border-radius: var(--radius-lg);
  padding: 24px;
  position: relative;
  transition: border-color 0.3s var(--ease);
}

.gh-box:hover {
  border-color: var(--border-accent);
}

/* Toolbar holding the filter dropdown (top-right inside the border) */
.gh-toolbar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 20px;
}

.gh-filter-wrap {
  position: relative;
}

.gh-control {
  background: var(--bg-soft);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 12px;
  font-family: var(--font-body);
  font-size: 0.9rem;
  outline: none;
  cursor: pointer;
  transition: border-color 0.25s var(--ease);
}

.gh-control:focus,
.gh-control:hover {
  border-color: var(--accent);
}

/* Date-range popup */
.gh-range-popup {
  position: absolute;
  top: 46px;
  right: 0;
  z-index: 50;
  width: 250px;
  background: var(--bg-soft);
  border: 1px solid var(--border-accent);
  border-radius: var(--radius-md);
  padding: 16px;
  box-shadow: var(--shadow-1);
}

.gh-range-popup[hidden] {
  display: none;
}

.gh-range-title {
  color: var(--text);
  font-weight: 600;
  font-size: 0.95rem;
  margin-bottom: 10px;
}

.gh-range-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  color: var(--muted);
  font-size: 0.8rem;
  margin-bottom: 10px;
}

.gh-range-field .gh-control {
  width: 100%;
  /* calendar icon shown as a hint on the right of the input */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%230078ff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='4' width='18' height='18' rx='2' ry='2'/%3E%3Cline x1='16' y1='2' x2='16' y2='6'/%3E%3Cline x1='8' y1='2' x2='8' y2='6'/%3E%3Cline x1='3' y1='10' x2='21' y2='10'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 32px;
}

.gh-range-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 4px;
}

.gh-mini-btn {
  background: var(--accent);
  color: #fff;
  border: 1px solid var(--accent);
  border-radius: 8px;
  padding: 6px 14px;
  font-family: var(--font-body);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.25s var(--ease);
}

.gh-mini-btn:hover {
  background: #0061cc;
}

.gh-mini-ghost {
  background: transparent;
  color: var(--muted);
  border-color: var(--border);
}

.gh-mini-ghost:hover {
  background: var(--surface-strong);
  color: var(--text);
}

/* Stats row */
.gh-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 24px;
}

.gh-stat-card {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  text-align: center;
  transition: transform 0.25s var(--ease), border-color 0.25s var(--ease);
}

.gh-stat-card:hover {
  transform: translateY(-3px);
  border-color: var(--border-accent);
}

.gh-stat-label {
  color: var(--muted);
  font-size: 0.85rem;
  margin-bottom: 6px;
}

.gh-stat-value {
  color: #39d353;
  font-family: var(--font-display);
  font-size: 1.7rem;
  font-weight: 700;
  line-height: 1.1;
}

.gh-stat-sub {
  color: var(--muted);
  font-size: 0.75rem;
  margin-top: 4px;
}

/* Heatmap */
.gh-calendar {
  overflow-x: auto;
  padding-bottom: 8px;
  text-align: center;
}

.gh-status {
  color: var(--muted);
  text-align: center;
  padding: 20px;
}

/* heatmap with GitHub-style month + weekday labels */
.gh-cal-wrap {
  display: inline-block;
  text-align: left;
}

.gh-months {
  position: relative;
  height: 16px;
  margin-left: 34px; /* matches the weekday gutter */
  margin-bottom: 4px;
}

.gh-months span {
  position: absolute;
  top: 0;
  font-size: 0.72rem;
  color: var(--muted);
  line-height: 16px;
  white-space: nowrap;
}

.gh-body {
  display: flex;
  gap: 6px;
}

.gh-wdays {
  display: grid;
  grid-template-rows: repeat(7, var(--gh-cell, 12px));
  gap: 3px;
  width: 28px;
}

.gh-wdays span {
  font-size: 0.68rem;
  color: var(--muted);
  line-height: var(--gh-cell, 12px);
  text-align: right;
}

.gh-grid {
  display: inline-grid;
  grid-auto-flow: column;
  grid-template-rows: repeat(7, var(--gh-cell, 12px));
  gap: 3px;
}

.gh-day {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  background: var(--surface-strong);
}

/* heatmap cells scale to fill the box width (set via --gh-cell in JS) */
.gh-grid .gh-day {
  width: var(--gh-cell, 12px);
  height: var(--gh-cell, 12px);
}

.gh-day[data-level="1"] { background: #0e4429; }
.gh-day[data-level="2"] { background: #006d32; }
.gh-day[data-level="3"] { background: #26a641; }
.gh-day[data-level="4"] { background: #39d353; }

/* light theme: empty day cells need real contrast (surface-strong is white there) */
[data-theme="light"] .gh-day { background: rgba(15, 23, 42, 0.09); }

[data-theme="light"] .gh-day[data-level="1"] { background: #9be9a8; }
[data-theme="light"] .gh-day[data-level="2"] { background: #40c463; }
[data-theme="light"] .gh-day[data-level="3"] { background: #30a14e; }
[data-theme="light"] .gh-day[data-level="4"] { background: #216e39; }

.gh-legend {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 5px;
  color: var(--muted);
  font-size: 0.8rem;
  margin-top: 12px;
}

.gh-legend .gh-day {
  display: inline-block;
}

/* No-data / empty state (shown inside the border) */
.gh-nodata {
  text-align: center;
  padding: 50px 20px;
  border: 1px dashed var(--border-accent);
  border-radius: var(--radius-md);
  background: var(--bg-soft);
}

.gh-nodata-icon {
  font-size: 2.5rem;
  margin-bottom: 10px;
}

.gh-nodata-title {
  color: var(--text);
  font-size: 1.2rem;
  font-weight: 600;
  margin-bottom: 6px;
}

.gh-nodata-sub {
  color: var(--muted);
  font-size: 0.9rem;
}

/* ===== flatpickr calendar — themed to match the site ===== */
.flatpickr-calendar {
  background: var(--bg-soft);
  border: 1px solid var(--border-accent);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-1);
}

.flatpickr-calendar.arrowTop::before { border-bottom-color: var(--border-accent); }
.flatpickr-calendar.arrowTop::after { border-bottom-color: var(--bg-soft); }
.flatpickr-calendar.arrowBottom::before { border-top-color: var(--border-accent); }
.flatpickr-calendar.arrowBottom::after { border-top-color: var(--bg-soft); }

.flatpickr-months,
.flatpickr-month,
.flatpickr-current-month,
.flatpickr-weekdays,
span.flatpickr-weekday {
  background: transparent;
  color: var(--text);
  fill: var(--text);
}

span.flatpickr-weekday {
  color: var(--muted);
  font-weight: 600;
}

.flatpickr-current-month input.cur-year,
.flatpickr-monthDropdown-months {
  color: var(--text);
  font-weight: 600;
}

.flatpickr-monthDropdown-months {
  background: var(--bg-soft);
}

.flatpickr-months .flatpickr-prev-month svg,
.flatpickr-months .flatpickr-next-month svg {
  fill: var(--text);
}

.flatpickr-months .flatpickr-prev-month:hover svg,
.flatpickr-months .flatpickr-next-month:hover svg {
  fill: var(--accent);
}

.numInputWrapper span.arrowUp::after { border-bottom-color: var(--muted); }
.numInputWrapper span.arrowDown::after { border-top-color: var(--muted); }
.numInputWrapper:hover { background: var(--surface-strong); }

.flatpickr-day {
  color: var(--text);
  border-radius: 8px;
}

.flatpickr-day:hover,
.flatpickr-day:focus {
  background: rgba(0, 120, 255, 0.18);
  border-color: transparent;
}

.flatpickr-day.today {
  border-color: var(--accent);
}

.flatpickr-day.selected,
.flatpickr-day.selected:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.flatpickr-day.flatpickr-disabled,
.flatpickr-day.prevMonthDay,
.flatpickr-day.nextMonthDay {
  color: var(--muted);
  opacity: 0.45;
}

@media (max-width: 700px) {
  .gh-stats {
    grid-template-columns: repeat(2, 1fr);
  }
}
