/* =============================================================
   Bildformat — styles.css
   1. Tokens
   ============================================================= */
:root {
  --bg: #f6f6f4;
  --surface: #ffffff;
  --surface-2: #eeeeeb;
  --ink: #1b1c1e;
  --ink-soft: #55565c;
  --line: #dcdcd7;
  --accent: #4f46e5;
  --accent-ink: #ffffff;
  --accent-soft: #eceafd;
  --ok: #15803d;
  --warn: #b45309;
  --error: #b91c1c;
  --stage: #232327;
  --radius: 14px;
  --radius-s: 9px;
  --gutter: clamp(1rem, 4vw, 2rem);
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --display: "Sora", var(--sans);
  --shadow: 0 1px 2px rgba(20, 20, 30, .05), 0 8px 24px rgba(20, 20, 30, .07);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #131316;
    --surface: #1d1d21;
    --surface-2: #26262b;
    --ink: #ececef;
    --ink-soft: #a6a6ad;
    --line: #33333a;
    --accent: #818cf8;
    --accent-ink: #14142a;
    --accent-soft: #2b2b46;
    --ok: #4ade80;
    --warn: #fbbf24;
    --error: #f87171;
    --stage: #0c0c0e;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .35);
  }
}

/* =============================================================
   2. Reset & 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;
  overscroll-behavior-y: none;
}
img, svg, video, canvas { display: block; max-width: 100%; }
img { height: auto; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
a { color: inherit; }
p { text-wrap: pretty; }
h1, h2, h3, h4 { text-wrap: balance; line-height: 1.12; letter-spacing: -0.02em; font-family: var(--display); }
::selection { background: var(--accent); color: var(--accent-ink); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }

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

.container { width: min(1080px, 100% - 2 * var(--gutter)); margin-inline: auto; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* =============================================================
   3. Header
   ============================================================= */
.site-header {
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: blur(8px);
  position: sticky; top: 0; z-index: 50;
}
.site-header .container {
  display: flex; align-items: center; justify-content: space-between;
  padding-block: .7rem; gap: 1rem;
}
.logo { display: flex; align-items: center; gap: .55rem; font-family: var(--display); font-weight: 700; font-size: 1.12rem; text-decoration: none; }
.logo svg { width: 26px; height: 26px; }
.site-nav { display: flex; gap: .25rem; }
.site-nav a {
  text-decoration: none; font-size: .9rem; color: var(--ink-soft);
  padding: .4rem .7rem; border-radius: 8px; transition: background .2s var(--ease-out), color .2s var(--ease-out);
}
.site-nav a:hover { background: var(--surface-2); color: var(--ink); }

/* =============================================================
   4. Hero / intro
   ============================================================= */
.hero { padding-block: clamp(1.6rem, 5vw, 3rem) 1.2rem; text-align: center; }
.hero h1 { font-size: clamp(1.65rem, 4.6vw, 2.6rem); font-weight: 700; }
.hero .sub { margin-top: .7rem; color: var(--ink-soft); font-size: clamp(.98rem, 2.4vw, 1.12rem); max-width: 46rem; margin-inline: auto; }
.privacy-badge {
  display: inline-flex; align-items: flex-start; gap: .5rem; text-align: left;
  margin-top: 1rem; padding: .45rem .9rem;
  background: var(--accent-soft); color: var(--ink);
  border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
  border-radius: 999px; font-size: .88rem; font-weight: 600;
}
.privacy-badge svg { width: 15px; height: 15px; flex: none; }

/* =============================================================
   5. Tool card & states
   ============================================================= */
.tool-card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: clamp(.9rem, 2.5vw, 1.5rem);
  margin-top: 1.4rem;
}
.tool-card > [data-panel] { display: none; }
.tool-card[data-state="idle"]  > [data-panel="idle"],
.tool-card[data-state="edit"]  > [data-panel="edit"],
.tool-card[data-state="error"] > [data-panel="error"] { display: block; }

/* --- dropzone --- */
.dropzone {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: .8rem; text-align: center; cursor: pointer;
  border: 2px dashed var(--line); border-radius: var(--radius-s);
  padding: clamp(2rem, 7vw, 3.6rem) 1rem;
  transition: border-color .2s var(--ease-out), background .2s var(--ease-out);
}
.dropzone:hover, .dropzone.is-over { border-color: var(--accent); background: var(--accent-soft); }
.dropzone svg { width: 44px; height: 44px; color: var(--accent); }
.dropzone strong { font-size: 1.08rem; }
.dropzone .hint { color: var(--ink-soft); font-size: .88rem; max-width: 30rem; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  background: var(--accent); color: var(--accent-ink);
  font-weight: 600; padding: .72rem 1.4rem; border-radius: 10px;
  transition: transform .15s var(--ease-out), filter .15s var(--ease-out);
}
.btn:hover { filter: brightness(1.08); transform: translateY(-1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn-ghost { background: var(--surface-2); color: var(--ink); }
.btn-big { font-size: 1.05rem; padding: .9rem 1.8rem; width: 100%; }

/* --- error panel --- */
.tool-error { text-align: center; padding: 2rem 1rem; }
.tool-error p { color: var(--error); font-weight: 600; margin-bottom: 1rem; }

/* --- editor layout --- */
.editor { display: grid; gap: 1.1rem; }
@media (min-width: 960px) {
  .editor { grid-template-columns: 300px 1fr; align-items: start; }
  .editor .fmt-picker { position: sticky; top: 70px; max-height: calc(100vh - 90px); overflow: auto; }
}

.file-meta {
  display: flex; align-items: center; justify-content: space-between; gap: .8rem;
  flex-wrap: wrap; margin-bottom: 1rem; font-size: .88rem; color: var(--ink-soft);
}
.file-meta strong { color: var(--ink); font-weight: 600; word-break: break-all; }
.link-reset { color: var(--accent); font-weight: 600; text-decoration: underline; background: none; font-size: .88rem; }

/* --- format picker --- */
.fmt-picker { border: 1px solid var(--line); border-radius: var(--radius-s); padding: .8rem; background: var(--surface); }
.fmt-picker h2 { font-size: .95rem; margin-bottom: .5rem; }
.fmt-picker .picker-hint { font-size: .8rem; color: var(--ink-soft); margin-bottom: .7rem; }
.fmt-group { margin-bottom: .75rem; }
.fmt-group h3 { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-soft); margin-bottom: .35rem; font-family: var(--sans); }
.fmt-list { display: flex; flex-wrap: wrap; gap: .38rem; }
.fmt-chip {
  display: inline-flex; align-items: center; gap: .42rem;
  border: 1.5px solid var(--line); border-radius: 999px;
  padding: .34rem .75rem; font-size: .84rem; background: var(--surface);
  transition: border-color .15s var(--ease-out), background .15s var(--ease-out), color .15s var(--ease-out);
}
.fmt-chip .dims { color: var(--ink-soft); font-size: .74rem; }
.fmt-chip .tick { width: 14px; height: 14px; border-radius: 50%; border: 1.5px solid var(--line); display: inline-flex; align-items: center; justify-content: center; flex: none; transition: inherit; }
.fmt-chip .tick svg { width: 9px; height: 9px; opacity: 0; }
.fmt-chip[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); }
.fmt-chip[aria-pressed="true"] .tick { background: var(--accent); border-color: var(--accent); }
.fmt-chip[aria-pressed="true"] .tick svg { opacity: 1; color: var(--accent-ink); }
.fmt-chip.is-active { box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 55%, transparent); }
.selected-count { font-size: .8rem; color: var(--ink-soft); margin-top: .3rem; }

/* --- stage / preview --- */
.workbench { display: grid; gap: 1rem; min-width: 0; }
.active-format-bar {
  display: flex; align-items: baseline; justify-content: space-between; gap: .8rem; flex-wrap: wrap;
}
.active-format-bar h2 { font-size: 1.02rem; }
.active-format-bar .dims { color: var(--ink-soft); font-size: .86rem; }
.stage {
  background: var(--stage); border-radius: var(--radius-s);
  padding: clamp(.7rem, 2vw, 1.2rem);
  display: flex; align-items: center; justify-content: center;
  min-height: 260px;
}
.stage-frame { position: relative; touch-action: none; max-width: 100%; }
.stage-frame canvas {
  width: 100%; height: 100%; border-radius: 4px;
  box-shadow: 0 0 0 1px rgba(255,255,255,.22), 0 10px 30px rgba(0,0,0,.45);
  cursor: grab;
}
.stage-frame.is-dragging canvas { cursor: grabbing; }
.stage-frame .drag-hint {
  position: absolute; left: 50%; bottom: .55rem; transform: translateX(-50%);
  background: rgba(0,0,0,.55); color: #fff; font-size: .74rem;
  padding: .22rem .7rem; border-radius: 999px; pointer-events: none;
  white-space: nowrap; opacity: 1; transition: opacity .4s var(--ease-out);
}
.stage-frame .drag-hint.is-hidden { opacity: 0; }

/* --- controls --- */
.controls { display: grid; gap: .9rem; }
.control-row { display: flex; flex-wrap: wrap; gap: .6rem 1rem; align-items: center; }
.control-label { font-size: .82rem; font-weight: 600; color: var(--ink-soft); min-width: 88px; }
.segmented { display: inline-flex; background: var(--surface-2); border-radius: 10px; padding: 3px; gap: 2px; }
.segmented button {
  padding: .4rem .85rem; border-radius: 8px; font-size: .86rem; font-weight: 600;
  color: var(--ink-soft); transition: background .15s var(--ease-out), color .15s var(--ease-out);
}
.segmented button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.bg-options { display: flex; flex-wrap: wrap; gap: .45rem; align-items: center; }
.bg-chip {
  display: inline-flex; align-items: center; gap: .4rem;
  border: 1.5px solid var(--line); border-radius: 999px; padding: .3rem .7rem;
  font-size: .82rem; transition: border-color .15s var(--ease-out), background .15s var(--ease-out);
}
.bg-chip[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); }
.bg-chip .swatch { width: 14px; height: 14px; border-radius: 50%; border: 1px solid var(--line); flex: none; }
.bg-chip input[type="color"] { width: 22px; height: 22px; padding: 0; border: 0; background: none; cursor: pointer; }
input[type="range"] { accent-color: var(--accent); flex: 1; min-width: 130px; max-width: 300px; }
.range-val { font-variant-numeric: tabular-nums; font-size: .84rem; color: var(--ink-soft); min-width: 3.4em; }
select {
  font: inherit; padding: .42rem .6rem; border-radius: 8px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
}
.size-estimate { font-size: .86rem; color: var(--ink-soft); }
.size-estimate strong { color: var(--ink); font-variant-numeric: tabular-nums; }
.note-inline { font-size: .78rem; color: var(--warn); }

/* --- export --- */
.export-bar { display: grid; gap: .5rem; }
.progress { height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; display: none; }
.progress.is-on { display: block; }
.progress i { display: block; height: 100%; width: 0%; background: var(--accent); border-radius: 99px; transition: width .2s var(--ease-out); }

/* --- results --- */
.results { display: none; margin-top: 1.2rem; }
.results.is-on { display: block; }
.results h2 { font-size: 1.05rem; margin-bottom: .35rem; }
.results .compare { font-size: .88rem; color: var(--ink-soft); margin-bottom: .8rem; }
.results-grid { display: grid; gap: .7rem; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.result-card {
  border: 1px solid var(--line); border-radius: var(--radius-s);
  background: var(--surface); padding: .7rem; display: grid; gap: .55rem;
}
.result-card .thumbwrap { background: var(--stage); border-radius: 6px; display: flex; align-items: center; justify-content: center; padding: .5rem; min-height: 110px; }
.result-card img { max-height: 130px; width: auto; max-width: 100%; border-radius: 3px; box-shadow: 0 2px 10px rgba(0,0,0,.35); }
.result-card .r-name { font-size: .86rem; font-weight: 600; line-height: 1.3; }
.result-card .r-meta { font-size: .78rem; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.result-card a.btn { padding: .5rem .8rem; font-size: .85rem; }

/* =============================================================
   6. Ad slots (placeholders only — ANZEIGE)
   ============================================================= */
.ad-slot {
  position: relative; display: flex; align-items: center; justify-content: center;
  border: 1.5px dashed var(--line); border-radius: var(--radius-s);
  background: color-mix(in srgb, var(--surface) 55%, transparent);
  color: var(--ink-soft); font-size: .8rem;
}
.ad-slot::before {
  content: "ANZEIGE";
  position: absolute; top: -0.62em; left: 12px;
  background: var(--bg); padding-inline: .45em;
  font-size: .64rem; letter-spacing: .14em; color: var(--ink-soft);
}
.ad-slot--leaderboard { min-height: 100px; margin-block: 1.6rem; }
.ad-slot--incontent { min-height: 250px; max-width: 340px; margin: 2rem auto; }

.ad-toast {
  position: fixed; right: 14px; bottom: 14px; z-index: 60;
  width: min(300px, calc(100vw - 28px));
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-s);
  box-shadow: var(--shadow); padding: .7rem;
  transform: translateY(16px); opacity: 0; pointer-events: none;
  transition: transform .35s var(--ease-out), opacity .35s var(--ease-out);
}
.ad-toast.is-on { transform: none; opacity: 1; pointer-events: auto; }
.ad-toast .ad-toast-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: .45rem; }
.ad-toast .ad-toast-head span { font-size: .64rem; letter-spacing: .14em; color: var(--ink-soft); }
.ad-toast .close-toast { padding: .15rem .45rem; border-radius: 6px; font-size: 1rem; line-height: 1; color: var(--ink-soft); }
.ad-toast .close-toast:hover { background: var(--surface-2); }
.ad-toast .ad-slot-inner {
  border: 1.5px dashed var(--line); border-radius: 6px; min-height: 90px;
  display: flex; align-items: center; justify-content: center;
  color: var(--ink-soft); font-size: .78rem;
}

/* Interruptor global de publicidad: los huecos solo se muestran si
   lib/manifest.js declara adsEnabled: true (main.js añade .ads-on). */
html:not(.ads-on) .ad-slot,
html:not(.ads-on) .ad-toast { display: none !important; }

/* =============================================================
   7. Content sections
   ============================================================= */
.section { padding-block: clamp(1.8rem, 5vw, 3rem); }
.section h2 { font-size: clamp(1.3rem, 3.2vw, 1.7rem); margin-bottom: .5rem; }
.section .lead { color: var(--ink-soft); max-width: 46rem; margin-bottom: 1.4rem; }

.steps { display: grid; gap: .9rem; counter-reset: step; }
@media (min-width: 720px) { .steps { grid-template-columns: repeat(3, 1fr); } }
.step {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.1rem; counter-increment: step;
}
.step::before {
  content: counter(step);
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--accent); color: var(--accent-ink);
  font-weight: 700; font-size: .92rem; margin-bottom: .6rem;
}
.step h3 { font-size: 1rem; margin-bottom: .3rem; }
.step p { font-size: .9rem; color: var(--ink-soft); }

/* size reference table */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius-s); background: var(--surface); }
.size-table { width: 100%; border-collapse: collapse; font-size: .9rem; min-width: 560px; }
.size-table th, .size-table td { text-align: left; padding: .55rem .85rem; border-bottom: 1px solid var(--line); }
.size-table thead th { font-size: .76rem; text-transform: uppercase; letter-spacing: .07em; color: var(--ink-soft); background: var(--surface-2); }
.size-table tbody tr:last-child td { border-bottom: 0; }
.size-table .pf { font-weight: 700; }
.size-table td.px { font-variant-numeric: tabular-nums; white-space: nowrap; }
.size-table td.note { color: var(--ink-soft); font-size: .82rem; }

/* use cases */
.usecases { display: grid; gap: .9rem; }
@media (min-width: 720px) { .usecases { grid-template-columns: repeat(2, 1fr); } }
.usecase { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem; }
.usecase h3 { font-size: 1rem; margin-bottom: .35rem; display: flex; align-items: center; gap: .5rem; }
.usecase h3 svg { width: 18px; height: 18px; color: var(--accent); flex: none; }
.usecase p { font-size: .9rem; color: var(--ink-soft); }

/* FAQ */
.faq details {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-s);
  padding: .85rem 1rem; margin-bottom: .55rem;
}
.faq summary { font-weight: 600; cursor: pointer; list-style: none; display: flex; justify-content: space-between; gap: .8rem; align-items: center; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; font-size: 1.2rem; color: var(--accent); font-weight: 400; flex: none; }
.faq details[open] summary::after { content: "–"; }
.faq details p { margin-top: .55rem; color: var(--ink-soft); font-size: .93rem; }

/* SEO text */
.seo-text { max-width: 50rem; }
.seo-text p { margin-bottom: .9rem; color: var(--ink-soft); }
.seo-text strong { color: var(--ink); }

/* =============================================================
   8. Footer
   ============================================================= */
.site-footer { border-top: 1px solid var(--line); padding-block: 1.6rem; margin-top: 2rem; font-size: .86rem; color: var(--ink-soft); }
.site-footer .container { display: flex; flex-wrap: wrap; gap: .8rem 1.6rem; justify-content: space-between; align-items: center; }
.footer-links { display: flex; flex-wrap: wrap; gap: .3rem 1.2rem; }
.footer-links a, .footer-links button { color: var(--ink-soft); text-decoration: underline; text-underline-offset: 2px; font-size: .86rem; padding: 0; }
.footer-links a:hover, .footer-links button:hover { color: var(--ink); }
.footer-privacy { width: 100%; font-size: .8rem; }

/* =============================================================
   9. Cookie banner (blocking consent)
   ============================================================= */
.cookie-banner {
  position: fixed; inset-inline: 0; bottom: 0; z-index: 100;
  padding: var(--gutter); display: none;
}
.cookie-banner.is-on { display: block; }
.cookie-banner .inner {
  width: min(680px, 100%); margin-inline: auto;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 1.1rem 1.2rem;
}
.cookie-banner h2 { font-size: 1rem; margin-bottom: .35rem; }
.cookie-banner p { font-size: .86rem; color: var(--ink-soft); margin-bottom: .8rem; }
.cookie-banner .cookie-actions { display: flex; flex-wrap: wrap; gap: .55rem; }
.cookie-banner .cookie-actions .btn { padding: .55rem 1.1rem; font-size: .9rem; }
.cookie-banner a { color: var(--accent); }

/* =============================================================
   10. Legal pages
   ============================================================= */
.legal { max-width: 46rem; padding-block: clamp(1.6rem, 5vw, 3rem); }
.legal h1 { font-size: clamp(1.5rem, 4vw, 2.1rem); margin-bottom: 1.2rem; }
.legal h2 { font-size: 1.15rem; margin: 1.6rem 0 .5rem; }
.legal p, .legal li { color: var(--ink-soft); margin-bottom: .6rem; font-size: .95rem; }
.legal ul { padding-left: 1.2rem; }
.legal .placeholder {
  background: #fef3c7; color: #92400e; padding: .1em .35em; border-radius: 4px;
  font-weight: 600; font-style: normal;
}
@media (prefers-color-scheme: dark) {
  .legal .placeholder { background: #45350b; color: #fcd34d; }
}
.legal .todo-box {
  border: 1.5px dashed var(--warn); border-radius: var(--radius-s);
  padding: .8rem 1rem; margin-block: 1rem; font-size: .88rem; color: var(--warn);
}

/* =============================================================
   11. No-JS fallback
   ============================================================= */
.nojs-note { padding: 1.4rem; text-align: center; color: var(--ink-soft); }

/* =============================================================
   12. Reduced motion (intrusive effects only)
   ============================================================= */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .ad-toast { transition: opacity .2s linear; transform: none; }
}
