/* Shared by every page: theme colours, navigation and the menu. */

/* --- Themes ----------------------------------------------------------------
   js/settings.js sets data-theme on <html> to light, dark or vintage ("Auto"
   picks light or dark to match the device). */

:root,
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f6f3ec;
  --surface: #ffffff;
  --surface-hover: #f1ede4;
  --glass: rgba(255, 255, 255, 0.92);
  --text: #2f2c27;
  --text-soft: #4d4a44;
  --muted: #7d7667;
  --line: #e7e1d5;
  --line-strong: #d6d0c3;
  --accent: #3f6f80;
  --on-accent: #ffffff;
  --shadow: rgba(0, 0, 0, 0.22);

  /* Map */
  --ocean: #a9d3de;
  --land: #f4f0e6;
  --border: #b3a995;
  --label: #4d4a44;
  --label-halo: #ffffff;
  --city-dot: #5b5547;
  --month: #2f9e6e;
  --place: #c2410c;
  --place-text: #9a3412;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #15191c;
  --surface: #1f2428;
  --surface-hover: #2a3036;
  --glass: rgba(31, 36, 40, 0.92);
  --text: #ece8e0;
  --text-soft: #d2cdc3;
  --muted: #9a958b;
  --line: #343b41;
  --line-strong: #46505a;
  --accent: #6fa8bd;
  --on-accent: #0f1417;
  --shadow: rgba(0, 0, 0, 0.5);

  --ocean: #142530;
  --land: #2b3035;
  --border: #4b535a;
  --label: #d9d4ca;
  --label-halo: #15191c;
  --city-dot: #cfc9bd;
  --month: #3fbf86;
  --place: #fb923c;
  --place-text: #fdba74;
}

:root[data-theme="vintage"] {
  color-scheme: light;
  --bg: #efe6d3;
  --surface: #faf4e6;
  --surface-hover: #ece2cc;
  --glass: rgba(250, 244, 230, 0.94);
  --text: #3b2f22;
  --text-soft: #4f4030;
  --muted: #85735a;
  --line: #ddd0b5;
  --line-strong: #c9b996;
  --accent: #8a5a2b;
  --on-accent: #ffffff;
  --shadow: rgba(60, 40, 10, 0.25);

  --ocean: #c4d3c9;
  --land: #f3e9d2;
  --border: #b39c76;
  --label: #5a4630;
  --label-halo: #f8f1e1;
  --city-dot: #6b5338;
  --month: #5f8f3e;
  --place: #b4441c;
  --place-text: #8a3214;
}

:root {
  /* Space taken by the navigation bars; set by the nav-* classes below. */
  --nav-top: 0px;
  --nav-bottom: 0px;
  /* Where floating controls start: below the top bar, or below the phone's
     status bar / notch when there is no top bar. */
  --float-top: max(var(--nav-top), env(safe-area-inset-top, 0px));
  --visited-color: #1d4f91;
  -webkit-tap-highlight-color: transparent;
}

/* The nav-* class is set on <html> by js/settings.js before the page is
   drawn, so space for the bar is reserved from the start (no jump). */
.nav-top {
  --nav-top: calc(56px + env(safe-area-inset-top, 0px));
}

.nav-bottom {
  --nav-bottom: calc(62px + env(safe-area-inset-bottom, 0px));
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* --- Menu button and dropdown ("Menu button only" navigation) ------------- */

.menu-wrap {
  position: fixed;
  top: calc(var(--float-top) + 12px);
  right: calc(12px + env(safe-area-inset-right, 0px));
  z-index: 1100;
}

.menu-button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--glass);
  color: var(--text-soft);
  box-shadow: 0 1px 4px var(--shadow);
  cursor: pointer;
}

.menu-button[aria-expanded="true"] {
  background: var(--surface-hover);
}

.menu {
  position: absolute;
  top: 48px;
  right: 0;
  min-width: 210px;
  padding: 6px;
  background: var(--surface);
  border-radius: 10px;
  box-shadow: 0 4px 16px var(--shadow);
}

.menu[hidden] {
  display: none;
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  box-sizing: border-box;
  padding: 9px 10px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  font: inherit;
  font-size: 14px;
  color: var(--text);
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}


.menu-item[aria-current="page"] {
  font-weight: 600;
  color: var(--accent);
}

.menu-item[aria-current="page"] .menu-icon {
  color: var(--accent);
}

.menu-icon {
  display: flex;
  width: 18px;
  height: 18px;
  flex: none;
  color: var(--muted);
}

.menu-divider {
  height: 1px;
  margin: 6px 4px;
  background: var(--line);
}

.menu-check {
  width: 16px;
  height: 16px;
  margin: 1px;
  flex: none;
  border: 1.5px solid var(--muted);
  border-radius: 4px;
  box-sizing: border-box;
}

.menu-item[aria-checked="true"] .menu-check {
  background: var(--accent) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M4 8.5l2.5 2.5L12 5.5' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 100% no-repeat;
  border-color: var(--accent);
}

/* --- Top bar and bottom bar navigation ------------------------------------ */

.nav-bar {
  position: fixed;
  left: 0;
  right: 0;
  z-index: 1100;
  display: flex;
  justify-content: center;
  gap: 4px;
  background: var(--glass);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}

.nav-bar--top {
  top: 0;
  height: var(--nav-top);
  align-items: center;
  padding: env(safe-area-inset-top, 0px) calc(12px + env(safe-area-inset-right, 0px)) 0
           calc(12px + env(safe-area-inset-left, 0px));
  border-bottom: 1px solid var(--line);
}

.nav-bar--bottom {
  bottom: 0;
  height: var(--nav-bottom);
  padding: 0 calc(4px + env(safe-area-inset-right, 0px)) env(safe-area-inset-bottom, 0px)
           calc(4px + env(safe-area-inset-left, 0px));
  border-top: 1px solid var(--line);
  justify-content: space-around;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 8px 14px;
  border: 0;
  border-radius: 999px;
  background: none;
  color: var(--text-soft);
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
}

.nav-link[aria-current="page"] {
  background: var(--accent);
  color: var(--on-accent);
}

.nav-link .menu-icon {
  color: inherit;
}

.nav-bar--bottom .nav-link {
  flex: 1;
  flex-direction: column;
  justify-content: center;
  gap: 3px;
  max-width: 96px;
  padding: 6px 0;
  border-radius: 0;
  font-size: 11px;
}

.nav-bar--bottom .nav-link[aria-current="page"] {
  background: none;
  color: var(--accent);
  font-weight: 600;
}

.nav-bar--bottom .menu-icon {
  width: 22px;
  height: 22px;
}

/* On narrow screens the top bar looks like the bottom bar: evenly spaced
   icons with small labels, the current page shown in the accent colour. */
@media (max-width: 560px) {
  .nav-bar--top {
    gap: 0;
    padding-left: calc(4px + env(safe-area-inset-left, 0px));
    padding-right: calc(4px + env(safe-area-inset-right, 0px));
    justify-content: space-around;
  }

  .nav-bar--top .nav-link {
    flex: 1;
    flex-direction: column;
    justify-content: center;
    gap: 3px;
    max-width: 96px;
    height: 100%;
    padding: 0;
    border-radius: 0;
    font-size: 11px;
  }

  .nav-bar--top .nav-link[aria-current="page"] {
    background: none;
    color: var(--accent);
    font-weight: 600;
  }

  .nav-bar--top .menu-icon {
    width: 21px;
    height: 21px;
  }
}

/* Hover effects only where there's a mouse; on touch screens they would
   stick after a tap. */
@media (hover: hover) {
  .menu-button:hover,
  .menu-item:hover {
    background: var(--surface-hover);
  }

  .nav-bar--top .nav-link:not([aria-current="page"]):hover {
    background: var(--surface-hover);
  }
}

@media (hover: hover) and (max-width: 560px) {
  .nav-bar--top .nav-link:not([aria-current="page"]):hover {
    background: none;
    color: var(--text);
  }
}

.menu-button:focus-visible,
.menu-item:focus-visible,
.nav-link:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
