/* ==========================================================================
   Amelion.ai — Studio Glass UI (visionOS / Studio Display inspired)
   Reusable template. Re-theme via the tokens in :root.
   Building blocks: .glass (surface), .brand, .drop-zone, .pill-toggle,
   .btn, .status, .card, .badge. Icons: Lucide (<i data-lucide="…">).
   State hook: body.is-processing (set by app.js while the queue runs).
   ========================================================================== */

:root {
  --font: system-ui, -apple-system, BlinkMacSystemFont, Inter, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;

  /* Studio lighting */
  --studio-center: #f8f9fb;
  --studio-mid: #f1f3f5;
  --studio-edge: #e9ecef;
  --studio-corner: #dee2e6;

  /* Text */
  --text: #1c1c1e;
  --text-secondary: rgba(28, 28, 30, 0.6);
  --text-tertiary: rgba(28, 28, 30, 0.4);

  /* Accents */
  --blue: #007aff;
  --blue-glow: rgba(0, 122, 255, 0.4);
  --indigo: #5856d6;
  --purple: #af52de;
  --green: #34c759;
  --green-glow: rgba(52, 199, 89, 0.4);
  --danger: #d70015;

  /* Glass physics */
  --glass-shadow:
    inset 0 1px 1px rgba(255, 255, 255, 0.9),
    0 20px 45px rgba(0, 0, 0, 0.06),
    0 4px 12px rgba(0, 0, 0, 0.03);
  --glass-shadow-lift:
    inset 0 1px 1px rgba(255, 255, 255, 0.9),
    0 28px 56px rgba(0, 0, 0, 0.08),
    0 6px 16px rgba(0, 0, 0, 0.04);
  --focus-ring: 0 0 0 4px rgba(0, 122, 255, 0.28);

  --radius-panel: 32px;
  --radius-pill: 50px;

  --ease: cubic-bezier(0.25, 1, 0.5, 1);
  --duration: 0.5s;

  font-family: var(--font);
  color: var(--text);
  color-scheme: light;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

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

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  line-height: 1.5;
  background-color: var(--studio-edge);
}

/* Studio light: a soft spotlight that stays fixed while the page scrolls. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background: radial-gradient(
    ellipse 85% 75% at 50% 38%,
    var(--studio-center) 0%,
    var(--studio-mid) 38%,
    var(--studio-edge) 68%,
    var(--studio-corner) 100%
  );
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* Holds shared SVG <defs>; must stay rendered (not display:none) for gradients. */
.svg-defs {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.lucide {
  stroke-width: 1.75;
}

/* ==========================================================================
   Glass surface
   ========================================================================== */

.glass {
  position: relative;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.25);
  backdrop-filter: blur(24px) saturate(120%);
  -webkit-backdrop-filter: blur(24px) saturate(120%);
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-top: 1px solid rgba(255, 255, 255, 0.7);
  border-left: 1px solid rgba(255, 255, 255, 0.7);
  box-shadow: var(--glass-shadow);
  transition: all var(--duration) var(--ease);
}

@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .glass {
    background: rgba(255, 255, 255, 0.72);
  }
}

/* Shine that sweeps across every glass surface while the AI is working. */
.glass::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 2;
  border-radius: inherit;
  background: linear-gradient(
    110deg,
    transparent 25%,
    rgba(255, 255, 255, 0.7) 50%,
    transparent 75%
  );
  opacity: 0;
  transform: translateX(-130%);
  pointer-events: none;
}

.is-processing .glass::after {
  opacity: 1;
  animation: sheen 2.8s var(--ease) infinite;
}

/* ==========================================================================
   Layout & branding
   ========================================================================== */

.app {
  display: flex;
  flex-direction: column;
  gap: 20px;
  max-width: 800px;
  margin: 0 auto;
  padding: 72px 20px 88px;
}

.hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 16px;
  text-align: center;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.26em;
  margin: 0;
  font-size: clamp(2.4rem, 7vw, 3.6rem);
  font-weight: 700;
  letter-spacing: -0.045em;
  line-height: 1.05;
}

/* App-icon style squircle; sizes in em so it scales with the title. */
.brand-mark {
  display: grid;
  flex-shrink: 0;
  place-items: center;
  width: 1.2em;
  height: 1.2em;
  margin-right: 0.08em;
  border-radius: 0.36em;
}

.brand-mark svg {
  width: 0.68em;
  height: 0.68em;
  stroke: url(#brand-gradient);
  stroke-width: 1.6;
}

/* ".ai" micro glass capsule. */
.brand-tld {
  display: inline-flex;
  align-items: center;
  padding: 0.24em 0.62em 0.28em;
  border: 1px solid rgba(255, 255, 255, 0.9);
  border-radius: var(--radius-pill);
  background:
    linear-gradient(135deg, rgba(0, 122, 255, 0.1), rgba(175, 82, 222, 0.12)),
    rgba(255, 255, 255, 0.55);
  backdrop-filter: blur(12px) saturate(140%);
  -webkit-backdrop-filter: blur(12px) saturate(140%);
  box-shadow:
    inset 0 1px 1px rgba(255, 255, 255, 0.95),
    0 6px 16px rgba(88, 86, 214, 0.14),
    0 1px 3px rgba(0, 0, 0, 0.04);
  font-size: 0.6em;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1;
  transform: translateY(-0.12em);
}

.brand-tld > span {
  background: linear-gradient(135deg, var(--blue), var(--indigo) 55%, var(--purple));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.tagline {
  margin: 14px 0 0;
  font-size: 1.1rem;
  font-weight: 500;
  letter-spacing: -0.01em;
  color: var(--text-secondary);
}

/* ==========================================================================
   Drop zone
   ========================================================================== */

.drop-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 280px;
  padding: 56px 28px;
  border-radius: var(--radius-panel);
  text-align: center;
  cursor: pointer;
}

/* Soft light that follows the pointer (position set by app.js). */
.drop-zone::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: radial-gradient(
    380px circle at var(--mx, 50%) var(--my, 35%),
    rgba(255, 255, 255, 0.7),
    transparent 65%
  );
  opacity: 0;
  transition: opacity var(--duration) var(--ease);
  pointer-events: none;
}

.drop-ring {
  position: absolute;
  inset: 14px;
  border: 1.5px dashed rgba(28, 28, 30, 0.14);
  border-radius: 22px;
  pointer-events: none;
  transition: all var(--duration) var(--ease);
}

.drop-icon,
.drop-title,
.drop-hint {
  position: relative;
  z-index: 1;
}

.drop-icon {
  display: grid;
  place-items: center;
  width: 76px;
  height: 76px;
  margin-bottom: 14px;
  border: 1px solid rgba(255, 255, 255, 0.95);
  border-radius: 50%;
  background: linear-gradient(180deg, #fff, rgba(255, 255, 255, 0.6));
  box-shadow: inset 0 1px 1px #fff, 0 12px 28px rgba(0, 0, 0, 0.07), 0 2px 6px rgba(0, 0, 0, 0.03);
  color: var(--blue);
  transition: all var(--duration) var(--ease);
}

.drop-icon svg {
  width: 30px;
  height: 30px;
}

.drop-title {
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.drop-hint {
  font-size: 0.95rem;
  color: var(--text-secondary);
}

.drop-zone:hover {
  background: rgba(255, 255, 255, 0.34);
  box-shadow: var(--glass-shadow-lift);
}

.drop-zone:hover::before {
  opacity: 0.8;
}

.drop-zone:hover .drop-icon {
  transform: translateY(-4px);
}

.drop-zone:focus-visible {
  outline: none;
  box-shadow: var(--glass-shadow), var(--focus-ring);
}

/* Magnetism: lift, brighter glass edge, stronger blur. */
.drop-zone.is-dragover {
  transform: scale(1.02);
  background: rgba(255, 255, 255, 0.42);
  border-color: #fff;
  backdrop-filter: blur(40px) saturate(140%);
  -webkit-backdrop-filter: blur(40px) saturate(140%);
  box-shadow:
    inset 0 1px 1px rgba(255, 255, 255, 0.95),
    0 28px 60px rgba(0, 0, 0, 0.09),
    0 0 0 4px rgba(0, 122, 255, 0.1),
    0 0 50px rgba(0, 122, 255, 0.12);
}

.drop-zone.is-dragover::before {
  opacity: 1;
}

.drop-zone.is-dragover .drop-ring {
  inset: 10px;
  border-color: rgba(0, 122, 255, 0.5);
  box-shadow: inset 0 0 30px rgba(0, 122, 255, 0.06);
}

.drop-zone.is-dragover .drop-icon {
  transform: translateY(-8px) scale(1.08);
  box-shadow: inset 0 1px 1px #fff, 0 18px 40px rgba(0, 122, 255, 0.2);
}

.drop-zone.is-dragover .drop-icon svg {
  animation: bob 1.2s ease-in-out infinite;
}

/* ==========================================================================
   Controls row
   ========================================================================== */

.controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.toggles {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.actions {
  display: flex;
  gap: 12px;
  margin-left: auto;
}

/* ==========================================================================
   Pill toggles — a liquid fill spreads out from the icon when checked
   ========================================================================== */

.pill-toggle {
  --tone: var(--blue);
  --tone-glow: var(--blue-glow);
  display: inline-flex;
  align-items: center;
  gap: 10px;
  height: 52px;
  padding: 0 12px;
  border-radius: var(--radius-pill);
  font-size: 0.98rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  cursor: pointer;
  user-select: none;
}

.pill-toggle--green {
  --tone: var(--green);
  --tone-glow: var(--green-glow);
}

.pill-input {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: 0;
  opacity: 0;
  pointer-events: none;
}

/* Circle centred on the icon with radius = pill width, so it always just
   covers the pill and the whole scale range reads as a visible spread. */
.pill-fill {
  position: absolute;
  top: 50%;
  left: 29px; /* centre of .pill-icon */
  z-index: 0;
  width: 200%;
  aspect-ratio: 1;
  margin: -100% 0 0 -100%; /* percentages resolve against pill width */
  border-radius: 50%;
  background: var(--tone);
  transform: scale(0);
  transition: transform 0.9s var(--ease);
}

.pill-icon,
.pill-label,
.pill-check {
  position: relative;
  z-index: 1;
  transition: all var(--duration) var(--ease);
}

.pill-icon {
  display: grid;
  flex-shrink: 0;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.7);
  box-shadow: inset 0 1px 1px #fff, 0 1px 3px rgba(0, 0, 0, 0.06);
  color: var(--tone);
}

.pill-icon svg {
  width: 18px;
  height: 18px;
}

.pill-label {
  flex: 1;
  white-space: nowrap;
}

.pill-check {
  display: grid;
  flex-shrink: 0;
  place-items: center;
  width: 24px;
  height: 24px;
  margin-left: 4px;
  border: 1.5px solid rgba(28, 28, 30, 0.18);
  border-radius: 50%;
  color: var(--tone);
}

.pill-check svg {
  width: 14px;
  height: 14px;
  stroke-width: 3.25;
  transform: scale(0);
  transition: transform var(--duration) cubic-bezier(0.34, 1.56, 0.64, 1);
}

.pill-toggle:hover {
  background: rgba(255, 255, 255, 0.38);
  box-shadow: var(--glass-shadow-lift);
  transform: translateY(-2px);
}

.pill-toggle:has(.pill-input:checked) {
  color: #fff;
  border-color: rgba(255, 255, 255, 0.5);
  box-shadow: var(--glass-shadow), 0 10px 28px -8px var(--tone-glow);
}

.pill-input:checked ~ .pill-fill {
  transform: scale(1);
}

.pill-input:checked ~ .pill-icon {
  background: rgba(255, 255, 255, 0.24);
  box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.35);
  color: #fff;
}

.pill-input:checked ~ .pill-check {
  border-color: #fff;
  background: #fff;
}

.pill-input:checked ~ .pill-check svg {
  transform: scale(1);
}

.pill-toggle:has(.pill-input:focus-visible) {
  box-shadow: var(--glass-shadow), var(--focus-ring);
}

.pill-toggle:has(.pill-input:disabled) {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.pill-toggle:active,
.btn:active:not(:disabled) {
  transform: scale(0.96);
  transition-duration: 0.2s;
}

/* ==========================================================================
   Buttons
   ========================================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 52px;
  padding: 0 26px;
  border-radius: var(--radius-pill);
  font: inherit;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
  text-decoration: none;
  cursor: pointer;
}

.btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.4);
  box-shadow: var(--glass-shadow-lift);
  transform: translateY(-2px);
}

.btn:focus-visible {
  outline: none;
  box-shadow: var(--glass-shadow), var(--focus-ring);
}

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

.btn-primary {
  padding: 0 28px 0 22px;
  color: var(--blue);
}

.btn-primary:hover:not(:disabled) {
  box-shadow: var(--glass-shadow-lift), 0 10px 30px -6px var(--blue-glow);
}

/* Reserves space before Lucide swaps the <i> for an <svg>. */
.btn-icon {
  display: inline-block;
  flex-shrink: 0;
  width: 18px;
  height: 18px;
}

.btn-small {
  height: 42px;
  padding: 0 18px;
  font-size: 0.9rem;
}

/* Processing: the primary button breathes while the queue runs. */
.is-processing .btn-primary:disabled {
  opacity: 1;
  cursor: progress;
  animation: pulse 1.8s ease-in-out infinite;
}

.is-processing .btn-primary .btn-icon {
  animation: twirl 2.4s var(--ease) infinite;
}

/* ==========================================================================
   Status pill
   ========================================================================== */

.status {
  align-self: center;
  max-width: 100%;
  margin: 0;
  padding: 10px 20px;
  border-radius: var(--radius-pill);
  font-size: 0.92rem;
  font-weight: 500;
  color: var(--text-secondary);
  text-align: center;
}

.status:empty {
  display: none;
}

/* ==========================================================================
   Queue cards
   ========================================================================== */

.queue {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 18px;
  margin: 8px 0 0;
  padding: 0;
  list-style: none;
}

.queue:empty {
  display: none;
}

.card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 12px;
  border-radius: var(--radius-panel);
  animation: card-in 0.7s var(--ease) both;
}

.card-images {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.card figure {
  margin: 0;
}

/* Concentric corners: 32px card - 12px padding = 20px outer image corners. */
.card img,
.card .placeholder {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 20px 8px 8px 8px;
  background: rgba(255, 255, 255, 0.5);
}

.card .result img,
.card .result .placeholder {
  border-radius: 8px 20px 8px 8px;
}

.card .result img {
  animation: fade-in 0.8s var(--ease);
}

.card figcaption {
  margin-top: 6px;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  text-align: center;
}

.card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 6px;
}

.card-name {
  overflow: hidden;
  font-size: 0.92rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.card-error {
  margin: 0 6px;
  font-size: 0.84rem;
  color: var(--danger);
}

.card-error:empty {
  display: none;
}

.card-download {
  align-self: stretch;
}

.card[data-status="processing"] {
  box-shadow: var(--glass-shadow), 0 0 0 2px rgba(0, 122, 255, 0.22), 0 12px 36px -10px var(--blue-glow);
}

.card[data-status="processing"] .placeholder {
  background:
    linear-gradient(100deg, transparent 30%, rgba(255, 255, 255, 0.9) 50%, transparent 70%)
    rgba(255, 255, 255, 0.5);
  background-size: 250% 100%;
  animation: placeholder-shimmer 1.4s linear infinite;
}

.card[data-status="error"] {
  box-shadow: var(--glass-shadow), 0 0 0 2px rgba(255, 59, 48, 0.16);
}

/* ---------- Badges ---------- */

.badge {
  flex-shrink: 0;
  padding: 4px 11px;
  border-radius: var(--radius-pill);
  font-size: 0.74rem;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.6);
  color: var(--text-secondary);
  transition: all var(--duration) var(--ease);
}

.card[data-status="processing"] .badge {
  background: rgba(0, 122, 255, 0.12);
  color: #0062d6;
}

.card[data-status="done"] .badge {
  background: rgba(52, 199, 89, 0.16);
  color: #1f8a3b;
}

.card[data-status="error"] .badge {
  background: rgba(255, 59, 48, 0.12);
  color: var(--danger);
}

/* ==========================================================================
   Keyframes
   ========================================================================== */

@keyframes sheen {
  0% {
    transform: translateX(-130%);
  }
  55%,
  100% {
    transform: translateX(130%);
  }
}

@keyframes pulse {
  0% {
    transform: scale(1);
    box-shadow: var(--glass-shadow), 0 0 0 0 rgba(0, 122, 255, 0.35);
  }
  50% {
    transform: scale(1.04);
    box-shadow: var(--glass-shadow), 0 0 0 8px rgba(0, 122, 255, 0.12);
  }
  70% {
    box-shadow: var(--glass-shadow), 0 0 0 14px rgba(0, 122, 255, 0);
  }
  100% {
    transform: scale(1);
    box-shadow: var(--glass-shadow), 0 0 0 14px rgba(0, 122, 255, 0);
  }
}

@keyframes twirl {
  to {
    rotate: 360deg;
  }
}

@keyframes bob {
  50% {
    transform: translateY(-4px);
  }
}

@keyframes placeholder-shimmer {
  from {
    background-position: 100% 0;
  }
  to {
    background-position: 0 0;
  }
}

@keyframes card-in {
  from {
    opacity: 0;
    transform: translateY(16px) scale(0.97);
  }
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ==========================================================================
   Small screens
   ========================================================================== */

@media (max-width: 640px) {
  .app {
    gap: 16px;
    padding: 48px 16px 64px;
  }

  .tagline {
    font-size: 1rem;
  }

  .drop-zone {
    min-height: 240px;
    padding: 44px 20px;
  }

  .controls,
  .toggles {
    flex-direction: column;
    align-items: stretch;
  }

  .pill-toggle {
    width: 100%;
  }

  .actions {
    margin-left: 0;
  }

  .actions .btn {
    flex: 1;
  }
}
