/*
 * Navigation Twink
 * - mobile: floating glass tabbar adapted from the newer KVS sibling theme
 * - desktop: accessible disclosure mega-menu
 *
 * This file intentionally contains only semantic Twink tokens. The source
 * project's palette is not imported here.
 */

:root {
  --nav-accent: var(--btn-bg-act);
  --nav-accent-text: var(--btn-bg-act);
  --nav-focus: var(--btn-bg-act);
  --nav-accent-hover: #3cbff0;
  --nav-accent-soft: rgba(60, 191, 240, .12);
  --nav-accent-faint: rgba(60, 191, 240, .08);
  --nav-on-accent: var(--black-color);

  --nav-panel-bg: var(--main-background);
  --nav-sidebar-bg: var(--surface-1);
  --nav-text: var(--text-subtle);
  --nav-text-strong: var(--general-color);
  --nav-text-dim: var(--text-muted);
  --nav-icon: var(--text-muted);
  --nav-border: var(--surface-outline-strong);
  --nav-hairline: var(--surface-outline);
  --nav-hover: rgba(255, 255, 255, .06);
  --nav-shadow: 0 24px 64px rgba(0, 0, 0, .70), 0 2px 8px rgba(0, 0, 0, .40);
  --nav-overlay: rgba(0, 0, 0, .55);
  --nav-skeleton: rgba(255, 255, 255, .05);
  --nav-skeleton-highlight: rgba(255, 255, 255, .09);

  --tabbar-glass-bg: rgba(24, 24, 24, .68);
  --tabbar-glass-border: var(--surface-outline-strong);
  --tabbar-glass-sheen: rgba(255, 255, 255, .07);
}

html.light {
  --nav-accent-text: #006f93;
  --nav-focus: #006f93;
  --nav-sidebar-bg: var(--surface-2);
  --nav-hover: rgba(0, 0, 0, .05);
  --nav-shadow: 0 24px 64px rgba(0, 0, 0, .16), 0 2px 8px rgba(0, 0, 0, .08);
  --nav-overlay: rgba(0, 0, 0, .30);
  --nav-skeleton: rgba(0, 0, 0, .05);
  --nav-skeleton-highlight: rgba(0, 0, 0, .10);
  --tabbar-glass-bg: rgba(255, 255, 255, .72);
  --tabbar-glass-border: var(--surface-outline-strong);
  --tabbar-glass-sheen: rgba(255, 255, 255, .90);
}

/* -------------------------------------------------------------------------
   Mobile tabbar and bottom sheet
   ---------------------------------------------------------------------- */

@media (max-width: 1020px) {
  .tabbar {
    left: 50%;
    right: auto;
    bottom: calc(10px + env(safe-area-inset-bottom, 0px));
    width: calc(100% - 28px);
    max-width: 440px;
    height: auto;
    min-height: 60px;
    padding: 7px 4px 8px;
    border: 1px solid var(--tabbar-glass-border);
    border-radius: 24px;
    background: var(--tabbar-glass-bg);
    -webkit-backdrop-filter: blur(26px) saturate(180%);
    backdrop-filter: blur(26px) saturate(180%);
    box-shadow: 0 10px 30px rgba(0, 0, 0, .42),
                0 2px 8px rgba(0, 0, 0, .28),
                inset 0 1px 0 var(--tabbar-glass-sheen);
    overflow: hidden;
    -webkit-transform: translateX(-50%) translateZ(0);
    transform: translateX(-50%) translateZ(0);
  }

  html.light .tabbar {
    background: var(--tabbar-glass-bg);
    border-color: var(--tabbar-glass-border);
    box-shadow: 0 10px 30px rgba(15, 35, 48, .14),
                0 2px 8px rgba(15, 35, 48, .08),
                inset 0 1px 0 var(--tabbar-glass-sheen);
  }

  .tabbar-tab {
    min-width: 0;
    padding: 4px 0;
    gap: 4px;
    border-radius: 16px;
  }

  .tabbar-tab .tabbar-icon {
    width: 22px;
    height: 22px;
  }

  .tabbar-label {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 11px;
    line-height: 1.1;
    letter-spacing: -.01em;
  }

  .tabbar-tab.active .tabbar-label {
    font-weight: 700;
  }

  .tabbar-dot {
    top: -1px;
  }

  .tabbar-shorts-box {
    width: 32px;
    height: 32px;
    border-radius: 9px;
  }

  body {
    padding-bottom: calc(88px + env(safe-area-inset-bottom, 0px));
  }

  body.nav-open,
  body.profile-open {
    overflow: hidden !important;
  }

  .footer {
    padding-bottom: 8px;
  }

  /* The floating pill must overlay the sheet rather than leave an empty band. */
  .header-nav {
    bottom: 0;
    max-height: 82vh;
    padding-bottom: calc(88px + env(safe-area-inset-bottom, 0px));
    border-radius: 18px 18px 0 0;
    transform: translateY(110%);
    visibility: hidden;
    pointer-events: none;
    transition: transform .3s cubic-bezier(.16, 1, .3, 1), visibility 0s linear .3s;
  }

  body.nav-open .header-nav {
    transform: translateY(0);
    visibility: visible;
    pointer-events: auto;
    transition-delay: 0s;
  }

  .profile-sheet {
    visibility: hidden;
    transition: transform .3s cubic-bezier(.32, .72, 0, 1), visibility 0s linear .3s;
  }

  .header-nav,
  .profile-sheet {
    overscroll-behavior: contain;
  }

  body.profile-open .profile-sheet {
    visibility: visible;
    transition-delay: 0s;
  }

  .header-nav .nav-link:last-child {
    border-bottom: 0;
  }

  .tabbar-tab:focus-visible,
  .mh-user-btn:focus-visible,
  .header-nav a:focus-visible,
  .profile-sheet a:focus-visible {
    outline: 2px solid var(--nav-focus);
    outline-offset: 2px;
  }

  html.light .tabbar-tab.active,
  html.light .tabbar-more.sheet-open {
    color: var(--nav-accent-text);
  }
}

@media (max-width: 359px) {
  .tabbar {
    width: calc(100% - 16px);
  }

  .tabbar-label {
    font-size: 10px;
  }
}

/* -------------------------------------------------------------------------
   Desktop mega-menu
   ---------------------------------------------------------------------- */

@media (min-width: 1021px) {
  .wrapper {
    height: auto;
    min-height: 100%;
  }

  .header-nav {
    position: sticky;
    top: 0;
    right: auto;
    bottom: auto;
    left: auto;
    max-height: none;
    padding-bottom: 6px;
    border-radius: 0;
    overflow: visible;
    transform: none;
    visibility: visible;
    pointer-events: auto;
    transition: none;
    z-index: 100;
  }

  .header-nav .header-inner {
    flex-direction: row;
    justify-content: space-between;
    padding-bottom: 0;
  }

  .mm-bar {
    --mm-sidebar-width: 244px;
    --mm-padding: 24px;
    --mm-row-height: 40px;
    --mm-row-gap: 2px;
    --mm-link-size: 15px;
    --mm-icon-size: 18px;
    --mm-icon-gap: 12px;
    --mm-grid-gap: 16px;
    --mm-trigger-height: 38px;
    --mm-trigger-size: 15px;
    --mm-trigger-padding: 16px;
    --mm-toggle-width: 28px;
    --mm-radius: 8px;

    display: flex;
    align-items: center;
    gap: 4px;
    width: 100%;
    position: relative;
    padding: 4px 0;
  }

  .mm-item {
    position: static;
    display: flex;
    align-items: center;
    border-radius: var(--mm-radius);
    transition: background .15s;
  }

  .mm-item:hover,
  .mm-item.mm-open,
  html.light .mm-item:hover,
  html.light .mm-item.mm-open {
    background: var(--nav-hover);
  }

  .mm-item:has(.mm-trigger.mm-active):hover,
  .mm-item.mm-open:has(.mm-trigger.mm-active),
  html.light .mm-item:has(.mm-trigger.mm-active):hover,
  html.light .mm-item.mm-open:has(.mm-trigger.mm-active) {
    background: var(--nav-accent-faint);
  }

  .mm-trigger,
  html.light .mm-trigger {
    position: relative;
    display: flex;
    align-items: center;
    gap: 6px;
    min-height: var(--mm-trigger-height);
    padding: 0 var(--mm-trigger-padding);
    border: 0;
    border-radius: var(--mm-radius);
    background: transparent;
    color: var(--nav-text);
    text-transform: uppercase;
    font-size: var(--mm-trigger-size);
    font-weight: 700;
    line-height: 1;
    letter-spacing: .3px;
    white-space: nowrap;
    text-decoration: none;
    cursor: pointer;
    transition: background .15s, color .15s;
  }

  .mm-trigger:hover,
  .mm-item.mm-open .mm-trigger,
  html.light .mm-trigger:hover,
  html.light .mm-item.mm-open .mm-trigger {
    background: var(--nav-hover);
    color: var(--nav-text-strong);
  }

  .mm-trigger.mm-active,
  html.light .mm-trigger.mm-active {
    color: var(--nav-accent-text);
  }

  .mm-trigger.mm-active:hover,
  .mm-item.mm-open .mm-trigger.mm-active,
  html.light .mm-trigger.mm-active:hover,
  html.light .mm-item.mm-open .mm-trigger.mm-active {
    background: var(--nav-accent-faint);
    color: var(--nav-accent-text);
  }

  .mm-item .mm-trigger:hover,
  .mm-item.mm-open .mm-trigger,
  .mm-item .mm-trigger.mm-active:hover,
  .mm-item.mm-open .mm-trigger.mm-active,
  .mm-item .mm-toggle:hover,
  .mm-item.mm-open .mm-toggle,
  html.light .mm-item .mm-trigger:hover,
  html.light .mm-item.mm-open .mm-trigger,
  html.light .mm-item .mm-trigger.mm-active:hover,
  html.light .mm-item.mm-open .mm-trigger.mm-active,
  html.light .mm-item .mm-toggle:hover,
  html.light .mm-item.mm-open .mm-toggle {
    background: transparent;
  }

  .mm-trigger.mm-active::after,
  .mm-item.mm-open > .mm-trigger::after {
    content: '';
    position: absolute;
    left: var(--mm-trigger-padding);
    right: var(--mm-trigger-padding);
    bottom: -4px;
    height: 3px;
    border-radius: 3px 3px 0 0;
    background: var(--nav-accent);
  }

  .mm-trigger:has(+ .mm-toggle)::after {
    right: calc(var(--mm-trigger-padding) - var(--mm-toggle-width));
  }

  .mm-item > .mm-trigger {
    padding-right: 4px;
  }

  .mm-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: var(--mm-toggle-width);
    height: 32px;
    margin: 0;
    padding: 0;
    border: 0;
    background: transparent;
    color: inherit;
    cursor: pointer;
    flex-shrink: 0;
  }

  .mm-chevron {
    width: 12px;
    height: 12px;
    opacity: .55;
    pointer-events: none;
    flex-shrink: 0;
    transition: transform .15s, opacity .15s;
  }

  .mm-item:hover .mm-chevron,
  .mm-item.mm-open .mm-chevron,
  .mm-toggle:hover .mm-chevron,
  .mm-toggle[aria-expanded="true"] .mm-chevron {
    opacity: 1;
  }

  .mm-item.mm-open .mm-chevron,
  .mm-toggle[aria-expanded="true"] .mm-chevron {
    transform: rotate(180deg);
  }

  .mm-spacer {
    flex: 1;
  }

  .mm-sponsored,
  html.light .mm-sponsored {
    padding: 0 14px;
    color: var(--nav-text-dim);
    font-size: 13px;
    font-weight: 600;
    text-transform: none;
    letter-spacing: 0;
    box-shadow: inset 0 0 0 1px var(--nav-hairline);
  }

  .mm-badge-live,
  .mm-badge-new {
    display: inline-block;
    margin-left: 6px;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 9px;
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: .5px;
  }

  .mm-badge-live {
    background: #e53e3e;
    color: #fff;
    animation: mm-pulse-live 2s ease-in-out infinite;
  }

  .mm-badge-new,
  html.light .mm-badge-new {
    background: var(--nav-accent);
    color: var(--nav-on-accent);
  }

  @keyframes mm-pulse-live {
    0%, 100% { opacity: 1; }
    50% { opacity: .6; }
  }

  .mm-panel,
  html.light .mm-panel {
    display: none;
    position: absolute;
    top: 100%;
    left: -20px;
    right: -20px;
    z-index: 1000;
    max-height: min(64vh, calc(100vh - 132px));
    overflow: hidden auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    border: 0;
    border-top: 1px solid var(--nav-hairline);
    border-radius: 0 0 14px 14px;
    background: var(--nav-panel-bg);
    box-shadow: var(--nav-shadow);
    opacity: 0;
    transform: translateY(-8px);
    transition: opacity .15s ease, transform .22s cubic-bezier(.2, .7, .3, 1);
  }

  .mm-item.mm-open .mm-panel {
    display: block;
  }

  .mm-item.mm-visible .mm-panel {
    opacity: 1;
    transform: translateY(0);
  }

  .mm-panel::-webkit-scrollbar {
    width: 8px;
  }

  .mm-panel::-webkit-scrollbar-thumb {
    border-radius: 4px;
    background: var(--nav-border);
  }

  .mm-inner {
    display: flex;
    align-items: stretch;
    min-height: 320px;
  }

  .mm-sidebar,
  html.light .mm-sidebar {
    display: flex;
    flex-direction: column;
    gap: 0;
    width: var(--mm-sidebar-width);
    min-width: var(--mm-sidebar-width);
    padding: var(--mm-padding);
    border-right: 1px solid var(--nav-border);
    background: var(--nav-sidebar-bg);
  }

  .mm-cta,
  html.light .mm-cta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--mm-icon-gap);
    min-height: 44px;
    margin-bottom: 18px;
    padding: 0 14px;
    border-radius: var(--mm-radius);
    background: var(--nav-accent);
    color: var(--nav-on-accent);
    font-size: 14px;
    font-weight: 700;
    line-height: 1.25;
    text-align: left;
    text-transform: uppercase;
    letter-spacing: .4px;
    text-decoration: none;
    transition: background .15s, transform .15s, box-shadow .15s;
  }

  .mm-cta::after {
    content: '\2192';
    flex-shrink: 0;
    font-size: 15px;
    opacity: .65;
  }

  .mm-cta:hover,
  html.light .mm-cta:hover {
    background: var(--nav-accent-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px var(--nav-accent-soft);
  }

  .mm-cta:active {
    transform: translateY(0);
  }

  .mm-sidebar-title,
  html.light .mm-sidebar-title {
    margin: 16px 0 6px;
    padding: 0 12px;
    color: var(--nav-text-dim);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .8px;
  }

  .mm-sidebar-title:first-child,
  .mm-cta + .mm-sidebar-title {
    margin-top: 0;
  }

  .mm-links {
    display: flex;
    flex-direction: column;
    gap: var(--mm-row-gap);
    margin: 0;
    padding: 0;
    list-style: none;
  }

  .mm-links li a,
  html.light .mm-links li a {
    position: relative;
    display: flex;
    align-items: center;
    gap: var(--mm-icon-gap);
    min-height: var(--mm-row-height);
    padding: 0 12px;
    overflow: hidden;
    border: 0;
    border-radius: var(--mm-radius);
    background: transparent;
    color: var(--nav-text);
    font-size: var(--mm-link-size);
    font-weight: 500;
    line-height: 1.35;
    text-decoration: none;
    transition: background .15s, color .15s;
  }

  .mm-links li a:hover,
  html.light .mm-links li a:hover {
    background: var(--nav-accent-soft);
    color: var(--nav-accent-text);
  }

  .mm-links li a::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    width: 3px;
    height: 0;
    border-radius: 0 3px 3px 0;
    background: var(--nav-accent);
    transform: translateY(-50%);
    transition: height .22s cubic-bezier(.2, .7, .3, 1);
  }

  .mm-links li a:hover::before {
    height: 20px;
  }

  .mm-link-txt {
    display: -webkit-box;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    white-space: normal;
    line-height: 1.25;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
  }

  .mm-link-ico,
  html.light .mm-link-ico {
    width: var(--mm-icon-size);
    height: var(--mm-icon-size);
    fill: var(--nav-icon);
    flex-shrink: 0;
    transition: fill .15s;
  }

  .mm-links li a:hover .mm-link-ico,
  html.light .mm-links li a:hover .mm-link-ico {
    fill: var(--nav-accent);
  }

  .mm-links--tags li a {
    padding-left: 42px;
    gap: 0;
  }

  .mm-links--tags li a::after {
    content: '';
    position: absolute;
    left: 20px;
    top: 50%;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--nav-icon);
    transform: translateY(-50%);
    transition: background .15s;
  }

  .mm-links--tags li a:hover::after {
    background: var(--nav-accent);
  }

  .mm-count,
  html.light .mm-count {
    min-width: 20px;
    padding: 1px 6px;
    border-radius: 10px;
    background: var(--nav-hairline);
    color: var(--nav-text-dim);
    flex-shrink: 0;
    font-size: 11px;
    font-weight: 700;
    line-height: 1.6;
    text-align: center;
  }

  .mm-links li a:hover .mm-count,
  html.light .mm-links li a:hover .mm-count {
    background: var(--nav-accent);
    color: var(--nav-on-accent);
  }

  .mm-count--alert,
  html.light .mm-count--alert {
    background: #e53e3e;
    color: #fff;
  }

  .mm-sep,
  html.light .mm-sep {
    height: 1px;
    margin: 14px 0;
    background: var(--nav-hairline);
  }

  .mm-content {
    flex: 1;
    min-width: 0;
    padding: var(--mm-padding);
    overflow: hidden;
  }

  .mm-content-title,
  html.light .mm-content-title {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    margin: 0 0 14px;
    color: var(--nav-text-dim);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .8px;
  }

  .mm-content-more,
  html.light .mm-content-more {
    color: var(--nav-accent-text);
    font-size: 12px;
    font-weight: 600;
    text-transform: none;
    letter-spacing: .4px;
    white-space: nowrap;
    text-decoration: none;
  }

  .mm-content-more:hover {
    text-decoration: underline;
  }

  .mm-rail + .mm-rail {
    margin-top: 22px;
  }

  .mm-cards,
  .mm-model-grid,
  .mm-community-grid {
    display: flex;
    flex-wrap: wrap;
    gap: var(--mm-grid-gap);
    padding: 0;
  }

  .mm-cards.mm-community-grid {
    flex-wrap: nowrap;
  }

  .mm-cards.mm-cards--5 > * {
    flex: 0 0 calc((100% - var(--mm-grid-gap) * 4) / 5);
    max-width: calc((100% - var(--mm-grid-gap) * 4) / 5);
    min-width: 0;
    width: auto;
    padding: 0;
  }

  .mm-cards.mm-cards--6 > * {
    flex: 0 0 calc((100% - var(--mm-grid-gap) * 5) / 6);
    max-width: calc((100% - var(--mm-grid-gap) * 5) / 6);
    min-width: 0;
    width: auto;
    padding: 0;
  }

  .mm-cards.mm-cards--8 > * {
    flex: 0 0 calc((100% - var(--mm-grid-gap) * 7) / 8);
    max-width: calc((100% - var(--mm-grid-gap) * 7) / 8);
    min-width: 0;
    width: auto;
    padding: 0;
  }

  .mm-cards .img-holder {
    overflow: hidden;
    border-radius: 10px;
  }

  .mm-cards .title,
  html.light .mm-cards .title {
    margin-top: 8px;
    color: var(--nav-text);
    font-size: 13px;
    line-height: 1.4;
  }

  .mm-cards .thumb-bottom,
  html.light .mm-cards .thumb-bottom {
    margin-top: 5px;
    color: var(--nav-text-dim);
    font-size: 12px;
  }

  .mm-cards.mm-album-grid .title {
    -webkit-line-clamp: 1;
  }

  .mm-cards .thumb {
    transition: transform .22s cubic-bezier(.2, .7, .3, 1);
  }

  .mm-cards .thumb:hover {
    transform: translateY(-2px);
  }

  .mm-cards .thumb a:hover .title,
  html.light .mm-cards .thumb a:hover .title {
    color: var(--nav-accent-text);
  }

  .mm-overlay,
  html.light .mm-overlay {
    background: var(--nav-overlay);
  }

  .mm-trigger:focus-visible,
  .mm-toggle:focus-visible,
  .mm-cta:focus-visible,
  .mm-links li a:focus-visible,
  .mm-content a:focus-visible {
    outline: 2px solid var(--nav-focus);
    outline-offset: 2px;
    border-radius: var(--mm-radius);
  }

  @media (max-width: 1350px) {
    .mm-bar {
      --mm-sidebar-width: 208px;
      --mm-padding: 18px;
      --mm-row-height: 38px;
      --mm-link-size: 14px;
      --mm-icon-size: 17px;
      --mm-icon-gap: 10px;
      --mm-grid-gap: 12px;
      --mm-trigger-height: 34px;
      --mm-trigger-size: 14px;
      --mm-trigger-padding: 12px;
    }

    .mm-sponsored {
      padding: 0 10px;
      font-size: 12px;
    }

    .mm-cta {
      min-height: 40px;
      margin-bottom: 14px;
      font-size: 13px;
    }
  }

  @media (max-width: 1200px) {
    .mm-cards.mm-cards--5 > *:nth-child(5),
    .mm-cards.mm-cards--6 > *:nth-child(6),
    .mm-cards.mm-cards--8:not(.mm-community-grid) > *:nth-child(n+7) {
      display: none;
    }

    .mm-cards.mm-cards--5 > * {
      flex-basis: calc((100% - var(--mm-grid-gap) * 3) / 4);
      max-width: calc((100% - var(--mm-grid-gap) * 3) / 4);
    }

    .mm-cards.mm-cards--6 > *,
    .mm-cards.mm-cards--8:not(.mm-community-grid) > * {
      flex-basis: calc((100% - var(--mm-grid-gap) * 4) / 5);
      max-width: calc((100% - var(--mm-grid-gap) * 4) / 5);
    }
  }
}

@media (prefers-reduced-motion: reduce) {
  .header-nav,
  .profile-sheet,
  .tabbar-sheet-overlay {
    transition-duration: .01ms !important;
  }

  .mm-panel {
    transition-duration: .01ms;
    transform: none;
  }

  .mm-item.mm-visible .mm-panel {
    transform: none;
  }

  .mm-cards .thumb:hover,
  .mm-cta:hover {
    transform: none;
  }

  .mm-links li a::before {
    transition: none;
  }

  .mm-badge-live {
    animation: none;
  }
}
