/* ─────────────────────────────────────
  1. Base & Typography
───────────────────────────────────── */
html, body {
  font-family: 'Inter', sans-serif;
  height: 100%;
  margin: 0;
  padding: 0;
}

canvas {
  margin-bottom: 1rem;
}

/* ─────────────────────────────────────
  2. Color Variables per Day
───────────────────────────────────── */
:root {
  --day-1:  #e6194b;
  --day-2:  #3cb44b;
  --day-3:  #ffe119;
  --day-4:  #4363d8;
  --day-5:  #f58231;
  --day-6:  #911eb4;
  --day-7:  #46f0f0;
  --day-8:  #343434;
  --day-9:  #bcf60c;
  --day-10: #ff7f7f;
  --day-11: #008080;
  --day-12: #dda0dd;
  --day-13: #9a6324;
  --day-14: #ffcc00;
  --day-15: #343434;
  --day-16: #3cb44b;
  --day-17: #00cc99;
  --day-18: #808000;
  --day-19: #ff9966;
  --day-20: #800000;
}

/* ─────────────────────────────────────
  3. Map Layout
───────────────────────────────────── */
#map {
  height: 100vh;
  width: 100vw;
  position: absolute;
  top: 0;
  left: 0;
  z-index: 1;
}

/* ─────────────────────────────────────
  4. Floating Buttons
───────────────────────────────────── */
.fab {
  position: fixed;
  top: 12px;
  left: 12px;
  background: white;
  border-radius: 6px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
  padding: 8px 12px;
  font-size: 1.2rem;
  font-weight: bold;
  cursor: pointer;
  z-index: 1100;
}

.fab:hover {
  background: #f0f0f0;
}

/* ─────────────────────────────────────
  5. Legend Styling
───────────────────────────────────── */
.legend {
  position: absolute;
  top: 10px;
  left: 10px;
  background: white;
  padding: 10px;
  z-index: 1000;
  font-family: 'Inter', sans-serif;
  text-align: center;
}

.legend ul {
  padding-left: 10px;
  line-height: 1.5;
  list-style-position: inside;
  text-align: left;
}

.legend a {
  color: #333;
  text-decoration: none;
  font-size: 0.7rem;
}

.legend a:hover {
  text-decoration: underline;
}

.legend-footer {
  margin-top: 0.5rem;
  font-size: 0.9rem;
}

.legend-day[data-day] {
  font-weight: 500;
}

.legend-day[data-day="1"]  { color: var(--day-1); }
.legend-day[data-day="2"]  { color: var(--day-2); }
.legend-day[data-day="3"]  { color: var(--day-3); }
.legend-day[data-day="4"]  { color: var(--day-4); }
.legend-day[data-day="5"]  { color: var(--day-5); }
.legend-day[data-day="6"]  { color: var(--day-6); }
.legend-day[data-day="7"]  { color: var(--day-7); }
.legend-day[data-day="8"]  { color: var(--day-8); }
.legend-day[data-day="9"]  { color: var(--day-9); }
.legend-day[data-day="10"] { color: var(--day-10); }
.legend-day[data-day="11"] { color: var(--day-11); }
.legend-day[data-day="12"] { color: var(--day-12); }
.legend-day[data-day="13"] { color: var(--day-13); }
.legend-day[data-day="14"] { color: var(--day-14); }
.legend-day[data-day="15"] { color: var(--day-15); }
.legend-day[data-day="16"] { color: var(--day-16); }
.legend-day[data-day="17"] { color: var(--day-17); }
.legend-day[data-day="18"] { color: var(--day-18); }
.legend-day[data-day="19"] { color: var(--day-19); }
.legend-day[data-day="20"] { color: var(--day-20); }

.active-day {
  font-weight: 700;
  text-decoration: underline;
}

/* ─────────────────────────────────────
  6. Modal Layout
───────────────────────────────────── */
.modal {
  position: fixed;
  top: 0;
  right: -50vw;
  width: 50vw;
  height: 100vh;
  background: #fff;
  box-shadow: -2px 0 12px rgba(0,0,0,0.3);
  z-index: 2000;
  overflow-y: auto;
  transition: right 0.4s cubic-bezier(0.25, 1, 0.5, 1);
  pointer-events: auto;
}

.modal.show {
  right: 0;
}

.modal-content {
  padding: 24px;
  line-height: 1.7;
  font-size: 1rem;
  box-sizing: border-box;
}

.modal-content p + canvas {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid #eee;
}

#modalTitle {
  display: none;
}

.close-btn {
  text-align: right;
  font-size: 1.5em;
  cursor: pointer;
  margin-bottom: 16px;
}

/* ─────────────────────────────────────
  7. Elevation Chart
───────────────────────────────────── */
#elevationChart {
  width: 100%;
  max-width: 700px;
  height: 240px;
  margin-top: 1rem;
}

/* ─────────────────────────────────────
  8. Video Embed
───────────────────────────────────── */
.video-wrapper {
  position: relative;
  width: 100%;
  padding-top: 56.25%;
}

.video-wrapper iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

#videoDescription {
  font-family: 'Inter', sans-serif;
  font-size: 1rem;
  line-height: 1.6;
  border-radius: 6px;
  margin: 1rem 0;
  padding: 1rem;
  color: rgba(255,255,255,0.95);
  background: rgba(0, 0, 0, 0.5);
  box-shadow: 0 1px 4px rgba(0,0,0,0.1);
}

/* ─────────────────────────────────────
  9. Loading Overlay
───────────────────────────────────── */
#loadingNotice {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-family: 'Inter', sans-serif;
  font-size: 1.2rem;
  background: rgba(255, 255, 255, 0.95);
  padding: 1rem 2rem;
  border-radius: 10px;
  box-shadow: 0 4px 8px rgba(0,0,0,0.1);
  z-index: 3000;
}

#modalOverlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.3);
  z-index: 1500;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s cubic-bezier(0.25, 1, 0.5, 1);
}

#modalOverlay.show {
  opacity: 1;
  pointer-events: auto;
}

/* ─────────────────────────────────────
  10. Mobile Responsive – Portrait
───────────────────────────────────── */
@media (max-width: 768px) and (orientation: portrait) {
  .modal {
    top: 20px;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    height: calc(100vh - env(safe-area-inset-top) - 56px);
    max-height: calc(100vh - env(safe-area-inset-top) - 16px);
    transform: translateY(120%);
    border-radius: 16px 16px 0 0;
    transition: transform 0.3s ease-in-out;
  }

  .modal.show {
    transform: translateY(0%);
    padding-top: env(safe-area-inset-top);
  }

  .modal-content {
    max-height: 100%;
    overflow-y: auto;
    padding: 0.5rem 1rem 2rem;
  }

  .swipe-bar {
    width: 40px;
    height: 4px;
    background: #ccc;
    border-radius: 2px;
    margin: 20px auto 10px auto;
    position: relative;
  }

  .swipe-bar::after {
    content: "▼";
    display: block;
    text-align: center;
    color: #aaa;
    font-size: 0.8rem;
    margin-top: 2px;
  }

  .close-btn {
    display: none;
  }
}

/* ─────────────────────────────────────
  11. Mobile Responsive – Landscape
───────────────────────────────────── */
@media (max-width: 768px) and (orientation: landscape) {
  html, body {
    height: 100vh;
    overflow: auto;
  }

  #map {
    height: 100vh;
  }

  .legend {
    max-height: 100vh;
    overflow-y: auto;
  }

  .modal {
    max-height: 100dvh;
    overflow-y: auto;
  }

  .modal-content {
    max-height: none;
    padding: 1rem;
    box-sizing: border-box;
  }

  #elevationChart {
    display: block;
    max-width: 100%;
    height: auto !important;
  }
}

/* ─────────────────────────────────────
  12. Small Screens
───────────────────────────────────── */
@media (max-width: 600px) {
  #elevationChart {
    height: 280px;
  }
}

/* ─────────────────────────────────────
  13. Legend Toggle: Mobile Only
───────────────────────────────────── */
@media (min-width: 769px) {
  .legend-toggle-fab {
    display: none !important;
  }
}

@media (max-width: 768px) {
  .legend.collapsed {
    transform: translateX(-120%);
    transition: transform 0.3s ease;
  }

  .legend {
    transition: transform 0.3s ease;
  }

  .legend-toggle-fab {
    position: fixed;
    top: 12px;
    left: 12px;
    background: white;
    border-radius: 6px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
    padding: 8px 12px;
    font-size: 1.2rem;
    font-weight: bold;
    cursor: pointer;
    z-index: 1100;
  }

  .legend-toggle-fab:hover {
    background: #f0f0f0;
  }
}