/* ============================================================================
   Background Remover — page styles.

   Restyled onto the manuslabs.app design system (paper palette, Geist body,
   Fraunces display italic). Fonts are SELF-HOSTED here rather than pulled from
   Google Fonts, because the page ships COEP: require-corp (for threaded WASM)
   and Google's font files don't send the cross-origin headers that requires.
   ============================================================================ */

/* ---- Self-hosted fonts (subset to what this page uses) ---- */
@font-face {
  font-family: "Geist";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("./assets/fonts/geist-400.woff2") format("woff2");
}
@font-face {
  font-family: "Geist";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("./assets/fonts/geist-500.woff2") format("woff2");
}
@font-face {
  font-family: "Geist";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("./assets/fonts/geist-600.woff2") format("woff2");
}
@font-face {
  font-family: "Fraunces";
  font-style: italic;
  font-weight: 400 600;
  font-display: swap;
  src: url("./assets/fonts/fraunces-italic.woff2") format("woff2");
}

/* ==========================================================================
   Tokens — mirror /css/style.css so the page belongs to the site.
   ========================================================================== */
:root {
  --ink: #131311;
  --forest: #143829;
  --terracotta: #b04a28;
  --paper: #faf6eb;
  --paper-soft: #fdfbf5;
  --paper-deep: #ede4cc;
  --paper-deeper: #e2d7b8;
  --stone: #575751;
  --rule: #d7ccb0;

  --h1-size: clamp(2.25rem, 5vw, 3.5rem);
  --lead-size: clamp(1.125rem, 2vw, 1.375rem);

  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --dur-fast: 180ms;
  --dur: 240ms;

  --container: 1100px;
  --pad-x: 1.25rem;
  --radius: 16px;
  --radius-sm: 10px;
  --tap: 44px;
}

@media (min-width: 640px) {
  :root {
    --pad-x: 1.75rem;
  }
}
@media (min-width: 960px) {
  :root {
    --pad-x: 2.25rem;
  }
}

/* ==========================================================================
   Reset + base
   ========================================================================== */
*,
*::before,
*::after {
  box-sizing: border-box;
}
html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}
body,
h1,
p,
figure,
dl,
dd,
ul,
ol {
  margin: 0;
  padding: 0;
}
ul,
ol {
  list-style: none;
}
img,
picture,
svg {
  display: block;
  max-width: 100%;
  height: auto;
}
button,
input {
  font: inherit;
  color: inherit;
}
[hidden] {
  display: none !important;
}

body {
  font-family:
    "Geist",
    system-ui,
    -apple-system,
    "Segoe UI",
    sans-serif;
  font-size: 1.0625rem;
  line-height: 1.65;
  color: var(--ink);
  background-color: var(--paper);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image: url("/assets/noise.svg");
  background-repeat: repeat;
  background-size: 120px 120px;
  opacity: 0.025;
  z-index: -1;
}

.container {
  width: 100%;
  max-width: var(--container);
  margin: 0 auto;
  padding-inline: var(--pad-x);
}

a {
  color: var(--forest);
  text-decoration: none;
  text-underline-offset: 4px;
}
a:hover {
  text-decoration: underline;
}

:focus:not(:focus-visible) {
  outline: none;
}
:focus-visible {
  outline: 2px solid var(--forest);
  outline-offset: 3px;
  border-radius: 2px;
}

.eyebrow {
  display: inline-block;
  font-weight: 500;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--forest);
  margin-bottom: 0.875rem;
}

.i {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: none;
}
.sprite {
  position: absolute;
  width: 0;
  height: 0;
}

.skip-link {
  position: absolute;
  top: 0;
  left: 0;
  transform: translateY(-120%);
  background: var(--forest);
  color: var(--paper-soft);
  padding: 0.75rem 1.25rem;
  font-weight: 500;
  font-size: 0.875rem;
  border-bottom-right-radius: 4px;
  z-index: 100;
  transition: transform var(--dur) var(--ease);
}
.skip-link:focus,
.skip-link:focus-visible {
  transform: translateY(0);
  outline: none;
  text-decoration: none;
}

/* ==========================================================================
   Site header / footer — copied from the main site for visual continuity
   ========================================================================== */
.site-header {
  padding-block: 1.25rem;
}
@media (min-width: 960px) {
  .site-header {
    padding-block: 1.75rem;
  }
}
.site-header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--ink);
  font-weight: 500;
  font-size: 1rem;
  letter-spacing: -0.01em;
}
.brand:hover {
  text-decoration: none;
  color: var(--forest);
}
.brand img {
  width: auto;
  height: 28px;
  flex-shrink: 0;
}
@media (min-width: 640px) {
  .brand img {
    height: 32px;
  }
}
.site-nav {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  font-size: 0.9375rem;
}
.site-nav a {
  color: var(--stone);
  padding-block: 0.25rem;
}
.site-nav a:hover {
  color: var(--forest);
  text-decoration: none;
}
@media (max-width: 520px) {
  .site-nav {
    gap: 1rem;
    font-size: 0.875rem;
  }
}

.site-footer {
  background: var(--paper-deeper);
  padding-block: 2.25rem;
  color: var(--stone);
  font-size: 0.875rem;
  border-top: 3px solid var(--forest);
  margin-top: auto;
}
.site-footer__inner {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}
.site-footer__row {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  align-items: flex-start;
}
@media (min-width: 640px) {
  .site-footer__row {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
  }
}
.site-footer__brand {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  color: var(--ink);
  font-weight: 500;
  font-size: 0.9375rem;
}
.site-footer__brand:hover {
  text-decoration: none;
  color: var(--forest);
}
.site-footer__brand img {
  width: auto;
  height: 22px;
}
.site-footer__nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.25rem;
}
.site-footer__nav a {
  color: var(--stone);
  padding-block: 0.25rem;
}
.site-footer__nav a:hover {
  color: var(--forest);
  text-decoration: none;
}
.site-footer__base {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--rule);
  font-size: 0.8125rem;
}
@media (min-width: 640px) {
  .site-footer__base {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
  }
}
.site-footer__colophon {
  font-family: "Fraunces", Georgia, serif;
  font-style: italic;
}

/* ==========================================================================
   Tool hero
   ========================================================================== */
.tool-hero {
  background: var(--paper-soft);
  padding-block: clamp(2.5rem, 7vw, 5rem);
}
.tool-hero__title {
  font-weight: 500;
  font-size: var(--h1-size);
  letter-spacing: -0.035em;
  line-height: 1.04;
  max-width: 18ch;
  margin-bottom: 1.25rem;
}
.tool-hero__title em {
  font-family: "Fraunces", Georgia, serif;
  font-style: italic;
  font-weight: 400;
  font-variation-settings: "opsz" 72;
  color: var(--terracotta);
}
.tool-hero__lead {
  font-family: "Fraunces", Georgia, serif;
  font-variation-settings: "opsz" 36;
  font-size: var(--lead-size);
  line-height: 1.5;
  color: var(--stone);
  max-width: 46ch;
  margin-bottom: 1.5rem;
}
.tool-hero__badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8125rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  color: var(--forest);
  background: var(--paper-deep);
  border: 1px solid var(--rule);
  border-radius: 999px;
  padding: 0.4rem 0.9rem;
}
.tool-hero__badge .i {
  width: 16px;
  height: 16px;
}

/* ==========================================================================
   Tool
   ========================================================================== */
.tool {
  background: var(--paper);
  padding-block: clamp(2rem, 5vw, 3.5rem) clamp(3rem, 7vw, 5rem);
  flex: 1 0 auto;
}

/* ---- buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: var(--tap);
  padding: 0 1.25rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-weight: 500;
  font-size: 0.9375rem;
  cursor: pointer;
  transition:
    background var(--dur-fast) var(--ease),
    color var(--dur-fast) var(--ease),
    border-color var(--dur-fast) var(--ease),
    transform var(--dur-fast) var(--ease);
}
.btn:active {
  transform: translateY(1px);
}
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}
.btn .i {
  width: 18px;
  height: 18px;
}
.btn-primary {
  background: var(--forest);
  color: var(--paper-soft);
}
.btn-primary:hover:not(:disabled) {
  background: #0f2a1f;
  text-decoration: none;
}
.btn-secondary {
  background: var(--paper-soft);
  color: var(--ink);
  border-color: var(--rule);
}
.btn-secondary:hover:not(:disabled) {
  background: var(--paper-deep);
  text-decoration: none;
}

/* ---- drop zone ---- */
.dropzone {
  width: 100%;
  min-height: clamp(300px, 48vh, 460px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  text-align: center;
  padding: 2.5rem 1.5rem;
  background: var(--paper-soft);
  border: 2px dashed var(--rule);
  border-radius: var(--radius);
  color: var(--ink);
  cursor: pointer;
  transition:
    border-color var(--dur) var(--ease),
    background var(--dur) var(--ease),
    transform var(--dur) var(--ease);
}
.dropzone:hover {
  border-color: var(--forest);
  background: var(--paper-deep);
}
.dropzone.is-dragover {
  border-color: var(--forest);
  background: var(--paper-deep);
  transform: scale(1.005);
}
.dz-icon {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--paper-deep);
  color: var(--forest);
  margin-bottom: 0.5rem;
}
.dz-icon .i {
  width: 30px;
  height: 30px;
}
.dz-title {
  font-weight: 500;
  font-size: clamp(1.25rem, 2.4vw, 1.625rem);
  letter-spacing: -0.02em;
  line-height: 1.2;
}
.dz-sub {
  color: var(--stone);
}
.dz-browse {
  margin-top: 0.5rem;
  pointer-events: none;
}
.dz-formats {
  margin-top: 0.75rem;
  color: var(--stone);
  font-size: 0.8125rem;
}

/* ---- result ---- */
.result {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.canvas-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 10;
  max-height: 70vh;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--rule);
  background: conic-gradient(
    var(--paper-deep) 25%,
    var(--paper-soft) 0 50%,
    var(--paper-deep) 0 75%,
    var(--paper-soft) 0
  );
  background-size: 24px 24px;
}
.compare {
  position: absolute;
  inset: 0;
  user-select: none;
  touch-action: none;
}
.pic {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 1rem;
  pointer-events: none;
}
#img-cutout {
  z-index: 1;
}
.clip-original {
  position: absolute;
  inset: 0;
  z-index: 2;
  overflow: hidden;
  clip-path: inset(0 50% 0 0);
  background: conic-gradient(
    var(--paper-deep) 25%,
    var(--paper-soft) 0 50%,
    var(--paper-deep) 0 75%,
    var(--paper-soft) 0
  );
  background-size: 24px 24px;
}
.split {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 40px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: ew-resize;
  z-index: 3;
}
.split-line {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 2px;
  transform: translateX(-50%);
  background: var(--paper-soft);
  box-shadow: 0 0 0 1px rgba(19, 19, 17, 0.18);
}
.split-handle {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--paper-soft);
  color: var(--forest);
  box-shadow: 0 8px 24px -8px rgba(19, 19, 17, 0.4);
  border: 1px solid var(--rule);
}
.split:focus-visible {
  outline: none;
}
.split:focus-visible .split-handle {
  outline: 2px solid var(--forest);
  outline-offset: 2px;
}
/* The slider only makes sense once a cutout exists. */
.result:not(.is-done) .split {
  display: none;
}
.result:not(.is-done) .clip-original {
  clip-path: none;
}

/* ---- overlay (spinner + % progress) ---- */
.overlay {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  background: color-mix(in srgb, var(--paper-soft) 78%, transparent);
  backdrop-filter: blur(3px);
}
.overlay-text {
  font-weight: 500;
  color: var(--ink);
}
.spinner {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 4px solid var(--rule);
  border-top-color: var(--forest);
  animation: spin 0.8s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
.progress {
  width: min(260px, 70%);
  height: 6px;
  border-radius: 999px;
  background: var(--paper-deep);
  overflow: hidden;
}
.progress-bar {
  display: block;
  height: 100%;
  width: 0%;
  background: var(--forest);
  transition: width var(--dur) var(--ease);
}

/* ---- error ---- */
.error-card {
  position: absolute;
  inset: 0;
  z-index: 6;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  text-align: center;
  padding: 1.5rem;
  background: var(--paper-soft);
}
.error-card .i {
  width: 34px;
  height: 34px;
  color: var(--terracotta);
}
.error-text {
  max-width: 40ch;
  color: var(--ink);
  font-weight: 500;
}

/* ---- action bar ---- */
.actionbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
}

.tool-note {
  margin-top: 1.75rem;
  max-width: 60ch;
  font-size: 0.875rem;
  color: var(--stone);
}

/* ==========================================================================
   a11y / motion
   ========================================================================== */
.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .spinner {
    animation: spin 0.8s linear infinite;
  }
}
