/* ==========================================================
   App shell for phones (below 900px): bottom tab bar is the main navigation.
   The hamburger is removed there; its links live in the "More" sheet.
   Tablets (900-959px) keep the hamburger because the tab bar is hidden there.
   ========================================================== */

/* 1. Phones: no hamburger, the tab bar takes over */
@media (max-width: 899px) {
  .site-header .menu-toggle, .site-header .main-nav { display: none !important; }
  .site-header .nav-wrap { justify-content: space-between; }
}

/* 2. Tab bar: six tabs fit even at 360px; press feedback like a native app */
@media (max-width: 899px) {
  .tabbar { padding-left: max(6px, env(safe-area-inset-left, 0px)); padding-right: max(6px, env(safe-area-inset-right, 0px)); }
  .tab { min-width: 0; font-size: .6rem; letter-spacing: .02em; transition: transform .15s ease, color .2s ease; -webkit-tap-highlight-color: transparent; }
  .tab:active { transform: scale(.9); }
  .tab svg { width: 22px; height: 22px; }
  .tab span { white-space: nowrap; }
  .tab-more[aria-expanded="true"] { color: var(--gold-dark); }
}

/* 3. "More" bottom sheet */
.more-sheet { position: fixed; inset: 0; z-index: 80; display: flex; align-items: flex-end; }
.more-sheet[hidden] { display: none; }
.more-backdrop { position: absolute; inset: 0; background: rgba(21, 16, 11, .45); animation: fadeOnly .25s ease both; }
.more-panel {
  position: relative; width: 100%; max-width: 560px; margin: 0 auto;
  background: var(--ivory); border-radius: 22px 22px 0 0; padding: 10px 16px calc(18px + env(safe-area-inset-bottom, 0px));
  box-shadow: 0 -12px 40px rgba(0, 0, 0, .2); animation: sheetUp .32s cubic-bezier(.2, .8, .2, 1) both;
}
.more-grip { display: block; width: 42px; height: 5px; border-radius: 3px; background: var(--beige); margin: 4px auto 12px; }
.more-link {
  display: flex; align-items: center; gap: 14px; width: 100%; padding: 16px 12px; border: 0; background: none;
  border-bottom: 1px solid var(--beige); color: var(--brown); font: inherit; font-size: 1rem; text-align: left; cursor: pointer; text-decoration: none;
}
.more-link span { width: 30px; text-align: center; font-size: 1.15rem; }
.more-link:active { background: var(--cream); }
.more-close { margin-top: 12px; width: 100%; padding: 14px; border-radius: 999px; border: 1px solid var(--gold); background: none; color: var(--brown); font: inherit; letter-spacing: .08em; text-transform: uppercase; font-size: .8rem; cursor: pointer; }
@keyframes sheetUp { from { transform: translateY(100%); } to { transform: none; } }
@keyframes fadeOnly { from { opacity: 0; } to { opacity: 1; } }
@media (min-width: 900px) { .more-sheet { display: none !important; } }

/* 4. Page transitions (all browsers): js/app-shell.js fades the page out before a link opens,
      and the page fades/slides in on arrival (pageIn in style.css). */
@media (max-width: 899px) {
  body { transition: opacity .2s ease, transform .2s ease; }
  body.leaving { opacity: 0; transform: translateX(-10px); pointer-events: none; }
}
@media (prefers-reduced-motion: reduce) {
  body, body.leaving { transition: none; }
  .more-panel, .more-backdrop { animation: none !important; }
}

/* Very small phones (under 380px): six tabs must fit without overflow */
@media (max-width: 379px) {
  .tabbar { padding-left: 2px; padding-right: 2px; }
  .tab { padding: 6px 0; }
  .tab span { font-size: .54rem; letter-spacing: 0; }
  .tab svg { width: 20px; height: 20px; }
  .tab-main { width: 56px; height: 56px; }
}

/* Tab bar must fit inside the phone width. A fixed element wider than the screen makes the
   mobile browser zoom the whole page out (layout width jumps to ~980px). */
@media (max-width: 899px) {
  .tabbar { box-sizing: border-box; width: 100%; max-width: 100vw; overflow: hidden; }
  .tabbar > .tab, .tabbar > .tab-more { flex: 1 1 0; min-width: 0; width: auto; }
  .tabbar > .tab-main { flex: 0 0 56px; width: 56px; height: 56px; margin: 0 2px; top: -14px; }
  .tab span { overflow: hidden; text-overflow: clip; }
}
/* Safety net: nothing may widen the page sideways on a phone */
@media (max-width: 899px) {
  html, body { overflow-x: hidden; max-width: 100%; }
}
