/* ==========================================================================
   menu.css: the site menu ("menu D": five doors, five worlds) and the phone dock.
   Behaviour and motion live in js/menu.js. Artboards: Menu-D (1440), Menu-D-tablet (768),
   Menu-D-phone (390), and the dock at the end of Phone.dc.html.
   Breakpoints as the rest of the page: desktop 1100+, tablet 761-1099, phone 760 and narrower.
   ========================================================================== */

/* While the menu is open the page behind does not scroll; the gutter beside it stays navy. */
html.menu-open, html.menu-open body { overflow: hidden; }
html.menu-open { background: var(--ink); }
@media (min-width: 761px) {
  html.menu-open .bar__pill::before { box-shadow: 0 5px 0 var(--ink-deep); }
}

/* ---------- 1. The takeover ---------- */
.menu {
  position: fixed;
  inset: 0;
  z-index: 59;                       /* under the bar (60), which keeps its pill and the close button on top */
  container-type: size;              /* door sizes below are worked out from this box (cqw / cqh) */
  color: var(--cream);
  --focus: var(--gold-light);
}
.menu[hidden] { display: none; }

/* The navy sheet: it slides down from under the bar, and scrolls inside itself when it must. */
.menu__sheet {
  position: absolute;
  inset: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--ink);
}

.menu__inner {
  position: relative;
  min-height: 100%;
  width: min(100%, 1440px);
  margin-inline: auto;
  padding: calc(var(--nav-top) + var(--nav-h) + 16px) 64px 10px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  /* One measure drives every door: as tall as the artboard (500px) when the window allows,
     shorter on shorter or narrower windows, and never so tall that the doors become thin. */
  --door-w: calc((min(100cqw, 1440px) - 208px) / 5);
  --door-h: clamp(300px, min(100cqh - 320px, (min(100cqw, 1440px) - 208px) * .406), 500px);
  --door-r: calc(var(--door-h) * .22);
  --pic-h: calc(var(--door-h) * .54);
  --friend: calc(var(--door-h) * .6);
  --friend-top: calc(var(--door-h) * .16);
  --shadow-top: calc(var(--door-h) * .728);
  --shadow-w: calc(var(--door-h) * .252);
  --shadow-hh: calc(var(--door-h) * .036);
  --words-top: calc(var(--door-h) * .78);
  --eyebrow-fs: clamp(10px, calc(var(--door-w) * .053), 13px);
  --dest-fs: clamp(19px, calc(var(--door-w) * .11), 27px);
}

/* Four small stars in the side margins (desktop only, as in the artboard). */
.menu__stars { position: absolute; inset: 0; pointer-events: none; }
.menu__stars svg { position: absolute; }
.menu__stars svg:nth-child(1) { left: 24px; top: 26.4%; fill: var(--gold); }
.menu__stars svg:nth-child(2) { left: 30px; top: 55.3%; fill: var(--cream); opacity: .5; }
.menu__stars svg:nth-child(3) { right: 22px; top: 35.3%; fill: var(--cream); opacity: .5; }
.menu__stars svg:nth-child(4) { right: 30px; top: 63.1%; fill: var(--gold); }

/* ---------- 2. The doors ---------- */
.menu__doors {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 20px;
}
.menu__door {
  position: relative;
  display: block;
  height: var(--door-h);
  border-radius: var(--door-r) var(--door-r) 30px 30px;
  border: 3px solid var(--cream);
  box-shadow: 0 10px 0 var(--ink-deep);
  background: var(--floor);
  color: var(--ink);
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
  transition: border-color .2s ease;
}
.menu__door:hover { border-color: var(--gold-light); }
.menu__door:focus-visible { outline-offset: 4px; }

.menu__door--write  { --floor: #fde3c2; --floor-0: rgba(253, 227, 194, 0); }
.menu__door--awards { --floor: #1f2e74; --floor-0: rgba(31, 46, 116, 0); color: var(--cream); }
.menu__door--play   { --floor: #b6f2bf; --floor-0: rgba(182, 242, 191, 0); }
.menu__door--watch  { --floor: #6e1840; --floor-0: rgba(110, 24, 64, 0); color: var(--cream); }
.menu__door--home   { --floor: #f8b062; --floor-0: rgba(248, 176, 98, 0); }

/* The world picture is clipped by the frame; the friend is not (it is a sibling of the frame). */
.menu__frame {
  position: absolute;
  inset: 0;
  overflow: hidden;
  border-radius: calc(var(--door-r) - 3px) calc(var(--door-r) - 3px) 27px 27px;
}
.menu__world {
  position: absolute;
  left: 0; top: 0;
  display: block;
  width: 100%;
  max-width: none;
  height: var(--pic-h);
  object-fit: cover;
  object-position: 50% 50%;
}
/* The melt: the picture's bottom quarter fades into the floor colour (2px past its edge, so no seam). */
.menu__melt {
  position: absolute;
  left: 0; right: 0;
  top: calc(var(--pic-h) * .74);
  height: calc(var(--pic-h) * .26 + 2px);
  background: linear-gradient(to bottom, var(--floor-0), var(--floor));
}
.menu__shadow {
  position: absolute;
  left: 50%;
  top: var(--shadow-top);
  width: var(--shadow-w);
  height: var(--shadow-hh);
  margin-left: calc(var(--shadow-w) / -2);
  border-radius: 50%;
  background: rgba(7, 22, 49, .22);
  filter: blur(5px);
}
.menu__friend {
  position: absolute;
  left: 50%;
  top: var(--friend-top);
  width: var(--friend);
  max-width: none;
  height: var(--friend);
  margin-left: calc(var(--friend) / -2);
}
.menu__words {
  position: absolute;
  left: 10px; right: 10px;
  top: var(--words-top);
  display: block;
  text-align: center;
}
.menu__eyebrow {
  display: block;
  font: 800 var(--eyebrow-fs)/1 var(--font-label);
  letter-spacing: .12em;
  text-transform: uppercase;
  white-space: nowrap;
}
.menu__door--awards .menu__eyebrow, .menu__door--watch .menu__eyebrow { color: var(--gold-light); }
.menu__dest {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  margin-top: 8px;
  font: 800 var(--dest-fs)/1.15 var(--font-display);
  letter-spacing: -.01em;
  white-space: nowrap;
}
.menu__dest svg { width: .82em; height: .82em; }
.menu__live {
  display: flex; align-items: center; justify-content: center; gap: 7px;
  margin-top: 8px;
  font: 800 var(--eyebrow-fs)/1 var(--font-label);
  letter-spacing: .08em;
  text-transform: uppercase;
  white-space: nowrap;
  color: var(--cream);
}
.menu__live .dot { width: 8px; height: 8px; }

/* ---------- 3. Links, switch, foot ---------- */
.menu__paper { display: none; }       /* phone only: Art Studio and My creations as two paper buttons */

.menu__row {
  display: flex; align-items: center; justify-content: space-between; gap: 24px;
  margin-top: calc(var(--door-h) * .096);
}
.menu__links {
  display: flex; flex-wrap: wrap; align-items: center;
  gap: 0 clamp(16px, 1.95vw, 28px);
  margin: 0; padding: 0;
  list-style: none;
}
.menu__link, .menu__small {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 44px;
  color: var(--cream);
  font: 700 17px/1 var(--font-display);
  text-decoration: none;
  white-space: nowrap;
}
.menu__small { font-size: 15px; }
.menu__link:hover, .menu__small:hover {
  text-decoration: underline; text-decoration-color: var(--gold);
  text-decoration-thickness: 3px; text-underline-offset: 6px;
}

/* The "Reduce movement" switch (role="switch", aria-checked). */
.menu__switch {
  display: inline-flex; align-items: center; gap: 12px;
  min-height: 44px; padding: 0;
  background: transparent; border: 0;
  color: var(--cream);
  font: 700 17px/1 var(--font-display);
  white-space: nowrap;
  cursor: pointer;
}
.menu__track {
  position: relative; display: block; flex: none;
  width: 52px; height: 30px;
  border-radius: 999px;
  border: 2.5px solid var(--cream);
  transition: background-color .2s ease, border-color .2s ease;
}
.menu__knob {
  position: absolute; left: 3px; top: 3px;
  width: 19px; height: 19px;
  border-radius: 50%;
  background: var(--cream);
  transition: translate .2s var(--ease-pop), background-color .2s ease;
}
.menu__switch[aria-checked="true"] .menu__track { background: var(--gold); border-color: var(--gold); }
.menu__switch[aria-checked="true"] .menu__knob { translate: 22px 0; background: var(--ink); }

.menu__foot {
  display: flex; align-items: center; justify-content: space-between; gap: 24px;
  margin-top: 14px; padding-top: 12px;
  border-top: 1.5px solid rgba(255, 247, 232, .18);
}
.menu__line {
  margin: 0;
  font: 700 var(--body-max)/1.6 var(--font-body);
  color: var(--muted-on-navy);
}
.menu__smalls { display: flex; align-items: center; gap: 30px; }

/* ---------- 4. Tablet: three by two (five doors and a list panel) ---------- */
@media (max-width: 1099px) {
  .menu__inner {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
    align-content: start;
    width: 100%;
    padding: calc(var(--nav-top) + var(--nav-h) + 32px) 24px 28px;
    --door-h: 380px;
    --door-r: 96px;
    --pic-h: 224px;
    --friend: 250px;
    --friend-top: 48px;
    --shadow-top: 284px;
    --shadow-w: 105px;
    --shadow-hh: 15px;
    --words-top: 304px;
    --eyebrow-fs: 12px;
    --dest-fs: 22px;
  }
  .menu__stars { display: none; }
  .menu__doors, .menu__row, .menu__foot { display: contents; }
  .menu__door { border-radius: 96px 96px 28px 28px; box-shadow: 0 8px 0 var(--ink-deep); }
  .menu__frame { border-radius: 93px 93px 25px 25px; }
  .menu__dest { margin-top: 5px; }
  .menu__live { margin-top: 6px; letter-spacing: .06em; }

  .menu__links {
    flex-direction: column; flex-wrap: nowrap; align-items: stretch; justify-content: center;
    gap: 0;
    padding: 10px 20px;
    border-radius: 30px;
    background: var(--ink-2);
  }
  .menu__links .menu__link { display: flex; height: 44px; }
  .menu__links li:not(:last-child) .menu__link { border-bottom: 1.5px solid rgba(255, 247, 232, .16); }

  .menu__switch { grid-row: 3; grid-column: 1; justify-self: start; margin-top: 4px; }
  .menu__smalls { grid-row: 3; grid-column: 2 / -1; justify-self: end; margin-top: 4px; gap: 28px; }
  .menu__line {
    grid-row: 4; grid-column: 1 / -1;
    margin-top: -8px; padding-top: 10px;
    border-top: 1.5px solid rgba(255, 247, 232, .18);
  }
}
/* The sentence shows on tablets only when there is room for it. */
@media (min-width: 761px) and (max-width: 1099px) and (max-height: 1000px) {
  .menu__line { display: none; }
}

/* ---------- 5. Phone: two by three tiles, pills, the switch row ---------- */
@media (max-width: 760px) {
  .menu__sheet {
    top: calc(var(--nav-top) + var(--nav-h) + 10px);
    border-radius: 32px 32px 0 0;
  }
  .menu__inner {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    padding: 26px 16px calc(20px + env(safe-area-inset-bottom));
  }
  .menu__door {
    height: 178px;
    border-radius: 22px;
    border-width: 2px;
    box-shadow: 0 4px 0 var(--ink-deep);
  }
  .menu__frame { border-radius: 20px; }
  .menu__world { height: 104px; object-position: 50% 0; }
  .menu__melt { top: 77px; height: 29px; }
  .menu__friend { left: auto; right: -26px; top: -26px; width: 136px; height: 136px; margin-left: 0; }
  .menu__shadow { left: auto; right: 14px; top: 103px; width: 57px; height: 8px; margin-left: 0; filter: blur(4px); }
  .menu__words { left: 12px; right: 8px; top: 116px; text-align: left; }
  .menu__eyebrow { font-size: 11px; letter-spacing: .08em; }
  .menu__dest { justify-content: flex-start; gap: 6px; margin-top: 4px; font-size: 20px; line-height: 1.1; }
  .menu__live {
    justify-content: flex-start; align-items: flex-start; gap: 5px;
    margin-top: 4px;
    font-size: clamp(10px, 2.82vw, 11px); line-height: 1.1;
    letter-spacing: .02em;
  }
  .menu__live .dot { width: 7px; height: 7px; margin-top: 2px; }

  .menu__paper { display: flex; flex-direction: column; gap: 10px; }
  .menu__paper-link {
    flex: 1;
    display: flex; align-items: center; justify-content: space-between; gap: 8px;
    min-height: 44px;
    padding: 0 16px 0 18px;
    border-radius: 20px;
    background: var(--paper);
    box-shadow: 0 4px 0 var(--ink-deep);
    color: var(--ink);
    font: 800 18px/1 var(--font-display);
    letter-spacing: -.01em;
    text-decoration: none;
    white-space: nowrap;
  }

  .menu__links {
    grid-column: 1 / -1;
    flex-direction: row; flex-wrap: wrap; align-items: center; justify-content: flex-start;
    gap: 8px;
    margin-top: 4px;
    padding: 0;
    border-radius: 0;
    background: none;
  }
  .menu__links .is-dup { display: none; }
  .menu__links .menu__link,
  .menu__links li:not(:last-child) .menu__link {
    display: inline-flex;
    height: 44px;
    padding: 0 14px;
    border: 1.5px solid rgba(255, 247, 232, .5);
    border-radius: 999px;
    font-size: 14px;
  }
  .menu__links .menu__link:hover { text-decoration: none; border-color: var(--cream); }

  .menu__switch {
    grid-row: auto; grid-column: 1 / -1;
    display: flex; justify-content: space-between;
    width: 100%;
    margin-top: 2px; padding: 0 4px;
    border-top: 1.5px solid rgba(255, 247, 232, .18);
    font-size: 15px;
  }
  /* The phone artboard has no foot: the sentence and the two small links stay in the page footer. */
  .menu__line, .menu__smalls { display: none; }
}

/* ---------- 6. The phone dock ---------- */
.dock { display: none; }
@media (max-width: 760px) {
  .dock {
    position: fixed;
    z-index: 55;
    left: var(--gutter); right: var(--gutter);
    bottom: calc(12px + env(safe-area-inset-bottom));
    height: 64px;
    display: flex; align-items: center; justify-content: space-around;
    border-radius: 999px;
    background: var(--paper);
    border: 2.5px solid var(--ink);
    box-shadow: 0 5px 0 var(--ink);
    transition: translate .25s ease, visibility 0s linear 0s;
  }
  .dock.is-away, html.menu-open .dock {
    translate: 0 calc(100% + 24px + env(safe-area-inset-bottom));
    visibility: hidden;
    transition: translate .25s ease, visibility 0s linear .25s;
  }
  .dock__link {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    min-width: 80px; height: 52px;
    border-radius: 999px;
    color: var(--ink);
    text-decoration: none;
    -webkit-tap-highlight-color: transparent;
  }
  .dock__link svg { width: 24px; height: 24px; fill: none; stroke: var(--ink); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
  .dock__link span { display: block; font: 800 12px/1 var(--font-label); letter-spacing: .1em; text-transform: uppercase; }
  .dock__link:active { translate: 0 1px; }

  /* The last sheet keeps its last line clear of the dock. */
  #page > .sheet:last-child { padding-bottom: calc(64px + 12px + 5px + 16px + env(safe-area-inset-bottom)); }
}
