/* Shared site header (nav) — used by index.html and account.html.
   Rendered by nav.js. Color variables (--green, --ink, …) come from each
   page's own :root block; --danger has a fallback here for pages that
   don't define it. */

:root { --danger: #b3402f; }
@media (prefers-color-scheme: dark) {
  :root { --danger: #e07a63; }
}
html[data-theme="light"] {
  color-scheme: light;
  --green: #2F7D59;
  --green-dark: #256147;
  --green-tint: #E8F1EB;
  --ink: #172026;
  --muted: #566068;
  --cream: #F7F3EA;
  --card: #ffffff;
  --border: #ece7db;
  --bg: #ffffff;
  --danger: #b3402f;
}
html[data-theme="dark"] {
  color-scheme: dark;
  --green: #4FA97C;
  --green-dark: #3E8A64;
  --green-tint: #16241d;
  --ink: #eef1ee;
  --muted: #9aa4a0;
  --cream: #14181a;
  --card: #1a1f1d;
  --border: #2a302d;
  --bg: #101312;
  --danger: #e07a63;
}

.site-footer {
  display: block;
  width: 100%;
  flex-shrink: 0;
  margin-top: auto;
  border-top: 1px solid var(--border);
  color: var(--muted);
  background: var(--card, var(--bg));
}
.site-footer .site-footer-inner {
  max-width: 960px;
  margin: 0 auto;
  padding: 24px 20px calc(24px + env(safe-area-inset-bottom, 0px));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  font-size: 12px;
}
.site-footer p { margin: 0; }
.site-footer a {
  color: var(--muted);
  font-weight: 600;
}
.site-footer a:hover {
  color: var(--ink);
  text-decoration: none;
}
.site-footer-links {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}
@media (max-width: 640px) {
  .site-footer .site-footer-inner {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
    font-size: 13px;
  }
  .site-footer-links {
    width: 100%;
    justify-content: flex-start;
    gap: 12px 16px;
  }
}

nav {
  position: sticky; top: 0; z-index: 20;
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  border-bottom: 1px solid var(--border);
}
.nav-inner {
  max-width: 960px; margin: 0 auto; padding: 0 20px; height: 60px;
  display: flex; align-items: center; justify-content: space-between;
}
.brand { display: flex; align-items: center; color: var(--ink); }
.brand-wordmark { width: 132px; height: auto; display: block; }

.nav-menu { display: flex; align-items: center; gap: 22px; }
.nav-links { display: flex; gap: 22px; font-size: 14px; align-items: center; }
.nav-links a { color: var(--muted); font-weight: 500; }
.nav-links a:hover { color: var(--ink); text-decoration: none; }
#nav-account { gap: 10px; }
.nav-actions { display: flex; align-items: center; gap: 8px; }
.nav-theme-btn {
  width: 34px; height: 34px; display: grid; place-items: center; padding: 0;
  border: 1px solid var(--border); border-radius: 999px;
  background: var(--bg); color: var(--muted); cursor: pointer;
}
.nav-theme-btn:hover { color: var(--ink); border-color: var(--green); }
.nav-theme-btn:focus-visible { outline: none; border-color: var(--green); color: var(--ink); }
.nav-theme-btn .theme-ic { width: 17px; height: 17px; display: none; }
.nav-theme-btn[data-mode="system"] .theme-ic-system { display: block; }
.nav-theme-btn[data-mode="light"] .theme-ic-light { display: block; }
.nav-theme-btn[data-mode="dark"] .theme-ic-dark { display: block; }
/* Before theme.js stamps data-mode, show the system icon. */
.nav-theme-btn:not([data-mode]) .theme-ic-system { display: block; }

.hide { display: none !important; }

/* Signed-out profile icon (links to account.html) */
.profile-link {
  display: inline-flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  height: 46px; padding: 4px 7px;
  border-radius: 10px;
}
.profile-link svg { width: 25px; height: 25px; display: block; }
.profile-link img { width: 27px; height: 27px; display: block; object-fit: cover; border-radius: 8px; }
.profile-link .profile-link-label { font-size: 10.5px; line-height: 1; font-weight: 700; color: var(--ink); }
.profile-link:hover { background: color-mix(in srgb, var(--ink) 6%, transparent); }

/* Hamburger (mobile only) */
.nav-toggle {
  display: none; align-items: center; justify-content: center;
  width: 36px; height: 36px; padding: 0; border-radius: 9px;
  background: transparent; border: 1px solid var(--border); color: var(--ink); cursor: pointer;
}
.nav-toggle svg { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; }
.nav-toggle:hover { background: color-mix(in srgb, var(--ink) 6%, transparent); }

/* Signed-in app links */
.nav-link-icon {
  display: inline-flex; align-items: center; gap: 7px; min-height: 36px;
  padding: 7px 10px; border-radius: 999px; color: var(--muted);
  font-size: 13px; font-weight: 600;
}
.nav-link-icon:hover {
  color: var(--ink); text-decoration: none;
  background: color-mix(in srgb, var(--ink) 6%, transparent);
}
.nav-link-icon.active { color: var(--green-dark); background: var(--green-tint); }
.nav-link-icon.icon-only {
  width: 36px;
  height: 36px;
  justify-content: center;
  padding: 0;
}
.nav-link-icon svg { width: 19px; height: 19px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.nav-link-icon img { width: 19px; height: 19px; object-fit: contain; flex: none; border-radius: 4px; }

/* Signed-in profile link */
.profile-wrap { position: relative; }
.nav-profile {
  display: flex; align-items: center; gap: 9px; min-width: 0;
  padding: 4px 0 4px 12px; border: 0; border-left: 1px solid var(--border);
  color: inherit; background: transparent; font: inherit; cursor: pointer;
  text-decoration: none;
}
.nav-profile:hover { text-decoration: none; }
.nav-profile:hover .profile-name { color: var(--green-dark); }
.profile-icon { width: 31px; height: 31px; flex: none; display: block; }
.profile-copy { min-width: 0; line-height: 1.15; text-align: left; }
.profile-name { font-size: 13px; font-weight: 700; color: var(--ink); max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profile-email { font-size: 11px; color: var(--muted); max-width: 170px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Mobile: the signed-in icon nav stays inline in the header as compact,
   label-less icons — no hamburger needed. Only the public (text) links, shown
   signed-out, collapse into the hamburger dropdown. */
@media (max-width: 640px) {
  .brand-wordmark { width: 108px; }
  .nav-menu { gap: 8px; }

  .nav-toggle { display: inline-flex; }
  /* Hide the hamburger once the icon nav is showing (signed in). */
  nav:has(#nav-account:not(.hide)) .nav-toggle { display: none; }

  /* Public text links collapse into the hamburger dropdown. */
  #nav-public-links {
    position: absolute; top: 100%; left: 0; right: 0;
    flex-direction: column; align-items: stretch; gap: 0;
    background: var(--bg); border-bottom: 1px solid var(--border);
    box-shadow: 0 18px 40px rgba(23,32,38,.10);
    padding: 6px 20px 12px; display: none;
  }
  nav.menu-open #nav-public-links { display: flex; }
  nav.menu-open #nav-public-links.hide { display: none !important; }
  #nav-public-links a {
    padding: 13px 2px; font-size: 15px; border-top: 1px solid var(--border);
    display: flex; align-items: center; gap: 10px; min-height: 0; border-radius: 0;
  }
  #nav-public-links a:hover { background: transparent; }
  #nav-public-links > a:first-child { border-top: none; }

  /* Signed-in icon links: inline, icon-only. */
  #nav-account { gap: 2px; }
  #nav-account .nav-link-icon { padding: 8px; gap: 0; }
  #nav-account .nav-link-icon span { display: none; }

  nav .nav-profile { padding-left: 0; border-left: 0; }
  nav .profile-copy { display: none; }
  .profile-link { gap: 1px; height: 44px; padding: 3px 6px; border-radius: 9px; }
  .profile-link img { width: 24px; height: 24px; border-radius: 7px; }
  .profile-link .profile-link-label { font-size: 10px; line-height: 1; }
  .nav-theme-btn { width: 32px; height: 32px; }
}
