/* =============================================================
   0. Fonts (self-hosted, no external requests)
   ============================================================= */
@font-face {
  font-family: "Manrope";
  font-style: normal; font-display: swap; font-weight: 200 800;
  src: url("assets/fonts/manrope-latin-wght-normal.woff2") format("woff2");
}
@font-face {
  font-family: "Bricolage Grotesque";
  font-style: normal; font-display: swap; font-weight: 200 800;
  src: url("assets/fonts/bricolage-grotesque-latin-wght-normal.woff2") format("woff2");
}

/* =============================================================
   1. Tokens
   ============================================================= */
:root {
  --bg: #f6f7f4;
  --surface: #ffffff;
  --ink: #14201d;
  --muted: #5b6763;
  --line: #dfe4e0;
  --accent: #0f766e;
  --accent-ink: #ffffff;
  --accent-soft: #e3f2ef;
  --warn: #b42318;
  --ok: #157f3b;
  --radius: 18px;
  --sans: "Manrope", system-ui, -apple-system, "Segoe UI", sans-serif;
  --display: "Bricolage Grotesque", var(--sans);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --cream: #ffffff;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1514;
    --surface: #161e1c;
    --ink: #e8efec;
    --muted: #9aa7a2;
    --line: #2a3532;
    --accent: #2dd4bf;
    --accent-ink: #062b27;
    --accent-soft: #123a35;
    --warn: #f97066;
    --ok: #4ade80;
  }
}

/* =============================================================
   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;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  overflow-x: clip;
}
img, svg { display: block; max-width: 100%; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
a { color: inherit; }
p { text-wrap: pretty; }
h1, h2, h3 { text-wrap: balance; line-height: 1.1; letter-spacing: -0.02em; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 6px; }
::selection { background: var(--accent); color: var(--accent-ink); }

/* =============================================================
   3. Utilities
   ============================================================= */
.container { width: min(100% - 2rem, 860px); margin-inline: auto; }
.skip-link {
  position: fixed; top: -100px; left: 1rem; z-index: 9999;
  padding: .6rem 1rem; background: var(--surface); border-radius: 8px; font-weight: 600;
}
.skip-link:focus { top: 1rem; }
[hidden] { display: none !important; }

/* =============================================================
   4. Typography
   ============================================================= */
h1 { font-family: var(--display); font-weight: 800; font-size: clamp(1.9rem, 6.5vw, 3rem); }
h2 { font-family: var(--display); font-weight: 700; font-size: clamp(1.4rem, 4vw, 1.9rem); margin-bottom: 1rem; }
h3 { font-size: 1.1rem; font-weight: 700; margin: 1.4rem 0 .4rem; }
code { font-size: .9em; background: var(--accent-soft); padding: .1em .35em; border-radius: 5px; }

/* =============================================================
   5. Components
   ============================================================= */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  min-height: 44px; padding: .65rem 1.2rem; border-radius: 999px;
  font-weight: 700; border: 1.5px solid var(--line); background: var(--surface);
  transition: transform .2s var(--ease-out), background .2s, border-color .2s;
  text-decoration: none;
}
.btn:hover { border-color: var(--accent); }
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn-primary:hover { filter: brightness(1.08); }
.btn-sm { min-height: 38px; padding: .4rem .9rem; font-size: .9rem; }

/* Tool card */
.tool-card {
  margin-top: 1.1rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem;
  box-shadow: 0 1px 2px rgba(0,0,0,.04), 0 12px 32px -18px rgba(15,118,110,.35);
}
.noscript { padding: 1rem; text-align: center; font-weight: 600; }

.tool-options { display: flex; flex-wrap: wrap; gap: .75rem 1.25rem; align-items: center; margin-bottom: .85rem; }
.opt { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; min-width: 0; }
.seg { flex-wrap: wrap; }
.opt-label { font-size: .85rem; font-weight: 700; color: var(--muted); white-space: nowrap; }
.opt-label output { color: var(--ink); }
.opt-quality input { width: 120px; accent-color: var(--accent); }
.seg { display: inline-flex; background: var(--bg); border: 1px solid var(--line); border-radius: 999px; padding: 3px; }
.seg label { position: relative; }
.seg input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.seg span { display: block; padding: .3rem .85rem; border-radius: 999px; font-weight: 700; font-size: .9rem; transition: background .2s; }
.seg input:checked + span { background: var(--accent); color: var(--accent-ink); }
.seg input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.seg label.is-disabled { opacity: .4; }
.webp-note { font-size: .85rem; color: var(--muted); margin: -.4rem 0 .8rem; }

.dropzone {
  position: relative;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .35rem;
  min-height: 210px; padding: 1.5rem 1rem; text-align: center;
  border: 2px dashed var(--line); border-radius: calc(var(--radius) - 6px);
  background: var(--bg); cursor: pointer;
  transition: border-color .2s, background .2s;
}
.dropzone:hover, .dropzone.is-over { border-color: var(--accent); background: var(--accent-soft); }
.dropzone input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.dropzone:focus-within { border-color: var(--accent); }
.dz-icon { color: var(--accent); }
.dz-title { font-weight: 800; font-size: 1.15rem; }
.dz-sub { font-size: .88rem; color: var(--muted); }
.dz-btn { margin-top: .6rem; pointer-events: none; }

/* Engine loading */
.engine { display: none; padding: 1.4rem .5rem; text-align: center; }
.engine p { font-size: .92rem; color: var(--muted); margin-top: .7rem; }
.bar { height: 8px; background: var(--bg); border-radius: 99px; overflow: hidden; border: 1px solid var(--line); }
.bar span { display: block; height: 100%; width: 35%; background: var(--accent); border-radius: 99px; animation: indet 1.2s var(--ease-out) infinite; }
@keyframes indet { from { transform: translateX(-100%); } to { transform: translateX(300%); } }

/* Results */
.results { display: none; }
.results-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .6rem; margin-bottom: .7rem; }
.results-summary { font-weight: 700; }
.file-list { list-style: none; padding: 0; display: grid; gap: .5rem; max-height: 420px; overflow: auto; }
.file-row {
  display: grid; grid-template-columns: 52px 1fr auto; gap: .75rem; align-items: center;
  padding: .55rem; border: 1px solid var(--line); border-radius: 12px; background: var(--bg);
}
.thumb { width: 52px; height: 52px; border-radius: 8px; object-fit: cover; background: var(--line); }
.file-meta { min-width: 0; }
.file-name { font-weight: 700; font-size: .92rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-status { font-size: .82rem; color: var(--muted); }
.file-row[data-status="error"] .file-status { color: var(--warn); }
.file-row[data-status="done"] .file-status { color: var(--ok); }
.spinner { width: 22px; height: 22px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.link-reset { margin-top: .9rem; color: var(--accent); font-weight: 700; text-decoration: underline; text-underline-offset: 3px; padding: .4rem 0; }

/* Error */
.error-box { display: none; padding: 1.4rem .5rem; text-align: center; }
.error-msg { color: var(--warn); font-weight: 700; margin-bottom: .9rem; }

/* State machine */
.tool-card[data-state="loading-engine"] .dropzone,
.tool-card[data-state="working"] .dropzone,
.tool-card[data-state="done"] .dropzone,
.tool-card[data-state="error"] .dropzone,
.tool-card[data-state="error"] .tool-options { display: none; }
.tool-card[data-state="loading-engine"] .engine { display: block; }
.tool-card[data-state="working"] .results,
.tool-card[data-state="done"] .results { display: block; }
.tool-card[data-state="working"] .link-reset { visibility: hidden; }
.tool-card[data-state="error"] .error-box { display: block; }

.privacy-badge {
  display: flex; gap: .55rem; align-items: flex-start; margin-top: .9rem;
  font-size: .9rem; color: var(--ink);
}
.privacy-badge svg { color: var(--accent); flex: none; margin-top: 2px; }
.limits { font-size: .82rem; color: var(--muted); margin-top: .35rem; padding-left: 1.6rem; }

/* Ads (placeholders) */
.ad-slot {
  display: flex; align-items: center; justify-content: center;
  margin: 2rem 0; border: 1px dashed var(--line); border-radius: 12px;
  color: var(--muted); font-size: .75rem; letter-spacing: .08em; text-transform: uppercase;
}
.ad-leaderboard { min-height: 100px; }
.ad-incontent { min-height: 250px; }
/* Hidden while empty: shows automatically once the AdSense <ins> is pasted inside */
.ad-slot:not(:has(ins)) { display: none; }

/* =============================================================
   6. Sections
   ============================================================= */
.site-header { border-bottom: 1px solid var(--line); background: var(--surface); }
.header-inner { display: flex; align-items: center; justify-content: space-between; height: 56px; }
.logo { display: inline-flex; align-items: center; gap: .5rem; font-family: var(--display); font-weight: 800; font-size: 1.2rem; text-decoration: none; color: var(--ink); }
.logo svg { color: var(--accent); }
.logo b { color: var(--accent); }
.header-link { font-size: .9rem; font-weight: 600; color: var(--muted); text-decoration: none; }
.header-link:hover { color: var(--accent); }

.hero { padding: 1.1rem 0 .5rem; }
.subtitle { color: var(--muted); margin-top: .45rem; font-size: 1rem; max-width: 60ch; }

.section { padding: 1.5rem 0; }
.steps { list-style: none; padding: 0; display: grid; gap: 1rem; counter-reset: s; }
.steps li { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 1.1rem; }
.steps svg { color: var(--accent); }
.steps h3 { margin: .6rem 0 .25rem; }
.steps p { color: var(--muted); font-size: .95rem; }

.prose p, .prose ul { margin-bottom: .9rem; }
.prose ul { padding-left: 1.2rem; }
.prose li { margin-bottom: .4rem; }

.faq details { border-bottom: 1px solid var(--line); padding: .9rem 0; }
.faq summary { cursor: pointer; font-weight: 700; list-style: none; display: flex; justify-content: space-between; gap: 1rem; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; color: var(--accent); font-size: 1.3rem; line-height: 1; transition: transform .2s var(--ease-out); }
.faq details[open] summary::after { transform: rotate(45deg); }
.faq details p { margin-top: .5rem; color: var(--muted); }

.tools-grid { display: grid; gap: .75rem; }
.tool-link {
  display: flex; flex-direction: column; padding: 1rem; border-radius: 14px;
  border: 1px solid var(--line); background: var(--surface); text-decoration: none;
}
.tool-link span { font-size: .88rem; color: var(--muted); }
.tool-link.is-current { border-color: var(--accent); }
.tool-link.is-soon { opacity: .6; }

.site-footer { border-top: 1px solid var(--line); margin-top: 2rem; padding: 1.5rem 0 2rem; font-size: .85rem; color: var(--muted); }
.footer-inner { display: grid; gap: .6rem; }
.site-footer nav { display: flex; flex-wrap: wrap; gap: 1rem; }
.site-footer a { color: var(--ink); }
.credits { font-size: .78rem; }

/* Legal pages */
.legal { padding: 2rem 0; }
.legal h1 { margin-bottom: 1rem; }
.legal h2 { font-size: 1.25rem; margin: 1.6rem 0 .5rem; }
.legal p, .legal ul { margin-bottom: .8rem; }
.legal ul { padding-left: 1.2rem; }
.todo { background: #fff4ce; color: #5c4400; padding: 0 .3em; border-radius: 4px; }

/* =============================================================
   8. Responsive
   ============================================================= */
@media (min-width: 720px) {
  .hero { padding-top: 2.2rem; }
  .tool-card { padding: 1.4rem; }
  .dropzone { min-height: 240px; }
  .steps { grid-template-columns: repeat(3, 1fr); }
  .tools-grid { grid-template-columns: repeat(3, 1fr); }
}

/* =============================================================
   9. Reduced motion (only intrusive loops)
   ============================================================= */
@media (prefers-reduced-motion: reduce) {
  .bar span { animation-duration: 2.4s; }
}

/* =============================================================
   10. Multi-tool additions (compressor, JPG→PDF)
   ============================================================= */
.select {
  font: inherit; font-size: .9rem; font-weight: 600; color: var(--ink);
  background: var(--bg); border: 1px solid var(--line); border-radius: 999px;
  padding: .35rem 2rem .35rem .85rem; min-height: 36px; cursor: pointer;
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 15px) 52%, calc(100% - 10px) 52%;
  background-size: 5px 5px; background-repeat: no-repeat;
}
.opt.check { gap: .45rem; font-weight: 700; font-size: .9rem; cursor: pointer; }
.opt.check input { width: 18px; height: 18px; accent-color: var(--accent); }
.saving { color: var(--ok); font-weight: 800; }
.file-status b { color: var(--ink); }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.row-tools { display: flex; gap: .25rem; }
.icon-btn {
  width: 36px; height: 36px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface); font-weight: 800; display: inline-flex; align-items: center; justify-content: center;
}
.icon-btn:hover { border-color: var(--accent); color: var(--accent); }
.pdf-list .file-row:first-child [data-up], .pdf-list .file-row:last-child [data-down] { visibility: hidden; }
.pdf-actions { margin-top: .9rem; display: flex; }
.btn-big { width: 100%; min-height: 52px; font-size: 1.05rem; }
.tool-card[data-state="working"] .pdf-actions .btn { opacity: .6; }
.cross-sell { margin-top: .6rem; font-size: .88rem; color: var(--muted); }
.cross-sell a { color: var(--accent); font-weight: 700; }
@media (max-width: 539px) {
  .seg span { padding: .3rem .62rem; font-size: .86rem; }
}

/* =============================================================
   11. Content pages (guides, about, contact)
   ============================================================= */
.article { max-width: 720px; }
.article .lead { font-size: 1.12rem; color: var(--ink); margin-bottom: 1.2rem; }
.article-meta { font-size: .85rem; color: var(--muted); margin-bottom: .6rem; }
.article h2 { font-size: 1.35rem; margin: 2rem 0 .6rem; }
.article ol, .article ul { padding-left: 1.3rem; margin-bottom: 1rem; }
.article li { margin-bottom: .45rem; }
.article a:not(.btn) { color: var(--accent); font-weight: 600; }
.guide-cta { margin: 1.2rem 0 1.4rem; }
.guide-list { list-style: none; padding: 0 !important; display: grid; gap: .75rem; }
.guide-list a {
  display: flex; flex-direction: column; gap: .25rem; padding: 1rem 1.1rem;
  border: 1px solid var(--line); border-radius: 14px; background: var(--surface); text-decoration: none; color: var(--ink) !important;
}
.guide-list a:hover { border-color: var(--accent); }
.guide-list span { font-size: .9rem; color: var(--muted); font-weight: 400; }
.guide-list.compact a { padding: .8rem 1rem; }
.more-link { color: var(--accent); font-weight: 700; display: inline-block; margin-top: .6rem; }
.contact-box {
  display: flex; flex-direction: column; gap: .2rem; padding: 1.1rem 1.2rem; margin: 1rem 0 1.5rem;
  border: 1px solid var(--accent); border-radius: 14px; background: var(--accent-soft);
}
.contact-box span { font-size: .85rem; color: var(--muted); }
.contact-box a { font-size: 1.05rem; word-break: break-all; }
.table-wrap { overflow-x: auto; margin: .5rem 0 1.2rem; }
.article table { border-collapse: collapse; width: 100%; font-size: .92rem; min-width: 520px; }
.article th, .article td { border-bottom: 1px solid var(--line); padding: .55rem .6rem; text-align: left; }
.article th { color: var(--muted); font-weight: 700; }
.site-footer nav { row-gap: .4rem; }
