/* Top-bar redesign — red-grid concept (2026-07-11).
   Loaded from _nav.html.j2 AFTER base.css, so equal-specificity rules
   here win the cascade. Three pieces:
     1. Search pill — 34px icon-only, expands to 280px on focus.
     2. Profile chip + hover/click dropdown (account links + admin +
        sign-out + the recent-activity notification feed).
     3. Small layout glue so pill / UPLOAD / chip share one height. */

/* ───── 1. Search pill ───── */
.nav-search {
  display: flex; align-items: center; gap: 0;
  background: var(--ink-100);
  border: 1px solid var(--ink-300);
  border-radius: var(--rad-sm);
  width: 34px; height: 34px;
  padding: 0 6px;
  cursor: text;
  transition: width 0.25s ease, gap 0.25s ease, padding 0.25s ease,
              border-color 0.2s ease;
}
.nav-search .search-icon {
  color: var(--ink-500);
  font-size: 13px; line-height: 1;
  flex: 0 0 20px;
  display: inline-flex; align-items: center; justify-content: center;
  transition: color 0.2s ease;
}
.nav-search:hover .search-icon,
.nav-search:focus-within .search-icon { color: var(--red-400); }
.nav-search input[type="search"] {
  background: transparent;
  border: 0; box-shadow: none;
  padding: 0;
  width: 0; min-width: 0; opacity: 0;
  flex: 1;
  transition: opacity 0.2s ease;
}
.nav-search input[type="search"]:focus {
  border: 0; box-shadow: none; outline: none;
  width: auto;
}
/* .has-text is nav.js's assist: keep the pill open while the input
   holds a query even after focus moves away (Escape clears + closes). */
.nav-search:focus-within,
.nav-search.has-text {
  width: 280px; gap: 8px; padding: 0 12px;
  border-color: var(--red-500);
}
.nav-search:focus-within input[type="search"],
.nav-search.has-text input[type="search"] {
  width: auto; opacity: 1;
}

/* ≤480px: revert the pill — the magnifier toggle (base.css) expands
   .nav-search as a full-width bar pinned under the sticky nav. */
@media (max-width: 480px) {
  .nav-search,
  .nav-search:focus-within,
  .nav-search.has-text {
    /* base.css hides the bar until the magnifier toggles .open —
       restate it here because this file loads after base.css and
       the desktop pill's display:flex would otherwise win. */
    display: none;
    width: auto; height: auto;
    padding: 10px 12px; gap: 0;
    border: 0; border-radius: 0;
    border-bottom: 1px solid color-mix(in oklch, var(--ink-300), transparent 40%);
    cursor: auto;
  }
  .nav-search.open { display: flex; }
  .nav-search .search-icon { display: none; }
  .nav-search input[type="search"],
  .nav-search:focus-within input[type="search"],
  .nav-search.has-text input[type="search"] {
    width: 100%; opacity: 1;
    padding: 10px 12px;
    font-size: 16px;   /* ≥16px stops iOS Safari's auto-zoom-on-focus */
    background: var(--ink-100);
    border: 1px solid var(--ink-300);
    border-radius: var(--rad-sm);
  }
}

/* ───── 2. Profile chip + dropdown ───── */
.profile-menu { position: relative; }
/* Persistent hover bridge — extends the hoverable area 14px below the
   chip so the mouse doesn't leave `.profile-menu:hover` while crossing
   the gap to the dropdown. Lives on `.profile-menu` (always present)
   rather than `.profile-dropdown::before` (which visibility:hidden
   used to knock out between hovers, causing a 1px flicker line where
   the dropdown rapidly opened/closed at the boundary). */
.profile-menu::after {
  content: ""; position: absolute;
  top: 100%; left: 0; right: 0; height: 14px;
}
.profile-menu > .profile-btn {
  position: relative;                 /* anchors the notif badge */
  display: inline-flex; align-items: center; gap: 8px;
  height: 34px; padding: 0 12px; box-sizing: border-box;
  background: transparent;
  border: 1px solid var(--ink-300);   /* match the resting search pill */
  border-radius: var(--rad-sm);
  font-family: var(--font-mono);
  font-size: 11px; font-weight: 600;
  letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--ink-700);
  line-height: 1;
  cursor: pointer;
  transition: border-color 0.2s ease, color 0.2s ease;
}
.profile-menu > .profile-btn .avatar {
  width: 20px; height: 20px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--ink-300);
  flex-shrink: 0;
}
.profile-menu > .profile-btn .avatar-fallback {
  display: inline-grid; place-items: center;
  font-family: var(--font-display);
  font-weight: 700; font-size: 11px;
  color: var(--ink-900);
  background: var(--red-600);
}
.profile-menu > .profile-btn .caret {
  font-size: 9px; opacity: 0.6;
  transition: opacity 0.2s ease;
}
.profile-menu:hover > .profile-btn,
.profile-menu:focus-within > .profile-btn,
.profile-menu.open > .profile-btn {
  border-color: var(--red-400);
  color: var(--red-400);
}
.profile-menu:hover > .profile-btn .caret,
.profile-menu:focus-within > .profile-btn .caret,
.profile-menu.open > .profile-btn .caret { opacity: 1; }

.profile-dropdown {
  position: absolute; top: calc(100% + 14px); inset-inline-end: 0; inset-inline-start: auto;
  min-width: min(320px, calc(100vw - 16px));
  /* never wider or taller than the screen: on a phone a long link in a
     notification used to push the left half off the screen */
  max-width: calc(100vw - 16px);
  max-height: calc(100dvh - 120px);
  background: var(--ink-100);
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  border: 1px solid color-mix(in oklch, var(--ink-300), transparent 40%);
  border-radius: var(--rad-md);
  box-shadow: 0 20px 60px oklch(0.03 0.005 25 / 0.75),
              0 0 0 1px oklch(0.03 0.005 25 / 0.35);
  overflow-x: hidden; overflow-y: auto;
  overscroll-behavior: contain;
  opacity: 0; visibility: hidden; transform: translateY(-4px);
  transition: opacity 0.15s, transform 0.15s, visibility 0.15s;
  z-index: 100;
}
/* Invisible mouse-bridge from chip to dropdown so hover doesn't drop
   when the cursor traverses the 14px gap. */
.profile-dropdown::before {
  content: ""; position: absolute;
  top: -14px; left: 0; right: 0; height: 14px;
}
.profile-menu.open .profile-dropdown,
.profile-menu:hover .profile-dropdown,
.profile-menu:focus-within .profile-dropdown {
  opacity: 1; visibility: visible; transform: translateY(0);
}
.profile-menu[data-dismissed] .profile-dropdown {
  opacity: 0; visibility: hidden; pointer-events: none;
}

.profile-dropdown a.pd-header {
  padding: 14px 16px 12px;
  display: flex; align-items: center; gap: 12px;
  border-bottom: 1px solid color-mix(in oklch, var(--ink-300), transparent 60%);
  text-decoration: none; color: inherit;
  cursor: pointer; transition: background 0.15s;
  border-top-left-radius: calc(var(--rad-md) - 1px);
  border-top-right-radius: calc(var(--rad-md) - 1px);
}
.profile-dropdown a.pd-header:hover {
  background: color-mix(in oklch, var(--red-400), transparent 90%);
  /* inset box-shadow respects border-radius; outline does not, so its
     top corners were being cropped by the dropdown's rounded shell. */
  box-shadow: inset 0 0 0 1px var(--red-400);
}
.profile-dropdown a.pd-header:hover .pd-name { color: var(--red-400); }
.profile-dropdown a.pd-header:hover .pd-header-arrow {
  color: var(--red-400); transform: translateX(3px);
}
.profile-dropdown .pd-header-arrow {
  margin-left: auto; color: var(--ink-500);
  font-family: var(--font-mono); font-size: 16px;
  transition: transform 0.15s, color 0.15s;
}
.profile-dropdown .pd-avatar-lg {
  width: 40px; height: 40px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--ink-300);
  flex-shrink: 0;
}
/* Ko-fi menu row — sits below About in the top pd-section. Cup rim
   + handle detail follow the icon color, which is fixed to Ko-fi
   brand orange #FF6433 so the whole mark reads as one — same tone
   as the heart. Override the default .pd-item:hover .pd-icon rule
   so the row hover doesn't recolor the cup to red. Heart still
   lights up on hover (brightness + drop-shadow glow). */
.profile-dropdown .pd-icon.pd-icon-kofi {
  color: #FF6433;
}
.profile-dropdown .pd-item.pd-item-kofi:hover .pd-icon.pd-icon-kofi {
  color: #FF6433;
}
.profile-dropdown .pd-icon.pd-icon-kofi svg {
  width: 20px; height: 20px;
  display: block;
}
.profile-dropdown .pd-icon.pd-icon-kofi .pd-kofi-heart {
  transition: filter 0.15s;
}
.profile-dropdown .pd-item.pd-item-kofi:hover .pd-icon.pd-icon-kofi .pd-kofi-heart {
  filter: brightness(1.4) drop-shadow(0 0 3px #FF6433);
}
/* Discord menu row — SVG mark fixed to Discord blurple #5865F2 on both
   idle and row hover, so the mark stays recognizable instead of shifting
   to the default red-on-hover accent. No glow — the row's own hover
   background gives it enough feedback. */
.profile-dropdown .pd-icon.pd-icon-discord,
.profile-dropdown .pd-item:hover .pd-icon.pd-icon-discord {
  color: #5865F2;
}
.profile-dropdown .pd-icon.pd-icon-discord svg {
  /* Integer width + height (18×14 ≈ viewBox 126.644×96 aspect) so the
     mark renders on whole-pixel boundaries. `height: auto` computes to
     13.6px which triggers sub-pixel AA and reads as a soft halo. */
  width: 18px; height: 14px;
  display: block;
  shape-rendering: geometricPrecision;
}
.profile-dropdown .pd-avatar-fallback {
  display: inline-grid; place-items: center;
  font-family: var(--font-display);
  font-weight: 900; font-size: 18px;
  color: var(--ink-900);
  background: var(--red-600);
}
.profile-dropdown .pd-name {
  font-family: var(--font-body);
  font-weight: 600; font-size: 14px; color: var(--ink-800);
}
.profile-dropdown .pd-sub {
  font-family: var(--font-mono); font-size: 10px; color: var(--ink-500);
  text-transform: uppercase; letter-spacing: 0.08em; margin-top: 2px;
}

.profile-dropdown .pd-section {
  padding: 6px 0;
  border-bottom: 1px solid color-mix(in oklch, var(--ink-300), transparent 70%);
}
.profile-dropdown .pd-section:last-child { border-bottom: 0; }
.profile-dropdown .pd-form { margin: 0; padding: 0; }
.profile-dropdown .pd-item {
  display: flex; align-items: center; gap: 12px;
  width: 100%;
  padding: 9px 16px;
  background: transparent; border: 0; border-radius: 0;
  text-decoration: none; text-align: left;
  font-family: var(--font-body); font-size: 13px; color: var(--ink-800);
  letter-spacing: normal; text-transform: none; font-weight: 400;
  cursor: pointer;
}
.profile-dropdown .pd-item:hover {
  background: color-mix(in oklch, var(--red-400), transparent 90%);
  color: var(--red-400);
  outline: 1px solid var(--red-400); outline-offset: -1px;
}
.profile-dropdown .pd-item .pd-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 20px; font-size: 14px; color: var(--ink-500);
}
.profile-dropdown .pd-item:hover .pd-icon { color: var(--red-400); }
.profile-dropdown .pd-item .pd-ext {
  margin-left: auto; color: var(--ink-500);
  font-family: var(--font-mono); font-size: 11px;
}
.profile-dropdown .pd-item .pd-badge {
  margin-left: auto;
  background: var(--red-500); color: var(--ink-0);
  font-family: var(--font-mono); font-size: 10px; font-weight: 700;
  padding: 1px 6px; border-radius: 8px; letter-spacing: normal;
}
.profile-dropdown .pd-item.sign-out { color: var(--red-400); }
/* Admin entry gets the warm-amber accent so it reads as a different
   privilege level from the regular items. */
.profile-dropdown .pd-item.admin-item .pd-icon { color: oklch(0.72 0.16 65); }
.profile-dropdown .pd-item.admin-item:hover .pd-icon { color: oklch(0.82 0.19 65); }
.profile-dropdown .pd-item.admin-item:hover {
  background: color-mix(in oklch, oklch(0.72 0.16 65), transparent 90%);
  color: oklch(0.82 0.19 65);
  outline: 1px solid oklch(0.72 0.16 65); outline-offset: -1px;
}
.profile-dropdown .pd-preview-toggle {
  min-block-size: 44px;
  padding-inline-start: 48px;
  text-align: start;
}
.pd-preview-toggle .pd-preview-state {
  margin-inline-start: auto;
  color: var(--ink-700);
  font-size: 12px;
}
.pd-preview-on,
.pd-preview-toggle[aria-checked="true"] .pd-preview-off { display: none; }
.pd-preview-toggle[aria-checked="true"] .pd-preview-on { display: inline; }
.pd-preview-switch {
  position: relative;
  flex: none;
  inline-size: 30px;
  block-size: 16px;
  border: 1px solid var(--ink-500);
  border-radius: 999px;
  background: var(--ink-200);
  transition: background-color 150ms ease-out, border-color 150ms ease-out;
}
.pd-preview-switch::after {
  content: "";
  position: absolute;
  inset-block-start: 2px;
  inset-inline-start: 2px;
  inline-size: 10px;
  block-size: 10px;
  border-radius: 50%;
  background: var(--ink-700);
  transition: inset-inline-start 150ms ease-out;
}
.pd-preview-toggle[aria-checked="true"] .pd-preview-switch { background: var(--red-400); border-color: var(--red-400); }
.pd-preview-toggle[aria-checked="true"] .pd-preview-switch::after { inset-inline-start: calc(100% - 12px); background: var(--ink-0); }
.pd-preview-toggle:focus-visible { outline: 2px solid var(--red-400); outline-offset: -2px; }
.pd-preview-toggle:disabled { opacity: .6; cursor: wait; }
.pd-preview-status { margin: .25rem 1rem .5rem 3rem; color: var(--red-400); font: 400 .75rem/1.4 var(--font-body); }
@media (prefers-reduced-motion: reduce) {
  .pd-preview-switch, .pd-preview-switch::after { transition: none; }
}
.profile-dropdown .pd-badge.admin-badge {
  background: color-mix(in oklch, oklch(0.72 0.16 65), transparent 20%);
  color: oklch(0.15 0.06 65);
}
/* Supporter thanks-row: warm Ko-fi coral heart + badge, distinct from
   both the red accent and the admin amber. */
.profile-dropdown .pd-item.pd-item-kofi .pd-icon { color: #FF6433; }
.profile-dropdown .pd-badge.sup-badge {
  background: color-mix(in oklch, #FF6433, transparent 20%);
  color: oklch(0.16 0.05 40);
}

/* Notification feed (bottom of dropdown). Rows are rendered by nav.js
   with the .notif-row markup base.css already styles; this block only
   frames the section. */
.profile-dropdown .pd-notif-hdr {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px 4px;
  font-family: var(--font-mono); font-size: 10px;
  color: var(--ink-500); text-transform: uppercase; letter-spacing: 0.12em;
}
.profile-dropdown .pd-notif-clear {
  background: transparent; border: 0; cursor: pointer;
  font-family: var(--font-mono); font-size: 10px;
  color: var(--ink-500);
  letter-spacing: 0.06em; text-transform: uppercase;
  padding: 0;
}
.profile-dropdown .pd-notif-clear:hover { color: var(--red-400); }
.profile-dropdown .pd-notif-acts { display: flex; gap: 14px; }
.profile-dropdown .pd-notif-clear.is-armed { color: var(--red-400); }
.profile-dropdown .notif-list {
  max-height: 260px;
  overflow-y: auto;
  padding: 4px 6px;
}
.profile-dropdown .notif-foot {
  display: block;
  padding: 9px 16px;
  border-top: 1px solid color-mix(in oklch, var(--ink-300), transparent 70%);
}

/* ───── 3. Layout glue ───── */
/* One shared size keeps the v2 logo and every top-level action aligned,
   including the avatar and phone-only search toggle. */
html[data-v2-icons] nav.top { --nav-control-size: 44px; }
html[data-v2-icons] nav.top .logo .logo-mark-v2 {
  width: var(--nav-control-size);
  height: var(--nav-control-size);
}
html[data-v2-icons] nav.top .nav-btn,
html[data-v2-icons] nav.top .profile-btn {
  height: var(--nav-control-size);
  min-width: var(--nav-control-size);
  justify-content: center;
  font-size: 14px;
  letter-spacing: .04em;
}
html[data-v2-icons] nav.top .nav-btn .icon,
html[data-v2-icons] nav.top .nav-search .search-icon { font-size: 22px; --r3d-icon-size: 22px; }
html[data-v2-icons] nav.top .nav-search .search-icon { flex-basis: 22px; }
html[data-v2-icons] nav.top .profile-btn .avatar { width: 26px; height: 26px; }
html[data-v2-icons] nav.top .profile-btn .label { max-inline-size: 16ch; overflow: hidden; text-overflow: ellipsis; }
@media (min-width: 481px) {
  html[data-v2-icons] nav.top .nav-search { height: var(--nav-control-size); }
  html[data-v2-icons] nav.top .nav-search:not(:focus-within):not(.has-text) {
    width: var(--nav-control-size);
    padding-inline: 10px;
  }
}
@media (max-width: 720px) {
  /* Chip collapses to avatar-only alongside the icon-only buttons. */
  .profile-menu > .profile-btn .label,
  .profile-menu > .profile-btn .caret { display: none; }
  .profile-menu > .profile-btn { padding: 0 7px; }
  html[data-v2-icons] nav.top .profile-btn { width: var(--nav-control-size); }
  .profile-dropdown { min-width: 0; width: min(320px, calc(100vw - 16px)); }
}

/* Language picker (globe in the top nav). Popover of native language names. */
.nav-lang { position: relative; }
.nav-lang-menu {
  position: absolute; top: calc(100% + 6px); inset-inline-end: 0; z-index: 60;
  margin: 0; padding: 6px; list-style: none;
  min-width: 180px; max-height: 70vh; overflow-y: auto;
  background: var(--ink-100); border: 1px solid var(--ink-300);
  border-radius: var(--rad-md);
  box-shadow: 0 12px 32px rgba(0,0,0,.45);
}
.nav-lang-opt {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 8px 10px; border: 0; background: transparent; cursor: pointer;
  font-family: var(--font-body); font-size: 14px; color: var(--ink-800);
  border-radius: var(--rad-sm); text-align: left;
}
.nav-lang-opt:hover { background: var(--ink-200); color: var(--ink-900); }
.nav-lang-opt.is-current { color: var(--red-400); }
.nav-lang-check { width: 14px; color: var(--red-400); font-size: 12px; }
