/* ============================================================
   CANOPY — UNIFIED BROWSING CHROME + FLAG
   One top head everywhere after home: canopy · query · menu · flag
   ============================================================ */

:root {
  --chrome-top: max(env(safe-area-inset-top, 0px), 0.65rem);
  --chrome-right: max(env(safe-area-inset-right, 0px), 0.75rem);
  --chrome-left: max(env(safe-area-inset-left, 0px), 0.75rem);
  --chrome-btn: 2.5rem;
}

/* ---------- living wordmark: same on every browsing surface ---------- */
body.is-browsing .living-home,
body.has-deck .living-home,
body.has-blobs .living-home,
body.has-strip .living-home,
body.has-deck-detail .living-home,
body.has-list-blobs .living-home,
body.is-browsing:has(#results-zone .refine-card) .living-home,
body.is-browsing:has(#results-zone .result-list) .living-home {
  display: inline-flex !important;
  top: var(--chrome-top) !important;
  left: var(--chrome-left) !important;
  gap: 0 !important;
  padding: 0.28rem 0.1rem !important;
  z-index: 95;
}
/* Top-bar brand stays for home only — browsing chrome uses .living-home */
body.is-browsing .top-bar {
  display: none !important;
}
body.is-browsing .living-home-mark,
body.has-deck .living-home-mark,
body.has-blobs .living-home-mark,
body.has-strip .living-home-mark,
body.has-deck-detail .living-home-mark,
body.has-list-blobs .living-home-mark { display: none !important; }
body.is-browsing .living-home-name,
body.has-deck .living-home-name,
body.has-blobs .living-home-name,
body.has-strip .living-home-name,
body.has-deck-detail .living-home-name,
body.has-list-blobs .living-home-name {
  display: inline !important;
  font-family: 'Outfit', 'Familjen Grotesk', sans-serif !important;
  font-size: 1.08rem !important;
  font-weight: 700 !important;
  letter-spacing: 0.02em !important;
  text-transform: lowercase !important;
  line-height: 1 !important;
}

/* ---------- bare hamburger — same everywhere (home + browsing) ---------- */
body.is-browsing .menu-toggle-fixed.pill-btn,
body.is-browsing .menu-toggle-fixed,
body.has-blobs .menu-toggle-fixed.pill-btn,
body.has-blobs .menu-toggle-fixed,
body.has-deck .menu-toggle-fixed,
body.has-strip .menu-toggle-fixed,
body.has-deck-detail .menu-toggle-fixed,
body.has-list-blobs .menu-toggle-fixed {
  top: var(--chrome-top) !important;
  right: var(--chrome-right) !important;
  width: var(--chrome-btn) !important;
  height: var(--chrome-btn) !important;
  min-width: 0 !important;
  padding: 0 !important;
  border: none !important;
  border-radius: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
  color: var(--espresso, #542916) !important;
}
body.is-browsing .menu-toggle-fixed:hover,
body.has-blobs .menu-toggle-fixed:hover,
body.has-deck .menu-toggle-fixed:hover,
body.has-strip .menu-toggle-fixed:hover {
  background: transparent !important;
  color: var(--terre, #a13a1e) !important;
  transform: none !important;
}
body.is-browsing .menu-toggle-fixed .menu-icon,
body.has-blobs .menu-toggle-fixed .menu-icon {
  width: 1.35rem !important;
  height: 1.35rem !important;
  stroke-width: 2.3;
}

/* ---------- focus chip — one style for list / blobs / deck / strip ---------- */
body.is-browsing .focus-bar,
body.has-blobs.is-browsing .focus-bar,
body.has-deck.is-browsing .focus-bar,
body.has-strip.is-browsing .focus-bar,
body.has-list-blobs.is-browsing .focus-bar {
  position: sticky !important;
  top: 0 !important;
  z-index: 45 !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  max-width: none !important;
  width: 100% !important;
  min-height: 2.85rem !important;
  margin: 0 !important;
  gap: 0 !important;
  padding-top: max(0.5rem, env(safe-area-inset-top, 0px)) !important;
  padding-bottom: 0.45rem !important;
  padding-left: max(0.75rem, env(safe-area-inset-left, 0px)) !important;
  padding-right: max(0.75rem, env(safe-area-inset-right, 0px)) !important;
  background: var(--ground, #fdf0e8) !important;
  border-bottom: none !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
}
body.is-browsing .focus-back,
body.has-blobs.is-browsing .focus-back,
body.has-deck.is-browsing .focus-back,
body.has-strip.is-browsing .focus-back {
  display: none !important;
}
body.is-browsing .focus-query,
body.has-blobs.is-browsing .focus-query,
body.has-deck.is-browsing .focus-query,
body.has-strip.is-browsing .focus-query,
body.has-list-blobs.is-browsing .focus-query {
  position: absolute !important;
  left: 50% !important;
  transform: translateX(-50%) !important;
  flex: none !important;
  width: max-content !important;
  max-width: min(26rem, calc(100vw - 8.5rem)) !important;
  min-width: 0 !important;
  gap: 0 !important;
  justify-content: center !important;
  margin: 0 !important;
  padding: 0.42rem 1.05rem !important;
  border: none !important;
  background: color-mix(in srgb, var(--surface, #fff8f2) 88%, transparent) !important;
  border-radius: 999px !important;
  box-shadow: none !important;
  text-align: center !important;
}
body.is-browsing .focus-q-label,
body.has-blobs.is-browsing .focus-q-label,
body.has-deck.is-browsing .focus-q-label,
body.has-strip.is-browsing .focus-q-label {
  display: none !important;
}
body.is-browsing .focus-q-text,
body.has-blobs.is-browsing .focus-q-text,
body.has-deck.is-browsing .focus-q-text,
body.has-strip.is-browsing .focus-q-text {
  font-family: 'Familjen Grotesk', 'Outfit', sans-serif !important;
  font-weight: 500 !important;
  font-style: italic !important;
  font-size: clamp(0.88rem, 2.2vw, 1.02rem) !important;
  color: var(--espresso, #542916) !important;
  text-align: center !important;
  margin: 0 !important;
  display: block !important;
  width: 100% !important;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
body.is-browsing .focus-q-text::before,
body.has-blobs.is-browsing .focus-q-text::before,
body.has-deck.is-browsing .focus-q-text::before,
body.has-strip.is-browsing .focus-q-text::before { content: "“" !important; }
body.is-browsing .focus-q-text::after,
body.has-blobs.is-browsing .focus-q-text::after,
body.has-deck.is-browsing .focus-q-text::after,
body.has-strip.is-browsing .focus-q-text::after { content: "”" !important; }

/* Detail keeps canopy + menu; query chip can hide under detail overlay */
body.has-deck-detail .focus-bar { display: none !important; }

/* ---------- FLAG FAB — quiet chip, not a red alarm disc ---------- */
.flag-fab {
  --flag-size: auto;
  position: fixed !important;
  top: calc(var(--chrome-top) + var(--chrome-btn) + 0.15rem) !important;
  right: var(--chrome-right) !important;
  bottom: auto !important;
  left: auto !important;
  z-index: 162 !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 0.35rem !important;
  width: auto !important;
  height: auto !important;
  min-height: 2rem !important;
  margin: 0 !important;
  padding: 0.35rem 0.55rem !important;
  border: none !important;
  border-radius: 0 !important;
  background: transparent !important;
  color: color-mix(in srgb, var(--espresso, #542916) 55%, transparent) !important;
  font-family: 'Outfit', 'Familjen Grotesk', sans-serif !important;
  font-weight: 650 !important;
  font-size: 0.78rem !important;
  letter-spacing: 0.02em !important;
  text-transform: lowercase !important;
  box-shadow: none !important;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: color 0.18s var(--ease, ease) !important;
}
.flag-fab span {
  display: inline !important;
  font-size: inherit !important;
  line-height: 1;
}
.flag-fab svg {
  flex: none;
  width: 0.95rem !important;
  height: 0.95rem !important;
  stroke-width: 2.1;
}
.flag-fab:hover,
.flag-fab:focus-visible {
  color: var(--terre, #a13a1e) !important;
  transform: none !important;
  filter: none !important;
  background: transparent !important;
  outline: none;
}
.flag-fab:focus-visible {
  outline: 2px solid var(--terre, #a13a1e);
  outline-offset: 3px;
}
.flag-fab[hidden] { display: none !important; }

body.has-blobs .flag-fab,
body.has-deck .flag-fab,
body.has-strip .flag-fab,
body.has-deck-detail .flag-fab,
body.has-list-blobs .flag-fab,
body.is-browsing .flag-fab {
  top: calc(var(--chrome-top) + var(--chrome-btn) + 0.1rem) !important;
  right: var(--chrome-right) !important;
}

body.menu-open .flag-fab,
body.has-crisis .flag-fab {
  opacity: 0;
  pointer-events: none;
}
body.flag-quick-open .flag-fab { pointer-events: none; }
body.flag-quick-open.no-motion .flag-fab { opacity: 0; }

/* ---------- FLAG POPUP — soft Affiche paper sheet ---------- */
.flag-quick-veil {
  position: fixed;
  inset: 0;
  z-index: 220;
  display: none;
  align-items: flex-end;
  justify-content: center;
  padding: 0.85rem;
  padding-bottom: max(0.85rem, env(safe-area-inset-bottom, 0px));
  background: color-mix(in srgb, var(--espresso, #542916) 28%, transparent);
}
.flag-quick-veil.on { display: flex; }
.flag-quick-stage {
  position: relative;
  width: min(100%, 24rem);
}
.flag-quick-box {
  position: relative;
  width: 100%;
  color: var(--espresso, #542916);
  background: var(--ground, #fdf0e8);
  border: none;
  border-radius: 1.35rem 1.35rem 1.1rem 1.1rem;
  box-shadow: 0 -8px 40px rgba(84, 41, 22, 0.12);
  padding: 0.55rem 1.35rem 1.35rem;
  transform-origin: center bottom;
}
.flag-quick-box::before {
  content: "";
  display: block;
  width: 2.4rem;
  height: 0.28rem;
  margin: 0.15rem auto 1rem;
  border-radius: 999px;
  background: color-mix(in srgb, var(--espresso, #542916) 22%, transparent);
}
.flag-quick-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.35rem;
}
.flag-quick-head h3 {
  margin: 0;
  font-family: 'Outfit', 'Familjen Grotesk', sans-serif;
  font-weight: 700;
  font-size: clamp(1.35rem, 4vw, 1.65rem);
  letter-spacing: -0.025em;
  line-height: 1.12;
  text-transform: lowercase;
  color: var(--espresso, #542916);
}
.flag-quick-close {
  flex: none;
  width: 2.35rem;
  height: 2.35rem;
  border: none;
  border-radius: 0;
  background: transparent;
  color: var(--espresso, #542916);
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
  transition: color 0.18s var(--ease, ease);
}
.flag-quick-close:hover {
  background: transparent;
  color: var(--terre, #a13a1e);
}
.flag-quick-hint {
  margin: 0 0 1.05rem;
  font-family: 'Familjen Grotesk', sans-serif;
  font-size: 0.92rem;
  line-height: 1.45;
  color: color-mix(in srgb, var(--espresso, #542916) 55%, transparent);
}
.flag-quick-box textarea {
  width: 100%;
  box-sizing: border-box;
  min-height: 7.5rem;
  resize: vertical;
  border: 1.5px solid color-mix(in srgb, var(--espresso, #542916) 18%, transparent);
  border-radius: 1rem;
  background: color-mix(in srgb, var(--surface, #fff8f2) 85%, transparent);
  color: var(--espresso, #542916);
  padding: 0.9rem 1rem;
  font-family: 'Familjen Grotesk', sans-serif;
  font-size: 1.02rem;
  line-height: 1.5;
  box-shadow: none;
}
.flag-quick-box textarea:focus {
  outline: none;
  border-color: color-mix(in srgb, var(--terre, #a13a1e) 55%, transparent);
  background: var(--surface, #fff8f2);
}
.flag-quick-box textarea::placeholder {
  color: color-mix(in srgb, var(--espresso, #542916) 35%, transparent);
}
.flag-quick-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.95rem;
}
.flag-quick-send {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.85rem;
  padding: 0.7rem 1.2rem;
  border: none;
  border-radius: 999px;
  background: var(--espresso, #542916);
  color: var(--milk, #fff8f2);
  font-family: 'Outfit', 'Familjen Grotesk', sans-serif;
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  text-transform: lowercase;
  cursor: pointer;
  transition: background 0.18s var(--ease, ease), transform 0.18s var(--ease, ease);
}
.flag-quick-send:hover {
  background: var(--terre, #a13a1e);
  border-color: transparent;
  color: var(--milk, #fff8f2);
  transform: translateY(-1px);
}
.flag-quick-status {
  margin: 0.75rem 0 0;
  font-size: 0.88rem;
  font-weight: 600;
  min-height: 1.2em;
  color: var(--terre, #a13a1e);
  text-align: center;
}

@media (min-width: 560px) {
  .flag-quick-veil {
    align-items: center;
    padding: 1.5rem;
  }
  .flag-quick-box {
    border-radius: 1.25rem;
    padding: 0.65rem 1.5rem 1.5rem;
    box-shadow: 0 18px 50px rgba(84, 41, 22, 0.14);
  }
}

@media (max-width: 560px) {
  body.is-browsing .living-home-name {
    font-size: 1.02rem !important;
  }
  .flag-fab {
    padding: 0.3rem 0.4rem !important;
    font-size: 0.74rem !important;
  }
}
