/* --- 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,
#app.share-open,
#app.info-modal-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-button.hidden {
  display: none;
}

.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 */
}

/* the info modal's title can run long (an episode title) and is free to wrap across
   several lines, but tightened to single-line spacing rather than .menu-header h2's
   generous 32px line-height (matched to menu-back-close's height, not meant for
   multi-line text) which reads as loosely double-spaced once it wraps */
#info-modal-title {
  line-height: 1.3;
}

.info-modal-podcast {
  padding-right: 42px; /* clear menu-back-close, same as h2 above */
  margin-top: 2px;
  font-size: 18px;
  font-weight: 700; /* match #info-modal-title's (h2's default) weight/size — a subtitle, not a footnote */
  color: var(--dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.info-modal-podcast.hidden {
  display: none;
}

.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;
}

/* same one-visible-at-a-time behavior as .menu-view, kept as a separate class so the
   share overlay (#share-overlay, a distinct dialog from the burger menu) isn't swept
   up in showMenuView()'s document-wide .menu-view query in menu.js */
.share-view {
  display: none;
}
.share-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-list-item:disabled {
  opacity: .4;
  pointer-events: none;
}
.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-podcasts-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid var(--hairline);
  padding-right: 12px; /* lines the refresh button's right edge up with the delete
                           chips below it, which sit 12px in from .menu-subscription-row's own padding */
  margin-bottom: 12px;
}
.menu-podcasts-toolbar .menu-add-new-item {
  flex: 1;
  border-bottom: none;
}
.menu-refresh-button {
  flex: none;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 8px;
  background: var(--chip-fill);
  color: var(--fg);
  padding: 0;
}

.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-search-wrap {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}
.menu-search-input {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: 10px;
  padding: 10px 12px;
  color: var(--fg);
  font-size: 14px;
}
.menu-search-results {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 300px;
  overflow-y: auto;
}
.menu-search-result-row {
  padding: 8px 12px;
  background: var(--surface);
  border-radius: 10px;
  font-size: 14px;
}
.menu-search-result-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.menu-search-result-author {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  color: var(--dim);
  margin-top: 2px;
}
.menu-add-divider {
  font-size: 12px;
  color: var(--dim);
  text-align: center;
  margin: 4px 0 12px;
}

.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;
}
/* 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);
}

/* unlike the other .menu-panel overlays, the info modal's own panel doesn't scroll
   as a whole — only #info-modal-body does, so .menu-header (title + the close
   button pinned to its top-right corner) stays fixed in place at the top of the
   modal regardless of how long the description below it scrolls. */
#info-modal .menu-panel {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
#info-modal .menu-header {
  flex: none;
}

.info-modal-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1;
  min-height: 0; /* lets this flex child shrink below its content height so overflow-y actually scrolls */
  overflow-y: auto;
  scrollbar-width: none; /* Firefox */
  -ms-overflow-style: none; /* old Edge */
}
.info-modal-body::-webkit-scrollbar {
  display: none; /* Chrome/Safari */
}
.info-modal-meta {
  font-size: 12px;
  color: var(--dim);
}
.info-modal-description {
  font-size: 14px;
  line-height: 1.5;
  white-space: pre-line;
}
.info-modal-description a {
  color: var(--accent);
  text-decoration: underline;
  word-break: break-word;
}

.podcast-info-artwork {
  width: 96px;
  height: 96px;
  border-radius: 14px;
  align-self: center;
  object-fit: cover;
}
.podcast-info-artwork.hidden {
  display: none;
}
.podcast-info-feed-url {
  word-break: break-all;
  text-align: center;
}
#podcast-info-episodes-value {
  color: var(--dim);
}
