/* Header navigation: five main tabs, Rangliste as an icon, and a sub-tab row for grouped screens
   (Krämer + Zentralmarkt + Truhen, Aufträge + Events). Loaded last so it settles the older header rules. */

/* Every screen pads itself by --hud-height, so the sub-tab row only adds height where it is shown. */
:root { --hud-row: 76px; }
body { --subnav-row: 0px; --hud-height: calc(var(--hud-row) + var(--subnav-row)); }
body:is([data-scene="markt"], [data-scene="truhen"], [data-scene="auftraege"], [data-scene="events"]) { --subnav-row: 46px; }

/* Side columns grow with their content (long player names) and keep the tabs centred when there is room. */
.hud { grid-template-columns: minmax(max-content, 1fr) auto minmax(max-content, 1fr); align-content: start; row-gap: 8px; }
.hud > :is(.wordmark, .scene-nav, .hud-tools) { grid-row: 1; min-height: calc(var(--hud-row) - 20px); }
.hud .scene-nav { grid-column: 2; }
.hud-tools { grid-column: 3; }

.nav-count {
  min-width: 17px; padding: 1px 5px; border-radius: 9px; background: #ffd47e; color: #33213f;
  font-size: 10px; line-height: 14px; font-variant-numeric: tabular-nums; text-align: center;
}
.nav-count[hidden] { display: none; }

.scene-subnav {
  grid-column: 1 / -1; grid-row: 2; justify-self: center; display: flex; gap: 4px; padding: 3px;
  border: 1px solid #80637d; border-radius: 9px; background: #211829f0;
}
.scene-subnav[hidden] { display: none; }
.scene-subnav button {
  display: flex; align-items: center; gap: 6px; min-height: 30px; padding: 3px 16px;
  border: 0; border-radius: 6px; background: transparent; color: #e8d6ee; font-size: 13px; font-weight: 800; white-space: nowrap;
}
.scene-subnav button[aria-pressed="true"] { background: #f0d4a0; color: #241c2d; }
.scene-subnav button[aria-pressed="true"] .nav-count { background: #3a2748; color: #ffe6ac; }
.scene-subnav button:focus-visible, .scene-nav button:focus-visible { outline: 3px solid #ead0ff; outline-offset: 2px; }
@media (hover: hover) and (pointer: fine) {
  .scene-subnav button:not([aria-pressed="true"]):hover { background: #3a2a48; color: #ffe1a0; }
}

.hud-tools [data-scene="rangliste"][aria-pressed="true"] { border-color: #ffd180; background: #4a3550; }

/* Laptops: drop the tab icons before the labels have to squeeze. */
@media (max-width: 1080px) {
  .scene-nav .pixel { display: none; }
  .scene-nav button { padding-inline: 7px; font-size: 13px; }
}
@media (max-width: 900px) {
  .hud .wordmark h1 { font-size: 18px; }
}

/* Phones and small tablets: tabs move to a bottom bar, the header keeps logo, tools and sub-tabs. */
@media (max-width: 820px) {
  :root { --hud-row: 64px; }
  body { padding-bottom: calc(62px + env(safe-area-inset-bottom)); }
  .hud { grid-template-columns: minmax(0, 1fr) auto; }
  .hud-tools { grid-column: 2; }
  .hud .scene-nav {
    position: fixed; z-index: 12; inset: auto 0 0; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 2px; min-height: 0; max-width: none; padding: 5px 6px calc(5px + env(safe-area-inset-bottom));
    border-top: 1px solid #5d4370; background: #181120f7; overflow: visible;
  }
  .scene-nav button {
    position: relative; flex-direction: column; justify-content: center; gap: 3px; min-width: 0; min-height: 50px;
    padding: 4px 2px; border: 0; border-radius: 10px; font-size: 11px;
  }
  .scene-nav button > span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
  .scene-nav .pixel { display: block; width: 20px; height: 20px; }
  .scene-nav button[aria-pressed="true"] { background: #2e1f3f; }
  .scene-nav .nav-count { position: absolute; top: 3px; left: calc(50% + 7px); }
  .toast { bottom: calc(76px + env(safe-area-inset-bottom)); }
  .loot-reveal:not([data-batch="true"]) { bottom: calc(62px + env(safe-area-inset-bottom)); }
}
@media (max-width: 420px) {
  .scene-subnav button { padding-inline: 12px; }
  .hud-tools { gap: 6px; }
}
