/*
 * Owner-only bottom-control pass. The existing five-tab navigation and
 * authenticated Community action are children of one non-interactive fixed
 * chassis. No interactive element, ID, route or handler is duplicated.
 */

:root {
  --rebuild-deck-nav-height: 64px;
  --rebuild-deck-community-height: 48px;
  --rebuild-deck-border-width: 1px;
  --rebuild-deck-bottom-offset: 8px;
  --rebuild-deck-content-gap: 10px;
  --rebuild-deck-visible-height: calc(var(--rebuild-deck-nav-height) + (2 * var(--rebuild-deck-border-width)));
  --today-card-stack-tail: 20px;
}

html.community-entry-available {
  --rebuild-deck-visible-height: calc(var(--rebuild-deck-nav-height) + var(--rebuild-deck-community-height) + (2 * var(--rebuild-deck-border-width)));
}

html body > .rebuild-bottom-control-deck {
  position: fixed;
  z-index: 220;
  left: 50%;
  bottom: calc(var(--rebuild-deck-bottom-offset) + env(safe-area-inset-bottom));
  display: flex;
  width: min(calc(100% - 16px), 430px);
  border: var(--rebuild-deck-border-width) solid rgba(100, 126, 137, 0.42);
  border-radius: 22px;
  box-sizing: border-box;
  flex-direction: column;
  overflow: hidden;
  transform: translateX(-50%);
  background: linear-gradient(180deg, #fff8f1 0%, #f4ebe2 66%, #e7d8cb 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.96),
    inset 0 -2px 0 rgba(163, 139, 121, 0.14),
    0 1px 0 rgba(255, 255, 255, 0.68),
    0 7px 12px rgba(37, 59, 71, 0.17),
    0 16px 28px rgba(37, 59, 71, 0.13);
}

html body > .rebuild-bottom-control-deck::before {
  content: "";
  position: absolute;
  z-index: 2;
  top: 1px;
  right: 15px;
  left: 15px;
  height: 1px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  pointer-events: none;
}

/*
 * The historical inline navigation layers fix height, padding, border,
 * background, shadow and the authenticated bottom offset with !important.
 * Matching priority is limited to those exact properties here.
 */
html body > .rebuild-bottom-control-deck > nav.nav,
html.community-entry-available body > .rebuild-bottom-control-deck > nav.nav {
  position: relative;
  left: auto;
  bottom: auto !important;
  display: grid;
  width: 100%;
  height: var(--rebuild-deck-nav-height) !important;
  border: 0 !important;
  border-radius: 0;
  padding: 4px 6px 3px !important;
  transform: none;
  background: transparent !important;
  box-shadow: none !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
}

html body > .rebuild-bottom-control-deck > nav.nav > button,
html.community-entry-available body > .rebuild-bottom-control-deck > nav.nav > button {
  min-width: 0;
  min-height: 44px;
  border: 0;
  border-radius: 13px;
  background: transparent;
  transition: transform 140ms ease, background-color 140ms ease, color 140ms ease;
}

html body > .rebuild-bottom-control-deck > nav.nav > button::before,
html.community-entry-available body > .rebuild-bottom-control-deck > nav.nav > button::before {
  top: 1px;
  height: 3px;
  border-radius: 999px;
  opacity: 0;
  transition: width 140ms ease, opacity 140ms ease;
}

html body > .rebuild-bottom-control-deck > nav.nav > button.on,
html.community-entry-available body > .rebuild-bottom-control-deck > nav.nav > button.on {
  border-top: 0;
  background: rgba(255, 255, 255, 0.24);
  font-weight: 950;
}

html body > .rebuild-bottom-control-deck > nav.nav > button.on::before,
html.community-entry-available body > .rebuild-bottom-control-deck > nav.nav > button.on::before {
  width: 18px;
  opacity: 0.9;
}

html body > .rebuild-bottom-control-deck > nav.nav > button:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--tab-accent, #20d5ef) 52%, #193a48);
  outline-offset: -2px;
}

html body > .rebuild-bottom-control-deck > nav.nav > button:active {
  transform: translateY(1px);
}

/* Community remains the same single button, now forming the lower deck row. */
html body > .rebuild-bottom-control-deck > .community-entry-dock {
  position: relative;
  left: auto;
  bottom: auto !important;
  width: 100%;
  height: var(--rebuild-deck-community-height) !important;
  transform: none;
  background: transparent !important;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  pointer-events: none;
}

html body > .rebuild-bottom-control-deck > .community-entry-dock[hidden] {
  display: none !important;
}

html body > .rebuild-bottom-control-deck > .community-entry-dock > .community-entry {
  position: relative;
  width: 100%;
  height: var(--rebuild-deck-community-height) !important;
  min-height: var(--rebuild-deck-community-height) !important;
  border: 0;
  border-top: 1px solid rgba(100, 126, 137, 0.28) !important;
  border-radius: 0;
  padding: 0 12px !important;
  box-sizing: border-box;
  justify-content: flex-start !important;
  gap: 8px !important;
  background: linear-gradient(180deg, rgba(255, 248, 241, 0.72) 0%, rgba(231, 216, 203, 0.56) 100%) !important;
  color: #193a48;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.86),
    inset 0 3px 7px rgba(37, 59, 71, 0.035) !important;
  pointer-events: auto;
  transition: transform 140ms ease, background-color 140ms ease, box-shadow 140ms ease;
}

html body > .rebuild-bottom-control-deck > .community-entry-dock > .community-entry[aria-current="page"] {
  background: linear-gradient(180deg, #f8eee5 0%, #eadbce 100%) !important;
  box-shadow:
    inset 3px 0 0 #20d5ef,
    inset 0 1px 0 rgba(255, 255, 255, 0.88),
    inset 0 3px 7px rgba(37, 59, 71, 0.055) !important;
}

html body > .rebuild-bottom-control-deck > .community-entry-dock > .community-entry:focus-visible {
  outline: 3px solid rgba(32, 213, 239, 0.58);
  outline-offset: -4px;
}

html body > .rebuild-bottom-control-deck > .community-entry-dock > .community-entry:active {
  transform: translateY(1px);
  box-shadow:
    inset 0 2px 4px rgba(37, 59, 71, 0.11),
    inset 0 1px 0 rgba(255, 255, 255, 0.7) !important;
}

html body > .rebuild-bottom-control-deck .community-entry-logo {
  position: relative !important;
  display: block !important;
  width: 92px !important;
  height: 28px !important;
  flex: 0 0 92px !important;
  overflow: hidden !important;
  border: 1px solid rgba(100, 126, 137, 0.16) !important;
  border-radius: 6px !important;
  background: #fff8f1 !important;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.92), 0 1px 2px rgba(37, 59, 71, 0.1) !important;
}

html body > .rebuild-bottom-control-deck .community-entry-logo > img {
  position: absolute !important;
  inset: 0 !important;
  display: block;
  width: 100% !important;
  height: 100% !important;
  max-width: none !important;
  object-fit: cover;
  transform: none !important;
}

html body > .rebuild-bottom-control-deck .community-entry-copy {
  display: block !important;
  flex: 0 1 auto !important;
  min-width: 0 !important;
}

html body > .rebuild-bottom-control-deck .community-entry-copy > strong {
  color: #193a48 !important;
  font-size: 12px !important;
  line-height: 1 !important;
  letter-spacing: 0.045em !important;
  white-space: nowrap !important;
}

html body > .rebuild-bottom-control-deck .community-entry-here {
  flex: 0 0 auto;
  border: 1px solid rgba(25, 58, 72, 0.18);
  border-radius: 999px;
  padding: 3px 5px;
  background: rgba(255, 255, 255, 0.38);
  color: #586d77;
  font-size: 8px;
  font-weight: 950;
  line-height: 1;
  letter-spacing: 0.08em;
}

html body > .rebuild-bottom-control-deck .community-entry-badge:not([hidden]) {
  margin-left: auto !important;
  background: #193a48;
  color: #fff7ea;
}

html body > .rebuild-bottom-control-deck .community-entry-arrow {
  position: static !important;
  display: grid;
  width: 30px !important;
  min-width: 30px !important;
  height: 30px !important;
  margin-left: auto !important;
  border: 1px solid rgba(32, 213, 239, 0.48) !important;
  border-radius: 10px !important;
  padding: 0 !important;
  place-items: center;
  background: linear-gradient(145deg, #fffdf8 0%, #e9ded3 100%) !important;
  color: #193a48 !important;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.94), 0 2px 4px rgba(37, 59, 71, 0.14) !important;
  font-size: 18px !important;
  line-height: 1 !important;
  transform: none;
}

html body > .rebuild-bottom-control-deck .community-entry-badge:not([hidden]) + .community-entry-arrow {
  margin-left: 0 !important;
}

/*
 * Today clearance is calculated once from the fixed deck, its offset, the
 * requested 10px finish gap and the unchanged 20px tail inside the card stack.
 */
html body > main.app:has(> #today.page.on) {
  padding-bottom: 0;
}

html body > main.app > #today.page {
  padding-bottom: 0;
}

html body > main.app > #today.page > .today-v3-body {
  padding-bottom: calc(
    var(--rebuild-deck-visible-height)
    + var(--rebuild-deck-bottom-offset)
    + env(safe-area-inset-bottom)
    + var(--rebuild-deck-content-gap)
    - var(--today-card-stack-tail)
  ) !important;
}

html.profile-open body > .rebuild-bottom-control-deck,
html.sos-open body > .rebuild-bottom-control-deck,
html.recovery-tools-open body > .rebuild-bottom-control-deck {
  visibility: hidden;
}

@media (max-width: 370px) {
  html body > .rebuild-bottom-control-deck {
    width: calc(100% - 12px);
    border-radius: 20px;
  }

  html body > .rebuild-bottom-control-deck .community-entry-logo {
    width: 78px !important;
    flex-basis: 78px !important;
  }

  html body > .rebuild-bottom-control-deck .community-entry-copy > strong {
    font-size: 11px !important;
  }

  html body > .rebuild-bottom-control-deck .community-entry-here {
    padding-inline: 4px;
    font-size: 7px;
  }
}

@media (min-width: 800px) {
  html body > .rebuild-bottom-control-deck {
    width: min(calc(100% - 32px), 760px);
  }
}

@media (prefers-reduced-motion: reduce) {
  html body > .rebuild-bottom-control-deck > nav.nav > button,
  html body > .rebuild-bottom-control-deck > nav.nav > button::before,
  html body > .rebuild-bottom-control-deck > nav.nav > button > svg,
  html body > .rebuild-bottom-control-deck .community-entry {
    transition: none !important;
  }
}
