/**
 * YPYM Observatory — Download Apps Section
 * Element X (Mobile) & Element Desktop/Web with Sovereign Homeserver Configuration
 */

.apps-download-section {
  width: 100%;
  padding: 80px 0 60px;
  margin: 0 auto;
  position: relative;
  z-index: 20;
}

.download-section-header {
  text-align: center;
  max-width: 680px;
  margin: 0 auto 36px;
}

.download-section-title {
  font-size: clamp(1.8rem, 3.2vw, 2.4rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--text-primary);
  line-height: 1.2;
  margin-bottom: 12px;
}

.download-section-subtitle {
  font-size: 0.95rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

/* ==========================================================================
   1. Sovereign Homeserver Configuration Banner (matrix.ypym.app)
   ========================================================================== */

.server-config-banner {
  background: transparent;
  border-radius: 0;
  border: none;
  box-shadow: none;
  padding: 0;
  margin-bottom: 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 28px;
  flex-wrap: wrap;
}

.server-config-info {
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
  min-width: 280px;
}

.server-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #0f172a;
}

.server-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: #10b981;
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2);
}

.server-statement {
  font-size: 0.90625rem;
  color: #334155;
  margin: 0;
  line-height: 1.55;
}

.server-statement strong {
  color: #0f172a;
  font-weight: 600;
}

.server-instruction {
  font-size: 0.84375rem;
  color: #64748b;
  margin: 0;
  line-height: 1.45;
}

.server-instruction strong {
  color: #0f172a;
  font-weight: 600;
}

.server-compatible-clients {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 8px;
  margin-top: 4px;
}

.clients-badge-label {
  font-size: 0.75rem;
  color: #94a3b8;
  font-weight: 600;
  margin-right: 2px;
}

.client-chip {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  background: #f1f5f9;
  border: 1px solid rgba(0, 0, 0, 0.06);
  border-radius: var(--radius-pill);
  font-size: 0.75rem;
  font-weight: 600;
  color: #475569;
  transition: all 180ms ease;
  user-select: none;
}

.client-chip:hover {
  background: #e2e8f0;
  color: #0f172a;
  transform: translateY(-1px);
}

.server-url-copybox {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: #f8fafc;
  padding: 6px 6px 6px 16px;
  border-radius: var(--radius-pill);
  border: 1px solid rgba(0, 0, 0, 0.08);
}

.server-url-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.875rem;
  font-weight: 600;
  color: #0f172a;
  user-select: all;
}

.btn-copy-server {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  font-size: 0.8125rem;
  font-weight: 600;
  border-radius: var(--radius-pill);
  background: #0f172a;
  color: #ffffff;
  border: none;
  cursor: pointer;
  transition: all 180ms ease;
  white-space: nowrap;
}

.btn-copy-server:hover {
  background: #1e293b;
  transform: translateY(-1px);
}

.btn-copy-server:active {
  transform: translateY(1px);
}

.btn-copy-server.is-copied {
  background: #10b981;
}

.copy-icon {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

/* ==========================================================================
   2. Two-Card Download Grid
   ========================================================================== */

.download-cards-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 28px;
  width: 100%;
  position: relative;
  z-index: 5;
}

.download-card {
  background: #ffffff;
  border-radius: 28px;
  border: 1px solid rgba(0, 0, 0, 0.05);
  box-shadow: none;
  overflow: visible;
  position: relative;
  display: flex;
  flex-direction: column;
  transition: transform 250ms cubic-bezier(0.16, 1, 0.3, 1);
}

.download-card:hover {
  transform: translateY(-2px);
  box-shadow: none;
}

/* Card Top Visual Preview Stage */
.download-card-preview {
  width: 100%;
  height: 260px;
  position: relative;
  overflow: hidden;
  display: flex;
  justify-content: center;
  align-items: flex-end;
  padding: 24px 20px 0;
  border-top-left-radius: 27px;
  border-top-right-radius: 27px;
}

/* Mobile Card Ambient Backdrop */
.mobile-preview-bg {
  background: radial-gradient(circle at 50% 10%, #38bdf8 0%, #0284c7 35%, #0f172a 90%);
}

/* Desktop Card Ambient Backdrop */
.desktop-preview-bg {
  background: radial-gradient(circle at 50% 10%, #2dd4bf 0%, #0f766e 40%, #0f172a 90%);
}

/* --------------------------------------------------------------------------
   2.1 Mobile Phone Illustration (Element X)
   -------------------------------------------------------------------------- */
.preview-phone-chassis {
  width: 250px;
  height: 260px;
  background: #ffffff;
  border-top-left-radius: 36px;
  border-top-right-radius: 36px;
  border: 4px solid #1e293b;
  border-bottom: none;
  box-shadow: none;
  position: relative;
  padding: 10px 14px 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.preview-phone-island {
  width: 76px;
  height: 18px;
  background: #0f172a;
  border-radius: 12px;
  margin: 0 auto 10px;
}

.preview-phone-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.65rem;
  font-weight: 700;
  color: #0f172a;
  margin-bottom: 8px;
  padding: 0 4px;
}

.preview-chat-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 4px 8px;
  border-bottom: 1px solid #f1f5f9;
  margin-bottom: 8px;
}

.preview-chat-title {
  font-size: 0.95rem;
  font-weight: 800;
  color: #0f172a;
  letter-spacing: -0.02em;
}

.preview-edit-icon {
  color: #64748b;
}

.preview-chat-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 4px;
}

.preview-avatar-circle {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  flex-shrink: 0;
  overflow: hidden;
}

.preview-avatar-circle .chat-avatar-photo {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
  display: block;
}

.icon-incident {
  background: #dbeafe;
  border: 1px solid #93c5fd;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.icon-incident::after {
  content: '';
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 2px solid #2563eb;
}

.avatar-jacob {
  background: #fef3c7;
  border: 1px solid #fde68a;
}

.preview-chat-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.preview-chat-line1 {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.725rem;
  color: #0f172a;
}

.preview-chat-time {
  font-size: 0.625rem;
  color: #94a3b8;
}

.preview-chat-snippet {
  font-size: 0.65rem;
  color: #64748b;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* --------------------------------------------------------------------------
   2.2 Desktop Window Illustration
   -------------------------------------------------------------------------- */
.preview-desktop-window {
  width: 100%;
  max-width: 440px;
  height: 240px;
  background: #181c24;
  border-top-left-radius: 16px;
  border-top-right-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-bottom: none;
  box-shadow: none;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.preview-window-titlebar {
  height: 32px;
  background: #11141a;
  display: flex;
  align-items: center;
  padding: 0 12px;
  gap: 6px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.preview-window-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
}

.dot-red { background: #ef4444; }
.dot-yellow { background: #f59e0b; }
.dot-green { background: #10b981; }

.preview-window-title {
  font-size: 0.725rem;
  font-weight: 600;
  color: #94a3b8;
  margin-left: 10px;
}

.preview-desktop-body {
  display: flex;
  flex: 1;
}

.preview-desktop-sidebar {
  width: 90px;
  background: #141720;
  padding: 10px 8px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  border-right: 1px solid rgba(255, 255, 255, 0.05);
}

.preview-sidebar-pill {
  font-size: 0.65rem;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 6px;
}

.preview-sidebar-pill.is-active {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
}

.preview-sidebar-item {
  font-size: 0.625rem;
  color: #64748b;
  padding: 3px 6px;
}

.preview-desktop-chat {
  flex: 1;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.preview-bubble {
  background: #1e2430;
  border-radius: 10px;
  padding: 6px 10px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  max-width: 90%;
}

.bubble-sender {
  font-size: 0.65rem;
  font-weight: 700;
  color: #38bdf8;
}

.bubble-voice-bar {
  font-size: 0.625rem;
  color: #94a3b8;
  letter-spacing: 0.05em;
}

.bubble-text {
  font-size: 0.6875rem;
  color: #e2e8f0;
  line-height: 1.35;
}

/* --------------------------------------------------------------------------
   2.3 Card Body & Download Action Controls
   -------------------------------------------------------------------------- */
.download-card-body {
  padding: 30px 28px 32px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  flex: 1;
}

.download-card-title {
  font-size: 1.75rem;
  font-weight: 800;
  letter-spacing: -0.025em;
  color: #0f172a;
  margin-bottom: 6px;
}

.download-card-caption {
  font-size: 0.875rem;
  color: #64748b;
  margin-bottom: 24px;
  max-width: 380px;
}

/* Mobile Store Badges Row */
.store-badges-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
  width: 100%;
}

.store-badge-link {
  display: inline-block;
  transition: transform 180ms ease, opacity 180ms ease;
  border-radius: 10px;
  overflow: hidden;
  line-height: 0;
}

.store-badge-link:hover {
  transform: translateY(-2px);
  opacity: 0.92;
}

.store-badge-link:active {
  transform: translateY(1px);
}

.store-badge-svg {
  height: 40px;
  width: auto;
  display: block;
}

/* Desktop 2x2 Buttons Grid */
.desktop-buttons-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  width: 100%;
  max-width: 440px;
}

.desktop-download-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 18px;
  border-radius: var(--radius-pill);
  border: 1.5px solid #27272a;
  background: #ffffff;
  color: #0f172a;
  font-size: 0.875rem;
  font-weight: 600;
  transition: all 180ms ease;
  cursor: pointer;
  user-select: none;
  text-decoration: none;
  width: 100%;
}

.desktop-download-btn:hover {
  background: #f4f4f5;
  border-color: #000000;
  transform: translateY(-1px);
}

.desktop-download-btn:active {
  transform: translateY(1px);
}

.btn-platform-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.btn-web-cta {
  background: #f8fafc;
}

/* Windows Dropdown Wrapper */
.windows-dropdown-wrapper {
  position: relative;
  width: 100%;
}

.dropdown-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.dropdown-chevron {
  transition: transform 200ms ease;
}

.windows-dropdown-wrapper.is-open {
  z-index: 60;
}

.windows-dropdown-wrapper.is-open .dropdown-chevron {
  transform: rotate(180deg);
}

.windows-dropdown-menu {
  position: absolute;
  top: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  width: 220px;
  background: #ffffff;
  border-radius: 16px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  box-shadow: 0 14px 34px -8px rgba(0, 0, 0, 0.18);
  padding: 6px;
  display: none;
  flex-direction: column;
  gap: 4px;
  z-index: 100;
}

.windows-dropdown-wrapper.is-open .windows-dropdown-menu {
  display: flex;
  animation: dropdownFadeIn 160ms var(--ease-spring);
}

@keyframes dropdownFadeIn {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(-6px);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

.dropdown-item {
  display: flex;
  flex-direction: column;
  padding: 8px 12px;
  border-radius: 10px;
  text-align: left;
  transition: background 150ms ease;
}

.dropdown-item:hover {
  background: #f1f5f9;
}

.dropdown-item-title {
  font-size: 0.8125rem;
  font-weight: 700;
  color: #0f172a;
}

.dropdown-item-sub {
  font-size: 0.6875rem;
  color: #64748b;
}

/* ==========================================================================
   3. Responsive Media Queries
   ========================================================================== */
@media (max-width: 860px) {
  .download-cards-grid {
    grid-template-columns: 1fr;
    gap: 24px;
  }
}

@media (max-width: 640px) {
  .apps-download-section {
    padding: 50px 0 40px;
  }

  .server-config-banner {
    flex-direction: column;
    align-items: flex-start;
    padding: 18px 16px;
    gap: 14px;
    border-radius: 18px;
  }

  .server-url-copybox {
    width: 100%;
    flex-direction: column;
    align-items: stretch;
    padding: 10px;
    gap: 10px;
    border-radius: 14px;
  }

  .server-url-code {
    font-size: 0.875rem;
    text-align: center;
    padding: 4px 0;
    word-break: break-all;
  }

  .btn-copy-server {
    width: 100%;
    justify-content: center;
    padding: 10px 16px;
    font-size: 0.8125rem;
  }

  .download-card {
    border-radius: 22px;
  }

  .download-card-preview {
    height: 220px;
    padding-top: 20px;
  }

  .preview-phone-chassis {
    width: 220px;
    height: 220px;
  }

  .preview-desktop-window {
    max-width: 320px;
    height: 200px;
  }

  .download-card-body {
    padding: 24px 18px 26px;
  }

  .download-card-title {
    font-size: 1.5rem;
  }

  .store-badges-row {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 10px;
  }

  .store-badge-svg {
    height: 38px;
  }

  .desktop-buttons-grid {
    grid-template-columns: 1fr;
    max-width: 100%;
    gap: 10px;
  }
}
