/* Hosted preview: sdlauncher nav + launcher-sized window frame */

:root {
  --preview-ribbon-accent: #ff3e5e;
  --launcher-window-width: min(1320px, calc(100vw - 36px));
  --launcher-window-height: min(840px, calc(100vh - 168px));
  --preview-pip-width: min(1020px, calc(100vw - 36px));
  --preview-pip-height: min(620px, calc(100vh - 160px));
}

html.hosted-preview {
  height: auto;
}

body.hosted-preview-body {
  position: relative;
  height: auto;
  min-height: 100vh;
  overflow-x: clip;
  overflow-y: auto;
  margin: 0;
  font-family: ui-sans-serif, system-ui, Segoe UI, sans-serif;
}

.preview-site-root {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  position: relative;
  z-index: 1;
  transition:
    filter 0.22s ease,
    opacity 0.22s ease;
}

.preview-site-root.launcher-main-dimmed {
  filter: brightness(0.55) saturate(0.92);
  opacity: 0.92;
}

.preview-site-root .site-header.site-header--preview {
  position: sticky;
  top: 12px;
  z-index: 30;
}

.preview-launcher-dock {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: clamp(12px, 2.8vw, 28px);
  gap: 12px;
}

.hosted-preview-ribbon {
  width: var(--launcher-window-width);
  max-width: 100%;
  box-sizing: border-box;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(12, 14, 20, 0.92);
  color: #c8cdd8;
  font-size: 12px;
  line-height: 1.45;
  backdrop-filter: blur(14px);
}

.hosted-preview-ribbon__note {
  margin: 0;
  max-width: 48rem;
  min-width: 0;
}

.hosted-preview-ribbon strong {
  color: var(--preview-ribbon-accent);
  font-weight: 700;
}

.hosted-preview-ribbon a {
  color: rgba(238, 242, 250, 0.92);
  font-weight: 600;
}

.hosted-preview-ribbon nav {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}

.hosted-preview-ribbon nav a {
  color: rgba(232, 237, 244, 0.88);
  text-decoration: none;
}

.hosted-preview-ribbon nav a:hover {
  color: #fff;
  text-decoration: underline;
}

.hosted-preview-ribbon__home {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  padding: 0 12px;
  border-radius: 8px;
  border: 1px solid rgba(255, 62, 94, 0.45);
  background: rgba(255, 62, 94, 0.12);
  font-weight: 700;
}

.hosted-preview-ribbon__home:hover {
  background: rgba(255, 62, 94, 0.2);
}

/* ── In-iframe toolbar (?embed=1) ─────────────────────────── */
.preview-embed-bar {
  position: sticky;
  top: 0;
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 8px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: linear-gradient(180deg, #14151e, #101119);
}

.preview-embed-return-btn {
  height: auto;
  min-height: 32px;
  padding: 0 14px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: var(--preview-ribbon-accent);
  color: #fff !important;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(255, 62, 94, 0.25);
}

.preview-embed-return-btn:hover {
  filter: brightness(1.06);
}

/* ── PIP iframe layer (same tab as main launcher) ───────────── */
.preview-pip-overlay {
  position: fixed;
  inset: 0;
  z-index: 120;
  padding: clamp(64px, 10vh, 100px) 16px 32px;
  box-sizing: border-box;
}

.preview-pip-overlay.hidden {
  display: none !important;
}

.preview-pip-backdrop {
  position: absolute;
  inset: 0;
  padding: 0;
  margin: 0;
  border: none;
  background: rgba(4, 6, 12, 0.52);
  backdrop-filter: blur(7px);
  cursor: default;
}

.preview-pip-shell {
  position: relative;
  z-index: 1;
  margin: 0 auto;
  width: var(--preview-pip-width);
  max-width: 100%;
  max-height: var(--preview-pip-height);
  display: flex;
  flex-direction: column;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: linear-gradient(180deg, rgba(26, 28, 36, 0.98), #12141c);
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.45),
    0 34px 80px rgba(0, 0, 0, 0.62);
  overflow: hidden;
}

.preview-pip-head {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}

.preview-pip-label {
  font-size: 12px;
  font-weight: 700;
  color: rgba(240, 242, 247, 0.9);
}

.preview-pip-close {
  margin-left: auto;
  min-height: 30px;
  padding: 0 12px;
  border-radius: 8px;
  border: 1px solid rgba(255, 62, 94, 0.45);
  background: rgba(255, 62, 94, 0.16);
  color: rgba(253, 230, 236, 0.96);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.preview-pip-close:hover {
  background: rgba(255, 62, 94, 0.26);
}

.preview-pip-frame {
  flex: 1;
  min-height: min(560px, 64vh);
  width: 100%;
  border: none;
  display: block;
  background: #0f0f12;
}

.launcher-window-shell {
  width: var(--launcher-window-width);
  height: var(--launcher-window-height);
  max-width: 100%;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(6, 7, 10, 0.65);
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.55),
    0 36px 100px rgba(0, 0, 0, 0.55),
    inset 0 1px 0 rgba(255, 255, 255, 0.05);
  overflow: hidden;
}

.launcher-window-titlebar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  height: 36px;
  padding: 0 12px 0 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  background: linear-gradient(180deg, #1a1b22 0%, #14151c 100%);
  cursor: default;
  user-select: none;
}

.launcher-window-title-group {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.launcher-window-title-dot {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  background: linear-gradient(145deg, var(--preview-ribbon-accent), #be123c);
  flex-shrink: 0;
}

.launcher-window-title-text {
  font-size: 12px;
  font-weight: 700;
  color: rgba(240, 242, 247, 0.85);
  letter-spacing: -0.02em;
}

.launcher-window-controls {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.launcher-window-control {
  display: inline-block;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
}

.launcher-window-control--min {
  width: 14px;
  height: 2px;
  border-radius: 1px;
  margin-bottom: -4px;
}

.launcher-window-control--max {
  width: 12px;
  height: 10px;
  border-radius: 2px;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.22);
}

.launcher-window-control--close {
  width: 12px;
  height: 12px;
  background: #ff5353;
  opacity: 0.85;
}

.launcher-window-body-inner {
  flex: 1;
  min-height: 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #0f0f12;
}

.launcher-window-body-inner > .app {
  flex: 1;
  min-height: 0;
  height: 100%;
  max-height: 100%;
}

.launcher-window-body-inner > .createInstanceApp,
.launcher-window-body-inner > .serversBrowseRoot,
.launcher-window-body-inner > .modpackBrowseRoot,
.launcher-window-body-inner > .browseApp,
.launcher-window-body-inner > .layout {
  flex: 1;
  min-height: 0;
  height: 100%;
  max-height: 100%;
  overflow: auto;
}

@media (max-width: 760px) {
  :root {
    --launcher-window-height: min(88vh, 840px);
    --preview-pip-height: min(82vh, 620px);
  }

  .launcher-window-shell {
    border-radius: 8px;
  }

  .preview-pip-shell {
    border-radius: 10px;
  }
}
