/* Global Styles & Theme */
:root {
  --bg: #ffffff;
  --text: #111111;
  --muted: #555555;
  --border: #e5e7eb;
  --accent: #e53935; /* Inspired by iLovePDF red */
  --accent-dark: #c62828;
  --accent-soft: #ffe5e5;
  --radius-sm: 6px;
  --radius: 12px;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06);
  --shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
  --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
  box-sizing: border-box;
}
body {
  margin: 0;
  font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, Arial,
    sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}
@media (max-width: 640px) {
  body {
    font-size: 15px;
  }
  .site-navbar .nav-inner {
    padding: 0.65rem 0.85rem;
  }
  main.feature,
  main {
    padding: 2rem 0.9rem;
  }
  .card {
    padding: 1.4rem 1.2rem;
  }
  .controls {
    gap: 0.55rem;
  }
  .upload-box {
    padding: 1.4rem 1.1rem;
  }
  .toolbar {
    flex-direction: column;
    align-items: stretch;
  }
  .page-thumb {
    width: 88px;
    height: 118px;
    font-size: 0.7rem;
  }
  .actions-row button {
    flex: 1 1 100%;
  }
}

/* Navbar */
.site-navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: #fff;
  border-bottom: 1px solid var(--border);
  backdrop-filter: saturate(180%) blur(6px);
  animation: navReveal 0.5s ease;
}
.site-navbar .nav-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0.75rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.brand {
  font-weight: 700;
  font-size: 1.25rem;
  letter-spacing: 0.5px;
  text-decoration: none;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 0.35rem;
}
.brand-logo {
  width: 40px;
  height: 40px;
  object-fit: contain;
}
.brand-text {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}
.brand-dot {
  font-weight: 400;
  color: var(--accent);
}
.nav-toggle {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 0.55rem 0.75rem;
  font-size: 1.1rem;
  line-height: 1;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: none;
}
.nav-links {
  display: flex;
  gap: 1.4rem;
  align-items: center;
}
.nav-links a {
  position: relative;
  text-decoration: none;
  color: var(--text);
  font-weight: 500;
  font-size: 0.95rem;
  padding: 0.35rem 0.15rem;
}
.nav-links a:after {
  content: "";
  position: absolute;
  left: 0;
  bottom: -4px;
  height: 2px;
  width: 0;
  background: var(--accent);
  transition: var(--transition);
}
.nav-links a:hover:after,
.nav-links a.active:after {
  width: 100%;
}

@media (max-width: 820px) {
  .nav-toggle {
    display: block;
  }
  .nav-links {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #fff;
    flex-direction: column;
    padding: 0.75rem 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow);
    opacity: 0;
    pointer-events: none;
    transform: translateY(-10px);
    transition: var(--transition);
  }
  .nav-links.open {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
  }
  .nav-links a {
    width: 100%;
    padding: 0.6rem 0.5rem;
    border-radius: var(--radius-sm);
  }
  .nav-links a:hover {
    background: var(--accent-soft);
  }
}

/* Footer */
.site-footer {
  background: #fff;
  border-top: 1px solid var(--border);
  margin-top: 3rem;
}
.site-footer .footer-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 2rem 1.25rem;
  text-align: center;
  font-size: 0.9rem;
  color: var(--muted);
}
.site-footer a {
  color: var(--accent-dark);
  text-decoration: none;
}
.site-footer a:hover {
  text-decoration: underline;
}
.disclaimer {
  margin-top: 0.75rem;
  font-size: 0.75rem;
  opacity: 0.8;
}

/* Cookie Banner */
.cookie-banner {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  background: #111;
  color: #fff;
  padding: 0.85rem 1rem;
  display: flex;
  gap: 1rem;
  justify-content: center;
  flex-wrap: wrap;
  font-size: 0.75rem;
  z-index: 200;
  animation: slideUp 0.6s ease;
}
.cookie-banner a {
  color: #ffb3b3;
}
.cookie-banner button {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 0.55rem 0.9rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.cookie-banner button:hover {
  background: var(--accent-dark);
}

@keyframes slideUp {
  from {
    transform: translateY(20px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* Cards / Tools */
.tools {
  display: grid;
  gap: 1.5rem;
  animation: none;
}
.tool {
  position: relative;
  overflow: hidden;
  transition: var(--transition);
  opacity: 0;
  animation: fadeIn 0.7s ease forwards;
}
.tool:before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    120deg,
    rgba(229, 57, 53, 0.08),
    rgba(198, 40, 40, 0.08)
  );
  opacity: 0;
  transition: var(--transition);
}
.tool:hover {
  transform: translateY(-6px);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.14);
}
.tool:hover:before {
  opacity: 1;
}
.tool-icon {
  transition: var(--transition);
  transform-origin: 50% 55%;
}
.tool:hover .tool-icon {
  transform: scale(1.18) rotate(-4deg);
}
/* Stagger */
.tools .tool:nth-child(1) {
  animation-delay: 0.05s;
}
.tools .tool:nth-child(2) {
  animation-delay: 0.1s;
}
.tools .tool:nth-child(3) {
  animation-delay: 0.15s;
}
.tools .tool:nth-child(4) {
  animation-delay: 0.2s;
}
.tools .tool:nth-child(5) {
  animation-delay: 0.25s;
}
.tools .tool:nth-child(6) {
  animation-delay: 0.3s;
}
.tools .tool:nth-child(7) {
  animation-delay: 0.35s;
}
.tools .tool:nth-child(8) {
  animation-delay: 0.4s;
}
.tools .tool:nth-child(9) {
  animation-delay: 0.45s;
}
.tools .tool:nth-child(10) {
  animation-delay: 0.5s;
}
.tools .tool:nth-child(11) {
  animation-delay: 0.55s;
}
.tools .tool:nth-child(12) {
  animation-delay: 0.6s;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Ad slot placeholders */
.ad-slot,
.ad-banner,
.ad-box {
  background: #f5f5f5;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  color: #777;
}

/* Additional placement styles for auto-inserted ads */
.ad-in-article {
  margin: 1rem 0 1.25rem;
  min-height: 90px;
}
.ad-below-tool {
  margin: 1.25rem 0 0;
  min-height: 90px;
}
.ad-mid {
  margin: 1.75rem 0;
  min-height: 90px;
}
.feature-blog .ad-inline-top {
  margin: 0.75rem 0 1rem;
  min-height: 70px;
}
.feature-blog .ad-after-explainer {
  margin: 1.25rem 0 1.1rem;
  min-height: 80px;
}
.ad-after-blog {
  margin: 2rem 0 0;
  min-height: 90px;
}
.ad-after-tools {
  margin: 2rem 0 1.5rem;
  min-height: 90px;
}
.ad-bottom-main {
  margin: 2.4rem 0 0;
  min-height: 90px;
}

/* --- Feature Blog Styles --- */
.feature-blog {
  margin-top: 3rem;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: #fff;
  padding: 2rem 1.5rem;
  box-shadow: var(--shadow-sm);
  animation: fadeIn 0.5s ease;
}
.feature-blog .blog-title {
  font-size: 1.35rem;
  margin: 0 0 1rem;
  font-weight: 600;
  letter-spacing: 0.4px;
}
.feature-blog p {
  line-height: 1.55;
}
.feature-blog ol.blog-steps {
  counter-reset: step;
  list-style: none;
  margin: 1rem 0 1.4rem;
  padding: 0;
}
.feature-blog ol.blog-steps li {
  position: relative;
  padding: 0.65rem 0.75rem 0.65rem 3rem;
  background: #fafafa;
  border: 1px solid #eee;
  border-radius: 12px;
  margin-bottom: 0.6rem;
  font-size: 0.92rem;
}
.feature-blog ol.blog-steps li:before {
  counter-increment: step;
  content: counter(step);
  position: absolute;
  left: 0.85rem;
  top: 50%;
  transform: translateY(-50%);
  width: 1.9rem;
  height: 1.9rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  border-radius: 50%;
  font-size: 0.85rem;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}
.feature-blog h4 {
  margin: 1.6rem 0 0.7rem;
  font-size: 1.05rem;
  letter-spacing: 0.3px;
}
.feature-blog .blog-figures {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  margin-top: 0.5rem;
}
.feature-blog .img-placeholder {
  background: linear-gradient(135deg, #f0f0f0, #e2e2e2);
  border: 1px solid #ddd;
  border-radius: 12px;
  height: 110px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 600;
  color: #666;
}
.feature-blog .blog-figures img {
  width: 100%;
  height: auto;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  box-shadow: var(--shadow-sm);
  background: #fff;
}
.feature-blog .blog-figures .ad-slot {
  min-height: 90px;
  align-self: center;
  justify-self: center;
  width: 100%;
}
.feature-blog .ad-slot + .fig,
.feature-blog .fig + .ad-slot {
  margin-top: 0;
}
.feature-blog figure {
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.feature-blog figcaption {
  font-size: 0.7rem;
  color: #666;
}
.feature-blog .blog-tips ul {
  list-style: disc;
  margin: 0.4rem 0 0.2rem 1.2rem;
  padding: 0;
}
.feature-blog details {
  border: 1px solid #eee;
  border-radius: 12px;
  padding: 0.75rem 1rem;
  background: #fafafa;
  margin-bottom: 0.55rem;
}
.feature-blog details[open] {
  background: #fff;
}
.feature-blog details summary {
  cursor: pointer;
  font-weight: 600;
}
.feature-blog .blog-ads {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  margin: 1.2rem 0 1.4rem;
}
.feature-blog .blog-ads .ad-slot {
  min-height: 70px;
  font-size: 0.7rem;
}
/* Comfortable spacing around inline ads */
.feature-blog .ad-slot {
  background: #f9f9f9;
  margin: 0.25rem 0;
}
@media (max-width: 640px) {
  .feature-blog {
    padding: 1.4rem 1rem;
  }
  .feature-blog ol.blog-steps li {
    padding: 0.6rem 0.65rem 0.6rem 2.6rem;
  }
  .feature-blog ol.blog-steps li:before {
    left: 0.55rem;
  }
}

/* Utility */
.fade-in {
  animation: fadeIn 0.6s ease;
}
.shadow-sm {
  box-shadow: var(--shadow-sm);
}

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

@keyframes navReveal {
  from {
    transform: translateY(-20px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* Scrollbar (WebKit) */
::-webkit-scrollbar {
  width: 10px;
}
::-webkit-scrollbar-track {
  background: #fafafa;
}
::-webkit-scrollbar-thumb {
  background: #ccc;
  border-radius: 20px;
}
::-webkit-scrollbar-thumb:hover {
  background: #bbb;
}

/* --- Feature Page Shared Styles --- */
main.feature {
  max-width: 900px;
  margin: 3rem auto;
  padding: 1rem;
}
.card {
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 2rem;
  background: #fff;
  box-shadow: var(--shadow-sm);
  animation: fadeIn 0.5s ease;
}
.form-grid {
  display: grid;
  gap: 1rem;
  align-items: center;
}
.form-grid.cols-2 {
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}
.form-grid.cols-3 {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}
.inline-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
}
.inline-actions > * {
  flex: 1 1 auto;
}
.upload-box {
  border: 2px dashed #ccc;
  border-radius: 12px;
  padding: 2rem;
  margin-top: 0.5rem;
  cursor: pointer;
  text-align: center;
  transition: var(--transition);
}
.upload-box:hover {
  background: #f8faff;
}
.upload-box.dragover {
  border-color: var(--accent);
  background: #fff;
}
.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  justify-content: center;
  align-items: center;
  margin-top: 0.75rem;
}
label,
input,
select,
button {
  font-size: 1rem;
}
input[type="text"],
input[type="number"],
input[type="password"],
select {
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 0.6rem 0.9rem;
}
button.primary {
  background: linear-gradient(90deg, var(--accent), var(--accent-dark));
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 0.85rem 1.6rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}
button.primary:hover {
  opacity: 0.9;
}
.progress {
  margin-top: 1rem;
  min-height: 1.3rem;
  color: var(--muted);
  text-align: center;
}

/* Paper-like preview surfaces */
.page-thumb,
.page-surface {
  position: relative;
  background: radial-gradient(
      1200px 400px at -10% -10%,
      rgba(0, 0, 0, 0.05),
      transparent 35%
    ),
    radial-gradient(
      800px 300px at 110% 110%,
      rgba(0, 0, 0, 0.04),
      transparent 40%
    ),
    linear-gradient(#fff, #fff);
  border: 1px solid #eee;
  border-radius: 8px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06), 0 8px 24px rgba(0, 0, 0, 0.05);
}
.page-thumb {
  display: flex;
  align-items: center;
  justify-content: center;
  color: #555;
  font-weight: 600;
  width: 110px;
  height: 140px;
  cursor: pointer;
  transition: var(--transition);
}
.page-thumb:hover {
  background-color: var(--accent-soft);
  border-color: var(--accent);
}
.page-thumb.active {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.canvas-wrap canvas.page-surface {
  background: #fff;
}
/* Responsive canvas/images */
canvas,
img {
  max-width: 100%;
  height: auto;
}
@media (max-width: 640px) {
  .work-area {
    flex-direction: column;
  }
  .right {
    width: 100%;
    order: -1;
  }
  .form-grid.cols-2,
  .form-grid.cols-3 {
    grid-template-columns: 1fr;
  }
  .inline-actions {
    flex-direction: column;
  }
}

/* Inner feature card subtle entrance */
.feature-enter {
  animation: fadeIn 0.6s ease, floatUp 0.6s ease;
}
@keyframes floatUp {
  from {
    transform: translateY(8px);
  }
  to {
    transform: translateY(0);
  }
}

/* Sticky mobile action bar */
.sticky-actions {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 0.65rem 1rem calc(0.65rem + env(safe-area-inset-bottom));
  background: rgba(255, 255, 255, 0.98);
  border-top: 1px solid var(--border);
  box-shadow: 0 -8px 20px rgba(0, 0, 0, 0.08);
  display: none;
  gap: 0.6rem;
  z-index: 140;
  backdrop-filter: saturate(160%) blur(6px);
}
.sticky-actions .primary {
  flex: 1 1 50%;
}
.sticky-actions.show {
  display: flex;
}
@media (min-width: 761px) {
  .sticky-actions {
    display: none !important;
  }
}

/* Feature Blog Logo Styling */
.title-with-logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}
.feature-blog .brand-logo {
  width: 50px;
  height: 50px;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}
.feature-blog h3 {
  margin: 0;
  flex: 1;
}
