/**
 * COSYlanguages ecosystem dock (shared)
 * File: css/ecosystem-strip.css
 *
 * A small, fixed ecosystem launcher for every COSYlanguages site except the hub.
 * The dock is always present in the bottom-right corner; the panel opens on hover,
 * focus, click or tap, so the ecosystem is available without occupying page space.
 *
 * Sibling repositories load it cross-origin:
 *
 *   <link rel="stylesheet" href="https://cosylanguages.github.io/COSYlanguages/css/ecosystem-strip.css">
 *   <div data-ecosystem-strip data-self="events"></div>
 *   <script src="https://cosylanguages.github.io/COSYlanguages/js/ecosystem-strip.js" defer></script>
 *
 * `data-self` (languages|events|data|tools|practice|games|magazine|manuals|platform|world)
 * removes the host's own link. COSYplatform appears only for signed-in visitors.
 */

.cosy-ecosystem-strip,
.cosy-ecosystem-strip *,
.cosy-ecosystem-strip *::before,
.cosy-ecosystem-strip *::after {
  box-sizing: border-box;
}

.cosy-ecosystem-strip {
  --cosy-strip-bg: var(--cosy-color-sage-deep, var(--sage-deep, #233827));
  --cosy-strip-fg: rgba(255, 255, 255, 0.94);
  --cosy-strip-accent: var(--cosy-color-lamp, #fcd34d);
  --cosy-strip-panel: var(--cosy-color-warm-white, #fffefb);
  --cosy-strip-ink: var(--cosy-color-ink, #1c1917);
  --cosy-strip-muted: var(--cosy-color-ink-muted, #5c5957);
  --cosy-strip-border: var(--cosy-color-border, rgba(74, 107, 80, 0.16));
  --cosy-strip-card: var(--cosy-color-cream, #faf7f2);
  position: fixed;
  right: max(16px, env(safe-area-inset-right));
  bottom: max(16px, env(safe-area-inset-bottom));
  z-index: 2147483000;
  width: auto;
  max-width: none;
  padding: 0;
  border: 0;
  background: transparent;
  overflow: visible;
  font-family: var(--cosy-font-sans, var(--font-sans, 'Nunito', 'DM Sans', system-ui, sans-serif));
  font-size: 0.82rem;
  line-height: 1.3;
  color: var(--cosy-strip-fg);
  -webkit-font-smoothing: antialiased;
}

/* ── Dock ───────────────────────────────────────────────────────────────────── */

.cosy-eco-dock {
  display: flex;
  width: fit-content;
  max-width: calc(100vw - 32px);
  align-items: center;
  gap: 6px;
  padding: 5px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  background: var(--cosy-strip-bg);
  box-shadow: 0 10px 30px rgba(20, 30, 22, 0.24);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.cosy-eco-trigger {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 14px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: 800;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: background-color 0.18s ease, color 0.18s ease;
}

.cosy-eco-trigger:hover,
.cosy-eco-trigger:focus-visible {
  background: rgba(255, 255, 255, 0.12);
  outline: none;
}

.cosy-eco-trigger-icon {
  font-size: 1.05rem;
  line-height: 1;
}

.cosy-eco-trigger-chevron {
  font-size: 0.66rem;
  opacity: 0.7;
  transition: transform 0.2s ease;
}

.cosy-eco-trigger[aria-expanded="true"] .cosy-eco-trigger-chevron {
  transform: rotate(180deg);
}

.cosy-strip-extra {
  display: inline-flex;
  align-items: center;
}

.cosy-strip-extra:empty {
  display: none;
}

/* ── Panel ──────────────────────────────────────────────────────────────────── */

.cosy-eco-panel {
  position: absolute;
  right: 0;
  bottom: calc(100% + 12px);
  width: min(430px, calc(100vw - 32px));
  max-height: min(72vh, 660px);
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: var(--cosy-strip-border) transparent;
  padding: 18px;
  border: 1px solid var(--cosy-strip-border);
  border-radius: 22px;
  background: var(--cosy-strip-panel);
  color: var(--cosy-strip-ink);
  box-shadow: 0 24px 70px rgba(35, 56, 39, 0.28);
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px) scale(0.98);
  transform-origin: bottom right;
  transition: opacity 0.22s cubic-bezier(0.16, 1, 0.3, 1),
              transform 0.22s cubic-bezier(0.16, 1, 0.3, 1),
              visibility 0.22s;
}

.cosy-eco-panel[hidden] {
  display: none !important;
}

.cosy-eco-panel.open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

.cosy-eco-panel::after {
  content: '';
  position: absolute;
  right: 22px;
  bottom: -7px;
  width: 14px;
  height: 14px;
  background: var(--cosy-strip-panel);
  border-right: 1px solid var(--cosy-strip-border);
  border-bottom: 1px solid var(--cosy-strip-border);
  transform: rotate(45deg);
}

.cosy-eco-panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
}

.cosy-eco-panel-heading {
  min-width: 0;
}

.cosy-eco-eyebrow {
  display: block;
  margin-bottom: 3px;
  color: var(--cosy-color-sage, #4a6b50);
  font-size: 0.64rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.cosy-eco-panel-title {
  margin: 0;
  color: var(--cosy-color-sage-deep, #233827);
  font-family: var(--cosy-font-serif, var(--font-serif, Georgia, 'Times New Roman', serif));
  font-size: 1.45rem;
  font-weight: 700;
  line-height: 1.1;
}

.cosy-eco-close {
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--cosy-strip-muted);
  font: inherit;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  transition: background-color 0.18s ease, color 0.18s ease;
}

.cosy-eco-close:hover,
.cosy-eco-close:focus-visible {
  background: var(--cosy-color-cream-dark, #f4ede2);
  color: var(--cosy-strip-ink);
  outline: none;
}

.cosy-eco-panel-intro {
  margin: 0 0 14px;
  color: var(--cosy-strip-muted);
  font-size: 0.8rem;
  line-height: 1.4;
}

.cosy-eco-here-inline {
  display: inline-block;
  margin-left: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--cosy-color-lamp, #fcd34d);
  color: var(--cosy-color-sage-deep, #233827);
  font-size: 0.68rem;
  font-weight: 800;
  white-space: nowrap;
}

.cosy-ecosystem-strip .cosy-eco-panel-body {
  display: flex;
  flex-direction: column;
  flex-wrap: nowrap;
  flex: 0 0 auto;
  align-items: stretch;
  gap: 14px;
  margin: 0;
  padding: 0;
  list-style: none;
  overflow: visible;
  scrollbar-width: thin;
  scrollbar-color: var(--cosy-strip-border) transparent;
  overscroll-behavior: contain;
}

.cosy-eco-group {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin: 0;
  padding: 0;
}

.cosy-eco-group-title {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
  margin: 0;
  padding-left: 2px;
  color: var(--cosy-color-sage, #416b49);
  font-size: 0.66rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.cosy-eco-tier-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 7px;
  border-radius: 999px;
  background: rgba(65, 107, 73, 0.12);
  color: var(--cosy-color-sage-deep, #2f5136);
  font-size: 0.58rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  white-space: nowrap;
}

.cosy-eco-group[data-tier="member"] .cosy-eco-tier-badge {
  background: rgba(148, 94, 5, 0.14);
  color: var(--cosy-color-amber, #945e05);
}

.cosy-eco-group[data-accent="live"] .cosy-eco-group-title {
  color: var(--cosy-color-amber, #945e05);
}

.cosy-eco-group[data-accent="space"] .cosy-eco-group-title {
  color: var(--cosy-color-terracotta, #b84318);
}

.cosy-eco-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.cosy-ecosystem-strip .cosy-eco-card {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  min-width: 0;
  padding: 10px 11px;
  border: 1px solid var(--cosy-strip-border);
  border-radius: 13px;
  background: var(--cosy-strip-card);
  color: inherit;
  text-decoration: none;
  font-weight: inherit;
  white-space: normal;
  transition: transform 0.18s ease, box-shadow 0.18s ease,
              background-color 0.18s ease, border-color 0.18s ease;
}

.cosy-ecosystem-strip .cosy-eco-card:hover,
.cosy-ecosystem-strip .cosy-eco-card:focus-visible {
  transform: translateY(-1px);
  border-color: var(--cosy-color-sage, #416b49);
  background: var(--cosy-strip-panel);
  color: inherit;
  box-shadow: 0 6px 16px rgba(46, 74, 51, 0.1);
  outline: none;
}

.cosy-eco-card-icon {
  flex: 0 0 auto;
  font-size: 1.1rem;
  line-height: 1.25;
}

.cosy-eco-card-body {
  display: flex;
  min-width: 0;
  flex: 1;
  flex-direction: column;
  gap: 2px;
}

.cosy-eco-card-title {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
  font-size: 0.82rem;
  font-weight: 800;
  line-height: 1.2;
}

.cosy-eco-card-lock {
  font-size: 0.72rem;
  opacity: 0.8;
}

.cosy-eco-card-promise {
  color: var(--cosy-strip-muted);
  font-size: 0.7rem;
  line-height: 1.3;
}

.cosy-eco-card-arrow {
  flex: 0 0 auto;
  margin-left: auto;
  color: var(--cosy-color-sage, #416b49);
  font-size: 0.78rem;
  opacity: 0;
  transform: translate(-2px, 2px);
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.cosy-ecosystem-strip .cosy-eco-card:hover .cosy-eco-card-arrow,
.cosy-ecosystem-strip .cosy-eco-card:focus-visible .cosy-eco-card-arrow {
  opacity: 1;
  transform: translate(0, 0);
}

.cosy-ecosystem-strip .cosy-eco-card.is-locked {
  border-style: dashed;
  background: transparent;
}

.cosy-ecosystem-strip .cosy-eco-card.is-locked .cosy-eco-card-promise,
.cosy-ecosystem-strip .cosy-eco-card.is-locked .cosy-eco-card-arrow {
  opacity: 0.72;
}

.cosy-eco-member-cta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 14px;
  padding: 11px 12px;
  border: 1px solid var(--cosy-strip-border);
  border-radius: 13px;
  background: var(--cosy-strip-card);
}

.cosy-eco-member-note {
  color: var(--cosy-strip-muted);
  font-size: 0.72rem;
  line-height: 1.35;
}

.cosy-eco-member-link {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  padding: 7px 12px;
  border-radius: 999px;
  background: var(--cosy-color-sage, #416b49);
  color: #ffffff;
  font-size: 0.72rem;
  font-weight: 800;
  text-decoration: none;
  white-space: nowrap;
}

.cosy-eco-member-link:hover,
.cosy-eco-member-link:focus-visible {
  background: var(--cosy-color-sage-deep, #2f5136);
  outline: none;
}

.cosy-eco-panel-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--cosy-strip-border);
}

.cosy-eco-foot-note {
  color: var(--cosy-strip-muted);
  font-size: 0.66rem;
  line-height: 1.35;
}

/* ── Backdrop (mobile sheet) ────────────────────────────────────────────────── */

.cosy-eco-backdrop {
  position: fixed;
  inset: 0;
  z-index: -1;
  background: rgba(20, 26, 21, 0.38);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}

.cosy-eco-backdrop[hidden] {
  display: none !important;
}

/* ── Theme toggle ───────────────────────────────────────────────────────────── */

.cosy-theme-toggle-btn {
  min-width: 40px;
  min-height: 40px;
  padding: 0 9px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 999px;
  background: transparent;
  color: var(--cosy-strip-fg);
  font: inherit;
  line-height: 1.4;
  cursor: pointer;
  transition: background-color 0.18s ease, border-color 0.18s ease;
}

.cosy-theme-toggle-btn:hover,
.cosy-theme-toggle-btn:focus-visible {
  border-color: var(--cosy-strip-accent);
  background: rgba(255, 255, 255, 0.12);
  outline: none;
}

/* ── Dark theme ─────────────────────────────────────────────────────────────── */

html[data-theme="dark"] .cosy-ecosystem-strip,
body.theme-dark .cosy-ecosystem-strip,
html[data-cosy-theme="dark"] .cosy-ecosystem-strip {
  --cosy-strip-bg: #141a15;
  --cosy-strip-fg: #f0f4f1;
  --cosy-strip-panel: #1b211c;
  --cosy-strip-ink: #f0f4f1;
  --cosy-strip-muted: #b9c4bb;
  --cosy-strip-border: rgba(255, 255, 255, 0.14);
  --cosy-strip-card: #232b25;
  --cosy-color-cream-dark: #2a342c;
  --cosy-color-sage: #86efac;
  --cosy-color-sage-deep: #d9f99d;
  --cosy-color-amber: #fcd34d;
  --cosy-color-terracotta: #fdba74;
  --cosy-color-lamp: #fcd34d;
}

html[data-theme="dark"] .cosy-eco-member-link,
body.theme-dark .cosy-eco-member-link,
html[data-cosy-theme="dark"] .cosy-eco-member-link {
  background: var(--cosy-color-sage, #86efac);
  color: #141a15;
}

/* ── Responsive ─────────────────────────────────────────────────────────────── */

/* Host pages still ship top-strip rules for this class; the dock wins. */
.cosy-ecosystem-strip.cosy-ecosystem-strip {
  position: fixed;
  right: max(16px, env(safe-area-inset-right));
  bottom: max(16px, env(safe-area-inset-bottom));
  width: auto;
  height: auto;
  min-height: 0;
  max-width: none;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  overflow: visible;
  display: block;
}

.cosy-ecosystem-strip .cosy-strip-brand {
  display: block;
  opacity: 1;
}

@media (max-width: 767px) {
  .cosy-ecosystem-strip.cosy-ecosystem-strip {
    right: max(12px, env(safe-area-inset-right));
    bottom: max(12px, env(safe-area-inset-bottom));
  }

  .cosy-eco-trigger {
    width: 44px;
    min-height: 44px;
    justify-content: center;
    padding: 0;
  }

  .cosy-eco-trigger-label,
  .cosy-eco-trigger-chevron {
    display: none;
  }

  .cosy-eco-panel {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    width: 100%;
    max-height: 88vh;
    padding: 20px 18px calc(20px + env(safe-area-inset-bottom));
    border-radius: 22px 22px 0 0;
    transform: translateY(100%);
    transform-origin: bottom center;
  }

  .cosy-eco-panel.open {
    transform: translateY(0);
  }

  .cosy-eco-panel::after {
    display: none;
  }

  .cosy-eco-grid {
    grid-template-columns: 1fr;
  }

  .cosy-eco-card-arrow {
    opacity: 1;
    transform: none;
  }
}

@media (max-width: 420px) {
  .cosy-eco-panel {
    padding-right: 14px;
    padding-left: 14px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .cosy-eco-panel,
  .cosy-eco-card,
  .cosy-eco-trigger,
  .cosy-eco-trigger-chevron,
  .cosy-theme-toggle-btn {
    transition: none !important;
  }

  .cosy-eco-panel {
    transform: none !important;
  }

  .cosy-eco-card:hover,
  .cosy-eco-card:focus-visible {
    transform: none;
  }
}

@media print {
  .cosy-ecosystem-strip,
  .cosy-eco-backdrop {
    display: none !important;
  }
}

/* ── Top-bar mode ───────────────────────────────────────────────────────────── */
/* A host can make its own brand the trigger. The dock hides and the panel becomes a
   centred mega menu below the brand, matching the hub navigation. */

@media (min-width: 901px) {
  .cosy-ecosystem-strip.has-topbar-trigger .cosy-eco-dock {
    display: none;
  }
}

.cosy-ecosystem-strip.has-topbar-trigger .cosy-eco-panel {
  position: fixed;
  top: var(--cosy-topbar-offset, 64px);
  left: 50%;
  right: auto;
  bottom: auto;
  width: min(1040px, calc(100vw - 32px));
  max-height: calc(100vh - 96px);
  transform: translate(-50%, -8px) scale(0.985);
  transform-origin: top center;
}

.cosy-ecosystem-strip.has-topbar-trigger .cosy-eco-panel.open {
  transform: translate(-50%, 0) scale(1);
}

.cosy-ecosystem-strip.has-topbar-trigger .cosy-eco-panel::after {
  display: none;
}

.cosy-ecosystem-strip.has-topbar-trigger .cosy-eco-panel-body {
  flex-direction: row;
  flex-wrap: wrap;
  gap: 18px;
}

.cosy-ecosystem-strip.has-topbar-trigger .cosy-eco-group {
  flex: 1 1 240px;
}

.cosy-ecosystem-strip.has-topbar-trigger .cosy-eco-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

/* ── Global top-bar links ───────────────────────────────────────────────────── */

.cosy-global-links {
  display: flex;
  align-items: center;
  gap: 2px;
  min-width: 0;
  margin-left: auto;
}

.cosy-global-link,
.cosy-global-ecosystem,
.cosy-global-login,
.cosy-global-contact {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 9px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  line-height: 1.1;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 0.18s ease, opacity 0.18s ease;
}

.cosy-global-link {
  opacity: 0.82;
}

.cosy-global-link:hover,
.cosy-global-link:focus-visible,
.cosy-global-ecosystem:hover,
.cosy-global-ecosystem:focus-visible,
.cosy-global-login:hover,
.cosy-global-login:focus-visible,
.cosy-global-contact:hover,
.cosy-global-contact:focus-visible {
  opacity: 1;
  background: rgba(0, 0, 0, 0.06);
  outline: none;
}

.cosy-global-tools {
  display: flex;
  align-items: center;
  gap: 2px;
}

.cosy-global-contact {
  border: 1px solid currentColor;
}

.cosy-global-link-icon {
  font-size: 0.95rem;
  line-height: 1;
}

@media (max-width: 1180px) {
  .cosy-global-link,
  .cosy-global-ecosystem,
  .cosy-global-login,
  .cosy-global-contact {
    padding: 7px;
  }

  .cosy-global-link-label {
    display: none;
  }
}

@media (max-width: 900px) {
  .cosy-global-links {
    display: none;
  }
}

@media (max-width: 767px) {
  .cosy-ecosystem-strip.has-topbar-trigger .cosy-eco-panel {
    top: auto;
    right: 0;
    bottom: 0;
    left: 0;
    width: 100%;
    max-height: 88vh;
    transform: translateY(100%);
    transform-origin: bottom center;
  }

  .cosy-ecosystem-strip.has-topbar-trigger .cosy-eco-panel.open {
    transform: translateY(0);
  }

  .cosy-ecosystem-strip.has-topbar-trigger .cosy-eco-panel-body {
    flex-direction: column;
  }

  .cosy-ecosystem-strip.has-topbar-trigger .cosy-eco-grid {
    grid-template-columns: 1fr;
  }
}
