/* The tile mega menu: an ivory bar and an ivory panel on a black page. The panel's tiles turn over in a wave; the
   colours of the cards and icons are written in the page, next to each one. */
:root {
  --page: #000000;          /* the page */
  --panel: #f4f0e7;         /* the bar and the panel */
  --ink: #17161b;           /* the words */
  --muted: #6f6a72;         /* the lines under the links, the headings */
  --hover: rgba(23, 22, 27, 0.055);    /* a link under the pointer */
  --focus: #ff7a45;         /* the ring of the focus */
  --radius: 22px;           /* the corners of the panel */
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  touch-action: manipulation;
}

html,
body {
  margin: 0;
  overflow-x: clip;
}

body {
  min-height: 100svh;
  background: var(--page);
  color: var(--ink);
  font-family: 'Manrope Variable', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-decoration: none;
}

p {
  margin: 0;
}

.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.stage {
  min-height: 100svh;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  place-items: center;
  padding: 40px 16px;
}

/* the whole menu, with the room the panel needs under the bar */
.mega {
  width: min(800px, calc(100vw - 32px));
  min-height: var(--room, 440px);
}

.mega__nav {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* ---------------------------------------------------------------- the bar */
.mega__barwrap {
  position: relative;
  padding: 5px;
  border-radius: 999px;
  background: var(--panel);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.7) inset, 0 12px 30px -12px rgba(0, 0, 0, 0.6);
}

.mega__bar {
  position: relative;
  z-index: 1;
  display: flex;
  gap: 2px;
  margin: 0;
  padding: 0;
  list-style: none;
}

/* the soft pill behind the open menu: it slides from one to the other */
.mega__glow {
  position: absolute;
  left: 0;
  top: 5px;
  bottom: 5px;
  width: 0;
  border-radius: 999px;
  background: rgba(23, 22, 27, 0.075);
  opacity: 0;
  pointer-events: none;
}

.mega__trigger {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 11px 16px 11px 18px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 15px;
  font-weight: 650;
  letter-spacing: -0.005em;
  cursor: pointer;
  outline: none;
  -webkit-tap-highlight-color: transparent;
  transition: color 0.2s;
}

.mega__caret {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.55;
  transition: transform 0.35s cubic-bezier(0.3, 1.4, 0.5, 1), opacity 0.2s;
}

.mega__trigger[aria-expanded='true'] .mega__caret {
  transform: rotate(180deg);
  opacity: 0.9;
}

@media (hover: hover) {
  .mega__trigger:hover {
    color: #000;
  }
}

.mega__trigger:focus-visible {
  box-shadow: 0 0 0 2px var(--focus);
}

/* ---------------------------------------------------------------- the panel */
.mega__panel {
  position: relative;
  width: 100%;
  margin-top: 12px;
  visibility: hidden;
}

.mega__panel.is-open,
.mega__panel.is-turning {
  visibility: visible;
}

/* the shadow under the panel: it comes and goes with the tiles */
.mega__shadow {
  position: absolute;
  inset: 0;
  border-radius: var(--radius);
  box-shadow: 0 30px 60px -20px rgba(0, 0, 0, 0.85), 0 0 0 1px rgba(255, 255, 255, 0.06);
  opacity: 0;
  pointer-events: none;
}

/* the real menus: on top, so they always take the clicks; seen once the tiles are still */
.mega__content {
  position: relative;
  z-index: 2;
  border-radius: var(--radius);
  background: var(--panel);
  opacity: 0;
}

.mega__panel.is-still .mega__content {
  opacity: 1;
}

.mega__panel.is-still .mega__tiles {
  visibility: hidden;
}

.mega__tiles {
  position: absolute;
  inset: 0;
  z-index: 1;
  perspective: 1400px;
  pointer-events: none;
}

.tile {
  position: absolute;
  transform-style: preserve-3d;
  will-change: transform;
}

.tile__face {
  position: absolute;
  /* a hair larger than the tile, so no line of the page shows between two still tiles */
  inset: -0.5px;
  overflow: hidden;
  background: var(--panel);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.tile__face--back {
  transform: rotateX(180deg);
}

/* the light on a turning tile: darker as it turns away, a little brighter as it faces up */
.tile__face::after {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--tone, #000);
  opacity: var(--shade, 0);
  pointer-events: none;
}

.tile__plate {
  position: absolute;
  left: 0.5px;
  top: 0.5px;
}

/* ---------------------------------------------------------------- what is in a menu */
.mega__section {
  display: grid;
  grid-template-columns: 1fr 1fr 1.12fr;
  gap: 10px 18px;
  padding: 20px;
}

.mega__col {
  display: grid;
  align-content: start;
  gap: 2px;
}

.mega__heading {
  padding: 6px 12px 8px;
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.mega__link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 14px;
  outline: none;
  transition: background-color 0.18s;
}

@media (hover: hover) {
  .mega__link:hover {
    background: var(--hover);
  }
}

.mega__link:focus-visible {
  box-shadow: inset 0 0 0 2px var(--focus);
}

.mega__icon {
  flex: none;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 11px;
  background: var(--tint);
}

.mega__icon svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: var(--mark);
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.mega__text {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.mega__text b {
  font-size: 14.5px;
  font-weight: 700;
  letter-spacing: -0.005em;
}

.mega__text small {
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 500;
  line-height: 1.35;
}

/* the card on the right: dark, with its drawing */
.mega__card {
  display: grid;
  align-content: start;
  gap: 6px;
  padding: 12px 12px 16px;
  border-radius: 16px;
  background: var(--card);
  color: #fff;
  outline: none;
  transition: transform 0.25s cubic-bezier(0.2, 0.8, 0.2, 1);
}

@media (hover: hover) {
  .mega__card:hover {
    transform: translateY(-2px);
  }
}

.mega__card:focus-visible {
  box-shadow: 0 0 0 2px var(--panel), 0 0 0 4px var(--focus);
}

.mega__art {
  display: block;
  width: 100%;
  height: auto;
  margin-bottom: 6px;
  border-radius: 10px;
}

.mega__tag {
  justify-self: start;
  padding: 3px 8px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--glow) 18%, transparent);
  color: var(--glow);
  font-size: 11px;
  font-weight: 750;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.mega__card b {
  font-size: 16px;
  font-weight: 750;
  letter-spacing: -0.01em;
}

.mega__card small {
  color: rgba(255, 255, 255, 0.68);
  font-size: 12.5px;
  font-weight: 500;
  line-height: 1.4;
}

/* ---------------------------------------------------------------- phone */
@media (max-width: 680px) {
  .mega__section {
    grid-template-columns: 1fr 1fr;
    gap: 6px 4px;
    padding: 14px;
  }

  .mega__card {
    grid-column: 1 / -1;
    grid-template-columns: 112px 1fr;
    column-gap: 14px;
    align-items: center;
    padding: 10px;
  }

  .mega__art {
    grid-row: span 3;
    margin: 0;
  }

  .mega__link {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    padding: 10px;
  }

  .mega__trigger {
    padding: 10px 11px 10px 13px;
    font-size: 14.5px;
  }

  /* sul telefono il pannello aperto è alto: spazi più stretti, così bar e pannello stanno insieme nella casella
     dell'anteprima (rimpicciolita dal visore) */
  .stage {
    padding: 22px 16px;
  }

  .mega__section {
    padding: 12px;
  }

  .mega__heading {
    padding: 4px 10px 6px;
  }

  .mega__link {
    gap: 6px;
    padding: 8px 10px;
  }

  .mega__icon {
    width: 32px;
    height: 32px;
    border-radius: 10px;
  }

  .mega__icon svg {
    width: 18px;
    height: 18px;
  }
}

/* telefono stretto: la barra con i tre menu sta dentro lo schermo */
@media (max-width: 380px) {
  .mega__trigger {
    gap: 4px;
    padding: 9px 7px 9px 10px;
    font-size: 14px;
  }

  .mega__caret {
    width: 12px;
    height: 12px;
  }
}
