/* ============================================================================
 * HUD v3 — forged bronze & obsidian
 *
 * A deliberate break from Rivenhold's flat navy pills. Every frame here is chamfered, riveted and layered:
 * cut corners instead of uniform radii, a bronze outer edge, a gold hairline inside it, a brushed-metal
 * sheen and four corner rivets. Panels are asymmetric on purpose — the vitals plate carries a level tab,
 * the map carries a title bar, the drawer carries a handle — the way a crafted MOM interface looks.
 *
 * Layout: vitals + resource belt top-left, quest tracker under them, map / party / feed in a right column,
 * menu rail on the far edge, chat in a corner drawer, consumables + action bar centred on the floor,
 * EXP hairline across the very bottom.
 *
 * Loaded after theme.css. Delete the two <link>/<script> tags to return to the shipped HUD.
 * ========================================================================== */

#hud.hudv2 {
  --edge: 10px;
  --rail: 300px;
  --belt: 320px;
  --side: 200px;
  --dock: 58px;
  --bronze: #7a5928;
  --bronze-dk: #3a2912;
  --gold: #f2c75c;
  --gold-lt: #ffe6a2;
  --obsidian: linear-gradient(155deg, #202a3c 0%, #141c2b 48%, #0d1320 100%);
  --sheen: repeating-linear-gradient(115deg, rgba(255,255,255,.018) 0 2px, transparent 2px 5px);
  --frame: 1px solid var(--bronze);
  --inner: inset 0 0 0 1px rgba(242,199,92,.24), inset 0 1px 0 rgba(255,255,255,.12);
  --drop: 0 10px 26px rgba(0,0,0,.62);
}

/* shared riveted, chamfered frame */
#hud.hudv2 .card,
#hud.hudv2 .hotbar-wrap,
#hud.hudv2 #hotbar2Wrap,
#hud.hudv2 .chips,
#hud.hudv2 #targetCard {
  background-image:
    radial-gradient(circle at 8px 8px, var(--gold) 0 1.4px, transparent 2px),
    radial-gradient(circle at calc(100% - 8px) 8px, var(--gold) 0 1.4px, transparent 2px),
    radial-gradient(circle at 8px calc(100% - 8px), var(--gold) 0 1.4px, transparent 2px),
    radial-gradient(circle at calc(100% - 8px) calc(100% - 8px), var(--gold) 0 1.4px, transparent 2px),
    var(--sheen), var(--obsidian);
  border: var(--frame);
  box-shadow: var(--inner), var(--drop);
  clip-path: polygon(11px 0, calc(100% - 11px) 0, 100% 11px, 100% calc(100% - 11px), calc(100% - 11px) 100%, 11px 100%, 0 calc(100% - 11px), 0 11px);
}

/* section headers: engraved bronze bars */
#hud.hudv2 .card .qhead,
#hud.hudv2 .card .mhead,
#hud.hudv2 .card .feed-head,
#hud.hudv2 .card.chat > div:first-child {
  background: linear-gradient(180deg, #4b3619, #2b1e0e);
  border-bottom: 2px solid var(--bronze-dk);
  box-shadow: inset 0 1px 0 rgba(255,232,170,.22);
}
#hud.hudv2 .card .qhead b,
#hud.hudv2 .card .mhead b,
#hud.hudv2 .card .feed-head b {
  color: var(--gold-lt);
  text-shadow: 0 1px 0 #000, 0 0 8px rgba(242,199,92,.25);
  letter-spacing: .6px;
  font-size: 11px;
}

/* ── vitals ─────────────────────────────────────────────────────────────── */
#hud.hudv2 .card.me {
  left: var(--edge);
  top: 8px;
  width: var(--belt);
  height: 104px;
  padding: 8px 10px 8px 8px;
  gap: 9px;
}
#hud.hudv2 .card.me #portrait {
  width: 66px; height: 66px;
  border: 2px solid var(--bronze);
  box-shadow: 0 0 0 1px #120c05, 0 3px 10px rgba(0,0,0,.6);
  clip-path: polygon(10px 0, calc(100% - 10px) 0, 100% 10px, 100% calc(100% - 10px), calc(100% - 10px) 100%, 10px 100%, 0 calc(100% - 10px), 0 10px);
}
#hud.hudv2 .card.me .me-body { gap: 3px; }
#hud.hudv2 .card.me .me-top b { font-size: 16px; letter-spacing: .5px; text-shadow: 0 1px 2px #000; }
#hud.hudv2 .card.me .job {
  background: linear-gradient(180deg, #7a5928, #3b2810);
  border: 1px solid var(--gold);
  color: var(--gold-lt);
  border-radius: 2px;
  padding: 1px 7px;
  font-size: 10px;
}
#hud.hudv2 .card.me .bar {
  height: 12px;
  border: 1px solid #0a0e16;
  box-shadow: inset 0 1px 3px rgba(0,0,0,.75), 0 1px 0 rgba(255,255,255,.06);
}
#hud.hudv2 .card.me .lvrow { font-size: 11px; gap: 7px; }
#hud.hudv2 .card.me .lvrow .bar { height: 8px; }

/* ── resource belt ──────────────────────────────────────────────────────── */
#hud.hudv2 .chips {
  left: var(--edge);
  top: 116px;
  width: var(--belt);
  height: auto;
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  padding: 5px;
}
#hud.hudv2 .chips .chip {
  padding: 2px 7px;
  font-size: 10px;
  border: 1px solid rgba(242,199,92,.32);
  background: linear-gradient(180deg, #2a344b, #151d2e);
  clip-path: polygon(5px 0, 100% 0, 100% calc(100% - 5px), calc(100% - 5px) 100%, 0 100%, 0 5px);
}
#hud.hudv2 .chips .chip b { font-size: 10px; }
#hud.hudv2 .chips .chip.cd-chip { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#hud.hudv2 .chips .chip.alert { border-color: var(--gold); box-shadow: 0 0 8px rgba(242,199,92,.25); }

/* ── quest tracker on the left ──────────────────────────────────────────── */
#hud.hudv2 #ovRail {
  display: block !important;
  left: var(--edge);
  top: 196px;
  width: var(--rail);
  max-height: calc(100% - 196px - 230px);
  overflow: auto;
  scrollbar-width: thin;
}
#hud.hudv2 #ovRail .card { position: relative; left: auto; top: auto; width: 100%; }

/* ── minimap: the zone name must not be squeezed by the controls ─────────── */
#hud.hudv2 .card.minimap .mhead {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 3px;
}
#hud.hudv2 .card.minimap #zoneName {
  flex: 1 1 64px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 11px;
}
#hud.hudv2 .card.minimap .np-sig {
  flex: 0 0 auto;
  font-size: 9px;
  padding: 1px 4px;
}
#hud.hudv2 .card.minimap .mini-btn {
  flex: 0 0 auto;
  font-size: 9px;
  padding: 1px 5px;
}
#hud.hudv2 .card.minimap .fold-btn { display: none; }
#hud.hudv2 .card.minimap .mm-online {
  position: absolute;
  left: auto;
  right: 6px;
  bottom: 6px;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 2px 7px;
  background: linear-gradient(180deg, rgba(75,54,25,.96), rgba(43,30,14,.96));
  border: 1px solid var(--gold, #f2c75c);
  border-radius: 3px;
  box-shadow: 0 2px 8px rgba(0,0,0,.5);
  color: var(--gold-lt, #ffe6a2);
  font-size: 9.5px;
  font-weight: 700;
  white-space: nowrap;
  pointer-events: none;
  z-index: 4;
}
#hud.hudv2 .card.minimap .mm-online i {
  width: 6px; height: 6px; border-radius: 50%;
  background: #6fd07a; box-shadow: 0 0 6px #6fd07a;
}
#hud.hudv2 .card.minimap .mm-online b { color: #fff; font-size: 10px; }

/* ── right column: map, party, feed ─────────────────────────────────────── */
#hud.hudv2 .card.minimap {
  left: auto;
  right: calc(var(--edge) + var(--dock) + 4px);
  top: 8px;
  width: var(--side);
  height: var(--side);
  padding: 5px;
}
#hud.hudv2 .card.minimap .mini-wrap { height: calc(100% - 34px); }
#hud.hudv2 .card.minimap canvas { width: 100% !important; height: 100% !important; }

/* the party panel lives inside the rail's tabbed pane — keep it there and let that pane size the rail.
   relative (not static) so the frame-hide button anchors to the panel, not to the rail's tab strip. */
#hud.hudv2 #partyPanel {
  position: relative !important;
  width: 100% !important;
  max-height: none;
  overflow: visible;
}
#hud.hudv2 #partyPanel .pp-x {
  top: auto !important;
  right: auto !important;
  bottom: -7px !important;
  left: -7px !important;
  z-index: 3;
}

#hud.hudv2 .card.feed,
#hud.hudv2 .card.feed.hm-moved {
  left: auto !important;
  right: calc(var(--edge) + var(--dock) + 4px) !important;
  top: calc(var(--side) + 216px);
  width: var(--side);
  height: 176px;
}
#hud.hudv2 .card.feed #feedList { font-size: 10.5px; }

/* ── menu rail ──────────────────────────────────────────────────────────── */
#hud.hudv2 #trDock {
  left: auto !important;
  right: 6px;
  top: 8px;
  bottom: 124px;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  max-height: none;
  overflow: auto;
  scrollbar-width: none;
}
#hud.hudv2 #trDock::-webkit-scrollbar { display: none; }

/* ── chat drawer ────────────────────────────────────────────────────────── */
#hud.hudv2 .card.chat {
  left: var(--edge);
  bottom: 150px;
  top: auto;
  width: 400px;
  height: 180px;
  transition: height .18s ease;
}
#hud.hudv2 .card.chat.collapsed { height: 34px; }
#hud.hudv2 .card.chat.collapsed .chat-log,
#hud.hudv2 .card.chat.collapsed .chat-row { display: none; }
#hud.hudv2 .chat-toggle {
  position: absolute; top: 6px; right: 8px; width: 24px; height: 20px; line-height: 1;
  display: grid; place-items: center; padding: 0; cursor: pointer;
  background: linear-gradient(180deg, #5b431f, #2c1e0c);
  border: 1px solid var(--gold);
  color: var(--gold-lt);
  font-size: 13px; font-weight: 900;
  clip-path: polygon(4px 0, 100% 0, 100% 100%, 0 100%, 0 4px);
}
#hud.hudv2 .chat-toggle:hover { color: #fff; box-shadow: 0 0 8px rgba(242,199,92,.4); }

/* ── action bars ────────────────────────────────────────────────────────── */
#hud.hudv2 #hotbar2Wrap {
  left: 50% !important; right: auto !important; top: auto !important; bottom: 112px !important;
  transform: translateX(-50%) !important; width: auto !important;
}
#hud.hudv2 .hotbar-wrap {
  left: 50% !important; right: auto !important; top: auto !important; bottom: 22px !important;
  transform: translateX(-50%) !important;
  width: auto;
  display: flex; align-items: center; gap: 8px;
  padding: 6px 12px;
}
#hud.hudv2 .hb-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  min-width: 58px;
  height: 63px;
  padding: 4px 6px;
  font-size: 11px;
  line-height: 1.05;
  background: linear-gradient(180deg, #33405a, #151d2e);
  border: 1px solid var(--bronze);
  clip-path: polygon(5px 0, 100% 0, 100% calc(100% - 5px), calc(100% - 5px) 100%, 0 100%, 0 5px);
}
#hud.hudv2 .hb-btn.on { border-color: var(--gold); color: var(--gold-lt); }
/* every control on the action bar shares one 63px spine */
#hud.hudv2 .autobox,
#hud.hudv2 .auto-btn.pot,
#hud.hudv2 .ult-btn,
#hud.hudv2 .ov-bar-toggle {
  height: 63px !important;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
#hud.hudv2 .autobox { min-width: 78px; }
#hud.hudv2 .auto-btn.pot { min-width: 58px; }
#hud.hudv2 .ult-btn { min-width: 58px; }
#hud.hudv2 .ov-bar-toggle { width: 26px !important; }

/* ── target + utilities ─────────────────────────────────────────────────── */
#hud.hudv2 #targetCard { left: 50%; top: 82px; transform: translateX(-50%); width: 320px; }
#hud.hudv2 #zoomCtl { left: auto; right: calc(var(--edge) + var(--dock) + 4px); top: calc(var(--side) + 400px); }
#hud.hudv2 #buffs { left: auto; right: calc(var(--edge) + var(--dock) + 4px); top: 214px; }

/* ── EXP hairline ───────────────────────────────────────────────────────── */
#hud.hudv2 #xpStrip {
  position: absolute; left: 0; right: 0; bottom: 0; height: 6px;
  background: #0a0f1a; box-shadow: inset 0 1px 0 rgba(255,255,255,.07);
  pointer-events: none; z-index: 30;
}
#hud.hudv2 #xpStrip i {
  display: block; height: 100%; width: 0;
  background: linear-gradient(90deg, var(--gold), var(--gold-lt) 65%, #fff8dc);
  box-shadow: 0 0 9px rgba(242,199,92,.65);
  transition: width .4s ease;
}

/* ── windows: fit the screen instead of covering it ──────────────────────── */
#hud.hudv2 .win {
  max-width: min(92%, 760px) !important;
  max-height: 62% !important;
  box-shadow: 0 22px 56px rgba(0,0,0,.66), inset 0 0 0 1px rgba(255,255,255,.5);
}
#hud.hudv2 .win > .win-body {
  max-height: calc(100% - 42px) !important;
  overflow-y: auto !important;
}
/* an obvious grab area — dragging only ever worked from the title bar, but nothing said so */
#hud.hudv2 .win > .win-head {
  min-height: 32px;
  cursor: move;
  user-select: none;
  color: #eef3ff;
  background:
    repeating-linear-gradient(90deg, rgba(255,230,162,.18) 0 2px, transparent 2px 6px) 10px 50% / 54px 4px no-repeat,
    linear-gradient(180deg, #24304f, #16203a);
  border-bottom: 2px solid #d99b1e;
}
#hud.hudv2 .win > .win-head .wt { padding-left: 22px; }

/* ── scrollbars: the browser's white bar looks broken on every dark plate ── */
#hud.hudv2 * { scrollbar-width: thin; scrollbar-color: #8b6a2f rgba(8,13,24,.55); }
#hud.hudv2 ::-webkit-scrollbar { width: 8px; height: 8px; }
#hud.hudv2 ::-webkit-scrollbar-track { background: rgba(8,13,24,.6); }
#hud.hudv2 ::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, #b58b3c, #6c4d1e);
  border: 1px solid #2b1e0c;
  border-radius: 6px;
}
#hud.hudv2 ::-webkit-scrollbar-thumb:hover { background: linear-gradient(180deg, #e0b45a, #8a6426); }
#hud.hudv2 ::-webkit-scrollbar-corner { background: #0a0f1a; }

/* ── feed: show the whole line, scroll cleanly when it overflows ─────────── */
#hud.hudv2 .card.feed,
#hud.hudv2 .card.feed.hm-moved { height: 232px; }
#hud.hudv2 .card.feed #feedList,
#hud.hudv2 .card.feed .feed-list {
  max-height: calc(100% - 30px);
  overflow-y: auto;
  overflow-x: hidden;
}
#hud.hudv2 .card.feed .feed-row { white-space: normal; line-height: 1.25; }

/* ── resource belt: never blank out a chip ──────────────────────────────── */
#hud.hudv2 .chips .chip { color: var(--gold-lt); }
#hud.hudv2 .chips .chip b,
#hud.hudv2 .chips .chip i { color: inherit; }
#hud.hudv2 .chips .chip.cd-chip { overflow: hidden; text-overflow: ellipsis; }

/* ── chat ───────────────────────────────────────────────────────────────── */
#hud.hudv2 .card.chat .chat-log { overflow-y: auto; overflow-x: hidden; }
#hud.hudv2 .card.chat {
  display: flex;
  flex-direction: column;
}
#hud.hudv2 .card.chat .chat-tabs {
  flex: none;
  gap: 2px;
  padding-right: 34px;
  overflow: hidden;
}
/* the online counter lives in the minimap now — no duplicate label in chat */
#hud.hudv2 .chat-tabs .rp-online { display: none; }
#hud.hudv2 .card.chat .chat-tabs button {
  padding: 2px 7px;
  font-size: 10.5px;
  white-space: nowrap;
}
#hud.hudv2 .card.chat .chat-log { flex: 1 1 auto; min-height: 0; }
#hud.hudv2 .card.chat .chat-row { flex: none; min-height: 30px; }

/* ── headers: the title must never sit under a control ──────────────────── */
#hud.hudv2 .win > .win-head,
#hud.hudv2 .card.feed .feed-head,
#hud.hudv2 .card .mhead,
#hud.hudv2 .card .qhead {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 32px;
}
#hud.hudv2 .win > .win-head .wt,
#hud.hudv2 .card.feed .feed-head > b,
#hud.hudv2 .card .mhead > b,
#hud.hudv2 .card .qhead > b {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#hud.hudv2 .win > .win-head button,
#hud.hudv2 .card.feed .feed-head button,
#hud.hudv2 .card.feed .feed-head .hm-grip {
  flex: 0 0 auto;
}
@media (max-width: 1300px) {
  #hud.hudv2 { --rail: 272px; --belt: 290px; --side: 178px; }
  #hud.hudv2 .card.chat { width: 320px; }
}
@media (max-width: 1080px) {
  #hud.hudv2 .win { max-height: 58% !important; max-width: 90% !important; }
  #hud.hudv2 { --rail: 244px; --belt: 260px; --side: 156px; }
  #hud.hudv2 .card.me { height: 96px; }
  #hud.hudv2 .card.me #portrait { width: 56px; height: 56px; }
  #hud.hudv2 .chips { top: 110px; }
  #hud.hudv2 #ovRail { top: 190px; max-height: calc(100% - 190px - 200px); }
  #hud.hudv2 .card.chat { width: 292px; height: 156px; }
  #hud.hudv2 .card.feed { height: 150px; top: calc(var(--side) + 200px); }
  #hud.hudv2 #partyPanel { max-height: 160px; top: calc(var(--side) + 16px); }
}
@media (max-width: 880px) {
  #hud.hudv2 .win { max-height: 72% !important; max-width: 94% !important; }
  #hud.hudv2 .win > .win-body { max-height: calc(100% - 40px) !important; }
  #hud.hudv2 .card.feed, #hud.hudv2 #ovRail { display: none; }
  #hud.hudv2 .card.chat { width: calc(100% - 2 * var(--edge)); height: 146px; }
  #hud.hudv2 #trDock {
    flex-direction: row; right: var(--edge); left: var(--edge);
    bottom: 206px; max-height: none; overflow-x: auto; gap: 4px;
  }
  #hud.hudv2 #hotbar2Wrap { bottom: 124px; }
  #hud.hudv2 .hotbar-wrap { bottom: 58px; }
  #hud.hudv2 #zoomCtl { display: none; }
}
@media (max-width: 640px) {
  #hud.hudv2 .win { max-height: 80% !important; max-width: 96% !important; }
  #hud.hudv2 .card.me { width: calc(100% - 2 * var(--edge)); height: 80px; }
  #hud.hudv2 .chips { top: 92px; width: calc(100% - 2 * var(--edge)); }
  #hud.hudv2 .card.minimap { width: 126px; height: 126px; }
  #hud.hudv2 #partyPanel { top: 142px; width: 126px !important; max-height: 140px; }
  #hud.hudv2 .card.chat { height: 128px; }
  #hud.hudv2 #trDock { bottom: 188px; }
  #hud.hudv2 #hotbar2Wrap { bottom: 110px; }
  #hud.hudv2 .hotbar-wrap { bottom: 50px; transform: translateX(-50%) scale(.9) !important; }
}
