/* AgencyDock — Shell: dunkle Sidebar und Portal-Umschalter für alle Portale.
   Werte aus ../tokens.css und ../module/module.css, hier noch einmal als
   --ad-shell-*, weil die Shell als geschlossener Ordner in jedes Portal kopiert
   wird (/brand/shell/) und dort ohne das übrige Kit auskommen muss.
   Schriften liegen relativ zu dieser Datei in fonts/. */

@font-face {
  font-family: 'Geist';
  src: url('fonts/Geist-Variable.woff2') format('woff2');
  font-weight: 100 900;
  font-display: swap;
}
@font-face {
  font-family: 'Space Grotesk';
  src: url('fonts/SpaceGrotesk.ttf') format('truetype');
  font-weight: 300 700;
  font-display: swap;
}

:root {
  --ad-shell-bg: #0B1124;            /* Midnight */
  --ad-shell-raise: #131B36;         /* Popover-Fläche */
  --ad-shell-hover: #161E3A;
  --ad-shell-active: #1A2342;
  --ad-shell-line: #232D4E;
  --ad-shell-text: #E6EAF5;
  --ad-shell-text-2: #C2C9D9;
  --ad-shell-muted: #9AA3B7;         /* 7,4:1 auf Midnight */
  --ad-shell-focus: #5C8DFF;

  --ad-shell-font: 'Geist', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --ad-shell-font-display: 'Space Grotesk', 'Geist', system-ui, sans-serif;
  --ad-shell-nav-size: 0.9375rem;    /* 15 px statt der üblichen 14 */
  --ad-shell-label-size: 0.75rem;
  --ad-shell-ease: cubic-bezier(0.16, 1, 0.3, 1);
}

/* ---------- Sidebar ---------- */

/* Trägt jede Sidebar, die zur Shell gehört — im eigenen Markup gesetzt oder von
   AgencyDockShell.andocken(). Färbt nur die Fläche; was darunter liegt, erbt
   über die Token-Abbildung des jeweiligen Portals (adapter/<portal>.css). */
[data-ad-sidebar] {
  color-scheme: dark;
  background-color: var(--ad-shell-bg);
  border-color: var(--ad-shell-line);
  color: var(--ad-shell-text-2);
  font-family: var(--ad-shell-font);
  font-size: var(--ad-shell-nav-size);
  scrollbar-color: #2B3760 transparent;
  scrollbar-width: thin;
}
[data-ad-sidebar] ::selection {
  background: rgba(47, 107, 255, 0.45);
  color: #FFFFFF;
}

/* Original-Marke eines Upstream-Portals, an deren Stelle der Umschalter steht. */
[data-ad-ersetzt] { display: none !important; }

/* ---------- Umschalter: Kopfzeile ---------- */

ad-portal-switch {
  display: block;
  container: ad-switch / inline-size;
  padding: 12px 10px 8px;
  font-family: var(--ad-shell-font);
  -webkit-font-smoothing: antialiased;
}

.ad-switch__trigger {
  appearance: none;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  width: 100%;
  margin: 0;
  padding: 8px 10px 8px 8px;
  border: 0;
  border-radius: 14px;
  background: transparent;
  color: #FFFFFF;
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: background-color 200ms var(--ad-shell-ease);
}
.ad-switch__trigger:hover { background: var(--ad-shell-hover); }
.ad-switch__trigger[aria-expanded="true"] { background: var(--ad-shell-active); }
.ad-switch__trigger:focus-visible,
.ad-switch__item:focus-visible,
.ad-switch__home:focus-visible {
  outline: 2px solid var(--ad-shell-focus);
  outline-offset: 2px;
}

.ad-switch__name {
  overflow: hidden;
  font-family: var(--ad-shell-font-display);
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: -0.032em;          /* wie die Wortmarke */
  line-height: 1.1;
  text-overflow: ellipsis;
  text-transform: lowercase;
  white-space: nowrap;
}

.ad-switch__chevron,
.ad-switch__hier {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.ad-switch__chevron {
  color: var(--ad-shell-muted);
  transition: color 200ms var(--ad-shell-ease);
}
.ad-switch__trigger:hover .ad-switch__chevron,
.ad-switch__trigger[aria-expanded="true"] .ad-switch__chevron { color: #FFFFFF; }

/* Kachel wie ../module/module.css (.ad-module-icon): Squircle 22,5 %, Verlauf,
   Glanz oben links, Fußschatten, Zeichen weiß und gefüllt. */
.ad-switch__tile {
  --ad-tile: 38px;
  --ad-tile-grad: linear-gradient(135deg, #6D5BF0 0%, #2F6BFF 46%, #16C7F2 100%);
  --ad-tile-glow: rgba(47, 107, 255, 0.6);
  display: grid;
  place-items: center;
  flex: none;
  width: var(--ad-tile);
  height: var(--ad-tile);
  border-radius: calc(var(--ad-tile) * 0.225);
  background:
    radial-gradient(120% 120% at 28% 20%, rgba(255, 255, 255, 0.34) 0%, rgba(255, 255, 255, 0.06) 42%, rgba(255, 255, 255, 0) 100%),
    linear-gradient(to bottom, rgba(11, 16, 32, 0) 62%, rgba(11, 16, 32, 0.16) 100%),
    var(--ad-tile-grad);
  box-shadow: 0 8px 16px -10px var(--ad-tile-glow);
  color: #FFFFFF;
}
.ad-switch__tile svg { width: 58%; height: 58%; fill: currentColor; }
.ad-switch__tile--sm { --ad-tile: 34px; box-shadow: none; }
.ad-switch__tile--violet {
  --ad-tile-grad: linear-gradient(135deg, #9B7BFF 0%, #6D5BF0 46%, #4B2FD6 100%);
  --ad-tile-glow: rgba(109, 91, 240, 0.65);
}
.ad-switch__tile--green {
  --ad-tile-grad: linear-gradient(135deg, #25D366 0%, #12A15C 46%, #0A7A48 100%);
  --ad-tile-glow: rgba(18, 161, 92, 0.65);
}

/* Eingeklappte Sidebar (WPMgr): nur die Kachel bleibt. */
@container ad-switch (max-width: 150px) {
  .ad-switch__trigger {
    grid-template-columns: auto;
    justify-content: center;
    padding: 6px;
  }
  .ad-switch__name,
  .ad-switch__chevron { display: none; }
}

/* ---------- Umschalter: Liste ---------- */

.ad-switch__pop {
  box-sizing: border-box;
  position: fixed;
  inset: auto;
  z-index: 2147483000;               /* nur für den Rückfall ohne Popover-API */
  margin: 0;
  padding: 6px;
  overflow: auto;
  border: 0;
  border-radius: 18px;
  background: var(--ad-shell-raise);
  box-shadow:
    inset 0 0 0 1px var(--ad-shell-line),
    0 28px 56px -20px rgba(3, 6, 18, 0.72),
    0 4px 12px -4px rgba(3, 6, 18, 0.4);
  color: var(--ad-shell-text-2);
  font-family: var(--ad-shell-font);
  font-size: 0.9375rem;
  line-height: 1.35;
  color-scheme: dark;
  -webkit-font-smoothing: antialiased;
}
.ad-switch__pop[hidden] { display: none; }

.ad-switch__list {
  display: grid;
  gap: 2px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.ad-switch__item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 9px 12px 9px 9px;
  border-radius: 12px;
  color: inherit;
  text-decoration: none;
  transition: background-color 180ms var(--ad-shell-ease);
}
a.ad-switch__item:hover,
a.ad-switch__item:focus-visible { background: var(--ad-shell-hover); }
.ad-switch__item[aria-current="page"] { background: var(--ad-shell-active); }

.ad-switch__text { display: grid; gap: 2px; min-width: 0; }
.ad-switch__item-name {
  color: #FFFFFF;
  font-family: var(--ad-shell-font-display);
  font-size: 1.0625rem;
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1.15;
  text-transform: lowercase;
}
.ad-switch__item-kurz {
  overflow: hidden;
  color: var(--ad-shell-muted);
  font-size: 0.8125rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ad-switch__hier { color: #FFFFFF; }

.ad-switch__item--bald { cursor: default; }
.ad-switch__item--bald .ad-switch__item-name { color: var(--ad-shell-text-2); }
.ad-switch__marke {
  padding: 4px 9px;
  border-radius: 999px;
  background: var(--ad-shell-active);
  box-shadow: inset 0 0 0 1px var(--ad-shell-line);
  color: var(--ad-shell-text-2);
  font-size: 0.75rem;
  font-weight: 500;
  line-height: 1.2;
  white-space: nowrap;
}

.ad-switch__home {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  margin-top: 6px;
  padding: 12px 12px 10px 17px;
  border-top: 1px solid var(--ad-shell-line);
  border-radius: 0 0 12px 12px;
  color: var(--ad-shell-text);
  font-size: 0.875rem;
  font-weight: 500;
  text-decoration: none;
  transition: color 180ms var(--ad-shell-ease);
}
.ad-switch__home:hover { color: #FFFFFF; }
.ad-switch__mark { width: 18px; height: 20px; fill: currentColor; }
.ad-switch__home-host {
  color: var(--ad-shell-muted);
  font-size: 0.8125rem;
  font-weight: 400;
}

/* ---------- Bewegung: die Portale legen nacheinander an ---------- */

@media (prefers-reduced-motion: no-preference) {
  .ad-switch__pop:popover-open {
    opacity: 1;
    transform: none;
    transition:
      opacity 220ms var(--ad-shell-ease),
      transform 260ms var(--ad-shell-ease),
      overlay 140ms allow-discrete,
      display 140ms allow-discrete;
  }
  .ad-switch__pop {
    opacity: 0;
    transform: translateY(-6px) scale(0.985);
    transform-origin: 24px 0;
    transition:
      opacity 140ms ease-in,
      transform 140ms ease-in,
      overlay 140ms allow-discrete,
      display 140ms allow-discrete;
  }
  .ad-switch__pop:not([popover]) { opacity: 1; transform: none; }

  .ad-switch__pop:popover-open .ad-switch__row {
    opacity: 1;
    transform: none;
    transition:
      opacity 260ms var(--ad-shell-ease) calc(var(--ad-i, 0) * 32ms + 40ms),
      transform 320ms var(--ad-shell-ease) calc(var(--ad-i, 0) * 32ms + 40ms);
  }

  @starting-style {
    .ad-switch__pop:popover-open {
      opacity: 0;
      transform: translateY(-6px) scale(0.985);
    }
    .ad-switch__pop:popover-open .ad-switch__row {
      opacity: 0;
      transform: translateX(-10px);
    }
  }
}
