/* Menu panels (blocks/mega-menu): a link of the menu that opens a wide panel under the bar, its template part's
   blocks inside. Core opens and closes it as a submenu; here it takes the bar's width and its look. */

.pt-bar:has(.pt-mega) {
  position: relative;
}

.pt-bar:has(.pt-mega) > .pt-menu,
.pt-bar:has(.pt-mega) > .pt-menu .wp-block-navigation__container,
.pt-menu .pt-mega {
  position: static !important;
}

.pt-menu .pt-mega > .wp-block-navigation-item__content {
  gap: 4px;
  border: 0;
  background: transparent;
  font: inherit;
  cursor: pointer;
}

.pt-menu .pt-mega .pt-mega-arrow {
  position: static;
  display: flex;
  margin: 0;
  width: auto;
  height: auto;
}

.pt-menu .pt-mega .pt-mega-arrow svg {
  stroke: currentColor;
}

.pt-menu .pt-mega > .pt-mega-panel {
  top: calc(100% - 4px) !important;
  left: 50% !important;
  right: auto !important;
  box-sizing: border-box;
  max-width: calc(100vw - 32px);
  margin: 0;
  padding: 8px !important;
  border: 1px solid var(--wp--preset--color--border) !important;
  border-radius: 18px;
  background: var(--wp--preset--color--surface) !important;
  box-shadow: 0 24px 48px -16px rgb(15 23 42 / 0.22), 0 2px 6px rgb(15 23 42 / 0.06);
  color: var(--wp--preset--color--contrast);
  transform: translateX(-50%);
  list-style: none;
}

/* Open: as wide as its blocks want, up to the bar's width. */
.pt-menu .pt-mega > [aria-expanded="true"] ~ .pt-mega-panel {
  width: min(1040px, calc(100vw - 32px)) !important;
  max-height: calc(100vh - var(--wp--custom--shell--bar, 61px) - 24px);
  overflow-y: auto !important;
}

/* Core's arrow-less bridge: the pointer crosses from the link to the panel without it closing. */
.pt-menu .pt-mega > .pt-mega-panel::before {
  content: "";
  position: absolute;
  inset: -12px 0 auto;
  height: 12px;
}

.pt-mega-item {
  display: block;
  margin: 0;
  padding: 0;
}

.pt-mega-body {
  padding: 16px;
}

.pt-mega-body > * + * {
  margin-block-start: 0;
}

.pt-mega-body .wp-block-columns {
  gap: 24px;
  margin: 0;
}

/* A list's column is as tall as the column beside it: its rows share the room, its closing link and note sit at the
   bottom. */
.pt-mega-body .wp-block-column:has(> .pt-mega-link) {
  display: flex;
  flex-direction: column;
}

.pt-mega-body .wp-block-column > .pt-mega-link {
  flex: 1 1 auto;
}

.pt-mega-body .wp-block-column > .pt-mega-more {
  margin-top: auto !important;
  padding-top: 8px;
}

/* A panel's small heading over a list. */
.pt-mega-label {
  margin: 0 0 8px;
  padding: 0 12px;
  color: var(--wp--preset--color--muted);
  font-size: 12px !important;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

/* A row: a picture or an icon, a name with its badge, a line under it; the whole row is its link. */
.pt-mega-link {
  position: relative;
  display: flex !important;
  gap: 14px;
  align-items: center;
  margin: 0 !important;
  padding: 10px 12px;
  border-radius: 12px;
  transition: background 0.15s;
}

.pt-mega-link:hover,
.pt-mega-link:focus-within {
  background: var(--wp--preset--color--accent-soft);
}

.pt-mega-link .wp-block-image,
.pt-mega-link figure {
  flex: none;
  width: 44px;
  margin: 0 !important;
}

.pt-mega-link img {
  display: block;
  width: 44px !important;
  height: 44px !important;
  border-radius: 11px;
  object-fit: cover;
}

.pt-mega-link > .wp-block-group,
.pt-mega-link > div:not(.wp-block-image) {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.pt-mega-link p {
  margin: 0 !important;
  line-height: 1.35;
}

.pt-mega-link p:first-child {
  color: var(--wp--preset--color--contrast);
  font-size: 15px;
  font-weight: 600;
}

.pt-mega-link p + p {
  color: var(--wp--preset--color--muted);
  font-size: 13px;
}

.pt-mega-link a {
  color: inherit;
  text-decoration: none;
}

.pt-mega-link a::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
}

.pt-mega-link a:focus-visible {
  outline: none;
}

.pt-mega-link:has(a:focus-visible) {
  outline: 2px solid var(--wp--preset--color--accent);
  outline-offset: -2px;
}

/* Beta, Preview, New: beside a name. */
.pt-badge {
  display: inline-block;
  margin-inline-start: 8px;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--wp--preset--color--accent-soft);
  color: var(--wp--preset--color--accent);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  line-height: 1.4;
  vertical-align: 2px;
}

/* A plain link at a list's end ("All plugins →"). */
.pt-mega-more {
  margin: 8px 0 0 !important;
  padding: 0 12px;
  font-size: 14px;
  font-weight: 600;
}

.pt-mega-more a {
  color: var(--wp--preset--color--accent);
  text-decoration: none;
}

.pt-mega-more a:hover {
  text-decoration: underline;
}

/* A featured card beside the lists. */
.pt-mega-feature {
  position: relative;
  box-sizing: border-box;
  margin: 0 !important;
  padding: 12px;
  border-radius: 14px;
  background: var(--wp--preset--color--accent-soft);
}

.pt-mega-feature .wp-block-image {
  margin: 0 0 12px !important;
}

.pt-mega-feature .wp-block-image img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 3;
  border-radius: 10px;
  object-fit: cover;
}

.pt-mega-feature h3,
.pt-mega-feature .wp-block-heading {
  margin: 0 0 4px !important;
  color: var(--wp--preset--color--contrast);
  font-size: 15px !important;
  font-weight: 600;
}

.pt-mega-feature p {
  margin: 0 0 10px !important;
  color: var(--wp--preset--color--secondary, var(--wp--preset--color--muted));
  font-size: 13px;
  line-height: 1.45;
}

.pt-mega-feature p:last-child {
  margin-bottom: 0 !important;
}

.pt-mega-feature a {
  color: var(--wp--preset--color--accent);
  font-weight: 600;
  text-decoration: none;
}

.pt-mega-feature + .pt-mega-feature {
  margin-top: 12px !important;
}

/* Folded into More, or in the open menu on a phone: the panel stands under its link, set in, its pictures smaller
   and its featured cards left out. */
.pt-menu .pt-more-list .pt-mega-panel,
.pt-menu .is-menu-open .pt-mega-panel {
  left: auto !important;
  width: auto !important;
  max-width: none;
  padding: 0 !important;
  border: 0 !important;
  border-radius: 0;
  background: none !important;
  box-shadow: none;
  transform: none;
}

.pt-menu .pt-more-list .pt-mega-body,
.pt-menu .is-menu-open .pt-mega-body {
  padding: 4px 0 8px;
}

.pt-menu .pt-more-list .pt-mega-body .wp-block-columns,
.pt-menu .is-menu-open .pt-mega-body .wp-block-columns {
  flex-direction: column;
  gap: 8px;
}

.pt-menu .pt-more-list .pt-mega-feature,
.pt-menu .is-menu-open .pt-mega-feature,
.pt-menu .pt-more-list .pt-mega-link p + p,
.pt-menu .is-menu-open .pt-mega-link p + p {
  display: none;
}

.pt-menu .pt-more-list .pt-mega-link,
.pt-menu .is-menu-open .pt-mega-link {
  gap: 10px;
  padding: 6px 8px;
}

.pt-menu .pt-more-list .pt-mega-link img,
.pt-menu .is-menu-open .pt-mega-link img {
  width: 28px !important;
  height: 28px !important;
  border-radius: 7px;
}

.pt-menu .pt-more-list .pt-mega-link .wp-block-image,
.pt-menu .is-menu-open .pt-mega-link .wp-block-image {
  width: 28px;
}

.pt-menu .pt-more-list .pt-mega-label,
.pt-menu .is-menu-open .pt-mega-label {
  margin-top: 4px;
  padding: 0 8px;
}

@media (prefers-reduced-motion: reduce) {
  .pt-mega-link {
    transition: none;
  }
}

/* A line of small print under a list. */
.pt-mega-note {
  margin: 12px 0 0 !important;
  padding: 0 12px;
  color: var(--wp--preset--color--muted);
  font-size: 12px !important;
  line-height: 1.45;
}

.pt-menu .pt-more-list .pt-mega-note,
.pt-menu .is-menu-open .pt-mega-note {
  display: none;
}

/* The arrow beside a panel's link turns while it is open. */
.pt-menu .pt-mega .pt-mega-arrow svg {
  transform-origin: center;
  transition: transform 0.15s;
}

.pt-menu .pt-mega.is-open .pt-mega-arrow svg {
  transform: rotate(180deg);
}

/* Links in a panel's text are text, not the menu's own links: none of the menu's padding, height or flex. */
.pt-menu .pt-mega-panel .pt-mega-body a {
  display: inline !important;
  width: auto !important;
  height: auto !important;
  padding: 0 !important;
  background: none !important;
  font-size: inherit !important;
  line-height: inherit;
  white-space: normal;
}

.pt-menu .pt-mega-panel .pt-mega-link p {
  font-size: 15px;
}

.pt-menu .pt-mega-panel .pt-mega-link p + p {
  font-size: 13px;
}

/* The arrow sits inside the panel's button: no room kept for core's arrow beside it, and none of core's background
   (a translucent hover would show twice over it). */
.pt-menu .pt-mega.has-child > .wp-block-navigation-item__content {
  padding-inline-end: 10px !important;
}

.pt-menu .pt-mega .pt-mega-arrow {
  background: none !important;
}

/* Core turns over every icon straight inside an open dropdown's button, meant for its arrow: a menu item's own icon
   stays upright. */
.pt-menu .pt-mega > .wp-block-navigation-submenu__toggle > svg:not(.pt-mega-arrow svg) {
  transform: none !important;
}
