/*
 * Navigation pill of The Nine Characterz (D31, D51, D52, D64-D68) and the palette of the two themes.
 * Shared: the public site (AppAsset) and the admin (BrandAsset, D86) use this same file.
 */
/* ---------- Tokens: dark theme by default, light theme = neon switched off ---------- */
:root {
  --dodger: #4D6AFF;
  --heliotrope: #9A5CFF;
  --pink: #FF57B9;
  --kournikova: #FFEC70;
  --spring: #00FF9D;
  --night: #0D0B1F;
  --paper: #F3F5FF;
  --ink: #1B1838;

  --bg: var(--night);
  --text: #E9E8F7;
  --muted: #A6A3C9;
  --line: rgba(166, 163, 201, .22);
  --glow: 1;
  --neon: linear-gradient(90deg, var(--dodger), var(--heliotrope), var(--pink), var(--kournikova), var(--spring));
  --focus: var(--kournikova);

  /* Glass pill (semi-transparent and blurred, user's taste) */
  --pill-h: 54px;
  --pill-top: max(12px, env(safe-area-inset-top));
  --pill-border: var(--neon);
  --pill-bg: rgba(21, 18, 44, .72);
  --pill-field: rgba(11, 9, 25, .55);
  --pill-field-line: rgba(166, 163, 201, .22);
  --pill-text: #E9E8F7;
  --pill-muted: #A6A3C9;
  --pill-placeholder: #8E8AB5;
  --pill-hover: rgba(255, 255, 255, .07);
  --pill-shadow: 0 10px 28px rgba(0, 0, 0, .38), 0 0 16px rgba(154, 92, 255, .35);

  /* Menu selection: dark = yellow outline and text */
  --menu-current: var(--kournikova);
  /* Name of a group in the menu and its line (D90): violet, apart from white and grey texts and the yellow of "active" */
  --menu-group: var(--heliotrope);
}
[data-theme="light"] {
  --bg: var(--paper);
  --text: var(--ink);
  --muted: #55527A;
  --line: rgba(27, 24, 56, .16);
  --glow: 0;
  --neon: linear-gradient(90deg, #22307A, #3F2470, #6E1A4B, #5C4D0E, #0D5A3E);
  --focus: var(--dodger);

  --pill-bg: rgba(255, 255, 255, .72);
  --pill-field: rgba(236, 238, 250, .7);
  --pill-field-line: rgba(27, 24, 56, .16);
  --pill-text: #1B1838;
  --pill-muted: #55527A;
  --pill-placeholder: #6A6790;
  --pill-hover: rgba(27, 24, 56, .07);
  --pill-shadow: 0 8px 22px rgba(27, 24, 56, .14);

  /* Light = unlit yellow tube (proposal A) */
  --menu-current: #5C4D0E;
  --menu-group: #3F2470;
}


/* ---------- Navigation pill: glass, gradient border, the menu inside (D31, D51) ---------- */
.pill-bar {
  position: fixed;
  top: var(--pill-top);
  left: 0;
  right: 0;
  z-index: 50;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  gap: 8px;
  padding: 0 12px;
  pointer-events: none;
}
.pill {
  position: relative;
  pointer-events: auto;
  flex: 0 1 640px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  border-radius: calc(var(--pill-h) / 2);
  padding: 2px;
  background: var(--pill-bg);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  backdrop-filter: blur(14px) saturate(140%);
  box-shadow: var(--pill-shadow);
  color: var(--pill-text);
}
/* Gradient border drawn by a masked layer, so the inside stays see-through (main and round pills) */
.pill::before,
.round-pill::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 2px;
  background: var(--pill-border);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
  pointer-events: none;
}
.pill > *,
.round-pill > * { position: relative; }
.pill-row {
  height: calc(var(--pill-h) - 4px);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 5px;
}
.pill-logo { flex: none; display: block; width: 38px; height: 38px; border-radius: 50%; }
.pill-logo img { display: block; width: 38px; height: 38px; border-radius: 50%; }
.pill-search {
  flex: 1;
  min-width: 0;
  height: 38px;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 14px;
  border-radius: 999px;
  background: var(--pill-field);
  border: 1px solid var(--pill-field-line);
  color: var(--pill-muted);
}
.pill-search:focus-within { border-color: var(--heliotrope); }
.pill-search input {
  flex: 1;
  min-width: 0;
  height: 100%;
  padding: 0 2px;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--pill-text);
  caret-color: var(--pill-text);
  /* 16px: below this iPhone Safari zooms the page when the field is tapped (D31) */
  font: 400 16px/normal 'Varela Round', system-ui, sans-serif;
}
.pill-search input::placeholder { color: var(--pill-placeholder); opacity: 1; }
.pill-search input::-webkit-search-cancel-button { display: none; }
.pill-menu {
  flex: none;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--pill-text);
  cursor: pointer;
}
.pill-menu:hover { background: var(--pill-hover); }
.icon { display: block; }
.pill-menu .icon-close { display: none; }
.pill.open .pill-menu .icon-open { display: none; }
.pill.open .pill-menu .icon-close { display: block; }

/* The pill extends downwards and shows the menu */
.pill-panel {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows .3s ease;
}
.pill.open .pill-panel { grid-template-rows: 1fr; }
.pill-panel-inner { min-height: 0; overflow: hidden; }
.pill-panel-content {
  margin: 0 12px;
  padding: 4px 6px 12px;
  border-top: 1px solid var(--pill-field-line);
}
.menu-sections { list-style: none; margin: 6px 0 4px; padding: 0; }
.menu-sections a {
  display: flex;
  align-items: center;
  min-height: 46px;
  padding: 0 8px;
  border-radius: 12px;
  color: var(--pill-text);
  text-decoration: none;
  font-size: 1.15rem;
  letter-spacing: .02em;
}
.menu-sections a:hover { background: var(--pill-hover); }
.menu-sections a[aria-current="page"] { color: var(--menu-current); }
/* ---------- Round pills (D64-D68): language and theme beside the main pill, same glass and border ---------- */
.round-pill {
  position: relative;
  pointer-events: auto;
  flex: none;
  width: var(--pill-h);
  display: flex;
  flex-direction: column;
  align-items: center;
  border-radius: calc(var(--pill-h) / 2);
  padding: 2px;
  background: var(--pill-bg);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  backdrop-filter: blur(14px) saturate(140%);
  box-shadow: var(--pill-shadow);
  color: var(--pill-text);
}
.round-button,
.round-choice {
  width: calc(var(--pill-h) - 4px);
  height: calc(var(--pill-h) - 4px);
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--pill-text);
  cursor: pointer;
}
.round-button:hover,
.round-choice:hover { background: var(--pill-hover); }
.round-button:focus-visible,
.round-choice:focus-visible { outline-offset: -3px; }
/* Flags inscribed in a circle, with a thin ring so white parts never vanish (D66) */
.flag {
  display: block;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  box-shadow: 0 0 0 1px var(--pill-field-line);
}
.round-button .flag { width: 32px; height: 32px; }
/* The language pill extends downwards with the other flags, like the menu (D65) */
.round-panel {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows .3s ease;
}
.round-pill.open .round-panel { grid-template-rows: 1fr; }
.round-panel-inner { min-height: 0; overflow: hidden; }
.round-choices {
  list-style: none;
  margin: 0;
  padding: 2px 0 4px;
  border-top: 1px solid var(--pill-field-line);
}
/* Theme pill: the icon of the current mode, turning in when the mode changes (D66) */
.theme-icon { transition: transform .45s ease, opacity .3s ease; }
.icon-sun { display: none; }
[data-theme="light"] .icon-sun { display: block; }
[data-theme="light"] .icon-moon { display: none; }
.round-button.turning .theme-icon { transform: rotate(-180deg) scale(.6); opacity: 0; transition: none; }

/* Smartphones in landscape: the open menu always fits the screen, no scrolling (D52) */
@media (pointer: coarse) and (orientation: landscape) and (max-height: 520px) {
  .pill-panel-content { max-height: calc(100dvh - var(--pill-top) - var(--pill-h) - 12px); overflow-y: auto; }
  .menu-sections { margin: 4px 0; }
  .menu-sections a { min-height: 36px; font-size: 1rem; }
}


/* ---------- Groups in the menu and in the results (D90): violet name, a line of the same colour below ---------- */
.menu-group-title {
  margin: 14px 8px 0;
  font-size: .75rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--menu-group);
}
.menu-group-line {
  height: 0;
  margin: 6px 8px 4px;
  border: 0;
  border-top: 1px solid var(--menu-group);
  opacity: 1;
}
.menu-group-title:first-child { margin-top: 8px; }
