/* ═══════════════════════════════════════════════════════════
   THE GIF-ORIZER 4000
   Warm retro theme — deep purple / orange / teal
   Palette from the logo: purple walrus, orange bg, teal circuits
   ═══════════════════════════════════════════════════════════ */

:root {
  --bg: #1a0f2e;
  --bg-dark: #120a20;
  --surface: #221640;
  --border: #3d2a6e;
  --accent: #e8a030;
  --accent2: #f0b848;
  --purple: #9b59b6;
  --teal: #2dd4a8;
  --text: #f0e8d8;
  --text-dim: #7a6b8a;
  --pixel-shadow: 3px 3px 0 rgba(232, 160, 48, 0.25);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { font-size: 16px; }

body {
  font-family: 'Space Mono', monospace;
  background: var(--bg);
  background-image:
    radial-gradient(ellipse at 30% 50%, rgba(155, 89, 182, 0.08) 0%, transparent 50%),
    radial-gradient(ellipse at 70% 20%, rgba(232, 160, 48, 0.06) 0%, transparent 50%);
  color: var(--text);
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1rem;
  overflow-x: hidden;
}

.scanlines {
  position: fixed; inset: 0;
  background: repeating-linear-gradient(0deg, rgba(0,0,0,0.06) 0px, rgba(0,0,0,0.06) 1px, transparent 1px, transparent 3px);
  pointer-events: none; z-index: 9999;
}

/* ── FLOATING BACKGROUND ───────────────── */

.bg-floats { position: fixed; inset: 0; pointer-events: none; z-index: 0; overflow: hidden; }
.bg-icon { position: absolute; opacity: 0.06; animation: bgDrift linear infinite; font-size: 1.8rem; }
.bg-icon:nth-child(1) { left: 8%; top: 15%; font-size: 2rem; animation-duration: 20s; animation-delay: 0s; }
.bg-icon:nth-child(2) { left: 85%; top: 22%; font-size: 1.6rem; animation-duration: 24s; animation-delay: -5s; }
.bg-icon:nth-child(3) { left: 20%; top: 55%; font-size: 2.2rem; animation-duration: 18s; animation-delay: -8s; }
.bg-icon:nth-child(4) { left: 72%; top: 65%; font-size: 1.4rem; animation-duration: 22s; animation-delay: -3s; }
.bg-icon:nth-child(5) { left: 45%; top: 82%; font-size: 1.8rem; animation-duration: 16s; animation-delay: -11s; }
.bg-icon:nth-child(6) { left: 92%; top: 45%; font-size: 1.5rem; animation-duration: 21s; animation-delay: -7s; }
.bg-icon:nth-child(7) { left: 35%; top: 30%; font-size: 2rem; animation-duration: 25s; animation-delay: -14s; }
.bg-icon:nth-child(8) { left: 60%; top: 8%; font-size: 1.3rem; animation-duration: 19s; animation-delay: -9s; }

@keyframes bgDrift {
  0% { transform: translateY(0) rotate(0deg); }
  25% { transform: translateY(-12px) rotate(5deg); }
  50% { transform: translateY(-4px) rotate(-3deg); }
  75% { transform: translateY(-16px) rotate(4deg); }
  100% { transform: translateY(0) rotate(0deg); }
}

#app { width: 100%; max-width: 520px; display: flex; flex-direction: column; gap: 1rem; position: relative; z-index: 1; }

/* ── HEADER ─────────────────────────────── */

header { text-align: center; padding: 1rem 0 0.25rem; }

.hero-logo {
  width: 200px; height: 200px; border-radius: 16px; object-fit: cover;
  border: 3px solid var(--accent);
  box-shadow: 0 0 30px rgba(232, 160, 48, 0.3), 0 0 60px rgba(232, 160, 48, 0.1), 0 0 0 6px var(--bg), 0 0 0 8px var(--border);
  animation: logoPulse 4s ease-in-out infinite;
  transition: transform 0.3s;
}
.hero-logo:hover { transform: scale(1.05) rotate(-2deg); }

@keyframes logoPulse {
  0%, 100% { box-shadow: 0 0 30px rgba(232, 160, 48, 0.3), 0 0 60px rgba(232, 160, 48, 0.1), 0 0 0 6px var(--bg), 0 0 0 8px var(--border); }
  50% { box-shadow: 0 0 40px rgba(232, 160, 48, 0.5), 0 0 80px rgba(232, 160, 48, 0.2), 0 0 0 6px var(--bg), 0 0 0 8px var(--accent); }
}

.privacy-badge {
  font-family: 'Orbitron', sans-serif; font-weight: 900; font-size: 0.75rem;
  color: var(--teal); letter-spacing: 0.1em; margin-top: 0.75rem;
  padding: 0.6rem 1.2rem; border: 2px solid var(--teal); border-radius: 4px;
  display: inline-block; background: rgba(45, 212, 168, 0.06);
  text-shadow: 0 0 10px rgba(45, 212, 168, 0.3);
  animation: badgeGlow 3s ease-in-out infinite;
}
@keyframes badgeGlow {
  0%, 100% { border-color: var(--teal); box-shadow: 0 0 8px rgba(45, 212, 168, 0.1); }
  50% { border-color: var(--accent); box-shadow: 0 0 16px rgba(232, 160, 48, 0.2); }
}

.privacy-sub { font-size: 0.8rem; font-weight: 700; color: var(--text-dim); letter-spacing: 0.08em; margin-top: 0.5rem; }

/* ── CARDS ──────────────────────────────── */

.card { background: var(--surface); border: 2px solid var(--border); border-radius: 4px; padding: 1.5rem; box-shadow: var(--pixel-shadow); display: none; }
.card.active { display: block; animation: cardSlam 0.4s cubic-bezier(0.34, 1.56, 0.64, 1); }
@keyframes cardSlam {
  0% { opacity: 0; transform: translateY(30px) scale(0.9); }
  60% { transform: translateY(-4px) scale(1.01); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}

/* ── DROP ZONE ─────────────────────────── */

#dropzone {
  border: 3px dashed var(--accent); border-radius: 4px; padding: 2.5rem 1rem;
  text-align: center; cursor: pointer; transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  outline: none; background: rgba(232, 160, 48, 0.03); position: relative; overflow: hidden;
}
#dropzone:hover, #dropzone:focus-visible, #dropzone.dragover {
  background: rgba(232, 160, 48, 0.08); border-color: var(--accent2);
  box-shadow: 0 0 30px rgba(232, 160, 48, 0.15);
}
#dropzone.dragover { transform: scale(1.03); border-color: var(--teal); box-shadow: 0 0 40px rgba(45, 212, 168, 0.2); }

.drop-icon { font-size: 3rem; margin-bottom: 0.75rem; animation: float 2s ease-in-out infinite; }
@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
#dropzone:hover .drop-icon { animation: wiggle 0.5s ease-in-out; }
@keyframes wiggle { 0%, 100% { transform: translateY(-6px) rotate(0); } 25% { transform: translateY(-6px) rotate(-10deg); } 75% { transform: translateY(-6px) rotate(10deg); } }

.drop-text { font-family: 'Orbitron', sans-serif; font-weight: 700; font-size: 1.1rem; color: var(--accent); margin-bottom: 0.25rem; text-shadow: 0 0 10px rgba(232, 160, 48, 0.3); transition: letter-spacing 0.2s; }
#dropzone:hover .drop-text { letter-spacing: 0.15em; }
.drop-hint { font-size: 0.8rem; color: var(--text-dim); }
.drop-formats { font-size: 0.7rem; color: var(--text-dim); margin-top: 0.75rem; letter-spacing: 0.1em; }

/* ── STEP TITLE ─────────────────────────── */

.step-title { font-family: 'Orbitron', sans-serif; font-weight: 700; font-size: 0.85rem; color: var(--accent); text-align: center; margin-bottom: 0.75rem; letter-spacing: 0.1em; }

/* ── CROP ───────────────────────────────── */

.ratio-buttons { display: flex; gap: 0.3rem; margin-bottom: 0.75rem; flex-wrap: wrap; }
.ratio-buttons .setting-btn { flex: 1; min-width: 0; font-size: 0.6rem; padding: 0.4rem 0.3rem; }

.crop-area {
  position: relative; width: 100%; background: #000; border: 2px solid var(--border);
  border-radius: 4px; overflow: hidden; margin-bottom: 1rem; touch-action: none; cursor: crosshair;
}
.crop-area canvas, .crop-area video { width: 100%; display: block; }

.crop-box {
  position: absolute; border: 2px solid var(--accent); background: rgba(232, 160, 48, 0.1);
  cursor: move; box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.5);
  min-width: 30px; min-height: 30px;
}

.crop-box::before {
  content: ''; position: absolute; inset: 0;
  background:
    linear-gradient(var(--accent), var(--accent)) 33.33% 0 / 1px 100% no-repeat,
    linear-gradient(var(--accent), var(--accent)) 66.66% 0 / 1px 100% no-repeat,
    linear-gradient(var(--accent), var(--accent)) 0 33.33% / 100% 1px no-repeat,
    linear-gradient(var(--accent), var(--accent)) 0 66.66% / 100% 1px no-repeat;
  opacity: 0.3; pointer-events: none;
}

/* Corner handles */
.crop-handle {
  position: absolute; width: 14px; height: 14px; background: var(--accent);
  border: 2px solid var(--bg); border-radius: 2px; z-index: 2;
}
.crop-handle.tl { top: -7px; left: -7px; cursor: nw-resize; }
.crop-handle.tr { top: -7px; right: -7px; cursor: ne-resize; }
.crop-handle.bl { bottom: -7px; left: -7px; cursor: sw-resize; }
.crop-handle.br { bottom: -7px; right: -7px; cursor: se-resize; }

/* ── CROP PANEL ─────────────────────────── */

.crop-panel {
  margin: 0.75rem 0; padding: 0.75rem; background: var(--bg-dark);
  border: 1px solid var(--border); border-radius: 4px;
  animation: cardSlam 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.crop-actions { display: flex; gap: 0.5rem; margin-top: 0.75rem; }
.crop-actions .btn-pixel { font-size: 0.7rem; padding: 0.5rem 0.75rem; }

#btnToggleCrop.crop-active { color: var(--accent); border-color: var(--accent); background: rgba(232, 160, 48, 0.1); }

/* ── VIDEO PREVIEW ─────────────────────── */

.video-preview-wrap {
  width: 100%; border-radius: 4px; overflow: hidden; border: 2px solid var(--border);
  margin-bottom: 1rem; background: #000;
}
.video-preview-wrap video { width: 100%; display: block; max-height: 250px; object-fit: contain; }

/* ── INFO ──────────────────────────────── */

.video-info { margin-bottom: 1rem; padding: 0.75rem; background: var(--bg-dark); border: 1px solid var(--border); border-radius: 4px; }
.info-row { display: flex; justify-content: space-between; padding: 0.3rem 0.4rem; font-size: 0.8rem; border-radius: 3px; transition: background 0.15s; }
.info-row:hover { background: rgba(232, 160, 48, 0.05); }
.info-label { color: var(--text-dim); font-size: 0.7rem; letter-spacing: 0.1em; }
.info-value { color: var(--teal); font-weight: 700; }

/* ── TIME CONTROLS ─────────────────────── */

.time-controls { margin-bottom: 1rem; }
.time-input-group { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 0.5rem; }
.time-label { font-family: 'Orbitron', sans-serif; font-size: 0.6rem; color: var(--text-dim); letter-spacing: 0.15em; min-width: 3rem; }
.time-slider { flex: 1; }
.time-display { font-family: 'Space Mono', monospace; font-size: 0.8rem; font-weight: 700; color: var(--teal); min-width: 4rem; text-align: right; }

.clip-length { text-align: center; padding: 0.5rem; background: var(--bg-dark); border: 1px solid var(--border); border-radius: 4px; margin-top: 0.25rem; }
.clip-label { font-family: 'Orbitron', sans-serif; font-size: 0.6rem; color: var(--text-dim); letter-spacing: 0.1em; margin-right: 0.5rem; }
.clip-value { font-family: 'Orbitron', sans-serif; font-size: 1.2rem; font-weight: 900; color: var(--accent); }
.clip-value.over-limit { color: #e74c3c; animation: shake 0.3s; }
@keyframes shake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }
.clip-max { font-size: 0.65rem; color: var(--text-dim); margin-left: 0.3rem; }

/* ── SLIDERS ───────────────────────────── */

input[type="range"] { -webkit-appearance: none; appearance: none; width: 100%; height: 6px; background: var(--border); border-radius: 4px; outline: none; }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 18px; height: 18px; background: var(--accent); border: 2px solid var(--bg); border-radius: 50%; cursor: pointer; box-shadow: 0 2px 6px rgba(232, 160, 48, 0.3); }
input[type="range"]::-moz-range-thumb { width: 18px; height: 18px; background: var(--accent); border: 2px solid var(--bg); border-radius: 50%; cursor: pointer; }

/* ── SETTINGS ──────────────────────────── */

.setting { margin-bottom: 1rem; }
.setting-label { display: block; font-family: 'Orbitron', sans-serif; font-size: 0.6rem; color: var(--text-dim); letter-spacing: 0.15em; margin-bottom: 0.4rem; }
.setting-buttons { display: flex; gap: 0.4rem; }
.setting-btn {
  font-family: 'Space Mono', monospace; font-weight: 700; font-size: 0.75rem;
  padding: 0.6rem 0.5rem; background: var(--bg-dark); color: var(--text-dim);
  border: 2px solid var(--border); border-radius: 4px; cursor: pointer; transition: all 0.15s;
  flex: 1; text-align: center; display: flex; flex-direction: column; align-items: center; line-height: 1.3;
}
.setting-btn:hover { border-color: var(--accent); color: var(--accent); }
.btn-sub { display: block; font-size: 0.55rem; opacity: 0.5; font-weight: 400; margin-top: 0.15rem; }
.setting-btn.active { background: var(--accent); color: var(--bg); border-color: var(--accent); animation: formatPop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1); }
.setting-btn.active .btn-sub { opacity: 0.8; }
@keyframes formatPop { 0% { transform: scale(0.9); } 60% { transform: scale(1.08); } 100% { transform: scale(1); } }

/* ── PLAYBACK ──────────────────────────── */

.playback-controls { display: flex; gap: 0.5rem; margin-bottom: 1rem; }

/* ── BUTTONS ───────────────────────────── */

.actions { display: flex; gap: 0.75rem; flex-wrap: wrap; }
.btn-pixel {
  font-family: 'Orbitron', sans-serif; font-weight: 700; font-size: 0.8rem;
  padding: 0.65rem 1.25rem; border: 2px solid var(--border); border-radius: 4px;
  cursor: pointer; transition: all 0.15s, transform 0.1s; text-transform: uppercase;
  letter-spacing: 0.05em; flex: 1; min-width: 0;
}
.btn-pixel:active { transform: translate(2px, 2px); box-shadow: none; }

.btn-primary { background: var(--accent); color: var(--bg); border-color: var(--accent); box-shadow: 3px 3px 0 rgba(232, 160, 48, 0.3); }
.btn-primary:hover { background: var(--accent2); box-shadow: 4px 4px 0 rgba(232, 160, 48, 0.4), 0 0 20px rgba(232, 160, 48, 0.3); transform: translateY(-1px); }

.btn-secondary { background: transparent; color: var(--text-dim); border-color: var(--border); box-shadow: 3px 3px 0 rgba(0,0,0,0.2); }
.btn-secondary:hover { color: var(--text); border-color: var(--teal); }

.btn-accent { background: rgba(45, 212, 168, 0.1); color: var(--teal); border-color: var(--teal); box-shadow: 3px 3px 0 rgba(45, 212, 168, 0.15); }
.btn-accent:hover { background: rgba(45, 212, 168, 0.2); box-shadow: 4px 4px 0 rgba(45, 212, 168, 0.25), 0 0 20px rgba(45, 212, 168, 0.2); transform: translateY(-1px); }

/* Ripple on GIF-ORIZE button */
#btnGiforize { position: relative; overflow: hidden; }
#btnGiforize::after { content: ''; position: absolute; top: 50%; left: 50%; width: 0; height: 0; background: rgba(255,255,255,0.15); border-radius: 50%; transform: translate(-50%,-50%); transition: width 0.4s, height 0.4s; }
#btnGiforize:active::after { width: 300px; height: 300px; }

/* ── PROGRESS ──────────────────────────── */

.processing-status { font-family: 'Orbitron', sans-serif; font-size: 0.9rem; color: var(--accent); text-align: center; margin-bottom: 1rem; text-shadow: 0 0 10px rgba(232, 160, 48, 0.3); }
.progress-bar-container { width: 100%; height: 24px; background: var(--bg-dark); border: 2px solid var(--border); border-radius: 4px; overflow: hidden; margin-bottom: 0.5rem; }
.progress-bar { height: 100%; width: 0%; background: linear-gradient(90deg, var(--purple), var(--accent), var(--accent2)); background-size: 200% 100%; transition: width 0.3s ease; animation: shimmer 1.5s linear infinite; }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
.progress-text { text-align: center; font-family: 'Orbitron', sans-serif; font-size: 0.85rem; color: var(--text-dim); }

/* ── DONE ──────────────────────────────── */

#step-done { position: relative; overflow: hidden; }
.done-icon { text-align: center; font-size: 2.5rem; margin-bottom: 0.5rem; animation: doneBounce 0.6s cubic-bezier(0.34, 1.56, 0.64, 1); }
@keyframes doneBounce { 0% { transform: scale(0); opacity: 0; } 50% { transform: scale(1.3); } 100% { transform: scale(1); opacity: 1; } }

.done-title { font-family: 'Orbitron', sans-serif; font-weight: 900; font-size: 1.2rem; color: var(--teal); text-align: center; margin-bottom: 0.25rem; text-shadow: 0 0 15px rgba(45, 212, 168, 0.4); animation: doneGlow 1.5s ease-in-out infinite; }
@keyframes doneGlow { 0%, 100% { text-shadow: 0 0 15px rgba(45, 212, 168, 0.4); } 50% { text-shadow: 0 0 25px rgba(45, 212, 168, 0.8), 0 0 50px rgba(45, 212, 168, 0.3); } }

.done-stats { text-align: center; font-size: 0.85rem; color: var(--text-dim); margin-bottom: 1rem; }
.done-stats span { color: var(--accent); font-family: 'Orbitron', sans-serif; font-weight: 700; }

.gif-preview-wrap { margin-bottom: 1rem; border: 2px solid var(--border); border-radius: 4px; overflow: hidden; background: #000; text-align: center; }
.gif-preview-wrap img { max-width: 100%; display: block; margin: 0 auto; }

/* ── SPARKLE PARTICLES ─────────────────── */

.sparkle { position: absolute; width: 6px; height: 6px; border-radius: 50%; pointer-events: none; z-index: 10; animation: sparkleUp 1s ease-out forwards; }
@keyframes sparkleUp { 0% { transform: scale(0) translateY(0); opacity: 1; } 50% { transform: scale(1.5) translateY(-30px); opacity: 1; } 100% { transform: scale(0) translateY(-60px); opacity: 0; } }

/* ── FOOTER ────────────────────────────── */

footer { margin-top: auto; padding: 2rem 0 1rem; text-align: center; position: relative; z-index: 1; }
.footer-title { font-family: 'Orbitron', sans-serif; font-weight: 900; font-size: 1rem; letter-spacing: 0.12em; color: var(--accent); animation: footerPulse 3s ease-in-out infinite; }
.footer-4000 { display: inline-block; color: var(--teal); animation: footerBounce 2s ease-in-out infinite; }
.footer-icon { display: inline-block; animation: footerSpin 2s ease-in-out infinite; }
@keyframes footerPulse { 0%, 100% { opacity: 0.7; } 50% { opacity: 1; } }
@keyframes footerBounce { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-3px); } }
@keyframes footerSpin { 0%, 100% { transform: rotate(0deg); } 50% { transform: rotate(10deg); } }

/* ── HUB NAV ──────────────────────────── */

.hub-nav { width: 100%; max-width: 520px; margin: 0 auto 0.5rem; position: relative; z-index: 1; }
.hub-back { display: inline-block; font-family: 'Orbitron', sans-serif; font-weight: 700; font-size: 0.75rem; color: var(--accent); text-decoration: none; padding: 0.4rem 0.8rem; border: 2px solid var(--border); border-radius: 4px; transition: all 0.15s; letter-spacing: 0.05em; }
.hub-back:hover { border-color: var(--accent); color: var(--accent2); background: rgba(232, 160, 48, 0.08); }

/* ── RESPONSIVE ────────────────────────── */

@media (max-width: 400px) {
  .hero-logo { width: 160px; height: 160px; }
  .card { padding: 1rem; }
  .btn-pixel { font-size: 0.7rem; padding: 0.55rem 0.75rem; }
  .settings-row { flex-direction: column; }
}
