/* ==========================================================================
   svg2png.net — stylesheet
   Mobile-first, accessible, dark-themed. Uses CSS logical properties so the
   layout mirrors correctly for RTL languages (Arabic) with no duplicate rules.
   ========================================================================== */

:root {
  --bg: #0f1115;
  --surface: #161a20;
  --surface-2: #1d232c;
  --border: #2a303c;
  --text: #eef1f5;
  --text-muted: #9aa4b3;
  --accent: #5b8cff;
  --accent-strong: #3f6cf0;
  --accent-contrast: #ffffff;
  --success: #3ecf8e;
  --danger: #ff6b6b;
  --radius: 12px;
  --radius-sm: 8px;
  --container-w: 900px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", "Noto Sans SC", "Noto Sans Arial Hebrew", sans-serif;
}

* { box-sizing: border-box; }
html { color-scheme: dark; }

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; display: block; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.container {
  max-width: var(--container-w);
  margin-inline: auto;
  padding-inline: 20px;
}

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.skip-link {
  position: absolute;
  inset-inline-start: 8px;
  top: -48px;
  background: var(--accent);
  color: #fff;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  z-index: 1000;
  transition: top .15s ease;
}
.skip-link:focus { top: 8px; }

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

/* ---------- Header ---------- */
.site-header {
  border-bottom: 1px solid var(--border);
  background: rgba(15, 17, 21, .92);
  backdrop-filter: saturate(140%) blur(6px);
  position: sticky;
  top: 0;
  z-index: 50;
}
.site-header-inner {
  max-width: var(--container-w);
  margin-inline: auto;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 20px;
}
.brand { display: inline-flex; align-items: center; }
.brand-logo { height: 26px; width: auto; }

.main-nav {
  display: flex;
  gap: 18px;
  margin-inline-start: auto;
  font-size: .95rem;
}
.main-nav a { color: var(--text-muted); }
.main-nav a:hover, .main-nav a[aria-current="page"] { color: var(--text); text-decoration: none; }

.lang-switch { position: relative; }
.lang-switch summary {
  list-style: none;
  cursor: pointer;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 7px 12px;
  font-size: .9rem;
  display: flex;
  align-items: center;
  gap: 6px;
}
.lang-switch summary::-webkit-details-marker { display: none; }
.lang-switch summary::after { content: "▾"; font-size: .7em; color: var(--text-muted); }
.lang-switch[open] summary::after { content: "▴"; }
.lang-switch ul {
  position: absolute;
  inset-inline-end: 0;
  top: calc(100% + 6px);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  list-style: none;
  margin: 0;
  padding: 6px;
  max-height: 60vh;
  overflow-y: auto;
  min-width: 160px;
  box-shadow: 0 10px 30px rgba(0,0,0,.4);
}
.lang-switch li a {
  display: block;
  padding: 8px 10px;
  border-radius: 6px;
  color: var(--text);
  font-size: .9rem;
}
.lang-switch li a:hover { background: var(--surface); text-decoration: none; }
.lang-switch li a[aria-current="true"] { color: var(--accent); font-weight: 600; }

/* ---------- Tool shell ---------- */
.tool-shell { padding: 40px 0 24px; }
.tool-shell h1 {
  font-size: clamp(1.6rem, 1.2rem + 1.6vw, 2.4rem);
  margin: 0 0 8px;
}
.tagline {
  color: var(--text-muted);
  font-size: 1.05rem;
  margin: 0 0 28px;
  max-width: 60ch;
}

.converter {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.dropzone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 40px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s ease, background .15s ease;
}
.dropzone:hover, .dropzone:focus-visible { border-color: var(--accent); background: rgba(91,140,255,.06); }
.dropzone.is-dragover { border-color: var(--accent); background: rgba(91,140,255,.1); }
.dropzone-icon { margin: 0 auto 10px; color: var(--accent); }
.dropzone-title { font-size: 1.1rem; font-weight: 600; margin: 0 0 4px; }
.dropzone-sub { color: var(--text-muted); margin: 0 0 6px; }
.browse-link { color: var(--accent); font-weight: 600; }
.dropzone-formats { font-size: .82rem; color: var(--text-muted); margin: 0; }

.empty-hint {
  color: var(--text-muted);
  font-size: .92rem;
  text-align: center;
  margin: 14px 0 0;
}

.converter-error {
  margin: 14px 0 0;
  padding: 12px 14px;
  background: rgba(255,107,107,.12);
  border: 1px solid rgba(255,107,107,.4);
  color: #ffb3b3;
  border-radius: var(--radius-sm);
  font-size: .92rem;
}

.preview-wrap { margin-top: 18px; }
.preview-stage {
  background:
    linear-gradient(45deg, #20242c 25%, transparent 25%),
    linear-gradient(-45deg, #20242c 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #20242c 75%),
    linear-gradient(-45deg, transparent 75%, #20242c 75%);
  background-size: 20px 20px;
  background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
  background-color: #14171d;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-height: 220px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.preview-stage svg { max-width: 100%; max-height: 320px; }

.preview-meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 10px;
  flex-wrap: wrap;
}
.file-meta { color: var(--text-muted); font-size: .85rem; margin: 0; }

.btn-text {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font-size: .88rem;
  padding: 4px 0;
}
.btn-text:hover { text-decoration: underline; }

.tool-panel { margin-top: 22px; display: grid; gap: 22px; }
.panel-section h2 {
  font-size: .95rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-muted);
  margin: 0 0 12px;
}

.color-palette { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 12px; }
.palette-empty { color: var(--text-muted); font-size: .88rem; margin: 0 0 12px; }
.color-swatch-row {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 10px 4px 4px;
}
.color-swatch-input {
  width: 28px; height: 28px;
  border: none;
  border-radius: 50%;
  padding: 0;
  cursor: pointer;
  background: none;
}
.color-swatch-input::-webkit-color-swatch-wrapper { padding: 0; border-radius: 50%; }
.color-swatch-input::-webkit-color-swatch { border: 1px solid var(--border); border-radius: 50%; }
.color-swatch-label { font-size: .8rem; color: var(--text-muted); font-variant-numeric: tabular-nums; }

.btn-secondary, .btn-primary {
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  font-size: .92rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--border);
}
.btn-secondary { background: var(--surface-2); color: var(--text); }
.btn-secondary:hover { background: var(--border); }
.btn-primary {
  background: var(--accent);
  color: var(--accent-contrast);
  border-color: var(--accent);
  width: 100%;
  margin-top: 14px;
  padding: 12px 16px;
  font-size: 1rem;
}
.btn-primary:hover { background: var(--accent-strong); }
.btn-primary:disabled, .btn-secondary:disabled { opacity: .6; cursor: progress; }

.bg-swatches { display: flex; align-items: center; gap: 10px; }
.bg-swatch {
  width: 34px; height: 34px;
  border-radius: 50%;
  border: 2px solid var(--border);
  cursor: pointer;
  padding: 0;
  background-color: transparent;
}
.bg-swatch.checkerboard {
  background-image:
    linear-gradient(45deg, #444 25%, transparent 25%),
    linear-gradient(-45deg, #444 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #444 75%),
    linear-gradient(-45deg, transparent 75%, #444 75%);
  background-size: 10px 10px;
  background-position: 0 0, 0 5px, 5px -5px, -5px 0px;
  background-color: #1a1a1a;
}
.bg-swatch.is-active { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(91,140,255,.3); }
.bg-swatch-custom {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: .85rem;
  color: var(--text-muted);
  cursor: pointer;
}
.bg-swatch-custom input[type="color"] {
  width: 30px; height: 30px;
  border-radius: 50%;
  border: 2px solid var(--border);
  padding: 0;
  cursor: pointer;
  background: none;
}

.size-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 10px;
}
.size-preset-btn {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  text-align: start;
  cursor: pointer;
  color: var(--text);
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.size-preset-btn:hover { border-color: var(--accent); }
.size-preset-btn.is-busy { opacity: .6; cursor: progress; }
.size-name { font-weight: 600; font-size: .92rem; }
.size-dimensions { font-size: .78rem; color: var(--text-muted); font-variant-numeric: tabular-nums; }

.custom-size-row {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  align-items: end;
}
.custom-size-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: .82rem;
  color: var(--text-muted);
}
.custom-size-field input {
  width: 110px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 9px 10px;
  font-size: .95rem;
}
.lock-aspect {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: .85rem;
  color: var(--text-muted);
  padding-bottom: 9px;
}

.privacy-note {
  margin: 18px 0 0;
  font-size: .82rem;
  color: var(--text-muted);
  text-align: center;
}

/* ---------- Article ---------- */
.article { padding: 56px 0 8px; border-top: 1px solid var(--border); margin-top: 48px; }
.article-inner h2 { font-size: 1.5rem; margin: 0 0 14px; }
.article-inner h3 { font-size: 1.15rem; margin: 32px 0 10px; }
.article-inner p, .article-inner li { color: #cdd3dc; font-size: 1rem; }
.article-inner ul, .article-inner ol { padding-inline-start: 22px; }
.article-inner li { margin-bottom: 6px; }
.article-inner strong { color: var(--text); }

/* ---------- FAQ ---------- */
.faq-section { padding: 24px 0 60px; }
.faq-section h2 { font-size: 1.4rem; margin: 0 0 16px; }
.faq-list { display: grid; gap: 10px; }
.faq-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px 16px;
}
.faq-item summary {
  cursor: pointer;
  padding: 14px 0;
  font-weight: 600;
  list-style: none;
  display: flex;
  justify-content: space-between;
  gap: 12px;
}
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after { content: "+"; color: var(--accent); font-size: 1.2rem; flex: none; }
.faq-item[open] summary::after { content: "−"; }
.faq-item p { color: var(--text-muted); margin: 0 0 16px; }

/* ---------- Generic content pages (about / privacy / news) ---------- */
.page-content { padding: 48px 0 64px; }
.page-content h1 { font-size: clamp(1.6rem, 1.2rem + 1.4vw, 2.2rem); margin: 0 0 8px; }
.page-content .tagline { margin-bottom: 32px; }
.page-content h2 { font-size: 1.3rem; margin: 30px 0 10px; }
.page-content h3 { font-size: 1.1rem; margin: 24px 0 8px; }
.page-content p, .page-content li { color: #cdd3dc; }
.page-content ul { padding-inline-start: 22px; }

.news-post {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  margin-bottom: 18px;
}
.news-post h2 { margin-top: 0; }
.news-post .post-meta { color: var(--text-muted); font-size: .82rem; margin: 0 0 10px; }

/* ---------- Footer ---------- */
.site-footer { border-top: 1px solid var(--border); margin-top: 20px; }
.site-footer-inner {
  max-width: var(--container-w);
  margin-inline: auto;
  padding: 28px 20px;
  text-align: center;
}
.footer-nav { display: flex; justify-content: center; gap: 18px; flex-wrap: wrap; margin-bottom: 12px; }
.footer-nav a { color: var(--text-muted); font-size: .9rem; }
.footer-nav a:hover { color: var(--text); }
.footer-copy { color: #6b7280; font-size: .82rem; margin: 0; }

/* ---------- Responsive ---------- */
@media (max-width: 640px) {
  .site-header-inner { flex-wrap: wrap; }
  .main-nav { order: 3; width: 100%; margin-inline-start: 0; gap: 14px; }
  .dropzone { padding: 28px 14px; }
  .custom-size-field input { width: 100%; }
  .custom-size-row { width: 100%; }
}

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