/* Interfaz de controles: HTML nativo, accesible y táctil. El lienzo
   (Canvas 2D) es exclusivamente el motor de composición/exportación; toda
   esta hoja de estilos es la que gobierna la interfaz alrededor de él. */

:root {
  --verde: #205C5B;
  --verde-profundo: #153F3E;
  --crema: #F4F0EB;
  --aqua: #93E1D8;
  --coral: #FF938C;
  --dorado: #E5B55D;

  --ui-bg: var(--crema);
  --ui-text: var(--verde-profundo);
  --ui-border: #D8D0C2;
  --touch-min: 48px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--ui-bg);
  color: var(--ui-text);
  font-family: 'DM Sans', -apple-system, sans-serif;
  /* Evita el "bounce" y el gesto de refresco accidental de Safari al
     interactuar con el lienzo; el scroll normal de la página sigue
     funcionando porque solo el overlay de encuadre bloquea touch-action. */
  overscroll-behavior-y: none;
}

#app {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.app-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--ui-border);
  display: flex;
  align-items: baseline;
  gap: 16px;
  flex-wrap: wrap;
}

.brand {
  font-family: 'Fraunces', serif;
  font-size: 22px;
  color: var(--verde);
}
.brand-astro { font-weight: 600; }
.brand-cami { font-style: italic; font-weight: 500; }
.brand-moon {
  display: inline-block;
  margin-left: 3px;
  vertical-align: -1px;
}

.privacy-note {
  margin: 0;
  font-size: 13px;
  color: var(--verde);
  opacity: 0.85;
}

.layout {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.controls {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  overflow-y: auto;
}

.control-group {
  border: 1px solid var(--ui-border);
  border-radius: 14px;
  padding: 12px;
  margin: 0;
}

.control-group legend {
  font-family: 'DM Sans', sans-serif;
  font-weight: 600;
  font-size: 13px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--verde);
  padding: 0 6px;
}

.button-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.button-grid button,
.button-row button {
  min-height: var(--touch-min);
  padding: 10px 16px;
  border-radius: 10px;
  border: 1.5px solid var(--verde);
  background: transparent;
  color: var(--verde);
  font-family: 'DM Sans', sans-serif;
  font-weight: 500;
  font-size: 15px;
  cursor: pointer;
  touch-action: manipulation;
}

.button-grid button[aria-pressed="true"] {
  background: var(--verde);
  color: var(--crema);
}

.button-grid button:disabled,
.button-row button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

textarea, input[type="text"] {
  width: 100%;
  font-family: 'DM Sans', sans-serif;
  font-size: 16px; /* >=16px evita el auto-zoom de Safari al enfocar */
  padding: 10px;
  border-radius: 10px;
  border: 1.5px solid var(--ui-border);
  resize: vertical;
  background: #fff;
  color: var(--ui-text);
}

.zoom-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 10px 0;
}
.zoom-row input[type="range"] {
  flex: 1;
  height: var(--touch-min);
}

.hint {
  font-size: 13px;
  color: var(--verde);
  opacity: 0.75;
  margin: 8px 0 0;
}

[data-visible-for] { display: none; }
[data-visible-for].is-visible { display: block; }

.canvas-area {
  padding: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  overflow-y: auto;
  min-height: 0; /* permite que overflow-y:auto funcione cuando .canvas-area se estira dentro de .layout */
}

/* Ninguno de los bloques de esta columna debe achicarse para "entrar":
   si el contenido no cabe en la altura disponible, .canvas-area debe
   scrollear (overflow-y: auto arriba), nunca comprimir el lienzo. */
.canvas-area > * {
  flex-shrink: 0;
}

.canvas-wrapper {
  position: relative;
  width: 100%;
  max-width: 420px;
  background: #fff;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 4px 24px rgba(21, 63, 62, 0.15);
  touch-action: pan-y; /* el overlay de encuadre restringe esto solo sobre la foto */
}

#mainCanvas {
  display: block;
  width: 100%;
  height: auto;
}

.photo-overlay {
  position: absolute;
  touch-action: none; /* único elemento donde se bloquea el gesto de scroll: el área de reencuadre */
  cursor: grab;
}

.warning {
  width: 100%;
  max-width: 420px;
  background: var(--coral);
  color: var(--verde-profundo);
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
}

.crop-previews {
  display: flex;
  gap: 12px;
  width: 100%;
  max-width: 420px;
  justify-content: center;
}

.crop-preview {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-width: 0;
}

.crop-preview canvas {
  width: 100%;
  height: auto;
  border-radius: 8px;
  border: 1px solid var(--ui-border);
  background: #fff;
}

.crop-preview span {
  font-size: 11px;
  color: var(--verde);
  opacity: 0.8;
  text-align: center;
}

.carousel-thumbs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  width: 100%;
  max-width: 420px;
  padding-bottom: 4px;
}

.carousel-thumbs .thumb {
  flex: 0 0 auto;
  width: 64px;
  border-radius: 8px;
  border: 2px solid transparent;
  overflow: hidden;
  cursor: pointer;
  background: #fff;
}
.carousel-thumbs .thumb.is-active { border-color: var(--dorado); }
.carousel-thumbs .thumb canvas { width: 100%; height: auto; display: block; }

.export-actions {
  display: flex;
  gap: 10px;
  width: 100%;
  max-width: 420px;
}

.export-actions button {
  flex: 1;
  min-height: var(--touch-min);
  border-radius: 10px;
  border: none;
  background: var(--verde);
  color: var(--crema);
  font-family: 'DM Sans', sans-serif;
  font-weight: 600;
  font-size: 15px;
  cursor: pointer;
}
.export-actions button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* Lista de diapositivas del carrusel */
.slide-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 10px;
}

.slide-card {
  border: 1.5px solid var(--ui-border);
  border-radius: 12px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.slide-card.is-active {
  border-color: var(--dorado);
  background: rgba(229, 181, 93, 0.08);
}

.slide-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--verde);
}

.slide-card-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.slide-card-actions button {
  min-height: 36px;
  padding: 4px 10px;
  font-size: 13px;
  border-radius: 8px;
  border: 1px solid var(--verde);
  background: transparent;
  color: var(--verde);
}
.slide-card-actions button:disabled { opacity: 0.35; }

.slide-card textarea, .slide-card input[type="text"] {
  font-size: 15px;
  padding: 8px;
}

/* Layout ancho: iPad horizontal / escritorio -> controles a la izquierda */
@media (min-width: 860px) {
  .layout {
    flex-direction: row;
  }
  .controls {
    width: 380px;
    flex: 0 0 380px;
    border-right: 1px solid var(--ui-border);
    max-height: calc(100dvh - 64px);
  }
  .canvas-area {
    flex: 1;
    max-height: calc(100dvh - 64px);
  }
}
