/* =============================================================
   Beita Image — Preview Experience
   Reusable styles for upload preview and workflow result cards.
   Reusable across future tools (Background Remover, Social Media
   Image, Amazon Product Image, …).
   ============================================================= */

/* -------- 1. Checkerboard backdrop ----------------------------
   Visible against transparent images so the user always sees
   what's transparent vs filled. Two densities: tile-8 (default)
   and tile-16 (used by result cards where larger icons live).
   ----------------------------------------------------------- */
.preview-tile {
  background-image:
    linear-gradient(45deg, #ebe6d6 25%, transparent 25%),
    linear-gradient(-45deg, #ebe6d6 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #ebe6d6 75%),
    linear-gradient(-45deg, transparent 75%, #ebe6d6 75%);
  background-size: 16px 16px;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
  background-color: #fffbf2;
  border: 3px solid #1e1a16;
  box-shadow: 4px 4px 0 0 #1e1a16;
  border-radius: 12px;
}
.preview-tile--sm {
  background-size: 8px 8px;
  background-position: 0 0, 0 4px, 4px -4px, -4px 0;
}


/* -------- 2. Upload preview -----------------------------------
   Horizontal layout: image is the primary visual, info column
   to the right. On mobile, stacks vertically.
   ----------------------------------------------------------- */
.upload-preview {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1.25rem;
  width: 100%;
  align-items: center;
  text-align: left;
}
@media (min-width: 640px) {
  .upload-preview {
    grid-template-columns: minmax(0, 240px) minmax(0, 1fr);
    gap: 1.75rem;
  }
}
@media (min-width: 1024px) {
  .upload-preview {
    grid-template-columns: minmax(0, 320px) minmax(0, 1fr);
  }
}

.upload-preview__media {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  border-radius: 1rem;
  min-height: 200px;
  max-height: 360px;
  overflow: hidden;
}
.upload-preview__img {
  width: 100%;
  height: 100%;
  max-width: 240px;
  max-height: 240px;
  object-fit: contain;
}
@media (min-width: 640px) {
  .upload-preview__img {
    max-width: 320px;
    max-height: 320px;
  }
}

.upload-preview__info {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  min-width: 0;
}
.upload-preview__filename {
  font-size: 1rem;
  font-weight: 600;
  color: #0f172a;
  word-break: break-all;
  line-height: 1.4;
}
.upload-preview__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  font-size: 0.8125rem;
  color: #64748b;
}
.upload-preview__meta-item {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}
.upload-preview__meta-item strong {
  font-weight: 600;
  color: #334155;
}
.upload-preview__actions {
  margin-top: 0.25rem;
  display: flex;
  gap: 0.5rem;
}
.upload-preview__remove {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.8125rem;
  font-weight: 500;
  color: #ef4444;
  padding: 0.45rem 0.85rem;
  border-radius: 0.625rem;
  background: #fef2f2;
  transition: background-color 0.15s ease;
}
.upload-preview__remove:hover {
  background: #fee2e2;
}


/* -------- 3. PreviewCard (result tiles) -----------------------
   Workflow-agnostic. Three regions: type tag, image area,
   file info (name + actual size + note).
   ----------------------------------------------------------- */
.preview-card {
  display: flex;
  flex-direction: column;
  background: #ffffff;
  border-radius: 1rem;
  padding: 1rem;
  border: 1px solid #f1f5f9;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
  transition: box-shadow 0.18s ease, transform 0.18s ease;
}
.preview-card:hover {
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04), 0 12px 28px -16px rgba(15, 23, 42, 0.18);
  transform: translateY(-2px);
}

.preview-card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}
.preview-card__type {
  display: inline-flex;
  align-items: center;
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 0.25rem 0.55rem;
  border-radius: 0.375rem;
  background: #eef2ff;
  color: #4f46e5;
}
.preview-card__type--ico {
  background: #fdf4ff;
  color: #a21caf;
}
.preview-card__type--png {
  background: #eef2ff;
  color: #4f46e5;
}

.preview-card__media {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 168px;
  min-height: 168px;
  padding: 1.25rem;
  border-radius: 0.75rem;
  overflow: hidden;
}

/* Image render modes:
   - .preview-card__img              default (smooth) — for medium/large icons
   - .preview-card__img--crisp       crisp-edges for tiny icons (<64px source)
   The display size is driven by the inline style set from data. */
.preview-card__img {
  display: block;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}
.preview-card__img--crisp {
  image-rendering: -webkit-optimize-contrast;
  image-rendering: crisp-edges;
}

.preview-card__body {
  margin-top: 0.85rem;
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 0.3rem;
  min-width: 0;
}
.preview-card__info {
  min-height: 3.35rem;
  min-width: 0;
}
.preview-card__description {
  min-height: 4.6rem;
  overflow: hidden;
}
.preview-card__filename {
  overflow: hidden;
  font-size: 0.875rem;
  font-weight: 600;
  color: #0f172a;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.preview-card__size {
  font-size: 0.75rem;
  color: #64748b;
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
}
.preview-card__size-label {
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 0.625rem;
  font-weight: 600;
  color: #94a3b8;
}
.preview-card__size-value {
  font-weight: 600;
  color: #334155;
  font-variant-numeric: tabular-nums;
}
.preview-card__note {
  display: -webkit-box;
  overflow: hidden;
  font-size: 0.75rem;
  color: #94a3b8;
  line-height: 1.45;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

/* ICO multi-size list */
.preview-card__sizes {
  margin-top: 0.4rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}
.preview-card__sizes span {
  display: inline-flex;
  align-items: center;
  font-size: 0.6875rem;
  font-weight: 500;
  color: #475569;
  background: #f8fafc;
  padding: 0.15rem 0.5rem;
  border-radius: 0.375rem;
  font-variant-numeric: tabular-nums;
}


/* -------- 4. Result page clarification note ------------------ */
.preview-note {
  margin-top: 1.5rem;
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  padding: 0.85rem 1rem;
  border-radius: 0.75rem;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  font-size: 0.8125rem;
  color: #64748b;
  line-height: 1.5;
  text-align: left;
}
.preview-note svg {
  flex-shrink: 0;
  margin-top: 0.1rem;
  color: #94a3b8;
}


/* -------- 5. Result grid responsiveness ----------------------
   375 (mobile) → 1 col
   768 (tablet) → 2 cols
   1440 (desktop) → 3 cols (default)
   ----------------------------------------------------------- */
.preview-grid {
  display: grid;
  grid-template-columns: 1fr;
  align-items: stretch;
  gap: 1rem;
}
.preview-grid .preview-card {
  height: 100%;
}
@media (min-width: 640px) {
  .preview-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
@media (min-width: 1024px) {
  .preview-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1.25rem;
  }
}


/* -------- 6. Result sections (Main + Technical) ---------------
   Two-tier layout: "Website Icon Preview" shows the icons most users
   care about (favicon.ico, Apple Touch Icon, Android 192/512).
   "Technical Sizes" shows the small browser icons at their actual
   pixel dimensions so users see exactly what the file contains.
   ----------------------------------------------------------- */
.result-section {
  margin-top: 2rem;
}
.result-section:first-of-type {
  margin-top: 2.25rem;
}

.result-section__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.result-section__title {
  font-size: 1.0625rem;
  font-weight: 600;
  color: #0f172a;
  line-height: 1.3;
}
.result-section__desc {
  margin-top: 0.25rem;
  font-size: 0.8125rem;
  color: #64748b;
  line-height: 1.45;
  max-width: 36rem;
}

.result-section__count {
  flex-shrink: 0;
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 0.25rem 0.6rem;
  border-radius: 0.375rem;
  background: #f1f5f9;
  color: #475569;
  align-self: flex-start;
}


/* Technical Sizes grid uses a 2-column layout (favicon-16 and
   favicon-32 only) and the cards use a compact variant below. */
.preview-grid--technical {
  grid-template-columns: 1fr;
}
@media (min-width: 640px) {
  .preview-grid--technical {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    max-width: 32rem;
  }
}


/* Compact card variant for the Technical Sizes section — the icon
   inside is shown at its actual pixel size (16 or 32), so the
   surrounding frame stays generous without inflating the image. */
.preview-card--technical {
  padding: 0.85rem;
}
.preview-card--technical .preview-card__media {
  height: 120px;
  min-height: 120px;
  padding: 1rem;
}
.preview-card--technical .preview-card__badge {
  display: inline-flex;
  align-items: center;
  font-size: 0.625rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #475569;
  background: #f1f5f9;
  padding: 0.15rem 0.45rem;
  border-radius: 0.3rem;
}

/* V1.6: actual-size variant (≤ 64 px). The IMG is exactly its native
   pixel size — no preview-tile wrapper, no fixed preview box, no
   object-fit scaling, no width: 100% / max-width: 100%. The card
   becomes a flex row that wraps; the image sits inline with the body
   so the whole card collapses to the image's intrinsic dimensions. */
.preview-card--actual {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: flex-start;
  padding: 0.5rem;
  gap: 0.5rem;
}
.preview-card--actual .preview-card__head {
  width: 100%;
  margin: 0;
}
.preview-card--actual .preview-card__actual {
  /* No fixed height, no checkerboard, no min-width. The IMG inside
     carries its own width/height (set via :style). */
  display: block;
  flex: 0 0 auto;
  align-self: flex-start;
  margin: 0;
  padding: 0;
  background: transparent;
}
.preview-card--actual .preview-card__img--actual {
  display: block;
  width: auto;
  height: auto;
  max-width: none;
  max-height: none;
  /* The IMG element is sized exactly `px × px` via inline style. The
     pixelated rendering keeps it crisp if the user zooms the page. */
  image-rendering: pixelated;
  image-rendering: -moz-crisp-edges;
}
.preview-card--actual .preview-card__body {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
  padding: 0;
}


/* -------- 7. Per-card download button ------------------------
   Anchored to the bottom of each preview card so the layout stays
   balanced regardless of note / sizes content length.
   ----------------------------------------------------------- */
.preview-card__download {
  margin-top: auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  width: 100%;
  padding: 0.55rem 0.75rem;
  border-radius: 0.625rem;
  background: #eef2ff;
  color: #4338ca;
  font-size: 0.8125rem;
  font-weight: 600;
  transition: background-color 0.15s ease, color 0.15s ease;
}
.preview-card__download:hover {
  background: #4338ca;
  color: #ffffff;
}
.preview-card__download svg {
  flex-shrink: 0;
}


/* -------- 8. "Also included" extras list ---------------------
   Lists non-visual artefacts (e.g. site.webmanifest) so the user
   knows the package contains more than just the rendered icons.
   ----------------------------------------------------------- */
.result-extras {
  margin-top: 1.5rem;
  padding: 0.85rem 1rem;
  border-radius: 0.75rem;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  text-align: left;
}
.result-extras__label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #64748b;
}
.result-extras ul {
  margin-top: 0.45rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1rem;
  font-size: 0.8125rem;
  color: #334155;
  font-variant-numeric: tabular-nums;
}
.result-extras li::before {
  content: "•";
  margin-right: 0.4rem;
  color: #94a3b8;
}


/* -------- 7. OG image preview (single 1200×630 share card) ----
   The OG Image Workflow produces one PNG at 1200 × 630, with a
   1.91:1 aspect ratio. We display the preview at full container
   width while keeping the aspect ratio, so the user sees exactly
   what a social platform will render.

   NOTE (V1.13): The Social Media Image Resizer re-used this class for
   its Step 3 result preview, but the four documented targets ship at
   different aspect ratios (1080×1080, 1200×627, 1200×628, 1280×720),
   so the hard-coded ``1200/630`` produced a visibly-wrong preview
   frame on three of them. The resizer template now sets the
   ``aspect-ratio`` inline per-target and only uses
   ``.og-preview__img--natural`` (no preset aspect-ratio) when the
   intrinsic aspect should drive the layout.
   ------------------------------------------------------------- */
.og-preview {
  position: relative;
  width: 100%;
  background: #f1f5f9;          /* tailwind slate-100 — the empty canvas */
  display: flex;
  align-items: center;
  justify-content: center;
}
.og-preview__img {
  display: block;
  width: 100%;
  height: auto;
  object-fit: contain;
}
/* Used by the OG workflow only — the resizer overrides aspect-ratio
   inline based on the picked target. */
.og-preview__img--og {
  aspect-ratio: 1200 / 630;
}