/* ================================
   RTCE — Ranjana Tripathi Carousel Engine (Scoped)
   Fonts are enqueued in shortcode: rtce-fonts
   Do NOT @import Google fonts here.
   ================================ */

.rtce-root{
  /* Brand palette */
  --rt-ivory:#F7F4FC;     /* Primary background */
  --rt-lilac:#F3CEDA;     /* Soft Lilac */
  --rt-plum:#5C3B87;      /* Deep Plum */
  --rt-charcoal:#3C3469;  /* Rich Charcoal (ink anchor) */
  --rt-gold:#C4A462;      /* Antique Gold (accent only) */

  /* UI neutrals */
  --md-outline: rgba(60,52,105,.22);
  --ink: var(--rt-charcoal);
  --ink2: rgba(60,52,105,.82);

  /* Dynamic accent (changes per slide) */
  --accent: var(--rt-plum);
  --accent-rgb: 92,59,135;

  /* Layout + effects */
  --r:22px;
  --r2:18px;
  --shadow:0 18px 55px rgba(15,23,42,.12);
  --shadow2:0 10px 26px rgba(15,23,42,.10);

  /* Typography system */
  --font-display: "Fraunces", ui-serif, Georgia, "Times New Roman", Times, serif;
  --font-body: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;

  --w-regular: 400;
  --w-medium: 500;
  --w-semibold: 600;
  --w-display: 500;

  --ls-tight: -0.02em;
  --ls-normal: 0;
  --ls-wide: 0.02em;

  --lh-solid: 1.08;
  --lh-title: 1.18;
  --lh-body: 1.65;
  --lh-tight: 1.42;

  --measure: 68ch;

  --fs-body: 16px;
  --fs-small: 13px;
  --fs-caption: 12px;

  /* Engine sizing */
  --rtce-maxh: 820px;
  --rtce-vh-offset: 220px;

  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;

  font-family: var(--font-body);
  color: var(--ink);
  line-height: 1.35;
  isolation: isolate;
}

.rtce-root, .rtce-root *{ box-sizing:border-box; }
.rtce-root img{ max-width:100%; height:auto; display:block; }

.rtce-root button,
.rtce-root input,
.rtce-root select,
.rtce-root textarea{
  font: inherit;
  color: var(--ink);
}

/* App backdrop */
.rtce-app{
  padding:20px;
  background:
    radial-gradient(1100px 600px at 12% 0%, rgba(243,206,218,.28), transparent 65%),
    radial-gradient(900px 520px at 96% 10%, rgba(92,59,135,.18), transparent 60%),
    radial-gradient(700px 420px at 70% 90%, rgba(196,164,98,.12), transparent 62%),
    linear-gradient(180deg, var(--rt-ivory), rgba(247,244,252,.72));
  border-radius: var(--r);
}

.rtce-card{
  background: rgba(255,255,255,.78);
  border: 1px solid rgba(17,24,39,.14);
  border-radius: var(--r);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

/* Top bar */
.rtce-top{
  padding:16px 18px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:14px;
  flex-wrap:wrap;
}

.rtce-brand{
  display:flex;
  align-items:center;
  gap:12px;
  min-width: 260px;
}

.rtce-mark{
  width:72px;
  height:72px;
  border-radius:14px;
  overflow:hidden;
  display:grid;
  place-items:center;
  background: rgba(255,255,255,.30);
  border:1px solid rgba(17,24,39,.12);
  box-shadow: var(--shadow2);
}

.rtce-logo{ width:86%; height:86%; object-fit:contain; display:block; }

.rtce-mark-fallback{
  display:none;
  width:100%;
  height:100%;
  align-items:center;
  justify-content:center;
  font-family: var(--font-display);
  font-weight:600;
  color:#fff;
  background: linear-gradient(135deg, var(--accent), rgba(196,164,98,.90));
}
.rtce-logo-missing .rtce-logo{ display:none; }
.rtce-logo-missing .rtce-mark-fallback{ display:flex; }

.rtce-title{
  font-family: var(--font-display);
  font-optical-sizing:auto;
  font-weight: var(--w-display);
  letter-spacing: -0.01em;
  font-size:19px;
}
.rtce-sub{
  font-size:11px;
  letter-spacing:.12em;
  text-transform:uppercase;
  color: var(--ink2);
  opacity:.9;
  margin-top:2px;
}

/* Actions */
.rtce-actions{
  display:flex;
  gap:10px;
  align-items:center;
  justify-content:flex-end;
  max-width:100%;
}

.rtce-btn{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  white-space:nowrap;
  border-radius:999px;
  padding:10px 14px;
  font-family: var(--font-body);
  font-weight:600;
  font-size:13px;
  border:1px solid rgba(17,24,39,.16);
  background: rgba(255,255,255,.84);
  cursor:pointer;
  transition: transform .08s ease, background .15s ease, box-shadow .15s ease;
}
.rtce-btn:hover{ background: rgba(255,255,255,.98); }
.rtce-btn:active{ transform: translateY(1px); }

.rtce-btn-primary{
  border:none;
  color:#fff;
  background: linear-gradient(135deg, var(--accent), rgba(60,52,105,.92));
  box-shadow: 0 18px 40px rgba(15,23,42,.16);
}

.rtce-btn-mini{ border-radius:14px; padding:9px 12px; }

@media (max-width:1100px){
  .rtce-actions{
    flex-wrap:nowrap;
    overflow-x:auto;
    padding-bottom:6px;
    -webkit-overflow-scrolling:touch;
  }
  .rtce-actions::-webkit-scrollbar{ height:6px; }
}

/* Main layout */
.rtce-main{
  margin-top:16px;
  display:grid;
  grid-template-columns: 420px 1fr;
  gap:16px;
  align-items:start;
}
@media (max-width:1100px){
  .rtce-main{ grid-template-columns:1fr; }
}

.rtce-panel, .rtce-preview{ padding:16px; min-height:0; }

/* Headers */
.rtce-panel-head, .rtce-preview-head{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
}
.rtce-h{
  font-size:12px;
  font-family: var(--font-body);
  font-weight:600;
  letter-spacing:.14em;
  text-transform:uppercase;
  color: var(--ink2);
}
.rtce-small{
  font-size:12px;
  color: var(--ink2);
  opacity:.9;
  margin-top:4px;
}
.rtce-mini-actions{ display:flex; gap:10px; align-items:center; flex-wrap:nowrap; }

/* Slide list */
.rtce-list{
  margin-top:12px;
  border-top:1px solid rgba(17,24,39,.12);
  padding-top:12px;
  max-height: 220px;
  overflow:auto;
  display:flex;
  flex-direction:column;
  gap:10px;
}

.rtce-item{
  display:flex;
  gap:12px;
  align-items:flex-start;
  padding:12px;
  border-radius:18px;
  border:1px solid rgba(17,24,39,.12);
  background: rgba(255,255,255,.74);
  cursor:pointer;
  transition: background .15s ease, border-color .15s ease, box-shadow .15s ease;
}
.rtce-item:hover{ background:#fff; }

.rtce-item.active{
  border-color: rgba(var(--accent-rgb), .35);
  background:#fff;
  box-shadow: 0 10px 22px rgba(17,24,39,.08);
}

.rtce-num{
  width:40px;
  height:40px;
  border-radius:16px;
  display:flex;
  align-items:center;
  justify-content:center;
  color:#fff;
  font-family: var(--font-body);
  font-weight:600;
  flex: 0 0 40px;
}

.rtce-item h4{
  margin:0;
  font-size:13px;
  font-family: var(--font-display);
  font-optical-sizing:auto;
  font-weight:600;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
  max-width:280px;
}
.rtce-item p{
  margin:4px 0 0;
  font-size:11px;
  color: var(--ink2);
  opacity:.9;
}

/* Editor */
.rtce-edit{ margin-top:14px; }
.rtce-grid2{ display:grid; grid-template-columns:1fr 1fr; gap:12px; }
@media (max-width:520px){ .rtce-grid2{ grid-template-columns:1fr; } }

.rtce-label{
  display:block;
  font-size:12px;
  font-family: var(--font-body);
  font-weight:600;
  margin:10px 0 6px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--ink2);
}

.rtce-input{
  width:100%;
  border-radius:14px;
  border:1px solid rgba(17,24,39,.14);
  background: rgba(255,255,255,.84);
  padding:10px 12px;
  outline:none;
  transition: box-shadow .15s ease, border-color .15s ease, background .15s ease;
}
.rtce-input:focus{
  box-shadow: 0 0 0 4px rgba(var(--accent-rgb), .18);
  border-color: rgba(var(--accent-rgb), .42);
  background:#fff;
}

.rtce-ta{ height:100px; resize:vertical; }
.rtce-ta-sm{ height:68px; resize:vertical; }

.rtce-tip{
  font-size:11px;
  color: var(--ink2);
  opacity:.85;
  margin-top:6px;
}

/* Accent controls */
.rtce-swatches{
  display:flex;
  gap:10px;
  align-items:center;
  flex-wrap:wrap;
  margin-top:10px;
}

.rtce-swatch{
  width:32px;
  height:32px;
  border-radius:999px;
  border: 2px solid rgba(255,255,255,.95);
  box-shadow: var(--shadow2);
  cursor:pointer;
  position:relative;
  padding:0;
}
.rtce-swatch:hover{ transform: translateY(-1px); }

.rtce-swatch:focus-visible{
  outline: 3px solid rgba(var(--accent-rgb), .30);
  outline-offset: 2px;
}
.rtce-swatch.is-active{
  outline: 3px solid rgba(17,24,39,.18);
  outline-offset: 2px;
}
.rtce-swatch.is-active::after{
  content:"";
  position:absolute;
  inset:7px;
  border-radius:999px;
  box-shadow: inset 0 0 0 2px rgba(255,255,255,.92);
  pointer-events:none;
}

.rtce-swatch-sep{
  width:1px;
  height:22px;
  background: rgba(17,24,39,.16);
  margin: 0 2px;
}

.rtce-color{
  width:36px;
  height:36px;
  border-radius:12px;
  border:1px solid rgba(17,24,39,.14);
  background:#fff;
  padding:2px;
  cursor:pointer;
}

/* Preview */
.rtce-preview{ display:flex; flex-direction:column; min-height:0; }

.rtce-preview-body{
  margin-top:12px;
  background: radial-gradient(700px 360px at 50% 0%, rgba(243,206,218,.18), transparent 70%);
  border-radius: calc(var(--r) - 6px);
  border: 1px dashed rgba(60,52,105,.22);
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  display:flex;
  justify-content:center;
  align-items:flex-start;
  padding: 16px;
  position:relative;
}
.rtce-scaler{ transform-origin: top center; will-change: transform; }

.rtce-footnote{
  margin-top:10px;
  border-top:1px solid rgba(17,24,39,.12);
  padding-top:10px;
  font-size:12px;
  color: var(--ink2);
  opacity:.9;
}

/* Modal */
.rtce-modal{
  position:fixed;
  inset:0;
  background: rgba(17,24,39,.55);
  z-index:999999;
  display:flex;
  align-items:center;
  justify-content:center;
  padding:16px;
}
.rtce-modal.hidden{ display:none; }

.rtce-modal-card{
  width:min(920px,94vw);
  max-height:92vh;
  overflow:hidden;
  padding:14px;
}

.rtce-modal-head{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  padding:6px 6px 10px;
  border-bottom:1px solid rgba(17,24,39,.12);
}

.rtce-json{
  width:100%;
  height:52vh;
  margin-top:12px;
  border-radius:14px;
  border:1px solid rgba(17,24,39,.14);
  padding:12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono","Courier New", monospace;
  font-size:12px;
  background:#fff;
}

.rtce-modal-actions{
  display:flex;
  justify-content:flex-end;
  gap:10px;
  margin-top:12px;
}

/* Export bucket */
.rtce-export{
  position:fixed;
  left:-20000px;
  top:0;
  opacity:.001;
  pointer-events:none;
}

/* Responsive stable height */
@media (max-width:1100px){
  .rtce-panel, .rtce-preview{ padding: 12px; }
  .rtce-list{ max-height: 170px; }
  .rtce-preview-body{ overflow:auto; }
}

@media (min-width:1101px){
  .rtce-panel, .rtce-preview{
    height: min(var(--rtce-maxh, 820px), calc(100dvh - var(--rtce-vh-offset, 220px)));
    overflow: hidden;
  }
  .rtce-panel{
    display:flex;
    flex-direction:column;
    min-height:0;
  }
  .rtce-list{ flex: 0 0 auto; }
  .rtce-edit{
    flex: 1 1 auto;
    min-height:0;
    overflow:auto;
    padding-right:6px;
  }
  .rtce-preview{ display:flex; flex-direction:column; min-height:0; }
  .rtce-preview-body{ flex: 1 1 auto; min-height:0; overflow:hidden; }
}
