/**
 * Shared Tutor popover menu (filter + guide voice + future surfaces)
 *
 * Panel: glass frost (same family as nav dock / guide)
 * Options: optional icon · label · optional hint; selected = solid ink
 * Placement: JS sets data-menu-side=up|down on host; data-align=start|end on panel
 */

.tm-panel {
  --tm-ink: var(--tf-ink, var(--ink, #1a1a1a));
  --tm-muted: var(--tf-muted, var(--muted, #4a463f));
  --tm-gap: 0.35rem;
  --tm-radius: 16px;
  --tm-opt-radius: 10px;
  --tm-touch: var(--tf-touch, var(--touch, 44px));

  box-sizing: border-box;
  position: absolute;
  z-index: var(--tf-z-menu, 60);
  min-width: max(100%, 11rem);
  width: max-content;
  max-width: min(18rem, 90vw);
  margin: 0;
  padding: var(--tm-gap);
  list-style: none;
  /* Glass — match guide / nav */
  background: rgb(255 253 248 / 0.88);
  backdrop-filter: blur(12px) saturate(1.15);
  -webkit-backdrop-filter: blur(12px) saturate(1.15);
  border: 1px solid rgb(26 26 26 / 0.1);
  border-radius: var(--tm-radius);
  box-shadow:
    0 1px 0 rgb(255 255 255 / 0.4) inset,
    0 8px 28px rgb(0 0 0 / 0.14);
  text-align: left;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  /* Default: below trigger, start-aligned */
  top: calc(100% + 0.35rem);
  bottom: auto;
  left: 0;
  right: auto;
}

.tm-panel[data-align="end"],
[data-menu-side] .tm-panel[data-align="end"] {
  left: auto;
  right: 0;
}

/* Host (e.g. .tf-menu, .voice-picker) sets data-menu-side via positionMenu() */
[data-menu-side="up"] > .tm-panel,
[data-menu-side="up"] .tm-panel {
  top: auto;
  bottom: calc(100% + 0.35rem);
}

[data-menu-side="down"] > .tm-panel,
[data-menu-side="down"] .tm-panel {
  top: calc(100% + 0.35rem);
  bottom: auto;
}

.tm-panel[hidden] {
  display: none !important;
}

/* Option row — use on <li> or <button role="option"> */
.tm-panel .tm-option,
.tm-panel [role="option"] {
  box-sizing: border-box;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.55rem;
  width: 100%;
  min-height: var(--tm-touch);
  margin: 0;
  padding: 0.45rem 0.7rem;
  border: 0;
  border-radius: var(--tm-opt-radius);
  background: transparent;
  color: var(--tm-ink);
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  line-height: 1.25;
}

/* Stacked title + hint (voice) */
.tm-option-text {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.1rem;
  min-width: 0;
  flex: 1 1 auto;
}

.tm-option-label {
  font-weight: 700;
  font-size: 0.88rem;
  line-height: 1.2;
}

.tm-option-hint {
  font-weight: 600;
  font-size: 0.72rem;
  opacity: 0.72;
  line-height: 1.2;
  color: inherit;
}

.tm-option-icon {
  display: inline-flex;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  color: var(--tm-muted);
  line-height: 0;
}

.tm-option-icon svg {
  width: 18px;
  height: 18px;
  display: block;
}

.tm-panel .tm-option:hover,
.tm-panel .tm-option:focus-visible,
.tm-panel [role="option"]:hover,
.tm-panel [role="option"]:focus-visible {
  background: rgb(255 255 255 / 0.7);
  outline: none;
}

.tm-panel .tm-option[aria-selected="true"],
.tm-panel [role="option"][aria-selected="true"] {
  background: var(--tm-ink);
  color: #fff;
  font-weight: 700;
}

.tm-panel .tm-option[aria-selected="true"] .tm-option-icon,
.tm-panel [role="option"][aria-selected="true"] .tm-option-icon {
  color: #fff;
}

.tm-panel .tm-option[aria-selected="true"] .tm-option-hint,
.tm-panel [role="option"][aria-selected="true"] .tm-option-hint {
  opacity: 0.85;
}
