/* =============================================================================
   Morphing Pill Menu — Professional Liquid Glass
   -----------------------------------------------------------------------------
   Liquid Glass vs classic glassmorphism:
   • Glassmorphism → one fill + blur
   • Liquid Glass  → refraction stack + specular rim + edge lens + depth shadow
     that thickens when the pill morphs open
   ============================================================================= */

/* ---------- Reset ---------- */

*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", sans-serif;
  background: #08090c;
  color: #0a0a0a;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

button,
a {
  font: inherit;
  color: inherit;
  text-decoration: none;
  border: 0;
  background: none;
  cursor: pointer;
}

ul {
  list-style: none;
}

img {
  display: block;
  max-width: 100%;
}

/* ---------- Stage ---------- */

.mpm {
  --mpm-fg: rgba(255, 252, 248, 0.94);
  --mpm-fg-soft: rgba(255, 255, 255, 0.78);
  --mpm-accent: #7eb8ff;
  --mpm-margin: 32px;
  --mpm-font: "Inter", -apple-system, BlinkMacSystemFont, sans-serif;

  /* Liquid glass material tokens */
  --glass-blur: 22px;
  --glass-blur-open: 36px;
  --glass-sat: 1.55;
  --glass-bright: 1.08;
  --glass-tint: rgba(255, 255, 255, 0.1);
  --glass-tint-open: rgba(255, 255, 255, 0.14);
  --glass-cool: rgba(180, 210, 255, 0.06);

  position: relative;
  width: 100%;
  height: 100dvh;
  min-height: 100vh;
  overflow: hidden;
  background-color: #08090c;
  font-family: var(--mpm-font);
  -webkit-font-smoothing: antialiased;
}

/* ---------- Backdrop ---------- */

.mpm__bg {
  position: absolute;
  inset: 0;
  z-index: 1;
}

.mpm__bg-image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  transform: scale(1.03);
  filter: saturate(1.08) contrast(1.05);
}

/* Keeps the glass readable without killing the photo */
.mpm__bg-wash {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 70% 55% at 50% 30%, transparent 0%, rgba(8, 9, 12, 0.35) 100%),
    linear-gradient(180deg, rgba(8, 9, 12, 0.25) 0%, transparent 35%, transparent 65%, rgba(8, 9, 12, 0.45) 100%);
  pointer-events: none;
}

.mpm__scrim {
  position: absolute;
  inset: 0;
  z-index: 3;
  background:
    radial-gradient(ellipse 80% 60% at 50% 20%, rgba(6, 8, 14, 0.2), rgba(6, 8, 14, 0.5));
  opacity: 0;
  pointer-events: none;
}

/* ---------- Morphing surface ---------- */

.mpm__surface {
  position: absolute;
  top: 28px;
  left: 50%;
  z-index: 100;
  width: 110px;
  height: 46px;
  border-radius: 23px;
  transform: translateX(-50%);
  overflow: hidden;
  isolation: isolate;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.28) inset,
    0 -1px 0 rgba(0, 0, 0, 0.12) inset,
    0 10px 32px rgba(0, 0, 0, 0.32),
    0 2px 8px rgba(0, 0, 0, 0.18);
  will-change: width, height, border-radius, box-shadow;
  transition: box-shadow 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}

/* Thicker material when open — deeper cast + richer inner rim */
.mpm[data-mpm-open] .mpm__surface {
  box-shadow:
    0 1.5px 0 rgba(255, 255, 255, 0.35) inset,
    0 0 0 0.5px rgba(255, 255, 255, 0.12) inset,
    0 -2px 12px rgba(0, 0, 0, 0.15) inset,
    0 32px 72px rgba(0, 0, 0, 0.48),
    0 14px 32px rgba(0, 0, 0, 0.3),
    0 0 40px rgba(120, 170, 255, 0.06);
}

/* ---------- Liquid glass material stack ----------
   1. filter      — SVG displacement lens (Chrome/Edge)
   2. refraction  — multi-pass blur / sat / contrast
   3. specular    — soft light catch (top + corners)
   4. highlight   — thin top rim streak
   5. tint        — cool milky body
   6. edge        — refractive perimeter stroke
   7. inner       — subtle bottom occlusion
*/

.mpm__glass {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  overflow: hidden;
  pointer-events: none;
  z-index: 0;
}

/* Optional SVG lens — ignored gracefully where unsupported */
.mpm__glass-filter {
  position: absolute;
  inset: -2px;
  border-radius: inherit;
  backdrop-filter: url(#liquid-glass-lens);
  -webkit-backdrop-filter: url(#liquid-glass-lens);
  opacity: 0.85;
}

.mpm__glass-refraction {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background:
    linear-gradient(
      165deg,
      rgba(255, 255, 255, 0.08) 0%,
      rgba(255, 255, 255, 0.02) 45%,
      rgba(200, 220, 255, 0.04) 100%
    );
  backdrop-filter:
    blur(var(--glass-blur))
    saturate(var(--glass-sat))
    brightness(var(--glass-bright))
    contrast(1.05);
  -webkit-backdrop-filter:
    blur(var(--glass-blur))
    saturate(var(--glass-sat))
    brightness(var(--glass-bright))
    contrast(1.05);
  transition:
    backdrop-filter 0.5s cubic-bezier(0.22, 1, 0.36, 1),
    -webkit-backdrop-filter 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}

.mpm[data-mpm-open] .mpm__glass-refraction {
  backdrop-filter:
    blur(var(--glass-blur-open))
    saturate(var(--glass-sat))
    brightness(1.1)
    contrast(1.06);
  -webkit-backdrop-filter:
    blur(var(--glass-blur-open))
    saturate(var(--glass-sat))
    brightness(1.1)
    contrast(1.06);
}

/* Specular volume — simulates light through a curved liquid lens */
.mpm__glass-specular {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background:
    linear-gradient(
      155deg,
      rgba(255, 255, 255, 0.55) 0%,
      rgba(255, 255, 255, 0.14) 22%,
      rgba(255, 255, 255, 0.03) 42%,
      transparent 58%
    ),
    radial-gradient(
      110% 70% at 12% -5%,
      rgba(255, 255, 255, 0.42) 0%,
      transparent 42%
    ),
    radial-gradient(
      80% 60% at 95% 105%,
      rgba(0, 0, 0, 0.22) 0%,
      transparent 50%
    ),
    radial-gradient(
      60% 40% at 70% 0%,
      rgba(200, 225, 255, 0.12) 0%,
      transparent 55%
    );
  mix-blend-mode: soft-light;
  opacity: 1;
}

/* Thin top highlight streak — glass catching a key light */
.mpm__glass-highlight {
  position: absolute;
  left: 8%;
  right: 8%;
  top: 0;
  height: 1px;
  border-radius: 999px;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255, 255, 255, 0.15) 15%,
    rgba(255, 255, 255, 0.75) 50%,
    rgba(255, 255, 255, 0.15) 85%,
    transparent 100%
  );
  opacity: 0.9;
  filter: blur(0.3px);
}

.mpm[data-mpm-open] .mpm__glass-highlight {
  left: 6%;
  right: 6%;
  opacity: 1;
}

/* Cool milky body */
.mpm__glass-tint {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background:
    linear-gradient(
      180deg,
      var(--glass-tint) 0%,
      rgba(255, 255, 255, 0.04) 55%,
      var(--glass-cool) 100%
    );
  transition: background 0.5s ease;
}

.mpm[data-mpm-open] .mpm__glass-tint {
  background:
    linear-gradient(
      180deg,
      var(--glass-tint-open) 0%,
      rgba(255, 255, 255, 0.06) 50%,
      rgba(170, 200, 255, 0.08) 100%
    );
}

/* Refractive edge stroke via mask composite */
.mpm__glass-edge {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  border: 1px solid transparent;
  background:
    linear-gradient(
        140deg,
        rgba(255, 255, 255, 0.72) 0%,
        rgba(255, 255, 255, 0.22) 28%,
        rgba(255, 255, 255, 0.06) 50%,
        rgba(180, 210, 255, 0.18) 72%,
        rgba(255, 255, 255, 0.4) 100%
      )
      border-box;
  -webkit-mask:
    linear-gradient(#fff 0 0) padding-box,
    linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask:
    linear-gradient(#fff 0 0) padding-box,
    linear-gradient(#fff 0 0);
  mask-composite: exclude;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.55),
    inset 0 -1px 0 rgba(0, 0, 0, 0.14);
  opacity: 0.95;
}

/* Soft bottom occlusion — glass thickness / contact shadow inside the pill */
.mpm__glass-inner {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow:
    inset 0 -18px 28px rgba(0, 0, 0, 0.08),
    inset 0 12px 20px rgba(255, 255, 255, 0.04);
  opacity: 0.7;
  transition: opacity 0.45s ease;
}

.mpm[data-mpm-open] .mpm__glass-inner {
  opacity: 1;
  box-shadow:
    inset 0 -28px 40px rgba(0, 0, 0, 0.1),
    inset 0 16px 28px rgba(255, 255, 255, 0.05);
}

/* ---------- Toggle ---------- */

.mpm__toggle {
  position: absolute;
  top: 0;
  left: 50%;
  z-index: 2;
  transform: translateX(-50%);
  height: 46px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 8px 0 18px;
  color: var(--mpm-fg-soft);
  -webkit-tap-highlight-color: transparent;
}

.mpm__toggle:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.55);
  outline-offset: 3px;
  border-radius: 999px;
}

.mpm__toggle-text {
  overflow: hidden;
  height: 21px;
}

.mpm__toggle-text-roller {
  display: flex;
  flex-direction: column;
  will-change: transform;
}

.mpm__toggle-line {
  display: block;
  height: 21px;
  line-height: 21px;
  font-size: 17px;
  font-weight: 500;
  letter-spacing: -0.01em;
  text-align: center;
  white-space: nowrap;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
}

.mpm__toggle-icon {
  width: 30px;
  height: 30px;
  border-radius: 999px;
  background:
    linear-gradient(160deg, rgba(255, 255, 255, 0.32) 0%, rgba(255, 255, 255, 0.12) 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.45),
    inset 0 -1px 0 rgba(0, 0, 0, 0.08),
    0 0 0 1px rgba(255, 255, 255, 0.1),
    0 2px 6px rgba(0, 0, 0, 0.15);
  color: var(--mpm-fg-soft);
  overflow: hidden;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.mpm__toggle-icon-roller {
  display: flex;
  flex-direction: column;
  will-change: transform;
}

.mpm__toggle-icon-face {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  flex-shrink: 0;
}

/* ---------- Expanded panel ---------- */

.mpm__panel {
  position: absolute;
  top: 0;
  left: 50%;
  z-index: 1;
  width: min(600px, calc(100vw - 24px));
  height: 280px;
  transform: translateX(-50%);
  padding: 56px var(--mpm-margin) var(--mpm-margin);
  box-sizing: border-box;
  color: var(--mpm-fg);
  visibility: hidden;
}

.mpm__body {
  display: grid;
  grid-template-columns: 190px 1fr;
  align-content: center;
  align-items: stretch;
  gap: 32px;
  width: 100%;
  height: 100%;
}

/* Featured media */
.mpm__media {
  position: relative;
  display: block;
  border-radius: 16px;
  overflow: hidden;
  cursor: pointer;
  min-height: 0;
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.12),
    0 8px 24px rgba(0, 0, 0, 0.25);
}

.mpm__media-image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  will-change: transform;
}

.mpm__media-shade {
  position: absolute;
  inset: 0;
  z-index: 1;
  background: linear-gradient(
    to top,
    rgba(0, 0, 0, 0.55) 0%,
    rgba(0, 0, 0, 0) 50%
  );
  opacity: 0;
  pointer-events: none;
}

.mpm__media-cue {
  position: absolute;
  left: 14px;
  bottom: 11px;
  z-index: 2;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: -0.01em;
  color: #ffffff;
  pointer-events: none;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

.mpm__media:focus-visible {
  outline: 2px solid var(--mpm-accent);
  outline-offset: 3px;
}

/* Nav links */
.mpm__nav {
  display: flex;
  align-items: center;
}

.mpm__list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 0;
  padding: 1rem 0;
}

.mpm__item {
  display: block;
}

.mpm__link {
  position: relative;
  display: inline-flex;
  align-items: flex-start;
  gap: 10px;
  color: var(--mpm-fg);
  cursor: pointer;
  padding-block: 2px;
  -webkit-tap-highlight-color: transparent;
}

.mpm__link-text {
  position: relative;
  display: inline-block;
  white-space: nowrap;
  font-size: clamp(28px, 3vw, 34px);
  font-weight: 400;
  letter-spacing: -0.02em;
  line-height: 1.08;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.2);
}

.mpm__link-badge {
  align-self: flex-start;
  margin-top: 0.35em;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: var(--mpm-accent);
  text-shadow: 0 0 12px rgba(126, 184, 255, 0.45);
}

.mpm__link:focus-visible {
  outline: none;
}

.mpm__link:focus-visible .mpm__link-text {
  text-decoration: underline;
  text-underline-offset: 4px;
}

/* ---------- Character split ---------- */

.mpm__char {
  position: relative;
  display: inline-block;
  overflow-x: visible;
  overflow-y: hidden;
  padding-bottom: 0.12em;
  margin-bottom: -0.12em;
  vertical-align: top;
}

.mpm__char-inner {
  position: relative;
  display: inline-block;
  will-change: transform;
}

.mpm__char-face {
  display: block;
}

.mpm__char-face--next {
  position: absolute;
  left: 0;
  top: 0;
  transform: translateY(110%);
}

.mpm__char-space {
  display: inline-block;
  white-space: pre;
}

/* ---------- SVG defs (off-screen) ---------- */

.mpm-svg {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
  pointer-events: none;
}

/* ---------- Responsive ---------- */

@media (max-width: 600px) {
  .mpm {
    --mpm-margin: 22px;
  }

  .mpm__panel {
    height: 430px;
  }

  .mpm__body {
    grid-template-columns: 1fr;
    gap: 20px;
  }

  .mpm__media {
    height: 150px;
  }

  .mpm__link-text {
    font-size: clamp(26px, 8vw, 32px);
  }
}

/* Prefer reduced motion: drop non-essential glass transitions */
@media (prefers-reduced-motion: reduce) {
  .mpm__surface,
  .mpm__glass-refraction,
  .mpm__glass-tint,
  .mpm__glass-inner {
    transition: none;
  }
}

/*
  Fallback when SVG backdrop-filter is unsupported:
  the refraction layer alone still produces a rich frosted liquid look.
*/
@supports not ((backdrop-filter: url(#liquid-glass-lens)) or (-webkit-backdrop-filter: url(#liquid-glass-lens))) {
  .mpm__glass-filter {
    display: none;
  }

  .mpm__glass-refraction {
    backdrop-filter:
      blur(26px)
      saturate(1.6)
      brightness(1.1)
      contrast(1.06);
    -webkit-backdrop-filter:
      blur(26px)
      saturate(1.6)
      brightness(1.1)
      contrast(1.06);
  }

  .mpm[data-mpm-open] .mpm__glass-refraction {
    backdrop-filter:
      blur(40px)
      saturate(1.65)
      brightness(1.12)
      contrast(1.07);
    -webkit-backdrop-filter:
      blur(40px)
      saturate(1.65)
      brightness(1.12)
      contrast(1.07);
  }
}
