/* =============================================================================
   Header menus, dialogs and Settings (js/headerMenus.js).
   The dropdown pattern follows SemperScribe's header: a label caption, icon and
   label items, separators between groups, a red destructive item, a chevron on
   each trigger, labels hidden on small screens (icons stay), 44px touch
   targets on mobile. Tokens come from semper-tokens.css.
   ============================================================================= */

/* --- The row in the header ------------------------------------------------- */
#stickyChrome .header-menus {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-1);
  flex-shrink: 0;
}

@media (max-width: 960px) {
  #stickyChrome .header-menus {
    width: 100%;
    justify-content: flex-start;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }
  #stickyChrome .header-menus::-webkit-scrollbar { display: none; }
}

.hm { position: relative; display: inline-flex; flex-shrink: 0; }

/* --- Triggers ------------------------------------------------------------------ */
.hm-trigger {
  font-family: var(--font-body);
  font-size: var(--text-sm);
  color: var(--color-foreground);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  min-height: 32px;
  line-height: 1;
  white-space: nowrap;
  transition: color var(--motion-fast) var(--easing-out),
              background var(--motion-fast) var(--easing-out);
}
.hm-trigger:hover,
.hm-trigger[aria-expanded="true"] {
  color: var(--color-usmc-scarlet);
  background: color-mix(in srgb, var(--color-usmc-scarlet) 8%, transparent);
}
body.dark .hm-trigger:hover,
body.dark .hm-trigger[aria-expanded="true"] { color: var(--color-foreground); background: var(--color-surface-3); }
.hm-trigger:focus-visible { outline: 3px solid var(--color-ring); outline-offset: 2px; }
.hm-trigger .hm-ic svg { width: 16px; height: 16px; display: block; }
.hm-trigger .hm-ic { color: var(--color-marine-blue); display: inline-flex; }
body.dark .hm-trigger .hm-ic { color: var(--color-marine-blue-100); }
.hm-chevron svg { width: 12px; height: 12px; opacity: 0.7; transition: transform var(--motion-fast) var(--easing-out); }
.hm-trigger[aria-expanded="true"] .hm-chevron svg { transform: rotate(180deg); }
.hm-trigger.is-disabled,
.hm-trigger[aria-disabled="true"] { opacity: 0.5; cursor: not-allowed; }
.hm-trigger.is-disabled:hover { color: var(--color-foreground); background: transparent; }

/* Small screens: icons only, 44px touch targets. The accessible name stays (aria-label). */
@media (max-width: 640px) {
  .hm--header .hm-label--hide-sm { display: none; }
  .hm--header .hm-trigger,
  .hm-gear { min-width: 44px; min-height: 44px; justify-content: center; padding: 6px 8px; gap: 2px; }
  .hm-gear { padding: 6px; }
}

/* A compact menu beside a field */
.hm--field .hm-trigger {
  border-color: var(--color-border-strong);
  background: var(--color-bg-elev);
  padding: 6px 10px;
}
@media (max-width: 640px) {
  .hm--field .hm-trigger { min-height: 44px; }
}

/* --- The open list (moved to <body>, so no ancestor clips it) --------------------- */
.hm-list {
  position: fixed;
  z-index: 15500;
  min-width: 220px;
  max-width: calc(100vw - 16px);
  overflow-y: auto;
  padding: 4px;
  background: var(--color-bg-elev);
  color: var(--color-foreground);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  font-family: var(--font-body);
  font-size: var(--text-sm);
}
.hm-list[hidden] { display: none; }
.hm-caption {
  padding: 6px 10px 4px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-muted-foreground);
}
.hm-sep { height: 1px; margin: 4px -4px; background: var(--color-border); }
.hm-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}
.hm-item .hm-ic { display: inline-flex; color: var(--color-muted-foreground); }
.hm-item .hm-ic svg { width: 16px; height: 16px; display: block; }
.hm-item:hover,
.hm-item:focus { background: var(--color-muted); outline: none; }
.hm-item:focus-visible { outline: 2px solid var(--color-ring); outline-offset: -2px; }
.hm-item.is-disabled { opacity: 0.5; cursor: not-allowed; }
/* An item that opens a flyout: a right chevron at the far edge, held lit while open */
.hm-item .hm-sub-chevron { margin-left: auto; padding-left: 8px; }
.hm-item .hm-sub-chevron svg { width: 14px; height: 14px; }
.hm-item[aria-expanded="true"] { background: var(--color-muted); }
.hm-item--destructive,
.hm-item--destructive .hm-ic { color: var(--color-destructive); }
.hm-item--destructive:hover,
.hm-item--destructive:focus { background: color-mix(in srgb, var(--color-destructive) 12%, transparent); }
@media (max-width: 640px) {
  .hm-item { min-height: 44px; }
}
.hm-sr {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* --- Dialogs -------------------------------------------------------------------------- */
body.hm-dialog-open { overflow: hidden; }
.hm-overlay {
  position: fixed;
  inset: 0;
  z-index: 15000;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 5vh 12px 12px;
  background: rgba(26, 22, 16, 0.55);
  overflow-y: auto;
}
.hm-dialog {
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  background: var(--color-bg-elev);
  color: var(--color-foreground);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  font-family: var(--font-body);
}
.hm-dialog--wide { max-width: 760px; }
.hm-dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--color-border);
}
.hm-dialog-title { margin: 0; font-size: var(--text-lg); font-weight: 700; }
.hm-dialog-close {
  min-width: 44px; min-height: 44px;
  border: 0; background: transparent; color: inherit;
  font-size: 24px; line-height: 1; cursor: pointer; border-radius: var(--radius-sm);
}
.hm-dialog-close:hover { background: var(--color-muted); }
.hm-dialog-close:focus-visible { outline: 3px solid var(--color-ring); outline-offset: 2px; }
.hm-dialog-body { padding: 16px; overflow-y: auto; }

/* Tabs */
.hm-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--color-border); margin-bottom: 16px; overflow-x: auto; overflow-y: hidden; }
.hm-tab {
  padding: 10px 14px; min-height: 44px; border: 0; background: transparent; color: var(--color-muted-foreground);
  font: inherit; font-weight: 600; cursor: pointer; border-bottom: 3px solid transparent; margin-bottom: -1px;
}
.hm-tab[aria-selected="true"] { color: var(--color-foreground); border-bottom-color: var(--color-usmc-scarlet); }
.hm-tab:focus-visible { outline: 3px solid var(--color-ring); outline-offset: -3px; }
.hm-tabpanel[hidden] { display: none; }

/* Settings content */
.hm-pane > * + * { margin-top: 12px; }
.hm-help, .hm-status { margin: 0; font-size: var(--text-sm); color: var(--color-muted-foreground); }
.hm-reason {
  margin: 0; padding: 8px 10px; font-weight: 600; font-size: var(--text-sm);
  border-left: 4px solid var(--color-usmc-scarlet); background: var(--color-muted);
}
.hm-field { display: flex; flex-direction: column; gap: 4px; }
.hm-field-label { font-weight: 600; font-size: var(--text-sm); }
.hm-input {
  width: 100%; box-sizing: border-box; min-height: 40px; padding: 8px 10px; font: inherit;
  color: var(--color-foreground); background: var(--color-bg); border: 1px solid var(--color-border-strong); border-radius: var(--radius-sm);
}
.hm-switch { display: flex; align-items: center; gap: 10px; min-height: 44px; font-weight: 600; cursor: pointer; }
.hm-switch input { width: 20px; height: 20px; }
.hm-btn {
  min-height: 40px; padding: 8px 14px; font: inherit; font-weight: 600; cursor: pointer;
  color: var(--color-foreground); background: transparent; border: 1px solid var(--color-border-strong); border-radius: var(--radius-sm);
}
.hm-btn--danger { color: var(--color-destructive); border-color: var(--color-destructive); }
.hm-btn:focus-visible { outline: 3px solid var(--color-ring); outline-offset: 2px; }

/* Settings > GunnyBot and the dialogs share the assistant styles; keep them readable in dark mode */
body.dark .assistant-output,
body.dark .assistant-pre { background: var(--color-muted); color: var(--color-foreground); }

/* --- Main page strip, summary hint --------------------------------------------------------- */
.resume-strip {
  margin: 16px auto 0;
  max-width: 520px;
  padding: 8px 12px;
  font-size: var(--text-sm);
  text-align: center;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-sm);
  background: var(--color-muted);
  color: var(--color-foreground);
}
.resume-strip[hidden] { display: none; }
.resume-strip__btn {
  border: 0; background: transparent; padding: 4px 6px; min-height: 32px; font: inherit; font-weight: 700;
  color: var(--color-usmc-scarlet); text-decoration: underline; cursor: pointer;
}
.resume-strip__btn:focus-visible { outline: 3px solid var(--color-ring); outline-offset: 2px; }
.export-hint { text-align: center; font-size: var(--text-sm); color: var(--color-muted-foreground); margin: 16px 0 0; }

/* Nothing here prints: the evaluation does. */
@media print {
  .hm-overlay,
  .hm-list,
  .header-menus,
  .resume-strip,
  .export-hint { display: none !important; }
}

/* Main page: the Begin button is just a button, not a card of text. */
#modeSelectionCard .mode-option-btn { padding: 20px 24px; }
