/* Paleta del evento: verde del marco, naranja AWS y el azul Squid Ink. */
:root {
  --green: #135e43;
  --green-deep: #111d18;
  --ink: #0d1a14;
  --orange: #ff9900;
  --line: rgba(255, 255, 255, 0.18);
  --panel: rgba(255, 255, 255, 0.06);
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

/* El display de una clase (.pick, .controls, .result…) le gana al display:none
   que el navegador aplica por el atributo hidden, porque las reglas de autor
   siempre pesan más que las del user agent. Sin esto el atributo no oculta
   nada: el botón de subir foto queda tapando el lienzo y los controles de
   encuadre se ven desde el arranque. */
[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  padding: 36px 20px 64px;
  background: radial-gradient(120% 90% at 50% 0%, var(--green) 0%, var(--ink) 62%);
  color: #fff;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  line-height: 1.5;
}

main {
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* --- Cabecera --- */

header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  text-align: center;
}

.brand {
  width: min(300px, 72%);
  height: auto;
}

h1 {
  margin: 0;
  font-size: clamp(1.5rem, 5vw, 1.9rem);
  font-weight: 600;
}

.tagline {
  margin: 0;
  max-width: 34ch;
  font-size: 0.9rem;
  opacity: 0.7;
}

/* --- Selectores --- */

form {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.picks {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.field {
  flex: 1 1 160px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.9rem;
}

.field span {
  opacity: 0.75;
  white-space: nowrap;
}

.field select,
.field input[type="range"] {
  flex: 1;
  min-width: 0;
  accent-color: var(--orange);
}

.field select {
  padding: 10px 12px;
  border: 0;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  font: inherit;
  cursor: pointer;
}

.field select option {
  background: var(--green-deep);
  color: #fff;
}

/* --- Escenario: la vista previa es también la zona de subida --- */

.stage {
  position: relative;
  align-self: center;
  width: min(340px, 100%);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.45);
  transition: box-shadow 0.18s;
}

.stage.over {
  box-shadow: 0 0 0 3px var(--orange), 0 14px 36px rgba(0, 0, 0, 0.45);
}

#preview {
  display: block;
  width: 100%;
  height: auto;
  touch-action: none; /* si no, el arrastre desplaza la página en celular */
}

#preview.draggable {
  cursor: grab;
}

#preview.draggable:active {
  cursor: grabbing;
}

.pick {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: rgba(10, 15, 20, 0);
  color: #fff;
  font: inherit;
  text-align: center;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.18s, background 0.18s;
}

.pick strong {
  font-size: 1.05rem;
}

.pick small {
  opacity: 0.75;
}

/* En touch no hay hover, así que ahí se muestra siempre y de forma sutil. */
@media (hover: hover) {
  .stage:hover .pick,
  .pick:focus-visible {
    opacity: 1;
    background: rgba(10, 15, 20, 0.62);
  }
}

@media (hover: none) {
  .pick {
    opacity: 1;
    inset: auto 0 0 0;
    height: auto;
    padding: 14px;
    background: rgba(10, 15, 20, 0.62);
  }
}

.clear {
  position: absolute;
  top: 10px;
  right: 10px;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: rgba(10, 15, 20, 0.6);
  color: #fff;
  cursor: pointer;
}

.clear:hover {
  background: rgba(10, 15, 20, 0.85);
}

.clear svg {
  width: 16px;
  height: 16px;
}

/* --- Controles de encuadre --- */

.controls {
  align-self: center;
  width: min(340px, 100%);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.mode {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.link {
  padding: 0;
  border: 0;
  background: none;
  color: var(--orange);
  font: inherit;
  font-size: 0.86rem;
  text-decoration: underline;
  cursor: pointer;
}

.hint {
  margin: 0;
  font-size: 0.85rem;
  opacity: 0.65;
}

.hint.center {
  text-align: center;
}

/* --- Botones --- */

button,
.btn {
  padding: 14px 24px;
  border: 0;
  border-radius: 999px;
  background: var(--orange);
  color: #111;
  font: inherit;
  font-weight: 600;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
}

button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn.ghost {
  background: transparent;
  color: #fff;
  box-shadow: inset 0 0 0 2px var(--line);
}

.status {
  margin: 0;
  min-height: 1.5em;
  text-align: center;
  opacity: 0.8;
}

.status.error {
  color: #ffb4a2;
  opacity: 1;
}

/* --- Resultado --- */

.warnings {
  margin: 0;
  padding: 14px 18px 14px 34px;
  border-radius: 12px;
  border-left: 3px solid var(--orange);
  background: rgba(255, 153, 0, 0.1);
  font-size: 0.92rem;
}

.warnings li + li {
  margin-top: 6px;
}

.result {
  display: flex;
  flex-direction: column;
  gap: 16px;
  align-items: center;
}

.result-title {
  margin: 0;
  font-weight: 600;
}

.result img {
  width: min(340px, 100%);
  height: auto;
  border-radius: 14px;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.5);
}

.actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}

.caption {
  width: 100%;
  padding: 14px 16px;
  border-radius: 12px;
  background: var(--panel);
  box-shadow: inset 0 0 0 1px var(--line);
}

.caption-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
  font-size: 0.9rem;
}

.caption pre {
  margin: 0;
  font: inherit;
  font-size: 0.88rem;
  white-space: pre-wrap;
  word-break: break-word;
  opacity: 0.85;
}

.result .hint {
  max-width: 40ch;
}
