/*
 * nav.css — The Gentle Studio
 * Single source of truth for the top navigation bar.
 * Linked by every page. Do not duplicate nav rules elsewhere.
 */

/* ── Nav bar ─────────────────────────────────────────────── */
.site-nav,
#siteNav {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 100;
  display: flex;
  align-items: stretch;
  height: 56px;
  background: var(--color-nav-bg);
  border-bottom: 1px solid var(--color-border);
  transition: border-color var(--duration-normal) var(--ease-out);
}

.site-nav.scrolled,
#siteNav.scrolled {
  border-bottom-color: var(--color-faint);
}

/* ── Logo slot — left ────────────────────────────────────── */
.nav-logo-slot {
  display: flex;
  align-items: stretch;
  border-right: 1px solid var(--color-border);
  flex-shrink: 0;
}

.nav-logo-link {
  display: flex;
  align-items: center;
  padding: 0 24px;
  text-decoration: none;
  color: var(--color-ink);
  transition: opacity var(--duration-fast);
  white-space: nowrap;
}
.nav-logo-link:hover { opacity: 0.6; }

.nav-logo-text {
}

/* A picture cannot take a colour, so a mark that would otherwise sit dark on a
   dark backdrop is inverted. js/nav.js decides, by measuring the logo's own ink
   against what is behind the bar — the class is only ever set when inverting
   is the better of the two. */
#siteNav.logo-inverted .nav-logo-img,
.site-nav.logo-inverted .nav-logo-img { filter: invert(1); }

.nav-logo-img {
  height: 24px;
  width: auto;
  max-width: 140px;
  object-fit: contain;
  display: block;
}

/* ── Center slot — view toggle (homepage only) ──────────── */
.nav-center-slot {
  display: flex;
  align-items: stretch;
  margin: 0 auto;
  border-left: 1px solid var(--color-border);
  border-right: 1px solid var(--color-border);
}

.view-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 56px;
  border: none;
  background: transparent;
  color: var(--color-muted);
  cursor: inherit;
  transition: color var(--duration-fast), background var(--duration-fast);
  padding: 0;
}
.view-btn + .view-btn { border-left: 1px solid var(--color-border); }
.view-btn:hover { color: var(--color-ink); }
.view-btn:focus-visible { outline: 2px solid var(--color-ink); outline-offset: -2px; }
.view-btn.active { color: var(--color-ink); background: var(--color-faint); }
.view-btn svg { width: 14px; height: 14px; }

/* ── Centre slot ─────────────────────────────────────────────
 * Absolutely centred rather than flexed, so the filter sits on the middle of
 * the bar regardless of how wide the logo and the links happen to be. */
.nav-center-slot {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  height: 100%;
  white-space: nowrap;
  pointer-events: auto;
}
.nav-center-slot:empty { display: none; }

/* ── Links slot — right ──────────────────────────────────── */
.nav-links-slot {
  display: flex;
  align-items: stretch;
  margin-left: auto;
}

.nav-link {
  display: flex;
  align-items: center;
  padding: 0 20px;
  border-left: 1px solid var(--color-border);
  text-decoration: none;
  transition: color var(--duration-fast), background var(--duration-fast);
  white-space: nowrap;
  cursor: inherit;
}
.nav-link:hover  { color: var(--color-ink); background: var(--color-faint); }
.nav-link:focus-visible { color: var(--color-ink); outline: 2px solid var(--color-ink); outline-offset: -2px; }
.nav-link.active { color: var(--color-ink); }

/* ── Automatic contrast ──────────────────────────────────────
 * applyNavContrast() in js/nav.js decides whether the measured backdrop
 * suits light text and, if so, re-points --color-muted / --color-ink /
 * --color-accent on the nav element itself. The nav's existing rules then
 * resolve to the overlay colour with no extra selectors, so this survives
 * whatever the style editor writes for .nav-link.
 * Only the hover fill needs stating, since it is a background rather than
 * an inherited colour.
 */
.site-nav.on-dark .nav-link:hover,
.site-nav.on-dark .nav-link.active,
#siteNav.on-dark .nav-link:hover,
#siteNav.on-dark .nav-link.active { background: var(--color-hairline-light); }

.site-nav.on-dark .view-btn:hover,
.site-nav.on-dark .view-btn.active,
#siteNav.on-dark .view-btn:hover,
#siteNav.on-dark .view-btn.active { background: var(--color-hairline-light); }

/* ── CMS corner ──────────────────────────────────────────────
 * Deliberately invisible: no fill, no outline, no hover state. It replaces
 * the "Edit Layout" links that used to sit inside the page composition.
 * Keyboard focus still shows a ring so it remains reachable.
 */
#cmsCorner {
  position: fixed;
  left: 0; bottom: 0;
  width: 44px; height: 44px;
  z-index: 200;
  background: none;
  border: none;
  text-decoration: none;
}
#cmsCorner:focus-visible {
  outline: 2px solid var(--color-ink);
  outline-offset: -2px;
}
