/* ==========================================================================
   Storage Cleaner - System Performance & Storage Optimizer (H5 Landing)
   iOS Native Glassmorphism / Dark Tech Theme
   Pure CSS - no external dependencies
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Design Tokens
   -------------------------------------------------------------------------- */
:root {
  --bg: #0f172a;
  --bg-elev: #1e293b;
  --primary: #2563eb;
  --primary-2: #3b82f6;
  --cyan: #22d3ee;
  --warn: #f59e0b;
  --warn-bright: #fbbf24;
  --danger: #ef4444;
  --ok: #22c55e;
  --ok-bright: #4ade80;
  --ok-ios: #30d158;

  --text: #f1f5f9;
  --text-dim: #94a3b8;
  --text-faint: #64748b;

  --glass: rgba(148, 163, 184, 0.08);
  --glass-2: rgba(148, 163, 184, 0.12);
  --stroke: rgba(148, 163, 184, 0.16);
  --stroke-bright: rgba(148, 163, 184, 0.28);

  --radius-lg: 24px;
  --radius-md: 16px;
  --radius-sm: 12px;

  --shadow-card: 0 24px 50px -24px rgba(2, 6, 23, 0.85);
  --ease-out: cubic-bezier(0.22, 0.9, 0.32, 1);
}

/* --------------------------------------------------------------------------
   2. Reset & Mobile Base (iOS Safari hardening)
   -------------------------------------------------------------------------- */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

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

html,
body {
  overscroll-behavior: none;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text",
    "Helvetica Neue", Helvetica, "Segoe UI", Roboto, Arial, sans-serif;
  background-color: var(--bg);
  color: var(--text);
  min-height: 100vh;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  touch-action: manipulation;
  overflow-x: hidden;
}

img {
  display: block;
  max-width: 100%;
}

button {
  font: inherit;
  color: inherit;
  border: 0;
  background: none;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  touch-action: manipulation;
}

ul {
  list-style: none;
}

[hidden] {
  display: none !important;
}

/* --------------------------------------------------------------------------
   3. Ambient Background (orbs + grid)
   -------------------------------------------------------------------------- */
.ambient {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(120% 90% at 50% -10%, rgba(37, 99, 235, 0.14), transparent 60%),
    var(--bg);
}

.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(70px);
  opacity: 0.45;
  will-change: transform;
}

.orb-1 {
  width: 340px;
  height: 340px;
  top: -130px;
  left: -100px;
  background: radial-gradient(circle, #1d4ed8 0%, transparent 65%);
  animation: drift 13s ease-in-out infinite alternate;
}

.orb-2 {
  width: 300px;
  height: 300px;
  bottom: -110px;
  right: -90px;
  background: radial-gradient(circle, #0e7490 0%, transparent 65%);
  animation: drift 16s ease-in-out infinite alternate-reverse;
}

.grid-overlay {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(148, 163, 184, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(148, 163, 184, 0.05) 1px, transparent 1px);
  background-size: 44px 44px;
  -webkit-mask-image: radial-gradient(ellipse 90% 60% at 50% 0%, #000 30%, transparent 75%);
  mask-image: radial-gradient(ellipse 90% 60% at 50% 0%, #000 30%, transparent 75%);
}

/* --------------------------------------------------------------------------
   4. Stage Layout
   -------------------------------------------------------------------------- */
.stage {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 440px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top, 0px) + 20px) 18px
    calc(env(safe-area-inset-bottom, 0px) + 18px);
  display: flex;
  flex-direction: column;
}

/* --------------------------------------------------------------------------
   5. Top Bar
   -------------------------------------------------------------------------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
}

.brand-mark {
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  border-radius: 13px;
  display: grid;
  place-items: center;
  color: #fff;
  background: linear-gradient(160deg, var(--primary-2), #1d4ed8);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.28),
    0 10px 22px -8px rgba(37, 99, 235, 0.65);
}

.brand-mark svg {
  width: 21px;
  height: 21px;
}

.brand h1 {
  font-size: 16.5px;
  font-weight: 700;
  letter-spacing: -0.2px;
  line-height: 1.2;
  white-space: nowrap;
}

.brand p {
  font-size: 11.5px;
  color: var(--text-dim);
  font-weight: 500;
  white-space: nowrap;
}

.pill {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px 12px;
  border-radius: 999px;
  background: var(--glass);
  border: 1px solid var(--stroke);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dim);
  flex: 0 0 auto;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.pill .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ok-ios);
  animation: pulse-dot 1.7s ease-in-out infinite;
}

/* --------------------------------------------------------------------------
   6. Gauge Zone
   -------------------------------------------------------------------------- */
.gauge-zone {
  margin: 22px 0 20px;
  position: relative;
}

.gauge {
  position: relative;
  width: min(66vw, 252px);
  aspect-ratio: 1 / 1;
  margin: 0 auto;
}

.gauge svg {
  width: 100%;
  height: 100%;
  display: block;
  overflow: visible;
}

.gauge-glow {
  position: absolute;
  inset: 6%;
  border-radius: 50%;
  filter: blur(38px);
  opacity: 0.4;
  pointer-events: none;
  background: radial-gradient(circle, #2563eb 0%, transparent 70%);
  transition: background 0.7s ease;
}

.gauge-track {
  fill: none;
  stroke: rgba(148, 163, 184, 0.16);
  stroke-width: 13;
}

.gauge-orbit {
  fill: none;
  stroke: rgba(148, 163, 184, 0.4);
  stroke-width: 2;
  stroke-dasharray: 1.5 10;
  stroke-linecap: round;
  opacity: 0;
  transform-origin: 130px 130px;
  transition: opacity 0.6s ease;
}

.gauge-progress {
  fill: none;
  stroke-width: 13;
  stroke-linecap: round;
  transition: stroke 0.6s ease;
}

.gauge-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 3px;
  padding: 0 24px;
}

.gauge-num {
  font-size: 62px;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -2.5px;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  transition: color 0.5s ease;
  display: flex;
  align-items: baseline;
}

.gauge-num .unit {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: 0;
  margin-left: 3px;
  color: var(--text-dim);
}

.gauge-label {
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 1.6px;
  text-transform: uppercase;
  color: var(--text-dim);
}

.gauge-state {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-dim);
  transition: color 0.5s ease;
}

/* --- Gauge state: scanning (blue) --- */
.state-scan .gauge-progress {
  stroke: url(#gradScan);
}
.state-scan .gauge-glow {
  background: radial-gradient(circle, #2563eb 0%, transparent 70%);
}
.state-scan .gauge-orbit {
  opacity: 0.5;
  animation: spin 9s linear infinite;
}

/* --- Gauge state: warning (amber -> red) --- */
.state-warn .gauge-progress {
  stroke: url(#gradWarn);
}
.state-warn .gauge-glow {
  background: radial-gradient(circle, #f59e0b 0%, transparent 70%);
}
.state-warn .gauge-num {
  color: var(--warn-bright);
  animation: warn-pulse 2.2s ease-in-out infinite;
}
.state-warn .gauge-state {
  color: var(--warn-bright);
}

/* --- Gauge state: cleaning (blue, memory dropping) --- */
.state-clean .gauge-progress {
  stroke: url(#gradScan);
}
.state-clean .gauge-glow {
  background: radial-gradient(circle, #0891b2 0%, transparent 70%);
}
.state-clean .gauge-num {
  color: #bfdbfe;
}

/* --- Gauge state: success (green) --- */
.state-ok .gauge-progress {
  stroke: url(#gradOk);
}
.state-ok .gauge-glow {
  background: radial-gradient(circle, #16a34a 0%, transparent 70%);
}
.state-ok .gauge-num {
  color: var(--ok-bright);
}
.state-ok .gauge-state {
  color: var(--ok-bright);
}

/* --------------------------------------------------------------------------
   7. Glass Cards
   -------------------------------------------------------------------------- */
.card {
  background: linear-gradient(180deg, rgba(148, 163, 184, 0.11), rgba(148, 163, 184, 0.05));
  border: 1px solid var(--stroke);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-card);
  backdrop-filter: blur(24px) saturate(160%);
  -webkit-backdrop-filter: blur(24px) saturate(160%);
}

.anim-in {
  animation: rise 0.45s var(--ease-out) both;
}

/* --------------------------------------------------------------------------
   8. Scan Card (diagnostic rows)
   -------------------------------------------------------------------------- */
.scan-card {
  padding: 6px 16px;
}

.scan-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 2px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.1);
}

.scan-row:last-child {
  border-bottom: 0;
}

.row-icon {
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  border-radius: 12px;
  display: grid;
  place-items: center;
  color: #7db5ff;
  background: rgba(37, 99, 235, 0.14);
  border: 1px solid rgba(59, 130, 246, 0.22);
}

.row-icon svg {
  width: 19px;
  height: 19px;
}

.row-info {
  min-width: 0;
}

.row-name {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.1px;
}

.row-sub {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 1px;
}

.row-status {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 7px;
  flex: 0 0 auto;
}

.status-text {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-faint);
}

.status-text.warn {
  color: var(--warn-bright);
}

.status-text.ok {
  color: var(--ok-bright);
}

.st-ic {
  width: 16px;
  height: 16px;
}

.row-status .st-ic {
  color: inherit;
}

.row-status:has(.status-text.warn) .st-ic {
  color: var(--warn-bright);
}

.row-status:has(.status-text.ok) .st-ic {
  color: var(--ok-bright);
}

/* --------------------------------------------------------------------------
   9. Result Card (conversion trigger)
   -------------------------------------------------------------------------- */
.result-card {
  text-align: center;
  border-color: rgba(59, 130, 246, 0.38);
  box-shadow:
    0 0 0 1px rgba(59, 130, 246, 0.12),
    0 24px 60px -24px rgba(37, 99, 235, 0.55);
}

.result-badge {
  width: 58px;
  height: 58px;
  margin: 2px auto 14px;
  border-radius: 19px;
  display: grid;
  place-items: center;
  color: #7db5ff;
  background: linear-gradient(140deg, rgba(59, 130, 246, 0.28), rgba(34, 211, 238, 0.16));
  border: 1px solid rgba(59, 130, 246, 0.35);
}

.result-badge svg {
  width: 27px;
  height: 27px;
}

.result-card h2 {
  font-size: 21px;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.result-size {
  margin-top: 10px;
  font-size: 58px;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -2px;
  font-variant-numeric: tabular-nums;
  background: linear-gradient(180deg, #ffffff 20%, #93c5fd);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}

.result-size .gb {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0;
  margin-left: 5px;
}

.result-label {
  margin-top: 6px;
  font-size: 13.5px;
  font-weight: 700;
  color: #93c5fd;
  letter-spacing: 0.4px;
  text-transform: uppercase;
}

.result-desc {
  margin: 12px auto 18px;
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--text-dim);
  max-width: 300px;
}

.micro {
  margin-top: 12px;
  font-size: 11.5px;
  color: var(--text-faint);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
}

.micro svg {
  width: 13px;
  height: 13px;
  flex: 0 0 auto;
}

/* --------------------------------------------------------------------------
   10. Clean Card (progress + logs)
   -------------------------------------------------------------------------- */
.clean-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.clean-head h2 {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.2px;
}

.clean-pct {
  font-size: 20px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: #93c5fd;
  letter-spacing: -0.5px;
}

.bar {
  margin-top: 14px;
  height: 10px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.16);
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--primary), var(--cyan));
  position: relative;
  overflow: hidden;
}

.bar-fill::after {
  content: "";
  position: absolute;
  inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.38), transparent);
  animation: shimmer 1.15s linear infinite;
}

.logs {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 11px;
  min-height: 96px;
}

.log {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13.5px;
  color: var(--text-dim);
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.35s ease, transform 0.35s ease;
}

.log.show {
  opacity: 1;
  transform: none;
}

.log-text {
  flex: 1;
  min-width: 0;
}

.log.done .log-text {
  color: var(--text);
}

.log-check {
  width: 16px;
  height: 16px;
  color: var(--ok-bright);
  display: none;
  flex: 0 0 auto;
}

.log.done .log-check {
  display: block;
  animation: pop 0.35s var(--ease-out) both;
}

.log.done .spinner {
  display: none;
}

/* --------------------------------------------------------------------------
   11. Success Card
   -------------------------------------------------------------------------- */
.success-card {
  text-align: center;
  border-color: rgba(34, 197, 94, 0.32);
  box-shadow:
    0 0 0 1px rgba(34, 197, 94, 0.1),
    0 24px 60px -24px rgba(22, 163, 74, 0.45);
}

.success-check {
  width: 64px;
  height: 64px;
  margin: 2px auto 14px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--ok-bright);
  background: rgba(34, 197, 94, 0.14);
  border: 1px solid rgba(34, 197, 94, 0.35);
  box-shadow: 0 0 0 9px rgba(34, 197, 94, 0.06);
  animation: pop 0.55s cubic-bezier(0.2, 1.5, 0.4, 1) both;
}

.success-check svg {
  width: 30px;
  height: 30px;
}

.success-card h2 {
  font-size: 19.5px;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.chip {
  margin-top: 12px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 999px;
  background: rgba(34, 197, 94, 0.12);
  border: 1px solid rgba(34, 197, 94, 0.3);
  color: var(--ok-bright);
  font-size: 12.5px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.success-desc {
  margin: 12px auto 0;
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--text-dim);
  max-width: 300px;
}

.app-row {
  margin: 16px 0 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
  background: rgba(15, 23, 42, 0.55);
  border: 1px solid var(--stroke);
  border-radius: var(--radius-md);
  padding: 12px;
}

.app-icon-box {
  position: relative;
  width: 52px;
  height: 52px;
  flex: 0 0 auto;
  border-radius: 13px;
  overflow: hidden;
  background: linear-gradient(140deg, #1d4ed8, #0891b2);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

.app-icon-fallback {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  padding: 13px;
  color: #fff;
}

.app-icon-box img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.app-meta {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.app-meta strong {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.1px;
}

.app-meta span {
  font-size: 12px;
  color: var(--text-dim);
}

/* --------------------------------------------------------------------------
   12. Buttons
   -------------------------------------------------------------------------- */
.btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 16px 18px;
  border-radius: var(--radius-md);
  font-size: 16.5px;
  font-weight: 700;
  letter-spacing: -0.1px;
  color: #fff;
  transition: transform 0.15s ease, box-shadow 0.3s ease, filter 0.2s ease;
}

.btn:active {
  transform: scale(0.97);
  filter: brightness(1.08);
}

.btn svg {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
}

.btn-primary {
  background: linear-gradient(180deg, var(--primary-2), var(--primary));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.25),
    0 12px 26px -10px rgba(37, 99, 235, 0.65);
}

.btn-breathe {
  animation: breathe 1.9s ease-in-out infinite;
}

/* --------------------------------------------------------------------------
   13. Footer
   -------------------------------------------------------------------------- */
.foot {
  margin-top: 22px;
  text-align: center;
  font-size: 11px;
  line-height: 1.6;
  color: var(--text-faint);
}

/* --------------------------------------------------------------------------
   14. Spinners
   -------------------------------------------------------------------------- */
.spinner {
  width: 15px;
  height: 15px;
  flex: 0 0 auto;
  border-radius: 50%;
  border: 2px solid rgba(148, 163, 184, 0.25);
  border-top-color: var(--primary-2);
  animation: spin 0.7s linear infinite;
}

.log .spinner {
  width: 13px;
  height: 13px;
}

/* --------------------------------------------------------------------------
   15. Keyframes
   -------------------------------------------------------------------------- */
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes pop {
  from {
    opacity: 0;
    transform: scale(0.3);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes shimmer {
  to {
    transform: translateX(100%);
  }
}

@keyframes breathe {
  0%,
  100% {
    box-shadow:
      inset 0 1px 0 rgba(255, 255, 255, 0.25),
      0 12px 26px -10px rgba(37, 99, 235, 0.65);
  }
  50% {
    box-shadow:
      inset 0 1px 0 rgba(255, 255, 255, 0.25),
      0 12px 40px -6px rgba(59, 130, 246, 0.95);
    transform: scale(1.015);
  }
}

@keyframes warn-pulse {
  0%,
  100% {
    text-shadow: 0 0 0 rgba(251, 191, 36, 0);
  }
  50% {
    text-shadow: 0 0 22px rgba(251, 191, 36, 0.55);
  }
}

@keyframes pulse-dot {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(48, 209, 88, 0.55);
  }
  55% {
    box-shadow: 0 0 0 5px rgba(48, 209, 88, 0);
  }
}

@keyframes drift {
  from {
    transform: translate(0, 0);
  }
  to {
    transform: translate(42px, 30px);
  }
}

/* --------------------------------------------------------------------------
   16. Responsive & Accessibility
   -------------------------------------------------------------------------- */
@media (max-height: 700px) {
  .gauge {
    width: min(56vw, 214px);
  }
  .gauge-num {
    font-size: 52px;
  }
  .gauge-zone {
    margin: 14px 0 14px;
  }
  .stage {
    padding-top: calc(env(safe-area-inset-top, 0px) + 14px);
  }
}

@media (min-width: 480px) {
  .stage {
    padding-top: calc(env(safe-area-inset-top, 0px) + 34px);
    padding-bottom: 40px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .orb,
  .gauge-orbit,
  .pill .dot,
  .bar-fill::after,
  .btn-breathe,
  .state-warn .gauge-num {
    animation: none !important;
  }
  .anim-in,
  .success-check,
  .log.done .log-check {
    animation-duration: 0.01ms !important;
  }
}
