/* ==========================================================================
   PixelKit — Free Online Image Tools
   Mobile-First Production CSS
   Zero external fonts/icons. 100% self-contained & fast.
   ========================================================================== */

:root {
  --bg-main: #f8fafc;
  --bg-surface: #ffffff;
  --bg-subtle: #f1f5f9;
  --border-color: #e2e8f0;
  --border-focus: #4f46e5;
  
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --text-inverse: #ffffff;

  --brand-primary: #4f46e5;
  --brand-hover: #4338ca;
  --brand-light: #eef2ff;

  --success: #059669;
  --success-bg: #ecfdf5;
  --warning: #d97706;
  --warning-bg: #fffbeb;
  --error: #dc2626;
  --error-bg: #fef2f2;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 20px;

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 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);

  --font-sans: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

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

html {
  font-family: var(--font-sans);
  background-color: var(--bg-main);
  color: var(--text-primary);
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

.tabular-nums {
  font-variant-numeric: tabular-nums;
  font-family: var(--font-mono);
}

/* ==========================================================================
   Header & Navigation (3-Zone Contract)
   ========================================================================== */

.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background-color: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border-color);
  height: 60px;
}

.header-container {
  max-width: 1200px;
  margin: 0 auto;
  height: 100%;
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand-link {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text-primary);
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: -0.02em;
  white-space: nowrap;
  flex-shrink: 0;
}

.brand-icon {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.nav-links {
  display: none;
  align-items: center;
  gap: 24px;
}

@media (min-width: 768px) {
  .nav-links {
    display: flex;
  }
}

.nav-link {
  text-decoration: none;
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 500;
  white-space: nowrap;
  transition: color 0.15s ease;
}

.nav-link:hover {
  color: var(--brand-primary);
}

.header-action {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ==========================================================================
   Layout Containers
   ========================================================================== */

.main-content {
  flex: 1;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 20px 16px 60px 16px;
}

@media (min-width: 768px) {
  .main-content {
    padding: 36px 24px 80px 24px;
  }
}

/* ==========================================================================
   Hero Section
   ========================================================================== */

.hero-section {
  text-align: center;
  margin-bottom: 28px;
  max-width: 800px;
  margin-left: auto;
  margin-right: auto;
}

.hero-title {
  font-size: clamp(1.75rem, 5vw, 2.75rem);
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: -0.03em;
  color: var(--text-primary);
  margin-bottom: 12px;
  text-wrap: balance;
}

.hero-desc {
  font-size: clamp(0.95rem, 2.5vw, 1.125rem);
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 16px;
}

.hero-trust-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px 16px;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.trust-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.trust-separator {
  color: var(--border-color);
}

/* ==========================================================================
   Upload Dropzone
   ========================================================================== */

.dropzone-container {
  margin-bottom: 28px;
}

.dropzone {
  border: 2px dashed var(--border-color);
  background-color: var(--bg-surface);
  border-radius: var(--radius-lg);
  padding: 32px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s ease, background-color 0.15s ease, box-shadow 0.15s ease;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 200px;
  box-shadow: var(--shadow-sm);
}

.dropzone:hover,
.dropzone.dragover {
  border-color: var(--brand-primary);
  background-color: #faf5ff;
}

.dropzone:focus-visible {
  outline: 2px solid var(--border-focus);
  outline-offset: 2px;
}

.dropzone-icon {
  width: 48px;
  height: 48px;
  color: var(--brand-primary);
  margin-bottom: 12px;
  stroke-width: 1.75;
}

.dropzone-title {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.dropzone-subtitle {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.dropzone-limits {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.file-input-hidden {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

/* ==========================================================================
   Active Image Info Bar
   ========================================================================== */

.image-meta-bar {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  margin-bottom: 24px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  box-shadow: var(--shadow-sm);
}

.image-meta-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.image-thumb-mini {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  background-color: var(--bg-subtle);
  border: 1px solid var(--border-color);
  flex-shrink: 0;
}

.image-details {
  min-width: 0;
}

.image-name {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 240px;
}

@media (min-width: 640px) {
  .image-name {
    max-width: 400px;
  }
}

.image-specs {
  font-size: 0.75rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ==========================================================================
   Tool Tabs Navigation
   ========================================================================== */

.tool-tabs-container {
  margin-bottom: 24px;
}

.tool-tabs {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  background-color: var(--bg-subtle);
  padding: 4px;
  border-radius: var(--radius-md);
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: none;
}

.tool-tab-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 8px 6px;
  min-height: 48px;
  border: none;
  background: transparent;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
  gap: 4px;
}

.tool-tab-btn svg {
  width: 18px;
  height: 18px;
}

.tool-tab-btn:hover {
  color: var(--text-primary);
}

.tool-tab-btn.active {
  background-color: var(--bg-surface);
  color: var(--brand-primary);
  box-shadow: var(--shadow-sm);
}

.tool-tab-btn:focus-visible {
  outline: 2px solid var(--border-focus);
}

/* ==========================================================================
   Tool Workspace Card
   ========================================================================== */

.workspace-card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 32px;
}

@media (min-width: 768px) {
  .workspace-card {
    padding: 28px;
  }
}

.tool-panel {
  display: none;
}

.tool-panel.active {
  display: block;
}

.tool-header {
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 16px;
}

.tool-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.tool-description {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

/* Form Controls & Grids */
.control-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
  margin-bottom: 24px;
}

@media (min-width: 768px) {
  .control-grid-2col {
    grid-template-columns: 1fr 1fr;
  }
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.control-label {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.control-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 400;
}

.form-input,
.form-select {
  width: 100%;
  height: 44px;
  padding: 0 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background-color: var(--bg-surface);
  color: var(--text-primary);
  font-size: 0.95rem;
  font-family: inherit;
  transition: border-color 0.15s ease;
}

.form-input:focus,
.form-select:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}

/* Custom Range Slider */
.slider-container {
  display: flex;
  align-items: center;
  gap: 12px;
}

.range-slider {
  flex: 1;
  height: 6px;
  border-radius: 3px;
  background: var(--bg-subtle);
  outline: none;
  -webkit-appearance: none;
  accent-color: var(--brand-primary);
}

.range-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--brand-primary);
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
  border: 2px solid #ffffff;
}

.slider-val-badge {
  min-width: 48px;
  text-align: right;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--brand-primary);
}

/* Segmented Buttons / Ratio Pills */
.segmented-group {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.segment-btn {
  padding: 8px 14px;
  min-height: 40px;
  font-size: 0.85rem;
  font-weight: 500;
  border: 1px solid var(--border-color);
  background-color: var(--bg-surface);
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
}

.segment-btn:hover {
  border-color: var(--text-muted);
  color: var(--text-primary);
}

.segment-btn.active {
  background-color: var(--brand-light);
  border-color: var(--brand-primary);
  color: var(--brand-primary);
  font-weight: 600;
}

.segment-btn:focus-visible {
  outline: 2px solid var(--border-focus);
}

/* Action Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 18px;
  height: 44px;
  min-width: 44px;
  font-size: 0.9rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s ease;
  white-space: nowrap;
  text-decoration: none;
}

.btn-primary {
  background-color: var(--brand-primary);
  color: var(--text-inverse);
  box-shadow: var(--shadow-sm);
}

.btn-primary:hover:not(:disabled) {
  background-color: var(--brand-hover);
}

.btn-secondary {
  background-color: var(--bg-surface);
  border-color: var(--border-color);
  color: var(--text-primary);
}

.btn-secondary:hover:not(:disabled) {
  background-color: var(--bg-subtle);
  border-color: var(--text-muted);
}

.btn-danger {
  background-color: var(--bg-surface);
  border-color: var(--border-color);
  color: var(--error);
}

.btn-danger:hover:not(:disabled) {
  background-color: var(--error-bg);
  border-color: var(--error);
}

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

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

.btn-group {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 20px;
}

/* ==========================================================================
   Output Result Card
   ========================================================================== */

.result-card {
  margin-top: 24px;
  background-color: var(--bg-main);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.result-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.result-title {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 6px;
}

.size-comparison {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 0.9rem;
}

.original-size {
  text-decoration: line-through;
  color: var(--text-muted);
}

.final-size {
  font-weight: 700;
  color: var(--text-primary);
}

.savings-tag {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 4px;
}

.savings-tag.positive {
  background-color: var(--success-bg);
  color: var(--success);
}

.savings-tag.negative {
  background-color: var(--warning-bg);
  color: var(--warning);
}

.result-note {
  font-size: 0.8rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

/* ==========================================================================
   Interactive Crop Canvas & Scrim
   ========================================================================== */

.crop-workspace-container {
  position: relative;
  width: 100%;
  max-width: 800px;
  margin: 0 auto 20px auto;
  background-color: #0b0f19;
  border-radius: var(--radius-md);
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 280px;
}

.crop-canvas-layer {
  display: block;
  max-width: 100%;
  max-height: 500px;
  width: auto;
  height: auto;
}

.crop-box-overlay {
  position: absolute;
  border: 2px dashed #ffffff;
  box-shadow: 0 0 0 9999px rgba(15, 23, 42, 0.65);
  cursor: move;
  box-sizing: border-box;
}

/* 4 corner handles for touch and mouse */
.crop-handle {
  position: absolute;
  width: 28px;
  height: 28px;
  background-color: #ffffff;
  border: 2px solid var(--brand-primary);
  border-radius: 4px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
  z-index: 10;
  touch-action: none;
}

.crop-handle-nw {
  top: -14px;
  left: -14px;
  cursor: nwse-resize;
}

.crop-handle-ne {
  top: -14px;
  right: -14px;
  cursor: nesw-resize;
}

.crop-handle-se {
  bottom: -14px;
  right: -14px;
  cursor: nwse-resize;
}

.crop-handle-sw {
  bottom: -14px;
  left: -14px;
  cursor: nesw-resize;
}

/* Touch Nudge Controls for Mobile Precision */
.crop-nudge-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.nudge-btn {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  touch-action: manipulation;
}

.nudge-btn:hover {
  background-color: var(--bg-subtle);
}

.nudge-btn:active {
  background-color: var(--brand-light);
  border-color: var(--brand-primary);
}

/* ==========================================================================
   Enhancer Live Canvas Preview
   ========================================================================== */

.enhancer-preview-box {
  width: 100%;
  max-width: 640px;
  margin: 0 auto 20px auto;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border-color);
  background-color: #000000;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 240px;
}

.enhancer-preview-canvas {
  max-width: 100%;
  max-height: 420px;
  width: auto;
  height: auto;
  display: block;
}

/* ==========================================================================
   Information, FAQ, and Privacy Sections
   ========================================================================== */

.content-section {
  margin-top: 48px;
  border-top: 1px solid var(--border-color);
  padding-top: 36px;
}

.section-heading {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 12px;
  letter-spacing: -0.02em;
}

.section-intro {
  font-size: 0.95rem;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 24px;
}

.info-cards-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

@media (min-width: 640px) {
  .info-cards-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 1024px) {
  .info-cards-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

.info-card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}

.info-card-icon {
  width: 32px;
  height: 32px;
  color: var(--brand-primary);
  margin-bottom: 12px;
}

.info-card-title {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.info-card-desc {
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* FAQ Accordions */
.faq-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.faq-item {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.faq-question {
  width: 100%;
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: none;
  border: none;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
  text-align: left;
  cursor: pointer;
}

.faq-icon {
  width: 20px;
  height: 20px;
  color: var(--text-muted);
  transition: transform 0.2s ease;
  flex-shrink: 0;
}

.faq-item.open .faq-icon {
  transform: rotate(180deg);
}

.faq-answer {
  display: none;
  padding: 0 16px 16px 16px;
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

.faq-item.open .faq-answer {
  display: block;
}

/* Advertising Placeholder Layout (Clean & Unobtrusive) */
.ad-slot-container {
  margin: 32px 0;
  border: 1px dashed var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
  text-align: center;
  background-color: var(--bg-subtle);
}

.ad-label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.ad-placeholder-text {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Footer */
.site-footer {
  background-color: var(--bg-surface);
  border-top: 1px solid var(--border-color);
  padding: 32px 16px;
  margin-top: auto;
}

.footer-container {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

@media (min-width: 768px) {
  .footer-container {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }
}

.footer-brand {
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 16px 24px;
}

.footer-link {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.85rem;
  transition: color 0.15s ease;
}

.footer-link:hover {
  color: var(--text-primary);
}

/* Toast Status & Notification */
.toast-notice {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 50;
  padding: 12px 18px;
  border-radius: var(--radius-md);
  background-color: var(--text-primary);
  color: var(--text-inverse);
  font-size: 0.875rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  display: none;
  align-items: center;
  gap: 8px;
  animation: slideUp 0.2s ease-out;
}

.toast-notice.show {
  display: flex;
}

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

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
