/* App Switcher - Matches Ryan Tools homepage bezel + electro-pulse */
@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap');

#app-switcher-root {
  --as-yellow: #e8b923;
  --as-purple: #c084fc;
  --as-blue: #40c4ff;
  --as-coral: #E07B6B;
  --as-seafoam: #4ff0aa;
  --as-seafoam-dim: #205c43;
  /* Homepage bezel colors - smaller shell, no lights/vent/power */
  --as-bezel: #4a4a50;
  --as-bezel-highlight: #6e6e75;
  --as-bezel-shadow: #2a2a30;
  --as-font-pixel: 'Press Start 2P', cursive, monospace;
}

#app-switcher-root {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 9999;
  padding: 0;
  padding-bottom: max(0, env(safe-area-inset-bottom));
  pointer-events: none;
}

#app-switcher-root.visible {
  display: flex;
  justify-content: center;
  pointer-events: auto;
}

/* Shell - homepage bezel style, full width flush */
.app-switcher-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px 10px 16px;
  background: var(--as-bezel);
  border-top: 4px solid var(--as-bezel-highlight);
  border-left: 0;
  border-right: 0;
  border-bottom: 0;
  border-radius: 0 !important;
  box-shadow: 0 -4px 24px rgba(0,0,0,0.5);
  width: 100%;
}

/* Reserve space so page content sits above the bar */
body:has(#app-switcher-root.visible),
body.has-app-switcher {
  --as-bar-height: 70px;
  padding-bottom: var(--as-bar-height) !important;
  box-sizing: border-box !important;
}

/* Force app containers to respect the bar height */
body:has(#app-switcher-root.visible) .app,
body:has(#app-switcher-root.visible) #app,
body.has-app-switcher .app,
body.has-app-switcher #app {
  height: calc(100vh - var(--as-bar-height)) !important;
  max-height: calc(100vh - var(--as-bar-height)) !important;
}

/* text-to-img sidebar - don't let it extend past the bar */
body:has(#app-switcher-root.visible) .app .sidebar,
body.has-app-switcher .app .sidebar {
  max-height: calc(100vh - var(--as-bar-height)) !important;
  overflow-y: auto !important;
}

/* terminal-to-md and similar full-height layouts */
body:has(#app-switcher-root.visible) > main,
body.has-app-switcher > main {
  height: calc(100vh - var(--as-bar-height) - 60px) !important;
  max-height: calc(100vh - var(--as-bar-height) - 60px) !important;
}

/* Home button - seafoam, favicon; extra space from tools */
.app-switcher-home {
  flex-shrink: 0;
  margin-right: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  background: var(--as-seafoam);
  border: 3px solid var(--as-seafoam-dim);
  border-radius: 8px;
  text-decoration: none;
  box-shadow:
    inset 1px 1px 0 rgba(255,255,255,0.5),
    inset -1px -1px 0 rgba(0,0,0,0.2),
    2px 2px 0 var(--as-seafoam-dim);
  transition: transform 0.15s ease;
}

.app-switcher-home:hover {
  transform: translateY(-2px);
  box-shadow:
    inset 1px 1px 0 rgba(255,255,255,0.6),
    inset -1px -1px 0 rgba(0,0,0,0.15),
    0 0 12px rgba(79, 240, 170, 0.5);
}

.app-switcher-home img {
  width: 22px;
  height: 22px;
  object-fit: contain;
}

/* Tool tiles/links */
.app-switcher-links {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: center;
}

.app-switcher-link {
  --theme-color: #fff;
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  border-radius: 8px;
  padding: 6px 10px;
  border: 3px solid #333;
  background: #1a1a1a;
  transition: transform 0.2s ease;
}

.app-switcher-link:hover {
  transform: translateY(-2px);
}

.app-switcher-link img {
  width: 24px;
  height: 24px;
  object-fit: contain;
  filter: grayscale(20%);
  flex-shrink: 0;
}

.app-switcher-link:hover img {
  filter: grayscale(0%);
}

.app-switcher-title {
  font-family: var(--as-font-pixel);
  font-size: 0.5rem;
  color: var(--theme-color);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  text-shadow: 1px 1px 0 #000;
  white-space: nowrap;
}

/* Theme variants - colored tiles with dark border */
.app-switcher-link.theme-yellow { --theme-color: var(--as-yellow); border-color: #333; background: var(--as-yellow); }
.app-switcher-link.theme-yellow .app-switcher-title { color: #1a1a1a; text-shadow: 1px 1px 0 rgba(255,255,255,0.4); }

.app-switcher-link.theme-purple { --theme-color: var(--as-purple); border-color: #333; background: var(--as-purple); }
.app-switcher-link.theme-purple .app-switcher-title { color: #1a1a1a; text-shadow: 1px 1px 0 rgba(255,255,255,0.4); }

.app-switcher-link.theme-blue { --theme-color: var(--as-blue); border-color: #333; background: var(--as-blue); }
.app-switcher-link.theme-blue .app-switcher-title { color: #1a1a1a; text-shadow: 1px 1px 0 rgba(255,255,255,0.4); }

.app-switcher-link.theme-coral { --theme-color: var(--as-coral); border-color: #333; background: var(--as-coral); }
.app-switcher-link.theme-coral .app-switcher-title { color: #1a1a1a; text-shadow: 1px 1px 0 rgba(255,255,255,0.4); }

/* Electro-pulse animation - homepage style */
@keyframes as-electro-pulse {
  0% { box-shadow: 0 0 5px var(--theme-color), inset 0 0 5px var(--theme-color); border-color: var(--theme-color); }
  50% { box-shadow: 0 0 20px var(--theme-color), inset 0 0 10px var(--theme-color); border-color: #fff; }
  100% { box-shadow: 0 0 5px var(--theme-color), inset 0 0 5px var(--theme-color); border-color: var(--theme-color); }
}

/* Desktop: hover = electro-pulse on whole border */
@media (min-width: 769px) {
  .app-switcher-link:hover {
    animation: as-electro-pulse 0.8s infinite alternate;
  }
}

/* Mobile: taller bar, bigger icons, smaller home button */
@media (max-width: 768px) {
  body:has(#app-switcher-root.visible),
  body.has-app-switcher {
    --as-bar-height: 100px;
  }

  body:has(#app-switcher-root.visible) .app,
  body:has(#app-switcher-root.visible) #app,
  body.has-app-switcher .app,
  body.has-app-switcher #app {
    height: calc(100dvh - var(--as-bar-height)) !important;
    max-height: calc(100dvh - var(--as-bar-height)) !important;
  }

  .app-switcher-bar {
    padding: 14px 16px 14px 20px;
    padding-bottom: max(14px, env(safe-area-inset-bottom));
    gap: 10px;
    border-width: 4px 0 0 0;
    border-radius: 0 !important;
    min-height: 90px;
    align-items: center;
    justify-content: flex-start;
  }

  /* Home button: noticeably smaller than tool buttons */
  .app-switcher-home {
    width: 36px !important;
    height: 36px !important;
    min-width: 36px !important;
    min-height: 36px !important;
    border-width: 2px;
    margin-right: 20px;
    border-radius: 6px;
  }

  .app-switcher-home img {
    width: 18px !important;
    height: 18px !important;
  }

  /* Tool buttons: bigger on mobile */
  .app-switcher-link {
    width: 64px !important;
    height: 64px !important;
    padding: 10px;
    justify-content: center;
    min-width: 64px !important;
    min-height: 64px !important;
    border-radius: 8px;
  }

  .app-switcher-title {
    display: none;
  }

  .app-switcher-link img {
    width: 38px !important;
    height: 38px !important;
    margin: 0;
  }

  .app-switcher-links {
    gap: 10px;
  }

  /* Mobile: electro-pulse on tap (:active) - quick flash */
  .app-switcher-link:active {
    animation: as-electro-pulse 0.15s ease-out 1;
  }
}
