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

/* Prevent horizontal "jump" when switching tabs changes page height enough to toggle a vertical scrollbar */
html {
  scrollbar-gutter: stable;
}

body {
  --bg-color: #fff;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.6;
  color: #333;
  background: var(--bg-color);
  max-width: 650px;
  margin: 0 auto;
  padding: 2rem 1rem;
}

header {
  margin-bottom: 5rem;
}

h1 {
  font-size: 2rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

/* Clickable name easter egg */
.clickable-name {
  cursor: pointer;
  display: inline-block;
  background-image: linear-gradient(var(--link-color, #648FFF), var(--link-color, #648FFF));
  background-repeat: no-repeat;
  background-size: calc(100% * var(--enable-link-animation, 1)) 0.15em;
  background-position: 0 calc(100% - 0.15em);
  transition: background-size 0.25s ease-in;
}

.clickable-name:hover {
  background-size: calc(100% * var(--enable-link-animation, 1)) 88%;
}

@media (prefers-reduced-motion: reduce) {
  .clickable-name {
    transition: none;
    background-size: 0 0;
  }
  .clickable-name:hover {
    text-decoration: underline;
    background-size: 0 0;
  }
}

header p {
  color: #666;
}

footer {
  margin-top: 4rem;
  padding: 2rem 0 1.5rem;
  border-top: 1px solid #e5e5e5;
  text-align: center;
}

footer p {
  font-size: 0.85rem;
  color: #999;
  margin: 0;
}

section {
  margin-bottom: 2.5rem;
}

h2 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 1rem;
  color: #111;
}

p {
  margin-bottom: 1rem;
}

ul {
  list-style: none;
  padding-left: 0;
}

li {
  margin-bottom: 0.75rem;
}

/* ============================================
   ANIMATED LINK UNDERLINES
   To disable: comment out the line below
   ============================================ */
:root {
  --enable-link-animation: 1; /* Set to 0 to disable */
}

a {
  color: inherit;
  text-decoration: none;
  
  /* Animated underline effect */
  background-image: linear-gradient(var(--link-color, #648FFF), var(--link-color, #648FFF));
  background-repeat: no-repeat;
  background-size: calc(100% * var(--enable-link-animation, 1)) 0.15em;
  background-position: 0 100%;
  transition: background-size 0.25s ease-in;
}

a:hover {
  background-size: calc(100% * var(--enable-link-animation, 1)) 88%;
}

/* Respect user's motion preferences */
@media (prefers-reduced-motion: reduce) {
  a {
    transition: none;
    background-size: 0 0;
  }
  
  a:hover {
    text-decoration: underline;
    background-size: 0 0;
  }
}

.project, .post {
  margin-bottom: 1rem;
}

.project-title, .post-title {
  font-weight: 500;
}

.project-desc, .post-date {
  color: #666;
  font-size: 0.9rem;
}

/* Tabs */
.tabs-nav {
  display: flex;
  gap: 1.5rem;
  margin-bottom: 1rem;
}

.tab-link {
  color: #666;
  cursor: pointer;
  font-size: 1rem;
  padding: 0;
  background: none;
  border: none;
  font-family: inherit;
}

.tab-link:hover {
  color: #333;
}

.tab-link.active {
  color: #111;
  font-weight: 600;
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* Creates space while loading data so Projects section does not "jump" */
#now {
  min-height: 260px;
}

#metrics {
  min-height: 265px;
}

.placeholder {
  color: #999;
  font-style: italic;
}

footer {
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid #eee;
  color: #666;
  font-size: 0.85rem;
}

/* Metrics */
.metrics-section {
  margin-bottom: 1.5rem;
}

.metrics-section h3 {
  font-size: 0.9rem;
  font-weight: 600;
  color: #666;
  margin-bottom: 0.75rem;
}

.metrics-grid {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: max-content;
  justify-content: space-between;
  column-gap: 0.625rem;
  row-gap: 0.75rem;
  align-items: start;
}

.metric-card {
  display: flex;
  flex-direction: column;
}

.metric-label {
  font-size: 0.75rem;
  color: #999;
}

.metric-value {
  font-size: 0.95rem;
  font-weight: 400;
  color: #111;
}

.trends-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.trend-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.trend-label {
  width: 80px;
  font-size: 0.85rem;
  color: #666;
}

.trend-value {
  font-size: 0.9rem;
  font-weight: 500;
}

.trend-delta {
  font-size: 0.8rem;
  color: #666;
}

.trend-up {
  color: #22c55e;
}

.trend-down {
  color: #ef4444;
}

/* Yesterday rows */
.yesterday-rows {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.yesterday-row {
  display: grid;
  grid-template-columns: 130px 1fr auto;
  align-items: baseline;
  gap: 0.5rem;
}

.yesterday-label {
  font-size: 0.8rem;
  color: #999;
}

.yesterday-value {
  font-size: 0.95rem;
  font-weight: 400;
  color: #111;
}

.yesterday-delta {
  font-size: 0.8rem;
  color: #999;
  font-variant-numeric: tabular-nums;
}

.delta-positive {
  color: #22c55e;
}

.delta-negative {
  color: #ef4444;
}

/* Sub-tabs (Yesterday / 30-Day Trends) */
.sub-tabs-nav {
  display: flex;
  gap: 1.5rem;
  margin-bottom: 1rem;
}

.sub-tab-link {
  color: #666;
  cursor: pointer;
  font-size: 0.9rem;
  padding: 0;
  background: none;
  border: none;
  font-family: inherit;
}

.sub-tab-link:hover {
  color: #333;
}

.sub-tab-link.active {
  color: #111;
  font-weight: 600;
}

.sub-tab-content {
  display: none;
}

.sub-tab-content.active {
  display: block;
}

/* Metric tabs (Sleep, Energy, Weight, etc.) */
.metric-tabs-nav {
  display: flex;
  gap: 1rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.metric-tab-link {
  color: #666;
  cursor: pointer;
  font-size: 0.85rem;
  padding: 0.25rem 0.5rem;
  background: none;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-family: inherit;
}

.metric-tab-link:hover {
  color: #333;
  border-color: #999;
}

.metric-tab-link.active {
  color: #111;
  border-color: #111;
  font-weight: 600;
}

/* Trend chart */
#trend-chart-container {
  margin-top: 0.5rem;
  position: relative;
}

#trend-chart-summary {
  font-size: 0.75rem;
  color: #666;
  margin-bottom: 0.5rem;
}

#trend-chart {
  width: 100%;
  height: auto;
  max-height: 160px;
}

.chart-x-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: #999;
  margin-top: 0.1rem;
  padding-left: calc(44 / 600 * 100%);
  padding-right: calc(20 / 600 * 100%);
}

.chart-tooltip {
  position: absolute;
  z-index: 2;
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 4px;
  padding: 0.35rem 0.5rem;
  font-size: 0.75rem;
  color: #111;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
  pointer-events: none;
  white-space: nowrap;
}

.chart-tooltip-date {
  font-weight: 600;
  margin-bottom: 0.2rem;
}

/* Now tab - calendar block */
#now-time-hr {
  margin-bottom: 0.2rem;
}

#now-location-weather {
  margin-top: 0;
}

.now-calendar-block {
  margin-top: 1rem;
  padding: 0.75rem;
  border: 1px solid #eee;
  border-radius: 6px;
}

.now-cal-layout {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  align-items: stretch;
}

.now-cal-left {
  min-width: 0;
}

.now-cal-middle {
  min-width: 0;
  border-left: 1px solid #eee;
  padding-left: 0.75rem;
}

.now-cal-right {
  min-width: 0;
  border-left: 1px solid #eee;
  padding-left: 0.75rem;
}

.now-cal-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 0.0rem;
}

.now-cal-title {
  font-weight: 500;
  font-size: 0.95rem;
  color: #111;
}

.now-cal-time {
  font-size: 0.8rem;
  color: #666;
  margin-bottom: 1.0rem;
}

.now-cal-progress-track {
  height: 6px;
  background: #eee;
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 0.4rem;
}

.now-cal-progress-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 0.3s ease;
}

.now-cal-meta {
  display: flex;
  justify-content: flex-end;
  font-size: 0.75rem;
  color: #999;
}

.now-cal-calendar {
  font-style: italic;
}

.now-cal-next {
  margin-top: 0.4rem;
  font-size: 0.8rem;
  color: #666;
}

.now-cal-divider {
  margin-top: 1.0rem;
  height: 1px;
  background: #eee;
}

.now-cal-next-detail {
  font-size: 0.75rem;
  color: #999;
  font-style: italic;
}

.now-cal-empty {
  font-size: 0.85rem;
  color: #666;
}

.now-cal-totals-title {
  font-size: 0.75rem;
  color: #999;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 0.5rem;
}

.now-cal-totals {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 0.4rem;
  align-self: center;
}

.now-cal-total-item {
  display: flex;
  flex-direction: column;
}

.now-cal-total-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 0.25rem;
}

.now-cal-total-name {
  font-size: 0.8rem;
  color: #555;
  font-weight: 400;
}

.now-cal-total-bar {
  height: 6px;
  background: #f1f1f1;
  border-radius: 999px;
  overflow: hidden;
}

.now-cal-total-fill {
  height: 100%;
  border-radius: 999px;
}

.now-cal-total-hours {
  font-variant-numeric: tabular-nums;
  font-size: 0.65rem;
  color: #999;
  white-space: nowrap;
  font-weight: 400;
}

.now-cal-weekly-chart {
  display: flex;
  justify-content: center;
  align-items: center;
  margin-top: 0.4rem;
}

@media (max-width: 700px) {
  .metrics-grid {
    grid-auto-flow: row;
    grid-template-columns: repeat(auto-fit, minmax(120px, max-content));
    justify-content: start;
    column-gap: 0.5rem;
    row-gap: 0.75rem;
  }

  .now-cal-layout {
    grid-template-columns: 1fr;
  }

  .now-cal-middle {
    border-left: none;
    padding-left: 0;
    border-top: 1px solid #eee;
    padding-top: 0.75rem;
  }

  .now-cal-right {
    border-left: none;
    padding-left: 0;
    border-top: 1px solid #eee;
    padding-top: 0.75rem;
  }

  .now-cal-total-row {
    display: contents;
  }

  .past-detail-layout {
    flex-direction: column;
  }

  #past-globe {
    width: 106px;
    height: 106px;
    align-self: center;
  }
}

.now-cal-pct {
  font-variant-numeric: tabular-nums;
}

/* Past timeline */
.past-timeline {
  display: flex;
  width: 100%;
  height: 32px;
  border-radius: 4px;
  overflow: hidden;
}

.past-block {
  flex: 1;
  cursor: pointer;
  border-right: 1px solid #fff;
  opacity: 0.4;
  transition: opacity 0.15s ease;
}

.past-block:last-child {
  border-right: none;
}

.past-block:hover,
.past-block.active {
  opacity: 1;
}

.past-legend {
  display: flex;
  gap: 1rem;
  margin-top: 0.5rem;
  font-size: 0.7rem;
  color: #999;
}

.past-legend-item {
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.past-legend-swatch {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  display: inline-block;
}

.past-detail-layout {
  display: flex;
  gap: 1.5rem;
  margin-top: 1rem;
  align-items: flex-start;
}

.past-detail {
  flex: 1;
  min-width: 0;
}

#past-globe {
  width: 132px;
  height: 132px;
  flex-shrink: 0;
}

.past-detail-place {
  font-weight: 500;
  font-size: 0.95rem;
  color: #111;
  margin-bottom: 0.2rem;
}

.past-detail-activity {
  font-size: 0.85rem;
  color: #666;
  margin-bottom: 0.4rem;
}

.past-detail-outputs {
  list-style: none;
  padding: 0;
}

.past-detail-outputs li {
  font-size: 0.8rem;
  color: #555;
  margin-bottom: 0.25rem;
  padding-left: 0.8rem;
  position: relative;
}

.past-detail-outputs li::before {
  content: "\2013";
  position: absolute;
  left: 0;
  color: #999;
}

/* Loading text */
.loading-text {
  color: #999;
  font-size: 0.9rem;
  margin: 0;
  padding: 0.5rem 0;
}
.loading-text span {
  color: #ccc;
  animation: loadingPulse 1.5s ease-in-out infinite;
}
@keyframes loadingPulse {
  0%, 100% {
    color: #ccc;
  }
  50% {
    color: #333;
  }
}

/* ============================================
   Photo Modal (Easter Egg)
   ============================================ */
.photo-modal {
  display: none;
  position: fixed;
  z-index: 9999;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(255, 255, 255, 0.75);
  justify-content: center;
  align-items: center;
  cursor: pointer;
  animation: fadeIn 0.2s ease-in;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.photo-modal-content {
  max-width: 63%;
  max-height: 63vh;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 4px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
  /* Prevent selection and dragging */
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  pointer-events: auto;
}

/* Medium-sized constraint for desktop */
@media (min-width: 768px) {
  .photo-modal-content {
    max-width: 560px;
  }
}
