/* =========================================================================
   Can Temurbağa — Varyasyon switcher "shell" stilleri
   Tam-viewport iframe sahnesi + sağ-üst açılır pill switcher + crossfade
   ========================================================================= */

:root { color-scheme: light dark; }
* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: #0e1116;
  overflow: hidden;                 /* shell asla kaymaz; içerik iframe içinde kayar */
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
               Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* ---------- iframe sahnesi (crossfade ile yığılı) ---------- */
#stage {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100dvh;                   /* mobil Safari toolbar'ı için dvh */
}
#stage iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
  background: #ffffff;
  opacity: 0;
  z-index: 1;
  pointer-events: none;
  transition: opacity .30s ease;
}
#stage iframe.is-active {
  opacity: 1;
  z-index: 2;
  pointer-events: auto;
}

/* ---------- yükleniyor overlay'i ---------- */
#loader {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 16px;
  background: radial-gradient(900px 600px at 50% -5%, #1a2230 0%, #0e1116 65%);
  color: #e9edf2;
  transition: opacity .25s ease;
}
#loader.is-hidden { opacity: 0; pointer-events: none; }
.loader__spin {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 3px solid rgba(233, 237, 242, .16);
  border-top-color: #7c8cff;
  animation: vs-spin .8s linear infinite;
}
.loader__label {
  font-size: 13px;
  letter-spacing: .04em;
  color: #9aa6b2;
}
@keyframes vs-spin { to { transform: rotate(360deg); } }

/* ---------- switcher (açılır pill) ---------- */
#switcher {
  position: fixed;
  top: max(14px, env(safe-area-inset-top));
  right: max(16px, env(safe-area-inset-right));
  z-index: 2147483000;              /* iframe içeriğinin üstünde (farklı doküman) */
}

.vswitch__toggle {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  height: 40px;
  padding: 0 12px 0 14px;
  margin: 0;
  background: rgba(17, 19, 24, .92);
  -webkit-backdrop-filter: blur(10px) saturate(140%);
  backdrop-filter: blur(10px) saturate(140%);
  border: 1px solid rgba(255, 255, 255, .14);
  border-radius: 999px;
  color: #f1f3f7;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 10px 30px -12px rgba(0, 0, 0, .6);
  transition: border-color .2s ease, transform .15s ease, background .2s ease;
}
.vswitch__toggle:hover { border-color: rgba(255, 255, 255, .30); background: rgba(22, 25, 31, .94); }
.vswitch__toggle:active { transform: scale(.97); }
.vswitch__toggle:focus-visible { outline: 2px solid #7c8cff; outline-offset: 2px; }

.vswitch__dot {
  width: 9px; height: 9px;
  border-radius: 50%;
  background: #7c8cff;
  flex: none;
  box-shadow: 0 0 0 3px rgba(124, 140, 255, .18);
  transition: background .25s ease, box-shadow .25s ease;
}
.vswitch__icon { display: none; width: 19px; height: 19px; color: #f1f3f7; }
.vswitch__name { white-space: nowrap; }
.vswitch__chev { width: 13px; height: 13px; opacity: .7; transition: transform .2s ease; }
#switcher[data-open="true"] .vswitch__chev { transform: rotate(180deg); }

/* açılır liste */
.vswitch__list {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 226px;
  margin: 0;
  padding: 6px;
  list-style: none;
  background: rgba(20, 23, 29, .97);
  -webkit-backdrop-filter: blur(14px) saturate(150%);
  backdrop-filter: blur(14px) saturate(150%);
  border: 1px solid rgba(255, 255, 255, .12);
  border-radius: 14px;
  box-shadow: 0 24px 60px -20px rgba(0, 0, 0, .75);
  transform-origin: top right;
  transform: translateY(-6px) scale(.98);
  opacity: 0;
  pointer-events: none;
  transition: opacity .16s ease, transform .16s ease;
}
#switcher[data-open="true"] .vswitch__list {
  opacity: 1;
  transform: none;
  pointer-events: auto;
}

.vswitch__opt {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 11px;
  border-radius: 9px;
  color: #cdd4de;
  cursor: pointer;
  user-select: none;
  outline: none;
}
.vswitch__opt:hover,
.vswitch__opt:focus-visible { background: rgba(255, 255, 255, .07); color: #fff; }
.vswitch__opt[aria-selected="true"] { background: rgba(124, 140, 255, .16); color: #fff; }
.vswitch__optdot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.vswitch__opttext { display: flex; flex-direction: column; line-height: 1.25; }
.vswitch__optname { font-size: 13px; font-weight: 600; }
.vswitch__optsub { font-size: 11px; color: #8a93a3; }
.vswitch__check { margin-left: auto; width: 15px; height: 15px; color: #7c8cff; opacity: 0; flex: none; }
.vswitch__opt[aria-selected="true"] .vswitch__check { opacity: 1; }

/* ---------- mobil: kompakt FAB ---------- */
@media (max-width: 640px) {
  .vswitch__name, .vswitch__chev { display: none; }
  .vswitch__dot { display: none; }
  .vswitch__icon { display: block; }
  .vswitch__toggle {
    width: 46px;
    height: 46px;
    padding: 0;
    justify-content: center;
    gap: 0;
  }
  /* Top-anchored dropdown directly under the FAB. NOT bottom-anchored:
     on mobile the dynamic URL/tool bar shrinks the visible viewport, so a
     bottom-fixed list spills below the fold and its lower options become
     untappable (that was the bug). Anchoring under the FAB keeps the whole
     list in the always-visible top area; max-height + scroll is a safety net. */
  .vswitch__list {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    left: auto;
    bottom: auto;
    width: min(84vw, 300px);
    max-width: calc(100vw - 24px);
    max-height: calc(100dvh - 96px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
}

/* ---------- hareketi azalt ---------- */
@media (prefers-reduced-motion: reduce) {
  #stage iframe,
  #loader,
  .vswitch__list,
  .vswitch__chev,
  .vswitch__toggle { transition: none !important; }
  .loader__spin { animation-duration: 1.6s; }
}
