/* ── Mobile / tablet layout (active when body.mobile is set) ──────────────── */

/* Disable ALL browser touch gesture detection — we handle everything in JS */
@media (pointer: coarse) {
  html, body {
    touch-action: none;
    overflow: hidden;
  }
}

/* Hide desktop-only panels */
body.mobile #slider-panel    { display: none; }
body.mobile #hint            { display: none; }
body.mobile #dev-panel       { display: none; }
body.mobile #zoom-display    { display: none; }
body.mobile #app-title       { display: none; }
body.mobile #moon-data-panel { display: none; }
body.mobile #observe-panel   { display: none !important; }
body.mobile #observe-tab     { display: none !important; }
body.mobile #week-btn        { display: none !important; }

/* ── Moon info button ─────────────────────────────────────────────────────── */
#moon-info-btn {
  display: none;
}

/* ── Mobile moon data panel ───────────────────────────────────────────────── */
#mobile-moon-panel {
  display: none;
}

body.mobile #mobile-moon-panel {
  position: fixed;
  bottom: 80px;
  left: 14px;
  z-index: 60;
  background: rgba(5, 10, 20, 0.75);
  border: 1px solid rgba(255, 255, 255, 0.10);
  border-radius: 12px;
  padding: 10px 14px;
  display: none;
  flex-direction: column;
  gap: 7px;
  font-family: 'Assistant', sans-serif;
  direction: rtl;
  min-width: 160px;
  pointer-events: none;
}

body.mobile #mobile-moon-panel.open {
  display: flex;
}

/* Info panel: hidden by default, shown briefly on tap */
body.mobile #info-panel {
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
  bottom: 60px;
}
body.mobile #info-panel.tap-show {
  opacity: 1;
}

/* Trivia panel: full width, above drawer, scrollable */
body.mobile #trivia-panel {
  left: 10px;
  right: 10px;
  width: auto;
  bottom: 70px;
  transform: translateY(20px);
  max-width: none;
  max-height: 42vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
body.mobile #trivia-panel.visible {
  transform: translateY(0);
}
body.mobile #trivia-text {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  flex: 1;
  padding-bottom: 4px;
}

/* Measure panel: compact, bottom-left, away from top buttons */
body.mobile #measure-panel {
  top: auto;
  bottom: 60px;
  left: 10px;
  right: auto;
  width: auto;
  max-width: min(260px, calc(100vw - 24px));
  transform: none;
}

/* Orient button: below measure-btn in top-right cluster */
body.mobile #orient-btn {
  display: flex;
  position: fixed;
  top: 140px;
  right: 14px;
  z-index: 60;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(5, 10, 25, 0.75);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: rgba(255, 255, 255, 0.5);
  font-size: 18px;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  bottom: auto;
  left: auto;
}

body.mobile #orient-btn.active {
  color: #60a5fa;
  border-color: rgba(96, 165, 250, 0.5);
  background: rgba(96, 165, 250, 0.08);
}

/* Orient popup: floats to the left of the button cluster */
body.mobile #mobile-orient-popup {
  position: fixed;
  top: 120px;
  right: 60px;
  z-index: 60;
  background: rgba(4, 8, 22, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  padding: 10px 12px;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

body.mobile #mobile-orient-popup.open {
  display: flex;
}

/* Phase bar: move to top on mobile */
body.mobile #phase-bar {
  bottom: auto;
  top: 64px;
  left: 50%;
  transform: translateX(-50%);
}

/* Search: 25% narrower on mobile */
body.mobile #search-wrap {
  width: calc((100vw - 100px) * 0.75);
  opacity: 1;
}

/* Float buttons: top-right cluster */
body.mobile #music-btn {
  top: 14px;
  right: 14px;
  bottom: auto;
  left: auto;
}
body.mobile #auto-rotate-btn {
  top: 56px;
  right: 14px;
  bottom: auto;
  left: auto;
}
body.mobile #measure-btn {
  top: 98px;
  right: 14px;
  bottom: auto;
  left: auto;
}
body.mobile #moon-info-btn {
  display: flex;
  position: fixed;
  top: 182px;
  right: 14px;
  bottom: auto;
  left: auto;
  z-index: 60;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(5, 10, 25, 0.75);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: rgba(255, 255, 255, 0.55);
  font-style: normal;
  font-size: 16px;
  font-family: 'Bookerly', Georgia, serif;
  font-weight: bold;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s, background 0.2s;
}

body.mobile #moon-info-btn.active {
  color: #60a5fa;
  border-color: rgba(96, 165, 250, 0.5);
  background: rgba(96, 165, 250, 0.08);
}

body.mobile #night-btn {
  position: fixed;
  top: 224px;
  right: 14px;
  bottom: auto;
  left: auto;
}

/* ── Flip (tonight) button — phase mode only ─────────────────────────────── */
body.mobile #flip-btn {
  display: none; /* shown via JS when phase mode + scored features exist */
  position: fixed;
  bottom: 96px;
  right: 14px;
  z-index: 60;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(5, 10, 25, 0.75);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: rgba(255, 255, 255, 0.55);
  font-size: 18px;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s, background 0.2s;
}
body.mobile #flip-btn.active {
  color: #fbbf24;
  border-color: rgba(251, 191, 36, 0.5);
  background: rgba(251, 191, 36, 0.12);
}
body.mobile #flip-btn.flip-btn-disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

/* ── Flip box internals ──────────────────────────────────────────────────── */
.flip-title {
  font-size: 11px;
  color: rgba(255,255,255,0.35);
  text-align: center;
  margin-bottom: 6px;
  letter-spacing: 0.02em;
}
.flip-pills {
  display: flex;
  gap: 4px;
  margin-bottom: 6px;
  justify-content: center;
}
.flip-pill {
  font-family: 'Assistant', sans-serif;
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 20px;
  border: 1px solid rgba(255,255,255,0.2);
  background: transparent;
  color: rgba(255,255,255,0.45);
  cursor: pointer;
}
.flip-pill.active {
  background: rgba(255,255,255,0.12);
  color: rgba(255,255,255,0.85);
  border-color: rgba(255,255,255,0.4);
}
.flip-newmoon {
  font-size: 12px;
  color: rgba(255,255,255,0.5);
  text-align: center;
  padding: 6px 4px;
  line-height: 1.4;
}
.flip-name {
  font-size: 15px;
  font-weight: 600;
  color: rgba(255,255,255,0.9);
  text-align: center;
  margin-bottom: 2px;
}
.flip-meta {
  font-size: 12px;
  color: rgba(255,255,255,0.45);
  text-align: center;
  margin-bottom: 6px;
}
.flip-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.flip-arrow {
  font-size: 16px;
  background: transparent;
  border: none;
  color: rgba(255,255,255,0.6);
  cursor: pointer;
  padding: 2px 6px;
}
.flip-counter {
  font-size: 12px;
  color: rgba(255,255,255,0.35);
}

/* ── Flip box — same position/size as info-panel, overlays it when active ── */
body.mobile #flip-box {
  display: none; /* shown via JS when flip mode active */
  position: fixed;
  bottom: 60px;
  left: 14px;
  z-index: 61; /* one above info-panel */
  background: rgba(5, 10, 25, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 10px;
  padding: 8px 20px;
  color: rgba(255, 255, 255, 0.75);
  font-family: 'Assistant', sans-serif;
  font-size: 14px;
  direction: rtl;
  white-space: nowrap;
}

body.mobile #share-btn-mobile {
  display: flex;
  position: fixed;
  bottom: 56px;
  right: 14px;
  z-index: 60;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(5, 10, 25, 0.75);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: rgba(255, 255, 255, 0.4);
  font-size: 16px;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s, background 0.2s;
}

/* Labels: half size on mobile, generous tap padding */
body.mobile .moon-label .heb {
  font-size: calc(var(--label-size, 14) * 0.4px * var(--label-scale, 1));
  padding: 8px 6px;
}
body.mobile .moon-label .lat {
  font-size: calc(var(--label-size, 14) * 0.325px * var(--label-scale, 1));
}
body.mobile .moon-label .dot {
  width: 5px;
  height: 5px;
}

/* ── Desktop/mobile content switching ────────────────────────────────────── */
.mobile-only { display: none; }
body.mobile .mobile-only { display: inline; }
body.mobile .desktop-only { display: none; }

/* ── Welcome screen ───────────────────────────────────────────────────────── */
body.mobile #welcome-box {
  padding: 20px 18px 20px;
  gap: 13px;
  border-radius: 16px;
  margin: 0 auto;
}

body.mobile #welcome-logo img {
  width: 52px !important;
  height: 52px !important;
}

body.mobile #welcome-title {
  font-size: 34px;
  font-weight: 800;
}

body.mobile #wc-carousel {
  height: 230px;
  margin-top: 20px;
}

body.mobile .wc-feature-frame {
  padding: 10px 6px 14px;
  gap: 10px;
  min-height: 140px;
}

body.mobile .wc-feature-icon {
  font-size: 40px;
}

body.mobile .wc-feature-title {
  font-size: 16px;
}

body.mobile .wc-feature-desc {
  font-size: 13px;
  line-height: 1.5;
}

body.mobile .wc-feature-note {
  font-size: 12px;
  padding: 6px 10px;
}

body.mobile #wc-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

body.mobile #welcome-btn,
body.mobile #wc-prev-btn {
  font-size: 14px;
  padding: 9px 18px;
  text-align: center;
  width: 100%;
}

body.mobile #wc-finish-btn {
  font-size: 14px;
  padding: 9px 18px;
}

body.mobile #wc-dots {
  gap: 4px;
  margin-bottom: 10px;
}

body.mobile #welcome-no-show {
  font-size: 12px;
}

body.mobile #welcome-credit {
  font-size: 10px;
}


body.mobile #splash-subtitle {
  font-size: 21px;
}

body.mobile #splash-sub,
body.mobile #splash-version {
  font-size: 15px;
}

body.mobile #mobile-zoom {
  display: block;
  position: fixed;
  top: 32px;
  transform: translateY(-50%);
  left: 10px;
  z-index: 60;
  font-family: 'Roboto Slab', serif;
  font-size: 13px;
  font-weight: 300;
  color: rgba(255, 255, 255, 0.35);
  pointer-events: none;
  letter-spacing: 0.04em;
}

body.mobile #fullscreen-btn {
  position: fixed;
  top: 52px;
  left: 10px;
  bottom: auto;
  width: 28px;
  height: 28px;
  font-size: 13px;
}

body.mobile #welcome-grid {
  grid-template-columns: 1fr;
  gap: 7px;
}

body.mobile .wc-item {
  padding: 7px 10px;
}

body.mobile .wc-text {
  font-size: 11px;
}


body.mobile #welcome-note {
  font-size: 13px;
}

body.mobile #welcome-btn {
  font-size: 15px;
  padding: 10px 32px;
  width: 100%;
}

/* Tighter Hebrew/Latin spacing on mobile */
body.mobile .moon-label .lat {
  margin-top: -5px;
}

/* ── Scope + filter row ───────────────────────────────────────────────────── */
#drawer-filter-row {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  gap: 16px;
  direction: rtl;
}

#mobile-scope-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* ── Filter panel inside drawer ───────────────────────────────────────────── */
body.mobile #filter-panel {
  position: static;
  transform: none;
  background: none;
  border: none;
  border-radius: 0;
  padding: 0;
  width: 100%;
  display: grid;
  grid-template-columns: auto auto;
  gap: 6px 28px;
  direction: rtl;
  justify-content: start;
}

body.mobile .filter-title {
  grid-column: 1 / -1;
  text-align: right;
  font-size: 10px;
  color: rgba(255,255,255,0.4);
  margin-bottom: 2px;
}

/* Crater + sub-checkbox side by side in one grid cell */
body.mobile .filter-crater-wrap {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 6px;
  direction: rtl;
}

body.mobile .filter-sub {
  padding-right: 0;
  font-size: 10px;
  white-space: nowrap;
}

/* ── Bottom drawer ────────────────────────────────────────────────────────── */
#mobile-drawer {
  display: none;
}

body.mobile #mobile-drawer {
  display: flex;
  flex-direction: column;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 65;
  background: rgba(4, 8, 22, 0.9);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 18px 18px 0 0;
  transform: translateY(calc(100% - 48px));
  transition: transform 0.35s cubic-bezier(0.32, 0.72, 0, 1);
  max-height: 72vh;
}

body.mobile #mobile-drawer.open {
  transform: translateY(0);
}

#drawer-handle {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px 0 8px;
  cursor: pointer;
  flex-shrink: 0;
  gap: 6px;
}

#drawer-handle-bar {
  width: 36px;
  height: 4px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.25);
}

#drawer-handle-label {
  font-family: 'Assistant', sans-serif;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.35);
  letter-spacing: 0.08em;
}

#drawer-body {
  overflow-y: auto;
  padding: 12px 20px 28px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  -webkit-overflow-scrolling: touch;
}

/* Drawer section headers */
.drawer-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.drawer-section-title {
  font-family: 'Assistant', sans-serif;
  font-size: 10px;
  font-weight: 400;
  letter-spacing: 0.1em;
  color: rgba(255, 255, 255, 0.3);
  text-transform: uppercase;
  direction: rtl;
}

/* Horizontal slider rows inside drawer */
.drawer-slider-row {
  display: flex;
  align-items: center;
  gap: 12px;
  direction: rtl;
}

.drawer-slider-row span {
  font-family: 'Assistant', sans-serif;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.6);
  white-space: nowrap;
  min-width: 72px;
}

.drawer-slider-row input[type="range"] {
  flex: 1;
  height: 4px;
  accent-color: #60a5fa;
  cursor: pointer;
}

#d-warmth { accent-color: #fb923c; }

/* ── Drawer reset button ──────────────────────────────────────────────────── */
.drawer-reset-row {
  display: flex;
  direction: rtl;
  justify-content: flex-start;
}

#drawer-reset-btn {
  font-family: 'Assistant', sans-serif;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.35);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  padding: 5px 12px;
  cursor: pointer;
  letter-spacing: 0.04em;
}

#drawer-reset-btn:active {
  background: rgba(255, 255, 255, 0.12);
  color: rgba(255, 255, 255, 0.6);
}

/* ── Sensitivity hint box ────────────────────────────────────────────────── */
@keyframes sens-hint-fadein {
  from { opacity: 0; transform: translate(-50%, -48%); }
  to   { opacity: 1; transform: translate(-50%, -50%); }
}

#sens-hint-overlay {
  position: fixed;
  inset: 0;
  z-index: 89;
  background: rgba(0, 0, 0, 0.6);
}

#sens-hint-box {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 90;
  width: calc(100vw - 32px);
  max-width: 360px;
  background: rgba(2, 5, 15, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 16px;
  padding: 20px 18px 16px;
  direction: rtl;
  font-family: 'Assistant', sans-serif;
  color: rgba(255, 255, 255, 0.85);
  animation: sens-hint-fadein 0.35s ease forwards;
}

#sens-hint-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

#sens-hint-title {
  font-size: 15px;
  font-weight: 700;
  color: #fbbf24;
  flex: 1;
}

#sens-hint-icon {
  font-size: 42px;
  line-height: 1;
  flex-shrink: 0;
  margin-right: 4px;
  filter: drop-shadow(0 0 6px rgba(251,191,36,0.3));
}

#sens-hint-text {
  font-size: 14px;
  line-height: 1.65;
  margin: 0 0 14px;
}

#sens-hint-skip-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.45);
  margin-bottom: 14px;
  cursor: pointer;
}

#sens-hint-btns {
  display: flex;
  gap: 10px;
}

#sens-hint-btns button {
  flex: 1;
  padding: 9px 0;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(255, 255, 255, 0.07);
  color: rgba(255, 255, 255, 0.8);
  font-family: 'Assistant', sans-serif;
  font-size: 13px;
  cursor: pointer;
}

#sens-hint-go {
  border-color: rgba(96, 165, 250, 0.4) !important;
  color: #60a5fa !important;
}
