/* The sidebar menu under the six new themes: one line per item (layout proposals A05,
   desktop, and C09, phone). portal/docs/themes.md, "The menu: one line per item".

   Every rule is scoped to NL - an <html> that has a data-theme and it is not "legacy" -
   so legacy draws exactly what it drew before. Theme flavour lives in a marked "menu"
   section at the end of each theme file.

   - Each item is one line: its name, and its count pinned to the right edge. A name that
     is longer than the column (Ukrainian runs long) wraps to a second line rather than
     being cut, so no meaning is hidden.
   - The grey description under each name is no longer drawn in the list. It stays in the
     link, visually hidden, so a screen reader still reads it as part of the item; on a
     desktop static/js/nav_menu.js shows it in a tooltip beside the item on pointer hover
     AND on keyboard focus. A disabled ("Coming soon") item cannot be hovered or focused,
     so its line stays visible.
   - The language button sits in one row: globe, then the languages, each in its own
     language. Its word "Language" stays for screen readers (the group also carries it as
     aria-label).
   - On a phone the drawer never draws its own Theme button: the app bar already has one,
     which sits above the drawer and opens and closes the theme list inside it
     (theme_picker.js). One Theme control in every state; `theme_one_control` in the UI
     harness counts them.
   - On a phone (no hover, so no tooltip) a "Show details" switch at the top of the
     drawer puts each description back, as a muted line under its item. Off by default,
     remembered per browser (nav_menu.js). */

/* Wrappers this layout adds have no box under legacy; the descriptions switch is phone
   only (shown in the phone section below). */
.sidebar-prefs { display: contents; }
.nav-desc-toggle { display: none; }

/* ---------------------------------------------------------------- both widths */
/* Theme and language are one block: the sidebar's own gap between them goes. */
:root[data-theme]:not([data-theme="legacy"]) .sidebar-prefs { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
:root[data-theme]:not([data-theme="legacy"]) .sidebar-prefs .lang-picker { margin-top: 0; }

:root[data-theme]:not([data-theme="legacy"]) .sidebar .nav-item { align-items: center; }
:root[data-theme]:not([data-theme="legacy"]) .sidebar .nav-item > span:not(.emoji) {
  display: flex; align-items: center; gap: 8px;
  flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere;
}
:root[data-theme]:not([data-theme="legacy"]) .sidebar .nav-item .nav-badge { flex: none; margin-left: auto; }
:root[data-theme]:not([data-theme="legacy"]) .sidebar .nav-item:not(.disabled) small {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; border: 0;
  overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}
/* A disabled item keeps its "Coming soon" line, under the name. */
:root[data-theme]:not([data-theme="legacy"]) .sidebar .nav-item.disabled > span:not(.emoji) { flex-wrap: wrap; }
:root[data-theme]:not([data-theme="legacy"]) .sidebar .nav-item.disabled small { flex-basis: 100%; }

:root[data-theme]:not([data-theme="legacy"]) .sidebar .lang-picker { flex-wrap: nowrap; padding: 6px 10px; }
:root[data-theme]:not([data-theme="legacy"]) .sidebar .lang-picker-text {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; border: 0;
  overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}
:root[data-theme]:not([data-theme="legacy"]) .sidebar .lang-picker-options { flex-wrap: nowrap; }

/* ---------------------------------------------------------------- desktop */
@media (min-width: 761px) {
  /* nav_menu.js reads this to know the descriptions are hidden and the tooltip is wanted. */
  :root[data-theme]:not([data-theme="legacy"]) .sidebar { --nav-tip: 1; }
  :root[data-theme]:not([data-theme="legacy"]) .sidebar .nav-item { padding-top: 5px; padding-bottom: 5px; }

  /* The rest of the room an admin's menu needs at 900px tall: a tighter column rhythm,
     section headings closer to their items, and the Theme button on one line - its
     swatch already shows the current theme, and the button's aria-label names it. */
  :root[data-theme]:not([data-theme="legacy"]) .sidebar { gap: 14px; }
  :root[data-theme]:not([data-theme="legacy"]) .sidebar nav > .nav-label:not(:first-child) { margin-top: 10px !important; }
  :root[data-theme]:not([data-theme="legacy"]) .sidebar .theme-toggle { min-height: 38px; padding-top: 5px; padding-bottom: 5px; }
  :root[data-theme]:not([data-theme="legacy"]) .sidebar .theme-toggle-text small {
    position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; border: 0;
    overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
  }
  :root[data-theme]:not([data-theme="legacy"]) .sidebar .lang-picker { padding-top: 4px; padding-bottom: 4px; }
  :root[data-theme]:not([data-theme="legacy"]) .sidebar .lang-option { min-height: 26px; padding-top: 3px; padding-bottom: 3px; }

  /* The account controls in rows, not a column: who you are; Sign out beside Change
     password; then View as. (The phone keeps its full-width, 44px-tall column.) */
  :root[data-theme]:not([data-theme="legacy"]) .sidebar-foot:has(> .nav-account) {
    display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px;
  }
  :root[data-theme]:not([data-theme="legacy"]) .sidebar-foot > .nav-account { flex: 1 1 100%; min-width: 0; }
  :root[data-theme]:not([data-theme="legacy"]) .sidebar-foot:has(> .nav-account) > form { margin-top: 0; min-width: 0; }
  :root[data-theme]:not([data-theme="legacy"]) .sidebar-foot > form[action="/logout"] { order: 1; }
  :root[data-theme]:not([data-theme="legacy"]) .sidebar-foot > .nav-password { order: 2; margin-top: 0 !important; }
  :root[data-theme]:not([data-theme="legacy"]) .sidebar-foot > .viewas-form { order: 3; flex: 1 1 100%; display: flex; gap: 6px; }
  :root[data-theme]:not([data-theme="legacy"]) .sidebar-foot > .viewas-form select { flex: 1 1 auto; min-width: 0; width: auto; margin: 0; }
  :root[data-theme]:not([data-theme="legacy"]) .sidebar-foot > .viewas-form .btn { flex: none; }
}

/* The tooltip: one element, appended to <body> by nav_menu.js and positioned beside the
   item, because the sidebar scrolls and would clip anything that pokes out of it. */
.nav-tip { display: none; }
:root[data-theme]:not([data-theme="legacy"]) .nav-tip {
  display: block; position: fixed; z-index: 59; left: 0; top: 0;
  max-width: min(300px, calc(100vw - 24px)); padding: 7px 10px;
  border: 1px solid var(--border); border-radius: var(--radius-sm, 6px);
  background: var(--surface-popover); color: var(--text-primary);
  box-shadow: 0 6px 20px var(--shadow-drawer, rgba(0, 0, 0, .35));
  font-size: 12.5px; line-height: 1.4; overflow-wrap: anywhere;
  pointer-events: none;
}
:root[data-theme]:not([data-theme="legacy"]) .nav-tip[hidden] { display: none; }
body.viewer-open .nav-tip { display: none; }

/* ---------------------------------------------------------------- phone */
@media (max-width: 760px) {
  :root[data-theme]:not([data-theme="legacy"]) .sidebar .nav-item {
    padding-top: 9px; padding-bottom: 9px; min-height: 44px; box-sizing: border-box;
  }
  :root[data-theme]:not([data-theme="legacy"]) .sidebar .theme-picker:not([open]),
  :root[data-theme]:not([data-theme="legacy"]) .sidebar .theme-picker > .theme-toggle { display: none; }
  :root[data-theme]:not([data-theme="legacy"]) .sidebar .theme-picker[open] > .theme-panel { margin-top: 0; }

  /* "Show details" (nav_menu.js builds it; the drawer's first row). */
  :root[data-theme]:not([data-theme="legacy"]) .sidebar .nav-desc-toggle {
    display: flex; align-items: center; gap: 10px; width: 100%; min-height: 44px;
    margin: 0 0 8px; padding: 6px 10px; box-sizing: border-box;
    border: 1px solid var(--border); border-radius: var(--radius-sm, 6px);
    background: transparent; color: var(--text-secondary, var(--text-primary));
    font: inherit; font-size: 13px; text-align: left; cursor: pointer;
  }
  :root[data-theme]:not([data-theme="legacy"]) .sidebar .nav-desc-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
  :root[data-theme]:not([data-theme="legacy"]) .nav-desc-switch {
    flex: none; position: relative; width: 30px; height: 18px; border-radius: 9px;
    border: 1px solid var(--border-hover, var(--border)); background: var(--surface-raised);
  }
  :root[data-theme]:not([data-theme="legacy"]) .nav-desc-switch::after {
    content: ""; position: absolute; top: 2px; left: 2px; width: 12px; height: 12px; border-radius: 50%;
    background: var(--text-muted, var(--muted));
  }
  :root[data-theme]:not([data-theme="legacy"]) .nav-desc-toggle[aria-pressed="true"] .nav-desc-switch { border-color: var(--accent); }
  :root[data-theme]:not([data-theme="legacy"]) .nav-desc-toggle[aria-pressed="true"] .nav-desc-switch::after { left: 14px; background: var(--accent); }

  /* Descriptions shown: each one a muted line under its item's name. */
  :root[data-theme]:not([data-theme="legacy"]) .sidebar.nav-show-desc .nav-item > span:not(.emoji) { flex-wrap: wrap; row-gap: 1px; }
  :root[data-theme]:not([data-theme="legacy"]) .sidebar.nav-show-desc .nav-item:not(.disabled) small {
    position: static; display: block; flex-basis: 100%; width: auto; height: auto; margin: 0; padding: 0;
    overflow: visible; clip: auto; clip-path: none; white-space: normal;
    color: var(--text-muted, var(--muted)); font-size: 11.5px; line-height: 1.35;
    -webkit-line-clamp: unset;
  }
  /* Opened from the app bar, the list is part of the drawer and as wide as it. Darkroom,
     Blueprint, Neon Sanctuary and Win2000 size their desktop panel from the sidebar width,
     which on a 390px phone left it 112px wide. */
  :root[data-theme]:not([data-theme="legacy"]) .sidebar .theme-panel { left: auto; top: auto; width: auto; max-height: none; }
}
