/* Nine Graves — persistent left sidebar (desktop).
   Loaded after refresh.css. Above 960px every screen, Combat included, uses one layout:
   a fixed left sidebar for navigation and the screen's own content to its right.
   At 960px and below the existing top/bottom tab bars are left untouched. */

@media (min-width: 961px) {
  #app {
    --sidebar-width: clamp(212px, 15vw, 248px);
  }

  /* ---- Grid: sidebar column + the rest ---- */
  #app:not([data-view="combat"]) {
    grid-template-columns: var(--sidebar-width) minmax(0, 1fr) clamp(250px, 22vw, 330px);
    grid-template-rows: 46px minmax(0, 1fr) 32px;
  }
  #app:not([data-view="combat"]) #status { grid-column: 2 / -1; grid-row: 1; height: 46px; }
  #app:not([data-view="combat"]) #view { grid-column: 2; grid-row: 2; }
  #app:not([data-view="combat"]) #bag { grid-column: 3; grid-row: 2 / 4; }
  #app:not([data-view="combat"]) #journal { grid-column: 2; grid-row: 3; }
  #app:is([data-view="character"], [data-view="mastery"], [data-view="codex"], [data-view="guide"], [data-view="inventory"]) :is(#view, #journal) {
    grid-column: 2 / -1;
  }

  #app[data-view="combat"] {
    grid-template: minmax(0, 1fr) / var(--sidebar-width) minmax(0, 1fr);
  }
  #app[data-view="combat"] > #view { grid-area: 1 / 2; }

  /* ---- The sidebar itself (overrides refresh.css top bar and hunt-ui hiding) ---- */
  body #app[data-view] #nav,
  body #app[data-view="combat"] > #nav,
  body #app:not([data-view="combat"]) #nav {
    grid-column: 1;
    grid-row: 1 / -1;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    height: auto;
    min-height: 0;
    padding: 0;
    overflow: hidden;
    z-index: 5;
    border: 0;
    border-right: 1px solid #4a2a2c;
    background:
      radial-gradient(120% 40% at 0% 0%, #331c1c55, transparent 70%),
      linear-gradient(180deg, #1a1414 0%, #110e0e 55%, #0d0b0b 100%);
    box-shadow: 4px 0 18px #0008, inset -1px 0 0 #b3262e1a;
  }

  /* Things the sidebar replaces */
  body #app[data-view] #nav .mobile-navigation,
  body #app[data-view] #nav .nav-menu-button,
  .hunt-header .hunt-brand,
  .hunt-header .hunt-tabs { display: none !important; }

  /* Brand */
  body #app[data-view] #nav .brand {
    display: flex !important;
    align-items: center;
    gap: 11px;
    flex: 0 0 auto;
    height: 64px;
    margin: 0;
    padding: 0 18px;
    border: 0;
    border-bottom: 1px solid #3c2c2b;
    border-radius: 0;
    background: transparent;
    color: #dbcbb8;
    box-shadow: none;
    text-align: left;
  }
  body #app[data-view] #nav .brand > span:last-child {
    display: inline !important;
    font-family: var(--title);
    font-size: 17px;
    letter-spacing: 2.4px;
    text-transform: uppercase;
    white-space: nowrap;
  }
  body #app[data-view] #nav .brand .hunt-brand-mark { flex: 0 0 auto; }

  /* Character card */
  #nav .nav-hero {
    display: flex;
    align-items: center;
    gap: 11px;
    flex: 0 0 auto;
    margin: 12px 12px 6px;
    padding: 9px 10px;
    border: 1px solid #572f2f;
    border-radius: 6px;
    background: linear-gradient(135deg, #241b1b, #141010);
    color: var(--text);
    text-align: left;
    box-shadow: inset 0 1px 0 #ffffff0d;
  }
  #nav .nav-hero:hover { border-color: #902228; }
  #nav .nav-hero-crest {
    display: grid;
    place-items: center;
    flex: 0 0 34px;
    height: 34px;
    border: 1px solid #a7272f;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 30%, #5a1a1e, #191414);
    color: #e4d8ca;
    font-family: var(--title);
    font-size: 14px;
    font-weight: 700;
  }
  #nav .nav-hero-text { display: flex; flex-direction: column; min-width: 0; }
  #nav .nav-hero-text b {
    font-family: var(--title);
    font-size: 14px;
    font-weight: 600;
    color: #e5dace;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  #nav .nav-hero-text small { font-size: 11px; color: var(--muted); }

  /* Scrolling link list + pinned utility row */
  body #app[data-view] #nav .desktop-navigation {
    display: flex !important;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
  }
  #nav .desktop-navigation > nav {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding: 2px 8px 10px;
    scrollbar-width: thin;
    scrollbar-color: #4e2226 transparent;
  }
  #nav .nav-utility {
    flex: 0 0 auto;
    display: flex;
    gap: 4px;
    padding: 8px;
    border-top: 1px solid #362929;
  }
  #nav .nav-utility button { flex: 1; justify-content: center; }

  /* Section headers */
  #nav .nav-section {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    margin: 10px 0 2px;
    padding: 6px 8px;
    border: 0;
    border-radius: 3px;
    background: transparent;
    box-shadow: none;
    color: #b4484d;
    font-family: var(--title);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 1.6px;
    text-transform: uppercase;
    cursor: pointer;
  }
  #nav .nav-section:hover { color: #cdb79d; }
  #nav .nav-section span { font-size: 10px; transition: transform .15s ease; }
  #nav .nav-group.collapsed .nav-section span { transform: rotate(-90deg); }
  #nav .nav-group.collapsed .nav-group-items { display: none; }

  /* Links */
  #nav .desktop-navigation button:not(.nav-section) {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    min-height: 34px;
    margin: 1px 0;
    padding: 6px 10px;
    border: 1px solid transparent;
    border-radius: 4px;
    background: transparent;
    box-shadow: none;
    color: #cfc2b0;
    font-size: 13px;
    text-align: left;
  }
  #nav .desktop-navigation button:not(.nav-section):hover {
    background: #552e2e33;
    color: #ece4da;
  }
  #nav .desktop-navigation button.active {
    background: linear-gradient(90deg, #5e333399, #2c222233 85%, transparent);
    border-color: #7a161c66;
    color: #ece4da;
  }
  #nav .desktop-navigation button.active::before {
    content: "";
    position: absolute;
    left: -8px;
    top: 6px;
    bottom: 6px;
    width: 3px;
    border-radius: 0 2px 2px 0;
    background: #dbcbb8;
    box-shadow: 0 0 8px #dbcbb888;
  }
  #nav .desktop-navigation .nav-icon {
    flex: 0 0 22px;
    width: 22px;
    font-size: 16px;
    text-align: center;
    filter: drop-shadow(0 1px 2px #000);
  }
  #nav .desktop-navigation .nav-label {
    flex: 1;
    min-width: 0;
    font-size: 13px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  #nav .desktop-navigation .nav-meta {
    flex: 0 0 auto;
    min-width: 24px;
    padding: 1px 6px;
    border: 1px solid #4a2828;
    border-radius: 10px;
    color: #a3827f;
    font-size: 11px;
    font-variant-numeric: tabular-nums;
    text-align: center;
  }
  #nav .quest-dot { float: none; margin-left: 6px; }

  /* Footer */
  body #app[data-view] #nav .nav-foot {
    display: block !important;
    flex: 0 0 auto;
    padding: 8px 16px 12px;
    color: #8f6a68;
    font-size: 10px;
    letter-spacing: .6px;
    line-height: 1.5;
  }

  /* Combat header no longer needs the brand/tabs; let location sit at the left */
  #app[data-view="combat"] .hunt-header { padding-left: clamp(14px, 1.6vw, 24px); }
}

/* Short desktop windows: tighten rows so all sections fit more often */
@media (min-width: 961px) and (max-height: 760px) {
  body #app[data-view] #nav .brand { height: 52px; }
  #nav .nav-hero { margin-top: 8px; padding: 7px 9px; }
  #nav .desktop-navigation button:not(.nav-section) { min-height: 29px; padding-top: 4px; padding-bottom: 4px; }
  #nav .nav-section { margin-top: 6px; padding-top: 4px; padding-bottom: 4px; }
}

/* The mobile "Menu" dialog reuses the sidebar markup: show every section, no toggles */
.hunt-menu .nav-group-items { display: block !important; }
.hunt-menu .nav-section { pointer-events: none; }
.hunt-menu .nav-section span { display: none; }
@media (max-width: 960px) {
  #nav .nav-hero { display: none; }
}

/* Hint that the link list scrolls when sections overflow */
@media (min-width: 961px) {
  #nav .desktop-navigation > nav {
    -webkit-mask-image: linear-gradient(#000 calc(100% - 22px), transparent);
    mask-image: linear-gradient(#000 calc(100% - 22px), transparent);
  }
}
