/* =============================================================
   FotoLigera — hoja de estilos única
   1. Tokens · 2. Reset · 3. Utilidades · 4. Tipografía
   5. Componentes · 6. Secciones · 7. Anuncios · 8. Diálogos
   9. Responsive · 10. Reduced motion
   ============================================================= */

/* =============================================================
   1. Tokens
   ============================================================= */
:root {
  --accent:        #0F766E;
  --accent-soft:   #14B8A6;
  --accent-wash:   #ECFDF5;
  --win:           #15803D;
  --win-wash:      #F0FDF4;

  --ink:           #0F172A;
  --ink-2:         #334155;
  --muted:         #64748B;
  --line:          #E2E8F0;
  --line-2:        #CBD5E1;
  --bg:            #F6F8FA;
  --card:          #FFFFFF;
  --card-2:        #F8FAFC;

  --radius:        16px;
  --radius-sm:     10px;
  --shadow:        0 1px 2px rgba(15,23,42,.04), 0 8px 24px rgba(15,23,42,.06);
  --shadow-lg:     0 24px 60px rgba(15,23,42,.18);

  --sans: "Manrope", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --gutter: clamp(1rem, 4vw, 2rem);
}

@media (prefers-color-scheme: dark) {
  :root {
    --accent:      #2DD4BF;
    --accent-soft: #5EEAD4;
    --accent-wash: #10312F;
    --win:         #4ADE80;
    --win-wash:    #10281A;

    --ink:         #E9EEF5;
    --ink-2:       #C3CDDA;
    --muted:       #93A3B8;
    --line:        #24303F;
    --line-2:      #33415A;
    --bg:          #0B1118;
    --card:        #121A23;
    --card-2:      #18222D;

    --shadow:      0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.35);
    --shadow-lg:   0 24px 60px rgba(0,0,0,.6);
  }
}

/* =============================================================
   2. Reset y base
   ============================================================= */
*, *::before, *::after { box-sizing: border-box; margin: 0; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  overflow-x: clip;
}

img, svg { display: block; max-width: 100%; }
img { height: auto; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
a { color: inherit; text-decoration: none; }
p { text-wrap: pretty; }
h1, h2, h3 { text-wrap: balance; line-height: 1.15; letter-spacing: -0.02em; font-weight: 800; }
input, select { font: inherit; color: inherit; }

::selection { background: var(--accent); color: #fff; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 6px; }

/* =============================================================
   3. Utilidades
   ============================================================= */
.container { width: 100%; max-width: 1080px; margin-inline: auto; padding-inline: var(--gutter); }
.container-narrow { max-width: 760px; }

.skip-link {
  position: fixed; top: -100px; left: 1rem; z-index: 999;
  padding: .6rem 1rem; background: var(--ink); color: var(--bg);
  border-radius: 8px; font-weight: 600;
}
.skip-link:focus { top: 1rem; }

/* =============================================================
   4. Cabecera y pie
   ============================================================= */
.site-header {
  position: sticky; top: 0; z-index: 40;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.header-inner { display: flex; align-items: center; justify-content: space-between; gap: 1rem; height: 60px; }

.logo { display: inline-flex; align-items: center; gap: .55rem; }
.logo-mark { width: 28px; height: 28px; fill: none; stroke: var(--accent); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.logo-mark .logo-peak { stroke: var(--accent-soft); }
.logo-mark .logo-lines { stroke: var(--accent-soft); }
.logo-word { font-weight: 500; font-size: 1.12rem; letter-spacing: -.02em; }
.logo-word strong { font-weight: 800; color: var(--accent); }

.site-nav { display: flex; gap: 1rem; font-size: .84rem; font-weight: 600; color: var(--muted); white-space: nowrap; }
.site-nav a:hover { color: var(--accent); }
@media (max-width: 430px) { .site-nav { font-size: .78rem; gap: .8rem; } }
@media (max-width: 350px) { .site-nav { display: none; } }

.site-footer { border-top: 1px solid var(--line); margin-top: 3.5rem; padding: 2rem 0 3rem; background: var(--card); }
.footer-inner { display: flex; flex-wrap: wrap; gap: 1.25rem; justify-content: space-between; align-items: flex-start; }
.footer-tag { color: var(--muted); font-size: .9rem; margin-top: .25rem; max-width: 34ch; }
.footer-links { display: flex; flex-wrap: wrap; gap: 1.1rem; font-size: .9rem; font-weight: 600; color: var(--muted); }
.footer-links a:hover { color: var(--accent); }

/* =============================================================
   5. Hero + tarjeta de la herramienta
   ============================================================= */
.hero { padding: clamp(1.5rem, 4vw, 2.75rem) 0 1.5rem; }
.hero h1 { font-size: clamp(1.65rem, 5.2vw, 2.5rem); }
.hero .sub { color: var(--ink-2); margin-top: .5rem; font-size: clamp(.98rem, 2.4vw, 1.08rem); max-width: 62ch; }
.hero .sub strong { color: var(--ink); font-weight: 700; }

.tool-card {
  margin-top: 1.15rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: clamp(.9rem, 2.5vw, 1.35rem);
}

/* --- Chips de plataforma --- */
.presets { display: flex; flex-wrap: wrap; gap: .4rem; }
/* En móvil los 6 preajustes ocupaban 3 filas y empujaban la herramienta:
   una sola fila deslizable la mantiene visible sin hacer scroll. */
@media (max-width: 620px) {
  .presets {
    flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none;
    -webkit-overflow-scrolling: touch; padding-bottom: 2px;
    margin-inline: -.35rem; padding-inline: .35rem;
  }
  .presets::-webkit-scrollbar { display: none; }
  .chip { flex: none; }
}
.chip {
  padding: .42rem .78rem; border-radius: 999px;
  border: 1px solid var(--line-2); color: var(--ink-2);
  font-size: .87rem; font-weight: 700; background: var(--card);
  transition: all .18s var(--ease-out);
}
.chip:hover { border-color: var(--accent); color: var(--accent); }
.chip.is-active { background: var(--accent); border-color: var(--accent); color: #fff; }
@media (prefers-color-scheme: dark) { .chip.is-active { color: #06231F; } }

.preset-note { margin-top: .55rem; font-size: .87rem; line-height: 1.45; color: var(--ink-2); font-weight: 600; }
.preset-disclaimer { margin-top: .2rem; font-size: .74rem; line-height: 1.4; color: var(--muted); }

/* --- Zona de arrastre --- */
.drop {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: .3rem; text-align: center;
  margin-top: .85rem; padding: clamp(1.4rem, 5vw, 2.3rem) 1rem;
  border: 2px dashed var(--line-2); border-radius: var(--radius-sm);
  background: var(--card-2); cursor: pointer;
  transition: border-color .18s var(--ease-out), background .18s var(--ease-out);
}
.drop:hover, .drop.is-over { border-color: var(--accent); background: var(--accent-wash); }
.drop input[type="file"] { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.drop-icon { width: 40px; height: 40px; fill: none; stroke: var(--accent); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; margin-bottom: .3rem; }
.drop-title { font-weight: 800; font-size: 1.05rem; }
.drop-sub { font-size: .85rem; color: var(--muted); }

/* --- Ajustes avanzados --- */
.adv { margin-top: .85rem; border-top: 1px solid var(--line); padding-top: .7rem; }
.adv > summary {
  cursor: pointer; list-style: none; font-weight: 700; font-size: .9rem;
  color: var(--accent); display: inline-flex; align-items: center; gap: .35rem;
}
.adv > summary::-webkit-details-marker { display: none; }
.adv > summary::after { content: "▾"; font-size: .8em; transition: transform .2s var(--ease-out); }
.adv[open] > summary::after { transform: rotate(180deg); }

.adv-grid { display: grid; gap: .9rem; margin-top: .85rem; grid-template-columns: 1fr; }
.field-label { display: block; font-size: .8rem; font-weight: 700; color: var(--muted); margin-bottom: .32rem; text-transform: uppercase; letter-spacing: .04em; }
.field-label output { color: var(--accent); }

.seg { display: inline-flex; background: var(--card-2); border: 1px solid var(--line); border-radius: 999px; padding: 3px; gap: 3px; flex-wrap: wrap; }
.seg-btn { padding: .34rem .7rem; border-radius: 999px; font-size: .84rem; font-weight: 700; color: var(--muted); }
.seg-btn.is-active { background: var(--accent); color: #fff; }
@media (prefers-color-scheme: dark) { .seg-btn.is-active { color: #06231F; } }

.inline { display: inline-flex; align-items: center; gap: .4rem; }
.unit { color: var(--muted); font-size: .85rem; font-weight: 700; }

input[type="number"], select {
  background: var(--card-2); border: 1px solid var(--line-2); border-radius: 8px;
  padding: .42rem .55rem; font-weight: 600; max-width: 190px;
}
input[type="range"] { width: min(260px, 100%); accent-color: var(--accent); }

.field[data-when] { display: none; }
.tool-card[data-mode="target"] .field[data-when="target"],
.tool-card[data-mode="auto"]   .field[data-when="auto"] { display: block; }

.noscript-msg {
  margin-top: .9rem; padding: .8rem 1rem; border-radius: var(--radius-sm);
  background: var(--accent-wash); color: var(--ink); font-weight: 600; font-size: .92rem;
}

/* --- Barra "preparando el motor" --- */
.engine { display: none; align-items: center; gap: .7rem; margin-top: .9rem; font-size: .87rem; color: var(--muted); font-weight: 600; }
.tool-card[data-state="loading-engine"] .engine { display: flex; }
.engine-bar { flex: 1; height: 6px; border-radius: 999px; background: var(--line); overflow: hidden; }
.engine-bar i { display: block; width: 40%; height: 100%; border-radius: 999px; background: var(--accent); animation: slide 1.1s infinite var(--ease-out); }
@keyframes slide { 0% { transform: translateX(-100%); } 100% { transform: translateX(280%); } }

/* --- Filas de archivos --- */
.rows { list-style: none; padding: 0; margin: 0; display: grid; gap: .55rem; }
.rows:not(:empty) { margin-top: .95rem; }

.row {
  display: grid; grid-template-columns: 52px 1fr auto; gap: .7rem; align-items: center;
  padding: .6rem; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--card-2);
}
.row-thumb { width: 52px; height: 52px; border-radius: 8px; object-fit: cover; background: var(--line); }
.row-main { min-width: 0; }
.row-name { font-weight: 700; font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-meta { font-size: .84rem; color: var(--muted); display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; margin-top: .1rem; }
.row-meta .after { color: var(--ink); font-weight: 700; }
.row-meta .save { background: var(--win-wash); color: var(--win); font-weight: 800; padding: .05rem .4rem; border-radius: 999px; font-size: .78rem; }
.row-meta .grow { background: var(--accent-wash); color: var(--accent); font-weight: 800; padding: .05rem .4rem; border-radius: 999px; font-size: .78rem; }
.row-err { font-size: .82rem; color: #B91C1C; font-weight: 600; margin-top: .15rem; }
@media (prefers-color-scheme: dark) { .row-err { color: #FCA5A5; } }

.bar { height: 5px; border-radius: 999px; background: var(--line); overflow: hidden; margin-top: .35rem; }
.bar i { display: block; height: 100%; width: 0; background: var(--accent); border-radius: 999px; transition: width .2s linear; }
.row[data-status="done"] .bar, .row[data-status="error"] .bar { display: none; }
.row[data-status="working"] .row-meta .after, .row[data-status="pending"] .row-meta .after { display: none; }

.row-actions { display: flex; align-items: center; gap: .35rem; }
.btn-mini {
  font-size: .8rem; font-weight: 700; padding: .34rem .6rem; border-radius: 8px;
  border: 1px solid var(--line-2); color: var(--ink-2); background: var(--card);
}
.btn-mini:hover { border-color: var(--accent); color: var(--accent); }
.btn-dl {
  font-size: .82rem; font-weight: 800; padding: .4rem .72rem; border-radius: 8px;
  background: var(--accent); color: #fff; display: inline-block;
}
@media (prefers-color-scheme: dark) { .btn-dl { color: #06231F; } }
.btn-dl:hover { background: var(--accent-soft); }
.btn-x { color: var(--muted); font-size: 1.25rem; line-height: 1; padding: .1rem .3rem; border-radius: 6px; }
.btn-x:hover { color: #B91C1C; }
.row[data-status="working"] .btn-mini, .row[data-status="working"] .btn-dl,
.row[data-status="pending"] .btn-mini, .row[data-status="pending"] .btn-dl,
.row[data-status="error"] .btn-mini, .row[data-status="error"] .btn-dl { display: none; }

/* --- Totales --- */
.totals {
  margin-top: .95rem; padding: .85rem; border-radius: var(--radius-sm);
  background: var(--accent-wash); border: 1px solid color-mix(in srgb, var(--accent) 25%, transparent);
  display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; justify-content: space-between;
}
/* display:flex se impone al [hidden] del navegador: hay que decirlo explícitamente */
.totals[hidden] { display: none; }
.totals-text strong { display: block; font-size: 1.05rem; font-weight: 800; }
.totals-text span { font-size: .85rem; color: var(--ink-2); }
.totals-actions { display: flex; flex-wrap: wrap; gap: .5rem; }

.btn { border-radius: 10px; font-weight: 800; padding: .6rem 1rem; font-size: .92rem; transition: all .18s var(--ease-out); }
.btn-primary { background: var(--accent); color: #fff; }
@media (prefers-color-scheme: dark) { .btn-primary { color: #06231F; } }
.btn-primary:hover { background: var(--accent-soft); }
.btn-primary[disabled] { opacity: .55; cursor: default; }
.btn-ghost { border: 1px solid var(--line-2); color: var(--ink-2); }
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }
.btn-block { display: block; width: 100%; }

/* --- Insignia de privacidad y límites --- */
.privacy-badge {
  display: flex; gap: .6rem; align-items: flex-start;
  margin-top: 1rem; padding: .8rem .95rem;
  background: var(--win-wash); border: 1px solid color-mix(in srgb, var(--win) 22%, transparent);
  border-radius: var(--radius-sm); font-size: .9rem; color: var(--ink-2);
}
.privacy-badge svg { width: 20px; height: 20px; flex: none; margin-top: 2px; fill: none; stroke: var(--win); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.privacy-badge strong { color: var(--ink); }
.limits { margin-top: .5rem; font-size: .82rem; color: var(--muted); }

/* =============================================================
   6. Secciones de contenido
   ============================================================= */
.section { padding: clamp(2rem, 6vw, 3.25rem) 0; }
/* La cabecera es fija: sin esto tapa el título al llegar desde un enlace interno */
[id] { scroll-margin-top: 76px; }
.section h2 { font-size: clamp(1.35rem, 4vw, 1.8rem); margin-bottom: 1.1rem; }
.section h3 { font-size: 1.08rem; margin-top: 1.6rem; margin-bottom: .35rem; font-weight: 700; }
.section-prose p { color: var(--ink-2); max-width: 72ch; margin-top: .5rem; }

.steps { list-style: none; padding: 0; display: grid; gap: 1rem; grid-template-columns: 1fr; counter-reset: none; }
.step {
  position: relative; background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 1.15rem 1.15rem 1.25rem; box-shadow: var(--shadow);
}
.step-num {
  position: absolute; top: -12px; left: 1.1rem;
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--accent); color: #fff; font-weight: 800; font-size: .85rem;
  display: grid; place-items: center;
}
@media (prefers-color-scheme: dark) { .step-num { color: #06231F; } }
.step-icon { width: 30px; height: 30px; margin: .35rem 0 .6rem; fill: none; stroke: var(--accent-soft); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.step h3 { margin: 0 0 .3rem; font-size: 1.05rem; }
.step p { color: var(--ink-2); font-size: .93rem; }

.faq { border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--card); margin-bottom: .55rem; overflow: hidden; }
.faq > summary {
  cursor: pointer; list-style: none; padding: .9rem 2.4rem .9rem 1rem;
  font-weight: 700; font-size: .97rem; position: relative;
}
.faq > summary::-webkit-details-marker { display: none; }
.faq > summary::after {
  content: "+"; position: absolute; right: 1rem; top: 50%; transform: translateY(-50%);
  font-size: 1.2rem; font-weight: 700; color: var(--accent); transition: transform .2s var(--ease-out);
}
.faq[open] > summary::after { content: "−"; }
.faq > p { padding: 0 1rem 1rem; color: var(--ink-2); font-size: .93rem; }

/* =============================================================
   7. Huecos de publicidad (placeholders vacíos)
   ============================================================= */
.ad-slot {
  position: relative; display: grid; place-items: center;
  border: 1px dashed var(--line-2); border-radius: var(--radius-sm);
  background: repeating-linear-gradient(45deg, transparent, transparent 10px, color-mix(in srgb, var(--line) 45%, transparent) 10px, color-mix(in srgb, var(--line) 45%, transparent) 20px);
  color: var(--muted);
}
.ad-tag { font-size: .7rem; font-weight: 800; letter-spacing: .18em; }
.ad-leaderboard { min-height: 100px; margin: .5rem 0 1.5rem; }
.ad-incontent { min-height: 250px; margin: 1rem 0; }
.ad-popup { min-height: 200px; width: 100%; margin: .9rem 0 1rem; }
.ad-corner { min-height: 90px; width: 100%; }

.corner-ad {
  position: fixed; right: 14px; bottom: 14px; z-index: 60;
  width: min(300px, calc(100vw - 28px));
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius-sm); box-shadow: var(--shadow-lg);
  padding: .55rem; padding-top: 1.35rem;
  animation: cornerIn .35s var(--ease-out) both;
}
.corner-ad[hidden] { display: none; }
@keyframes cornerIn { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
.corner-close {
  position: absolute; top: 2px; right: 4px;
  font-size: 1.15rem; line-height: 1; color: var(--muted); padding: .2rem .35rem; border-radius: 6px;
}
.corner-close:hover { color: var(--ink); background: var(--card-2); }

/* =============================================================
   8. Diálogos (pop-up de anuncio y comparador)
   ============================================================= */
dialog {
  border: 0; padding: 0; color: var(--ink); background: transparent;
  max-width: min(560px, calc(100vw - 24px)); width: 100%;
}
dialog::backdrop { background: rgba(6, 14, 22, .55); backdrop-filter: blur(3px); }

.ad-dialog, .cmp-dialog {
  position: relative; background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-lg);
  padding: 1.35rem 1.25rem 1.25rem;
}
.cmp-dialog { max-width: min(760px, calc(100vw - 24px)); }

.dialog-close {
  position: absolute; top: 8px; right: 10px; z-index: 2;
  font-size: 1.5rem; line-height: 1; color: var(--muted); padding: .15rem .45rem; border-radius: 8px;
}
.dialog-close:hover { color: var(--ink); background: var(--card-2); }

.dialog-kicker { color: var(--win); font-weight: 800; font-size: .82rem; letter-spacing: .04em; }
.ad-dialog h2 { font-size: 1.2rem; margin: .2rem 0 .3rem; }
.dialog-text { color: var(--ink-2); font-size: .93rem; }

.cmp-title { font-size: 1.1rem; margin-bottom: .7rem; }
.cmp-stage {
  position: relative; overflow: hidden; border-radius: var(--radius-sm);
  background: var(--card-2); border: 1px solid var(--line);
  max-height: 62vh; display: grid; place-items: center;
}
.cmp-stage img { width: 100%; height: auto; max-height: 62vh; object-fit: contain; display: block; }
.cmp-before-wrap {
  position: absolute; inset: 0; overflow: hidden; width: 50%;
  display: grid; place-items: center; border-right: 2px solid var(--accent);
}
.cmp-before-wrap img { width: auto; max-width: none; }
.cmp-handle { position: absolute; top: 0; bottom: 0; left: 50%; width: 2px; background: var(--accent); pointer-events: none; }
.cmp-handle::after {
  content: ""; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: 30px; height: 30px; border-radius: 50%; background: var(--accent); box-shadow: 0 2px 10px rgba(0,0,0,.3);
}
.cmp-range-label { display: block; font-size: .8rem; color: var(--muted); font-weight: 700; margin: .7rem 0 .2rem; }
#cmpRange { width: 100%; }
.cmp-legend { display: flex; justify-content: space-between; gap: 1rem; font-size: .86rem; color: var(--muted); margin-top: .3rem; }
.cmp-legend b { color: var(--ink); }
.cmp-legend i { font-style: normal; font-weight: 700; }

/* =============================================================
   9. Responsive
   ============================================================= */
@media (min-width: 540px) {
  .adv-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .row { grid-template-columns: 60px 1fr auto; }
  .row-thumb { width: 60px; height: 60px; }
}
@media (min-width: 720px) {
  .steps { grid-template-columns: repeat(3, 1fr); }
}
@media (min-width: 960px) {
  .hero { padding-top: 2.75rem; }
  .tool-card { padding: 1.5rem; }
}

/* Móviles muy estrechos: que la fila no se rompa */
@media (max-width: 400px) {
  .row { grid-template-columns: 44px 1fr; }
  .row-thumb { width: 44px; height: 44px; }
  .row-actions { grid-column: 1 / -1; justify-content: flex-end; }
}

/* =============================================================
   10. Reduced motion (solo efectos intrusivos)
   ============================================================= */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .engine-bar i { animation: none; width: 100%; }
  .corner-ad { animation: none; }
}
