/* ==========================================================================
   LAYOUT.CSS - Header, Footer, Sidebar, Main Container
   ========================================================================== */


/* Body-scoped so icon-font glyphs (Font Awesome / Material Icons, used on
   sibling pages) can declare their own font-family. The universal `*` rule
   with !important previously clobbered every icon and rendered tofu. */
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* ==========================================================================
   SWIPE-DRAWER SCROLL CONTAINMENT
   --------------------------------------------------------------------------
   The filter sidebar is an off-screen drawer (translateX out of view), which
   would otherwise create horizontal overflow. We clip it here.

   Use overflow-x:clip, NOT hidden — `hidden` makes html/body a scroll
   container, which silently breaks `position:sticky` on the site header (it
   scrolls away instead of pinning). `clip` suppresses the overflow without
   establishing a scroll container, so the sticky header keeps pinning.

   These rules used to be injected at runtime by sidebar-swipe.js. Declaring
   them here applies them on first paint, so the header is pinned immediately
   with no flash of an unpinned header before the script runs.
   ========================================================================== */
html, body { overscroll-behavior-x: none; overflow-x: clip; }
body { touch-action: pan-y pinch-zoom; }
body.modal-open { touch-action: auto; }
.main-content, .sidebar, .tabs-content { touch-action: auto; }

h1, h2, h3, h4, h5, h6 {
  font-family: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif !important;
}

/* Keyboard-focus indicator for interactive elements that have removed their
   default outline. Scoped to :focus-visible so it doesn't trigger on mouse
   clicks, only on keyboard navigation (WCAG 2.4.7). */
.start-saving-btn:focus-visible,
.details-toggle:focus-visible,
.see-details-link:focus-visible,
.custom-select-trigger:focus-visible,
.sort-select:focus-visible,
.filter-option label:focus-visible,
.modal-docs-section .doc-btn:focus-visible,
.plan-details-modal-close:focus-visible,
.utility-dropdown-trigger:focus-visible {
  outline: 2px solid #2563eb;
  outline-offset: 2px;
}

/* ==========================================================================
   CSS VARIABLES
   ========================================================================== */

:root {
  --blue: #3b82f6;
  --green: #10b981;
  --green-deep: #059669;
  --text: #111827;
  --text-muted: #6b7280;
  --bg: #ffffff;
  --bg-soft: #f8fafc;
  --panel: #f9fafb;
  --border: #e2e8f0;
  --border-mid: #d1d5db;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.05);
  --shadow-md: 0 8px 25px rgba(0,0,0,.10);
  --radius: 8px;
  --drawer-w: 16rem;

  /* Visible portion of the sticky header — set by JS via syncHeaderH().
     Equals header height at scrollY=0 and shrinks to 0 once the user has
     scrolled past, so the drawer reserves space for the header at the top
     of the page but extends to viewport top once it's been scrolled past. */
  --wk-header-h: 0px;

  /* Z-index scale */
  --z-main-content: 20;
  --z-header: 200;
  --z-dropdown: 100;
  --z-tabs: 101;
  --z-sidebar: 100;
  /* Drawer/overlay/toggle sit ABOVE the sticky header so the drawer can
     visually cover it once the user has scrolled past — JS shrinks
     --wk-header-h to 0 in that state and the drawer extends to top:0. */
  --z-sidebar-overlay: 210;
  --z-sidebar-drawer: 220;
  --z-sidebar-toggle: 230;
  --z-modal: 10000;
}

/* ==========================================================================
   SCROLLBAR
   ========================================================================== */

html {
  overflow-y: auto;
  scrollbar-width: auto;
  scrollbar-color: #94a3b8 #f1f5f9;
}

::-webkit-scrollbar {
  width: 12px;
  background: #e2e8f0;
}

::-webkit-scrollbar-track {
  background: #f1f5f9;
}

::-webkit-scrollbar-thumb {
  background: #94a3b8;
  border-radius: 6px;
  border: 2px solid #f1f5f9;
}

::-webkit-scrollbar-thumb:hover {
  background: #64748b;
}

/* ==========================================================================
   HEADER
   --------------------------------------------------------------------------
   The site header (.site-header, .header-wrap, .header-logo, the pill nav and
   the mobile menu) is styled globally in css/core/styles.css and
   css/components/mega-menu.css — both already loaded on this page. The
   plan-page-local copy that used to live here drifted from the canonical
   styles (solid vs. translucent background, missing nav alignment, plus dead
   pre-mega-menu rules), so the header looked different from every other page.
   Removed so the plan page inherits the shared header verbatim.
   ========================================================================== */

/* ==========================================================================
   MAIN CONTAINER
   ========================================================================== */

main.container {
  display: flex;
  flex-direction: column;
  max-width: 1400px;
  margin: 1rem auto;
  margin-top: 2rem;
  padding: 0 1rem;
  position: relative;
  width: 100%;
  box-sizing: border-box;
}

.main-content {
  padding: 0;
  flex: 1;
  z-index: 20;
  width: 100%;
}

@media (min-width: 470px) {
  main.container {
    display: flex !important;
    flex-direction: row !important;
    gap: 1rem;
    align-items: flex-start !important;
  }
  .main-content {
    flex: 1 !important;
    min-width: 0 !important;
  }
}

@media (max-width: 469px) {
  main.container {
    margin-top: 0 !important;
    padding: 0 !important;
  }
  .main-content {
    padding: 0 !important;
  }
}

/* ==========================================================================
   SIDEBAR
   ========================================================================== */

/*
   Sidebar has two layouts driven by the breakpoint:
     desktop (>=1025px) static column, 20rem wide, no toggle/overlay.
     mobile  (<=1024px) off-canvas drawer using --drawer-w (18rem tablet,
                        16rem phone); toggled via .closed on the container.

   The 1024px cutoff matches the header's hamburger breakpoint — below it
   we already commit to mobile-style chrome, so the sidebar follows suit
   instead of stealing 20rem from a viewport that's already tight (iPad
   landscape, iPad Pro 12.9" portrait).

   `--wk-header-h` is set live by syncHeaderH() so the drawer + toggle clear
   the sticky header. JS reads sidebar.getBoundingClientRect().width for
   swipe math, so changing --drawer-w here is enough — no JS edit needed.
*/

.sidebar-container {
  width: 100%;
  z-index: var(--z-sidebar);
}

.sidebar {
  background: var(--panel);
  padding: 1.5rem;
  border-radius: 0.5rem;
  box-shadow: var(--shadow-sm);
}

/* Desktop: static column */
@media (min-width: 1025px) {
  .sidebar-container {
    width: 20rem;
    flex-shrink: 0;
    align-self: flex-start;
  }

  .sidebar {
    position: static;
    width: 100%;
    box-shadow: var(--shadow-md);
  }

  .overlay,
  .toggle-button,
  #sidebarToggle {
    display: none;
  }
}

/* Mobile/tablet: off-canvas drawer */
@media (max-width: 1024px) {
  :root { --drawer-w: 18rem; }

  .sidebar-container {
    position: fixed;
    top: var(--wk-header-h, 0px);
    right: 0;
    bottom: 0;
    left: 0;
    width: 0;
    pointer-events: none;
  }

  .sidebar-container:not(.closed) {
    pointer-events: auto;
  }

  /*
     `.sidebar` is the SHELL. It positions, sizes, and slides — that's it.
     `overflow: visible` is critical: it lets the toggle stick out past the
     drawer's right edge as a real DOM child. `.sidebar-body` inside holds
     the scrolling content and carries the visual treatment.

     Padding/bg/border/shadow rules elsewhere (including the Tailwind classes
     `bg-white p-6 border-r border-gray-200` on the aside) are neutralized
     here so the shell stays purely structural.
  */
  .sidebar {
    position: fixed;
    top: var(--wk-header-h, 0px);
    bottom: 0;
    left: 0;
    width: var(--drawer-w);
    height: calc(100% - var(--wk-header-h, 0px));
    box-sizing: border-box;
    overflow: visible;
    background: transparent;
    border: none;
    padding: 0;
    z-index: var(--z-sidebar-drawer);
    transform: translateX(0);
  }

  .sidebar-container.closed .sidebar {
    transform: translateX(-100%);
  }

  /* The visible card. Scrolls internally; carries the modern-card styling. */
  .sidebar-body {
    position: absolute;
    inset: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
    padding: 1.5rem 1.25rem;
    box-sizing: border-box;
    background: #ffffff;
    border-radius: 0 16px 16px 0;
    box-shadow:
      2px 0 4px rgba(15, 23, 42, 0.06),
      12px 0 32px rgba(15, 23, 42, 0.18);
  }

  .overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: var(--z-sidebar-overlay);
    display: none;
    pointer-events: none;
    opacity: 0;
  }

  .overlay.active {
    display: block;
    pointer-events: auto;
    opacity: 1;
  }

  #sidebarToggle {
    display: flex;
    pointer-events: auto;
  }
}

@media (max-width: 469px) {
  :root { --drawer-w: 16rem; }
}

/*
   Sidebar Toggle Button — display is owned by the breakpoint blocks above
   (none at >=1025px, flex at <=1024px). Everything here is appearance only.

   The toggle is a DOM child of `.sidebar` (the shell) and uses
   `position: absolute; right: -32px` to literally stick out past the
   drawer's right edge. The drawer's transform carries the toggle with it,
   so when the drawer slides off-screen the toggle slides too — leaving
   exactly its own width visible at the viewport's left edge.

   No `box-shadow` or border here: the toggle borrows its elevation from
   the drawer it's attached to. The drawer's shadow extends rightward and
   wraps around the toggle silhouette since they share a layer.
*/
#sidebarToggle {
  appearance: none;
  -webkit-appearance: none;
  padding: 0;
  font: inherit;
  color: #ffffff;
  position: absolute;
  top: calc(50vh - var(--wk-header-h, 0px));
  left: auto;
  right: -32px;
  transform: translateY(-50%);
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 72px;
  background: var(--blue);
  border: none;
  border-radius: 0 12px 12px 0;
  box-shadow: 6px 0 16px rgba(15, 23, 42, 0.12);
  cursor: pointer;
  z-index: var(--z-sidebar-toggle);
  will-change: transform;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

/* Hide sidebar toggle when the plan details modal is open */
body.modal-open #sidebarToggle {
  pointer-events: none !important;
  opacity: 0 !important;
  transition: opacity 0.15s !important;
}

#sidebarToggle:hover {
  background: #2563eb;
}

#sidebarToggle:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

#sidebarToggle.pressing {
  transform: translateY(-50%) scale(0.92);
}

#sidebarToggle svg {
  width: 20px;
  height: 20px;
}

/* Sidebar text-selection: copyable values stay copyable; UI chrome does not. */
.sidebar {
  user-select: none;
  -webkit-user-select: none;
}

.sidebar input,
.sidebar select,
.sidebar textarea,
.sidebar .location-details,
.sidebar #sidebar-header-zip,
.sidebar #sidebar-utility,
.sidebar #sidebar-zone,
.sidebar #sidebar-start-month {
  user-select: text;
  -webkit-user-select: text;
}

/* Location Details */
.location-details {
  margin-bottom: 1.5rem;
  padding: 1rem;
  background: var(--bg);
  border: 1px solid #e5e7eb;
  border-radius: .5rem;
  box-shadow: var(--shadow-sm);
}

.location-details h2 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 1rem;
}

.edit-zip {
  margin-left: .5rem;
  cursor: pointer;
  color: #22c55e;
  transition: transform .2s;
}

.edit-zip:hover {
  transform: scale(1.1);
}

#edit-zip-header {
  pointer-events: auto;
  position: relative;
  z-index: 50;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  width: 20px !important;
  height: 20px !important;
  vertical-align: middle;
  margin-bottom: 6px;
}

#edit-zip-header:active {
  transform: scale(0.95);
}

#zip-modal {
  z-index: var(--z-modal) !important;
  position: fixed !important;
}

/* Supplier Options */
.supplier-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.supplier-header label {
  font-size: 1.125rem;
  font-weight: 600;
  margin: 0;
}

.all-providers-link {
  font-size: 0.875rem;
  color: var(--blue);
  cursor: pointer;
  text-decoration: underline;
  transition: color 0.2s ease;
  background: none;
  border: none;
  padding: 0;
  font-family: inherit;
}

.all-providers-link:hover {
  color: #2563eb;
}

.all-providers-link:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
  border-radius: 2px;
}

#supplier-options-text {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
  margin-left: -0.5rem;
}

.supplier-logo-container {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 8rem;
  height: 8rem;
  overflow: hidden;
  margin: 0 auto;
  cursor: pointer;
  border: 2px solid transparent;
  border-radius: 10px;
  background-color: var(--bg-soft);
  transition: background-color .2s ease, border-color .2s ease, transform .1s ease;
  padding: 0;
}

.supplier-logo-container:hover {
  transform: scale(1.05);
  background-color: #e0f2fe;
  border-color: #bfdbfe;
}

.supplier-logo-container.selected {
  border-color: var(--blue);
  background-color: #DBEAFE;
}

.supplier-logo {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

@media (min-width: 470px) {
  .supplier-logo-container {
    width: 6.5rem;
    height: 6.5rem;
  }
  #supplier-options-text {
    gap: 0.75rem;
  }
}

@media (max-width: 469px) {
  .supplier-logo-container {
    width: 5.5rem;
    height: 5.5rem;
  }
  #supplier-options-text {
    gap: 0.5rem;
  }
}

/* ==========================================================================
   FOOTER
   ========================================================================== */

footer.site-footer {
  margin-top: 80px;
  padding: 48px 24px 32px;
  background: #1e293b;
  color: #fff;
}

footer.site-footer .container {
  max-width: 1200px;
  margin: 0 auto;
  display: block !important;
  padding: 0 24px;
}

footer.site-footer a {
  color: #fff;
  text-decoration: none;
  opacity: .95;
}

footer.site-footer a:hover {
  opacity: 1;
}

.footer-top {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  text-align: center;
  padding-bottom: 32px;
  margin-bottom: 24px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.footer-nav {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.footer-nav a {
  font-size: 14px;
  font-weight: 500;
  transition: opacity 0.2s;
}

.footer-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
  flex-wrap: nowrap;
}

.footer-legal {
  color: #94a3b8;
  font-size: 12px;
  flex: 1;
}

.footer-phone {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #fff;
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  flex-shrink: 0;
  white-space: nowrap;
}

.footer-phone svg {
  width: 20px;
  height: 20px;
}

@media (max-width: 469px) {
  footer.site-footer {
    margin-top: 48px;
    padding: 32px 16px 24px;
  }

  footer.site-footer .footer-top {
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    gap: 24px;
  }

  footer.site-footer .footer-nav {
    flex-direction: column;
    align-items: center;
    gap: 14px;
  }

  .footer-bottom {
    flex-direction: column;
    text-align: center;
    flex-wrap: wrap;
  }

  .footer-legal {
    white-space: normal;
  }

  .footer-phone {
    margin-left: 0;
  }
}

@media (min-width: 470px) {
  footer.site-footer .footer-top {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    text-align: left;
    gap: 24px;
  }

  footer.site-footer .footer-nav {
    flex-direction: row;
    align-items: center;
    gap: 24px;
  }
}

/* ==========================================================================
   GLOBAL SVG & MISC
   ========================================================================== */

/* SVG sizing scoped to sidebar to avoid affecting all SVGs globally */
.sidebar svg {
  max-width: 3rem;
  max-height: 3rem;
}

#sidebar-utility:empty::after,
#sidebar-zone:empty::after,
#sidebar-start-month:empty::after {
  content: "Loading...";
  color: #9ca3af;
}

/*
   Sidebar transitions. Plain selectors — the swipe JS can suspend them
   via `element.style.transition = 'none'` inline since nothing here
   uses !important. The toggle's transition only services its own
   `.pressing` scale; it inherits the drawer's translation as a DOM
   child, so no transform animation of its own is needed for sliding.
*/
#sidebar { transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1); }
#sidebarOverlay { transition: opacity 0.35s cubic-bezier(0.4, 0, 0.2, 1); }
#sidebarToggle { transition: transform 0.15s cubic-bezier(0.4, 0, 0.2, 1); }

/* Compositor-layer promotion only where the drawer can actually move. */
@media (max-width: 1024px) {
  #sidebar { will-change: transform; }
  #sidebarOverlay { will-change: opacity; }
}

@media (prefers-reduced-motion: reduce) {
  #sidebar,
  #sidebarOverlay,
  #sidebarToggle {
    transition: none;
  }
}
