/* ==========================================================================
   Design tokens — "Blueprint" system
   A technical-drafting aesthetic: grid paper, registration marks, stamped
   format badges. Fits a tool whose entire job is transforming one spec
   into another.
   ========================================================================== */
:root {
  --navy:        #0B1E33;
  --navy-light:  #12304F;
  --navy-lifted: #17395F;
  --line:        #2A4A6B;
  --line-soft:   rgba(122, 160, 199, 0.18);
  --paper:       #F4F7FA;
  --paper-dim:   #C7D3E0;
  --muted:       #7C93AD;
  --accent:      #FFC857;
  --accent-dim:  #A9822F;
  --success:     #6FCF97;
  --error:       #FF7A6E;

  --font-display: 'Space Grotesk', 'Arial Narrow', sans-serif;
  --font-body:    'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono:    'IBM Plex Mono', 'SFMono-Regular', Consolas, monospace;

  --radius: 3px;
  --max-width: 880px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--navy);
  background-image:
    linear-gradient(var(--line-soft) 1px, transparent 1px),
    linear-gradient(90deg, var(--line-soft) 1px, transparent 1px);
  background-size: 32px 32px;
  color: var(--paper);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--paper);
  margin: 0 0 0.5em;
}

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

code, .mono { font-family: var(--font-mono); }

.wrap {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 20px;
}

/* Registration marks — the signature motif. Corner crop-marks like a
   printed spec sheet, used to frame the primary tool card only. */
.reg-frame {
  position: relative;
  border: 1px solid var(--line);
  background: var(--navy-light);
  border-radius: var(--radius);
}
.reg-frame::before,
.reg-frame::after,
.reg-frame .reg-tl,
.reg-frame .reg-br {
  content: "";
  position: absolute;
  width: 14px;
  height: 14px;
  pointer-events: none;
}
.reg-frame::before { top: -1px; left: -1px; border-top: 2px solid var(--accent); border-left: 2px solid var(--accent); }
.reg-frame::after   { bottom: -1px; right: -1px; border-bottom: 2px solid var(--accent); border-right: 2px solid var(--accent); }

/* ---------- Header ---------- */
.site-header {
  border-bottom: 1px solid var(--line);
  background: rgba(11, 30, 51, 0.9);
  backdrop-filter: blur(6px);
  position: sticky;
  top: 0;
  z-index: 10;
}
.site-header .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
}
.logo {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--paper);
  display: flex;
  align-items: baseline;
  gap: 2px;
}
.logo span { color: var(--accent); }
.site-nav { display: flex; gap: 24px; }
.site-nav a { color: var(--paper-dim); font-size: 0.92rem; }
.site-nav a:hover { color: var(--paper); text-decoration: none; }

/* ---------- Breadcrumb ---------- */
.breadcrumb {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--muted);
  padding: 18px 0 0;
}
.breadcrumb a { color: var(--muted); }
.breadcrumb a:hover { color: var(--accent); }
.breadcrumb .sep { margin: 0 6px; opacity: 0.5; }

/* ---------- Tool header ---------- */
.tool-header { padding: 18px 0 28px; }
.tool-badge-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}
.fmt-badge {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--paper);
  background: var(--navy-lifted);
}
.fmt-arrow { color: var(--accent); font-family: var(--font-mono); font-size: 1rem; }
.tool-header h1 { font-size: clamp(1.6rem, 3vw, 2.1rem); }
.tool-header .lede { color: var(--paper-dim); max-width: 60ch; }

/* ---------- Dropzone / tool card ---------- */
.tool-card { padding: 28px; margin-bottom: 28px; }

.dropzone {
  border: 1.5px dashed var(--line);
  border-radius: var(--radius);
  padding: 40px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.dropzone:hover,
.dropzone:focus-visible,
.dropzone.drag-over {
  border-color: var(--accent);
  background: rgba(255, 200, 87, 0.05);
  outline: none;
}
.dropzone-icon { font-family: var(--font-mono); font-size: 1.6rem; color: var(--accent); margin-bottom: 10px; }
.dropzone-title { font-size: 1rem; font-weight: 600; color: var(--paper); margin-bottom: 4px; }
.dropzone-sub { font-size: 0.85rem; color: var(--muted); }
.dropzone input[type="file"] {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

/* ---------- Controls ---------- */
.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  align-items: flex-end;
  margin-top: 22px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
}
.control-field { display: flex; flex-direction: column; gap: 6px; }
.control-field label {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.control-field input[type="range"] { width: 180px; accent-color: var(--accent); }
.control-value { font-family: var(--font-mono); color: var(--paper); font-size: 0.85rem; }

.btn {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.92rem;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: var(--navy);
  padding: 11px 22px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: opacity 0.15s ease;
}
.btn:hover { opacity: 0.88; }
.btn:disabled { opacity: 0.35; cursor: not-allowed; }
.btn-ghost {
  background: transparent;
  color: var(--paper);
  border-color: var(--line);
}
.btn-ghost:hover { border-color: var(--paper-dim); }
.btn:focus-visible, .dropzone:focus-visible, a:focus-visible, input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------- File list / results ---------- */
.file-list { margin-top: 20px; display: flex; flex-direction: column; gap: 10px; }
.file-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  background: var(--navy);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 0.88rem;
}
.file-row .fthumb {
  width: 36px;
  height: 36px;
  border-radius: var(--radius);
  object-fit: cover;
  border: 1px solid var(--line);
  flex-shrink: 0;
  background: var(--navy);
}
.file-row .fname { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--paper); }
.file-row .fsize { font-family: var(--font-mono); color: var(--muted); font-size: 0.78rem; }
.file-row .fstatus { font-family: var(--font-mono); font-size: 0.78rem; }
.file-row .fstatus.ok { color: var(--success); }
.file-row .fstatus.err { color: var(--error); }
.file-row .fstatus.pending { color: var(--muted); }
.file-row .fstatus.active { color: var(--accent); }
.file-row .fremove:disabled { color: var(--line); cursor: not-allowed; }
.file-row .fdims { font-family: var(--font-mono); font-size: 0.78rem; color: var(--muted); white-space: nowrap; }

/* ---------- Resize mode toggle + field groups (Image Resizer) ---------- */
.resize-mode-toggle {
  display: flex;
  gap: 2px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 3px;
  width: fit-content;
}
.mode-btn {
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 600;
  border: none;
  background: transparent;
  color: var(--paper-dim);
  padding: 7px 14px;
  border-radius: 2px;
  cursor: pointer;
}
.mode-btn.active { background: var(--accent); color: var(--navy); }
.mode-btn:not(.active):hover { color: var(--paper); }
.control-field-group { display: flex; flex-wrap: wrap; gap: 20px; align-items: flex-end; }
.control-field-checkbox label { display: flex; align-items: center; gap: 8px; font-family: var(--font-body); font-size: 0.88rem; color: var(--paper); text-transform: none; letter-spacing: normal; }
.control-field input[type="number"] {
  width: 110px;
  background: var(--navy);
  border: 1px solid var(--line);
  color: var(--paper);
  border-radius: var(--radius);
  padding: 8px 10px;
  font-family: var(--font-mono);
  font-size: 0.9rem;
}
.control-field input[type="number"]:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.output-preview {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--accent);
  width: 100%;
}
.output-preview.warn { color: var(--error); }

/* ---------- Pill-style button group (Image Cropper aspect ratios) ---------- */
.pill-group { display: flex; flex-wrap: wrap; gap: 6px; }
.pill-group .mode-btn { border: 1px solid var(--line); }
.pill-group .mode-btn.active { border-color: var(--accent); }

/* ---------- Interactive crop stage (Image Cropper) ---------- */
.crop-stage { width: 100%; }
.crop-image-wrap {
  position: relative;
  display: inline-block;
  max-width: 100%;
  line-height: 0;
  background:
    linear-gradient(45deg, #0e2033 25%, transparent 25%, transparent 75%, #0e2033 75%),
    linear-gradient(45deg, #0e2033 25%, transparent 25%, transparent 75%, #0e2033 75%);
  background-size: 16px 16px;
  background-position: 0 0, 8px 8px;
}
.crop-image-wrap img {
  display: block;
  max-width: 100%;
  max-height: 420px;
  width: auto;
  height: auto;
  user-select: none;
  pointer-events: none;
}
.crop-box {
  position: absolute;
  border: 2px solid var(--accent);
  /* Huge spread box-shadow dims everything outside the box, over the
     image, without needing a second canvas just for the mask. */
  box-shadow: 0 0 0 9999px rgba(11, 30, 51, 0.6);
  cursor: move;
  touch-action: none;
  box-sizing: border-box;
}
.crop-box:focus-visible { outline: 2px solid var(--paper); outline-offset: 2px; }
.crop-handle {
  position: absolute;
  width: 14px;
  height: 14px;
  background: var(--accent);
  border: 2px solid var(--navy);
  border-radius: 50%;
  touch-action: none;
}
.crop-handle[data-handle="nw"] { top: -7px; left: -7px; cursor: nwse-resize; }
.crop-handle[data-handle="ne"] { top: -7px; right: -7px; cursor: nesw-resize; }
.crop-handle[data-handle="sw"] { bottom: -7px; left: -7px; cursor: nesw-resize; }
.crop-handle[data-handle="se"] { bottom: -7px; right: -7px; cursor: nwse-resize; }
.crop-dims { font-family: var(--font-mono); font-size: 0.85rem; color: var(--paper); width: 100%; }

/* ---------- Rotate preview (Image Rotator) ---------- */
.rotate-preview-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 180px;
  padding: 20px;
  width: 100%;
}
.rotate-preview-wrap img {
  max-width: 200px;
  max-height: 160px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  transition: transform 0.25s ease;
  background:
    linear-gradient(45deg, #0e2033 25%, transparent 25%, transparent 75%, #0e2033 75%),
    linear-gradient(45deg, #0e2033 25%, transparent 25%, transparent 75%, #0e2033 75%);
  background-size: 16px 16px;
  background-position: 0 0, 8px 8px;
}
.file-row .fremove {
  background: none; border: none; color: var(--muted); cursor: pointer;
  font-size: 1rem; line-height: 1; padding: 2px 4px;
}
.file-row .fremove:hover { color: var(--error); }

.progress-track {
  height: 6px;
  background: var(--navy);
  border: 1px solid var(--line);
  border-radius: 3px;
  overflow: hidden;
  margin-top: 16px;
  display: none;
}
.progress-track.active { display: block; }
.progress-fill { height: 100%; background: var(--accent); width: 0%; transition: width 0.2s ease; }
.progress-label { font-family: var(--font-mono); font-size: 0.78rem; color: var(--muted); margin-top: 6px; }

.error-msg {
  margin-top: 16px;
  padding: 12px 14px;
  border: 1px solid var(--error);
  border-radius: var(--radius);
  background: rgba(255, 122, 110, 0.08);
  color: var(--error);
  font-size: 0.88rem;
  display: none;
}
.error-msg.active { display: block; }

.privacy-note {
  margin-top: 20px;
  font-size: 0.82rem;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 8px;
}
.privacy-note .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--success); flex-shrink: 0; }

/* ---------- Content sections ---------- */
.section { padding: 36px 0; border-top: 1px solid var(--line-soft); }
.section h2 { font-size: 1.3rem; }
.section p { color: var(--paper-dim); }

.how-steps { list-style: none; margin: 0; padding: 0; counter-reset: step; }
.how-steps li {
  counter-increment: step;
  padding: 10px 0 10px 40px;
  position: relative;
  color: var(--paper-dim);
  border-bottom: 1px solid var(--line-soft);
}
.how-steps li:last-child { border-bottom: none; }
.how-steps li::before {
  content: counter(step);
  position: absolute;
  left: 0; top: 8px;
  width: 24px; height: 24px;
  border: 1px solid var(--accent);
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
}

.faq-item { border-bottom: 1px solid var(--line-soft); padding: 14px 0; }
.faq-item summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--paper);
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after { content: "+"; font-family: var(--font-mono); color: var(--accent); font-size: 1.1rem; }
.faq-item[open] summary::after { content: "\2212"; }
.faq-item p { margin-top: 10px; }

.related-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 10px;
}
.related-grid a {
  display: block;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--paper-dim);
  font-family: var(--font-mono);
  font-size: 0.82rem;
  transition: border-color 0.15s ease, color 0.15s ease;
}
.related-grid a:hover { border-color: var(--accent); color: var(--paper); text-decoration: none; }

/* ---------- Footer ---------- */
.site-footer {
  border-top: 1px solid var(--line);
  margin-top: 40px;
  padding: 28px 0 40px;
  color: var(--muted);
  font-size: 0.82rem;
}
.site-footer .wrap { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 16px; }
.site-footer a { color: var(--muted); margin-right: 16px; }
.site-footer a:hover { color: var(--paper); }

/* ---------- Motion ---------- */
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; scroll-behavior: auto !important; }
}

/* ---------- Mobile ---------- */
@media (max-width: 640px) {
  .site-nav { display: none; }
  .tool-card { padding: 20px 16px; }
  .controls { flex-direction: column; align-items: stretch; }
  .control-field input[type="range"] { width: 100%; }
}

/* ==========================================================================
   Homepage-only components
   Scoped under home- prefixes so nothing here can collide with or affect
   any existing converter/tool page — those pages don't reference these
   classes and are unaffected by anything below.
   ========================================================================== */

.home-hero { padding: 56px 0 40px; text-align: center; }
.home-hero .fmt-badge { margin: 0 3px; }
.home-hero-badges { display: flex; justify-content: center; flex-wrap: wrap; gap: 8px; margin-bottom: 20px; }
.home-hero h1 {
  font-size: clamp(2rem, 5vw, 2.9rem);
  max-width: 18ch;
  margin: 0 auto 16px;
}
.home-hero .lede {
  color: var(--paper-dim);
  max-width: 62ch;
  margin: 0 auto 28px;
  font-size: 1.05rem;
}
.home-hero-ctas { display: flex; justify-content: center; gap: 14px; flex-wrap: wrap; margin-bottom: 32px; }
.home-trust-row {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px 22px;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--muted);
}
.home-trust-row span { display: flex; align-items: center; gap: 7px; }
.home-trust-row .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--success); flex-shrink: 0; }

.home-search-wrap { padding: 8px 0 40px; }
.home-search {
  width: 100%;
  background: var(--navy-light);
  border: 1px solid var(--line);
  color: var(--paper);
  border-radius: var(--radius);
  padding: 13px 16px;
  font-family: var(--font-body);
  font-size: 0.95rem;
}
.home-search::placeholder { color: var(--muted); }
.home-search:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.home-search-meta {
  margin-top: 10px;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--muted);
}
.home-search-empty {
  display: none;
  margin-top: 16px;
  padding: 14px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  color: var(--muted);
  font-size: 0.88rem;
  text-align: center;
}
.home-search-empty.active { display: block; }

.home-section-head { margin-bottom: 20px; }
.home-section-head h2 { margin-bottom: 6px; }
.home-section-head p { color: var(--paper-dim); margin: 0; max-width: 60ch; }

.tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
}
.tool-card-mini {
  display: block;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--navy-light);
  transition: border-color 0.15s ease, transform 0.15s ease;
}
.tool-card-mini:hover {
  border-color: var(--accent);
  text-decoration: none;
  transform: translateY(-2px);
}
.tool-card-mini .tool-badge-row { margin-bottom: 10px; }
.tool-card-mini .fmt-badge { font-size: 0.72rem; padding: 3px 8px; }
.tool-card-mini .fmt-arrow { font-size: 0.85rem; }
.tool-card-mini h3 {
  font-size: 0.98rem;
  color: var(--paper);
  margin: 0 0 6px;
}
.tool-card-mini p {
  color: var(--paper-dim);
  font-size: 0.84rem;
  margin: 0;
  line-height: 1.5;
}
.tool-card-mini[hidden] { display: none; }

.home-feature-banner {
  padding: 26px;
  margin-top: 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  align-items: center;
  justify-content: space-between;
}
.home-feature-banner .home-feature-copy { flex: 1; min-width: 240px; }
.home-feature-banner h2 { font-size: 1.15rem; margin-bottom: 8px; }
.home-feature-banner p { color: var(--paper-dim); margin: 0; max-width: 55ch; }
.home-feature-links { display: flex; gap: 10px; flex-wrap: wrap; }

.home-privacy-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
  margin-top: 18px;
}
.home-privacy-item {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--navy-light);
}
.home-privacy-item h3 { font-size: 0.95rem; margin: 0 0 8px; color: var(--paper); }
.home-privacy-item p { color: var(--paper-dim); font-size: 0.85rem; margin: 0; }

@media (max-width: 640px) {
  .home-hero { padding: 40px 0 28px; }
  .home-hero-ctas .btn { width: 100%; }
  .tool-grid { grid-template-columns: 1fr; }
  .home-feature-banner { padding: 20px 16px; }
}
