/* ==========================================================================
   activities.css — Aktivitäten-Seite für herrmontag.de
   Passt zu TYPR: Schwarz/Weiß, 2px-Rahmen, 8px-Radien, Inter,
   Dark Mode über die bestehenden CSS-Variablen.
   ========================================================================== */

.activities-page {
  max-width: var(--maxw, 75rem);
}

.activities {
  --act-gap: clamp(1rem, 2vw, 1.5rem);
  --heat-cell: 9px;
  --heat-gap: 2px;
  display: block;
  width: 100%;
  color: var(--fg, #000);
}

.activities *,
.activities *::before,
.activities *::after {
  box-sizing: border-box;
}

.act-sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

/* ---------- Meta & Jahr-Leiste ---------- */

.act-meta {
  margin: 0 0 1.25rem;
  font-size: var(--fs-small, 0.875rem);
  color: var(--fg-muted, #666);
  font-variant-numeric: tabular-nums;
}

.act-yearbar {
  display: flex;
  align-items: stretch;
  gap: 0.4rem;
  margin: 0 0 1.25rem;
  padding-bottom: 0.25rem;
  border-bottom: 2px solid var(--rule, #ececee);
}

.act-years {
  display: flex;
  align-items: stretch;
  gap: 0.35rem;
  overflow-x: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--rule-strong, #d9d9dd) transparent;
  padding: 0.15rem;
  flex: 0 1 auto;
}

.act-years::-webkit-scrollbar {
  height: 6px;
}

.act-years::-webkit-scrollbar-thumb {
  background: var(--rule-strong, #d9d9dd);
  border-radius: 99px;
}

.act-year {
  appearance: none;
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  min-width: 3.5rem;
  padding: 0.32rem 0.5rem;
  border: 2px solid transparent;
  border-radius: var(--radius-m, 8px);
  background: transparent;
  color: var(--fg, #000);
  font: inherit;
  line-height: 1.15;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.act-year:hover {
  background: var(--bg-soft, #f7f7f8);
  border-color: var(--rule, #ececee);
}

.act-year.is-active {
  background: var(--accent, #000);
  border-color: var(--accent, #000);
  color: var(--accent-ink, #fff);
}

.act-year__num {
  font-weight: 700;
  font-size: 0.95rem;
  font-variant-numeric: tabular-nums;
}

.act-year__count {
  margin-top: 0.1rem;
  font-size: 0.68rem;
  color: var(--fg-muted, #666);
  font-variant-numeric: tabular-nums;
}

.act-year.is-active .act-year__count {
  color: currentColor;
  opacity: 0.7;
}

.act-yearnav {
  appearance: none;
  flex: 0 0 2.5rem;
  width: 2.5rem;
  border: 2px solid var(--rule, #ececee);
  border-radius: var(--radius-m, 8px);
  background: transparent;
  color: var(--fg, #000);
  font: inherit;
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.act-yearnav:hover:not(:disabled) {
  background: var(--bg-soft, #f7f7f8);
  border-color: var(--rule-strong, #d9d9dd);
}

.act-yearnav:disabled {
  opacity: 0.3;
  cursor: default;
}

.act-year:focus-visible,
.act-yearnav:focus-visible,
.act-cat:focus-visible,
.act-segmented button:focus-visible,
.act-more:focus-visible,
.act-chip:focus-visible,
.act-search input:focus-visible,
.act-sort select:focus-visible {
  outline: 2px solid var(--fg, #000);
  outline-offset: 2px;
}

/* ---------- KPI-Karten ---------- */

.act-kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--act-gap);
  margin: 0 0 var(--act-gap);
}

.act-kpi {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 1.05rem 1.15rem 1rem;
  border: 2px solid var(--rule, #ececee);
  border-radius: var(--radius-m, 8px);
  background: var(--bg, #fff);
  min-width: 0;
}

.act-kpi__label {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--fg-muted, #666);
}

.act-kpi__value {
  display: block;
  font-size: clamp(1.65rem, 3.2vw, 2.35rem);
  line-height: 1.05;
  font-weight: 700;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.act-kpi__value small {
  font-size: 0.42em;
  font-weight: 600;
  letter-spacing: 0;
  color: var(--fg-muted, #666);
}

.act-kpi__delta {
  margin-top: 0.25rem;
  font-size: 0.72rem;
  color: var(--fg-muted, #666);
  font-variant-numeric: tabular-nums;
}

.act-kpi__delta--up {
  color: var(--green, #2e9e4f);
}

.act-kpi__delta--down {
  color: var(--fg-muted, #666);
}

.act-kpi__delta-note {
  color: var(--fg-muted, #666);
}

/* ---------- Panels ---------- */

.act-panel {
  border: 2px solid var(--rule, #ececee);
  border-radius: var(--radius-m, 8px);
  background: var(--bg, #fff);
  padding: clamp(1rem, 2vw, 1.4rem);
  min-width: 0;
}

.act-panel--chart {
  margin: 0 0 var(--act-gap);
}

.act-panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.act-panel-title {
  margin: 0;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--fg, #000);
}

.act-panel-sub {
  margin: 0.2rem 0 0;
  font-size: 0.78rem;
  color: var(--fg-muted, #666);
}

/* ---------- Ansichts-Umschalter ---------- */

.act-segmented {
  display: inline-flex;
  flex: 0 0 auto;
  border: 2px solid var(--rule, #ececee);
  border-radius: var(--radius-m, 8px);
  overflow: hidden;
}

.act-segmented button {
  appearance: none;
  border: 0;
  border-left: 1px solid var(--rule, #ececee);
  background: transparent;
  color: var(--fg-muted, #666);
  padding: 0.38rem 0.65rem;
  font: inherit;
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.act-segmented button:first-child {
  border-left: 0;
}

.act-segmented button:hover {
  background: var(--bg-soft, #f7f7f8);
  color: var(--fg, #000);
}

.act-segmented button.is-active {
  background: var(--accent, #000);
  color: var(--accent-ink, #fff);
}

/* ---------- Kategorie-Chips ---------- */

.act-cats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0 0 1rem;
}

.act-cat {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.32rem 0.6rem;
  border: 2px solid var(--rule, #ececee);
  border-radius: 999px;
  background: transparent;
  color: var(--fg, #000);
  font: inherit;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.act-cat:hover {
  background: var(--bg-soft, #f7f7f8);
  border-color: var(--rule-strong, #d9d9dd);
}

.act-cat.is-active {
  background: var(--accent, #000);
  border-color: var(--accent, #000);
  color: var(--accent-ink, #fff);
}

.act-cat__dot {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: var(--fg, #000);
  flex: 0 0 auto;
}

.act-cat__dot--run {
  background: var(--green, #2e9e4f);
}

.act-cat__dot--move {
  background: var(--fg-muted, #666);
}

.act-cat__dot--all {
  background: linear-gradient(90deg,
    var(--fg, #000) 0 33%,
    var(--green, #2e9e4f) 33% 66%,
    var(--fg-muted, #666) 66% 100%);
}

.act-cat__count {
  color: var(--fg-muted, #666);
  font-size: 0.68rem;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.act-cat.is-active .act-cat__count {
  color: currentColor;
  opacity: 0.7;
}

/* ---------- Chart ---------- */

.act-chart {
  position: relative;
  height: 360px;
  min-height: 240px;
}

.act-chart canvas {
  width: 100% !important;
  height: 100% !important;
}

.act-note {
  margin: 0.75rem 0 0;
  font-size: 0.7rem;
  color: var(--fg-faint, #767676);
}

.act-chart-fallback {
  display: grid;
  place-items: center;
  height: 100%;
  margin: 0;
  border: 2px dashed var(--rule, #ececee);
  border-radius: var(--radius-m, 8px);
  color: var(--fg-muted, #666);
  font-size: 0.85rem;
  text-align: center;
  padding: 1rem;
}

/* ---------- Heatmap & Rekorde ---------- */

.act-columns {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr);
  gap: var(--act-gap);
  margin-bottom: var(--act-gap);
}

.act-heat__summary {
  margin: 0 0 0.8rem;
  font-size: 0.76rem;
  color: var(--fg-muted, #666);
  font-variant-numeric: tabular-nums;
}

.act-heat__summary strong {
  color: var(--fg, #000);
}

.act-heat__scroll {
  overflow-x: auto;
  padding-bottom: 0.35rem;
  scrollbar-width: thin;
  scrollbar-color: var(--rule-strong, #d9d9dd) transparent;
}

.act-heat__months {
  display: grid;
  gap: var(--heat-gap);
  margin-left: 1.7rem;
  margin-bottom: 0.25rem;
  min-width: max-content;
}

.act-heat__months span {
  font-size: 0.58rem;
  color: var(--fg-faint, #767676);
  white-space: nowrap;
  overflow: visible;
}

.act-heat__body {
  display: flex;
  align-items: flex-start;
  gap: 0.45rem;
}

.act-heat__weekdays {
  display: grid;
  grid-template-rows: repeat(7, var(--heat-cell));
  gap: var(--heat-gap);
  flex: 0 0 1.1rem;
  font-size: 0.55rem;
  line-height: var(--heat-cell);
  color: var(--fg-faint, #767676);
  text-align: right;
}

.act-heat__grid {
  display: grid;
  grid-auto-flow: column;
  grid-template-rows: repeat(7, var(--heat-cell));
  gap: var(--heat-gap);
  min-width: max-content;
}

.act-heat__cell {
  display: block;
  width: var(--heat-cell);
  height: var(--heat-cell);
  border-radius: 2px;
  background: var(--bg-soft, #f7f7f8);
  cursor: default;
}

.act-heat__cell[data-level="1"] {
  background: color-mix(in srgb, var(--fg, #000) 18%, transparent);
}

.act-heat__cell[data-level="2"] {
  background: color-mix(in srgb, var(--fg, #000) 36%, transparent);
}

.act-heat__cell[data-level="3"] {
  background: color-mix(in srgb, var(--fg, #000) 62%, transparent);
}

.act-heat__cell[data-level="4"] {
  background: var(--fg, #000);
}

.act-heat__cell[data-date] {
  cursor: pointer;
}

.act-heat__cell[data-date]:hover {
  outline: 1px solid var(--fg, #000);
  outline-offset: 1px;
}

.act-heat__cell.is-selected {
  outline: 2px solid var(--green, #2e9e4f);
  outline-offset: 1px;
}

.act-heat__cell.is-out {
  background: transparent;
}

.act-heat__legend {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.3rem;
  margin-top: 0.65rem;
  font-size: 0.62rem;
  color: var(--fg-faint, #767676);
}

.act-heat__legend i {
  display: block;
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 2px;
  background: var(--bg-soft, #f7f7f8);
}

.act-heat__legend i[data-level="1"] {
  background: color-mix(in srgb, var(--fg, #000) 18%, transparent);
}

.act-heat__legend i[data-level="2"] {
  background: color-mix(in srgb, var(--fg, #000) 36%, transparent);
}

.act-heat__legend i[data-level="3"] {
  background: color-mix(in srgb, var(--fg, #000) 62%, transparent);
}

.act-heat__legend i[data-level="4"] {
  background: var(--fg, #000);
}

.act-records {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.6rem;
}

.act-record {
  display: flex;
  flex-direction: column;
  gap: 0.12rem;
  padding: 0.7rem 0.75rem;
  border: 2px solid var(--rule, #ececee);
  border-radius: var(--radius-m, 8px);
  color: var(--fg, #000);
  text-decoration: none;
  min-width: 0;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

a.act-record:hover {
  background: var(--bg-soft, #f7f7f8);
  border-color: var(--rule-strong, #d9d9dd);
}

.act-record__label {
  font-size: 0.61rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--fg-muted, #666);
}

.act-record__value {
  font-size: 1.12rem;
  font-weight: 700;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
}

.act-record__meta {
  font-size: 0.66rem;
  color: var(--fg-muted, #666);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- Liste ---------- */

.act-list-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}

.act-list-tools {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.act-search,
.act-sort {
  display: block;
}

.act-search input,
.act-sort select {
  appearance: none;
  border: 2px solid var(--rule, #ececee);
  border-radius: var(--radius-m, 8px);
  background: transparent;
  color: var(--fg, #000);
  font: inherit;
  font-size: 0.75rem;
  padding: 0.42rem 0.6rem;
  min-height: 2.15rem;
}

.act-search input {
  width: 12rem;
  max-width: 100%;
}

.act-search input::placeholder {
  color: var(--fg-faint, #767676);
}

.act-sort select {
  cursor: pointer;
  padding-right: 1.5rem;
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%),
    linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 0.9rem) 50%, calc(100% - 0.6rem) 50%;
  background-size: 0.3rem 0.3rem, 0.3rem 0.3rem;
  background-repeat: no-repeat;
}

.act-chips {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  margin-bottom: 0.6rem;
}

.act-chip {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  border: 2px solid var(--rule, #ececee);
  border-radius: 999px;
  background: var(--bg-soft, #f7f7f8);
  color: var(--fg, #000);
  font: inherit;
  font-size: 0.7rem;
  padding: 0.24rem 0.6rem;
  cursor: pointer;
}

.act-chip:hover {
  border-color: var(--rule-strong, #d9d9dd);
}

.act-list {
  list-style: none;
  margin: 0;
  padding: 0;
  border-top: 2px solid var(--rule, #ececee);
}

.act-row {
  display: grid;
  grid-template-columns: 4.2rem minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.8rem;
  padding: 0.7rem 0.35rem;
  border-bottom: 1px solid var(--rule, #ececee);
  transition: background-color 0.12s ease;
}

.act-row:hover {
  background: var(--bg-soft, #f7f7f8);
}

.act-row__badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 1.5rem;
  padding: 0.1rem 0.3rem;
  border: 1px solid var(--rule-strong, #d9d9dd);
  border-radius: 4px;
  font-size: 0.56rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--fg-muted, #666);
  white-space: nowrap;
}

.act-row__badge--bike {
  border-color: var(--fg, #000);
  color: var(--fg, #000);
}

.act-row__badge--run {
  border-color: var(--green, #2e9e4f);
  color: var(--green, #2e9e4f);
}

.act-row__body {
  display: flex;
  flex-direction: column;
  gap: 0.12rem;
  min-width: 0;
}

.act-row__title {
  color: var(--fg, #000);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.86rem;
  line-height: 1.25;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.act-row__title:hover {
  text-decoration: underline;
  text-underline-offset: 2px;
}

.act-row__meta {
  font-size: 0.68rem;
  color: var(--fg-muted, #666);
  font-variant-numeric: tabular-nums;
}

.act-row__commute {
  color: var(--green, #2e9e4f);
}

.act-row__arrow {
  color: var(--fg-faint, #767676);
  font-size: 1rem;
  line-height: 1;
}

.act-more {
  appearance: none;
  display: block;
  width: 100%;
  margin-top: 0.9rem;
  padding: 0.6rem 1rem;
  border: 2px solid var(--rule, #ececee);
  border-radius: var(--radius-m, 8px);
  background: transparent;
  color: var(--fg, #000);
  font: inherit;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.act-more:hover {
  background: var(--bg-soft, #f7f7f8);
  border-color: var(--rule-strong, #d9d9dd);
}

.act-empty {
  margin: 1rem 0;
  color: var(--fg-muted, #666);
  font-size: 0.85rem;
  text-align: center;
}

/* ---------- Laden / Fehler ---------- */

.act-loading {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 2.5rem 0;
  color: var(--fg-muted, #666);
  font-size: 0.85rem;
}

.act-loading__dot {
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  background: var(--green, #2e9e4f);
  animation: act-pulse 1.2s ease-in-out infinite;
}

@keyframes act-pulse {
  0%, 100% { opacity: 0.25; transform: scale(0.8); }
  50% { opacity: 1; transform: scale(1); }
}

.act-error {
  border: 2px solid var(--rule, #ececee);
  border-radius: var(--radius-m, 8px);
  padding: 1.25rem;
}

.act-error strong {
  display: block;
  margin-bottom: 0.4rem;
}

.act-error p {
  margin: 0 0 0.75rem;
  color: var(--fg-muted, #666);
  font-size: 0.85rem;
}

.act-error .act-more {
  width: auto;
  margin-top: 0;
}

.act-error__detail {
  margin: 0.75rem 0 0 !important;
  font-family: var(--font-mono, monospace);
  font-size: 0.68rem !important;
  color: var(--fg-faint, #767676) !important;
}

/* ---------- Responsive ---------- */

@media (max-width: 980px) {
  .act-kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .act-columns {
    grid-template-columns: minmax(0, 1fr);
  }

  .act-chart {
    height: 320px;
  }
}

@media (max-width: 640px) {
  .activities {
    --heat-cell: 8px;
    --heat-gap: 2px;
  }

  .act-panel {
    padding: 0.9rem;
  }

  .act-panel-head {
    flex-direction: column;
    gap: 0.6rem;
  }

  .act-segmented {
    width: 100%;
  }

  .act-segmented button {
    flex: 1;
  }

  .act-kpi {
    padding: 0.85rem 0.9rem;
  }

  .act-kpi__value {
    font-size: 1.65rem;
  }

  .act-chart {
    height: 270px;
  }

  .act-list-head {
    align-items: stretch;
  }

  .act-list-tools {
    width: 100%;
  }

  .act-search {
    flex: 1 1 10rem;
  }

  .act-search input {
    width: 100%;
  }

  .act-sort {
    flex: 0 0 auto;
  }

  .act-row {
    grid-template-columns: 3.4rem minmax(0, 1fr);
    gap: 0.55rem;
  }

  .act-row__arrow {
    display: none;
  }

  .act-records {
    grid-template-columns: minmax(0, 1fr);
  }

  .act-heat__months {
    margin-left: 1.45rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .activities *,
  .activities *::before,
  .activities *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

/* Excerpt auf der Ghost-Page (TYPR hat dafür keinen eigenen Stil) */
.activities-page .page__excerpt {
  margin: 0.6rem 0 1.6rem;
  max-width: 44rem;
  color: var(--fg-muted, #666);
  font-size: var(--fs-lead, 1.0625rem);
  line-height: 1.5;
}
