/**
 * te-launcher.css — Universal Think Extra 9-Dot Ecosystem Switcher
 * Reusable across thinkextra.in and all sister series portals.
 * Operated by Shri Laxmi Narayan Technologies (SLNT)
 */

:root {
  --tel-font: "Inter Tight", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --tel-font-mono: "JetBrains Mono", ui-monospace, monospace;
  --tel-bg: rgba(7, 11, 22, 0.96);
  --tel-bg-card: rgba(255, 255, 255, 0.035);
  --tel-bg-hover: rgba(255, 255, 255, 0.075);
  --tel-border: rgba(255, 255, 255, 0.12);
  --tel-border-subtle: rgba(255, 255, 255, 0.06);
  --tel-text: #ffffff;
  --tel-text-muted: #9ea8bc;
  --tel-text-subtle: #64748b;
  --tel-gold: #d4af37;
  --tel-gold-glow: rgba(212, 175, 55, 0.25);
  --tel-shadow: 0 25px 60px -15px rgba(0, 0, 0, 0.85), 0 0 0 1px rgba(255, 255, 255, 0.08);
  --tel-radius: 18px;
  --tel-radius-sm: 10px;
  --tel-ease: cubic-bezier(0.16, 1, 0.3, 1);
  --tel-transition: 140ms cubic-bezier(0.16, 1, 0.3, 1);
}

[data-theme="light"],
nav.on-light .te-launcher-dropdown {
  --tel-bg: rgba(255, 255, 255, 0.98);
  --tel-bg-card: rgba(0, 0, 0, 0.025);
  --tel-bg-hover: rgba(0, 0, 0, 0.06);
  --tel-border: rgba(0, 0, 0, 0.12);
  --tel-border-subtle: rgba(0, 0, 0, 0.06);
  --tel-text: #070b16;
  --tel-text-muted: #4a5568;
  --tel-text-subtle: #94a3b8;
  --tel-gold: #b38e1a;
  --tel-gold-glow: rgba(179, 142, 26, 0.2);
  --tel-shadow: 0 25px 60px -15px rgba(0, 0, 0, 0.18), 0 0 0 1px rgba(0, 0, 0, 0.08);
}

/* --------------------------------------------------------------------------
   Trigger Button (9-Dot Waffle)
   -------------------------------------------------------------------------- */
.te-launcher-wrapper {
  position: relative;
  display: inline-flex;
  align-items: center;
  font-family: var(--tel-font);
  user-select: none;
}

.te-launcher-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  padding: 0;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--tel-border-subtle);
  border-radius: 10px;
  color: var(--tel-text);
  cursor: pointer;
  transition: all var(--tel-transition);
  position: relative;
}

.te-launcher-btn:hover,
.te-launcher-btn[aria-expanded="true"] {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--tel-border);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.te-launcher-btn:focus-visible {
  outline: 2px solid var(--tel-gold);
  outline-offset: 2px;
}

.te-waffle-icon {
  display: grid;
  grid-template-columns: repeat(3, 3.5px);
  gap: 3px;
  justify-content: center;
  align-content: center;
  pointer-events: none;
}

.te-waffle-dot {
  width: 3.5px;
  height: 3.5px;
  background: currentColor;
  border-radius: 1px;
  opacity: 0.85;
  transition: transform var(--tel-transition), background-color var(--tel-transition);
}

.te-launcher-btn:hover .te-waffle-dot,
.te-launcher-btn[aria-expanded="true"] .te-waffle-dot {
  background: var(--tel-gold);
  opacity: 1;
}

.te-launcher-btn:hover .te-waffle-dot:nth-child(even) {
  transform: scale(1.15);
}

/* --------------------------------------------------------------------------
   Switcher Panel (Opaque, Deep Shadow, Blur)
   -------------------------------------------------------------------------- */
.te-launcher-dropdown {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  width: 390px;
  max-width: calc(100vw - 24px);
  background: var(--tel-bg);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid var(--tel-border);
  border-radius: var(--tel-radius);
  box-shadow: var(--tel-shadow);
  padding: 18px;
  z-index: 99999;
  display: none;
  flex-direction: column;
  gap: 14px;
  animation: teLauncherOpen 140ms var(--tel-ease) forwards;
  transform-origin: top right;
  color: var(--tel-text);
  box-sizing: border-box;
}

.te-launcher-dropdown.te-open {
  display: flex;
}

@keyframes teLauncherOpen {
  from {
    opacity: 0;
    transform: translateY(-6px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Drag handle bar (Mobile only) */
.te-launcher-drag-handle {
  display: none;
  width: 40px;
  height: 4px;
  background: var(--tel-text-subtle);
  border-radius: 999px;
  margin: -4px auto 6px;
  opacity: 0.5;
}

/* --------------------------------------------------------------------------
   Panel Header
   -------------------------------------------------------------------------- */
.te-launcher-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--tel-border-subtle);
}

.te-launcher-header-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.te-launcher-header-title {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--tel-text-muted);
}

.te-launcher-brand-pill {
  font-size: 0.65rem;
  font-family: var(--tel-font-mono);
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(212, 175, 55, 0.12);
  color: var(--tel-gold);
  border: 1px solid rgba(212, 175, 55, 0.28);
  font-weight: 700;
  letter-spacing: 0.04em;
}

.te-launcher-kbd-hint {
  font-size: 0.65rem;
  font-family: var(--tel-font-mono);
  color: var(--tel-text-subtle);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--tel-border-subtle);
  padding: 1px 5px;
  border-radius: 4px;
}

/* --------------------------------------------------------------------------
   Conditional Search Bar (> 8 portals)
   -------------------------------------------------------------------------- */
.te-launcher-search {
  position: relative;
  width: 100%;
}

.te-launcher-search-input {
  width: 100%;
  box-sizing: border-box;
  padding: 8px 12px 8px 32px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--tel-border-subtle);
  border-radius: 8px;
  font-size: 0.8125rem;
  color: var(--tel-text);
  font-family: inherit;
  outline: none;
  transition: border-color var(--tel-transition);
}

.te-launcher-search-input:focus {
  border-color: var(--tel-gold);
  background: rgba(255, 255, 255, 0.07);
}

.te-launcher-search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 14px;
  height: 14px;
  color: var(--tel-text-subtle);
  pointer-events: none;
}

/* --------------------------------------------------------------------------
   Recently Used Section
   -------------------------------------------------------------------------- */
.te-launcher-recent-section {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-bottom: 4px;
}

.te-launcher-section-label {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--tel-text-subtle);
}

.te-launcher-recent-row {
  display: flex;
  gap: 6px;
  overflow-x: auto;
}

.te-recent-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 9px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--tel-border-subtle);
  border-radius: 999px;
  color: var(--tel-text-muted);
  font-size: 0.75rem;
  font-weight: 500;
  text-decoration: none;
  transition: all var(--tel-transition);
  white-space: nowrap;
}

.te-recent-chip:hover,
.te-recent-chip:focus-visible {
  color: var(--tel-text);
  background: var(--tel-bg-hover);
  border-color: var(--tel-border);
}

.te-recent-chip svg {
  width: 12px;
  height: 12px;
}

/* --------------------------------------------------------------------------
   3x3 Hybrid Grid
   -------------------------------------------------------------------------- */
.te-launcher-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.te-portal-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 12px 6px 10px;
  background: var(--tel-bg-card);
  border: 1px solid var(--tel-border-subtle);
  border-radius: var(--tel-radius-sm);
  color: var(--tel-text);
  text-decoration: none;
  cursor: pointer;
  transition: transform var(--tel-transition), background var(--tel-transition), border-color var(--tel-transition), box-shadow var(--tel-transition);
  outline: none;
}

.te-portal-card:hover,
.te-portal-card:focus-visible,
.te-portal-card.te-keyboard-focused {
  background: var(--tel-bg-hover);
  border-color: var(--portal-accent, var(--tel-gold));
  box-shadow: 0 0 16px -2px var(--portal-accent, var(--tel-gold-glow));
  transform: translateY(-2px);
}

.te-portal-card:focus-visible,
.te-portal-card.te-keyboard-focused {
  outline: 2px solid var(--tel-gold);
  outline-offset: 1px;
}

/* Current Portal Ring / Left Bar indicator */
.te-portal-card[aria-current="page"] {
  border-color: var(--tel-gold);
  box-shadow: 0 0 0 1.5px var(--tel-gold), 0 0 16px -2px var(--tel-gold-glow);
  background: rgba(212, 175, 55, 0.08);
}

.te-portal-card[aria-current="page"]::before {
  content: "";
  position: absolute;
  top: 4px;
  left: 4px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--tel-gold);
  box-shadow: 0 0 6px var(--tel-gold);
}

/* Disabled / "Soon" Tiles */
.te-portal-card.te-status-soon {
  opacity: 0.45;
  pointer-events: none;
  cursor: not-allowed;
  filter: grayscale(0.5);
}

/* Icon Container */
.te-portal-icon-box {
  width: 36px;
  height: 36px;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--tel-border-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 7px;
  color: var(--portal-accent, var(--tel-gold));
  transition: transform var(--tel-transition), border-color var(--tel-transition);
  position: relative;
}

.te-portal-card:hover .te-portal-icon-box {
  transform: scale(1.08);
  border-color: var(--portal-accent, var(--tel-gold));
}

.te-portal-icon-box svg {
  width: 18px;
  height: 18px;
}

/* Offline-cached badge */
.te-portal-offline-badge {
  position: absolute;
  bottom: -3px;
  right: -3px;
  width: 13px;
  height: 13px;
  background: #10b981;
  color: #070b16;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 8px;
  font-weight: 800;
  border: 1.5px solid var(--tel-bg);
}

/* Series Badge */
.te-portal-series {
  font-family: var(--tel-font-mono);
  font-size: 0.625rem;
  color: var(--tel-text-subtle);
  font-weight: 600;
  margin-bottom: 2px;
}

/* Portal Name */
.te-portal-name {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--tel-text);
  line-height: 1.25;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Status Pill */
.te-portal-status-pill {
  font-size: 0.58rem;
  font-weight: 600;
  font-family: var(--tel-font-mono);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 1px 5px;
  border-radius: 999px;
  margin-top: 4px;
}

.te-status-live .te-portal-status-pill {
  color: #10b981;
  background: rgba(16, 185, 129, 0.12);
}

.te-status-beta .te-portal-status-pill {
  color: #38bdf8;
  background: rgba(56, 189, 248, 0.12);
}

.te-status-soon .te-portal-status-pill {
  color: #94a3b8;
  background: rgba(148, 163, 184, 0.12);
}

/* --------------------------------------------------------------------------
   GATE Studio Branch Chips (Inside Card)
   -------------------------------------------------------------------------- */
.te-gate-chips-row {
  display: flex;
  gap: 3px;
  margin-top: 5px;
  justify-content: center;
}

.te-gate-chip {
  font-size: 0.6rem;
  font-family: var(--tel-font-mono);
  font-weight: 700;
  padding: 1px 4px;
  border-radius: 4px;
  background: rgba(139, 92, 246, 0.16);
  color: #a78bfa;
  border: 1px solid rgba(139, 92, 246, 0.3);
  text-decoration: none;
  transition: all var(--tel-transition);
}

.te-gate-chip:hover,
.te-gate-chip:focus-visible {
  background: #8b5cf6;
  color: #ffffff;
  border-color: #8b5cf6;
}

/* --------------------------------------------------------------------------
   Dynamic Bottom Description Strip
   -------------------------------------------------------------------------- */
.te-launcher-desc-strip {
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--tel-border-subtle);
  border-radius: 8px;
  font-size: 0.72rem;
  line-height: 1.4;
  color: var(--tel-text-muted);
  min-height: 34px;
  display: flex;
  align-items: center;
  transition: color var(--tel-transition);
}

.te-launcher-desc-strip strong {
  color: var(--tel-text);
  margin-right: 4px;
}

/* --------------------------------------------------------------------------
   Footer Row: Account on Left, EN/हिं Toggle on Right
   -------------------------------------------------------------------------- */
.te-launcher-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 10px;
  border-top: 1px solid var(--tel-border-subtle);
  font-size: 0.78rem;
}

.te-launcher-account-link {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--tel-text-muted);
  text-decoration: none;
  font-weight: 600;
  transition: color var(--tel-transition);
}

.te-launcher-account-link:hover,
.te-launcher-account-link:focus-visible {
  color: var(--tel-gold);
}

.te-launcher-user-avatar {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--tel-gold);
  color: #070b16;
  font-size: 0.65rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
}

.te-launcher-lang-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--tel-border-subtle);
  border-radius: 6px;
  font-family: var(--tel-font-mono);
  font-size: 0.72rem;
  color: var(--tel-text-muted);
  cursor: pointer;
  transition: all var(--tel-transition);
}

.te-launcher-lang-btn:hover,
.te-launcher-lang-btn:focus-visible {
  color: var(--tel-text);
  border-color: var(--tel-border);
  background: var(--tel-bg-hover);
}

.te-launcher-lang-btn span.active {
  color: var(--tel-gold);
  font-weight: 700;
}

/* --------------------------------------------------------------------------
   Mobile Bottom Sheet (< 640px)
   -------------------------------------------------------------------------- */
@media (max-width: 640px) {
  .te-launcher-dropdown {
    position: fixed;
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100vw;
    max-width: 100vw;
    border-radius: 20px 20px 0 0;
    border-bottom: none;
    border-left: none;
    border-right: none;
    padding: 14px 18px calc(18px + env(safe-area-inset-bottom, 0px));
    animation: teLauncherSheetOpen 150ms var(--tel-ease) forwards;
    transform-origin: bottom center;
  }

  .te-launcher-drag-handle {
    display: block;
  }

  @keyframes teLauncherSheetOpen {
    from {
      opacity: 0;
      transform: translateY(100%);
    }
    to {
      opacity: 1;
      transform: translateY(0);
    }
  }
}

/* --------------------------------------------------------------------------
   Accessibility: Reduced Motion
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  .te-launcher-dropdown,
  .te-launcher-btn,
  .te-portal-card,
  .te-portal-icon-box {
    animation: none !important;
    transition: none !important;
    transform: none !important;
  }
}
