/* Global shell + design tokens */
:root {
  --bg: #0b1520;
  --text-primary: #e6eef8;
  --text-secondary: #d0dbed;
  --text-tertiary: #92b1cc;
  --text-muted: rgba(152, 195, 255, 0.35);
  --action-primary: rgba(97, 139, 254, 0.9);
  --action-success: rgba(97, 254, 139, 0.8);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family:
    Inter,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    'Segoe UI',
    sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  overflow-x: clip;
}

/* App launcher */
.mode-selector {
  position: fixed;
  inset: 0;
  z-index: 3000;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  overflow-x: clip;
  min-height: 100svh;
  min-height: 100dvh;
  background: var(--bg, #0b1520);
}

/* Video background */
.mode-selector-video-bg {
  position: absolute;
  top: 50%;
  left: 50%;
  min-width: 100%;
  min-height: 100%;
  width: auto;
  height: auto;
  transform: translate(-50%, -50%);
  object-fit: cover;
  z-index: 0;
}

/* Gradient overlay on top of video */
.mode-selector-overlay {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 50% 40%, rgba(11, 21, 32, 0.75) 0%, rgba(11, 21, 32, 0.92) 70%);
  z-index: 1;
}

@keyframes modeSelectorFadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes tileSlideIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.mode-selector-content {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(24px, 5vw, 40px);
  max-width: 1000px;
  width: 100%;
  padding: clamp(20px, 4vw, 40px) clamp(16px, 4vw, 24px);
  padding-bottom: max(56px, calc(env(safe-area-inset-bottom, 0px) + 48px));
  box-sizing: border-box;
  animation: modeSelectorFadeIn 0.5s ease-out;
}

/* Header section */
.mode-selector-header {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 20px;
  text-align: left;
}

.mode-selector-header--title-only {
  justify-content: center;
  text-align: center;
  width: 100%;
}

.mode-selector-header-text {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.mode-selector-logo {
  width: 72px;
  height: 72px;
  flex-shrink: 0;
  opacity: 0.95;
  filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.3));
}

.mode-selector-title {
  font-size: clamp(3rem, 10vw + 1rem, 6rem);
  font-weight: 700;
  color: var(--text-primary, #e6eef8);
  margin: 0;
  letter-spacing: -0.04em;
  line-height: 1.15;
  font-family: 'Inter', 'SF Pro Display', -apple-system, BlinkMacSystemFont, sans-serif;
  background: linear-gradient(135deg, #ffffff 0%, #a8c0e8 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-shadow: 0 2px 20px rgba(152, 195, 255, 0.2);
}

.mode-selector-subtitle {
  font-size: 17px;
  color: var(--text-tertiary, #92B1CC);
  margin: 0;
  font-weight: 400;
  opacity: 0.85;
  letter-spacing: 0.01em;
}

/* Equal-height tiles; responsive columns without awkward wrapping */
.mode-selector-buttons {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr));
  gap: clamp(12px, 2.5vw, 16px);
  width: 100%;
  max-width: 900px;
  align-items: stretch;
}

/* Individual mode button - Glass morphism style */
.mode-button {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 12px;
  padding: clamp(16px, 3vw, 24px) clamp(12px, 2.5vw, 16px);
  width: 100%;
  min-height: clamp(200px, 36vw, 220px);
  height: 100%;
  background: linear-gradient(
    165deg,
    rgba(152, 195, 255, 0.08) 0%,
    rgba(152, 195, 255, 0.03) 100%
  );
  border: 1px solid rgba(152, 195, 255, 0.08);
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
  backdrop-filter: blur(8px);
  animation: tileSlideIn 0.5s ease-out backwards;
  font-family: inherit;
}

.mode-button:nth-child(1) { animation-delay: 0.1s; }
.mode-button:nth-child(2) { animation-delay: 0.15s; }
.mode-button:nth-child(3) { animation-delay: 0.2s; }
.mode-button:nth-child(4) { animation-delay: 0.25s; }
.mode-button:nth-child(5) { animation-delay: 0.3s; }
.mode-button:nth-child(6) { animation-delay: 0.35s; }

.mode-button::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 0%, var(--app-color, rgba(152, 195, 255, 0.15)) 0%, transparent 70%);
  opacity: 0;
  transition: opacity 0.4s ease;
}

.mode-button::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1), transparent);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.mode-button:hover {
  transform: translateY(-6px);
  border-color: rgba(152, 195, 255, 0.15);
  box-shadow:
    0 20px 40px rgba(0, 0, 0, 0.3),
    0 0 60px color-mix(in srgb, var(--app-color, #5271FF) 10%, transparent);
}

.mode-button:hover::before {
  opacity: 0.6;
}

.mode-button:hover::after {
  opacity: 1;
}

.mode-button:active {
  transform: translateY(-3px);
}

/* Hero tile: Paradigmatic Innovations Group above the others */
.mode-selector-hero {
  width: 100%;
  max-width: 900px;
  margin: 0 auto clamp(12px, 2.5vw, 16px);
  display: flex;
  justify-content: center;
}

.mode-button--hero {
  width: clamp(280px, 42%, 380px);
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: clamp(16px, 3vw, 24px) clamp(12px, 2.5vw, 16px);
  min-height: clamp(200px, 36vw, 220px);
  text-align: center;
}

.mode-button--hero .mode-button-icon {
  flex: 0 0 auto;
  display: flex;
  justify-content: center;
}

.mode-button--hero .mode-button-text {
  flex: 0 1 auto;
  text-align: center;
}

/* Coming soon callout */
.coming-soon-callout {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translate(-50%, -6px) scale(0.92);
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(20, 26, 44, 0.92);
  border: 1px solid color-mix(in srgb, var(--app-color, #5271FF) 55%, transparent);
  color: #f1f5ff;
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  box-shadow:
    0 6px 20px rgba(0, 0, 0, 0.4),
    0 0 24px color-mix(in srgb, var(--app-color, #5271FF) 30%, transparent);
  backdrop-filter: blur(6px);
  transition:
    opacity 0.45s ease,
    transform 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
  z-index: 5;
}

.coming-soon-callout.is-visible,
.mode-button:hover .coming-soon-callout,
.mode-button:focus-visible .coming-soon-callout {
  opacity: 1;
  transform: translate(-50%, 0) scale(1);
}

.mode-selector-buttons--quad {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 180px), 1fr));
}

/* Dynamic color from CSS variable */
.mode-button:hover {
  background: linear-gradient(
    165deg,
    color-mix(in srgb, var(--app-color, #5271FF) 12%, transparent) 0%,
    color-mix(in srgb, var(--app-color, #5271FF) 5%, transparent) 100%
  );
}

/* Icon container — no boxed background (logos sit directly on the tile) */
.mode-button-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  align-self: center;
  flex-shrink: 0;
  background: transparent;
  border-radius: 0;
  transition: none;
}

.mode-button:hover .mode-button-icon {
  background: transparent;
}

.mode-button-logo-img {
  width: 72px;
  height: 72px;
  object-fit: contain;
  display: block;
  transition: transform 0.3s ease, filter 0.3s ease;
  /* Accent glow (per-tile --app-color from config) */
  filter: drop-shadow(0 0 14px color-mix(in srgb, var(--app-color) 45%, transparent));
}

/*
 * Tetranomics & PI Health: hue-shift the original multi-stop SVG so fades/gradients stay,
 * then nudge saturation toward each accent.
 */
.mode-button-tetranomics .mode-button-logo-img {
  filter:
    hue-rotate(-82deg)
    saturate(1.18)
    brightness(1.04)
    drop-shadow(0 0 14px color-mix(in srgb, var(--app-color) 48%, transparent));
}

.mode-button-pi-health .mode-button-logo-img {
  filter:
    hue-rotate(58deg)
    saturate(1.55)
    brightness(0.95)
    drop-shadow(0 0 14px color-mix(in srgb, var(--app-color) 55%, transparent));
}

.mode-button-atlas .mode-button-logo-img {
  filter:
    hue-rotate(-25deg)
    saturate(0.85)
    brightness(1.35)
    drop-shadow(0 0 14px color-mix(in srgb, var(--app-color) 55%, transparent));
}

.mode-button-eagora .mode-button-logo-img {
  filter:
    drop-shadow(0 0 14px color-mix(in srgb, var(--app-color) 50%, transparent));
}

.mode-button:hover .mode-button-logo-img {
  transform: scale(1.08);
}

.mode-button-paradigmatic-group:hover .mode-button-logo-img {
  filter:
    drop-shadow(0 0 22px color-mix(in srgb, var(--app-color) 70%, transparent))
    drop-shadow(0 0 8px var(--app-color));
}

.mode-button-tetranomics:hover .mode-button-logo-img {
  filter:
    hue-rotate(-82deg)
    saturate(1.18)
    brightness(1.04)
    drop-shadow(0 0 22px color-mix(in srgb, var(--app-color) 72%, transparent))
    drop-shadow(0 0 8px var(--app-color));
}

.mode-button-pi-health:hover .mode-button-logo-img {
  filter:
    hue-rotate(58deg)
    saturate(1.55)
    brightness(0.95)
    drop-shadow(0 0 22px color-mix(in srgb, var(--app-color) 75%, transparent))
    drop-shadow(0 0 8px var(--app-color));
}

.mode-button-atlas:hover .mode-button-logo-img {
  filter:
    hue-rotate(-25deg)
    saturate(0.85)
    brightness(1.35)
    drop-shadow(0 0 22px color-mix(in srgb, var(--app-color) 75%, transparent))
    drop-shadow(0 0 8px var(--app-color));
}

.mode-button-eagora:hover .mode-button-logo-img {
  filter:
    drop-shadow(0 0 22px color-mix(in srgb, var(--app-color) 70%, transparent))
    drop-shadow(0 0 8px var(--app-color));
}

/* Footer — Impressum */
.mode-selector-footer {
  position: fixed;
  bottom: max(12px, env(safe-area-inset-bottom, 0px));
  left: 0;
  right: 0;
  z-index: 4;
  text-align: center;
  pointer-events: none;
  padding: 0 16px;
}

.mode-selector-footer .mode-selector-footer-links,
.mode-selector-footer .mode-selector-impressum-link {
  pointer-events: auto;
}

.mode-selector-footer-links {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px 12px;
}

.mode-selector-footer-sep {
  color: rgba(152, 195, 255, 0.28);
  font-weight: 300;
  user-select: none;
}

.mode-selector-impressum-link {
  font-size: 12px;
  font-weight: 400;
  color: var(--text-muted, rgba(152, 195, 255, 0.4));
  text-decoration: none;
  transition: color 0.2s ease;
}

.mode-selector-impressum-link:hover {
  color: rgba(255, 255, 255, 0.75);
}

/* Text block */
.mode-button-text {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: space-between;
  width: 100%;
  min-height: 0;
  gap: 8px;
}

.mode-button-title-row {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 0 4px;
  min-height: 0;
}

.mode-button-title {
  margin: 0;
  font-size: clamp(14px, 2.4vw, 18px);
  font-weight: 600;
  line-height: 1.3;
  color: var(--text-primary, #e6eef8);
  letter-spacing: -0.01em;
  text-align: center;
  text-wrap: balance;
}

.mode-button-description {
  flex: 0 0 auto;
  margin: 0;
  font-size: clamp(11px, 2vw, 14px);
  line-height: 1.45;
  color: var(--text-tertiary, #92b1cc);
  text-align: center;
  opacity: 0.85;
  max-width: 100%;
}

/* --- Responsive --- */
@media (max-width: 900px) {
  .mode-selector-buttons {
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 180px), 1fr));
    max-width: 640px;
  }
}

@media (max-width: 640px) {
  .mode-selector {
    align-items: flex-start;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .mode-selector-content {
    padding-top: max(24px, env(safe-area-inset-top, 0px));
    gap: 28px;
  }

  .mode-selector-buttons {
    grid-template-columns: 1fr;
    max-width: min(360px, 100%);
  }

  .mode-button {
    min-height: auto;
    padding: 20px 18px;
  }

  .mode-button-logo-img {
    width: 56px;
    height: 56px;
  }
}

@media (max-width: 400px) {
  .mode-selector-content {
    padding-left: 14px;
    padding-right: 14px;
  }

  .mode-button-logo-img {
    width: 48px;
    height: 48px;
  }
}

@media (min-height: 700px) {
  .mode-selector {
    align-items: center;
  }
}

@media (max-height: 520px) and (orientation: landscape) {
  .mode-selector-content {
    gap: 16px;
    padding-top: 12px;
    padding-bottom: max(44px, env(safe-area-inset-bottom, 0px) + 40px);
  }

  .mode-selector-title {
    font-size: clamp(2.5rem, 8vh, 4rem);
  }

  .mode-button {
    min-height: 0;
    padding: 12px 14px;
  }

  .mode-button-logo-img {
    width: 44px;
    height: 44px;
  }
}
