/* Phones (narrow, or short when turned sideways): a search bar on top, the tabs and Menu along
   the bottom, everything else in the menu sheet. "Sideways" needs the orientation too: a small
   iPhone held upright in Safari is under 500px tall as well. app/mobile.js sets .compact on <html> and moves the pieces. */
.mnav { display: none; }
.msheet[hidden] { display: none; }

:root.compact { --nav-h: calc(62px + env(safe-area-inset-bottom, 0px)); }

/* top: the search bar alone; the tabs move to the bottom bar */
.compact header.top { padding-top: max(10px, env(safe-area-inset-top, 0px)); gap: 8px; }
.compact header.top::before { inset: 0 0 -24px; }
.compact .modes { display: none; }
.compact .search { flex: 1 1 100%; max-width: none; margin: 0; order: 0; }
.compact .search input { height: 46px; border-radius: 23px; font-size: 16px; } /* 16px keeps iPhone from zooming in */
.compact .search > svg { top: 15px; }
.compact .results { top: 52px; }

/* side buttons: just churches near me; Whole Globe sits at the end of the search bar */
.compact .ctrls > :not(#nearBtn) { display: none !important; }
.globe-btn { display: none; }
.compact .globe-btn {
  display: grid; place-items: center; position: absolute; z-index: 2; right: 5px; top: 5px; width: 36px; height: 36px;
  border-radius: 50%; border: 0; background: transparent; cursor: pointer;
}
.compact .globe-btn:hover { background: rgba(232, 184, 74, 0.14); }
.compact .search .globe-btn svg { position: static; width: 20px; height: 20px; stroke: var(--ink-soft); fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.compact .search input { padding-right: 46px; }
[dir="rtl"].compact .globe-btn { right: auto; left: 5px; }
[dir="rtl"].compact .search input { padding: 0 40px 0 46px; }
.compact .ctrls { bottom: calc(var(--nav-h) + 12px); }

/* bottom tabs */
.compact .mnav {
  display: flex; position: fixed; z-index: 6; left: 0; right: 0; bottom: 0;
  padding: 6px max(6px, env(safe-area-inset-right, 0px)) max(8px, env(safe-area-inset-bottom, 0px)) max(6px, env(safe-area-inset-left, 0px));
  background: color-mix(in srgb, var(--panel-solid) 94%, transparent); border-top: 1px solid var(--line);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
}
.mnav button {
  flex: 1 1 0; min-width: 0; display: grid; justify-items: center; gap: 3px; padding: 4px 2px; border: 0; background: none;
  color: var(--ink-soft); font-size: 11px; font-weight: 500; cursor: pointer; border-radius: 12px;
}
.mnav button > span:last-child { max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mnav svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.mnav .ic { font-size: 19px; line-height: 22px; height: 22px; }
.mnav button[aria-pressed="true"], .mnav button[aria-expanded="true"] { color: var(--gold); }

/* the floating cards and side buttons sit above the bar */
.compact .float-card, .compact .life { bottom: calc(var(--nav-h) + 8px); }
.compact .life { left: max(8px, env(safe-area-inset-left, 0px)); right: max(8px, env(safe-area-inset-right, 0px)); }  /* the whole width */
.compact body.tour-on .ctrls { bottom: calc(var(--tour-h, 0px) + var(--nav-h) + 18px); }
.compact .toast { top: calc(var(--search, 56px) + 12px); }

/* the menu sheet */
.compact .msheet { position: fixed; inset: 0; z-index: 14; background: rgba(0, 0, 0, 0.45); }
.ms-box {
  position: absolute; left: 0; right: 0; bottom: 0; max-height: 86%; overflow-y: auto; overscroll-behavior: contain;
  display: grid; gap: 18px; align-content: start;
  padding: 20px max(18px, env(safe-area-inset-right, 0px)) calc(18px + env(safe-area-inset-bottom, 0px)) max(18px, env(safe-area-inset-left, 0px));
  background: var(--panel-solid); border: 1px solid var(--line); border-bottom: 0; border-radius: 22px 22px 0 0; box-shadow: 0 -20px 60px #000b;
  animation: msUp .32s cubic-bezier(.2,.8,.2,1);
}
@keyframes msUp { from { transform: translateY(40%); opacity: 0; } }
.ms-x { position: absolute; top: 12px; right: 12px; width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--line); background: none; display: grid; place-items: center; cursor: pointer; }
.ms-x svg { width: 16px; height: 16px; stroke: var(--ink); stroke-width: 2; }
[dir="rtl"] .ms-x { right: auto; left: 12px; }
.ms-box .brand { padding-right: 44px; }
.ms-box .brand h1 { font-size: 17px; text-shadow: none; }
.ms-box .brand p { text-shadow: none; }
.ms-sect:empty { display: none; }
.ms-sect .chips { flex-wrap: wrap; overflow: visible; }
.ms-sect .chips .lbl { text-shadow: none; width: 100%; }
.ms-sect .chips .chip { background: rgba(255, 255, 255, 0.03); }
.ms-acts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.ms-acts button {
  display: flex; align-items: center; gap: 10px; min-height: 46px; padding: 8px 12px; border-radius: 12px; border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03); color: var(--ink); font-size: 13px; text-align: start; line-height: 1.25; cursor: pointer;
}
.ms-acts button:hover { border-color: color-mix(in srgb, var(--gold) 50%, transparent); }
.ms-acts button[aria-pressed="true"] { background: rgba(232, 184, 74, 0.14); }
.ms-acts svg { width: 18px; height: 18px; flex: none; stroke: var(--gold-soft); fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.ms-acts .ic { width: 18px; flex: none; text-align: center; color: var(--gold); font-size: 16px; }
.ms-acts button[data-n]:not([data-n=""])::after { content: attr(data-n); margin-inline-start: auto; min-width: 20px; padding: 0 6px; border-radius: 10px; background: var(--gold); color: #1a1406; font-size: 11px; font-weight: 600; line-height: 20px; text-align: center; }
body.bible-mode .ms-acts .church-only { display: none; }
.ms-picks { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 18px; }
.ms-picks .langpick select { max-width: 200px; }
.ms-picks .themepick select { font-size: 13px; }
.ms-picks .themepick svg { width: 16px; height: 16px; }
.msheet .foot { position: static; padding: 0; pointer-events: auto; gap: 8px 16px; line-height: 1.5; }
.msheet .foot::before { display: none; }
.msheet .foot button { font-size: 12.5px; }

/* the details card stops above the tabs, so they stay in reach */
@media (max-width: 640px) { .compact .card { bottom: calc(var(--nav-h) + 6px); max-height: calc(100% - var(--nav-h) - 74px); } }

/* phones on their side: the tabs become a rail down the left edge, the menu a side panel */
@media (max-height: 500px) and (orientation: landscape) {
  :root.compact { --nav-h: 0px; --rail: calc(74px + env(safe-area-inset-left, 0px)); }
  .compact header.top { padding-left: calc(var(--rail) + 8px); }
  .compact .search { max-width: 400px; margin-right: auto; }
  .compact .search input { height: 42px; }
  .compact .search > svg { top: 13px; }
  .compact .results { top: 48px; max-height: calc(100vh - 80px); }
  .compact .mnav {
    top: 0; bottom: 0; right: auto; width: var(--rail); flex-direction: column; justify-content: center; gap: 4px;
    padding: max(8px, env(safe-area-inset-top, 0px)) 4px max(8px, env(safe-area-inset-bottom, 0px)) max(4px, env(safe-area-inset-left, 0px));
    border-top: 0; border-right: 1px solid var(--line);
  }
  .mnav button { flex: none; padding: 8px 2px; font-size: 10.5px; }
  .mnav button > span:last-child { white-space: normal; line-height: 1.15; text-align: center; }
  .mnav button[aria-pressed="true"] { background: rgba(232, 184, 74, 0.12); }
  .compact .ctrls { bottom: max(12px, env(safe-area-inset-bottom, 0px)); grid-auto-flow: column; }
  .compact .card { width: min(420px, calc(100vw - var(--rail) - 120px)); }
  .compact .card .hero { height: 110px; }
  .compact .float-card, .compact .life, .compact .favs { left: calc(var(--rail) + 10px); }
  .compact .life { right: max(10px, env(safe-area-inset-right, 0px)); }
  .compact .globe-btn { top: 3px; }
  .compact .life { bottom: max(10px, env(safe-area-inset-bottom, 0px)); }
  .compact .life-now { display: none; }  /* the moment's story is in its card */
  .compact .viewmenu { top: 8px !important; bottom: auto !important; left: calc(var(--rail) + 10px) !important; right: auto !important; max-height: calc(100% - 16px); overflow-y: auto; }
  .ms-box {
    left: max(8px, env(safe-area-inset-left, 0px)); right: auto; top: 8px; bottom: 8px; width: min(420px, calc(100vw - 16px)); max-height: none;
    border: 1px solid var(--line); border-radius: 18px; animation-name: msIn;
  }
  [dir="rtl"] .ms-box { left: auto; right: max(8px, env(safe-area-inset-right, 0px)); }
}
@keyframes msIn { from { transform: translateX(-30%); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .ms-box { animation: none; } }
@media (max-width: 640px) { .compact .viewmenu { bottom: calc(var(--nav-h) + 8px) !important; } }
@media (max-width: 640px) {
  .compact .favs { bottom: calc(var(--nav-h) + 6px); max-height: calc(100% - var(--nav-h) - 74px); }
  .compact body.sheet-up .ctrls { display: none; }  /* an open card or list has its own close button */
}

/* the side buttons say what they do: phones have no hover tips */
.ctrls .lbl { display: none; }
.compact .ctrls { justify-items: end; }
.compact .ctrls button { width: auto; height: 40px; border-radius: 20px; padding: 0 14px 0 11px; display: inline-flex; align-items: center; gap: 7px; color: var(--ink); font-size: 12.5px; font-weight: 500; white-space: nowrap; }
.compact .ctrls .lbl { display: inline; }

/* Life of Jesus on an upright phone: a slim strip low on the screen, so the globe stays in view.
   The moment's story, its reading and the rest are a tap away on the title or More. */
@media (max-width: 640px) {
  .compact .life { padding: 8px 8px 4px; gap: 6px; }
  .compact .life-now { align-items: center; gap: 8px; flex-wrap: nowrap; }
  .compact .ln-txt .kick, .compact .ln-txt p { display: none; }
  .compact .ln-txt h2 { margin: 0; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .compact .ln-txt h2 small { display: none; }  /* the place is on the card below */
  .compact .ln-txt h2 .linkish { display: block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: start; }
  .compact .ln-ctl button { width: 32px; height: 32px; }
  .compact .ln-ctl button.ro-toggle { width: 32px; padding: 0; border-radius: 50%; justify-content: center; }
  .compact .ln-ctl button.ro-toggle span { display: none; }  /* the beads alone: the row has to fit */
  .compact .ln-open { display: inline-flex; height: 30px; padding: 0 12px; font-size: 12.5px; }  /* the story is behind it now */
  .compact .life-track { gap: 10px; }
  .compact .life-track .era-h { display: none; }  /* each card already shows where it belongs */
  .compact .life-track .ev { width: 112px; padding: 5px 7px; }
  .compact .life-track .ev .tt { font-size: 12px; min-height: 0; -webkit-line-clamp: 2; }
}

/* a guided tour on an upright phone: a slim strip, the stop's story a tap on its name away */
@media (max-width: 640px) {
  .compact #tourCard { padding: 10px 12px 10px; gap: 6px; }
  .compact #tourCard .kick { padding-right: 30px; }
  .compact #tourCard h2 { font-size: 16px; padding-right: 0; }
  .compact #tourCard h2 .more { cursor: pointer; display: flex; align-items: center; gap: 6px; max-width: 100%; }
  .compact #tourCard h2 .more::after { content: ''; flex: none; width: 7px; height: 7px; margin-top: -3px; border: solid var(--ink-soft); border-width: 0 1.8px 1.8px 0; transform: rotate(45deg); transition: transform .2s; }
  .compact #tourCard.more h2 .more::after { transform: rotate(-135deg); margin-top: 3px; }
  .compact #tourCard .where, .compact #tourCard p, .compact #tourCard .dots { display: none; }
  .compact #tourCard.more .where, .compact #tourCard.more p { display: block; }
  .compact #tourCard p { -webkit-line-clamp: unset; max-height: 30vh; overflow-y: auto; }
  .compact #tourCard .nav .btn { height: 34px; }
}

/* the number of saved churches on the Menu tab */
.mnav #mnavMenu { position: relative; }
.mnav #mnavMenu[data-n]:not([data-n=""])::after {
  content: attr(data-n); position: absolute; top: 0; left: calc(50% + 6px); min-width: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--gold); color: #1a1406; font-size: 10.5px; font-weight: 700; line-height: 18px; text-align: center;
}

/* the menu in four parts: Find a Church, My Churches, Explore, Settings */
.ms-h { margin: 6px 0 -8px; font-size: 11px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--gold-soft); }
.ms-h[hidden], .ms-acts[hidden] { display: none; }
.ms-box > .ms-h ~ .ms-h { padding-top: 14px; border-top: 1px solid var(--line); }
.ms-sect .chips .lbl { display: none; }  /* the section heading names them */

/* a short line under each menu item that says what it does (phones have no hover tips) */
.ms-acts .ms-t { display: grid; gap: 2px; min-width: 0; }
.ms-acts .ms-hint { font-size: 11.5px; line-height: 1.3; color: var(--ink-faint); }
.ms-acts button { align-items: center; padding-block: 10px; }
.lp-name { display: none; }
.ms-picks .langpick { height: auto; display: grid; gap: 4px; }
.ms-picks .langpick .lp-name { display: block; font-size: 12px; line-height: 16px; color: var(--ink-soft); }
.ms-picks .langpick svg { top: 33px; }

/* the first section is the open tab's own: Find a Church, or the Life of Jesus / Bible Locations filters */
.ms-find .for-jesus, .ms-find .for-bible, body.bible-mode .ms-find .for-churches { display: none; }
body.jesus-mode .ms-find .for-jesus, body.bible-mode:not(.jesus-mode) .ms-find .for-bible { display: inline; }
body.bible-mode .ms-acts:not(:has(> button:not(.church-only))) { display: none; }
.ms-empty { margin: -4px 0 0; font-size: 12.5px; line-height: 1.4; color: var(--ink-faint); }
.ms-empty[hidden] { display: none; }
