/* Tablet frame for embedded Flutter demo */
.qubitab-device {
  display: grid;
  gap: 0.75rem;
  justify-items: center;
}

.tablet-wrapper {
  /* Smaller embedded device */
  width: clamp(520px, 48vw, 900px);
  max-width: 900px;
}

.tablet-with-qubi {
  position: relative;
  display: flex;
  justify-self: center;
  align-items: flex-end;
  width: 100%;
  max-width: 1200px;
  height: auto;
  padding-bottom: 1.5rem;
}

.qubi-tablet-image {
  position: absolute;
  bottom: -23%;
  left: 52%;
  transform: translateX(-50%);
  width: clamp(550px, 130vw, 200%);
  height: auto;
  z-index: 1;
  display: block;
}

.tablet-wrapper--layered {
  position: absolute;
  top: clamp(8%, 12vw, 18%);
  left: 50%;
  transform: translate(-50%, 0);
  width: clamp(320px, 65vw, 600px);
  max-width: 600px;
  z-index: 2;
}

/* Desktop: Show Qubi with tablet layered on top */
@media (min-width: 1024px) {
  .tablet-with-qubi {
    max-width: none;
    overflow: visible;
  }
  
  .qubi-tablet-image {
    bottom: -398px !important; /* Move Qubi down a bit - fixed pixels */
    width: 720px !important; /* Moderate Qubi size - fixed pixels */
    left: 50% !important; /* Move Qubi slightly to the left */
    max-width: none !important;
    height: auto !important;
    z-index: 1; /* Ensure Qubi stays behind tablet */
  }
  
  .tablet-with-qubi .tablet-wrapper--layered {
    top: -300px !important; /* Move tablet higher up - above Qubi's face */
    left: 49%;
    z-index: 2; /* Ensure tablet is above Qubi */
  }
}

/* Tablet: Keep Qubi visible, adjust layout */
@media (min-width: 768px) and (max-width: 1023px) {
  .tablet-with-qubi {
    height: auto;
    padding-bottom: 1.5rem;
    min-height: 400px;
  }
}

/* Mobile: Consolidated mobile rules */
@media (max-width: 767px) {
  /* Qubi and tablet positioning */
  .qubi-tablet-image {
    width: clamp(540px, 125vw, 210%);
    left: 52%;
    transform: translateX(-50%);
    bottom: -35%;
  }

  .tablet-with-qubi {
    height: auto;
    padding-bottom: 1.5rem;
    min-height: 400px;
    order: 1;
    margin-top: 2rem;
  }

  .tablet-wrapper--layered {
    width: clamp(340px, 70vw, 625px);
    top: clamp(12%, 15vw, 22%);
  }

  /* CTA display */
  .tablet-cta-mobile {
    text-align: center;
    margin: 2rem 0;
  }

  /* QubiTab device layout */
  .qubitab-device { 
    margin-top: -2rem !important; 
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
  }
  
  .tablet-actions {
    display: none;
  }
  
  .tablet-note {
    display: none;
  }

  /* Modal optimization */
  .tablet-modal__inner {
    width: 100%;
    height: 100%;
    border-radius: 0;
    max-width: none;
    z-index: 1; /* Ensure Qubi stays behind tablet */
    aspect-ratio: auto;
  }
  
  .tablet-modal__close {
    position: fixed;
    top: 1rem;
    right: 1rem;
    background: rgba(0, 0, 0, 0.8);
  }
}

/* Hide mobile CTA on tablet and desktop */
@media (min-width: 768px) {
  .tablet-cta-mobile {
    display: none;
  }
}

.tablet-bezel {
  position: relative;
  aspect-ratio: 16 / 10;
  border-radius: 22px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.12);
  box-shadow: 0 24px 60px rgba(0,0,0,0.5);
  overflow: hidden;
}

.tablet-notch {
  position: absolute;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  width: 56px;
  height: 6px;
  border-radius: 6px;
  background: rgba(0,0,0,0.4);
  z-index: 2;
}

.tablet-screen {
  position: absolute;
  inset: 0;
  background: #000;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
}

.tablet-iframe {
  width: 100%;
  height: 100%;
  border: 0;
  background: #000;
}

.tablet-actions {
  display: flex;
  gap: .5rem;
  justify-content: center;
}

.btn--sm {
  font-size: .85rem;
  padding: .4rem .7rem;
}

/* Fullscreen modal overlay */
.tablet-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  opacity: 0;
  visibility: hidden;
  transition: all 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}
.tablet-modal.open { 
  opacity: 1; 
  visibility: visible;
  background: rgba(0,0,0,.85);
}
.tablet-modal__inner {
  /* Larger fullscreen size */
  width: clamp(720px, 70vw, 1200px);
  aspect-ratio: 16/10;
  background: #000;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 30px 80px rgba(0,0,0,.6);
  transform: scale(0.1);
  transition: transform 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}
.tablet-modal.open .tablet-modal__inner {
  transform: scale(1);
}
.tablet-modal__inner iframe { width: 100%; height: 100%; border: 0; }
.tablet-modal__close {
  position: absolute;
  top: 18px;
  right: 24px;
  font-size: 18px;
  min-width: var(--touch-target-min);
  min-height: var(--touch-target-min);
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(10px);
  border-radius: 50%;
  z-index: 10002;
}

.tablet-note {
  font-size: .8rem;
  opacity: .75;
  text-align: center;
  margin: 0;
}

/* Mobile: Fullscreen modal optimization */
@media (max-width: 767px) {
  .tablet-modal__inner {
    width: 100%;
    height: 100%;
    border-radius: 0;
    max-width: none;
    aspect-ratio: auto;
  }
  
  .tablet-modal__close {
    position: fixed;
    top: 1rem;
    right: 1rem;
    background: rgba(0, 0, 0, 0.8);
  }
}

.tablet-note {
  font-size: .8rem;
  opacity: .75;
  text-align: center;
  margin: 0;
}

/* Use consistent breakpoint from variables */
@media (max-width: 767px) {
  .qubitab-device { 
    margin-top: 1rem; 
  }
  
  .tablet-actions {
    flex-direction: column;
    width: 100%;
  }
  
  .tablet-actions .btn {
    width: 100%;
  }
}
