/* device-view.css — Multi device-view toggle UI + frames */

/* ============================================================
   TOGGLE BUTTON + MENU (dropdown floating bottom-left)
   ============================================================ */
.tlp-device-toggle {
  position: fixed;
  z-index: 9998;
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  left: calc(16px + env(safe-area-inset-left, 0px));
  font-family:
    -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter",
    ui-sans-serif, system-ui, sans-serif;
}
.tlp-device-toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: rgba(15, 20, 30, 0.78);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  color: #eef6ff;
  cursor: pointer;
  backdrop-filter: blur(28px) saturate(180%);
  -webkit-backdrop-filter: blur(28px) saturate(180%);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  font-size: 0.84rem;
  transition:
    transform 220ms cubic-bezier(0.32, 0.72, 0, 1),
    background 150ms,
    padding 220ms cubic-bezier(0.32, 0.72, 0, 1),
    width 220ms cubic-bezier(0.32, 0.72, 0, 1);
  min-height: 44px;
  max-width: min(320px, 70vw);
}
.tlp-device-toggle-btn:hover {
  background: rgba(20, 28, 40, 0.88);
  transform: translateY(-1px);
}
.tlp-device-toggle-icon { font-size: 1.05rem; line-height: 1; }
.tlp-device-toggle-text {
  display: grid;
  text-align: left;
  line-height: 1.1;
  gap: 1px;
  overflow: hidden;
  transition: max-width 220ms cubic-bezier(0.32, 0.72, 0, 1), opacity 180ms;
  max-width: 220px;
}
.tlp-device-toggle-label { font-weight: 600; font-size: 0.84rem; white-space: nowrap; }
.tlp-device-toggle-sub { font-size: 0.7rem; opacity: 0.7; white-space: nowrap; }
.tlp-device-toggle-caret { opacity: 0.6; font-size: 0.7rem; transition: opacity 180ms; }

/* ============================================================
   COLLAPSE BUTTON (✕ siempre visible cuando expandido — bulletproof)
   ============================================================ */
.tlp-device-toggle-collapse {
  position: absolute;
  top: -10px;
  right: -10px;
  width: 28px;
  height: 28px;
  min-height: 28px;
  padding: 0;
  border-radius: 50%;
  background: rgba(40, 50, 70, 0.96);
  border: 1.5px solid rgba(255, 255, 255, 0.32);
  color: #eef6ff;
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 800;
  line-height: 1;
  display: grid;
  place-items: center;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.45);
  /* SIEMPRE clickable cuando el toggle está expandido. No hover-only. */
  opacity: 1;
  transform: scale(1);
  pointer-events: auto;
  transition: background 150ms, transform 150ms cubic-bezier(0.32, 0.72, 0, 1), border-color 150ms;
  z-index: 2;
}
.tlp-device-toggle-collapse:hover {
  background: rgba(255, 141, 141, 0.95);
  border-color: rgba(255, 141, 141, 0.8);
  transform: scale(1.1);
}
.tlp-device-toggle-collapse:active { transform: scale(0.94); }
.tlp-device-toggle[data-collapsed] .tlp-device-toggle-collapse {
  display: none;
}

/* ============================================================
   COLLAPSED STATE — pill becomes a tiny round icon button
   ============================================================ */
.tlp-device-toggle[data-collapsed] .tlp-device-toggle-btn {
  padding: 0;
  width: 44px;
  height: 44px;
  min-height: 44px;
  border-radius: 50%;
  justify-content: center;
  gap: 0;
  position: relative;
}
.tlp-device-toggle[data-collapsed] .tlp-device-toggle-btn::after {
  /* Subtle glow indicator: this is interactive, click to expand */
  content: "";
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 1px solid rgba(57, 217, 138, 0.35);
  pointer-events: none;
  opacity: 0;
  transition: opacity 220ms;
}
.tlp-device-toggle[data-collapsed] .tlp-device-toggle-btn:hover::after,
.tlp-device-toggle[data-collapsed] .tlp-device-toggle-btn:focus::after {
  opacity: 1;
}
.tlp-device-toggle[data-collapsed] .tlp-device-toggle-icon {
  font-size: 1.2rem;
}
.tlp-device-toggle[data-collapsed] .tlp-device-toggle-text {
  max-width: 0;
  opacity: 0;
}
.tlp-device-toggle[data-collapsed] .tlp-device-toggle-caret {
  display: none;
}
.tlp-device-toggle[data-collapsed] .tlp-device-toggle-btn:hover {
  background: rgba(30, 45, 65, 0.95);
  transform: translateY(-1px) scale(1.06);
}

.tlp-device-toggle-menu {
  position: absolute;
  bottom: calc(100% + 10px);
  left: 0;
  width: min(320px, 88vw);
  max-height: min(70vh, 540px);
  display: flex;
  flex-direction: column;
  background: rgba(12, 18, 28, 0.94);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 18px;
  backdrop-filter: blur(40px) saturate(180%);
  -webkit-backdrop-filter: blur(40px) saturate(180%);
  box-shadow: 0 30px 100px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  overflow: hidden;
  color: #eef6ff;
  animation: tlp-dt-pop 200ms cubic-bezier(0.32, 0.72, 0, 1);
}
@keyframes tlp-dt-pop {
  from { opacity: 0; transform: translateY(8px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.tlp-device-toggle-head {
  padding: 14px 16px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}
.tlp-device-toggle-head strong { font-size: 0.86rem; display: block; }
.tlp-device-toggle-head span { font-size: 0.74rem; color: #a9bacf; }
.tlp-device-toggle-x {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 50%;
  width: 28px;
  height: 28px;
  min-height: 28px;
  padding: 0;
  color: #eef6ff;
  font-size: 1.05rem;
  line-height: 1;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background 150ms, border-color 150ms;
  flex-shrink: 0;
}
.tlp-device-toggle-x:hover {
  background: rgba(255, 141, 141, 0.18);
  border-color: rgba(255, 141, 141, 0.5);
}
.tlp-device-toggle-list {
  padding: 6px;
  overflow-y: auto;
  display: grid;
  gap: 2px;
}
.tlp-device-toggle-option {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  background: transparent;
  border: 0;
  border-radius: 10px;
  color: #eef6ff;
  cursor: pointer;
  text-align: left;
  font-size: 0.84rem;
  min-height: 44px;
  transition: background 120ms;
}
.tlp-device-toggle-option:hover {
  background: rgba(255, 255, 255, 0.07);
}
.tlp-device-toggle-option.is-active {
  background: rgba(57, 217, 138, 0.16);
  color: #39d98a;
}
.tlp-device-toggle-option .opt-icon { font-size: 1rem; }
.tlp-device-toggle-option .opt-text { display: grid; line-height: 1.2; }
.tlp-device-toggle-option .opt-label { font-weight: 600; }
.tlp-device-toggle-option .opt-sub { font-size: 0.72rem; opacity: 0.65; }
.tlp-device-toggle-option .opt-check { color: #39d98a; font-weight: 800; }
.tlp-device-toggle-foot {
  padding: 10px 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 0.74rem;
  color: #a9bacf;
}
.tlp-device-toggle-foot strong { color: #67d1ff; font-family: ui-monospace, "SF Mono", Menlo, monospace; }
.tlp-device-toggle-reset {
  padding: 6px 10px;
  background: rgba(103, 209, 255, 0.1);
  border: 1px solid rgba(103, 209, 255, 0.3);
  color: #67d1ff;
  border-radius: 999px;
  cursor: pointer;
  font-size: 0.72rem;
  font-weight: 600;
  min-height: auto;
}
.tlp-device-toggle-reset:hover { background: rgba(103, 209, 255, 0.18); }

/* ============================================================
   DEVICE FRAMES — when user picks a specific device, body becomes
   a constrained container with chrome (notch, home bar, bezel, etc.)
   ============================================================ */

html[data-device-frame] {
  background:
    radial-gradient(ellipse at 30% 20%, rgba(40, 50, 70, 0.5), transparent 50%),
    radial-gradient(ellipse at 70% 80%, rgba(60, 30, 70, 0.4), transparent 50%),
    #0a0a10;
  min-height: 100vh;
  padding: 24px 24px calc(24px + env(safe-area-inset-bottom, 0px));
  overflow-x: auto;
  display: flex;
  align-items: flex-start;
  justify-content: center;
}

html[data-device-frame] body {
  width: var(--vp-width, 100%);
  max-width: 100%;
  min-height: var(--vp-height, auto);
  margin: 0 auto;
  position: relative;
  border-radius: 28px;
  overflow: hidden;
  box-shadow:
    0 0 0 8px #1a1d24,
    0 0 0 10px #0a0c10,
    0 30px 80px rgba(0, 0, 0, 0.6),
    0 60px 160px rgba(0, 0, 0, 0.4);
  background: var(--bg, #07111d);
  isolation: isolate;
}

/* Phone iOS — notch + home indicator */
html[data-device-frame="phone-ios"] body {
  border-radius: 50px;
}
html[data-device-frame="phone-ios"] body::before {
  content: "";
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  width: 120px;
  height: 28px;
  background: #000;
  border-radius: 18px;
  z-index: 9000;
  pointer-events: none;
}
html[data-device-frame="phone-ios"] body::after {
  content: "";
  position: absolute;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  width: 130px;
  height: 5px;
  background: rgba(255, 255, 255, 0.7);
  border-radius: 3px;
  z-index: 9000;
  pointer-events: none;
}

/* Tablet iOS — top status bar + bezel */
html[data-device-frame="tablet-ios"] body {
  border-radius: 22px;
}
html[data-device-frame="tablet-ios"] body::after {
  content: "";
  position: absolute;
  bottom: 6px;
  left: 50%;
  transform: translateX(-50%);
  width: 140px;
  height: 4px;
  background: rgba(255, 255, 255, 0.6);
  border-radius: 2px;
  z-index: 9000;
}

/* Apple Watch — extreme rounded, crown indicator */
html[data-device-frame="watch"] body {
  border-radius: 50px / 60px;
  box-shadow:
    0 0 0 12px #181818,
    0 0 0 14px #0a0a0a,
    0 30px 80px rgba(0, 0, 0, 0.6);
}
html[data-device-frame="watch"] body::before {
  /* digital crown */
  content: "";
  position: absolute;
  right: -22px;
  top: 30%;
  width: 10px;
  height: 26px;
  background: linear-gradient(90deg, #2a2a2a, #4a4a4a);
  border-radius: 4px;
  z-index: 9000;
}
html[data-device="watch"] body { font-size: 0.78em; }
html[data-device="watch"] .globalnav-name,
html[data-device="watch"] .globalnav-sub,
html[data-device="watch"] .footer-grid,
html[data-device="watch"] .hero-meta,
html[data-device="watch"] #bio-canvas { display: none !important; }
html[data-device="watch"] .hero { min-height: auto; padding: 30px 0 14px; }
html[data-device="watch"] .hero-title { font-size: 2rem !important; }
html[data-device="watch"] .welcome-strip { padding: 16px 0; }
html[data-device="watch"] .welcome-inner { padding: 18px 14px; border-radius: 16px; }
html[data-device="watch"] .welcome-quote-mark { display: none; }

/* Apple Vision Pro — spatial, translucent, depth */
html[data-device-frame="vision"] {
  background:
    radial-gradient(ellipse at center, rgba(40, 60, 110, 0.4), transparent 70%),
    radial-gradient(ellipse at 20% 30%, rgba(120, 80, 200, 0.25), transparent 50%),
    radial-gradient(ellipse at 80% 70%, rgba(50, 200, 220, 0.2), transparent 50%),
    #04060a;
}
html[data-device-frame="vision"] body {
  border-radius: 40px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.05),
    0 50px 140px rgba(0, 0, 0, 0.7),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
  background:
    linear-gradient(165deg,
      rgba(20, 30, 50, 0.7),
      rgba(10, 18, 35, 0.7) 60%,
      rgba(30, 40, 70, 0.6));
  backdrop-filter: blur(60px) saturate(160%);
  -webkit-backdrop-filter: blur(60px) saturate(160%);
}
html[data-device="vision"] :is(.app-card, .ayuda-card, .welcome-inner, .teachers-callout) {
  background: rgba(255, 255, 255, 0.06) !important;
  backdrop-filter: blur(40px) saturate(180%) !important;
  -webkit-backdrop-filter: blur(40px) saturate(180%) !important;
}
html[data-device="vision"] :is(.app-card, .ayuda-card):hover {
  transform: translateZ(20px) translateY(-4px) scale(1.02);
}

/* Phone Android */
html[data-device-frame="phone-android"] body {
  border-radius: 22px;
  box-shadow:
    0 0 0 6px #1a1a1a,
    0 0 0 8px #0a0a0a,
    0 30px 80px rgba(0, 0, 0, 0.6);
}
html[data-device-frame="phone-android"] body::before {
  /* punch-hole camera */
  content: "";
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  width: 12px;
  height: 12px;
  background: #000;
  border-radius: 50%;
  z-index: 9000;
}

/* Generic phone */
html[data-device-frame="phone-generic"] body { border-radius: 26px; }

/* Generic tablet */
html[data-device-frame="tablet-generic"] body { border-radius: 18px; }

/* Desktop frame — mac chrome */
html[data-device-frame="desktop"] body {
  border-radius: 12px;
  max-width: 1440px;
  width: min(1440px, 100%);
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.08),
    0 0 0 8px rgba(20, 20, 24, 0.7),
    0 50px 120px rgba(0, 0, 0, 0.5);
}
html[data-device-frame="desktop"] body::before {
  content: "";
  position: sticky;
  top: 0;
  left: 0;
  right: 0;
  height: 28px;
  background: linear-gradient(180deg, #2a2a2a, #1a1a1a);
  display: block;
  z-index: 9000;
}

/* ============================================================
   BROWSER-SPECIFIC TWEAKS — emulan diferencias visuales
   ============================================================ */
html[data-browser="safari"] :is(button, input, select, textarea) {
  -webkit-appearance: none;
  appearance: none;
}
html[data-browser="safari"] input[type="search"] { -webkit-appearance: textfield; }

html[data-browser="chrome"] :is(button, .filter-btn) {
  font-feature-settings: normal;
}

/* Chrome iOS sticky bottom URL bar simulation */
html[data-chrome="ios-chrome"] body::after,
html[data-chrome="android-chrome"] body::after {
  /* Override: Chrome shows its url bar at top, simulate via top reservation */
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .tlp-device-toggle-menu { animation: none; }
}

/* When body is in a small frame, hide bg canvas to avoid weird scaling */
html[data-device-frame] #bio-canvas { display: none; }

/* Print-safe */
@media print {
  .tlp-device-toggle { display: none !important; }
  html[data-device-frame] body {
    box-shadow: none;
    border-radius: 0;
    width: auto !important;
  }
}
