/* --- burger menu --- */

/* #app sets touch-action:none app-wide to suppress pull-to-refresh/pinch-zoom around
   the dial gestures; relax that while the menu is open so its panel can natively
   scroll and its inputs behave like a normal form. */
#app.menu-open {
  touch-action: auto;
}

.menu-button {
  flex: none;
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 12px;
  background: var(--overlay-chip-fill);
  color: var(--fg);
  font-size: 18px;
  line-height: 40px;
  padding: 0;
  touch-action: manipulation;
}

.menu-overlay {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: rgba(0,0,0,.6);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  touch-action: auto;
}
.menu-overlay.show {
  opacity: 1;
  pointer-events: auto;
}

.menu-panel {
  position: relative;
  width: 100%;
  max-width: 420px;
  max-height: min(80vh, 640px);
  overflow-y: auto;
  background: var(--surface-2);
  border: 1px solid var(--border-soft);
  border-radius: 20px;
  padding: 20px 20px max(env(safe-area-inset-bottom, 20px), 20px);
  -webkit-user-select: text;
  user-select: text;
}

.menu-header {
  position: relative;
  margin-bottom: 14px;
}
.menu-header h2 {
  margin: 0;
  padding-right: 42px; /* room for menu-back-close, pinned to the top-right corner */
  font-size: 18px;
  line-height: 32px; /* matches menu-back-close's height so both align on the same baseline */
}

.menu-back-close {
  position: absolute;
  top: 0;
  right: 0;
  flex: none;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 10px;
  background: var(--chip-fill);
  color: var(--fg);
  font-size: 18px;
  line-height: 32px;
  padding: 0;
}

/* only one .menu-view is shown at a time — the root list, or one detail page */
.menu-view {
  display: none;
}
.menu-view.active {
  display: block;
}

.menu-list-item {
  display: flex;
  align-items: center;
  width: 100%;
  padding: 14px 4px;
  background: none;
  border: none;
  border-bottom: 1px solid var(--hairline);
  color: var(--fg);
  font-size: 15px;
  text-align: left;
}
.menu-view[data-view="root"] .menu-list-item:last-child {
  border-bottom: none;
}
.menu-toast {
  position: absolute;
  left: 20px;
  right: 20px;
  bottom: max(env(safe-area-inset-bottom, 20px), 20px);
  padding: 10px 14px;
  border-radius: 10px;
  background: var(--accent);
  color: var(--accent-contrast);
  font-size: 14px;
  font-weight: 600;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease;
}
.menu-toast.show {
  opacity: 1;
}

.menu-subscriptions-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 360px;
  overflow-y: auto;
}
.menu-subscription-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 12px;
  background: var(--surface);
  border-radius: 10px;
  font-size: 14px;
  /* .menu-panel opts back into text selection (so users can copy things like the
     About text) — but that makes long-pressing the podcast name trigger Android's
     native "select text"/search UI before our drag gesture ever sees the press.
     Override it back to none for the whole draggable row. */
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  /* dragging (see startSubscriptionDrag in scripts/menu.js) translates this row with
     the finger 1:1 — .dragging disables the transition so it doesn't lag, siblings
     making room for it keep the transition so their shift animates smoothly */
  transition: transform .15s ease;
  touch-action: pan-y;
}
.menu-subscription-row.dragging {
  position: relative;
  z-index: 1;
  transition: none;
  box-shadow: 0 8px 20px var(--shadow-1);
  background: lightgreen;
  color: #14141a; /* dark text for contrast against the light green fill, regardless of theme */
}
.menu-subscription-row.dragging .menu-subscription-drag-handle {
  color: #14141a;
}
.menu-subscription-drag-handle {
  flex: none;
  color: var(--dim);
  font-size: 16px;
  line-height: 1;
  padding: 4px 2px;
  cursor: grab;
}
.menu-subscription-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.menu-subscription-remove {
  flex: none;
  width: 26px;
  height: 26px;
  border: none;
  border-radius: 8px;
  background: var(--chip-fill);
  color: var(--fg);
  font-size: 15px;
  line-height: 26px;
  padding: 0;
}
.menu-empty {
  font-size: 13px;
  color: var(--dim);
}

.menu-add-new-item {
  color: var(--accent);
  font-weight: 600;
}

.menu-add-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.menu-add-form input {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: 10px;
  padding: 10px 12px;
  color: var(--fg);
  font-size: 14px;
}
.menu-add-form button,
.menu-opml-row button,
.menu-file-label {
  background: var(--accent);
  color: var(--accent-contrast);
  border: none;
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 14px;
  font-weight: 600;
  text-align: center;
}

.menu-opml-row {
  display: flex;
  gap: 10px;
}
.menu-opml-row button,
.menu-file-label {
  flex: 1;
}
.menu-file-label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.menu-about-text {
  font-size: 14px;
  color: var(--dim);
  line-height: 1.5;
  margin: 0;
}

.menu-setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 4px;
  border-bottom: 1px solid var(--hairline);
}
.menu-view[data-view="settings"] .menu-setting-row:last-child {
  border-bottom: none;
}
.menu-setting-row-stacked {
  flex-direction: column;
  align-items: stretch;
}
.menu-setting-label {
  font-size: 15px;
}
.menu-setting-row-stacked .menu-setting-label {
  margin-bottom: 10px;
}
#setting-episodes-value {
  color: var(--dim);
}

/* checkbox-driven pill switch — the checkbox itself is visually hidden but stays
   in the tab order / keeps native checked-state semantics; the track+thumb are
   plain siblings styled via the :checked selector rather than JS toggling classes */
.menu-toggle {
  position: relative;
  flex: none;
  /* plain inline-block, not flex — an absolutely-positioned child of a flex
     container resolves its "auto" static position via the flex alignment
     algorithm rather than simple top-left, which left the (invisible) checkbox
     offset from the visible track it's meant to sit exactly on top of */
  display: inline-block;
  width: 46px;
  height: 28px;
}
.menu-toggle input {
  position: absolute;
  inset: 0; /* without an explicit position, "auto" falls back to its normal-flow static position instead of overlaying the track */
  z-index: 1; /* both this and .menu-toggle-track are position:absolute now — without this, the track (later in DOM, equal stacking level) paints over the input and blocks clicks */
  opacity: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  cursor: pointer;
}
.menu-toggle-track {
  /* a plain <span> is display:inline by default, where width/height don't apply —
     absolutely position it to fill .menu-toggle's 46x28 box instead */
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--hairline);
  transition: background .15s ease;
}
.menu-toggle-thumb {
  display: block;
  width: 22px;
  height: 22px;
  margin: 2px;
  border-radius: 50%;
  background: var(--dim);
  transition: transform .15s ease, background .15s ease;
}
.menu-toggle input:checked ~ .menu-toggle-track {
  background: var(--accent);
  border-color: var(--accent);
}
.menu-toggle input:checked ~ .menu-toggle-track .menu-toggle-thumb {
  transform: translateX(18px);
  background: var(--accent-contrast);
}

.menu-slider {
  width: 100%;
  accent-color: var(--accent);
}
