/* ============================================================
 * Resource Guide — Mobile chrome (≤879px)
 *
 * Shared topbar + peeking bottom sheet, used by the home page and
 * every section page. Hidden on desktop.
 *
 * - .gh-mb-topbar  : thin fixed top bar (back link + town pill)
 * - .gh-mb-sheet   : peeking bottom sheet (handle + trigger + topics)
 * - .gh-mb-scrim   : backdrop while sheet is open
 *
 * Home-specific hero/canvas overrides live in guide-home.css.
 * Section-page specific overrides live in guide-deep.css.
 * ============================================================ */

.gh-mb-topbar,
.gh-mb-sheet,
.gh-mb-scrim { display: none; }

@media (max-width: 879px) {

  /* Peek height: visible strip when sheet is collapsed (handle + trigger). Shared with guide-home.css. */
  body.gh-body {
    --gh-mb-sheet-peek: 130px;
  }

  /* ----- Top bar (back + edition on one line) ----- */
  .gh-mb-topbar {
    position: fixed; top: 0; left: 0; right: 0; z-index: 25;
    display: flex; align-items: center; justify-content: space-between;
    gap: 0.6rem;
    padding: calc(env(safe-area-inset-top, 0px) + 0.55rem) 1.1rem 0.55rem;
    color: #fff;
    pointer-events: none;
    background: linear-gradient(to bottom, rgba(13,58,68,0.55), rgba(13,58,68,0));
  }
  .gh-mb-topbar > * { pointer-events: auto; }

  body.gh-deep .gh-mb-topbar {
    background: var(--color-accent, #1a5f6d);
    box-shadow: 0 1px 6px rgba(0,0,0,0.18);
  }

  .gh-mb-topbar__back {
    display: inline-flex; align-items: center; gap: 0.4rem;
    color: var(--color-golden, #d4a847);
    text-decoration: none;
    font-size: clamp(0.75rem, 2.4vw, 1.05rem); font-weight: 600;
    letter-spacing: 0.16em; text-transform: uppercase;
    text-shadow: 0 1px 6px rgba(0,0,0,0.55);
    padding: 0.2rem 0;
    flex: 1 1 auto;
    min-width: 0;
  }
  .gh-mb-topbar__back-arrow { font-size: 1em; line-height: 1; flex: 0 0 auto; }
  .gh-mb-topbar__back-label {
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  }
  .gh-mb-topbar__edition {
    margin: 0;
    font-size: clamp(0.68rem, 2.1vw, 0.95rem); letter-spacing: 0.14em; text-transform: uppercase;
    color: rgba(255,255,255,0.92);
    text-shadow: 0 1px 6px rgba(0,0,0,0.55);
    font-weight: 500;
    white-space: nowrap;
    flex: 0 0 auto;
  }
  .gh-mb-topbar__title {
    font-family: 'Playfair Display', Georgia, serif;
    font-size: 0.95rem; font-weight: 600;
    color: #fff;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    flex: 1 1 auto; text-align: center;
    margin: 0 0.4rem;
  }
  .gh-mb-town {
    appearance: none; border: 0; cursor: pointer;
    background: rgba(255,255,255,0.12);
    backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
    color: rgba(255,255,255,0.95);
    font: inherit; font-size: 0.78rem;
    padding: 0.35rem 0.65rem;
    border-radius: 999px;
    display: inline-flex; align-items: center; gap: 0.3rem;
    max-width: 56vw;
    flex: 0 0 auto;
  }
  body.gh-deep .gh-mb-town { background: rgba(255,255,255,0.16); }
  .gh-mb-town__pin { font-size: 0.85rem; }
  .gh-mb-town__value {
    font-weight: 600;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  }
  .gh-mb-town__caret { opacity: 0.85; }

  /* ----- Scrim ----- */
  .gh-mb-scrim {
    display: block;
    position: fixed; inset: 0;
    background: rgba(13, 58, 68, 0.45);
    opacity: 0; visibility: hidden;
    transition: opacity 0.25s ease, visibility 0.25s ease;
    z-index: 49;
  }
  .gh-mb-scrim.is-on { opacity: 1; visibility: visible; }

  /* ----- Peeking bottom sheet ----- */
  .gh-mb-sheet {
    display: flex; flex-direction: column;
    position: fixed; left: 0; right: 0; bottom: 0;
    background: var(--color-bg-cream, #faf7f2);
    color: var(--color-text-primary, #2c2416);
    border-top-left-radius: 20px;
    border-top-right-radius: 20px;
    box-shadow: 0 -12px 40px rgba(0,0,0,0.32);
    max-height: 88vh;
    transform: translateY(calc(100% - var(--gh-mb-sheet-peek, 130px)));
    transition: transform 0.32s cubic-bezier(0.2, 0.8, 0.2, 1);
    z-index: 50;
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  .gh-mb-sheet.is-open { transform: translateY(0); }

  /*
   * Deep section pages: collapsed sheet is only handle + peek row (body height 0).
   * translateY(calc(100% - var(--gh-mb-sheet-peek))) assumes the sheet is taller than
   * --gh-mb-sheet-peek; when the real height is slightly larger than the variable, the
   * transform nudges the sheet down and leaves a gap above the viewport bottom. No
   * translate is needed when the full sheet is already peek-sized.
   */
  .gh-mb-sheet--deep:not(.is-open) {
    transform: translate3d(0, 0, 0);
  }

  .gh-mb-sheet__handle-wrap {
    appearance: none; background: transparent; border: 0; cursor: pointer;
    padding: 0.7rem 0 0.4rem;
    display: flex; justify-content: center;
    width: 100%;
  }
  .gh-mb-sheet__handle {
    width: 44px; height: 4px; border-radius: 2px;
    background: rgba(26, 95, 109, 0.28);
  }
  .gh-mb-sheet__trigger {
    appearance: none; background: transparent; border: 0; cursor: pointer;
    width: 100%; text-align: left;
    padding: 0.2rem 1.15rem 0.6rem;
    display: flex; align-items: center; justify-content: space-between;
    gap: 0.75rem;
    font: inherit;
  }
  .gh-mb-sheet__trigger-text {
    display: flex; flex-direction: column; gap: 0.1rem;
  }
  .gh-mb-sheet__trigger-eyebrow {
    font-size: 0.65rem; letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--color-text-secondary, #5a4f3a);
    font-weight: 600;
  }
  .gh-mb-sheet__trigger-title {
    font-family: 'Playfair Display', Georgia, serif;
    font-size: 1.15rem; line-height: 1.2;
    color: var(--color-accent-dark, #144a55);
    font-weight: 700;
  }
  .gh-mb-sheet__trigger-bullet { opacity: 0.5; }
  .gh-mb-sheet__trigger-caret {
    width: 36px; height: 36px; border-radius: 50%;
    background: var(--color-accent, #1a5f6d); color: #fff;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 1.1rem;
    flex: 0 0 auto;
    transition: transform 0.25s ease;
  }
  .gh-mb-sheet.is-open .gh-mb-sheet__trigger-caret { transform: rotate(180deg); }

  .gh-mb-sheet__body {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 0 0 0.5rem;
    flex: 1 1 auto;
  }

  /* Deep pages: when collapsed, hide the scrollable body so topic rows (e.g. first category in the list) do not show under the peek. */
  .gh-mb-sheet--deep:not(.is-open) .gh-mb-sheet__body {
    flex: 0 0 0;
    max-height: 0;
    min-height: 0;
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
    padding: 0;
    margin: 0;
    border: 0;
  }
  .gh-mb-sheet--deep.is-open .gh-mb-sheet__body {
    flex: 1 1 auto;
    max-height: none;
    overflow-y: auto;
    opacity: 1;
    pointer-events: auto;
    padding: 0 0 0.5rem;
  }

  /* ----- Topics list inside the sheet ----- */
  .gh-mb-topics {
    list-style: none; margin: 0; padding: 0 0.75rem;
    display: flex; flex-direction: column;
  }
  .gh-mb-topic {
    display: grid;
    grid-template-columns: 32px 1fr auto;
    align-items: center;
    gap: 0.85rem;
    padding: 0.7rem 0.7rem;
    color: var(--color-text-primary, #2c2416);
    text-decoration: none;
    border-radius: 10px;
    border-left: 3px solid transparent;
    margin-bottom: 0.1rem;
  }
  .gh-mb-topic:active { background: rgba(26, 95, 109, 0.06); }
  .gh-mb-topic--current {
    background: rgba(26, 95, 109, 0.06);
  }
  .gh-mb-topic--current .gh-mb-topic__title {
    color: var(--color-accent-dark, #144a55);
  }
  .gh-mb-topic__icon {
    font-size: 1.2rem; color: var(--color-accent, #1a5f6d);
    display: inline-flex; align-items: center; justify-content: center;
  }
  .gh-mb-topic__title {
    font-size: 1rem; font-weight: 600; line-height: 1.2;
  }
  .gh-mb-topic__count {
    font-size: 0.85rem; font-weight: 500;
    color: var(--color-text-secondary, #5a4f3a);
    min-width: 1.5rem; text-align: right;
  }
  .gh-mb-topic[data-c="0"] { border-left-color: var(--section-0); }
  .gh-mb-topic[data-c="0"] .gh-mb-topic__icon { color: var(--section-0-dark); }
  .gh-mb-topic[data-c="1"] { border-left-color: var(--section-1); }
  .gh-mb-topic[data-c="1"] .gh-mb-topic__icon { color: var(--section-1-dark); }
  .gh-mb-topic[data-c="2"] { border-left-color: var(--section-2); }
  .gh-mb-topic[data-c="2"] .gh-mb-topic__icon { color: var(--section-2-dark); }
  .gh-mb-topic[data-c="3"] { border-left-color: var(--section-3); }
  .gh-mb-topic[data-c="3"] .gh-mb-topic__icon { color: var(--section-3-dark); }
  .gh-mb-topic[data-c="4"] { border-left-color: var(--section-4); }
  .gh-mb-topic[data-c="4"] .gh-mb-topic__icon { color: var(--section-4-dark); }
  .gh-mb-topic[data-c="5"] { border-left-color: var(--section-5); }
  .gh-mb-topic[data-c="5"] .gh-mb-topic__icon { color: var(--section-5-dark); }
  .gh-mb-topic[data-c="6"] { border-left-color: var(--section-6); }
  .gh-mb-topic[data-c="6"] .gh-mb-topic__icon { color: var(--section-6-dark); }
  .gh-mb-topic[data-c="7"] { border-left-color: var(--section-7); }
  .gh-mb-topic[data-c="7"] .gh-mb-topic__icon { color: var(--section-7-dark); }
  .gh-mb-topic--coming .gh-mb-topic__count {
    font-size: 0.65rem; letter-spacing: 0.08em; text-transform: uppercase;
    background: rgba(212, 168, 71, 0.18); color: var(--color-golden, #d4a847);
    padding: 0.15rem 0.5rem; border-radius: 999px;
    font-weight: 700;
  }

  .gh-mb-sheet__footer {
    margin-top: 0.4rem;
    padding: 0.65rem 1.5rem 0.6rem;
    border-top: 1px solid rgba(26, 95, 109, 0.12);
    display: flex; flex-direction: column; gap: 0.35rem;
  }
  .gh-mb-sheet__footer-link {
    color: var(--color-accent-dark, #144a55);
    font-size: 0.9rem; font-weight: 500;
    text-decoration: none;
    padding: 0.4rem 0;
  }

  /* ----- Deep section pages: category peek + “Choose a category” menu header ----- */
  .gh-mb-sheet--deep:not(.is-open) .gh-mb-sheet__menu-header {
    display: none;
  }
  .gh-mb-sheet--deep.is-open .gh-mb-sheet__peek-row {
    display: none;
  }

  .gh-mb-sheet--deep .gh-mb-sheet__peek-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.15rem 1.15rem 0.65rem;
    width: 100%;
    box-sizing: border-box;
  }

  .gh-mb-sheet--deep .gh-mb-sheet__peek-category {
    appearance: none;
    background: transparent;
    border: 0;
    cursor: pointer;
    font: inherit;
    text-align: left;
    flex: 1 1 auto;
    min-width: 0;
    padding: 0;
    margin: 0;
  }

  .gh-mb-sheet--deep .gh-mb-sheet__peek-category-inner {
    display: grid;
    grid-template-columns: 32px 1fr auto;
    align-items: center;
    gap: 0.85rem;
    width: 100%;
    box-sizing: border-box;
    padding: 0.65rem 0.7rem;
    border-radius: 10px;
    border-left: 3px solid var(--color-golden, #d4a847);
    background: rgba(26, 95, 109, 0.06);
  }
  .gh-mb-sheet--deep .gh-mb-sheet__peek-category-inner--plain {
    grid-template-columns: 32px 1fr;
  }

  .gh-mb-sheet--deep .gh-mb-sheet__peek-category-inner[data-c="0"] { border-left-color: var(--section-0); }
  .gh-mb-sheet--deep .gh-mb-sheet__peek-category-inner[data-c="0"] .gh-mb-sheet__peek-icon { color: var(--section-0-dark); }
  .gh-mb-sheet--deep .gh-mb-sheet__peek-category-inner[data-c="1"] { border-left-color: var(--section-1); }
  .gh-mb-sheet--deep .gh-mb-sheet__peek-category-inner[data-c="1"] .gh-mb-sheet__peek-icon { color: var(--section-1-dark); }
  .gh-mb-sheet--deep .gh-mb-sheet__peek-category-inner[data-c="2"] { border-left-color: var(--section-2); }
  .gh-mb-sheet--deep .gh-mb-sheet__peek-category-inner[data-c="2"] .gh-mb-sheet__peek-icon { color: var(--section-2-dark); }
  .gh-mb-sheet--deep .gh-mb-sheet__peek-category-inner[data-c="3"] { border-left-color: var(--section-3); }
  .gh-mb-sheet--deep .gh-mb-sheet__peek-category-inner[data-c="3"] .gh-mb-sheet__peek-icon { color: var(--section-3-dark); }
  .gh-mb-sheet--deep .gh-mb-sheet__peek-category-inner[data-c="4"] { border-left-color: var(--section-4); }
  .gh-mb-sheet--deep .gh-mb-sheet__peek-category-inner[data-c="4"] .gh-mb-sheet__peek-icon { color: var(--section-4-dark); }
  .gh-mb-sheet--deep .gh-mb-sheet__peek-category-inner[data-c="5"] { border-left-color: var(--section-5); }
  .gh-mb-sheet--deep .gh-mb-sheet__peek-category-inner[data-c="5"] .gh-mb-sheet__peek-icon { color: var(--section-5-dark); }
  .gh-mb-sheet--deep .gh-mb-sheet__peek-category-inner[data-c="6"] { border-left-color: var(--section-6); }
  .gh-mb-sheet--deep .gh-mb-sheet__peek-category-inner[data-c="6"] .gh-mb-sheet__peek-icon { color: var(--section-6-dark); }
  .gh-mb-sheet--deep .gh-mb-sheet__peek-category-inner[data-c="7"] { border-left-color: var(--section-7); }
  .gh-mb-sheet--deep .gh-mb-sheet__peek-category-inner[data-c="7"] .gh-mb-sheet__peek-icon { color: var(--section-7-dark); }
  .gh-mb-sheet--deep .gh-mb-sheet__peek-category-inner--plain {
    border-left-color: var(--color-accent, #1a5f6d);
  }

  .gh-mb-sheet--deep .gh-mb-sheet__peek-icon {
    font-size: 1.2rem;
    color: var(--color-accent, #1a5f6d);
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
  .gh-mb-sheet--deep .gh-mb-sheet__peek-title {
    font-size: 1rem;
    font-weight: 700;
    line-height: 1.2;
    color: var(--color-accent-dark, #144a55);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .gh-mb-sheet--deep .gh-mb-sheet__peek-count {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--color-text-secondary, #5a4f3a);
    min-width: 1.5rem;
    text-align: right;
  }
  .gh-mb-sheet--deep .gh-mb-sheet__peek-count--coming {
    font-size: 0.65rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    background: rgba(212, 168, 71, 0.18);
    color: var(--color-golden, #d4a847);
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    font-weight: 700;
  }

  .gh-mb-sheet--deep .gh-mb-sheet__peek-caret,
  .gh-mb-sheet--deep .gh-mb-sheet__menu-close {
    appearance: none;
    border: 0;
    cursor: pointer;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--color-accent, #1a5f6d);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    flex: 0 0 auto;
    padding: 0;
    margin: 0;
  }

  .gh-mb-sheet--deep .gh-mb-sheet__menu-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.25rem 1.15rem 0.55rem;
    position: sticky;
    top: 0;
    z-index: 1;
    background: var(--color-bg-cream, #faf7f2);
  }
  .gh-mb-sheet--deep .gh-mb-sheet__menu-title {
    margin: 0;
    font-family: 'Playfair Display', Georgia, serif;
    font-size: 1.15rem;
    line-height: 1.2;
    color: var(--color-accent-dark, #144a55);
    font-weight: 700;
  }
}
