/* ============================================================================
   retals · editor stylesheet
   paleta meowrhino studio · vanilla, forever
   ========================================================================== */

:root {
  /* paleta meowrhino */
  --coral:  #ef7d57;
  --amber:  #f5b840;
  --cream:  #fef8e6;
  --ink:    #1a1a1a;
  --paper:  #fafafa;
  --moss:   #5a6a3e;
  --ash:    #d4d4d0;

  /* funcionales */
  --r-bg:        var(--cream);
  --r-fg:        var(--ink);
  --r-accent:    var(--coral);
  --r-accent-2:  var(--amber);
  --r-border:    var(--ash);
  --r-muted:     #7a7a76;

  /* tipografía */
  --r-font:      'JetBrains Mono', 'Menlo', 'Consolas', monospace;
  --r-font-body: ui-sans-serif, system-ui, sans-serif;

  /* spacing */
  --r-gap:       1rem;
  --r-gap-lg:    2rem;
  --r-gap-xl:    4rem;

  /* otros */
  --r-radius:    0;
  --r-border-w:  1px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--r-bg);
  color: var(--r-fg);
  font-family: var(--r-font);
  font-size: 15px;
  line-height: 1.55;
}

a {
  color: var(--r-accent);
  text-decoration: underline;
  text-underline-offset: 3px;
}
a:hover { text-decoration: none; }

/* ========== header ========== */
.r-editor__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 2rem;
  border-bottom: 2px solid var(--ink);
  background: var(--paper);
}

.r-editor__brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
  color: var(--ink);
  font-weight: 700;
  font-size: 1.1rem;
}

.r-editor__mascot {
  image-rendering: pixelated;
}

.r-editor__nav {
  display: flex;
  gap: 1.5rem;
}
.r-editor__nav a {
  color: var(--ink);
  text-decoration: none;
}
.r-editor__nav a:hover {
  text-decoration: underline;
  text-decoration-color: var(--r-accent);
  text-decoration-thickness: 2px;
}

/* ========== hero ========== */
.r-hero {
  padding: 6rem 2rem 4rem;
  max-width: 900px;
  margin: 0 auto;
}

.r-hero h1 {
  font-size: clamp(2.5rem, 6vw, 4.5rem);
  line-height: 1.05;
  margin: 0 0 1.5rem;
  letter-spacing: -0.02em;
}

.r-hero__lead {
  font-size: clamp(1.1rem, 2vw, 1.4rem);
  color: var(--r-muted);
  margin: 0 0 2.5rem;
}

.r-hero__actions {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

/* ========== botones ========== */
.r-btn {
  display: inline-block;
  padding: 0.7rem 1.4rem;
  border: 2px solid var(--ink);
  background: var(--paper);
  color: var(--ink);
  font-family: var(--r-font);
  font-size: 1rem;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.1s ease, box-shadow 0.1s ease;
  box-shadow: 2px 2px 0 var(--ink);
}
.r-btn:hover {
  transform: translate(-1px, -1px);
  box-shadow: 3px 3px 0 var(--ink);
}
.r-btn:active {
  transform: translate(1px, 1px);
  box-shadow: 1px 1px 0 var(--ink);
}
.r-btn--primary {
  background: var(--r-accent);
  color: var(--ink);
}

/* ========== sections ========== */
.r-section {
  padding: 3rem 2rem;
  max-width: 900px;
  margin: 0 auto;
  border-top: 1px solid var(--r-border);
}

.r-section h2 {
  font-size: 1.4rem;
  margin: 2rem 0 1rem;
  letter-spacing: -0.01em;
}
.r-section h2:first-child { margin-top: 0; }

.r-section p {
  margin: 0 0 1rem;
}

.r-list {
  padding-left: 1.5rem;
  margin: 0 0 1.5rem;
}
.r-list li { margin-bottom: 0.5rem; }
.r-list--steps { list-style: decimal; }

.r-muted {
  color: var(--r-muted);
  font-style: italic;
}

/* ========== footer ========== */
.r-editor__footer {
  padding: 2rem;
  text-align: center;
  font-size: 0.85rem;
  color: var(--r-muted);
  border-top: 1px solid var(--r-border);
  margin-top: 4rem;
}

/* ============================================================================
   landing — cards de bloques y starters
   ========================================================================== */

.r-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1rem;
  margin: 1.5rem 0 0;
}

.r-card-block,
.r-card-starter {
  background: var(--paper);
  border: 2px solid var(--ink);
  padding: 0.85rem 1rem 0.6rem;
  box-shadow: 3px 3px 0 var(--amber);
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}
.r-card-block:hover,
.r-card-starter:hover {
  transform: translate(-1px, -1px);
  box-shadow: 4px 4px 0 var(--amber);
}

.r-card-block h3,
.r-card-starter h3 {
  margin: 0;
  font-size: 0.95rem;
  font-family: var(--r-font);
  font-weight: 700;
  letter-spacing: -0.01em;
}
.r-card-block p,
.r-card-starter p {
  margin: 0;
  font-size: 0.82rem;
  line-height: 1.45;
  color: var(--r-fg);
  flex: 1 1 auto;
}
.r-card-block code,
.r-card-starter code {
  background: rgba(0,0,0,0.06);
  padding: 0 0.2rem;
  font-size: 0.78rem;
}
.r-card-block footer,
.r-card-starter footer {
  display: flex;
  gap: 0.6rem;
  font-size: 0.78rem;
  margin-top: 0.25rem;
  padding-top: 0.4rem;
  border-top: 1px dashed var(--ash);
}

/* (los puntos de complexity 🟢/🟡 viven en el ROADMAP y en el editor —
   en la landing pública no aportan al visitante.) */

.r-card-starter {
  box-shadow: 3px 3px 0 var(--coral);
}
.r-card-starter:hover { box-shadow: 4px 4px 0 var(--coral); }
.r-card-starter h3 {
  font-size: 1.05rem;
  letter-spacing: 0.01em;
}

/* ============================================================================
   editor (split-view biblioteca · código · preview)
   ========================================================================== */

.r-editor-body {
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.r-editor__header--app {
  padding: 0.5rem 1rem;
  gap: 0.6rem;
  flex-wrap: wrap;
  flex: 0 0 auto;
}
.r-editor__header--app .r-editor__brand { font-size: 0.95rem; }

.r-editor__toolbar {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  align-items: center;
}

.r-btn--sm {
  padding: 0.35rem 0.7rem;
  font-size: 0.78rem;
  box-shadow: 1px 1px 0 var(--ink);
}
.r-btn--sm:hover  { box-shadow: 2px 2px 0 var(--ink); }
.r-btn--sm:active { box-shadow: 0 0 0 var(--ink); }
.r-btn--xs {
  padding: 0.15rem 0.45rem;
  font-size: 0.72rem;
  border-width: 1px;
  box-shadow: 1px 1px 0 var(--ink);
}

.r-editor__toolbar select {
  font: inherit;
  font-size: 0.78rem;
  margin-left: 0.25rem;
  background: transparent;
  border: 1px solid var(--ink);
  padding: 0.1rem;
}

/* tabs móviles (sólo visibles <700px) */
.r-editor__tabs {
  display: none;
  border-bottom: 2px solid var(--ink);
  background: var(--paper);
  flex: 0 0 auto;
}
.r-editor__tab {
  flex: 1 1 0;
  padding: 0.6rem 0.4rem;
  background: transparent;
  border: 0;
  border-right: 1px solid var(--ash);
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
  color: var(--r-muted);
}
.r-editor__tab:last-child { border-right: 0; }
.r-editor__tab--active {
  background: var(--cream);
  color: var(--ink);
  font-weight: 700;
}

/* layout principal: 3 paneles separados por splitters arrastrables.
   las anchuras se controlan via CSS vars que JS modifica al arrastrar.
   ocultar paneles → JS pone su variable a 0 y oculta el splitter precedente. */
.r-editor__app {
  flex: 1 1 auto;
  display: grid;
  grid-template-columns:
    var(--col-library, 240px)
    var(--col-splitter-1, 6px)
    var(--col-code, 1fr)
    var(--col-splitter-2, 6px)
    var(--col-preview, 1fr);
  min-height: 0;
}

.r-editor__panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  background: var(--paper);
}

/* splitters */
.r-editor__splitter {
  background: var(--ink);
  cursor: col-resize;
  position: relative;
  user-select: none;
}
.r-editor__splitter::after {
  content: '';
  position: absolute;
  inset: 0 -3px;
  background: transparent;
}
.r-editor__splitter:hover { background: var(--coral); }
.r-editor__splitter--dragging { background: var(--amber); }
.r-editor__splitter[hidden] { display: none; }
.r-editor__panel[hidden]    { display: none; }

.r-editor__panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--r-border);
  background: var(--cream);
  flex: 0 0 auto;
}
.r-editor__panel-head h2 {
  margin: 0;
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.r-editor__panel-head small {
  font-weight: 400;
  letter-spacing: 0;
  text-transform: none;
  color: var(--r-muted);
}
.r-editor__used {
  font-size: 0.72rem;
  color: var(--r-muted);
  font-family: var(--r-font);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 50%;
}

/* biblioteca */
.r-editor__panel--library #lib-search {
  font: inherit;
  font-size: 0.78rem;
  border: 1px solid var(--ink);
  background: var(--paper);
  padding: 0.2rem 0.4rem;
  width: 110px;
}
.r-editor__lib {
  list-style: none;
  margin: 0;
  padding: 0.5rem;
  overflow: auto;
  flex: 1 1 auto;
}
.r-editor__lib li {
  margin: 0 0 0.25rem;
}
.r-lib-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.5rem 0.6rem;
  background: var(--paper);
  border: 1px solid var(--ash);
  cursor: pointer;
  font: inherit;
  font-size: 0.8rem;
  color: var(--ink);
}
.r-lib-item:hover {
  border-color: var(--ink);
  background: var(--cream);
  box-shadow: 1px 1px 0 var(--ink);
}
.r-lib-item:focus-visible {
  outline: 2px solid var(--amber);
  outline-offset: 1px;
}
.r-lib-item strong {
  display: block;
  font-weight: 700;
  margin-bottom: 0.15rem;
}
.r-lib-item small {
  display: block;
  color: var(--r-muted);
  font-size: 0.72rem;
}
.r-lib-item[data-complexity="green"]  strong::after { content: ' 🟢'; }
.r-lib-item[data-complexity="yellow"] strong::after { content: ' 🟡'; }

.r-editor__hint {
  margin: 0;
  padding: 0.4rem 0.75rem 0.6rem;
  font-size: 0.7rem;
  color: var(--r-muted);
  border-top: 1px solid var(--r-border);
  flex: 0 0 auto;
}

/* código */
.r-editor__code {
  flex: 1 1 auto;
  width: 100%;
  resize: none;
  border: 0;
  outline: none;
  padding: 0.75rem;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--r-font);
  font-size: 13px;
  line-height: 1.5;
  tab-size: 2;
  white-space: pre;
  min-height: 0;
}
.r-editor__code:focus { background: var(--cream); }

/* preview */
.r-editor__preview {
  flex: 1 1 auto;
  width: 100%;
  border: 0;
  background: #fff;
  min-height: 0;
}

/* ============================================================================
   toggles + menú hamburger
   ========================================================================== */

.r-editor__view-toggles {
  display: inline-flex;
  gap: 0.2rem;
}
.r-toggle {
  min-width: 1.8rem;
  font-family: var(--r-font);
  background: var(--paper);
  color: var(--r-muted);
  opacity: 0.55;
}
.r-toggle--on {
  background: var(--amber);
  color: var(--ink);
  opacity: 1;
}

.r-menu { position: relative; }
.r-menu__panel {
  position: absolute;
  top: calc(100% + 0.35rem);
  right: 0;
  min-width: 220px;
  background: var(--paper);
  border: 2px solid var(--ink);
  box-shadow: 3px 3px 0 var(--ink);
  z-index: 50;
  padding: 0.3rem 0;
}
.r-menu__panel[hidden] { display: none; }
.r-menu__item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.4rem 0.85rem;
  background: transparent;
  border: 0;
  font: inherit;
  font-size: 0.82rem;
  cursor: pointer;
  color: var(--ink);
}
.r-menu__item:hover { background: var(--cream); }
.r-menu__sep {
  height: 1px;
  background: var(--ash);
  margin: 0.3rem 0;
}
.r-menu__group {
  padding: 0.4rem 0.85rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.78rem;
}
.r-menu__group small {
  color: var(--r-muted);
}
.r-menu__group select {
  flex: 1 1 auto;
  margin: 0;
}

/* ============================================================================
   inspector contextual (flota abajo-derecha del editor)
   ========================================================================== */

.r-editor__inspector {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  width: 280px;
  max-height: 60vh;
  background: var(--paper);
  border: 2px solid var(--ink);
  box-shadow: 3px 3px 0 var(--amber);
  z-index: 40;
  display: flex;
  flex-direction: column;
  font-size: 0.82rem;
}
.r-editor__inspector[hidden] { display: none; }
.r-editor__inspector-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.4rem 0.7rem;
  background: var(--amber);
  border-bottom: 1px solid var(--ink);
}
.r-editor__inspector-head strong { font-size: 0.82rem; }
.r-editor__inspector-head code {
  background: rgba(0,0,0,0.08);
  padding: 0 0.3rem;
  font-family: var(--r-font);
  font-size: 0.78rem;
}
.r-editor__inspector-body {
  padding: 0.6rem 0.75rem;
  overflow: auto;
  flex: 1 1 auto;
}
.r-ins-field {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin: 0 0 0.35rem;
}
.r-ins-field label {
  flex: 0 0 auto;
  min-width: 4.5rem;
  font-size: 0.78rem;
  color: var(--r-muted);
}
.r-ins-field input,
.r-ins-field select {
  flex: 1 1 auto;
  min-width: 0;
  font: inherit;
  font-size: 0.78rem;
  border: 1px solid var(--ash);
  background: var(--paper);
  padding: 0.15rem 0.3rem;
}
.r-ins-field input:focus,
.r-ins-field select:focus {
  outline: 2px solid var(--amber);
  outline-offset: 1px;
  border-color: var(--ink);
}

/* ============================================================================
   panel de assets (flota arriba-derecha del editor)
   ========================================================================== */

.r-editor__assets {
  position: fixed;
  top: 60px;
  right: 1rem;
  width: 280px;
  max-height: 60vh;
  background: var(--paper);
  border: 2px solid var(--ink);
  box-shadow: 3px 3px 0 var(--coral);
  z-index: 35;
  display: flex;
  flex-direction: column;
  font-size: 0.82rem;
}
.r-editor__assets[hidden] { display: none; }
.r-editor__assets-head {
  padding: 0.4rem 0.7rem;
  background: var(--coral);
  color: var(--ink);
  border-bottom: 1px solid var(--ink);
}
.r-editor__assets-head small {
  display: block;
  font-size: 0.7rem;
  font-weight: 400;
}
.r-editor__assets-list {
  list-style: none;
  margin: 0;
  padding: 0.4rem;
  overflow: auto;
}
.r-asset {
  display: grid;
  grid-template-columns: 48px 1fr auto;
  gap: 0.5rem;
  padding: 0.4rem;
  align-items: center;
  border-bottom: 1px dashed var(--ash);
}
.r-asset:last-child { border-bottom: 0; }
.r-asset__thumb {
  width: 48px; height: 48px;
  object-fit: cover;
  border: 1px solid var(--ash);
}
.r-asset__icon {
  width: 48px; height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--cream);
  border: 1px solid var(--ash);
  font-size: 1.2rem;
}
.r-asset__path {
  font-size: 0.75rem;
  word-break: break-all;
  background: rgba(0,0,0,0.04);
  padding: 0 0.25rem;
}
.r-asset__meta small {
  display: block;
  color: var(--r-muted);
  font-size: 0.68rem;
  margin-top: 0.15rem;
}
.r-asset__actions {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

/* drop target highlight */
.r-drop-target--active {
  outline: 3px dashed var(--coral) !important;
  outline-offset: -3px;
  background: rgba(239,125,87,0.06) !important;
}

/* ============================================================================
   modal de media (comprimir imágenes/video con imgToWeb embebido)
   ========================================================================== */

.r-media-modal {
  position: fixed;
  inset: 0;
  background: rgba(26,26,26,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1100;
  padding: 1rem;
}
.r-media-modal[hidden] { display: none; }
.r-media-modal__card {
  background: var(--paper);
  border: 2px solid var(--ink);
  box-shadow: 5px 5px 0 var(--coral);
  width: 100%;
  max-width: 1200px;
  height: 90vh;
  display: flex;
  flex-direction: column;
}
.r-media-modal__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0.85rem;
  border-bottom: 2px solid var(--ink);
  background: var(--cream);
}
.r-media-modal__head strong { font-size: 0.95rem; }
.r-media-modal__body {
  flex: 1 1 auto;
  display: grid;
  grid-template-columns: 1fr 320px;
  min-height: 0;
}
.r-media-modal__iframe {
  width: 100%;
  height: 100%;
  border: 0;
  border-right: 2px solid var(--ink);
  background: #fff;
}
.r-media-modal__side {
  display: flex;
  flex-direction: column;
  padding: 0.75rem;
  gap: 0.75rem;
  overflow: auto;
  background: var(--cream);
}
.r-drop-zone {
  flex: 0 0 auto;
  min-height: 130px;
  border: 2px dashed var(--coral);
  background: var(--paper);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  text-align: center;
  gap: 0.3rem;
  font-size: 0.82rem;
}
.r-drop-zone strong { color: var(--coral); }
.r-drop-zone small { color: var(--r-muted); font-size: 0.72rem; }
.r-media-modal__help {
  font-size: 0.78rem;
  line-height: 1.55;
  margin: 0;
  color: var(--ink);
}
.r-media-modal__help em { font-style: normal; background: var(--amber); padding: 0 0.25rem; }
@media (max-width: 800px) {
  .r-media-modal__body { grid-template-columns: 1fr; }
  .r-media-modal__iframe { border-right: 0; border-bottom: 2px solid var(--ink); height: 60vh; }
}

/* ============================================================================
   modal genérico
   ========================================================================== */

.r-editor__modal {
  position: fixed;
  inset: 0;
  background: rgba(26,26,26,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1.5rem;
}
.r-editor__modal[hidden] { display: none; }
.r-editor__modal-card {
  background: var(--paper);
  border: 2px solid var(--ink);
  box-shadow: 4px 4px 0 var(--amber);
  padding: 1.25rem 1.5rem;
  max-width: 520px;
  width: 100%;
}
.r-editor__modal-card h3 {
  margin: 0 0 0.5rem;
  font-size: 1rem;
}
.r-editor__modal-card #modal-body {
  font-size: 0.85rem;
  margin: 0 0 1rem;
}
.r-editor__modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

/* ============================================================================
   modal de preview de bloque (landing)
   ========================================================================== */

.r-block-modal {
  position: fixed;
  inset: 0;
  background: rgba(26,26,26,0.78);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}
.r-block-modal[hidden] { display: none; }
.r-block-modal__card {
  background: var(--paper);
  border: 2px solid var(--ink);
  box-shadow: 5px 5px 0 var(--coral);
  width: 100%;
  max-width: 880px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}
.r-block-modal__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 1rem;
  border-bottom: 2px solid var(--ink);
  background: var(--cream);
}
.r-block-modal__head h3 {
  margin: 0;
  font-size: 0.95rem;
  font-family: var(--r-font);
}
.r-block-modal__body {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  flex: 1 1 auto;
  min-height: 0;
}
.r-block-modal__live {
  padding: 1.25rem;
  overflow: auto;
  border-right: 2px solid var(--ink);
  background: var(--cream);
  position: relative;     /* ancla para r-window y otros position:absolute */
  min-height: 280px;
}
/* dentro del modal: que r-window no se vaya a (40,40) del viewport */
.r-block-modal__live r-window.r-window--ready {
  left: 1rem !important;
  top: 1rem !important;
  position: absolute;
}
.r-block-modal__code {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.r-block-modal__code header {
  padding: 0.4rem 0.75rem;
  font-size: 0.75rem;
  color: var(--r-muted);
  border-bottom: 1px solid var(--ash);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.r-block-modal__code pre {
  margin: 0;
  padding: 0.75rem 1rem;
  background: var(--ink);
  color: var(--cream);
  font-family: var(--r-font);
  font-size: 0.78rem;
  line-height: 1.5;
  overflow: auto;
  flex: 1 1 auto;
  white-space: pre;
}
.r-block-modal__copied {
  color: var(--amber);
  font-size: 0.72rem;
}
@media (max-width: 700px) {
  .r-block-modal__body { grid-template-columns: 1fr; }
  .r-block-modal__live { border-right: 0; border-bottom: 2px solid var(--ink); }
  .r-block-modal { padding: 0.5rem; }
}

/* ============================================================================
   responsive
   ========================================================================== */

@media (max-width: 700px) {
  .r-editor__header {
    flex-direction: column;
    gap: 1rem;
    padding: 1rem;
  }
  .r-hero { padding: 3rem 1rem 2rem; }
  .r-section { padding: 2rem 1rem; }

  /* editor en móvil: tabs en vez de tres columnas */
  .r-editor__header--app {
    flex-direction: row;
    align-items: flex-start;
    gap: 0.5rem;
    padding: 0.5rem 0.6rem;
  }
  .r-editor__tabs { display: flex; }
  .r-editor__app {
    grid-template-columns: 1fr;
  }
  .r-editor__panel { display: none; border-right: 0; }
  .r-editor__panel--active { display: flex; }
}

