/* DCE Holdings — PWA shell styles
 * Only visible on mobile. Bottom tab bar + bottom sheet + native feel tweaks.
 * Brand: navy #1B2642, gold #B88B47.
 */

/* ─── E) Kill overscroll bounce & pull-to-refresh (feels native) ─── */
html {
  overscroll-behavior-y: none;
  -webkit-text-size-adjust: 100%;
}
body {
  overscroll-behavior-y: none;
  /* Prevent horizontal rubber-band scroll on iOS */
  overscroll-behavior-x: none;
}

/* ─── S) Kill iOS tap-flash on all interactive elements ─── */
a, button, [role="button"], input[type="button"], input[type="submit"], .clickable {
  -webkit-tap-highlight-color: transparent;
}

/* ─── R) Disable long-press callout on non-input elements ─── */
body {
  -webkit-touch-callout: none;
}
input, textarea, [contenteditable="true"] {
  -webkit-touch-callout: default;
  -webkit-user-select: text;
  user-select: text;
}

/* When running as installed PWA (standalone mode)
 * Push page content below the translucent status bar, respect notch,
 * and hide any web-only elements marked with .pwa-hide.
 */
@media all and (display-mode: standalone) {
  body {
    padding-top: env(safe-area-inset-top);
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
  }
  /* Fixed cream backdrop that sits behind the iOS system status bar.
   * Without this any content that scrolls up under the notch/status
   * bar shows through and collides with the system glyphs (time,
   * signal, battery). We paint a solid cream (#faf7ef) bar exactly
   * the height of env(safe-area-inset-top) fixed at the very top so
   * scrolling content is always clipped behind it. */
  body::before {
    content: "";
    position: fixed;
    top: 0; left: 0; right: 0;
    height: env(safe-area-inset-top, 0px);
    background: #faf7ef;
    z-index: 10000;
    pointer-events: none;
  }
  /* Any element the site marks as web-only can hide itself in standalone */
  .pwa-hide { display: none !important; }
  /* Mark class the site can use to show elements only when installed */
  .pwa-only { display: initial; }
}
@media all and (display-mode: browser) {
  .pwa-only { display: none !important; }
}

/* ─── Mobile-only shell: below 820px (covers iPhone + iPad Mini portrait) ─── */
@media (max-width: 820px) {

  /* Hide the desktop top nav in favor of the bottom tab bar */
  .hnav {
    display: none !important;
  }
  /* Some pages use variants of the header — hide their top nav container too if it uses <nav> */
  header nav.hnav { display: none !important; }

  /* Give room at the page bottom for the tab bar (56px + safe-area) */
  body.dce-has-tabbar {
    padding-bottom: calc(64px + env(safe-area-inset-bottom, 0px));
  }

  /* ─── Bottom tab bar ─── */
  #dce-tabbar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 9998;
    display: flex;
    justify-content: space-around;
    align-items: stretch;
    background: #1B2642;              /* solid navy — no backdrop-blur bleed */
    border-top: 1px solid rgba(184, 139, 71, 0.28);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom, 0px));
    font-family: 'Archivo', 'Calibri', system-ui, -apple-system, sans-serif;
    box-shadow: 0 -1px 12px rgba(0, 0, 0, 0.18);
  }
  .dce-tab {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 4px 2px;
    background: transparent;
    border: 0;
    color: rgba(255, 255, 255, 0.85);  /* high-contrast inactive */
    text-decoration: none;
    font-family: inherit;
    font-size: 10px;
    font-weight: 500;
    letter-spacing: 0.02em;
    cursor: pointer;
    opacity: 1;
    -webkit-tap-highlight-color: transparent;
    transition: color 0.15s ease;
  }
  .dce-tab:active { transform: scale(0.96); }
  .dce-tab.is-active { color: #B88B47; }
  .dce-tab-label { color: inherit; opacity: 1; }
  .dce-tab-icon { color: inherit; opacity: 1; }
  .dce-tab-icon {
    width: 24px;
    height: 24px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
  .dce-tab-icon svg { width: 100%; height: 100%; }
  .dce-tab-label {
    font-size: 10px;
    line-height: 1;
  }

  /* ─── Bottom sheet (Menu) ─── */
  #dce-sheet-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(0, 0, 0, 0);
    transition: background 0.22s ease;
  }
  #dce-sheet-overlay.is-open {
    background: rgba(0, 0, 0, 0.5);
  }
  #dce-sheet {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10000;
    background: #FFFFFF;
    color: #1B2642;
    border-top-left-radius: 18px;
    border-top-right-radius: 18px;
    padding: 8px 20px calc(24px + env(safe-area-inset-bottom, 0px));
    transform: translateY(100%);
    transition: transform 0.24s cubic-bezier(0.32, 0.72, 0, 1);
    font-family: 'Archivo', 'Calibri', system-ui, -apple-system, sans-serif;
    max-height: 78vh;
    overflow-y: auto;
    box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.16);
  }
  #dce-sheet.is-open { transform: translateY(0); }

  .dce-sheet-handle {
    width: 40px;
    height: 4px;
    background: rgba(27, 38, 66, 0.18);
    border-radius: 2px;
    margin: 8px auto 12px;
  }
  .dce-sheet-title {
    font-family: 'Archivo', system-ui, sans-serif;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: rgba(27, 38, 66, 0.5);
    margin-bottom: 14px;
    text-align: center;
  }
  .dce-sheet-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }
  .dce-sheet-item {
    background: #F7F7F5;
    border: 1px solid rgba(27, 38, 66, 0.08);
    border-radius: 10px;
    padding: 14px 12px;
    color: #1B2642;
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
    text-align: center;
    letter-spacing: 0.01em;
    -webkit-tap-highlight-color: transparent;
    transition: background 0.12s ease;
  }
  .dce-sheet-item:active { background: #EDEDE7; }

  /* Feed action sheet (vertical list, gold arrows) */
  .dce-sheet-feed {
    display: flex;
    flex-direction: column;
    gap: 8px;
  }
  .dce-sheet-feed-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #F7F7F5;
    border: 1px solid rgba(27, 38, 66, 0.08);
    border-radius: 10px;
    padding: 18px 18px;
    color: #1B2642;
    text-decoration: none;
    -webkit-tap-highlight-color: transparent;
    transition: background 0.12s ease;
  }
  .dce-sheet-feed-item:active { background: #EDEDE7; }
  .dce-sheet-feed-label {
    font-family: 'Archivo', system-ui, sans-serif;
    font-size: 15px;
    font-weight: 600;
    letter-spacing: 0.02em;
  }
  .dce-sheet-feed-arrow {
    color: #B88B47;
    font-size: 18px;
    font-weight: 400;
  }

  .dce-sheet-close {
    display: block;
    width: 100%;
    margin-top: 16px;
    padding: 14px;
    background: transparent;
    border: 0;
    color: #B88B47;
    font-family: inherit;
    font-size: 15px;
    font-weight: 700;
    letter-spacing: 0.02em;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }

  /* Prevent background scroll while sheet is open */
  body.dce-sheet-open {
    overflow: hidden;
  }

  /* ─── Share FAB (top-right, native iOS look) ─── */
  #dce-share-fab {
    position: fixed;
    top: calc(10px + env(safe-area-inset-top, 0px));
    right: calc(12px + env(safe-area-inset-right, 0px));
    z-index: 9997;
    width: 36px;
    height: 36px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: rgba(27, 38, 66, 0.86);
    -webkit-backdrop-filter: saturate(180%) blur(14px);
    backdrop-filter: saturate(180%) blur(14px);
    color: #B88B47;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
    -webkit-tap-highlight-color: transparent;
    transition: transform 0.12s ease, background 0.12s ease;
  }
  #dce-share-fab:active { transform: scale(0.92); background: rgba(27, 38, 66, 0.95); }
  #dce-share-fab svg { width: 18px; height: 18px; }
}

/* ─── P) Update banner (all viewports) ─── */
#dce-update-banner {
  position: fixed;
  left: 50%;
  bottom: calc(80px + env(safe-area-inset-bottom, 0px));
  transform: translate(-50%, 20px);
  opacity: 0;
  z-index: 10001;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px 10px 16px;
  background: #1B2642;
  color: #FFFFFF;
  border: 1px solid rgba(184, 139, 71, 0.35);
  border-radius: 999px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.24);
  font-family: 'Archivo', 'Calibri', system-ui, sans-serif;
  font-size: 13px;
  transition: opacity 0.24s ease, transform 0.24s ease;
}
#dce-update-banner.is-open {
  opacity: 1;
  transform: translate(-50%, 0);
}
.dce-update-text { font-weight: 500; letter-spacing: 0.02em; }
.dce-update-btn {
  background: #B88B47;
  color: #1B2642;
  border: 0;
  border-radius: 999px;
  padding: 6px 14px;
  font: inherit;
  font-weight: 700;
  letter-spacing: 0.02em;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.dce-update-btn:active { transform: scale(0.96); }
.dce-update-close {
  background: transparent;
  border: 0;
  color: rgba(255, 255, 255, 0.6);
  font-size: 20px;
  line-height: 1;
  padding: 0 4px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
@media (min-width: 821px) {
  #dce-update-banner { bottom: 24px; }
}

/* ─── M) Pull-to-refresh indicator (mobile pages that opt-in) ─── */
#dce-ptr {
  position: fixed;
  top: env(safe-area-inset-top, 0px);
  left: 50%;
  transform: translate(-50%, -40px);
  opacity: 0;
  z-index: 9996;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(27, 38, 66, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  transition: opacity 0.15s ease;
  pointer-events: none;
}
.dce-ptr-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,0.2);
  border-top-color: #B88B47;
  border-radius: 50%;
}
#dce-ptr.is-armed .dce-ptr-spinner { border-top-color: #B88B47; }
#dce-ptr.is-loading .dce-ptr-spinner {
  animation: dce-ptr-spin 0.8s linear infinite;
}
@keyframes dce-ptr-spin {
  to { transform: rotate(360deg); }
}

/* ─── Toast ─── */
#dce-toast {
  position: fixed;
  left: 50%;
  bottom: calc(88px + env(safe-area-inset-bottom, 0px));
  transform: translate(-50%, 12px);
  opacity: 0;
  pointer-events: none;
  z-index: 10002;
  padding: 8px 16px;
  background: rgba(27, 38, 66, 0.94);
  color: #FFFFFF;
  font-family: 'Archivo', 'Calibri', system-ui, sans-serif;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.02em;
  border-radius: 999px;
  border: 1px solid rgba(184, 139, 71, 0.28);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.24);
  transition: opacity 0.2s ease, transform 0.2s ease;
}
#dce-toast.is-open {
  opacity: 1;
  transform: translate(-50%, 0);
}
@media (min-width: 821px) {
  #dce-toast { bottom: 32px; }
}

/* Desktop — ensure no leaks (≥821px, above iPad Mini portrait) */
@media (min-width: 821px) {
  #dce-tabbar, #dce-sheet, #dce-sheet-overlay, #dce-share-fab, #dce-ptr { display: none !important; }
}
