/* The map-backed frame (Find a masjid): on top of frame.css, for pages whose body has class "frame-map".
   Approved prototype: the map is the whole page; the sky is a card floating on it (on the right under the menu on
   wide screens); the results, the menu and the foot float on it too. Only the body class changes the frame:
   every other page keeps frame.css as it is. */

body.frame-map { height: 100%; overflow: hidden; }
body.frame-map .split { display: block; min-height: 0; }

/* The map: the whole page, behind everything. */
body.frame-map .sheet {
  position: fixed; inset: 0; z-index: 0; margin: 0; padding: 0; border-radius: 0; box-shadow: none; background: var(--line);
}
body.frame-map .sheet-in { max-width: none; height: 100%; }
body.frame-map .finder-map-slot { position: absolute; inset: 0; }
body.frame-map .finder-map-slot .map,
body.frame-map .finder-map-slot .map svg { display: block; width: 100%; height: 100%; }
body.frame-map .map-note {
  position: fixed; left: 50%; transform: translateX(-50%); padding: 2px 8px; border-radius: 999px;
  background: var(--white); font-size: 0.7rem; color: var(--muted); white-space: nowrap;
}

/* The sky: a card on the map, with the title and the search. */
/* One floating card over the map, on every width: no band that stops and shows the map beneath it. */
body.frame-map .stage {
  position: fixed; z-index: 2; top: calc(var(--gutter) * 0.5 + var(--tap) + 8px); left: calc(var(--gutter) * 0.5); right: calc(var(--gutter) * 0.5);
  max-height: calc(100vh - 2 * (var(--gutter) * 0.5) - 120px); overflow-y: auto;
  padding: 0 var(--gutter) 20px; border-radius: var(--radius);
  box-shadow: 0 10px 30px rgb(8 0 77 / 28%);
}
/* Paint the whole scrolling card with one sky; a viewport-sized day overlay
   used to end halfway down long cards and reveal the night background. */
body.frame-map[data-sky="day"] .stage { background: var(--stage-day); }
body.frame-map .stage::before { content: none; }
body.frame-map .stage { --day: 0; }
body.frame-map[data-sky="day"] .stage { --day: 1; }
body.frame-map .sky-art { display: none; }
body.frame-map .stage-in { position: static; }

/* Phones: the foot is a strip above the bottom bar, and the menu is the bar. */
body.frame-map .foot {
  position: fixed; z-index: 2; left: 0; right: 0; bottom: calc(56px + env(safe-area-inset-bottom));
  margin: 0; padding: 0 var(--gutter); border: 0; background: rgb(255 255 255 / 92%);
}
body.frame-map .tabbar { position: fixed; left: 0; right: 0; bottom: 0; }
/* The finder's own stylesheet gives the top bar a white band; on this page the sky card's top bar is the sky. */
body.frame-map .topbar { background: none; height: auto; min-height: 0; box-shadow: none; border: 0; }

@media (min-width: 900px) {
  /* Wide screens: the menu is a capsule at the top right; the sky card floats under it, the foot at the bottom right. */
  body.frame-map .stage {
    top: calc(var(--gutter) * 0.5 + var(--tap) + 12px); left: auto; right: calc(var(--gutter) * 0.5); width: 400px;
    max-height: calc(100vh - 3 * (var(--gutter) * 0.5) - 2 * var(--tap) - 24px);
    padding: 0 24px 24px; border-radius: var(--radius); overflow-y: auto;
  }
  body.frame-map .sky-art { display: block; }
  body.frame-map .nav {
    position: fixed; z-index: 2; top: calc(var(--gutter) * 0.5); right: calc(var(--gutter) * 0.5); margin: 0; padding: 0 10px;
    border-radius: 999px; background: var(--white); box-shadow: 0 6px 20px rgb(8 0 77 / 18%);
  }
  body.frame-map .foot {
    left: auto; right: calc(var(--gutter) * 0.5); bottom: calc(var(--gutter) * 0.5); padding: 2px 16px 0; border-radius: 20px;
    background: var(--white); box-shadow: 0 6px 20px rgb(8 0 77 / 18%);
  }
  body.frame-map .tabbar { display: none; }
}

/* ---------- The logo: no tile. A transparent top row, on the menu line, over the map ---------- */
body.frame-map .topbar {
  position: fixed; z-index: 3; top: calc(var(--gutter) * 0.5); left: calc(var(--gutter) * 0.5); right: calc(var(--gutter) * 0.5);
  height: var(--tap); padding: 0; background: none; box-shadow: none; border: 0; pointer-events: none;
}
body.frame-map .topbar > * { pointer-events: auto; }
body.frame-map .topbar .logo img { filter: drop-shadow(0 1px 3px rgb(8 0 77 / 45%)); }
body.frame-map .topbar .topbar-link { color: var(--ink); text-shadow: 0 1px 3px rgb(255 255 255 / 80%); }
@media (min-width: 900px) {
  /* The menu capsule is at the top right; the logo keeps the top left, on the same line. */
  body.frame-map .topbar { right: auto; width: auto; }
}

/* ---------- Phone: the title tile folds to the search capsule; the search is for quick entry ---------- */
@media (max-width: 899px) {
  /* The card shows the title, search and note; a little of the sun shows over the top of the card. */
  body.frame-map .sky-art { display: block; position: absolute; left: 50%; top: -55px; width: 300px; height: auto; transform: translateX(-50%); z-index: -2; }
  body.frame-map[data-sky].stage-folded .stage { padding: 0; border-radius: 999px; background: var(--white); }
  body.frame-map.stage-folded .stage-in > :not(.topbar, #finder-search),
  body.frame-map.stage-folded #finder-search > :not(form[role="search"]),
  body.frame-map.stage-folded #finder-search .clear-search { display: none; }
  body.frame-map.stage-folded .stage-in > #finder-search { display: block; }
  body.frame-map.stage-folded #finder-search form { margin: 0; }
  body.frame-map.stage-folded #city-query { margin: 0; }
  body.frame-map.js .stage-toggle {
    position: sticky; top: 0; z-index: 1; display: flex; width: fit-content; min-height: 44px;
    margin: 0 0 6px auto; padding: 0 12px;
  }
  body.frame-map.stage-folded .stage-toggle { display: none; }
}
.stage-toggle, .foot-toggle {
  display: inline-flex; align-items: center; justify-content: center; min-height: var(--tap); padding: 0 16px;
  border: 0; border-radius: 999px; background: var(--white); color: var(--ink); font: inherit; font-size: 0.85rem; font-weight: 700; cursor: pointer;
}
.stage-toggle { display: none; }
body.frame-map.js .stage-toggle { display: inline-flex; }
@media (min-width: 900px) { body.frame-map.js .stage-toggle { display: none; } }

/* ---------- The footer: a compact strip that opens to the rest ---------- */
body.frame-map .foot .foot-toggle { margin: 0 0 6px; display: none; }
body.frame-map.js .foot .foot-toggle { display: inline-flex; }
body.frame-map.js .foot .site-social,
body.frame-map.js .foot .foot-links span { display: none; }
body.frame-map.js .foot.open .site-social,
body.frame-map.js .foot.open .foot-links span { display: inline; }
body.frame-map.js .foot.open .site-social { display: flex; }
@media (max-width: 899px) {
  /* Phones: the footer is a drawer above the bottom bar; its strip shows only the toggle until it opens. */
  /* Closed: only a small tab at the bottom right, above the bottom bar. */
  body.frame-map.js .foot {
    position: fixed; z-index: 2; left: auto; right: calc(var(--gutter) * 0.5); bottom: calc(56px + env(safe-area-inset-bottom) + 8px);
    width: auto; margin: 0; padding: 0; border: 0; background: none; box-shadow: none;
  }
  body.frame-map.js .foot .foot-toggle { box-shadow: 0 4px 14px rgb(8 0 77 / 22%); }
  /* Open: the drawer above the bottom bar, full width. */
  body.frame-map.js .foot.open {
    left: calc(var(--gutter) * 0.5); right: calc(var(--gutter) * 0.5); padding: 10px 16px 14px; border-radius: 20px;
    background: var(--white); box-shadow: 0 6px 20px rgb(8 0 77 / 18%); max-height: 70vh; overflow-y: auto;
  }
  /* A phone shows the tab with an arrow, not the word. The word stays for screen readers. */
  body.frame-map.js .foot .foot-toggle { min-width: 56px; min-height: 30px; padding: 0 18px; margin: 0; }
  body.frame-map.js .foot .foot-toggle .toggle-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  body.frame-map.js .foot .foot-toggle::before {
    content: ""; width: 9px; height: 9px; margin-top: 3px; border-left: 2.5px solid var(--ink); border-top: 2.5px solid var(--ink);
    transform: rotate(45deg); transition: transform 0.2s ease;
  }
  body.frame-map.js .foot.open .foot-toggle::before { margin-top: -3px; transform: rotate(225deg); }
  body.frame-map.js .foot .foot-links { display: none; }
  body.frame-map.js .foot.open .foot-links { display: flex; }
}
@media (min-width: 900px) {
  /* Laptop and desktop: the links show; the social row and the credit expand from the toggle. */
  body.frame-map.js .foot .foot-links { display: flex; }
}

/* ---------- The search sits on the sky, with no tile of its own (one card, one map) ---------- */
body.frame-map .search-card { background: none; box-shadow: none; border: 0; padding: 0; margin: 0; max-width: none; }
body.frame-map .search-card label[for="city-query"] {
  position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}
body.frame-map .search-card h2,
body.frame-map .search-card p,
body.frame-map #place-help { color: var(--white); }
body.frame-map .search-card .muted,
body.frame-map #place-help { color: var(--date); }

/* ---------- The search button is an icon inside the search field ---------- */
body.frame-map .search-card form { position: relative; }
body.frame-map .search-card input[type="text"] { padding-right: 90px; }
body.frame-map .search-card .city-search-actions { position: absolute; top: 0; right: 0; bottom: 0; display: flex; align-items: center; padding-right: 8px; }
body.frame-map .search-card .city-search-submit {
  display: inline-flex; align-items: center; justify-content: center; min-width: 70px; min-height: 44px; height: 44px; padding: 0 12px; font-weight: 700;
  border: 0; border-radius: 999px; background: var(--gold); color: var(--ink); cursor: pointer;
}
body.frame-map .search-card .city-search-submit svg { width: 22px; height: 22px; }
body.frame-map .search-card .city-search-submit:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; }

/* Tablets held wide (900-1199): the footer card lifts clear of the bottom edge and keeps its links on one row. */
@media (min-width: 900px) and (max-width: 1199px) {
  body.frame-map .foot { bottom: calc(var(--gutter) * 0.5 + 14px); padding: 6px 14px 4px; }
  body.frame-map.js .foot .foot-links { gap: 0 10px; flex-wrap: nowrap; white-space: nowrap; }
}

/* ---------- Wide screens: the sun fits the card, and the title starts below its rays ---------- */
@media (min-width: 900px) {
  body.frame-map { --art: 400px; }
  /* The top bar is fixed outside the card here, so the title starts at half the art's width (its rays end at about 49%). */
  body.frame-map .now { margin-top: calc(var(--art) * 0.5); }
  /* With results inside it the card can fill the height: stop it above the foot card at the bottom right. */
  body.frame-map .stage { max-height: calc(100vh - 3 * (var(--gutter) * 0.5) - 2 * var(--tap) - 24px - 36px); }
}

/* ---------- Results on the sky: the nearby list and the picked masjid, white on the card ---------- */
body.frame-map .nearby-card, body.frame-map .mosque-card { margin-top: 22px; color: var(--white); }
body.frame-map .nearby-card h2, body.frame-map .mosque-card h2 { margin: 0; color: var(--gold); font-weight: 600; line-height: 1.25; letter-spacing: 0; overflow-wrap: anywhere; }
body.frame-map .nearby-card h2 { font-size: 1.25rem; }
body.frame-map .nearby-card h2:focus { outline: 2px solid var(--gold); outline-offset: 3px; }
/* The sky card is not a bottom sheet here, so the sheet handles are not shown. */
body.frame-map .sheet-handle { display: none; }
body.frame-map .nearby-from { margin: 4px 0 8px; color: var(--date); font-size: 0.875rem; line-height: 1.4; }
body.frame-map :is(.nearby-list, .card-prayers, .card-chips) { margin: 0; padding: 0; list-style: none; }
body.frame-map .nearby-list > li { padding: 2px 0; border-top: 1px solid rgb(255 255 255 / 30%); }
body.frame-map .near-main {
  display: block; width: 100%; min-height: 72px; padding: 8px 0 4px; border: 0; background: none; color: inherit;
  font: inherit; text-align: left; cursor: pointer;
}
body.frame-map .near-main:hover .near-name { text-decoration: underline; text-underline-offset: 3px; }
body.frame-map .near-main:focus-visible, body.frame-map .nearby-all:focus-visible, body.frame-map .card-back:focus-visible,
body.frame-map .card-tabs button:focus-visible, body.frame-map .take-me:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
body.frame-map .near-name { display: block; font-size: 1.125rem; font-weight: 700; line-height: 1.3; overflow-wrap: anywhere; }
body.frame-map .near-meta { display: flex; flex-wrap: wrap; gap: 2px 14px; margin-top: 2px; color: var(--date); font-size: 0.875rem; line-height: 1.4; }
body.frame-map .near-open { display: inline-flex; align-items: center; gap: 6px; color: var(--white); }
/* Open is a filled gold dot, closed a hollow ring: the two states do not differ by colour alone. */
body.frame-map .open-dot { flex: none; align-self: center; width: 10px; height: 10px; border-radius: 50%; background: var(--gold); }
body.frame-map [data-open="false"] > .open-dot { border: 2px solid var(--date); background: none; }
body.frame-map :is(.card-contact, .card-full) a {
  display: inline-flex; align-items: center; min-height: var(--tap); color: var(--white); font-size: 0.875rem; font-weight: 700;
  text-decoration: underline; text-underline-offset: 3px;
}
/* "Show all 20 masjids" under the eight nearest. */
body.frame-map .nearby-all {
  display: block; width: 100%; min-height: var(--tap); padding: 0; border: 0; border-top: 1px solid rgb(255 255 255 / 30%); background: none;
  color: var(--white); font: inherit; font-size: 0.95rem; font-weight: 700; text-align: left; text-decoration: underline; text-underline-offset: 3px; cursor: pointer;
}
body.frame-map .nearby-all[hidden] { display: none; }

/* The picked masjid. */
/* The finder's older stylesheet makes this a white tile; here it is part of the sky card. */
body.frame-map .mosque-card { padding: 0; border: 0; border-radius: 0; background: none; box-shadow: none; overflow: visible; }
body.frame-map .mosque-card .summary { padding: 0; }
body.frame-map .mosque-card:focus { outline: none; }
body.frame-map .card-back {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: var(--tap); padding: 0; border: 0; background: none;
  color: var(--white); font: inherit; font-size: 0.95rem; font-weight: 700; cursor: pointer;
}
body.frame-map .card-back::before {
  content: ""; width: 7px; height: 7px; border-bottom: 2px solid var(--white); border-left: 2px solid var(--white); transform: rotate(45deg);
}
body.frame-map .card-kicker { margin: 8px 0 6px; color: var(--date); font-size: 0.75rem; font-weight: 700; letter-spacing: 0.14em; line-height: 1.4; text-transform: uppercase; }
body.frame-map .mosque-card h2 { margin: 0 0 8px; font-size: 1.6rem; line-height: 1.2; }
body.frame-map .card-status { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px; margin: 0 0 8px; font-size: 0.95rem; line-height: 1.4; }
body.frame-map .card-actions { display: flex; flex-wrap: wrap; gap: 8px; padding: 8px 0 14px; }
body.frame-map .take-me {
  display: inline-flex; align-items: center; justify-content: center; flex: 1 1 auto; min-height: 46px; margin: 0; padding: 8px 18px;
  border: 2px solid var(--gold); border-radius: 999px; background: var(--gold); color: var(--ink); font-size: 0.95rem; font-weight: 700;
  text-decoration: none; white-space: nowrap; cursor: pointer;
}
body.frame-map .take-me.is-quiet { border-color: var(--white); background: none; color: var(--white); }
body.frame-map .mosque-card :is(.card-address, .card-note) { display: block; margin: 0; padding: 0 0 14px; color: var(--white); font-size: 0.95rem; line-height: 1.5; }
body.frame-map .mosque-card a.card-address { text-decoration: underline; text-underline-offset: 3px; }
body.frame-map .card-tabs { display: flex; border-top: 1px solid rgb(255 255 255 / 30%); border-bottom: 1px solid rgb(255 255 255 / 30%); }
body.frame-map .card-tabs[hidden] { display: none; }
body.frame-map .card-tabs button {
  flex: 1 1 0; min-height: var(--tap); padding: 0 8px; border: 0; border-bottom: 3px solid transparent; background: none;
  color: var(--date); font: inherit; font-size: 0.95rem; font-weight: 600; cursor: pointer;
}
body.frame-map .card-tabs button[aria-selected="true"] { border-bottom-color: var(--gold); color: var(--white); font-weight: 700; }
body.frame-map .card-panel { padding: 14px 0 6px; }
body.frame-map .card-panel[hidden] { display: none; }
body.frame-map .card-label { margin: 0 0 6px; color: var(--date); font-size: 0.75rem; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; }
body.frame-map .card-panel .card-label:not(:first-child) { margin-top: 18px; }
body.frame-map .card-prayers li {
  display: grid; grid-template-columns: 22px 1fr auto; align-items: center; gap: 12px; min-height: var(--tap);
  border-bottom: 1px solid rgb(255 255 255 / 30%); font-size: 0.95rem;
}
body.frame-map .card-prayers li:last-child { border-bottom: 0; }
body.frame-map .prayer-name { font-weight: 600; }
body.frame-map .prayer-when { text-align: right; }
body.frame-map .card-hours { margin: 0; }
body.frame-map .card-hours div { display: flex; justify-content: space-between; gap: 12px; padding: 5px 0; font-size: 0.95rem; }
body.frame-map .card-hours dt { font-weight: 600; }
body.frame-map .card-hours dd { margin: 0; text-align: right; }
body.frame-map .card-chips { display: flex; flex-wrap: wrap; gap: 6px; }
body.frame-map .card-chips li { padding: 6px 12px; border: 1px solid rgb(255 255 255 / 40%); border-radius: 999px; font-size: 0.875rem; }
body.frame-map .card-contact { display: flex; flex-wrap: wrap; gap: 4px 20px; margin: 0; }
body.frame-map .card-full { margin: 10px 0 0; }

body.frame-map .mosque-card[data-sheet="peek"] .card-more,
body.frame-map .mosque-card [hidden] { display: none; }
body.frame-map .mosque-card[data-sheet="open"] #masjid-details { display: none; }
body.frame-map .masjid-community { overflow-wrap: anywhere; }
body.frame-map .community-card { border-top: 1px solid rgb(255 255 255 / 30%); padding-block: 12px; }
body.frame-map .community-thread .community-body { color: var(--white); font-size: 1rem; }
body.frame-map .community-card textarea { width: 100%; }
body.frame-map .masjid-community :is(button, summary) { min-height: var(--tap); }
body.frame-map .masjid-community .reactions { display: flex; flex-wrap: wrap; gap: 8px; margin-block: 8px; }
body.frame-map .masjid-community .pill { display: inline-block; padding: 4px 8px; border: 1px solid currentColor; border-radius: 999px; font-size: .875rem; }
body.frame-map .masjid-community button[aria-pressed="true"] { background: var(--gold); color: var(--ink); }
body.frame-map #card-panel-details a { text-decoration: underline; text-underline-offset: 3px; }
@media (max-width: 767px) {
  body.frame-map .stage-in:has(.mosque-card:not([hidden])) > :is(.now, .search-card) { display: none; }
}
body.frame-map .stage .masjid-community form {
  display: grid; gap: 8px; margin-block: 12px; padding: 12px; border-radius: 12px;
  background: var(--white); color: var(--ink);
}
body.frame-map .stage .masjid-community textarea {
  box-sizing: border-box; width: 100%; min-height: 88px; padding: 8px; font: inherit; color: var(--ink);
}
body.frame-map .stage .masjid-community form button {
  width: auto; height: auto; padding: 8px 16px; border-radius: 999px; background: var(--gold);
  color: var(--ink); font: inherit; font-weight: 700; white-space: nowrap;
}

/* The map and its fixed controls stay in place across finder form submissions. */
@view-transition { navigation: none; }

@media (max-width: 899px) {
  body.frame-map:has(#load-map:not([hidden])) .stage {
    bottom: calc(56px + var(--tap) + env(safe-area-inset-bottom) + 76px);
    height: fit-content; max-height: calc(100dvh - var(--gutter) * 0.5 - 2 * var(--tap) - env(safe-area-inset-bottom) - 140px);
  }
  body.frame-map .map-load-label {
    position: absolute; bottom: calc(56px + var(--tap) + env(safe-area-inset-bottom) + 12px);
    left: 50%; transform: translateX(-50%); width: max-content; max-width: calc(100% - 24px);
  }
  body.frame-map .map-actions {
    left: 50%; right: auto; bottom: calc(56px + var(--tap) + env(safe-area-inset-bottom) + 12px);
    transform: translateX(-50%); width: max-content; max-width: calc(100% - 24px); justify-content: center;
  }
  body.frame-map.stage-folded .stage-in > .stage-toggle,
  body.frame-map .stage:has(#nearby-list li, #place-results, #mosque-card:not([hidden])) .stage-toggle { display: none; }
  body.frame-map.stage-folded .stage:has(#nearby-list li) { border-radius: var(--radius); }
  body.frame-map.stage-folded #nearby-masjids:not([hidden]):has(li) {
    display: block; padding: 0 var(--gutter) 12px; background: var(--ink); color: var(--white);
  }
}

body.frame-map .stage .map-status:not(:empty) { position: static; display: block; margin: 8px 0; }
