/* ── Editor Fullscreen Modal ─────────────────────────────────────────────────
   Shared overlay used by both the Python playground (Monaco) and the
   DataCamp Light exercise iframe widgets.
   ─────────────────────────────────────────────────────────────────────────── */

/* ── Variables ────────────────────────────────────────────────────────────── */
:root {
  --ef-backdrop:       rgba(0, 0, 0, 0.72);
  --ef-panel-bg:       var(--sl-color-gray-7, #0d1117);
  --ef-header-bg:      var(--sl-color-gray-6, #161b22);
  --ef-header-border:  color-mix(in srgb, var(--sl-color-gray-5, #30363d) 70%, transparent);
  --ef-title-color:    var(--sl-color-gray-1, #f0f6fc);
  --ef-btn-bg:         var(--sl-color-gray-6, #21262d);
  --ef-btn-hover:      var(--sl-color-gray-5, #30363d);
  --ef-btn-color:      var(--sl-color-gray-1, #c9d1d9);
  --ef-radius:         12px;
  --ef-header-h:       52px;
  --ef-anim:           240ms cubic-bezier(0.4, 0, 0.2, 1);
}

html[data-theme='light'] {
  --ef-backdrop:       rgba(0, 0, 0, 0.55);
  --ef-panel-bg:       #ffffff;
  --ef-header-bg:      #f6f8fa;
  --ef-header-border:  #d0d7de;
  --ef-title-color:    #1f2328;
  --ef-btn-bg:         #f6f8fa;
  --ef-btn-hover:      #eaeef2;
  --ef-btn-color:      #24292f;
}

/* ── Overlay ──────────────────────────────────────────────────────────────── */
.ef-overlay {
  position: fixed;
  inset: 0;
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  /* animation applied when shown */
}

.ef-overlay[hidden] {
  display: none !important;
}

/* ── Backdrop ─────────────────────────────────────────────────────────────── */
.ef-backdrop {
  position: absolute;
  inset: 0;
  background: var(--ef-backdrop);
  animation: ef-fade-in var(--ef-anim) forwards;
}

/* ── Panel ────────────────────────────────────────────────────────────────── */
.ef-panel {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  width: min(96vw, 1280px);
  height: 355px;
  background: var(--ef-panel-bg);
  border-radius: var(--ef-radius);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.55);
  overflow: hidden;
  animation: ef-slide-up var(--ef-anim) forwards;
}

/* ── Header ───────────────────────────────────────────────────────────────── */
.ef-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--ef-header-h);
  padding: 0 1rem;
  background: var(--ef-header-bg);
  border-bottom: 1px solid var(--ef-header-border);
  flex-shrink: 0;
  gap: 0.75rem;
}

.ef-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--ef-title-color);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  /* Override Starlight paragraph margin inside the header */
  margin: 0 !important;
}

/* ── Close button ─────────────────────────────────────────────────────────── */
.ef-close-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--ef-header-border);
  border-radius: 8px;
  background: var(--ef-btn-bg);
  color: var(--ef-btn-color);
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
  transition: background var(--ef-anim), color var(--ef-anim);
}

.ef-close-btn:hover {
  background: var(--ef-btn-hover);
  color: var(--ef-title-color);
}

.ef-close-btn svg {
  width: 18px;
  height: 18px;
}

/* ── Body ─────────────────────────────────────────────────────────────────── */
.ef-body {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  position: relative;
}

/* ── Monaco inside modal ──────────────────────────────────────────────────── */
.ef-body .py-playground {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0;
  margin: 0;
  padding: 0.75rem;
  overflow: hidden;
}

.ef-body .py-playground__cm {
  flex: 1;
  min-height: 0;
  height: 100% !important;  /* override JS-set height */
  border-radius: 0.5rem;
}

.ef-body .py-playground__output-wrap {
  flex-shrink: 0;
  max-height: 180px;
  overflow-y: auto;
}

/* ── DataCamp iframe inside modal ─────────────────────────────────────────── */
.ef-body .dcl-frame {
  flex: 1;
  width: 100%;
  height: 100%;
  min-height: 0;
  border: none;
  border-radius: 0;
}

.ef-body .datacamp-exercise-iframe {
  flex: 1;
  display: flex;
  flex-direction: column;
  margin: 0;
  height: 100%;
}

/* ── Fullscreen trigger buttons ───────────────────────────────────────────── */
/* Shared style for the ⛶ expand button added to both editor types */
.ef-expand-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: 1px solid var(--ef-header-border, rgba(125,125,125,0.3));
  border-radius: 7px;
  background: var(--ef-btn-bg, rgba(255,255,255,0.06));
  color: var(--ef-btn-color, inherit);
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
  transition: background 150ms, color 150ms;
}

.ef-expand-btn:hover {
  background: var(--ef-btn-hover, rgba(255,255,255,0.12));
}

.ef-expand-btn svg {
  width: 15px;
  height: 15px;
}

/* DCL wrapper: position the expand button in the top-right corner */
.datacamp-exercise-iframe {
  position: relative;
}

.datacamp-exercise-iframe .ef-expand-btn {
  position: absolute;
  top: 10px;
  right: 14px;
  z-index: 10;
  /* slightly larger for touch */
  width: 32px;
  height: 32px;
}

/* ── Animations ───────────────────────────────────────────────────────────── */
@keyframes ef-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes ef-slide-up {
  from { opacity: 0; transform: translateY(24px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0)    scale(1);    }
}

/* ── No content margin inside modal ──────────────────────────────────────── */
/* Starlight adds margin-top to consecutive block elements; kill it inside modal */
.ef-body * {
  margin-top: 0 !important;
}

/* ── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  .ef-panel {
    width: 100vw;
    height: 100dvh;
    border-radius: 0;
  }
}
