/* Header of the text pages (templates/_site_header.html, nav.js), ported from the thai-map prototype:
   name, main menu, and the menus Destinations, Regions and Things to find in a second row. Colours
   from the start page's palette (home.css); the map has no header. */
:root {
  --bg: #f6f5ef;
  --bg-elevated: #fff;
  --bg-surface: #eeece3;
  --fg: #222;
  --fg-secondary: rgb(34 34 34 / 0.68);
  --fg-tertiary: rgb(34 34 34 / 0.6);
  --border: #e3e1d2;
  --border-hover: rgb(34 34 34 / 0.24);
  --accent: #FF7326;
  --gutter: 16px; /* left and right, the same as the page content */
  --shadow-popover: 0 8px 24px rgb(0 0 0 / 0.12);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121212;
    --bg-elevated: #1b1b1b;
    --bg-surface: #262626;
    --fg: #ddd;
    --fg-secondary: rgb(221 221 221 / 0.68);
    --fg-tertiary: rgb(221 221 221 / 0.58);
    --border: #2a2a2a;
    --border-hover: rgb(221 221 221 / 0.24);
    --shadow-popover: 0 8px 24px rgb(0 0 0 / 0.5);
  }
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  font: 1rem/1.7 system-ui, sans-serif;
  color: var(--fg);
  -webkit-font-smoothing: antialiased;
}
.site-header,
.site-header *,
.site-header *::before,
.site-header *::after {
  box-sizing: border-box;
}
.site-header ul {
  margin: 0;
}
.site-header :focus-visible {
  outline: 2px solid var(--fg);
  outline-offset: 3px;
  border-radius: 2px;
}
/* As wide as the page content (home.css), main menu on the right */
.site-header-inner {
  position: relative;
  max-width: 1040px;
  margin: 0 auto;
  padding-inline: var(--gutter);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  min-height: 3.25rem;
}
.site-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.nav-toggle .icon-close,
.nav-toggle[aria-expanded="true"] .icon-open {
  display: none;
}
.nav-toggle[aria-expanded="true"] .icon-close {
  display: block;
}
.brand {
  font-weight: 700;
  font-size: 22px;
  letter-spacing: -0.02em;
  color: var(--fg);
  text-decoration: none;
}
.brand span {
  color: var(--accent);
}
.nav ul {
  display: flex;
  gap: 1.5rem;
  list-style: none;
  margin: 0;
  padding: 0;
}
.nav a {
  display: block;
  padding-block: 0.5rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--fg-secondary);
  text-decoration: none;
}
.nav a:hover,
.nav a[aria-current] {
  color: var(--fg);
}
.nav a[aria-current] {
  text-decoration: underline;
  text-underline-offset: 0.5em;
  text-decoration-thickness: 1px;
}

/* Second row under the name: Destinations, Regions, Things to find */
.subnav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1.5rem;
  flex-basis: 100%;
  margin-top: -0.5rem;
  padding-bottom: 0.375rem;
}

/* Menu "Destinations" (<details>): list under its button, over the content */
.nav-menu {
  position: relative;
}
.nav-menu summary {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  padding-block: 0.5rem;
  list-style: none;
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--fg-secondary);
}
.nav-menu summary::-webkit-details-marker {
  display: none;
}
.nav-menu summary::after {
  content: "";
  width: 0.375rem;
  height: 0.375rem;
  margin-top: -0.25rem;
  border: solid currentColor;
  border-width: 0 1.5px 1.5px 0;
  transform: rotate(45deg);
}
.nav-menu details[open] summary::after {
  margin-top: 0.25rem;
  transform: rotate(-135deg);
}
.nav-menu summary:hover,
.nav-menu details[open] summary {
  color: var(--fg);
}
.nav .nav-menu details > ul {
  position: absolute;
  top: 100%;
  left: -0.625rem;
  z-index: 30;
  display: block;
  min-width: 15rem;
  max-height: 70vh;
  overflow-y: auto;
  padding: 0.375rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow-popover);
}
.nav .nav-menu details > ul a {
  padding: 0.375rem 0.625rem;
  border-radius: 6px;
  color: var(--fg);
  white-space: nowrap;
}
.nav .nav-menu details > ul a:hover {
  background: var(--bg-surface);
}
.nav .nav-menu details > ul a[aria-current] {
  text-decoration: none;
  font-weight: 600;
  background: var(--bg-surface);
  box-shadow: inset 2px 0 0 var(--fg);
}
.nav-menu [lang="th"] {
  margin-left: 0.25rem;
  color: var(--fg-tertiary);
  font-weight: 400;
}

/* Menu "Regions": a panel over the width of the content with three columns (regions | provinces |
   districts). The provinces hang in their region (<li>) but lie absolutely in the panel; the
   regions column has no position, or it would clip them. */
.nav .nav-mega {
  position: static;
}
.nav .mega {
  position: absolute;
  top: 100%;
  left: var(--gutter);
  right: var(--gutter);
  z-index: 30;
  max-width: 46rem;
  height: min(30rem, calc(100vh - 5rem));
  margin-top: 0.25rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow-popover);
}
.nav .mega ul {
  display: block;
  margin: 0;
  padding: 0.375rem;
  list-style: none;
}
.nav .mega .mega-regions {
  width: 33.333%;
}
.nav .mega .mega-sub,
.nav .mega .mega-districts {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 33.333%;
  overflow-y: auto;
  border-left: 1px solid var(--border);
}
.nav .mega .mega-sub {
  left: 33.333%;
  display: none;
}
.nav .mega .mega-districts {
  left: 66.666%;
}
.nav .mega .mega-item.open > .mega-sub {
  display: block;
}
.nav .mega-item {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  border-radius: 6px;
}
.nav .mega-item.open {
  background: var(--bg-surface);
}
.nav .mega a {
  flex: 1;
  padding: 0.375rem 0.625rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--fg);
  text-decoration: none;
  border-radius: 6px;
}
.nav .mega a:hover {
  background: var(--bg-surface);
}
.nav .mega a[aria-current] {
  text-decoration: none;
  font-weight: 700;
  box-shadow: inset 2px 0 0 var(--fg);
}

/* Menu "Things to find": a panel like "Regions" with the categories in a grid */
.nav .nav-types {
  position: static;
}
.nav .types-panel {
  position: absolute;
  top: 100%;
  left: var(--gutter);
  right: var(--gutter);
  z-index: 30;
  max-width: 60rem;
  max-height: calc(100vh - 6rem);
  overflow-y: auto;
  margin-top: 0.25rem;
  padding: 1rem 1.25rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow-popover);
}
.types-where {
  margin: 0 0 0.875rem;
  font-size: 0.875rem;
  color: var(--fg-secondary);
}
.nav .types-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr));
  gap: 0 1.5rem;
}
.nav .types-panel a {
  padding-block: 0.1875rem;
  font-size: 0.875rem;
  font-weight: 400;
  color: var(--fg);
}
.nav .types-panel a:hover {
  text-decoration: underline;
}
.nav .types-panel a[aria-current] {
  font-weight: 700;
  text-decoration: none;
}
.nav .types-where a {
  display: inline;
  padding: 0;
  font-weight: 500;
  text-decoration: underline;
}

/* Button with the page's place instead of "Destinations"/"Regions", long names shortened */
.nav-menu summary.is-here {
  color: var(--fg);
  font-weight: 600;
}
.nav-here {
  max-width: 16rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.nav .mega-note {
  padding: 0.375rem 0.625rem;
  font-size: 0.875rem;
  color: var(--fg-tertiary);
}
.mega-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: 1.75rem;
  padding: 0;
  color: var(--fg-tertiary);
  background: none;
  border: 0;
  border-radius: 6px;
  cursor: pointer;
}
.mega-toggle::before {
  content: "";
  width: 0.375rem;
  height: 0.375rem;
  border: solid currentColor;
  border-width: 0 1.5px 1.5px 0;
  transform: rotate(-45deg);
}
.mega-toggle:hover,
.mega-item.open > .mega-toggle {
  color: var(--fg);
}

/* Menu button: only with JavaScript and on narrow screens. Without JavaScript the menus stay open. */
.nav-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  padding: 0;
  background: none;
  color: var(--fg);
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
}
.nav-toggle:hover {
  background: var(--bg-surface);
}
@media (max-width: 36em) {
  .js .nav-toggle {
    display: inline-flex;
  }
  .js .site-bar {
    flex-basis: 100%;
    min-height: 3.25rem;
  }
  .js .nav {
    width: 100%;
  }
  .js .nav:not([data-state="open"]) {
    display: none;
  }
  .js .nav ul {
    flex-direction: column;
    gap: 0;
    padding-bottom: 0.5rem;
  }
  .nav a {
    font-size: 1rem;
  }
  /* No Regions and Things to find on phones, too much for their menu: the start page lists the
     regions, a directory page's filter panel has the places and categories */
  .subnav {
    display: none;
  }
}

/* The footer of every text page (templates/_site_footer.html), as wide as the header */
.bottom {
  box-sizing: border-box;
  max-width: 1040px;
  margin: 0 auto;
  padding: 14px var(--gutter);
  font-size: 13px;
  color: var(--fg-tertiary);
}
.bottom a { color: inherit; }
