/* DagoWilds · Heraldic banners — reference button system
   Asset paths are relative to this file: .//assets/ui/heraldic/...  */
:root {
  --hb-royal-top: #2A4E8C;  --hb-royal-bottom: #1A3361;
  --hb-navy-top: #17283F;   --hb-navy-bottom: #0F1B2C;
  --hb-gold-top: #F2D38C;   --hb-gold-bottom: #D7A54B;
  --hb-gold: #E0B25A;       --hb-gold-soft: #F0D9A6;
  --hb-ink: #2A1906;        --hb-text: #F5EEDF;   --hb-muted: #A9B6C4;
  --hb-focus: #6FC3FF;
  --hb-font: 'Cinzel', serif;
  --hb-notch: 84%;          /* banner sides end at 84% of height; tip at 100% */
  --hb-tail: 10px;          /* ribbon swallowtail depth */
  --hb-weave: url(/assets/ui/heraldic/cloth-weave.png);
  --hb-weave-size: 64px 64px;
}
@media (min-resolution: 2dppx) { :root { --hb-weave: url(/assets/ui/heraldic/cloth-weave@2x.png); } }

/* ---------- Rod: the bar banners hang from ---------- */
.hb-rod { position: relative; display: flex; flex-wrap: wrap; align-items: flex-start; gap: 6px; padding: 0 16px; min-height: 66px; }
.hb-rod::before { content: ""; position: absolute; z-index: 2; left: 0; right: 0; top: 0; height: 12px; pointer-events: none;
  background: url(/assets/ui/heraldic/finial.svg) left center / 12px 12px no-repeat,
              url(/assets/ui/heraldic/finial.svg) right center / 12px 12px no-repeat,
              url(/assets/ui/heraldic/rod.svg) center / auto 6px repeat-x;
  filter: drop-shadow(0 2px 2px rgba(0,0,0,0.5)); }
.hb-rod > * { margin-top: 6px; }
/* Equal-width variant for the mobile tab bar */
.hb-rod--tabs { display: grid; grid-template-columns: repeat(var(--hb-tabs, 5), minmax(0, 1fr)); gap: 4px; padding: 0 8px; }

/* ---------- Banner: nav items, segmented options, mobile tabs ---------- */
.hb-banner { position: relative; isolation: isolate; align-self: flex-start;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 22px 8px; border: 0; background: none; cursor: pointer; box-sizing: border-box; line-height: 1.2; -webkit-appearance: none; appearance: none;
  font: 700 15px var(--hb-font); letter-spacing: 0.04em; color: var(--hb-muted); text-decoration: none;
  transition: min-height .18s ease, color .18s ease; }
.hb-banner::before { content: ""; position: absolute; inset: 0; z-index: -1;
  clip-path: polygon(0 0, 100% 0, 100% var(--hb-notch), 50% 100%, 0 var(--hb-notch));
  background: url(/assets/ui/heraldic/banner-trim-faint.svg) 0 0 / 100% 100% no-repeat,
              var(--hb-weave) 0 0 / var(--hb-weave-size) repeat,
              linear-gradient(180deg, var(--hb-navy-top), var(--hb-navy-bottom));
  transition: filter .18s ease; }
.hb-banner:hover { color: #DCE3EA; }
.hb-banner:hover::before { filter: brightness(1.18); }
.hb-banner[aria-pressed="true"], .hb-banner[aria-current="page"], .hb-banner[aria-selected="true"] {
  min-height: 60px; padding-bottom: 11px; color: var(--hb-text); text-shadow: 0 1px 2px #000; }
.hb-banner[aria-pressed="true"]::before, .hb-banner[aria-current="page"]::before, .hb-banner[aria-selected="true"]::before {
  background: url(/assets/ui/heraldic/banner-trim-gold.svg) 0 0 / 100% 100% no-repeat,
              var(--hb-weave) 0 0 / var(--hb-weave-size) repeat,
              linear-gradient(90deg, rgba(0,0,0,0.22), transparent 18%, transparent 82%, rgba(0,0,0,0.22)),
              linear-gradient(180deg, var(--hb-royal-top), var(--hb-royal-bottom)); }
.hb-banner:active::before { filter: brightness(0.9); }
.hb-banner:focus-visible { outline: 2px solid var(--hb-focus); outline-offset: 3px; border-radius: 4px; }
/* Ghost banner: inactive nav item without cloth (plain text under the rod) */
.hb-banner--ghost:not([aria-current="page"]):not([aria-pressed="true"]):not([aria-selected="true"])::before { background: none; }
/* Tassel under the active main-nav banner */
.hb-banner--nav[aria-current="page"]::after { content: ""; position: absolute; left: 50%; bottom: -16px; width: 12px; height: 20px;
  transform: translateX(-50%); background: url(/assets/ui/heraldic/tassel.svg) center / contain no-repeat; pointer-events: none; }
/* Mobile tab variant: icon above label */
.hb-banner--tab { flex-direction: column; gap: 3px; min-height: 52px; width: 100%; padding: 4px 0 8px; font: 700 11px 'Source Sans 3', sans-serif; letter-spacing: 0.01em; }
.hb-banner--tab[aria-current="page"] { min-height: 66px; padding-bottom: 12px; }

/* ---------- Ribbon: filter chips and action buttons ---------- */
.hb-ribbon { position: relative; isolation: isolate;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 38px; padding: 0 24px; border: 0; background: none; cursor: pointer; box-sizing: border-box; line-height: 1.2; -webkit-appearance: none; appearance: none;
  font: 700 13px var(--hb-font); letter-spacing: 0.04em; color: #D3DBE4; text-decoration: none; white-space: nowrap;
  transition: transform .12s ease; }
.hb-ribbon::before { content: ""; position: absolute; inset: 0; z-index: -1;
  clip-path: polygon(0 0, 100% 0, calc(100% - var(--hb-tail)) 50%, 100% 100%, 0 100%, var(--hb-tail) 50%);
  background:
    repeating-linear-gradient(90deg, rgba(224,178,90,0.55) 0 5px, transparent 5px 9px) 0 4px / 100% 1px no-repeat,
    repeating-linear-gradient(90deg, rgba(224,178,90,0.55) 0 5px, transparent 5px 9px) 0 calc(100% - 4px) / 100% 1px no-repeat,
    var(--hb-weave) 0 0 / var(--hb-weave-size) repeat,
    linear-gradient(180deg, var(--hb-navy-top), var(--hb-navy-bottom));
  transition: filter .18s ease; }
.hb-ribbon:hover::before { filter: brightness(1.18); }
.hb-ribbon:active { transform: translateY(1px); }
.hb-ribbon:active::before { filter: brightness(0.9); }
.hb-ribbon:focus-visible { outline: 2px solid var(--hb-focus); outline-offset: 3px; border-radius: 3px; }
.hb-ribbon[aria-pressed="true"], .hb-ribbon[aria-checked="true"], .hb-ribbon--primary { color: var(--hb-ink); text-shadow: 0 1px 0 rgba(255,255,255,0.3); }
.hb-ribbon[aria-pressed="true"]::before, .hb-ribbon[aria-checked="true"]::before, .hb-ribbon--primary::before {
  background:
    repeating-linear-gradient(90deg, rgba(90,58,16,0.7) 0 5px, transparent 5px 9px) 0 4px / 100% 1px no-repeat,
    repeating-linear-gradient(90deg, rgba(90,58,16,0.7) 0 5px, transparent 5px 9px) 0 calc(100% - 4px) / 100% 1px no-repeat,
    var(--hb-weave) 0 0 / var(--hb-weave-size) repeat,
    linear-gradient(180deg, var(--hb-gold-top), var(--hb-gold-bottom)); }
.hb-ribbon--primary, .hb-ribbon--secondary { min-height: 50px; padding: 0 38px; font-size: 16px; --hb-tail: 13px; }
.hb-ribbon:disabled, .hb-ribbon[aria-disabled="true"] { opacity: 0.45; cursor: not-allowed; transform: none; }
.hb-ribbon:disabled::before { filter: grayscale(0.5); }

/* ---------- Seal: icon-only buttons ---------- */
.hb-seal { width: 44px; height: 44px; display: inline-flex; align-items: center; justify-content: center;
  border: 0; border-radius: 50%; cursor: pointer; color: var(--hb-gold-soft);
  background: url(/assets/ui/heraldic/seal.svg) center / 100% 100% no-repeat; filter: drop-shadow(0 2px 2px rgba(0,0,0,0.5));
  transition: filter .18s ease, transform .12s ease; }
.hb-seal:hover { filter: drop-shadow(0 2px 2px rgba(0,0,0,0.5)) brightness(1.15); }
.hb-seal:active { transform: translateY(1px); }
.hb-seal:focus-visible { outline: 2px solid var(--hb-focus); outline-offset: 3px; }

/* ---------- Text link ---------- */
.hb-link { font: 700 14px var(--hb-font); letter-spacing: 0.06em; color: #E8BE6A;
  text-decoration: underline dotted rgba(224,178,90,0.6); text-underline-offset: 5px; }
.hb-link:hover { color: #F6D592; }
.hb-link:focus-visible { outline: 2px solid var(--hb-focus); outline-offset: 3px; border-radius: 2px; }

/* ---------- Touch: keep every target at least 44px tall ---------- */
@media (pointer: coarse) { .hb-ribbon { min-height: 44px; } .hb-banner { min-height: 50px; } }

/* ---------- Segmented trays never wrap; they scroll sideways instead ---------- */
.hb-rod--segmented { flex-wrap: nowrap; overflow-x: auto; overflow-y: hidden; min-height: 74px; scrollbar-width: none; }

@media (prefers-reduced-motion: reduce) { .hb-banner, .hb-banner::before, .hb-ribbon, .hb-ribbon::before, .hb-seal { transition: none; } }


/* DagoWilds adapter: the existing theme owns colour and typography. */
:root {
  --hb-royal-top: color-mix(in srgb, var(--dw-border) 48%, #315b9a);
  --hb-royal-bottom: color-mix(in srgb, var(--dw-bg) 56%, #1a3361);
  --hb-navy-top: var(--dw-surface);
  --hb-navy-bottom: var(--dw-surface-sunken);
  --hb-gold-top: color-mix(in srgb, var(--dw-gold) 52%, white);
  --hb-gold-bottom: color-mix(in srgb, var(--dw-gold) 92%, #8a5c1b);
  --hb-gold: var(--dw-gold);
  --hb-gold-soft: var(--dw-gold-text);
  --hb-text: var(--dw-text);
  --hb-muted: var(--dw-text-muted);
  --hb-font: var(--font-display);
}
.hb-banner, .hb-ribbon, .hb-seal, .hb-link { text-rendering: optimizeLegibility; }
.hb-banner:disabled, .hb-banner[aria-disabled="true"], .hb-seal:disabled, .hb-seal[aria-disabled="true"] { opacity: .45; cursor: not-allowed; }
.hb-filter-row { display: flex; flex-wrap: wrap; gap: 8px; }
.hb-rod--segmented { width: max-content; max-width: 100%; }
.hb-rod--segmented > .hb-banner { flex: none; min-width: 100px; }
.hb-ribbon--secondary { color: var(--dw-text); }
.hb-link { color: var(--dw-gold-text); }
.hb-banner:focus-visible, .hb-ribbon:focus-visible, .hb-seal:focus-visible, .hb-link:focus-visible { outline-color: var(--hb-focus); }

/* Header and navigation: preserve the hanging banner below the wooden rod. */
.app-header { min-height: 86px; }
.route-menu.hb-rod { display: flex; flex-wrap: nowrap; align-items: flex-start; gap: 0; min-height: 74px; padding: 0 16px; overflow: visible; }
.route-menu.hb-rod a.hb-banner { display: inline-flex; flex: 1 1 auto; min-width: 0; min-height: 48px; margin-top: 6px; padding: 0 11px 8px; border: 0; border-radius: 0; background: none; box-shadow: none; color: var(--hb-muted); font: 700 13px/1.2 var(--hb-font); font-variant: small-caps; text-shadow: none; }
.route-menu.hb-rod a.hb-banner::before { display: block; }
.route-menu.hb-rod a.hb-banner[aria-current="page"] { min-height: 60px; padding-bottom: 11px; color: var(--hb-text); text-shadow: 0 1px 2px #000; }
.route-menu.hb-rod a.hb-banner[aria-current="page"]::after { display: block; }
.route-menu.hb-rod a.hb-banner:hover { color: var(--dw-text); }
.management-link.hb-seal { display: inline-flex; border: 0; border-radius: 50%; background: url(/assets/ui/heraldic/seal.svg) center / contain no-repeat; color: var(--hb-gold-soft); }
.management-link.hb-seal:hover { color: var(--hb-text); border: 0; }

/* Shared segmented rows and filter ribbons supersede old per-screen buttons. */
.hb-rod--segmented:is(.inventory-modes,.profile-tabs,.hiscores-subviews,.progression-periods,.quest-tabs) { display: flex; flex-wrap: nowrap; gap: 6px; min-height: 74px; padding: 0 16px; overflow-x: auto; overflow-y: hidden; border: 0; border-radius: 0; background: none; box-shadow: none; scrollbar-width: none; }
.hb-rod--segmented > button.hb-banner, .hb-rod--segmented > a.hb-banner { min-height: 48px; padding: 0 20px 8px; border: 0; border-radius: 0; background: none; box-shadow: none; color: var(--hb-muted); font: 700 14px/1.2 var(--hb-font); text-shadow: none; transform: none; }
.hb-rod--segmented > button.hb-banner:is([aria-pressed="true"],[aria-selected="true"]), .hb-rod--segmented > a.hb-banner[aria-current="page"] { min-height: 60px; padding-bottom: 11px; color: var(--hb-text); background: none; box-shadow: none; text-shadow: 0 1px 2px #000; }
.hb-rod--segmented > button.hb-banner::after { content: none; }
.hb-filter-row > button.hb-ribbon, .activity-filters > button.hb-ribbon { min-height: 40px; padding: 0 22px; border: 0; border-radius: 0; background: none; box-shadow: none; color: #e5eaf0; font: 700 13px/1.2 var(--hb-font); }
.hb-filter-row > button.hb-ribbon[aria-pressed="true"], .activity-filters > button.hb-ribbon[aria-pressed="true"] { color: var(--hb-ink); background: none; border: 0; }
.hb-filter-row > button.hb-ribbon:focus-visible, .hb-rod--segmented > button.hb-banner:focus-visible { outline: 2px solid var(--hb-focus); outline-offset: 3px; }
.inventory-toolbar .inventory-modes { align-self: start; }
.inventory-categories.hb-filter-row { overflow-x: auto; flex-wrap: nowrap; }
.activity-filters.hb-filter-row { flex-wrap: nowrap; overflow-x: auto; }
.activity-pagination > button.hb-ribbon { min-height: 44px; }
.redesign-quest > a.hb-ribbon { margin-top: 14px; }

/* Map controls remain icon-only. */
.world-fullscreen.hb-seal, .world-map-action.hb-seal { width: 46px; height: 46px; padding: 0; border: 0; border-radius: 50%; background: url(/assets/ui/heraldic/seal.svg) center / contain no-repeat; color: var(--hb-gold-soft); box-shadow: none; }
.world-fullscreen.hb-seal:hover, .world-map-action.hb-seal:not(:disabled):hover { border: 0; background: url(/assets/ui/heraldic/seal.svg) center / contain no-repeat; color: var(--hb-text); }

/* Earlier navigation switch prevents a cramped desktop rod. */
@media (width < 1024px) {
  .app-menu, .management-link.hb-seal { display: none; }
  .app-header { width: 100%; min-height: 56px; margin-left: 0; }
  .mobile-nav.hb-rod { position: fixed; z-index: 4000; inset: auto 0 0; display: grid; grid-template-columns: repeat(5,minmax(0,1fr)); align-items: start; gap: 4px; min-height: 78px; height: calc(78px + env(safe-area-inset-bottom)); padding: 0 8px env(safe-area-inset-bottom); background: var(--dw-bg-header); border-top: 1px solid var(--dw-border); }
  .mobile-nav.hb-rod > a.hb-banner, .mobile-nav.hb-rod > .mobile-more { margin-top: 6px; }
  .mobile-nav.hb-rod > a.hb-banner, .mobile-more > summary.hb-banner { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-width: 0; width: 100%; min-height: 52px; padding: 3px 1px 8px; border: 0; border-radius: 0; background: none; color: var(--hb-muted); font: 700 var(--fs-caption)/1.1 var(--font-body); }
  .mobile-nav.hb-rod a.hb-banner[aria-current="page"], .mobile-more.is-current > summary.hb-banner { min-height: 66px; padding-bottom: 12px; color: var(--hb-text); }
  .mobile-more.is-current > summary.hb-banner::before { background: url(/assets/ui/heraldic/banner-trim-gold.svg) 0 0 / 100% 100% no-repeat, var(--hb-weave) 0 0 / var(--hb-weave-size) repeat, linear-gradient(180deg,var(--hb-royal-top),var(--hb-royal-bottom)); }
  .mobile-more__menu a.hb-ribbon { margin: 3px 0; color: var(--dw-text); }
  .page-content { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }
}
@media (min-width: 1024px) { .mobile-nav.hb-rod { display: none; } }
@media (pointer: coarse) { .hb-filter-row > button.hb-ribbon, .activity-filters > button.hb-ribbon { min-height: 44px; } }
@media (prefers-reduced-motion: reduce) { .hb-rod, .hb-banner, .hb-ribbon, .hb-seal { scroll-behavior: auto; animation: none; transition: none; } }


/* Authenticated Management uses the same ribbon primitive. Destructive actions keep red cloth. */
.admin-management .hb-ribbon { min-height: 44px; padding: 0 24px; border: 0 !important; border-radius: 0; background: none !important; box-shadow: none; }
.admin-management .admin-secondary.hb-ribbon { color: var(--dw-text) !important; }
.admin-management .admin-primary.hb-ribbon { color: var(--hb-ink) !important; }
.admin-management .admin-danger.hb-ribbon { color: var(--dw-text) !important; }
.hb-ribbon--danger::before { background: repeating-linear-gradient(90deg,rgba(255,195,177,.62) 0 5px,transparent 5px 9px) 0 4px / 100% 1px no-repeat, repeating-linear-gradient(90deg,rgba(255,195,177,.62) 0 5px,transparent 5px 9px) 0 calc(100% - 4px) / 100% 1px no-repeat, var(--hb-weave) 0 0 / var(--hb-weave-size) repeat, linear-gradient(180deg,#73352e,#3c171d); }
.admin-management .hb-ribbon:focus-visible { outline: 2px solid var(--hb-focus); outline-offset: 3px; }
.redesign-quest > a.hb-ribbon--primary { color: var(--hb-ink); }
