/* ==========================================================================
   MyAlaska.me — Mobile-First Design System & Responsive Layout
   Served from /assets/mobile-first.css across all 96 pages.
   ========================================================================== */

:root {
  --alaska-bottom-bar-h: 64px;
  --alaska-tap-min: 44px;
}

/* 1. Global Overflow & Media Safety */
html,
body {
  overflow-x: clip;
  max-width: 100%;
}

img,
video,
iframe,
svg,
canvas {
  max-width: 100%;
  height: auto;
}

.grid > *,
[class*="grid"] > *,
.flex > *,
[class*="metrics"] > * {
  min-width: 0;
}

h1, h2, h3, p, li, td, th {
  overflow-wrap: break-word;
}

pre {
  white-space: pre-wrap;
  word-break: break-word;
  max-width: 100%;
}

/* 2. Global Visitor & Traffic Counter Pill */
.myalaska-visitor-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 9999px;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  color: #166534;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.myalaska-visitor-pill-dot {
  width: 7px;
  height: 7px;
  border-radius: 9999px;
  background: #10b981;
  flex-shrink: 0;
  animation: myalaskaPulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

@keyframes myalaskaPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* 3. Mobile Slide-Over Navigation & Searchable Enclave Drawer */
#myalaska-drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 9998;
  background: rgba(2, 6, 23, 0.55);
  backdrop-filter: blur(4px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

#myalaska-drawer-backdrop.is-open {
  opacity: 1;
  pointer-events: auto;
}

#myalaska-mobile-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 9999;
  width: min(92vw, 390px);
  height: 100dvh;
  background: #ffffff;
  border-left: 1px solid #e2e8f0;
  box-shadow: -16px 0 40px rgba(15, 23, 42, 0.22);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.24s cubic-bezier(0.16, 1, 0.3, 1);
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

#myalaska-mobile-drawer.is-open {
  transform: translateX(0);
}

.myalaska-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid #e2e8f0;
  background: #f8fafc;
}

.myalaska-drawer-search-wrap {
  padding: 12px 16px;
  border-bottom: 1px solid #e2e8f0;
  background: #ffffff;
}

.myalaska-drawer-search {
  width: 100%;
  min-height: 42px;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid #cbd5e1;
  background: #f8fafc;
  color: #0f172a;
  font-size: 13px;
  font-weight: 500;
  outline: none;
}

.myalaska-drawer-search:focus {
  border-color: #0284c7;
  background: #ffffff;
  box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.15);
}

.myalaska-drawer-body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 12px 16px 28px;
}

.myalaska-drawer-group-title {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #64748b;
  margin: 14px 0 6px;
  padding: 0 4px;
}

.myalaska-drawer-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: var(--alaska-tap-min);
  padding: 9px 12px;
  border-radius: 10px;
  font-size: 13.5px;
  font-weight: 700;
  color: #1e293b;
  text-decoration: none;
  transition: background-color 0.15s ease;
}

.myalaska-drawer-link:hover,
.myalaska-drawer-link:active {
  background: #f1f5f9;
  color: #0284c7;
}

.myalaska-drawer-link[data-active="true"] {
  background: #e0f2fe;
  color: #0369a1;
}

/* 4. Sticky Mobile Bottom Action Bar (< 768px only) */
#myalaska-mobile-bottom-bar {
  display: none;
}

@media (max-width: 767px) {
  body {
    padding-bottom: calc(var(--alaska-bottom-bar-h) + env(safe-area-inset-bottom, 0px));
  }

  #myalaska-mobile-bottom-bar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 9985;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    align-items: center;
    min-height: var(--alaska-bottom-bar-h);
    padding: 4px 6px calc(4px + env(safe-area-inset-bottom, 0px));
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-top: 1px solid #cbd5e1;
    box-shadow: 0 -6px 24px rgba(15, 23, 42, 0.08);
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
  }

  .myalaska-bottom-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    min-height: 48px;
    border-radius: 10px;
    background: transparent;
    border: none;
    color: #334155;
    font-size: 11px;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
    padding: 4px 2px;
  }

  .myalaska-bottom-btn:active {
    background: #f1f5f9;
  }

  .myalaska-bottom-btn-order {
    color: #0284c7;
    font-weight: 800;
  }

  .myalaska-bottom-icon {
    font-size: 17px;
    line-height: 1.1;
  }

  /* Compact Mobile Header & BFCM Ribbon */
  #myalaska-global-header {
    position: relative !important;
  }

  #bfcm-global-ribbon {
    padding: 5px 10px !important;
    font-size: 11px !important;
  }

  #bfcm-global-ribbon > div > div:first-child > span:nth-child(n+2) {
    display: none !important;
  }

  #bfcm-global-ribbon > div > div:first-child::after {
    content: "25% off · BFCM2026";
    color: #fef3c7;
    font-weight: 700;
    font-size: 11px;
  }

  aside.myalaska-trust-strip,
  aside[aria-label="Commercial Trust Status"] {
    display: none !important;
  }

  .myalaska-badge,
  #myalaska-global-header .myalaska-brand-sub {
    display: none !important;
  }

  #myalaska-header-main-row {
    padding: 8px 12px !important;
    min-height: 54px !important;
  }

  /* Fluid Mobile Typography */
  h1 {
    font-size: clamp(1.75rem, 7.6vw, 2.5rem) !important;
    line-height: 1.13 !important;
  }

  h2 {
    font-size: clamp(1.35rem, 6vw, 1.9rem) !important;
    line-height: 1.2 !important;
  }

  /* Horizontal Scroll-Snap Carousels on Mobile */
  .mobile-snap-row {
    display: flex !important;
    flex-wrap: nowrap !important;
    overflow-x: auto !important;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    gap: 12px !important;
    padding-bottom: 10px;
    scrollbar-width: thin;
  }

  .mobile-snap-row > * {
    flex: 0 0 84% !important;
    max-width: 84% !important;
    scroll-snap-align: start;
  }

  /* Single-Row Swipeable Filter Pill Strip */
  .mobile-pill-strip {
    display: flex !important;
    flex-wrap: nowrap !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
    gap: 8px !important;
    padding-bottom: 6px;
    scrollbar-width: none;
  }

  .mobile-pill-strip::-webkit-scrollbar {
    display: none;
  }

  .mobile-pill-strip > button,
  .mobile-pill-strip > a {
    flex: 0 0 auto !important;
    white-space: nowrap !important;
    min-height: 40px;
    padding-left: 14px !important;
    padding-right: 14px !important;
  }

  /* Responsive Card-Table for Wide Enterprise Tables */
  table.mobile-card-table {
    display: block !important;
    width: 100% !important;
    overflow-x: visible !important;
  }

  table.mobile-card-table thead {
    display: none !important;
  }

  table.mobile-card-table tbody {
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 12px !important;
    padding: 12px !important;
    background: #f8fafc;
  }

  table.mobile-card-table tr {
    display: block !important;
    background: #ffffff;
    border: 1px solid #e2e8f0 !important;
    border-radius: 14px;
    padding: 12px 14px;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.05);
  }

  table.mobile-card-table td {
    display: flex !important;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 6px 0 !important;
    border-bottom: 1px dashed #f1f5f9 !important;
    text-align: right !important;
    white-space: normal !important;
  }

  table.mobile-card-table td:last-child {
    border-bottom: none !important;
  }

  table.mobile-card-table td::before {
    content: attr(data-label);
    flex: 0 0 36%;
    text-align: left;
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: #64748b;
  }

  /* Fallback for generic tables on subpages */
  table:not(.mobile-card-table) {
    display: block;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Metric grids & stacked forms */
  .hero-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }

  .mobile-stack-grid {
    grid-template-columns: 1fr !important;
  }

  /* Bottom-Sheet Modals on Phones */
  #landing-order-modal-backdrop,
  #orderModal,
  #licensing-modal {
    align-items: flex-end !important;
    padding: 0 !important;
  }

  #landing-order-modal-backdrop > div,
  #orderModal > div,
  #licensing-modal > div {
    width: 100% !important;
    max-width: 100% !important;
    max-height: 90dvh !important;
    overflow-y: auto !important;
    border-radius: 20px 20px 0 0 !important;
    padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px)) !important;
  }
}

/* 5. Mobile-Only Accordion Footer */
@media (max-width: 767px) {
  .mobile-footer-acc > summary {
    list-style: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid #1e293b;
    cursor: pointer;
    min-height: 44px;
  }
  .mobile-footer-acc > summary::-webkit-details-marker {
    display: none;
  }
  .mobile-footer-acc > summary::after {
    content: "+";
    font-family: 'JetBrains Mono', monospace;
    font-size: 16px;
    color: #94a3b8;
  }
  .mobile-footer-acc[open] > summary::after {
    content: "−";
  }
}

@media (min-width: 768px) {
  .mobile-footer-acc > summary {
    list-style: none;
    pointer-events: none;
  }
  .mobile-footer-acc > summary::-webkit-details-marker {
    display: none;
  }
}
