/* Shared Navigation */
@import url('https://fonts.googleapis.com/css2?family=Bebas+Neue&family=Work+Sans:wght@400;600;900&family=Space+Mono&display=swap');

:root {
  --red: #E53935;
  --blue: #1565C0;
  --yellow: #FDD835;
  --yellow-dark: #B89A1E;   /* active nav: the yellow, dimmed to sit inside the black bar */
  --black: #1A1A1A;
  --white: #FAFAFA;
  --cream: #FFF8E1;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

/* Navigation - Consistent across all pages */
.nav {
  background: var(--black);
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  border-bottom: 4px solid var(--yellow);
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  text-decoration: none;
}

.nav-left {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 20px;
}

.nav-home {
  color: var(--white);
  opacity: 0.6;
  font-family: 'Space Mono', monospace;
  font-size: 0.75rem;
  text-decoration: none;
  transition: opacity 0.2s;
}

.nav-home:hover {
  opacity: 1;
  color: var(--yellow);
}

.nav-title {
  color: var(--white);
  font-family: 'Bebas Neue', sans-serif;
  font-size: 1.5rem;
  letter-spacing: 0.05em;
}

.nav-title:hover {
  color: var(--yellow);
}

/* Running Musang */
.musang-container {
  position: relative;
  width: 40px;
  height: 40px;
}

.musang-body {
  font-size: 28px;
  animation: bounce 0.3s ease-in-out infinite;
}

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-3px); }
}

.dust {
  position: absolute;
  bottom: 5px;
  right: -3px;
  width: 4px;
  height: 4px;
  background: var(--yellow);
  border-radius: 50%;
  opacity: 0;
  animation: dust 0.4s ease-out infinite;
}

.dust:nth-child(2) { animation-delay: 0.1s; bottom: 8px; }
.dust:nth-child(3) { animation-delay: 0.2s; bottom: 3px; }

@keyframes dust {
  0% { opacity: 0.8; transform: translateX(0) scale(1); }
  100% { opacity: 0; transform: translateX(12px) scale(0.3); }
}

/* Nav Links */
.nav-links {
  display: flex;
  gap: 4px;
}

.nav-link {
  color: var(--white);
  text-decoration: none;
  padding: 16px 24px;
  font-family: 'Bebas Neue', sans-serif;
  font-size: 1.1rem;
  letter-spacing: 0.1em;
  transition: all 0.2s;
  border-bottom: 4px solid transparent;
  margin-bottom: -4px;
}

.nav-link:hover {
  background: rgba(255,255,255,0.1);
}

.nav-link.active {
  background: var(--yellow-dark);
  color: var(--black);
}
.nav-link.active:hover { background: var(--yellow-dark); }

@media (max-width: 768px) {
  .nav {
    flex-direction: column;
    padding: 8px 16px;
  }
  
  .nav-links {
    width: 100%;
    justify-content: center;
  }
  
  .nav-link {
    padding: 12px 16px;
    font-size: 0.9rem;
  }
}

/* Page Footer - Designer Tribute */
.page-footer {
  background: var(--black);
  color: var(--white);
  padding: 60px 24px;
  text-align: left;
  margin-top: 80px;
}

.tribute {
  max-width: 700px;
  margin: 0 auto;
}

.tribute-title {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 1.25rem;
  letter-spacing: 0.1em;
  color: var(--yellow);
  margin-bottom: 20px;
}

.tribute-main {
  font-family: 'Work Sans', sans-serif;
  font-size: 1rem;
  line-height: 1.7;
  color: rgba(255,255,255,0.85);
  margin-bottom: 16px;
}

.tribute-funfact {
  font-family: 'Space Mono', monospace;
  font-size: 0.875rem;
  line-height: 1.6;
  color: var(--yellow);
  padding-left: 16px;
  border-left: 3px solid var(--yellow);
}

.tribute-designer {
  font-weight: 700;
  color: var(--white);
}

.tribute-work {
  font-style: italic;
  color: var(--white);
}

.data-sync {
  margin-top: 24px;
  font-family: 'Space Mono', monospace;
  font-size: 0.75rem;
  color: rgba(255,255,255,0.4);
}

/* ---------------------------------------------------------------- run list
   Shared by This Week, This Month and All Time (see js/runlog-ui.js). */
.runs-empty {
  text-align: center;
  padding: 28px 12px;
  font-family: 'Space Mono', monospace;
  font-size: 0.8rem;
  opacity: 0.55;
}

/* ------------------------------------------------------------- week strip */
.day-strip {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  align-items: end;
}
.day-col { text-align: center; }
.day-bar-track {
  height: 90px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  border-bottom: 2px solid currentColor;
}
.day-bar {
  width: 60%;
  background: var(--blue);
  min-height: 2px;
  transition: height 0.3s;
}
.day-col.rest .day-bar { background: transparent; }
.day-col.is-today .day-bar { background: var(--red); }
.day-col.future { opacity: 0.35; }
.day-km {
  font-family: 'Space Mono', monospace;
  font-size: 0.65rem;
  margin-top: 6px;
  opacity: 0.75;
}
.day-label {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 0.85rem;
  letter-spacing: 0.08em;
}
.day-col.is-today .day-label { color: var(--red); font-weight: 700; }

/* ---------------------------------------------------------- month heatmap */
.month-heatmap { display: flex; flex-direction: column; gap: 4px; }
.mh-row { display: flex; align-items: center; gap: 10px; }
.mh-year {
  width: 42px;
  flex: none;
  font-family: 'Space Mono', monospace;
  font-size: 0.7rem;
  opacity: 0.7;
}
.mh-cells {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 4px;
  flex: 1;
  min-width: 0;
}
.mh-col-label {
  font-family: 'Space Mono', monospace;
  font-size: 0.6rem;
  text-align: center;
  opacity: 0.5;
}
.mh-cell {
  height: 24px;
  background: #262626;
  border-radius: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
}
/* Rank of that month against the same month in every other year. 1 = best. */
.mh-rank {
  display: flex;
  align-items: center;
  /* The label must never become the hover target: the tooltip reads the cell. */
  pointer-events: none;
  font-family: 'Space Mono', monospace;
  font-size: 0.72rem;
  line-height: 1;
  white-space: nowrap;
  color: rgba(255, 255, 255, 0.55);
}
.mh-medal { font-size: 0.78rem; line-height: 1; margin-right: 2px; }
.mh-cell.lvl-4 .mh-rank, .mh-cell.lvl-5 .mh-rank { color: rgba(0, 0, 0, 0.55); }
.mh-cell.is-best .mh-rank { color: #fff; font-weight: 700; }
.mh-cell.lvl-4.is-best .mh-rank,
.mh-cell.lvl-5.is-best .mh-rank { color: rgba(0, 0, 0, 0.85); }
/* One ramp for both heatmaps: the more you run, the greener. Dull red is a
   thin stretch, not a hot one. Month edges in km: 20 / 45 / 75 / 110.
   Week edges are the same scale over four and a bit weeks: 5 / 10 / 18 / 25. */
.mh-cell.lvl-1, .week-dot.lvl-1 { background: #5c2727; }
.mh-cell.lvl-2, .week-dot.lvl-2 { background: #9e6a03; }
.mh-cell.lvl-3, .week-dot.lvl-3 { background: #26a641; }
.mh-cell.lvl-4, .week-dot.lvl-4 { background: #39d353; }
.mh-cell.lvl-5, .week-dot.lvl-5 { background: #6ee787; }
.mh-total {
  width: 110px;
  flex: none;
  text-align: right;
  font-family: 'Space Mono', monospace;
  font-size: 0.68rem;
  opacity: 0.8;
}
.mh-head .mh-cell { background: none; }

/* --------------------------------------------------------- cumulative chart */
.ch-svg { width: 100%; height: auto; display: block; overflow: visible; }
.ch-grid { stroke: currentColor; stroke-width: 1; opacity: 0.12; }
.ch-axis {
  fill: currentColor;
  opacity: 0.55;
  font-family: 'Space Mono', monospace;
  font-size: 10px;
}
.ch-line { fill: none; stroke-linejoin: round; stroke-linecap: round; }
.ch-line.other { stroke: currentColor; opacity: 0.16; stroke-width: 1.5; }
.ch-line.prev  { stroke: var(--blue); opacity: 0.85; stroke-width: 2.5; }
.ch-line.best  { stroke: var(--yellow); opacity: 0.95; stroke-width: 2.5; }
.ch-line.cur   { stroke: var(--red); stroke-width: 4; }
.ch-dot { fill: currentColor; opacity: 0.2; }
.ch-dot.prev { fill: var(--blue); opacity: 1; }
.ch-dot.best { fill: var(--yellow); opacity: 1; }
.ch-dot.cur  { fill: var(--red); opacity: 1; }
.ch-series.hidden { display: none; }
.ch-legend { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 14px; }
.ch-chip {
  font-family: 'Space Mono', monospace;
  font-size: 0.68rem;
  padding: 5px 10px;
  border: 1px solid currentColor;
  background: none;
  color: inherit;
  cursor: pointer;
  opacity: 0.45;
  border-radius: 2px;
}
.ch-chip em { font-style: normal; opacity: 0.7; }
.ch-chip.cur  { opacity: 1; border-color: var(--red); color: var(--red); font-weight: 700; }
.ch-chip.best { opacity: 1; border-color: var(--yellow); }
.ch-chip.prev { opacity: 1; border-color: var(--blue); }
.ch-chip.off { opacity: 0.2; text-decoration: line-through; }

@media (max-width: 640px) {
  .mh-year { width: 34px; font-size: 0.6rem; }
  .mh-total { width: 78px; font-size: 0.58rem; }
  .mh-cell { height: 16px; }
  /* A month cell is about 8px wide on a phone, too narrow for any label, so
     the rank lives in the tap tooltip there. */
  .mh-rank { display: none; }
}

/* Grid/flex children default to min-width:auto, so a wide table pushes its
   track open and the whole page scrolls sideways. Pin them and let the table
   scroll inside its own container instead. */
.week-extra, .year-extra { min-width: 0; }
.week-panel, .year-panel { min-width: 0; }
.week-panel .runs-table, .year-panel .runs-table { min-width: 520px; }
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* ----------------------------------------------------------- week heatmap
   Moved out of alltime.html so This Week can use it (js/runlog-ui.js). */
.heatmap-scroll { overflow-x: auto; padding-bottom: 6px; }
.year-row { display: flex; align-items: center; margin-bottom: 4px; }
.year-label {
  font-family: 'Space Mono', monospace;
  font-size: 0.75rem;
  width: 50px;
  flex: none;
  opacity: 0.5;
}
.weeks-container { display: flex; gap: 2px; }
.week-dot {
  width: 10px;
  height: 10px;
  flex: none;
  border-radius: 2px;
  background: #333;
  cursor: pointer;
  transition: transform 0.1s;
}
.week-dot:hover { transform: scale(1.8); }
.year-stats {
  font-family: 'Space Mono', monospace;
  font-size: 0.625rem;
  margin-left: 16px;
  white-space: nowrap;
  opacity: 0.4;
}
.year-stats strong { color: var(--yellow); opacity: 1; }
.heatmap-legend {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 20px;
  font-family: 'Space Mono', monospace;
  font-size: 0.625rem;
  opacity: 0.6;
}
.legend-box { width: 12px; height: 12px; border-radius: 2px; flex: none; }

@media (max-width: 640px) {
  .week-dot { width: 8px; height: 8px; }
  .year-stats { display: none; }
  .year-label { width: 38px; font-size: 0.65rem; }
}

.ch-end {
  font-family: 'Space Mono', monospace;
  font-size: 9px;
  fill: currentColor;
  opacity: 0.3;
}
.ch-end.prev { fill: var(--blue); opacity: 1; font-weight: 700; }
.ch-end.best { fill: var(--yellow); opacity: 1; font-weight: 700; }
.ch-end.cur  { fill: var(--red); opacity: 1; font-weight: 700; font-size: 11px; }

/* The month-by-month mean of the complete years — a typical year, for scale. */
.ch-line.avg { stroke: var(--white); stroke-width: 2; stroke-dasharray: 6 5; opacity: 0.85; }
.ch-dot.avg  { fill: var(--white); opacity: 0.9; }
.ch-end.avg  { fill: var(--white); opacity: 0.9; font-weight: 700; }
.ch-chip.avg { opacity: 1; border-color: var(--white); border-style: dashed; }

.ch-chip small { font-size: 0.85em; opacity: 0.55; margin-left: 2px; }

/* Where the weekly target lands by year end. */
.ch-proj {
  fill: none;
  stroke: var(--red);
  stroke-width: 2;
  stroke-dasharray: 2 4;
  opacity: 0.75;
}
.ch-proj-dot { fill: none; stroke: var(--red); stroke-width: 2; }
.ch-proj-label {
  fill: var(--red);
  font-family: 'Space Mono', monospace;
  font-size: 10px;
  font-weight: 700;
}
