/* ── Image Tools — page & tool styles ──────────────────────────────
   Builds on css/shared.css design tokens (:root). LK Forge brand family
   (Orbitron display + Outfit body + JetBrains Mono numerics), with a
   rose accent (#e11d48). 100% client-side — no upload, no network calls. */

main { max-width: 860px; margin: 0 auto; padding: 20px; }

/* ── Tool hero (icon + title + subtitle) ───────────────────────── */
.tool-hero { max-width: 860px; margin: 0 auto; padding: 36px 20px 4px; }
.tool-hero .hero-head { display: flex; align-items: center; gap: 16px; }
.tool-hero .hero-icon {
  flex-shrink: 0; width: 56px; height: 56px; border-radius: 14px;
  background: var(--accent); display: flex; align-items: center; justify-content: center;
}
.tool-hero .hero-icon svg { width: 30px; height: 30px; stroke: #fff; fill: none; }
.tool-hero h1 { font-family: 'Orbitron', sans-serif; font-size: clamp(1.55rem, 4.2vw, 2.2rem); font-weight: 900; letter-spacing: -.5px; line-height: 1.2; }
.tool-hero .subtitle { color: var(--muted); font-size: 1.02rem; margin-top: 12px; max-width: 680px; }

/* ── Tool card ─────────────────────────────────────────────────── */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow); padding: 24px; margin-top: 24px; }
.card + .card { margin-top: 16px; }

/* ── Labels ────────────────────────────────────────────────────── */
.field-label { display: block; font-size: .82rem; font-weight: 700; color: var(--text); margin-bottom: 7px; }
.field-label .hint { font-weight: 500; color: var(--muted); }

/* ── Buttons ───────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 11px 22px;
  font-family: inherit; font-size: .98rem; font-weight: 700;
  border: none; border-radius: var(--radius); cursor: pointer;
  background: var(--accent); color: #fff;
  transition: background .15s, transform .1s, opacity .15s;
  white-space: nowrap; text-decoration: none;
}
.btn:hover { background: var(--accent-h); text-decoration: none; }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn svg { width: 16px; height: 16px; }
.btn-ghost { background: var(--surface); color: var(--text); border: 1.5px solid var(--border); }
.btn-ghost:hover { background: var(--surface2); border-color: var(--muted); }

.action-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }

/* ── Drop zone ─────────────────────────────────────────────────── */
.dropzone {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  text-align: center; cursor: pointer; min-height: 150px; padding: 28px 20px;
  border: 2px dashed var(--border); border-radius: var(--radius-lg);
  background: var(--surface2); color: var(--muted);
  transition: border-color .15s, background .15s, color .15s;
}
.dropzone:hover, .dropzone:focus-visible { border-color: var(--accent); color: var(--accent-fg); outline: none; }
.dropzone.drag { border-color: var(--accent); background: var(--accent-bg); color: var(--accent-fg); }
.dropzone .drop-icon { width: 40px; height: 40px; stroke: var(--accent); fill: none; }
.dropzone .drop-title { font-size: 1rem; font-weight: 700; color: var(--text); }
.dropzone .drop-hint { font-size: .85rem; }

/* ── Source-image meta grid ────────────────────────────────────── */
.meta-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 12px; margin-top: 16px; }
.meta-item { display: flex; flex-direction: column; gap: 2px; }
.meta-item .m-label { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.meta-item .m-val { font-family: 'JetBrains Mono', monospace; font-size: .9rem; font-weight: 600; color: var(--text); word-break: break-word; }

/* Source-file card header with the "Clear image" control (returns the tool to its
   blank first-load state). Shown only while an image is loaded. */
.src-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 16px; }
.src-head-label { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.src-meta .meta-grid { margin-top: 12px; }
.clear-btn { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; font-family: inherit; font-size: .82rem; font-weight: 600; color: var(--muted); background: var(--surface); border: 1.5px solid var(--border); border-radius: var(--radius); cursor: pointer; transition: background .15s, color .15s, border-color .15s; }
.clear-btn:hover { color: var(--accent); border-color: var(--accent); background: var(--surface2); }
.clear-btn svg { width: 14px; height: 14px; stroke: currentColor; fill: none; }

hr.rule { border: none; border-top: 1px solid var(--border); margin: 18px 0; }

/* ── Dimension inputs (resizer) ────────────────────────────────── */
.dim-grid { display: grid; grid-template-columns: 1fr auto 1fr; align-items: end; gap: 12px; }
.dim-col { display: flex; flex-direction: column; gap: 7px; min-width: 0; }
.dim-num {
  width: 100%; font-family: 'JetBrains Mono', monospace; font-size: 1rem;
  padding: 13px 14px; border: 1.5px solid var(--border); border-radius: var(--radius);
  background: var(--surface); color: var(--text); outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.dim-num:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(225,29,72,.14); }
.lock-btn {
  flex-shrink: 0; width: 44px; height: 44px; align-self: end; margin-bottom: 1px;
  display: flex; align-items: center; justify-content: center; cursor: pointer;
  background: var(--surface); color: var(--muted);
  border: 1.5px solid var(--border); border-radius: 50%;
  transition: background .15s, border-color .15s, color .15s;
}
.lock-btn svg { width: 18px; height: 18px; stroke: currentColor; fill: none; }
.lock-btn.locked { color: var(--accent); border-color: var(--accent); background: var(--accent-bg); }

/* Resize-mode toggle + preset chips (reused for compressor formats) */
.seg { display: inline-flex; padding: 3px; gap: 3px; background: var(--surface2); border: 1px solid var(--border); border-radius: 999px; margin-bottom: 16px; }
.seg-btn { font-family: inherit; font-size: .86rem; font-weight: 700; cursor: pointer; padding: 8px 16px; min-height: 38px; color: var(--muted); background: transparent; border: none; border-radius: 999px; transition: background .15s, color .15s; }
.seg-btn.active { background: var(--surface); color: var(--accent-fg); box-shadow: var(--shadow); }

.preset-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.preset-chip {
  font-family: 'JetBrains Mono', monospace; font-size: .8rem; font-weight: 600; cursor: pointer;
  min-height: 36px; padding: 7px 13px; color: var(--text);
  background: var(--surface); border: 1.5px solid var(--border); border-radius: var(--radius);
  transition: border-color .15s, background .15s, transform .1s;
}
.preset-chip:hover { border-color: var(--accent); background: var(--accent-bg); transform: translateY(-1px); }

/* ── Quality slider (compressor) ───────────────────────────────── */
.range-row { display: flex; align-items: center; gap: 14px; margin: 4px 0; }
.range-row input[type=range] { flex: 1; accent-color: var(--accent); height: 28px; cursor: pointer; }
.range-row .range-val { font-family: 'JetBrains Mono', monospace; font-weight: 700; color: var(--text); min-width: 48px; text-align: right; }

/* ── Result preview ────────────────────────────────────────────── */
.preview-wrap { display: flex; justify-content: center; margin-bottom: 16px; }
.preview-img {
  max-width: 100%; max-height: 420px; border-radius: var(--radius); border: 1px solid var(--border);
  background-image:
    linear-gradient(45deg, #e7e7f0 25%, transparent 25%), linear-gradient(-45deg, #e7e7f0 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #e7e7f0 75%), linear-gradient(-45deg, transparent 75%, #e7e7f0 75%);
  background-size: 20px 20px; background-position: 0 0, 0 10px, 10px -10px, -10px 0;
}
.result-meta { font-family: 'JetBrains Mono', monospace; font-size: .85rem; color: var(--muted); text-align: center; margin-top: 12px; word-break: break-word; }

/* Before/after savings bar (compressor) */
.compare { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px; margin: 4px 0 16px; text-align: center; }
.compare .cmp-box { padding: 12px 10px; background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius); }
.compare .cmp-label { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.compare .cmp-val { display: block; margin-top: 3px; font-family: 'JetBrains Mono', monospace; font-size: 1.05rem; font-weight: 700; color: var(--text); }
.compare .cmp-arrow { color: var(--muted); font-size: 1.2rem; }
.savings { text-align: center; font-size: .95rem; font-weight: 700; color: var(--accent-fg); background: var(--accent-bg); border-radius: var(--radius); padding: 10px 14px; }

/* ── Interactive crop stage (cropper) ──────────────────────────── */
.crop-stage { text-align: center; margin: 4px 0 2px; }
.crop-wrap {
  position: relative; display: inline-block; max-width: 100%; line-height: 0;
  touch-action: none; user-select: none; border-radius: var(--radius); overflow: hidden;
}
.crop-wrap img { display: block; max-width: 100%; max-height: 460px; height: auto; -webkit-user-drag: none; }
.crop-box {
  position: absolute; box-sizing: border-box; cursor: move;
  border: 2px solid var(--accent);
  box-shadow: 0 0 0 100vmax rgba(15, 15, 46, .5);
}
/* Rule-of-thirds guides */
.crop-box::before, .crop-box::after {
  content: ''; position: absolute; inset: 0; pointer-events: none;
}
.crop-box::before { background:
  linear-gradient(to right, transparent calc(33.33% - .5px), rgba(255,255,255,.4) calc(33.33% - .5px), rgba(255,255,255,.4) calc(33.33% + .5px), transparent calc(33.33% + .5px)),
  linear-gradient(to right, transparent calc(66.66% - .5px), rgba(255,255,255,.4) calc(66.66% - .5px), rgba(255,255,255,.4) calc(66.66% + .5px), transparent calc(66.66% + .5px)); }
.crop-box::after { background:
  linear-gradient(to bottom, transparent calc(33.33% - .5px), rgba(255,255,255,.4) calc(33.33% - .5px), rgba(255,255,255,.4) calc(33.33% + .5px), transparent calc(33.33% + .5px)),
  linear-gradient(to bottom, transparent calc(66.66% - .5px), rgba(255,255,255,.4) calc(66.66% - .5px), rgba(255,255,255,.4) calc(66.66% + .5px), transparent calc(66.66% + .5px)); }
.crop-handle {
  position: absolute; width: 16px; height: 16px; background: var(--accent);
  border: 2px solid #fff; border-radius: 50%; box-sizing: border-box;
}
.crop-handle[data-h="nw"] { top: -9px; left: -9px; cursor: nwse-resize; }
.crop-handle[data-h="ne"] { top: -9px; right: -9px; cursor: nesw-resize; }
.crop-handle[data-h="sw"] { bottom: -9px; left: -9px; cursor: nesw-resize; }
.crop-handle[data-h="se"] { bottom: -9px; right: -9px; cursor: nwse-resize; }
.crop-dims { margin-top: 12px; font-family: 'JetBrains Mono', monospace; font-size: .9rem; font-weight: 600; color: var(--text); }
.crop-dims span { color: var(--muted); font-weight: 400; }

/* ── Rotate & flip (transform tool) ────────────────────────────── */
.xform-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; }
.xform-btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 11px 14px;
  font-family: inherit; font-size: .9rem; font-weight: 600; cursor: pointer;
  color: var(--text); background: var(--surface);
  border: 1.5px solid var(--border); border-radius: var(--radius);
  transition: border-color .15s, background .15s, transform .1s;
}
.xform-btn:hover { border-color: var(--accent); background: var(--accent-bg); transform: translateY(-1px); }
.xform-btn svg { width: 18px; height: 18px; stroke: var(--accent); fill: none; }
.xform-stage { text-align: center; margin: 4px 0; }
.stage-canvas {
  max-width: 100%; max-height: 460px; border-radius: var(--radius); border: 1px solid var(--border);
  background-image:
    linear-gradient(45deg, #e7e7f0 25%, transparent 25%), linear-gradient(-45deg, #e7e7f0 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #e7e7f0 75%), linear-gradient(-45deg, transparent 75%, #e7e7f0 75%);
  background-size: 20px 20px; background-position: 0 0, 0 10px, 10px -10px, -10px 0;
}
.xform-dims { margin-top: 12px; font-family: 'JetBrains Mono', monospace; font-size: .9rem; font-weight: 600; color: var(--text); }
.xform-dims span { color: var(--muted); font-weight: 400; }

/* ── Status / error line ───────────────────────────────────────── */
.status-line { min-height: 20px; margin-top: 12px; font-size: .88rem; font-weight: 600; }
.status-line.error { color: #b42318; }

/* ── Tool hub grid (index) ─────────────────────────────────────── */
.hub-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(264px, 1fr)); gap: 18px; margin-top: 8px; }
.hub-card {
  display: block; text-decoration: none; position: relative; overflow: hidden;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 26px 24px; box-shadow: var(--shadow);
  transition: transform .18s, border-color .18s, box-shadow .18s;
}
.hub-card:hover { transform: translateY(-4px); border-color: var(--accent); box-shadow: var(--shadow-lg); text-decoration: none; }
.hub-card .hub-tag { position: absolute; top: 18px; right: 18px; font-size: .72rem; font-weight: 700; color: var(--accent-fg); background: var(--accent-bg); padding: 2px 9px; border-radius: 999px; }
.hub-card .hub-icon { width: 52px; height: 52px; border-radius: 12px; background: var(--accent); display: flex; align-items: center; justify-content: center; margin-bottom: 16px; }
.hub-card .hub-icon svg { width: 27px; height: 27px; stroke: #fff; fill: none; }
.hub-card h2 { font-family: 'Orbitron', sans-serif; font-size: 1.15rem; font-weight: 700; color: var(--text); margin-bottom: 7px; }
.hub-card p { font-size: .9rem; color: var(--muted); line-height: 1.6; margin-bottom: 16px; }
.hub-card .hub-open { display: inline-flex; align-items: center; gap: 6px; font-size: .88rem; font-weight: 700; color: var(--accent); }

/* ── Content sections (how-it-works / faq) ─────────────────────── */
.section { max-width: 860px; margin: 16px auto; padding: 24px 20px; }
.section > h2 { font-family: 'Orbitron', sans-serif; font-size: 1.4rem; font-weight: 700; margin-bottom: 8px; }
.section > .section-sub { color: var(--muted); margin-bottom: 20px; }
.steps { display: grid; gap: 14px; }
.step { display: flex; gap: 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 20px; box-shadow: var(--shadow); }
.step-num { flex-shrink: 0; width: 36px; height: 36px; border-radius: 50%; background: var(--accent-bg); color: var(--accent-fg); font-weight: 800; display: flex; align-items: center; justify-content: center; }
.step-body h3 { font-size: 1.05rem; font-weight: 700; margin-bottom: 4px; }
.step-body p { font-size: .92rem; color: var(--muted); line-height: 1.6; }
.section-sub a, .step-body a { color: var(--accent); }

.faq details { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 10px; overflow: hidden; }
.faq summary { cursor: pointer; padding: 16px 18px; font-weight: 700; font-size: .98rem; list-style: none; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: '+'; float: right; color: var(--accent); font-weight: 700; }
.faq details[open] summary::after { content: '\2013'; }
.faq .faq-body { padding: 0 18px 16px; font-size: .92rem; color: var(--muted); line-height: 1.7; }
.faq .faq-body a { color: var(--accent); }

/* ── Footer ────────────────────────────────────────────────────── */
footer.page-footer { border-top: 1px solid var(--border); padding: 24px 20px; text-align: center; font-size: .82rem; color: var(--muted); margin-top: 24px; }
footer.page-footer nav { margin-bottom: 6px; }
footer.page-footer nav a { color: var(--muted); }
footer.page-footer nav a:hover { color: var(--text); }

/* ── Toast ─────────────────────────────────────────────────────── */
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px); background: var(--text); color: #fff; padding: 11px 20px; border-radius: var(--radius); font-size: .88rem; font-weight: 600; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 200; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* 4 nav links + Home + Tools; fall back to hamburger on mid widths. */
@media (min-width: 680px) and (max-width: 899px) {
  .site-nav .nav-link { display: none; }
  .nav-hamburger { display: flex; }
  .nav-mobile-menu.open { display: flex !important; }
}
@media (min-width: 900px) { .nav-link { min-width: 0; padding: 8px 11px; } }

@media (max-width: 560px) {
  .dim-grid { grid-template-columns: 1fr; }
  .lock-btn { transform: rotate(90deg); margin: 2px auto; }
  .compare { grid-template-columns: 1fr; }
  .compare .cmp-arrow { transform: rotate(90deg); }
  .clear-btn { min-height: 44px; padding-top: 0; padding-bottom: 0; }
}

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

/* ── Color Picker ───────────────────────────────────────────────── */
.picker-layout { display: grid; grid-template-columns: 1fr 260px; gap: 20px; align-items: start; }
.canvas-wrap { position: relative; overflow: hidden; }
.picker-canvas { max-width: 100%; height: auto; cursor: crosshair; display: block; }
.pick-panel { display: flex; flex-direction: column; gap: 10px; }
.pick-swatch { width: 100%; height: 72px; border-radius: 10px; border: 1px solid rgba(0,0,0,.12); background: #f1f5f9; }
.pick-row { display: flex; align-items: center; gap: 8px; }
.pick-label { width: 34px; font-size: 12px; font-weight: 600; color: var(--muted, #64748b); }
.pick-val { flex: 1; font-family: 'JetBrains Mono', monospace; font-size: 13px; padding: 6px 8px; background: #f8fafc; border-radius: 6px; overflow-x: auto; }
.copy-btn { border: 1px solid var(--accent); color: var(--accent); background: transparent; border-radius: 6px; padding: 5px 10px; font: inherit; font-size: 12px; cursor: pointer; }
.copy-btn:hover { background: var(--accent); color: #fff; }
@media (max-width: 640px) { .picker-layout { grid-template-columns: 1fr; } }
#dropzone[hidden] { display: none; }
.loupe { position: absolute; width: 121px; height: 121px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 2px 10px rgba(0,0,0,.35); pointer-events: none; image-rendering: pixelated; z-index: 5; }

.palette-block { margin-top: 18px; }
.palette-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.palette-head .palette-title { margin: 0; }
.palette-actions { display: flex; align-items: center; gap: 8px; }
.palette-dl { border: 1px solid var(--accent); color: var(--accent); background: transparent; border-radius: 6px; padding: 5px 12px; font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; }
.palette-fmt { border: 1px solid rgba(0,0,0,.18); border-radius: 6px; padding: 5px 8px; font: inherit; font-size: 13px; cursor: pointer; background: #fff; }
.palette-dl:hover { background: var(--accent); color: #fff; }
.palette-title { font-size: 14px; margin: 0 0 8px; color: var(--muted, #64748b); }
.palette-strip { display: flex; flex-wrap: wrap; gap: 8px; }
.palette-sw { width: 52px; height: 52px; border-radius: 8px; border: 1px solid rgba(0,0,0,.12); cursor: pointer; padding: 0; }
.palette-sw:hover { transform: scale(1.06); }

.history-block { margin-top: 14px; }
.hist-sw { width: 40px; height: 40px; border-radius: 8px; border: 1px solid rgba(0,0,0,.12); cursor: pointer; padding: 0; }
.hist-sw:hover { transform: scale(1.06); }

/* Separate the Reset / "Choose a different image" actions from the palette/history above. */
.stage-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 22px; }

/* Compressor animated-GIF warning: its inline display:flex overrides the [hidden]
   attribute, so it showed for every image. !important is needed to beat the inline style. */
#gifWarn[hidden] { display: none !important; }
