/* ============================================================
   Image to PNG — base.css
   Classes  : itp-*
   Approach : Mobile-first (base = mobile, @media min-width = desktop)
   Brand    : #42B5A4 (teal) — protected across every UI state
   Contains : tokens, reset, header, stepper, panels, buttons, toast
   ============================================================ */


/* ══════════════════════════════════════════
   0. BASE / RESET / BRAND TOKENS
   ══════════════════════════════════════════ */
.itp-wrap,
.itp-wrap * {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

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

body {
  margin: 0;
  min-width: 320px;
  overflow-x: hidden;
}

:root {
  /* ── Brand color tokens — defined on :root (not scoped to
     .itp-wrap) so that elements rendered OUTSIDE
     the main wrapper — like the toast notification, which is a
     sibling of <main>, not a descendant — still inherit them.
     A scoped custom property is invisible to non-descendants;
     that gap was exactly why the toast previously rendered with
     no background color and unreadable white-on-white text. ── */
  --itp-brand: #42B5A4;
  --itp-brand-dark: #2E8577;
  --itp-brand-soft: #E8F8F6;

  --itp-ink: #1a1a22;
  --itp-ink-soft: #55555f;
  --itp-line: #e4e4ee;
  --itp-line-strong: #c4c4d4;
  --itp-bg: #f5f5fa;
  --itp-error: #c0392b;
  --itp-success: #1e8e5a;
}

.itp-wrap {
  max-width: 720px;
  margin: 0 auto;
  /* safe-area insets: keep content clear of notches / rounded corners /
     home bar (viewport-fit=cover is on), especially in landscape */
  padding: 24px max(16px, env(safe-area-inset-right)) calc(56px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  touch-action: manipulation;
  overscroll-behavior-y: contain;
}


/* ══════════════════════════════════════════
   1. HEADER
   ══════════════════════════════════════════ */
.itp-header {
  text-align: center;
  margin-bottom: 24px;
}

.itp-header__title {
  font-weight: 800;
  font-size: clamp(1.65rem, 6.5vw, 2.4rem);
  letter-spacing: -0.9px;
  color: var(--itp-ink);
  margin: 0 0 8px;
}

.itp-header__title strong {
  font-weight: 900;
  color: var(--itp-brand);
}

.itp-header__subtitle {
  font-size: 15.5px;
  font-weight: 600;
  color: var(--itp-ink-soft);
  line-height: 1.6;
  margin: 0;
  overflow-wrap: break-word;
}

.itp-header__note {
  font-size: 12.5px;
  font-weight: 500;
  color: #8a8a96;
  line-height: 1.5;
  margin: 8px 0 0;
}

.itp-header__subtitle a {
  color: var(--itp-brand-dark);
  font-weight: 700;
  text-decoration: underline;
  text-decoration-color: var(--itp-brand-soft);
  text-underline-offset: 2px;
}

.itp-header__subtitle a:hover,
.itp-header__subtitle a:focus-visible {
  text-decoration-color: currentColor;
}


/* ══════════════════════════════════════════
   2. STEPPER
   ══════════════════════════════════════════ */
.itp-stepper {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-bottom: 28px;
}

.itp-stepper__step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.itp-stepper__dot {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  color: #9999a2;
  background: #fff;
  border: 1.5px solid var(--itp-line);
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.itp-stepper__step.is-active .itp-stepper__dot {
  background: var(--itp-brand);
  border-color: var(--itp-brand);
  color: #fff;
}

.itp-stepper__step.is-done .itp-stepper__dot {
  background: var(--itp-brand-soft);
  border-color: var(--itp-brand);
  color: var(--itp-brand);
}

.itp-stepper__dot--export {
  width: auto;
  border-radius: 9999px;
  padding: 0 16px;
  font-size: 12.5px;
  letter-spacing: 0.3px;
  text-transform: uppercase;
}

.itp-stepper__label {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--itp-ink-soft);
}

.itp-stepper__line {
  width: 28px;
  height: 2px;
  background: var(--itp-line);
  margin-top: -18px;
}


/* ══════════════════════════════════════════
   3. PANELS
   ══════════════════════════════════════════ */
.itp-panel {
  display: none;
}

.itp-panel.is-active {
  display: block;
  animation: fcFadeIn 0.28s ease both;
}

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


/* ══════════════════════════════════════════
   4. ACTION BUTTONS (shared across all 3 steps)
   ══════════════════════════════════════════ */
.itp-actions {
  display: flex;
  gap: 10px;
  margin-top: 24px;
}

.itp-btn {
  flex: 1 1 0;
  min-width: 0;
  min-height: 48px;
  padding: 0 16px;
  border-radius: 9999px;
  font-family: inherit;
  font-weight: 800;
  font-size: 15.5px;
  border: 1.5px solid transparent;
  cursor: pointer;
  touch-action: manipulation;
  line-height: 1.2;
}

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

.itp-btn--primary {
  background: var(--itp-brand);
  color: #fff;
  box-shadow: 0 2px 10px rgba(66,181,164,0.28);
}

.itp-btn--primary:active {
  transform: scale(0.98);
}

.itp-btn--ghost {
  background: #fff;
  border-color: var(--itp-line);
  color: var(--itp-ink);
}

.itp-btn--ghost:active {
  background: var(--itp-bg);
}

/* Secondary = "download one by one" — sits between ghost and primary,
   brand-tinted outline so it doesn't compete with the primary ZIP action */
.itp-btn--secondary {
  background: var(--itp-brand-soft);
  border-color: var(--itp-brand-soft);
  color: var(--itp-brand-dark);
}

.itp-btn--secondary:active {
  background: #d9f2ee;
}


/* ══════════════════════════════════════════
   5. TOAST
   ══════════════════════════════════════════ */
.itp-toast {
  position: fixed;
  left: 50%;
  bottom: calc(28px + env(safe-area-inset-bottom));
  transform: translate(-50%, 16px) scale(0.96);
  display: inline-flex;
  align-items: center;
  gap: 11px;
  background: var(--itp-ink);
  color: #fff;
  padding: 13px 20px 13px 15px;
  border-radius: 16px;
  border: 1px solid rgba(255,255,255,0.08);
  font-family: 'Inter', sans-serif;
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.4;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s cubic-bezier(0.16, 1, 0.3, 1), transform 0.22s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 999;
  box-shadow: 0 12px 32px rgba(0,0,0,0.24), 0 2px 8px rgba(0,0,0,0.14);
  width: max-content;
  max-width: calc(100vw - 32px);
  text-align: left;
}

.itp-toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0) scale(1);
}

/* Status icon — a small filled circle with a check/exclamation
   glyph, so a toast reads at a glance without parsing the text
   first. Pure CSS, no change needed in the JS that sets it. */
.itp-toast::before {
  content: '✓';
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(255,255,255,0.16);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
}

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

.itp-toast.is-error::before {
  content: '!';
}


/* ══════════════════════════════════════════
   5b. SMALL PHONES (≤520px) — stack the 3 export buttons so
   nothing overflows; primary (ZIP) on top, Back at the bottom
   ══════════════════════════════════════════ */
@media (max-width: 520px) {
  .itp-actions--export {
    flex-direction: column-reverse;
  }

  .itp-actions--export .itp-btn {
    flex: 0 0 auto;
    width: 100%;
  }
}

@media (max-width: 340px) {
  .itp-wrap {
    padding-top: 16px;
  }

  .itp-stepper__line {
    width: 18px;
  }

  .itp-header__subtitle {
    font-size: 14.5px;
  }
}


/* ══════════════════════════════════════════
   6. DESKTOP ENHANCEMENTS (≥768px)
   ══════════════════════════════════════════ */
@media (min-width: 768px) {
  .itp-wrap {
    padding: 40px 24px 72px;
  }

  .itp-header__subtitle {
    font-size: 16px;
  }

  .itp-stepper {
    gap: 10px;
    margin-bottom: 36px;
  }

  .itp-stepper__line {
    width: 56px;
  }

  .itp-actions {
    max-width: 420px;
    margin-left: auto;
    margin-right: auto;
  }

  .itp-actions--export {
    max-width: 560px;
  }
}


@media (hover: hover) {
  .itp-btn--ghost:hover {
    border-color: var(--itp-ink);
  }

  .itp-btn--primary:hover {
    box-shadow: 0 4px 16px rgba(66,181,164,0.36);
  }

  .itp-btn--secondary:hover {
    background: #d9f2ee;
  }
}

/* Large desktop (≥1100px): use the extra room */
@media (min-width: 1100px) {
  .itp-wrap {
    max-width: 880px;
  }
}


/* ══════════════════════════════════════════
   7. ACCESSIBILITY
   ══════════════════════════════════════════ */
.itp-wrap :focus-visible {
  outline: 2px solid var(--itp-brand);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  .itp-panel.is-active {
    animation: none;
  }

  .itp-toast {
    transition: opacity 0.15s ease;
    transform: translate(-50%, 0) scale(1);
  }
}
