/* The floating tab at the bottom of the screen (Figma: "Frame 356"): the
 carousel / list switch (js/layout-toggle.js) and the sound button
 (js/sound-toggle.js). On the homepage and the guest book page. */

.view-tab {
  /* The toggle's sliding circle: the shared glass lens
     (css/styles.css) */
  --view-tab-lens-bg: var(--lens-bg);
  --view-tab-lens-shadow: var(--lens-shadow);
  --view-tab-icon-emboss: var(--icon-emboss);
  position: fixed;
  left: 0;
  right: 0;
  bottom: calc(1.5rem + env(safe-area-inset-bottom));
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 1.25rem;
  width: fit-content;
  margin-inline: auto; /* centered (no transform, so the page's fade-up can move it) */
  padding: 0.25rem;
  border-radius: 999px;
  /* Frosted glass: a light see-through tint over a strong blur of
     what's behind (colors kept a little richer), a bright edge
     along the top, a faint rim, and a soft shadow under it */
  /* Clear glass: only a faint sheen (brighter at the top), and
     just enough blur to soften what's behind without frosting it */
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.22) 0%, rgba(255, 255, 255, 0.06) 100%);
  -webkit-backdrop-filter: blur(4px) saturate(160%);
  backdrop-filter: blur(4px) saturate(160%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.7),
    inset 0 0 0 1px rgba(255, 255, 255, 0.25),
    0 0 0 0.5px rgba(0, 0, 0, 0.06),
    0 8px 24px rgba(0, 0, 0, 0.08),
    0 2px 6px rgba(0, 0, 0, 0.04);
}
/* Dark (the archive): a smoky glass instead */
html.is-dark .view-tab {
  --view-tab-lens-bg:
    radial-gradient(60% 35% at 50% 12%, rgba(255, 255, 255, 0.18) 0%, rgba(255, 255, 255, 0) 100%),
    radial-gradient(circle, rgba(255, 255, 255, 0) 58%, rgba(255, 255, 255, 0.08) 100%);
  --view-tab-lens-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.2),
    inset 0 -1px 1px rgba(255, 255, 255, 0.06),
    inset 0 -4px 8px rgba(0, 0, 0, 0.2),
    0 0 0 0.5px rgba(0, 0, 0, 0.6),
    0 2px 4px rgba(0, 0, 0, 0.35),
    0 6px 12px rgba(0, 0, 0, 0.25);
  --view-tab-icon-emboss: drop-shadow(0 -1px 0 rgba(0, 0, 0, 0.6));
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.07) 0%, rgba(255, 255, 255, 0.02) 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.12),
    inset 0 0 0 1px rgba(255, 255, 255, 0.06),
    0 8px 24px rgba(0, 0, 0, 0.35);
}
/* The toggle: a second, inner pill */
.layout-toggle {
  position: relative;
  display: flex;
  gap: 0.25rem;
  border-radius: 999px;
  /* Recessed, like a slot the circle slides in (css/styles.css) */
  background-color: var(--slot-bg);
  box-shadow: var(--slot-shadow);
}
html.is-dark .layout-toggle {
  background-color: rgba(0, 0, 0, 0.25);
  box-shadow:
    inset 0 1px 3px rgba(0, 0, 0, 0.5),
    0 1px 0 rgba(255, 255, 255, 0.06);
}
/* The glass lens over the chosen button. It slides between the
   two (one button's width + the gap) instead of switching on/off.
   It sits on top of the icons, and clicks and drags pass through
   it to the buttons. */
.layout-toggle::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 2.75rem;
  height: 2.75rem;
  z-index: 1;
  pointer-events: none;
  border-radius: 50%;
  background: var(--view-tab-lens-bg);
  box-shadow: var(--view-tab-lens-shadow);
}
html.is-list-layout .layout-toggle::before {
  translate: 3rem 0;
}
/* Only slides once the page is set up, so it doesn't slide over
   when a page opens already in list view (js/layout-toggle.js) */
.layout-toggle.is-ready::before {
  transition: translate 0.45s cubic-bezier(0.22, 1, 0.36, 1); /* the site's arrival ease */
}
.layout-toggle button {
  position: relative; /* under the lens */
  display: grid;
  place-items: center;
  width: 2.75rem;
  height: 2.75rem;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background-color: transparent;
  color: var(--black);
  cursor: pointer;
}
/* The circle can also be dragged across (js/layout-toggle.js) */
.layout-toggle {
  touch-action: pan-y; /* sideways drags move the circle, not the page */
}
.layout-toggle button[aria-pressed="true"] {
  cursor: grab;
}
.view-tab .layout-toggle.is-dragging,
.view-tab .layout-toggle.is-dragging button {
  cursor: grabbing;
}
/* While dragging it follows the finger or mouse exactly (--drag) */
.view-tab .layout-toggle.is-dragging::before {
  translate: var(--drag) 0;
  transition: none;
}
/* The chosen layout's icon is full size, the other a little
   smaller. --p is how far the circle is toward list (0 to 1),
   so while dragging they grow and shrink as it moves. */
.layout-toggle {
  --p: 0;
}
html.is-list-layout .layout-toggle {
  --p: 1;
}
.view-tab .layout-toggle.is-dragging {
  --p: var(--drag-p);
}
.layout-toggle svg {
  transition: scale 0.45s cubic-bezier(0.22, 1, 0.36, 1); /* same as the circle */
}
.layout-toggle [data-layout="carousel"] svg {
  scale: calc(1 - 0.2 * var(--p));
}
.layout-toggle [data-layout="list"] svg {
  scale: calc(0.8 + 0.2 * var(--p));
}
.view-tab .layout-toggle.is-dragging svg {
  transition: none;
}
.view-tab button:focus-visible {
  outline: 2px solid var(--black);
  outline-offset: 2px;
}
.view-tab svg {
  width: 1.5rem;
  height: 1.5rem;
}
.view-tab svg {
  filter: var(--view-tab-icon-emboss);
}
/* Sound on/off (js/sound-toggle.js): a plain round button beside
   the toggle. Off, the sound waves give way to an x. */
.sound-toggle {
  display: grid;
  place-items: center;
  width: 2.75rem;
  height: 2.75rem;
  margin-left: -0.75rem; /* closer to the toggle than the tab's gap */
  padding: 0;
  border: 0;
  border-radius: 50%;
  background-color: transparent;
  color: var(--black);
  cursor: pointer;
}
.sound-toggle g {
  transform-box: view-box;
  transform-origin: 17px 12px;
  transition: opacity 0.25s ease, scale 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.sound-toggle .sound-mute,
html.is-sound-off .sound-toggle .sound-waves {
  opacity: 0;
  scale: 0.4;
}
html.is-sound-off .sound-toggle .sound-mute {
  opacity: 1;
  scale: 1;
}
/* Fades out and drops away as the footer comes up from under the
   page (html.footer-near, js/site-footer.js), rather than being
   cut off by the page's edge; comes back on the way up */
.view-tab {
  transition:
    opacity 0.3s ease,
    translate 0.45s cubic-bezier(0.22, 1, 0.36, 1),
    scale 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}
html.footer-near .view-tab {
  opacity: 0;
  translate: 0 1.5rem;
  scale: 0.92;
  pointer-events: none;
}
/* On page load it fades up after the cards (css/page-intro.css) */
html.page-intro .view-tab {
  animation: page-intro 550ms cubic-bezier(0.22, 1, 0.36, 1) 450ms backwards;
}
@media screen and (max-width: 479px) {
  .view-tab {
    bottom: calc(2rem + env(safe-area-inset-bottom));
  }
}
