/* PixSlim — Global Styles (shared across all pages) */

/* --- CSS Custom Properties --- */
:root {
  --color-primary: #0EA5E9;
  --color-primary-hover: #0284C7;
  --color-primary-light: rgba(14, 165, 233, 0.1);
  --color-bg: #FFFFFF;
  --color-surface: #F8FAFC;
  --color-dropzone-bg: #F1F5F9;
  --color-text: #0F172A;
  --color-text-secondary: #64748B;
  --color-success: #10B981;
  --color-warning: #F59E0B;
  --color-error: #EF4444;
  --color-border: #E2E8F0;
  --color-border-hover: #CBD5E1;

  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'SF Mono', 'Fira Code', 'Fira Mono', 'Roboto Mono', monospace;

  --fs-hero: clamp(2rem, 5vw, 3rem);
  --fs-h2: 1.75rem;
  --fs-body: 1rem;
  --fs-small: 0.875rem;
  --fs-xs: 0.75rem;

  --fw-regular: 400;
  --fw-medium: 500;
  --fw-semibold: 600;
  --fw-bold: 700;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-full: 9999px;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.04);

  --transition-fast: 150ms ease;
  --transition-base: 200ms ease;
  --transition-slow: 300ms ease;

  --header-height: 60px;
  --container-max: 1200px;
  --container-padding: 1.5rem;
}

/* --- Reset --- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-family);
  font-size: var(--fs-body);
  font-weight: var(--fw-regular);
  line-height: 1.6;
  color: var(--color-text);
  background: var(--color-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

img, svg {
  display: block;
  max-width: 100%;
}

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  line-height: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  border: none;
  background: none;
}

a {
  color: var(--color-primary);
  text-decoration: none;
}

a:hover {
  color: var(--color-primary-hover);
}

/* --- Utilities --- */
.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;
}

.skip-link {
  position: absolute;
  top: -100%;
  left: 16px;
  z-index: 10000;
  padding: 8px 16px;
  background: var(--color-primary);
  color: #fff;
  border-radius: var(--radius-sm);
  font-weight: var(--fw-medium);
  transition: top var(--transition-fast);
}

.skip-link:focus {
  top: 8px;
  color: #fff;
}

.container {
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 0 var(--container-padding);
}

/* --- Header --- */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--color-border);
  height: var(--header-height);
}

.header__inner {
  display: flex;
  align-items: center;
  height: 100%;
  gap: 2rem;
}

.header__logo {
  display: flex;
  align-items: center;
  height: 112px;
}

.header__logo-img {
  height: 112px;
  width: auto;
}

.header__logo-img--dark {
  display: none;
}

[data-theme="dark"] .header__logo-img--light {
  display: none;
}

[data-theme="dark"] .header__logo-img--dark {
  display: block;
}

.header__logo:hover {
  opacity: 0.85;
}

.header__nav {
  display: flex;
  gap: 1.5rem;
  margin-left: auto;
}

.header__link {
  color: var(--color-text-secondary);
  font-size: var(--fs-small);
  font-weight: var(--fw-medium);
  transition: color var(--transition-fast);
  padding: 4px 0;
}

.header__link:hover,
.header__link:focus-visible {
  color: var(--color-text);
}

.header__badge {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  background: var(--color-primary-light);
  color: var(--color-primary);
  border-radius: var(--radius-full);
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  white-space: nowrap;
}

.header__right {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* --- Theme Toggle Button --- */
.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  color: var(--color-text-secondary);
  transition: all var(--transition-base);
  position: relative;
}

.theme-toggle:hover {
  background: var(--color-surface);
  color: var(--color-text);
}

.theme-toggle:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

.theme-toggle__sun,
.theme-toggle__moon {
  position: absolute;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.theme-toggle__moon {
  opacity: 0;
  transform: rotate(-90deg) scale(0);
}

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  font-size: var(--fs-small);
  font-weight: var(--fw-semibold);
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
  white-space: nowrap;
  outline: none;
}

.btn:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn--primary {
  background: var(--color-primary);
  color: #fff;
}

.btn--primary:hover:not(:disabled) {
  background: var(--color-primary-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.btn--primary:active:not(:disabled) {
  transform: translateY(0);
}

.btn--secondary {
  background: var(--color-bg);
  color: var(--color-text);
  border: 1px solid var(--color-border);
}

.btn--secondary:hover:not(:disabled) {
  border-color: var(--color-border-hover);
  background: var(--color-surface);
}

.btn--ghost {
  color: var(--color-text-secondary);
  padding: 8px 12px;
}

.btn--ghost:hover:not(:disabled) {
  color: var(--color-text);
  background: var(--color-surface);
}

.btn--danger {
  color: var(--color-error);
}

.btn--danger:hover:not(:disabled) {
  background: rgba(239, 68, 68, 0.08);
  color: var(--color-error);
}

.btn--lg {
  padding: 12px 28px;
  font-size: var(--fs-body);
}

.btn--sm {
  padding: 6px 12px;
  font-size: var(--fs-xs);
}

/* --- Footer --- */
.footer {
  border-top: 1px solid var(--color-border);
  padding: 2.5rem 0;
}

.footer__inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  text-align: center;
}

.footer__brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.footer__logo {
  font-weight: var(--fw-bold);
  color: var(--color-text);
}

.footer__copyright {
  font-size: var(--fs-small);
  color: var(--color-text-secondary);
}

.footer__links {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.footer__link {
  font-size: var(--fs-small);
  color: var(--color-text-secondary);
}

.footer__link:hover {
  color: var(--color-text);
}

.footer__sep {
  color: var(--color-border);
  font-size: var(--fs-xs);
}

.footer__tagline {
  font-size: var(--fs-small);
  color: var(--color-text-secondary);
}

.footer__formats {
  display: flex;
  gap: 6px;
  margin-top: 4px;
}

.format-badge {
  padding: 2px 8px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  color: var(--color-text-secondary);
}

/* --- Toasts --- */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 1000;
  display: flex;
  flex-direction: column-reverse;
  gap: 8px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: var(--color-text);
  color: #fff;
  border-radius: var(--radius-md);
  font-size: var(--fs-small);
  font-weight: var(--fw-medium);
  box-shadow: var(--shadow-lg);
  pointer-events: auto;
  animation: toastIn 0.2s ease both;
  max-width: 360px;
}

.toast--success {
  background: var(--color-success);
}

.toast--error {
  background: var(--color-error);
}

.toast--warning {
  background: var(--color-warning);
  color: var(--color-text);
}

.toast--leaving {
  animation: toastOut 0.15s ease both;
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes toastOut {
  from {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
  to {
    opacity: 0;
    transform: translateY(-8px) scale(0.95);
  }
}

/* --- Scroll Animations --- */
.animate-on-scroll {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}

.animate-on-scroll.is-visible {
  opacity: 1;
  transform: translateY(0);
}

/* --- Reduced Motion --- */
@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;
  }
}

/* ============================================
   DARK MODE
   ============================================ */
[data-theme="dark"] {
  --color-bg: #0F172A;
  --color-surface: #1E293B;
  --color-dropzone-bg: #1E293B;
  --color-text: #F1F5F9;
  --color-text-secondary: #94A3B8;
  --color-border: #334155;
  --color-border-hover: #475569;
  --color-primary-light: rgba(14, 165, 233, 0.15);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 8px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 10px 20px rgba(0, 0, 0, 0.4);
}

[data-theme="dark"] body {
  background: var(--color-bg);
}

[data-theme="dark"] .header {
  background: rgba(15, 23, 42, 0.88);
  border-bottom-color: var(--color-border);
}

/* header__logo now uses images — dark variant handled via display toggle */

[data-theme="dark"] .footer {
  border-top-color: var(--color-border);
}

[data-theme="dark"] .format-badge {
  background: var(--color-surface);
  border-color: var(--color-border);
}

[data-theme="dark"] .toast {
  background: #334155;
}

[data-theme="dark"] .theme-toggle__sun {
  opacity: 0;
  transform: rotate(90deg) scale(0);
}

[data-theme="dark"] .theme-toggle__moon {
  opacity: 1;
  transform: rotate(0) scale(1);
}

[data-theme="dark"] .theme-toggle {
  color: var(--color-warning);
}

/* --- Mobile Responsive (Header & Footer) --- */
@media (max-width: 767px) {
  :root {
    --container-padding: 1rem;
  }

  .header__nav {
    gap: 1rem;
  }

  .header__badge span {
    display: none;
  }

  .toast-container {
    bottom: 16px;
    right: 16px;
    left: 16px;
  }

  .toast {
    max-width: none;
  }
}
