/* ──────────────────────────────────────────────────────────────────────────
 * Design tokens — Pawfectly Yours
 *
 * Soft pink / cream watercolor aesthetic. The legacy `--accent` token is kept
 * as an alias to `--brand-pink` so older components that still reference it
 * (e.g. some sticker-tab styles) keep working without modification.
 * ────────────────────────────────────────────────────────────────────────── */

:root {
  /* Brand palette */
  --brand-pink: #ec4899;
  --brand-pink-strong: #db2777;
  --brand-pink-soft: #fbe2ec;
  --brand-pink-tint: #fde8ef;
  --brand-pink-wash: #fdf2f4;
  --brand-cream: #fffaf5;
  --brand-lavender: #c4b5e5;
  --brand-lavender-soft: #ede7f6;
  --brand-peach: #fcd7b6;
  --brand-blue: #b6cef0;

  /* Surfaces */
  --bg-app: var(--brand-pink-wash);
  --bg-primary: #ffffff;
  --bg-secondary: var(--brand-cream);
  --bg-tertiary: var(--brand-pink-tint);

  /* Text */
  --text-primary: #1f1d23;
  --text-secondary: #5d5763;
  --text-muted: #9a9099;
  --text-on-brand: #ffffff;

  /* Borders */
  --border: #fde2ea;
  --border-strong: #f9c8d6;
  --border-focus: var(--brand-pink);

  /* Status */
  --success: #22c55e;
  --warning: #f59e0b;
  --error: #ef4444;

  /* Radii — gentle, never sharp. Cards lean larger. */
  --radius-xs: 6px;
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-xl: 28px;
  --radius-pill: 999px;

  /* Shadows — soft, pink-tinted */
  --shadow-xs: 0 1px 2px rgba(236, 72, 153, 0.06);
  --shadow-sm: 0 2px 4px rgba(236, 72, 153, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 6px 12px -2px rgba(236, 72, 153, 0.10), 0 2px 4px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 12px 24px -6px rgba(236, 72, 153, 0.18), 0 6px 10px -4px rgba(0, 0, 0, 0.05);
  --shadow-pop: 0 18px 36px -10px rgba(236, 72, 153, 0.32);

  /* Fonts */
  --font-display: 'Pacifico', 'Caveat', 'DM Sans', cursive;
  --font-body: 'Nunito', 'DM Sans', system-ui, -apple-system, sans-serif;
  --font-mono: 'Space Mono', ui-monospace, Consolas, monospace;

  /* Layout rhythm */
  --header-height: 72px;
  --header-height-mobile: 56px;
  --right-panel-width: 420px;
  --right-panel-width-md: 360px;

  /* Legacy aliases — keep older components working */
  --accent: var(--brand-pink);
  --accent-hover: var(--brand-pink-strong);
  --accent-bg: var(--brand-pink-soft);

  font-family: var(--font-body);
  line-height: 1.5;
  font-weight: 400;
  color: var(--text-primary);
  background-color: var(--bg-app);
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg-app);
  /* Subtle grid texture echoing the screenshot's notebook backdrop. */
  background-image:
    linear-gradient(rgba(236, 72, 153, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(236, 72, 153, 0.04) 1px, transparent 1px);
  background-size: 24px 24px;
  background-position: -1px -1px;
}

#root {
  /* `height: 100vh` (not `min-height`) is intentional. The editor is a
   * single-screen app — every panel is meant to live within the
   * viewport, with internal scrolling where needed (the sidebar's
   * `.rp__scroll`, the layers panel, etc.). With `min-height: 100vh`,
   * if any descendant's intrinsic content was taller than the viewport
   * (e.g. the sidebar with many layers), #root would grow past 100vh,
   * the page would scroll, and the canvas-area would extend below the
   * visible viewport — taking the absolutely-positioned bottom bar
   * with it. Capping at exactly 100vh gives every descendant a
   * definite height to resolve `height: 100%` against, so
   * `.rp__scroll`'s `overflow-y: auto` actually engages and the
   * canvas-area stays viewport-sized.
   *
   * `overflow: hidden` belts-and-suspenders the cap so anything that
   * sneaks past (e.g. a wide popover) gets clipped rather than
   * scrolling the page. */
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ────────────────────────────────────────────────────────────────────────── */
/* Generic interactive elements                                               */
/* ────────────────────────────────────────────────────────────────────────── */

button {
  font-family: inherit;
  cursor: pointer;
  outline: none;
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible {
  box-shadow: 0 0 0 2px var(--bg-primary), 0 0 0 4px var(--brand-pink);
}

input,
textarea,
select {
  font-family: inherit;
  color: inherit;
}

input[type='range'] {
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
  width: 100%;
}

input[type='range']::-webkit-slider-runnable-track {
  height: 6px;
  background: var(--brand-pink-soft);
  border-radius: 999px;
}

input[type='range']::-moz-range-track {
  height: 6px;
  background: var(--brand-pink-soft);
  border-radius: 999px;
}

input[type='range']::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 999px;
  background: var(--brand-pink);
  border: 3px solid #fff;
  box-shadow: var(--shadow-sm);
  margin-top: -6px;
  cursor: pointer;
}

input[type='range']::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 999px;
  background: var(--brand-pink);
  border: 3px solid #fff;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
}

/* ────────────────────────────────────────────────────────────────────────── */
/* Shared utilities (S13)                                                     */
/*                                                                            */
/* Pulled out of individual component stylesheets so the same pattern         */
/* doesn't get re-defined in 5 places. Add new utilities here when a          */
/* CSS rule shows up in 3+ files unchanged.                                   */
/* ────────────────────────────────────────────────────────────────────────── */

/* Visually hide content while keeping it accessible to screen readers.
 * The classic 1px clipping trick. `.sr-only` is an alias because
 * different parts of the codebase grew up using one or the other (S24
 * audit referenced both — unifying them prevents drift). */
.visually-hidden,
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Strip native <button> chrome so you can build a custom-styled clickable
 * surface that still gets keyboard accessibility for free. Used by
 * LayersPanel rows, Sidebar tabs, and similar. Pair with explicit
 * `:focus-visible` styling so keyboard users still see focus. */
.btn-reset {
  appearance: none;
  background: transparent;
  border: none;
  padding: 0;
  margin: 0;
  font: inherit;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

/* Generic fade+slide-up entrance for toasts, banners, and other
 * top-anchored chips. Components that need an X-translate variant
 * (e.g. .app-toast which is centered via translateX(-50%)) keep their
 * own bespoke @keyframes since this one only handles Y. */
@keyframes fade-up-in {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ────────────────────────────────────────────────────────────────────────── */
/* Spinner — used by background removal and uploads                           */
/* ────────────────────────────────────────────────────────────────────────── */

.spinner-small {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ────────────────────────────────────────────────────────────────────────── */
/* PWA install banner + offline indicator                                     */
/* ────────────────────────────────────────────────────────────────────────── */

.pwa-install-banner {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-primary);
  border: 1px solid var(--brand-pink);
  border-radius: var(--radius-lg);
  padding: 1rem 1.5rem;
  box-shadow: var(--shadow-lg);
  z-index: 1000;
  display: flex;
  align-items: center;
  gap: 1rem;
  animation: slideUp 0.3s ease-out;
}

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

.pwa-install-banner p {
  margin: 0;
  font-size: 0.875rem;
  color: var(--text-primary);
}

.install-btn {
  padding: 0.5rem 1rem;
  background: var(--brand-pink);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
}

.dismiss-btn {
  padding: 0.5rem 1rem;
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  cursor: pointer;
}

.offline-indicator {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: white;
  padding: 0.5rem 1rem;
  text-align: center;
  font-size: 12px;
  font-weight: 500;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  box-shadow: var(--shadow-md);
}

/* ────────────────────────────────────────────────────────────────────────── */
/* Background removal button (rendered inside ElementToolbar)                 */
/* ────────────────────────────────────────────────────────────────────────── */

.bg-removal-container {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.bg-removal-btn {
  width: 100%;
  padding: 0.65rem 0.85rem;
  background: linear-gradient(135deg, var(--brand-pink), var(--brand-lavender));
  color: #fff;
  border: none;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease, opacity 0.12s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  box-shadow: 0 4px 10px -2px rgba(236, 72, 153, 0.4);
}

.bg-removal-btn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 8px 16px -4px rgba(236, 72, 153, 0.55);
}

.bg-removal-btn:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

/* ────────────────────────────────────────────────────────────────────────── */
/* Filerobot photo editor modal                                               */
/* ────────────────────────────────────────────────────────────────────────── */

.filerobot-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(31, 29, 35, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.filerobot-container {
  width: 90%;
  height: 90%;
  background: #1e1e1e;
  border-radius: var(--radius-lg);
  overflow: hidden;
}
