/* ══════════════════════════════════════════════════════════════════════
   CONTEXT MENU - the site's own right-click menu (context-menu.js).
   Themed from the tokens in style.css so it reads as part of the site
   rather than a browser surface: deep purple panel, IsamiRi wordmark,
   BlueCurve labels, and the same accent glow the nav uses on hover.
   Everything is prefixed .ctm- so it can never collide with page styles.
   ══════════════════════════════════════════════════════════════════════ */

.ctm {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 5000; /* above the fixed header (1000), below a native dialog */
  width: max-content;
  min-width: 264px;
  max-width: min(340px, calc(100vw - 16px));
  padding: 8px;
  border: 1px solid rgba(184, 169, 255, 0.22);
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(30, 16, 67, 0.98), rgba(18, 8, 48, 0.99));
  box-shadow: 0 20px 50px rgba(4, 2, 16, 0.62), inset 0 0 0 1px rgba(255, 255, 255, 0.035);
  color: var(--text-soft);
  font: 500 12px/1.3 "BlueCurve", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  animation: ctm-in 0.12s var(--ease-out, ease-out) both;
}
.ctm[hidden] { display: none; }

@keyframes ctm-in {
  from { opacity: 0; transform: translateY(-4px) scale(0.985); }
  to   { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  .ctm { animation: none; }
}

/* ── Brand header ──────────────────────────────────────────────────── */
.ctm__brand {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
  padding: 5px 10px 9px;
  border-bottom: 1px solid rgba(184, 169, 255, 0.14);
}
.ctm__brand strong {
  color: var(--text);
  font: 400 16px/1 "IsamiRi Display", serif;
  letter-spacing: 0.01em;
}
.ctm__brand small {
  color: var(--muted);
  font: 700 8.5px/1 "BlueCurve", sans-serif;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

/* ── Rows ──────────────────────────────────────────────────────────── */
.ctm__list { margin: 0; padding: 0; list-style: none; }
.ctm__row { position: relative; }

.ctm__item {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text-soft);
  font: 600 11px/1 "BlueCurve", system-ui, sans-serif;
  letter-spacing: 0.12em;
  text-align: left;
  text-transform: uppercase;
  text-decoration: none;
  cursor: pointer;
}
.ctm__item:hover,
.ctm__item:focus-visible,
.ctm__row.is-open > .ctm__item {
  background: rgba(184, 169, 255, 0.14);
  color: var(--text);
  outline: none;
}
.ctm__item[aria-current="page"] { color: var(--accent-3); }
.ctm__item[aria-current="page"]::after {
  content: "";
  width: 5px;
  height: 5px;
  margin-left: auto;
  border-radius: 50%;
  background: var(--accent-3);
}

/* Share rows carry data-network, so the brand palette in share.css tints the
   hover: the glyph paints with currentColor, so it takes the brand ink too.
   Falls back to the shared accent when a network has no tint of its own. */
.ctm__item[data-network]:hover,
.ctm__item[data-network]:focus-visible {
  background: var(--brand-tint, rgba(184, 169, 255, 0.14));
  color: var(--brand-ink, var(--text));
}

/* Network glyphs on the Share rows. All line art at one weight, so none of
   them turns into a solid blob on the dark panel. */
.ctm__icon {
  flex: none;
  width: 16px;
  height: 16px;
  fill: none;
  opacity: 0.8;
}
.ctm__item:hover .ctm__icon,
.ctm__item:focus-visible .ctm__icon { opacity: 1; }
.ctm__item[aria-haspopup]::after { content: none; }
/* Momentary confirmation after “Copy link”. */
.ctm__item.is-done,
.ctm__item.is-done:hover { color: #86efac; }

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

.ctm__chev {
  flex: none;
  width: 9px;
  height: 9px;
  margin-left: auto;
  opacity: 0.65;
  transition: transform 0.14s var(--ease-out, ease-out);
}
.ctm__row.is-open > .ctm__item .ctm__chev { transform: rotate(90deg); }

/* ── Submenus ──────────────────────────────────────────────────────── */
.ctm__sub {
  position: absolute;
  top: -9px;
  left: calc(100% + 4px);
  z-index: 1;
  display: none;
  min-width: 218px;
  max-height: min(64vh, 460px);
  margin: 0;
  padding: 8px;
  overflow-y: auto;
  list-style: none;
  border: 1px solid rgba(184, 169, 255, 0.22);
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(32, 18, 72, 0.99), rgba(18, 8, 48, 0.99));
  box-shadow: 0 18px 44px rgba(4, 2, 16, 0.6);
}
.ctm__row.is-open > .ctm__sub { display: block; }
.ctm__sub.is-flip { left: auto; right: calc(100% + 4px); }

.ctm__sub .ctm__item {
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.02em;
  text-transform: none;
  padding: 8px 10px;
}
.ctm__sub .ctm__item[aria-current="page"] { color: var(--accent-3); }

/* ── Divider + footer ──────────────────────────────────────────────── */
.ctm__rule {
  height: 1px;
  margin: 6px 6px 4px;
  background: rgba(184, 169, 255, 0.14);
}

.ctm__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 2px 4px 0 6px;
}
.ctm__brandlink {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--text-soft);
  font: 600 10px/1 "BlueCurve", system-ui, sans-serif;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  text-decoration: none;
}
.ctm__brandlink svg { width: 14px; height: 14px; opacity: 0.8; }
.ctm__brandlink:hover,
.ctm__brandlink:focus-visible { color: var(--text); outline: none; }

.ctm__socials { display: flex; align-items: center; gap: 2px; }
.ctm__social {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 7px;
  color: var(--text-dim);
  text-decoration: none;
}
.ctm__social svg { width: 15px; height: 15px; }
.ctm__social:hover,
.ctm__social:focus-visible {
  background: rgba(184, 169, 255, 0.16);
  color: var(--text);
  outline: none;
}

/* ── Narrow screens: submenus open inline, not as flyouts ──────────── */
@media (max-width: 560px) {
  .ctm { min-width: 0; width: min(300px, calc(100vw - 16px)); }
  .ctm__sub,
  .ctm__sub.is-flip {
    position: static;
    display: none;
    min-width: 0;
    max-height: none;
    margin: 2px 0 4px;
    padding: 3px 0 3px 10px;
    overflow: visible;
    border: 0;
    border-left: 1px solid rgba(184, 169, 255, 0.26);
    border-radius: 0;
    background: transparent;
    box-shadow: none;
  }
  .ctm__row.is-open > .ctm__sub { display: block; }
  .ctm__row.is-open > .ctm__item .ctm__chev { transform: rotate(90deg); }
  .ctm__item { min-height: 40px; padding: 10px; } /* finger-sized rows */
  /* Inline submenus cannot fly outside the panel, so the panel itself
     scrolls instead of running past the bottom of a short screen. */
  .ctm { max-height: calc(100dvh - 16px); overflow-y: auto; }
}

/* A very short window (landscape phone) needs the same scroll guard. */
@media (max-height: 420px) {
  .ctm { max-height: calc(100dvh - 16px); overflow-y: auto; }
}
