/* Escarapela 30X — tokens del 30X Design System (modo oscuro). */
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("../fonts/inter-latin-wght-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("../fonts/inter-latin-ext-wght-normal.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
  color-scheme: dark;
  --bg: #000000;
  --surface: #0A0A0A;
  --surface-2: #171717;   /* neutral-900 */
  --dark: #262626;        /* 30X Dark / neutral-800 */
  --line: #262626;
  --line-strong: #404040;
  --text: #FAFAFA;        /* neutral-50 */
  --text-2: #D4D4D4;      /* neutral-300 */
  --text-3: #A3A3A3;      /* neutral-400 */
  --text-4: #737373;      /* neutral-500 */
  --accent: #E9FF7B;      /* único acento, solo sobre oscuro */
  --on-accent: #0A0A0A;
  --whisper: rgba(255, 255, 255, 0.08);

  --space-2xs: 4px;
  --space-xs: 8px;
  --space-sm: 12px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-2xl: 48px;
  --space-3xl: 64px;

  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;

  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --font: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100svh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  font-weight: 500;
  letter-spacing: -0.01em;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "cv11", "ss01";
}
img, canvas, video { display: block; max-width: 100%; }
button, input, textarea { font: inherit; letter-spacing: inherit; color: inherit; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- íconos (Heroicons Solid) ---------- */
.icon { width: 20px; height: 20px; flex: none; }
.icon--sm { width: 18px; height: 18px; }
.icon--lg { width: 28px; height: 28px; }
.icon--muted { color: var(--text-4); }

/* ---------- layout ---------- */
.app {
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  padding: max(var(--space-md), env(safe-area-inset-top)) var(--space-md) max(var(--space-xl), env(safe-area-inset-bottom));
}
.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  position: relative;
  z-index: 2;
}
.top__logo { height: 22px; width: auto; }

.layout {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-lg);
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
}

/* ---------- escenario: sin marco, la escarapela cae dentro de la página ---------- */
.stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-sm);
  margin-top: calc(-1 * var(--space-xs));
}
.stage__frame {
  position: relative;
  overflow: hidden;
  --stage-h: min(60svh, 620px);
  width: min(100%, calc(var(--stage-h) * var(--frame-ar, 0.5625)));
  aspect-ratio: var(--frame-ar, 0.5625);
  /* el cordón entra desde la oscuridad, no desde un borde duro */
  -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 14%, #000 100%);
  mask-image: linear-gradient(to bottom, transparent 0, #000 14%, #000 100%);
}
.stage__canvas { position: absolute; left: var(--canvas-x, 0); top: var(--canvas-y, 0); width: var(--canvas-w, 100%); height: var(--canvas-h, 100%); max-width: none; background: var(--bg); }
.stage__video {
  position: absolute; left: 0; top: 0; width: 2px; height: 2px;
  opacity: 0.01; pointer-events: none;
}
.stage__loading {
  position: absolute; inset: auto 0 45% 0; margin: 0;
  text-align: center; font-size: 14px; color: var(--text-4);
}
.app:not([data-state="loading"]) .stage__loading { display: none; }
.stage__replay {
  position: absolute; right: var(--space-xs); bottom: var(--space-xs);
}

/* ---------- formato (control segmentado) ---------- */
.segmented {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  border-radius: 9999px;
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--whisper);
  position: relative;
  z-index: 2;
}
.segmented__btn {
  display: inline-flex; align-items: center; gap: 6px;
  height: 34px; padding: 0 14px;
  border: 0; border-radius: 9999px;
  background: transparent; color: var(--text-3);
  font-size: 14px; font-weight: 600; letter-spacing: -0.01em;
  cursor: pointer; -webkit-tap-highlight-color: transparent;
  transition: background-color 160ms var(--ease-out), color 160ms var(--ease-out);
}
.segmented__btn:hover { color: var(--text); }
.segmented__btn[aria-pressed="true"] { background: var(--dark); color: var(--text); }
.segmented__btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.segmented__meta { font-size: 12px; font-weight: 500; color: var(--text-4); font-variant-numeric: tabular-nums; }

/* ---------- quitar fondo ---------- */
.bg-row { display: flex; align-items: center; gap: var(--space-sm); min-height: 40px; }
.bg-row__busy { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 500; color: var(--text-4); }
.spinner {
  width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid var(--line-strong); border-top-color: var(--text-2);
  animation: spin 800ms linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.segmented--sm .segmented__btn { height: 30px; padding: 0 12px; font-size: 13px; }

/* ---------- panel ---------- */
.panel { display: flex; flex-direction: column; min-width: 0; }
.panel__main { display: flex; flex-direction: column; gap: var(--space-lg); }
.panel__error {
  display: flex; flex-direction: column; gap: var(--space-sm);
  padding-top: var(--space-xl);
}

.intro { display: flex; flex-direction: column; gap: var(--space-xs); }
.title {
  margin: 0;
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -0.035em;
  line-height: 1.08;
  text-wrap: balance;
}
.lede {
  margin: 0;
  max-width: 44ch;
  color: var(--text-3);
  line-height: 1.65;
  text-wrap: pretty;
}
.label {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.4;
  color: var(--text-2);
}
.hint {
  margin: 0;
  font-size: 14px;
  line-height: 1.55;
  color: var(--text-4);
}

/* ---------- badge (ring-1 ring-inset) ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  height: 26px;
  padding: 0 10px;
  border-radius: 9999px;
  background: rgba(255, 255, 255, 0.04);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12);
  color: var(--text-2);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: -0.005em;
  white-space: nowrap;
}

/* ---------- botones (Button30x: light / dark / accent) ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-xs);
  height: 48px;
  padding: 0 20px;
  border: 0;
  border-radius: var(--radius-md);
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.3px;
  line-height: 1;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: filter 160ms var(--ease-out), background-color 160ms var(--ease-out), transform 160ms var(--ease-out), opacity 160ms var(--ease-out);
}
.btn:active:not(:disabled) { transform: scale(0.985); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn:disabled { cursor: not-allowed; opacity: 0.5; }
.btn--block { width: 100%; }
.btn--sm { height: 36px; padding: 0 14px; font-size: 14px; gap: 6px; }
.btn--accent { background: var(--accent); color: var(--on-accent); box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.1); }
.btn--accent:hover:not(:disabled) { filter: brightness(0.9); }
.btn--dark { background: var(--dark); color: #FFFFFF; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.04); }
.btn--dark:hover:not(:disabled) { filter: brightness(1.5); }
.btn--ghost { background: transparent; color: var(--text-3); padding: 0 12px; }
.btn--ghost:hover:not(:disabled) { color: var(--text); background: rgba(255, 255, 255, 0.04); }
.btn--icon {
  width: 40px; height: 40px; padding: 0; border-radius: 9999px;
  background: rgba(38, 38, 38, 0.72); color: var(--text-2);
  box-shadow: inset 0 0 0 1px var(--whisper);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
}
.btn--icon:hover { color: var(--text); }

/* ---------- foto ---------- */
.block { display: flex; flex-direction: column; gap: var(--space-sm); }
.photo-row { display: flex; align-items: center; gap: var(--space-md); }
.photo-row__thumb {
  width: 64px; height: 64px; object-fit: cover; border-radius: var(--radius-lg);
  background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--whisper);
}
.photo-row__body { display: flex; flex-direction: column; gap: var(--space-xs); min-width: 0; }
.photo-row__actions { display: flex; flex-wrap: wrap; gap: var(--space-xs); margin-left: -2px; }
.upload { display: flex; flex-direction: column; gap: var(--space-sm); }

.cropper {
  display: flex; flex-direction: column; gap: var(--space-md);
  padding: var(--space-md);
  border-radius: var(--radius-xl);
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--whisper);
}
.cropper__head { display: flex; flex-direction: column; gap: 2px; }
.cropper__view {
  position: relative;
  width: 100%;
  border-radius: var(--radius-lg);
  overflow: hidden;
  touch-action: none;
  cursor: grab;
  background: var(--surface-2);
}
.cropper__view:active { cursor: grabbing; }
.cropper__view:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.cropper__view canvas { width: 100%; height: 100%; }
.cropper__view::after {
  /* guía de tercios, muy tenue */
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background:
    linear-gradient(to right, transparent calc(33.33% - 0.5px), rgba(255,255,255,0.14) calc(33.33% - 0.5px), rgba(255,255,255,0.14) calc(33.33% + 0.5px), transparent calc(33.33% + 0.5px), transparent calc(66.66% - 0.5px), rgba(255,255,255,0.14) calc(66.66% - 0.5px), rgba(255,255,255,0.14) calc(66.66% + 0.5px), transparent calc(66.66% + 0.5px)),
    linear-gradient(to bottom, transparent calc(33.33% - 0.5px), rgba(255,255,255,0.14) calc(33.33% - 0.5px), rgba(255,255,255,0.14) calc(33.33% + 0.5px), transparent calc(33.33% + 0.5px), transparent calc(66.66% - 0.5px), rgba(255,255,255,0.14) calc(66.66% - 0.5px), rgba(255,255,255,0.14) calc(66.66% + 0.5px), transparent calc(66.66% + 0.5px));
  border-radius: inherit;
  box-shadow: inset 0 0 0 1px var(--whisper);
}
.cropper__zoom { display: flex; align-items: center; gap: var(--space-sm); }
.cropper__actions, .li-panel__actions { display: flex; flex-wrap: wrap; gap: var(--space-xs); }

input[type="range"] {
  flex: 1; height: 28px; margin: 0; background: transparent; -webkit-appearance: none; appearance: none;
}
input[type="range"]::-webkit-slider-runnable-track { height: 2px; background: var(--line-strong); border-radius: 2px; }
input[type="range"]::-moz-range-track { height: 2px; background: var(--line-strong); border-radius: 2px; }
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 20px; height: 20px; margin-top: -9px; border-radius: 50%;
  background: var(--text); box-shadow: 0 0 0 4px rgba(255,255,255,0.06);
}
input[type="range"]::-moz-range-thumb { width: 20px; height: 20px; border: 0; border-radius: 50%; background: var(--text); }
input[type="range"]:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; border-radius: 4px; }

/* ---------- edición ---------- */
.edit { border-top: 1px solid var(--whisper); border-bottom: 1px solid var(--whisper); }
.edit__summary {
  display: flex; align-items: center; gap: var(--space-xs);
  min-height: 52px; cursor: pointer; list-style: none;
  font-size: 14px; font-weight: 600; color: var(--text-3);
  transition: color 120ms linear;
}
.edit__summary::-webkit-details-marker { display: none; }
.edit__summary:hover, .edit[open] .edit__summary { color: var(--text); }
.edit__summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.edit__fields { display: grid; gap: var(--space-md); padding: var(--space-xs) 0 var(--space-lg); }
.field { display: flex; flex-direction: column; gap: 6px; }
.input {
  width: 100%;
  height: 44px;
  padding: 0 14px;
  border: 0;
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--line);
  color: var(--text);
  font-size: 16px; /* evita zoom en iOS */
  font-weight: 500;
  transition: box-shadow 120ms linear;
}
.input::placeholder { color: var(--text-4); }
.input:hover { box-shadow: inset 0 0 0 1px var(--line-strong); }
.input:focus { outline: none; box-shadow: inset 0 0 0 1px var(--text-3), 0 0 0 3px rgba(233, 255, 123, 0.18); }
.input--area { height: auto; padding: 12px 14px; line-height: 1.55; resize: vertical; min-height: 160px; }

/* ---------- compartir ---------- */
.block--share { gap: var(--space-md); }
.export { display: flex; flex-direction: column; gap: var(--space-xs); }
.export__bar { height: 2px; border-radius: 2px; background: var(--line); overflow: hidden; }
.export__bar span {
  display: block; height: 100%; width: 100%;
  background: var(--accent);
  transform: scaleX(0); transform-origin: left center;
  transition: transform 200ms var(--ease-out);
}
.export__label { margin: 0; font-size: 13px; font-weight: 500; color: var(--text-4); font-variant-numeric: tabular-nums; }
.export[data-phase="ready"] .export__bar { display: none; }
.export[data-phase="ready"] .export__label { color: var(--text-3); }
.export[data-phase="error"] .export__label { color: #FCA5A5; }

.actions { display: flex; flex-direction: column; gap: var(--space-sm); }
.actions__row { display: flex; flex-wrap: wrap; gap: var(--space-2xs); margin-left: -12px; }
.actions__row .btn { height: 40px; font-size: 14px; gap: 6px; }
.li-panel {
  display: flex; flex-direction: column; gap: var(--space-sm);
  padding: var(--space-md);
  border-radius: var(--radius-xl);
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--whisper);
  animation: rise 260ms var(--ease-out);
}
.qr {
  width: 148px; padding: 10px; border-radius: var(--radius-lg);
  background: #FFFFFF; /* el QR necesita contraste real para escanearse */
}
.qr svg { display: block; width: 100%; height: auto; }
.status { margin: 0; min-height: 1.5em; font-size: 14px; color: var(--text-3); }

/* ---------- entrada ---------- */
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.app[data-state="ready"] .intro,
.app[data-state="ready"] .block--photo,
.app[data-state="ready"] .edit,
.app[data-state="ready"] .block--share { animation: rise 520ms var(--ease-out) both; }
.app[data-state="ready"] .block--photo { animation-delay: 60ms; }
.app[data-state="ready"] .edit { animation-delay: 120ms; }
.app[data-state="ready"] .block--share { animation-delay: 180ms; }

/* ---------- desktop ---------- */
@media (min-width: 900px) {
  .app { padding: var(--space-xl) var(--space-2xl) var(--space-2xl); }
  .top__logo { height: 26px; }
  .layout {
    grid-template-columns: minmax(0, 1fr) minmax(360px, 420px);
    gap: var(--space-3xl);
    align-items: start;
  }
  .stage { margin-top: 0; position: sticky; top: var(--space-lg); }
  .stage__frame { --stage-h: min(calc(100svh - 190px), 820px); }
  .panel { padding: var(--space-xl) 0; }
  .panel__main { gap: var(--space-xl); }
  .title { font-size: 44px; letter-spacing: -0.04em; line-height: 1.04; }
  .lede { font-size: 17px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; transition-duration: 1ms !important; }
}
