/* ===========================================================================
   MAK Website Viewer
   Self-contained, lightweight UI. All rules are scoped under .mak-viewer*
   so nothing leaks into the host theme. System fonts only — no web fonts.
   =========================================================================== */

#mak-viewer {
  /* Design tokens (scoped) */
  --v-accent:      #2563eb;
  --v-accent-soft: #eff6ff;
  --v-bg:          #ffffff;
  --v-stage:       #eef0f3;
  --v-border:      #e5e7eb;
  --v-text:        #1f2937;
  --v-muted:       #6b7280;
  --v-shadow-sm:   0 2px 8px rgba(17, 24, 39, .12);
  --v-shadow-lg:   0 18px 50px rgba(17, 24, 39, .22);
  --v-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

#mak-viewer[hidden] { display: none !important; }

#mak-viewer *,
#mak-viewer *::before,
#mak-viewer *::after { box-sizing: border-box; }

/* Lock background scroll while the viewer is open */
html.mak-viewer-lock,
html.mak-viewer-lock body { overflow: hidden !important; }

/* ── Overlay ──────────────────────────────────────────────────────────── */
.mak-viewer-overlay {
  position: fixed;
  inset: 0;
  z-index: 100000;
  display: flex;
  flex-direction: column;
  font-family: var(--v-font);
  color: var(--v-text);
  background: var(--v-stage);
}
.mak-viewer-overlay[hidden] { display: none !important; }

/* ── Top toolbar ──────────────────────────────────────────────────────── */
.mak-viewer-bar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 16px;
  background: var(--v-bg);
  border-bottom: 1px solid var(--v-border);
  box-shadow: 0 1px 0 rgba(17, 24, 39, .03);
}

.mak-viewer-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 700;
  color: var(--v-text);
  white-space: nowrap;
}
.mak-viewer-brand svg { width: 18px; height: 18px; color: var(--v-accent); }

/* Segmented device switch */
.mak-viewer-seg {
  display: flex;
  gap: 2px;
  padding: 3px;
  background: var(--v-stage);
  border-radius: 10px;
}
.mak-viewer-seg-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin: 0;
  padding: 7px 13px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  line-height: 1;
  color: var(--v-muted);
  background: transparent;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  transition: color .12s ease, background .12s ease, box-shadow .12s ease;
}
.mak-viewer-seg-btn svg { width: 17px; height: 17px; display: block; }
.mak-viewer-seg-btn:hover { color: var(--v-text); }
.mak-viewer-seg-btn.is-active {
  color: var(--v-accent);
  background: var(--v-bg);
  box-shadow: var(--v-shadow-sm);
}
.mak-viewer-seg-btn:focus-visible {
  outline: 2px solid var(--v-accent);
  outline-offset: 1px;
}

/* Dimensions / zoom readout */
.mak-viewer-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--v-muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.mak-viewer-sep { opacity: .5; }

/* Tool buttons pushed to the far right */
.mak-viewer-tools {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
}
.mak-viewer-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 34px;
  margin: 0;
  padding: 0 12px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--v-muted);
  background: transparent;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  transition: color .12s ease, background .12s ease;
}
.mak-viewer-icon-btn svg { width: 18px; height: 18px; display: block; }
.mak-viewer-icon-btn span { white-space: nowrap; }
.mak-viewer-icon-btn:hover { color: var(--v-text); background: var(--v-stage); }
.mak-viewer-icon-btn.is-active { color: var(--v-accent); background: var(--v-accent-soft); }
.mak-viewer-icon-btn:disabled {
  opacity: .4;
  cursor: default;
  pointer-events: none;
}
.mak-viewer-icon-btn:focus-visible {
  outline: 2px solid var(--v-accent);
  outline-offset: 1px;
}

/* ── Stage + device frame ─────────────────────────────────────────────── */
.mak-viewer-stage {
  flex: 1 1 auto;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background:
    radial-gradient(circle at center, rgba(17, 24, 39, .035) 1px, transparent 1px) 0 0 / 22px 22px,
    var(--v-stage);
}

.mak-viewer-scaler {
  position: relative;
  transition: width .22s ease, height .22s ease;
}

.mak-viewer-device {
  position: absolute;
  top: 0;
  left: 0;
  transform-origin: top left;
  display: flex;
  flex-direction: column;
  background: var(--v-bg);
  border: 1px solid var(--v-border);
  border-radius: 14px;
  box-shadow: var(--v-shadow-lg);
  overflow: hidden;
}

.mak-viewer-titlebar {
  flex: 0 0 auto;
  height: 34px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  background: #f9fafb;
  border-bottom: 1px solid var(--v-border);
}
.mak-viewer-dots { display: flex; gap: 6px; flex: 0 0 auto; }
.mak-viewer-dots i {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #d1d5db;
}
.mak-viewer-addr {
  font-size: 12px;
  font-weight: 500;
  color: var(--v-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Wide / fluid view — fills the stage edge-to-edge, no chrome */
.mak-viewer-device.is-fluid {
  border: 0;
  border-radius: 0;
  box-shadow: none;
}
.mak-viewer-device.is-fluid .mak-viewer-titlebar { display: none; }

.mak-viewer-screen {
  flex: 0 0 auto;
  width: 100%;
  background: var(--v-bg);
}
.mak-viewer-iframe {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  background: var(--v-bg);
}

/* ── Compact layout for narrow screens ────────────────────────────────── */
@media (max-width: 720px) {
  .mak-viewer-bar { gap: 10px; padding: 9px 12px; }
  .mak-viewer-brand span,
  .mak-viewer-seg-btn span,
  .mak-viewer-icon-btn span,
  .mak-viewer-meta { display: none; }
  .mak-viewer-seg-btn { padding: 7px 10px; }
  .mak-viewer-icon-btn { padding: 0 9px; }
}

@media (prefers-reduced-motion: reduce) {
  .mak-viewer-scaler { transition: none; }
}
