/* The menu. One trigger wearing the wordmark opens the whole house:
   rooms, readings, the circle, the way out. A popover at a desk, a
   near-full sheet in the hand — the same panel, dressed by the viewport. */
@layer components {

.menu__panel:focus, .menu__panel:focus-visible { outline: none; }
/* The one button in the house: a pill that reads as one — paper, a hem,
   a shadow — wearing the star and the wordmark. */
.menu__trigger {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 2.6rem;
  padding: 0 1rem 0 0.85rem;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--paper-high);
  box-shadow: var(--shadow);
  cursor: pointer;
  color: var(--ink);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
@media (hover: hover) {
  .menu__trigger:hover { border-color: var(--gold-dim); box-shadow: 0 4px 18px oklch(var(--lch-ink) / 16%); }
}
.menu__star { --seal-size: 1.4rem; }
.menu__wordmark {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1rem;
  letter-spacing: 0.3em;
  /* Tracking trails the last letter; walk half of it back so the word
     sits centered in the pill. */
  margin-inline-end: -0.15em;
  text-transform: uppercase;
  color: var(--gold);
  line-height: 1;
}
.menu__caret {
  color: var(--ink-dim);
  font-size: 0.55rem;
  translate: 0 1px;
}
.menu__kbd {
  font-family: var(--font-ui);
  font-size: 0.62rem;
  color: var(--ink-dim);
  border: 1px solid var(--line-strong);
  border-bottom-width: 2px;
  border-radius: 5px;
  padding: 0.1rem 0.3rem;
  line-height: 1;
  background: var(--paper-high);
}
.menu__panel {
  /* Floats centered under the masthead, the way Fizzy's popup hangs from
     its header — auto margins rather than a translate, so the rise
     animation owns the transform. */
  position: absolute;
  inset: calc(100% + 0.6rem) 0 auto 0;
  margin-block: 0;
  margin-inline: auto;
  width: min(21.5rem, calc(100vw - 1.6rem));
  max-block-size: min(calc(100dvh - 5.5rem - env(safe-area-inset-top)), 40rem);
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
  padding: 0.55rem;
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  background: var(--paper-high);
  color: var(--ink);
  box-shadow: 0 12px 40px rgba(20, 14, 50, 0.25), var(--shadow);
  z-index: 60;
}
.menu__panel[open] { animation: menu-rise 0.18s ease; }
.menu__head { display: flex; gap: 0.5rem; align-items: center; margin-bottom: 0.55rem; }
.menu__jump {
  flex: 1;
  min-width: 0;
  font: inherit;
  font-family: var(--font-ui);
  /* Never under 16px: a smaller field invites iOS to zoom on focus, and
     the whole page side-scrolls after it. */
  font-size: 1rem;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.5rem 0.7rem;
}
.menu__jump:focus { outline: none; border-color: var(--gold-dim); }
.menu__jump::placeholder { color: var(--ink-dim); }
.menu__close {
  display: none;
  border: none;
  background: none;
  color: var(--ink-dim);
  font-family: var(--font-ui);
  font-size: 0.85rem;
  min-height: 2.5rem;
  padding: 0 0.5rem;
  cursor: pointer;
}
.menu__tiles {
  list-style: none;
  margin: 0 0 0.55rem;
  padding: 0;
  display: grid;
  /* Four across: Home, Seer, Circle, My chart. */
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.4rem;
}
.menu__tile-seat { min-width: 0; }
.menu__tile {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--paper);
  padding: 0.55rem 0.3rem 0.45rem;
  font-family: var(--font-ui);
  font-size: 0.8rem;
  color: var(--ink);
}
@media (hover: hover) {
  .menu__tile:hover { text-decoration: none; border-color: var(--line-strong); background: var(--paper-high); }
}
.menu__tile .menu__glyph { width: auto; font-size: 1.25rem; --icon-size: 1.3rem; }
.menu__kbd--corner { position: absolute; inset: 0.3rem 0.3rem auto auto; }

/* The glyph column: every row leads with a small mark in the glyph face,
   tinted by element where one applies, quiet ink otherwise. */
.menu__glyph {
  display: inline-flex;
  justify-content: center;
  width: 1.6rem;
  flex: none;
  font-size: 1.02rem;
  color: var(--ink-dim);
}
.menu__glyph--gold { color: var(--gold); }
.menu__glyph--fire { color: var(--fire); }
.menu__glyph--earth { color: var(--earth); }
.menu__glyph--air { color: var(--air); }
.menu__glyph--water { color: var(--water); }
.menu__section { padding: 0.35rem 0.2rem 0.2rem; }
.menu__section + .menu__section { border-top: 1px solid var(--line); margin-top: 0.4rem; padding-top: 0.6rem; }
.menu__heading {
  font-family: var(--font-ui);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-dim);
  margin: 0 0 0.15rem 0.45rem;
}
.menu__list { list-style: none; margin: 0; padding: 0; }
.menu__item form { display: contents; }
.menu__link {
  display: flex;
  width: 100%;
  align-items: center;
  gap: 0.45rem;
  min-height: 2.35rem;
  padding: 0.3rem 0.45rem;
  border: none;
  border-radius: 8px;
  background: none;
  font-family: var(--font-ui);
  font-size: 0.95rem;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}
@media (hover: hover) {
  .menu__link:hover { background: var(--paper); text-decoration: none; color: var(--ink); }
}
.menu__link--gold { color: var(--gold); }
@media (hover: hover) {
  .menu__link--gold:hover { color: var(--gold); }
}
.menu__link--quiet { color: var(--ink-dim); }
.menu__empty {
  font-family: var(--font-ui);
  color: var(--ink-dim);
  font-size: 0.9rem;
  text-align: center;
  padding: 0.9rem 0.5rem;
  margin: 0;
}
.menu__footer {
  margin-top: 0.5rem;
  padding: 0.55rem 0.45rem 0.25rem;
  border-top: 1px solid var(--line);
  font-family: var(--font-ui);
  font-size: 0.8rem;
  color: var(--ink-dim);
}
.menu__footer a { color: var(--ink-dim); }
@media (hover: hover) {
  .menu__footer a:hover { color: var(--ink); }
}

/* While filtering, whatever empties folds away — sections, tiles, and the
   footer — so the panel narrows to the few things that answer. */
.menu__panel[data-filtering] .menu__section:not(:has(.menu__item:not([hidden]))),
.menu__panel[data-filtering] .menu__tiles:not(:has(.menu__tile-seat:not([hidden]))),
.menu__panel[data-filtering] .menu__footer { display: none; }

/* Touch dresses the panel differently: a close button instead of key hints. */
@media (any-hover: none) {
  .menu__kbd { display: none; }
  .menu__close { display: inline-flex; align-items: center; }
}

@media (prefers-reduced-motion: reduce) {
  .menu__panel[open] { animation: none; }
}

}

@keyframes menu-rise {
  from { opacity: 0; translate: 0 -0.4rem; }
}
