@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url('/app/inter-latin-wght-normal.woff2') format('woff2-variations');
}

:root {
  --cream: #fbf4ef;
  --panel: #fffcfa;
  --ink: #1e2530;
  --orange: #e95b39;
  --orange-press: #d24e2e;
  --lilac: #4b4892;
  --beige: #f2e7df;
  --line: #dccabd;
  --line-soft: #e9dbd0;
  --stone: #8a8079;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --radius: 4px;
  color-scheme: light;
}

*,
*::before,
*::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--cream);
  color: var(--ink);
  font: 400 16px/1.5 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-feature-settings: 'ss01', 'cv11';
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

[hidden] { display: none !important; }

/* Mapa de marca: una capa fija, quieta, sin repetición. */
.map {
  position: fixed;
  inset: 0;
  z-index: -1;
  background: url('/app/brand-map.webp') center / cover no-repeat;
  opacity: 0.77;
  pointer-events: none;
}

/* ─── Barra ─── */
.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 28px clamp(20px, 4vw, 56px);
}

/* Logotipo «ADCITIES publish»: logo oficial + «publish» sobre la misma línea base.
   El archivo trae margen alrededor de las letras; .logo lo recorta para que su
   borde inferior sea la línea base de las mayúsculas. */
.brand {
  --cap: 17px;
  --h: calc(var(--cap) / 0.415);
  color: var(--ink);
  text-decoration: none;
  white-space: nowrap;
  line-height: 1;
}
.brand .logo {
  display: inline-block;
  overflow: hidden;
  height: var(--cap);
  width: calc(var(--h) * 3.5336 * 0.855);
}
.brand .logo img {
  display: block;
  height: var(--h);
  width: auto;
  margin: calc(var(--h) * -0.2915) 0 0 calc(var(--h) * 3.5336 * -0.0725);
}
.brand .word {
  margin-left: 0.3em;
  font-size: calc(var(--cap) * 1.42);
  font-weight: 500;
  letter-spacing: -0.035em;
  color: var(--orange);
}

/* ─── Composición: texto a la izquierda, escenario a la derecha ─── */
.layout {
  flex: 1;
  width: 100%;
  max-width: 1320px;
  margin: 0 auto;
  padding: clamp(16px, 4vh, 48px) clamp(20px, 4vw, 56px) clamp(40px, 7vh, 80px);
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 6.4fr);
  gap: clamp(40px, 6vw, 104px);
  align-items: center;
}

.copy { min-width: 0; }

h1 {
  margin: 0 0 clamp(36px, 6vh, 64px);
  font-size: clamp(36px, 4.6vw, 66px);
  line-height: 1.02;
  font-weight: 600;
  letter-spacing: -0.045em;
}
h1 span { display: block; }
.stone { color: var(--stone); }
h1 .l1, h1 .l2 { animation: rise 0.9s var(--ease) both; }
h1 .l2 { animation-delay: 0.08s; }

.view { animation: rise 0.7s var(--ease) 0.12s both; }

/* ─── Escenario ─── */
.stage { min-width: 0; animation: settle 1s var(--ease) 0.1s both; }

.drop {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 1 / 0.86;
  min-height: 340px;
  max-height: 72vh;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 252, 250, 0.86);
  overflow: hidden;
  cursor: pointer;
  isolation: isolate;
  transition: border-color 0.35s var(--ease), background-color 0.35s var(--ease);
}
.drop input[type='file'] {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  opacity: 0;
  cursor: pointer;
}
body.locked .drop { cursor: default; }
body.locked .drop input,
body.busy .drop input { pointer-events: none; }

/* Retícula de calles (funcional: es la cuadrícula sobre la que se colocan los archivos). */
.grid {
  position: absolute;
  inset: -1px;
  z-index: -1;
  background-image:
    linear-gradient(to right, rgba(220, 202, 189, 0.55) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(220, 202, 189, 0.55) 1px, transparent 1px);
  background-size: 48px 48px;
  background-position: center;
  transition: transform 0.8s var(--ease), opacity 0.5s var(--ease);
}
.drop.over .grid { transform: scale(0.94); }

/* Ejes: atraviesan el escenario y se cruzan donde aterriza el enlace. */
.axis {
  position: absolute;
  z-index: -1;
  background: var(--line);
  transition: transform 0.9s var(--ease), background-color 0.4s var(--ease);
}
.axis-x { left: 0; right: 0; top: 50%; height: 1px; transform: scaleX(0); }
.axis-y { top: 0; bottom: 0; left: 50%; width: 1px; transform: scaleY(0); }
.drop[data-state='live'] .axis { transform: none; background: rgba(30, 37, 48, 0.18); }

.drop:hover { border-color: var(--stone); }
.drop.over { border-color: var(--orange); background: rgba(242, 231, 223, 0.94); }
.drop:has(input:focus-visible) { outline: 2px solid var(--lilac); outline-offset: 3px; }

/* Estado vacío */
.empty {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 32px;
  text-align: center;
  transition: opacity 0.4s var(--ease), transform 0.6s var(--ease);
}
.drop:not([data-state='empty']) .empty { opacity: 0; transform: scale(0.96); pointer-events: none; }
body.locked .empty { opacity: 0.45; }

.glyph {
  position: relative;
  width: 64px;
  aspect-ratio: 4 / 5;
  margin-bottom: 22px;
  border: 1.5px solid var(--ink);
  border-radius: 2px;
  background: var(--panel);
  transition: transform 0.6s var(--ease);
}
.glyph::before {
  /* cremallera del ZIP */
  content: '';
  position: absolute;
  left: 50%;
  top: 0;
  width: 6px;
  height: 46%;
  transform: translateX(-50%);
  background: repeating-linear-gradient(to bottom, var(--ink) 0 4px, transparent 4px 8px);
}
.glyph i {
  position: absolute;
  right: -1.5px;
  bottom: -1.5px;
  width: 30%;
  aspect-ratio: 1;
  background: var(--orange);
  transition: transform 0.6s var(--ease);
  transform-origin: 100% 100%;
}
.drop:hover .glyph { transform: translateY(-4px); }
.drop.over .glyph { transform: translateY(-8px) rotate(-4deg); }
.drop.over .glyph i { transform: scale(1.35); }

.empty strong {
  font-size: clamp(19px, 1.9vw, 24px);
  font-weight: 600;
  letter-spacing: -0.025em;
  line-height: 1.2;
}
.empty .sub { color: var(--stone); font-size: 15px; }

.pick-folder {
  position: relative;
  z-index: 2;
  appearance: none;
  border: 0;
  background: none;
  padding: 0;
  font: inherit;
  color: var(--ink);
  font-weight: 500;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: var(--line);
}
.pick-folder:hover { text-decoration-color: var(--ink); }

/* Celdas: una por archivo real del proyecto */
.cells {
  position: absolute;
  inset: 0 0 76px;
  display: grid;
  place-content: center;
  grid-template-columns: repeat(var(--cols, 8), var(--cell, 22px));
  gap: var(--gap, 8px);
  padding: 32px;
  pointer-events: none;
}
.cell {
  width: var(--cell, 22px);
  aspect-ratio: 1;
  border-radius: 1px;
  opacity: 0.32;
  transform: scale(0);
  transition: transform 0.55s var(--ease), opacity 0.35s var(--ease), background-color 0.35s var(--ease);
  transition-delay: var(--d, 0s);
}
.cell.in { transform: none; }
.cell.up { opacity: 1; }
.cell.t-index { background: var(--orange); }
.cell.t-page { background: var(--ink); }
.cell.t-code { background: var(--lilac); }
.cell.t-media { background: var(--stone); }
.cell.t-other { background: transparent; box-shadow: inset 0 0 0 1.5px var(--ink); }
.drop[data-state='ready'] .cell { opacity: 0.88; }
/* Al publicarse convergen en el punto del enlace */
.cell.gone {
  transform: translate(var(--tx), var(--ty)) scale(0.2);
  opacity: 0;
  transition-duration: 0.7s, 0.6s, 0.3s;
}

/* Señal: el lugar donde vive el enlace */
.signal {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 0;
  height: 0;
  opacity: 0;
  pointer-events: none;
}
.signal .point {
  position: absolute;
  left: -8px;
  top: -8px;
  width: 16px;
  height: 16px;
  background: var(--orange);
  transform: scale(0) rotate(45deg);
  transition: transform 0.6s var(--ease) 0.35s;
}
.signal .ring {
  position: absolute;
  left: -40px;
  top: -40px;
  width: 80px;
  height: 80px;
  border: 1px solid var(--orange);
  border-radius: 50%;
  opacity: 0;
  transform: scale(0.2);
}
.signal .tag {
  position: absolute;
  left: 24px;
  bottom: 18px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 14px 11px;
  border-left: 2px solid var(--orange);
  background: var(--panel);
  white-space: nowrap;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.5s var(--ease) 0.6s, transform 0.6s var(--ease) 0.6s;
}
.signal .tag b { font-size: 17px; font-weight: 600; letter-spacing: -0.02em; }
.signal .tag span { font-size: 12px; color: var(--stone); letter-spacing: 0.02em; }
.drop[data-state='live'] .signal { opacity: 1; }
.drop[data-state='live'] .signal .point { transform: scale(1) rotate(0deg); }
.drop[data-state='live'] .signal .tag { opacity: 1; transform: none; }
.drop[data-state='live'] .signal .ring { animation: ping 1.4s var(--ease) 0.5s both; }

/* Pie del escenario: nombre, recuento y leyenda por tipo */
.meta {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 10px 24px;
  padding: 18px 24px 20px;
  border-top: 1px solid var(--line-soft);
  background: var(--panel);
  transform: translateY(100%);
  transition: transform 0.6s var(--ease);
}
.drop[data-state='ready'] .meta,
.drop[data-state='uploading'] .meta { transform: none; }
.meta-name { display: flex; flex-direction: column; gap: 2px; min-width: 0; max-width: 100%; }
.meta-name strong {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.015em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.meta-name span { font-size: 13px; color: var(--stone); font-variant-numeric: tabular-nums; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12px; color: var(--stone); }
.legend span { display: inline-flex; align-items: center; gap: 6px; font-variant-numeric: tabular-nums; }
.legend i { width: 8px; height: 8px; border-radius: 1px; }

/* ─── Campos ─── */
.label {
  display: block;
  margin: 0 0 10px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.label em { font-style: normal; color: var(--stone); font-weight: 500; letter-spacing: 0.06em; }

.url {
  display: flex;
  align-items: baseline;
  border-bottom: 1px solid var(--line);
  transition: border-color 0.3s var(--ease);
}
.url:focus-within { border-color: var(--ink); }
.url span {
  flex: none;
  max-width: 60%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--stone);
  font-size: clamp(17px, 1.6vw, 21px);
  padding: 12px 0;
}

input[type='text'],
input[type='password'] {
  flex: 1;
  min-width: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: clamp(17px, 1.6vw, 21px);
  font-weight: 500;
  letter-spacing: -0.01em;
  padding: 12px 0;
  outline: none;
}
input::placeholder { color: rgba(138, 128, 121, 0.45); }

.hint {
  min-height: 22px;
  margin: 10px 0 0;
  font-size: 14px;
  color: var(--stone);
}
.hint.exists { color: var(--lilac); }
.hint.bad { color: var(--orange); }

.row {
  display: flex;
  gap: 16px;
  align-items: stretch;
  border-bottom: 1px solid var(--line);
  padding-bottom: 8px;
}
.row:focus-within { border-color: var(--ink); }

/* ─── Botones ─── */
.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 20px;
  margin-top: 32px;
}
.status { margin: 0; font-size: 14px; color: var(--stone); font-variant-numeric: tabular-nums; }

.btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 52px;
  padding: 0 30px;
  border: 1px solid var(--orange);
  border-radius: var(--radius);
  background: var(--orange);
  color: #fff;
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.005em;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 0.25s var(--ease), border-color 0.25s var(--ease), color 0.25s var(--ease),
    opacity 0.25s var(--ease), transform 0.25s var(--ease);
}
.btn:hover { background: var(--orange-press); border-color: var(--orange-press); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.3; cursor: not-allowed; transform: none; background: var(--orange); border-color: var(--orange); }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--ink); }
.btn.ghost:hover { background: var(--ink); color: var(--cream); }
.row .btn { min-height: 46px; }

.link {
  appearance: none;
  border: 0;
  background: none;
  padding: 10px 0;
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 4px;
  text-decoration-color: var(--line);
  transition: text-decoration-color 0.25s var(--ease);
}
.link:hover { text-decoration-color: var(--ink); }

:focus-visible { outline: 2px solid var(--lilac); outline-offset: 3px; }

/* ─── Progreso ─── */
.progress { margin-top: 24px; }
.track { height: 2px; background: var(--line); overflow: hidden; }
.fill {
  height: 100%;
  width: 100%;
  background: var(--orange);
  transform: scaleX(0);
  transform-origin: 0 50%;
  transition: transform 0.35s var(--ease);
}

.msg {
  margin: 20px 0 0;
  padding-left: 14px;
  border-left: 2px solid var(--orange);
  font-size: 15px;
}
.msg:empty { display: none; }

/* ─── Resultado ─── */
.result {
  display: block;
  margin-top: 4px;
  font-size: clamp(24px, 2.8vw, 38px);
  font-weight: 600;
  letter-spacing: -0.035em;
  line-height: 1.15;
  color: var(--ink);
  text-decoration: none;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
  transition: color 0.25s var(--ease);
}
.result .host { color: var(--stone); font-weight: 500; overflow-wrap: anywhere; }
.result .name { display: inline-block; white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis; vertical-align: bottom; }
.result:hover .name { color: var(--orange); }
#done .label::before {
  content: '';
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 10px;
  background: var(--orange);
  vertical-align: 1px;
}
.again { margin-top: 28px; }

@keyframes rise {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: none; }
}
@keyframes settle {
  from { opacity: 0; transform: translateY(20px) scale(0.985); }
  to { opacity: 1; transform: none; }
}
@keyframes ping {
  0% { opacity: 0.9; transform: scale(0.2); }
  100% { opacity: 0; transform: scale(1.6); }
}

/* ─── Pantallas estrechas ─── */
@media (max-width: 900px) {
  .layout { grid-template-columns: minmax(0, 1fr); gap: 28px; align-items: start; }
  h1 { margin-bottom: 0; }
  .copy { display: contents; }
  .copy h1 { order: 1; }
  .stage { order: 2; }
  .copy .view { order: 3; }
  .drop { aspect-ratio: 1 / 0.8; min-height: 300px; }
}

@media (max-width: 560px) {
  .bar { padding-top: 20px; padding-bottom: 12px; }
  .grid { background-size: 36px 36px; }
  .empty .sub { font-size: 14px; }
  .actions .btn { flex: 1 1 100%; }
  .status { flex: 1 1 100%; }
  .row { flex-direction: column; gap: 4px; border-bottom: 0; padding-bottom: 0; }
  .row input { border-bottom: 1px solid var(--line); }
  .row input:focus { border-color: var(--ink); }
  .row .btn { margin-top: 20px; min-height: 52px; }
  .meta { padding: 14px 16px 16px; }
  .cells { inset: 0 0 96px; padding: 20px; }
  .signal .tag { left: 0; bottom: auto; top: 26px; translate: -50% 0; max-width: calc(100vw - 88px); }
  .signal .tag b { overflow: hidden; text-overflow: ellipsis; }
}

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

/* ─── Modo actualizar: nota con barra naranja ─── */
.target {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 4px 16px;
  margin: 0 0 28px;
  padding: 10px 0 10px 14px;
  border-left: 2px solid var(--orange);
  font-size: 15px;
  animation: rise 0.5s var(--ease) both;
}
.target b { font-weight: 600; }
.target .link { padding: 0; }
.field.pw { margin-top: 20px; animation: rise 0.5s var(--ease) both; }
.drop.cue { border-color: var(--orange); }

/* ─── Proyectos publicados ─── */
.library {
  width: 100%;
  max-width: 1320px;
  margin: 0 auto;
  padding: 0 clamp(20px, 4vw, 56px) clamp(56px, 10vh, 112px);
  animation: rise 0.8s var(--ease) 0.2s both;
}
.lib-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--ink);
}
.lib-head h2 {
  margin: 0;
  font-size: clamp(24px, 2.4vw, 32px);
  font-weight: 600;
  letter-spacing: -0.035em;
  line-height: 1.1;
}
.lib-count { margin: 0; font-size: 14px; color: var(--stone); font-variant-numeric: tabular-nums; }

.lib-list { list-style: none; margin: 0; padding: 0; }
.lib-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto auto;
  align-items: center;
  gap: 8px clamp(16px, 3vw, 40px);
  padding: 18px 0;
  border-bottom: 1px solid var(--line);
  animation: rise 0.5s var(--ease) both;
  animation-delay: var(--d, 0s);
}
.lib-name { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.lib-name a {
  font-size: 19px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--ink);
  text-decoration: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: color 0.25s var(--ease);
}
.lib-name a:hover { color: var(--orange); }
.lib-name span { font-size: 13px; color: var(--stone); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lib-meta { font-size: 14px; color: var(--stone); font-variant-numeric: tabular-nums; white-space: nowrap; }
.lib-row .btn { min-height: 40px; padding: 0 18px; font-size: 14px; }
.lib-row.is-target { border-bottom-color: var(--orange); }
.lib-row.is-target .lib-name a { color: var(--orange); }
.lib-empty { padding: 24px 0; color: var(--stone); font-size: 15px; }

@media (max-width: 720px) {
  .lib-row { grid-template-columns: minmax(0, 1fr) auto; }
  .lib-meta { grid-column: 1 / -1; grid-row: 2; }
  .lib-row .open { display: none; }
}
