/* Shared top nav for signed-in /portal/ pages — see lib/header.php.
   Deliberately mirrors styles.css's .site-header treatment (sticky,
   frosted glass, same type scale) so the portal reads as a continuation
   of hirenico.com rather than a separate app chrome. */

.portal-nav {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
  /* Extends the frosted strip up under the status bar/notch when
     installed standalone, same idea as a native app's nav bar. */
  padding-top: env(safe-area-inset-top);
}

.portal-nav-top {
  max-width: 960px;
  margin: 0 auto;
  height: 52px;
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.portal-nav-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: #1d1d1f;
  flex-shrink: 0;
}
.portal-nav-logo { width: 48px; height: auto; display: block; }
.portal-nav-divider { color: rgba(0,0,0,0.2); font-weight: 400; font-size: 19px; }
.portal-nav-brand span:last-child { font-size: 19px; font-weight: 600; letter-spacing: -0.01em; }

.portal-nav-right {
  display: flex;
  align-items: center;
  gap: 20px;
  min-width: 0;
}

/* Desktop Home/Quotes/Billing pill — same Liquid Glass treatment as
   the mobile .portal-bottom-tabs capsule (real glass refraction via
   the pg-lens-pill/pg-lens-tile filters defined once in
   lib/header.php, sliding tile behind the active tab), just sitting
   inline in the header instead of floating over the page. Driven by
   the same portal-bottom-nav.js, generalized to set up any matching
   nav+tile pair it finds. */
.portal-nav-tabs {
  position: relative;
  display: flex;
  align-items: center;
  gap: 2px;
  min-width: 0;
  padding: 4px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.45);
  backdrop-filter: blur(16px) saturate(200%) contrast(112%) brightness(1.03);
  -webkit-backdrop-filter: blur(16px) saturate(200%) contrast(112%) brightness(1.03);
  border: 1px solid rgba(255, 255, 255, 0.6);
  box-shadow:
    0 4px 14px rgba(0, 0, 0, 0.08),
    inset 0 1px 1px rgba(255, 255, 255, 0.85);
}
@supports (backdrop-filter: url(#pg-lens-pill)) or (-webkit-backdrop-filter: url(#pg-lens-pill)) {
  .portal-nav-tabs {
    backdrop-filter: url(#pg-lens-pill) blur(8px) saturate(200%) contrast(112%) brightness(1.03);
    -webkit-backdrop-filter: url(#pg-lens-pill) blur(8px) saturate(200%) contrast(112%) brightness(1.03);
  }
}
.portal-nav-tabs::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.45) 0%, rgba(255, 255, 255, 0.06) 35%, rgba(255, 255, 255, 0) 60%);
  mix-blend-mode: overlay;
  pointer-events: none;
}
.portal-nav-tabs-tile {
  position: absolute;
  top: 4px;
  bottom: 4px;
  left: 0;
  width: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(3px) saturate(220%) contrast(118%);
  -webkit-backdrop-filter: blur(3px) saturate(220%) contrast(118%);
  box-shadow:
    0 1px 6px rgba(0, 0, 0, 0.08),
    inset 0 1px 1px rgba(255, 255, 255, 0.95);
  transition:
    transform 0.38s cubic-bezier(0.34, 1.4, 0.64, 1),
    width 0.38s cubic-bezier(0.34, 1.4, 0.64, 1),
    opacity 0.2s ease;
  pointer-events: none;
}
/* Hidden on pages that aren't Home/Quotes/Billing (e.g. Account
   settings) — set by setupGlassNav() in portal-bottom-nav.js when no
   tab matches the active page, instead of defaulting to a tab. */
.portal-nav-tabs-tile.is-hidden { opacity: 0; }
@supports (backdrop-filter: url(#pg-lens-tile)) or (-webkit-backdrop-filter: url(#pg-lens-tile)) {
  .portal-nav-tabs-tile {
    backdrop-filter: url(#pg-lens-tile) blur(1.5px) saturate(220%) contrast(118%);
    -webkit-backdrop-filter: url(#pg-lens-tile) blur(1.5px) saturate(220%) contrast(118%);
  }
}
.portal-nav-tab {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: -0.005em;
  color: #6e6e73;
  text-decoration: none;
  white-space: nowrap;
  transition: color 0.2s ease;
}
.portal-nav-tab svg { width: 15px; height: 15px; flex-shrink: 0; }
.portal-nav-tab:hover { color: #1d1d1f; }
.portal-nav-tab.active { color: #1a6fe8; font-weight: 600; }

.portal-nav-user { position: relative; flex-shrink: 0; }
.portal-nav-user summary { list-style: none; cursor: pointer; }
.portal-nav-user summary::-webkit-details-marker { display: none; }
.portal-nav-user-summary { display: flex; align-items: center; gap: 8px; }
.portal-nav-username { font-size: 13px; font-weight: 400; letter-spacing: -0.005em; color: #1d1d1f; opacity: 0.75; white-space: nowrap; }
.portal-nav-usericon {
  width: 30px; height: 30px; flex-shrink: 0; color: #1d1d1f;
  display: flex; align-items: center; justify-content: center;
  transition: color 0.2s ease;
}
.portal-nav-usericon svg { width: 21px; height: 21px; }
.portal-nav-user[open] .portal-nav-usericon { color: #1a6fe8; }
/* Hover-driven highlight only for devices that have a real hover
   state (mouse/trackpad). Touch browsers — iOS Safari in particular —
   apply :hover on tap and then leave it "stuck" until something else
   is tapped, which made the icon stay blue after closing the menu
   even though [open] had already cleared. Gating this behind
   (hover: hover) means touch devices rely on [open] alone, which
   toggles correctly with the <details> element every time. */
@media (hover: hover) and (pointer: fine) {
  .portal-nav-user:hover .portal-nav-usericon { color: #1a6fe8; }
}

.portal-nav-user-menu {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 30;
  background: #ffffff; border-radius: 12px; box-shadow: 0 10px 30px rgba(0,0,0,0.14);
  padding: 6px; min-width: 170px;
}
.portal-nav-user-menu form { margin: 0; }
.portal-nav-menu-item {
  display: block; width: 100%; text-align: left; background: none; border: none; padding: 10px 12px;
  border-radius: 8px; font-size: 14px; color: #1d1d1f; cursor: pointer; font-family: inherit;
  text-decoration: none; box-sizing: border-box;
}
.portal-nav-menu-item:hover { background: #f5f5f7; }
.portal-nav-menu-item.portal-nav-menu-danger { color: #c5362f; }
.portal-nav-menu-item.portal-nav-menu-danger:hover { background: #fdeeee; }

@media (max-width: 420px) {
  .portal-nav-username { display: none; }
  .portal-nav-right { gap: 14px; }
}

/* ---- Bottom tab bar: Home/Quotes/Billing move down here on mobile,
   styled as a floating "Liquid Glass" capsule (detached from the
   screen edges, heavily frosted, a soft specular border) with a
   sliding glass "tile" behind the active tab — see
   portal-bottom-nav.js for the tap/swipe-driven sliding. Comes out of
   the header entirely on mobile so it's not competing with the
   brand/user menu for a cramped top row. ---- */
:root {
  --portal-bottom-nav-h: 56px;
  --portal-bottom-nav-offset: 14px;
}
.portal-bottom-tabs { display: none; }
@media (max-width: 640px) {
  .portal-nav-tabs { display: none; }
  .portal-bottom-tabs {
    display: flex;
    position: fixed;
    left: 50%;
    bottom: calc(var(--portal-bottom-nav-offset) + env(safe-area-inset-bottom, 0px));
    transform: translateX(-50%);
    z-index: 50;
    width: min(92vw, 360px);
    height: var(--portal-bottom-nav-h);
    border-radius: 999px;
    padding: 6px;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.4);
    /* Safe baseline for every browser: blur + punched-up saturation/
       contrast/brightness so colors behind the pill read as richer
       and more vivid, standing in for true refraction where the
       browser can't do that. The @supports rule below layers real
       pixel displacement (feDisplacementMap, defined in
       lib/header.php) on top where it's actually honored. */
    backdrop-filter: blur(24px) saturate(220%) contrast(115%) brightness(1.05);
    -webkit-backdrop-filter: blur(24px) saturate(220%) contrast(115%) brightness(1.05);
    border: 1px solid rgba(255, 255, 255, 0.65);
    box-shadow:
      0 10px 30px rgba(0, 0, 0, 0.14),
      0 1px 2px rgba(0, 0, 0, 0.06),
      inset 0 1px 1px rgba(255, 255, 255, 0.9);
    /* The pill is the only thing that should respond to a horizontal
       drag — portal-bottom-nav.js scopes its touch listeners to this
       element, and this tells the browser not to treat a horizontal
       finger movement here as an attempt to scroll the page either. */
    touch-action: pan-y;
    /* Chrome on Android paints its own blue tap-highlight rectangle
       over whatever you touch, which looked like a stray flash of
       color over a tab before the custom drag/tap handling even got
       a chance to run (iOS Safari doesn't do this, which is why it
       only showed up on Android) — same fix for every tap target in
       the pill. */
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    user-select: none;
  }
  @supports (backdrop-filter: url(#pg-lens-pill)) or (-webkit-backdrop-filter: url(#pg-lens-pill)) {
    .portal-bottom-tabs {
      backdrop-filter: url(#pg-lens-pill) blur(12px) saturate(220%) contrast(115%) brightness(1.05);
      -webkit-backdrop-filter: url(#pg-lens-pill) blur(12px) saturate(220%) contrast(115%) brightness(1.05);
    }
  }
  /* A soft diagonal sheen so the pill reads as a curved, lit surface
     rather than a flat tinted rectangle — clipped to the capsule by
     its own border-radius, same trick as the tile's ::before below. */
  .portal-bottom-tabs::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.5) 0%, rgba(255, 255, 255, 0.08) 35%, rgba(255, 255, 255, 0) 60%);
    mix-blend-mode: overlay;
    pointer-events: none;
  }
  .portal-bottom-tabs-tile {
    position: absolute;
    top: 6px;
    bottom: 6px;
    left: 0;
    width: 0;
    overflow: hidden;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.78);
    /* Glass sitting on glass: noticeably stronger saturation/contrast
       than the pill underneath it, since light passing through two
       layers of glass should look more intense, not less. */
    backdrop-filter: blur(6px) saturate(260%) contrast(125%) brightness(1.08);
    -webkit-backdrop-filter: blur(6px) saturate(260%) contrast(125%) brightness(1.08);
    box-shadow:
      0 2px 10px rgba(0, 0, 0, 0.10),
      inset 0 1px 1px rgba(255, 255, 255, 0.95);
    transition:
      transform 0.38s cubic-bezier(0.34, 1.4, 0.64, 1),
      width 0.38s cubic-bezier(0.34, 1.4, 0.64, 1),
      background 0.2s ease, box-shadow 0.2s ease, backdrop-filter 0.2s ease,
      opacity 0.2s ease;
    pointer-events: none;
    transform-origin: center;
  }
  .portal-bottom-tabs-tile.is-hidden { opacity: 0; }
  @supports (backdrop-filter: url(#pg-lens-tile)) or (-webkit-backdrop-filter: url(#pg-lens-tile)) {
    .portal-bottom-tabs-tile {
      backdrop-filter: url(#pg-lens-tile) blur(3px) saturate(260%) contrast(125%) brightness(1.08);
      -webkit-backdrop-filter: url(#pg-lens-tile) blur(3px) saturate(260%) contrast(125%) brightness(1.08);
    }
  }
  .portal-bottom-tabs-tile::before {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.9) 0%, rgba(255, 255, 255, 0.18) 45%, rgba(255, 255, 255, 0) 70%);
    mix-blend-mode: overlay;
    pointer-events: none;
  }
  /* While an active drag is in progress (finger down on the pill),
     the tile gets an even stronger "liquid" treatment: heavier blur/
     saturation so it visibly refracts what's behind it as it moves,
     a brighter glassy fill, and a crisper rim light — on top of the
     stretch-in-the-direction-of-travel that portal-bottom-nav.js
     applies via an inline scaleX() each frame. */
  .portal-bottom-tabs-tile.is-dragging {
    transition: background 0.15s ease, box-shadow 0.15s ease, backdrop-filter 0.15s ease;
    background: rgba(255, 255, 255, 0.58);
    backdrop-filter: blur(20px) saturate(280%) contrast(130%) brightness(1.1);
    -webkit-backdrop-filter: blur(20px) saturate(280%) contrast(130%) brightness(1.1);
    box-shadow:
      0 6px 18px rgba(0, 0, 0, 0.18),
      inset 0 1px 1px rgba(255, 255, 255, 1),
      inset 0 0 0 1px rgba(255, 255, 255, 0.55);
  }
  @supports (backdrop-filter: url(#pg-lens-tile)) or (-webkit-backdrop-filter: url(#pg-lens-tile)) {
    .portal-bottom-tabs-tile.is-dragging {
      backdrop-filter: url(#pg-lens-tile) blur(10px) saturate(280%) contrast(130%) brightness(1.1);
      -webkit-backdrop-filter: url(#pg-lens-tile) blur(10px) saturate(280%) contrast(130%) brightness(1.1);
    }
  }
  .portal-bottom-tab {
    position: relative;
    z-index: 1;
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1px;
    text-decoration: none;
    color: #6e6e73;
    font-size: 10px;
    font-weight: 500;
    border-radius: 999px;
    -webkit-tap-highlight-color: transparent;
  }
  .portal-bottom-tab svg { width: 20px; height: 20px; transition: transform 0.25s ease; }
  .portal-bottom-tab.active { color: #1a6fe8; }
  .portal-bottom-tab.active svg { transform: translateY(-1px) scale(1.06); }
}

/* Get-help popup (portal-help-widget.js) — reuses the marketing site's
   .chat-widget-* classes from styles.css for the panel/backdrop/sheet
   chrome, since the portal doesn't load chat-widget.js and there's no
   collision. These two just reposition the bubble/panel for a page
   with no sticky footer below them (chat-widget-bubble normally sits
   at bottom:84px to clear one). */
.portal-help-bubble { bottom: max(20px, env(safe-area-inset-bottom)); }

/* Idle floating bubble needs to clear the new bottom tab bar on
   mobile; the open sheet (.chat-widget-panel) already slides up over
   it by design (see styles.css's "slides up from under the sticky
   footer" comment), so that one needs no change here. Must come after
   the unscoped rule above — same specificity, so source order is what
   makes this win inside the media query. */
@media (max-width: 640px) {
  .portal-help-bubble {
    bottom: calc(var(--portal-bottom-nav-offset) + var(--portal-bottom-nav-h) + env(safe-area-inset-bottom, 0px) + 14px);
  }
}

/* Desktop only — mobile's .chat-widget-panel already anchors with its
   own bottom:0 (full sheet) to make the translateY(100%) closed state
   land fully off-screen; overriding bottom here unscoped broke that
   math and left the sheet's header peeking in at the bottom while
   "closed" on narrow viewports. */
@media (min-width: 481px) {
  .portal-help-panel { bottom: calc(max(20px, env(safe-area-inset-bottom)) + 70px); }
}

.portal-help-footer { flex-shrink: 0; }
.portal-help-submit-btn {
  display: block;
  width: calc(100% - 24px);
  margin: 0 12px 12px;
  font-size: 14px;
  padding: 11px 0;
}
.portal-help-notice:empty { display: none; }
.portal-help-notice-msg, .portal-help-error-msg {
  border-radius: 12px; padding: 10px 14px; font-size: 13px; margin: 0 12px 12px;
}
.portal-help-notice-msg { background: #eef4ff; color: #1a6fe8; }
.portal-help-error-msg { background: #fdeeee; color: #c5362f; }

/* Account settings used to be a popup sheet (portal-settings-widget.js)
   — now a plain page (settings.php), reusing just the field/button/
   notice styling below. A real page sidesteps the whole class of
   bugs that sheet kept running into: the keyboard-covers-the-sheet
   gap on Android, iOS's AutoFill Contact bar, pinch-zoom on focus —
   all symptoms of fighting a fixed-position overlay against the
   keyboard instead of just letting the page scroll normally. */
.portal-settings-field { margin-bottom: 14px; }
.portal-settings-field label {
  display: block; font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.04em; color: #86868b; margin-bottom: 6px;
}
.portal-settings-field input {
  width: 100%; padding: 11px 14px; border: 1px solid rgba(0,0,0,0.1); border-radius: 10px;
  font-size: 14px; font-family: inherit; background: #ffffff;
}
/* iOS Safari auto-zooms the whole page when focusing a text input
   under 16px — same fix as .chat-widget-form input in styles.css,
   which is what was causing the settings sheet to open pinch-zoomed
   in once a field was focused (e.g. tapping into Address). */
@media (max-width: 480px) {
  .portal-settings-field input {
    font-size: 16px;
  }
}
.portal-settings-save { border: none; cursor: pointer; font-family: inherit; font-size: 14px; }
.portal-settings-notice:empty { display: none; }
.portal-settings-notice-msg, .portal-settings-error-msg {
  border-radius: 12px; padding: 10px 14px; font-size: 13px; margin-top: 10px;
}
.portal-settings-notice-msg { background: #e8f8ee; color: #2f8f5b; }
.portal-settings-error-msg { background: #fdeeee; color: #c5362f; }
