/* Soluzioni Potenza — middleware download TeamViewer (CTA + progress) */
:root {
  --navy: oklch(0.32 0.08 250);
  --navy-deep: oklch(0.24 0.07 250);
  --navy-soft: oklch(0.42 0.09 250);
  --sky: oklch(0.96 0.015 240);
  --sky-mid: oklch(0.92 0.025 235);
  --ink: oklch(0.28 0.03 250);
  --ink-muted: oklch(0.48 0.03 250);
  --surface: #fff;
  --shadow: 0 18px 48px oklch(0.28 0.06 250 / 0.14);
  --radius: 14px;
  --font: "Segoe UI", system-ui, -apple-system, sans-serif;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --tv-blue: #0e8ee9;
  --arrow-green: #1faa5c;
  --arrow-green-deep: #168a49;
  /* Coachmark toolbar Download (override: ?hintRight= / ?hintTop=) */
  --hint-top: 0px;
  --hint-right: 56px;
}

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

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(120% 80% at 50% 0%, var(--sky-mid), var(--sky) 55%),
    var(--sky);
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.09;
  background: url("assets/map-watermark.svg") center 42% / min(1100px, 92vw) no-repeat;
}

.brand-bar {
  position: relative;
  z-index: 2;
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-deep) 100%);
  box-shadow: 0 2px 10px oklch(0.2 0.05 250 / 0.35);
  padding: 14px clamp(16px, 4vw, 32px);
  display: flex;
  align-items: center;
  min-height: 64px;
}

.brand-logo {
  height: clamp(36px, 5.5vw, 48px);
  width: auto;
  max-width: min(420px, 78vw);
  object-fit: contain;
  filter: brightness(0) invert(1);
}

.page {
  position: relative;
  z-index: 1;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  align-items: safe center;
  justify-content: center;
  justify-content: safe center;
  width: 100%;
  min-height: 0;
  padding: clamp(24px, 5vw, 48px) 16px 40px;
  box-sizing: border-box;
}

.panel {
  width: min(520px, 100%);
  margin-inline: auto;
  flex: 0 0 auto;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border-top: 3px solid var(--navy-soft);
  padding: clamp(28px, 4vw, 36px) clamp(22px, 4vw, 32px) 28px;
  text-align: center;
  overflow-x: clip;
  animation: panel-in 520ms var(--ease-out) both;
}

@keyframes panel-in {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.status-icon {
  width: 52px;
  height: 52px;
  margin: 0 auto 16px;
  border-radius: 50%;
  background: var(--navy);
  color: #fff;
  display: grid;
  place-items: center;
  position: relative;
}

.status-icon svg {
  width: 26px;
  height: 26px;
  display: none;
  grid-area: 1 / 1;
}

.status-icon[data-state="loading"] .icon-spin {
  display: block;
  animation: spin 0.9s linear infinite;
}

.status-icon[data-state="idle"] {
  background: var(--navy);
}

.status-icon[data-state="idle"] .icon-download {
  display: block;
}

.status-icon[data-state="ready"] {
  background: #1e7a4a;
}

.status-icon[data-state="ready"] .icon-check {
  display: block;
}

.status-icon[data-state="error"] {
  background: #a14a4a;
}

.status-icon[data-state="error"] .icon-check {
  display: block;
  transform: rotate(45deg);
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.panel h1 {
  margin: 0 0 10px;
  font-size: clamp(1.4rem, 2.4vw, 1.7rem);
  font-weight: 700;
  color: var(--navy);
  letter-spacing: -0.02em;
  text-wrap: balance;
  line-height: 1.2;
}

.lede {
  margin: 0 auto 20px;
  max-width: 40ch;
  font-size: 1.02rem;
  line-height: 1.45;
  color: var(--ink-muted);
  text-wrap: pretty;
}

.file-chip {
  display: flex;
  align-items: center;
  gap: 14px;
  text-align: left;
  background: oklch(0.97 0.01 240);
  border: 1px solid oklch(0.88 0.02 240);
  border-radius: 12px;
  padding: 14px 16px;
  margin: 0 auto 18px;
}

.file-icon {
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 4px 12px oklch(0.45 0.1 240 / 0.22);
}

.file-icon-img {
  width: 44px;
  height: 44px;
  display: block;
  object-fit: contain;
}

.file-meta {
  flex: 1;
  min-width: 0;
}

.file-name {
  margin: 0;
  font-weight: 700;
  font-size: 0.98rem;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-sub {
  margin: 4px 0 0;
  font-size: 0.86rem;
  color: var(--ink-muted);
}

/* Progress */
.progress-block {
  margin: 0 0 22px;
  opacity: 0.55;
  transition: opacity 200ms var(--ease-out);
}

.progress-block.is-active {
  opacity: 1;
}

.progress-track {
  height: 12px;
  border-radius: 999px;
  background: oklch(0.93 0.015 240);
  overflow: hidden;
  border: 1px solid oklch(0.88 0.02 240);
  position: relative;
}

.progress-fill {
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--navy-soft), var(--tv-blue));
  transition: width 120ms linear;
}

.progress-track.is-indeterminate .progress-fill {
  width: 40% !important;
  animation: progress-indeterminate 1.1s ease-in-out infinite;
}

@keyframes progress-indeterminate {
  0% {
    transform: translateX(-120%);
  }
  100% {
    transform: translateX(280%);
  }
}

.progress-meta {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 8px 12px;
  margin: 8px 2px 0;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--ink-muted);
}

.progress-speed {
  margin-left: auto;
  color: var(--arrow-green-deep);
  font-variant-numeric: tabular-nums;
}

/* CTA + freccia verso il pulsante */
.cta-stage {
  position: relative;
  margin: 8px 0 18px;
  padding-top: 78px;
  isolation: isolate;
}

.cta-hint {
  position: absolute;
  left: 50%;
  top: 0;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  pointer-events: none;
  /* Sopra il pulsante blu (pointer-events: none → i click passano al CTA) */
  z-index: 20;
  animation: hint-in 500ms var(--ease-out) both;
}

.cta-hint[hidden] {
  display: none !important;
}

@keyframes hint-in {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(-6px);
  }
  to {
    opacity: 1;
    transform: translateX(-50%);
  }
}

.cta-glow {
  position: absolute;
  top: 48px;
  left: 50%;
  width: min(420px, 92vw);
  height: 100px;
  transform: translateX(-50%);
  border-radius: 50%;
  background: radial-gradient(
    ellipse at 50% 70%,
    oklch(0.78 0.12 150 / 0.45) 0%,
    oklch(0.55 0.08 150 / 0) 70%
  );
  filter: blur(16px);
  z-index: 0;
  animation: glow-breathe 2s var(--ease-out) infinite;
}

@keyframes glow-breathe {
  0%,
  100% {
    opacity: 0.7;
    transform: translateX(-50%) scale(1);
  }
  50% {
    opacity: 1;
    transform: translateX(-50%) scale(1.05);
  }
}

.cta-arrow {
  position: relative;
  z-index: 2;
  width: 48px;
  height: 64px;
  color: var(--arrow-green);
  filter: drop-shadow(0 6px 12px rgba(10, 40, 20, 0.4));
  animation: arrow-nudge 1.5s var(--ease-out) infinite;
}

.cta-arrow svg {
  width: 100%;
  height: 100%;
  display: block;
  overflow: visible;
}

/* Bordo bianco continuo fino alla punta */
.cta-arrow .arrow-border {
  stroke: #fff;
  stroke-width: 12;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.cta-arrow .arrow-core {
  stroke: var(--arrow-green);
  stroke-width: 5.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

@keyframes arrow-nudge {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(6px);
  }
}

.cta-hint-label {
  position: relative;
  z-index: 2;
  order: -1;
  margin-bottom: 4px;
  background: var(--arrow-green-deep);
  color: #fff;
  font-size: 0.78rem;
  font-weight: 700;
  padding: 5px 12px;
  border-radius: 999px;
  border: 2px solid #fff;
  box-shadow: 0 6px 16px rgba(20, 80, 40, 0.35);
}

.cta-btn {
  position: relative;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
  max-width: 100%;
  min-height: 56px;
  padding: 14px 22px;
  border: none;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-deep) 100%);
  color: #fff;
  font: inherit;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  cursor: pointer;
  text-decoration: none;
  box-shadow: 0 10px 28px oklch(0.3 0.08 250 / 0.35);
  transition:
    transform 160ms var(--ease-out),
    box-shadow 160ms var(--ease-out),
    opacity 160ms var(--ease-out);
}

.cta-btn:hover:not(.is-disabled) {
  transform: translateY(-1px);
  box-shadow: 0 14px 32px oklch(0.3 0.08 250 / 0.42);
  color: #fff;
}

.cta-btn:focus-visible {
  outline: 3px solid oklch(0.55 0.12 250);
  outline-offset: 3px;
}

.cta-btn.is-disabled,
.cta-btn[aria-disabled="true"] {
  opacity: 0.55;
  cursor: not-allowed;
  box-shadow: none;
  pointer-events: none;
}

body.cta-ready .cta-btn {
  animation: cta-pulse 1.8s var(--ease-out) infinite;
}

@keyframes cta-pulse {
  0%,
  100% {
    box-shadow: 0 10px 28px oklch(0.3 0.08 250 / 0.35);
  }
  50% {
    box-shadow:
      0 10px 28px oklch(0.3 0.08 250 / 0.35),
      0 0 0 6px oklch(0.55 0.12 250 / 0.22);
  }
}

.cta-btn-icon {
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  overflow: hidden;
  background: #fff;
}

.cta-btn-icon img {
  display: block;
  width: 28px;
  height: 28px;
}

.cta-btn-text {
  text-wrap: balance;
}

.hint-line {
  margin: 0 0 8px;
  font-size: 0.92rem;
  color: var(--ink-muted);
  text-wrap: pretty;
}

.hint-line[hidden] {
  display: none !important;
}

.retry {
  margin: 16px 0 0;
  font-size: 0.9rem;
  color: var(--ink-muted);
}

.retry a {
  color: var(--navy-soft);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.retry a:hover {
  color: var(--navy);
}

.retry a:focus-visible {
  outline: 2px solid var(--navy);
  outline-offset: 3px;
  border-radius: 2px;
}

.foot {
  position: relative;
  z-index: 1;
  text-align: center;
  padding: 12px 16px 20px;
  font-size: 0.78rem;
  color: oklch(0.55 0.02 250);
}

.debug-box {
  position: fixed;
  left: 8px;
  bottom: 8px;
  z-index: 99;
  max-width: min(480px, 92vw);
  max-height: 180px;
  overflow: auto;
  margin: 0;
  padding: 8px 10px;
  font: 11px/1.35 ui-monospace, Consolas, monospace;
  color: #d8e6ff;
  background: rgba(8, 20, 40, 0.92);
  border-radius: 8px;
  white-space: pre-wrap;
}

/* —— Coachmark toolbar: freccia+blur verso icona Download del browser —— */
.download-hint {
  position: fixed;
  z-index: 50;
  top: var(--hint-top);
  right: var(--hint-right);
  width: 140px;
  height: 200px;
  pointer-events: none;
  opacity: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  animation: toolbar-hint-in 700ms 200ms var(--ease-out) forwards;
}

.download-hint[hidden] {
  display: none !important;
}

@keyframes toolbar-hint-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.hint-glow {
  position: absolute;
  top: -28px;
  left: 50%;
  width: 120px;
  height: 100px;
  transform: translateX(-50%);
  border-radius: 50%;
  background: radial-gradient(
    ellipse at 50% 20%,
    oklch(0.92 0.08 150 / 0.9) 0%,
    oklch(0.75 0.12 150 / 0.45) 38%,
    oklch(0.55 0.08 150 / 0) 72%
  );
  filter: blur(14px);
  animation: toolbar-glow-breathe 2.2s var(--ease-out) infinite;
}

@keyframes toolbar-glow-breathe {
  0%,
  100% {
    opacity: 0.75;
    transform: translateX(-50%) scale(1);
  }
  50% {
    opacity: 1;
    transform: translateX(-50%) scale(1.08);
  }
}

.hint-arrow {
  position: relative;
  z-index: 1;
  width: 48px;
  height: 72px;
  margin-top: 4px;
  color: var(--arrow-green);
  filter: drop-shadow(0 6px 12px rgba(10, 40, 20, 0.4));
  animation: toolbar-arrow-nudge 1.6s var(--ease-out) infinite;
}

.hint-arrow svg {
  width: 100%;
  height: 100%;
  display: block;
  overflow: visible;
}

.hint-arrow .arrow-border {
  stroke: #fff;
  stroke-width: 12;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.hint-arrow .arrow-core {
  stroke: var(--arrow-green);
  stroke-width: 5.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

@keyframes toolbar-arrow-nudge {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-8px);
  }
}

.hint-label {
  position: relative;
  z-index: 1;
  margin-top: 4px;
  white-space: nowrap;
  background: var(--arrow-green-deep);
  color: #fff;
  font-size: 0.78rem;
  font-weight: 700;
  padding: 5px 12px;
  border-radius: 999px;
  border: 2px solid #fff;
  box-shadow: 0 6px 16px rgba(20, 80, 40, 0.35);
  animation: toolbar-label-pulse 1.6s var(--ease-out) infinite;
}

@keyframes toolbar-label-pulse {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.03);
  }
}

body[data-browser="chrome"] .download-hint,
body[data-browser="edge"] .download-hint {
  /* Vicino al bordo destro (sinistra di profilo/⋮). Con estensioni: ?hintRight=140 */
  --hint-top: 0px;
  --hint-right: 56px;
}

body[data-browser="firefox"] .download-hint {
  --hint-top: 0px;
  --hint-right: 96px;
}

body[data-browser="safari"] .download-hint {
  --hint-top: 0px;
  --hint-right: 120px;
}

body[data-browser="unknown"] .download-hint,
body[data-browser="mobile"] .download-hint {
  display: none !important;
}

.page-veil {
  display: none;
}

@media (min-width: 900px) {
  body.toolbar-guide:not([data-browser="unknown"]):not([data-browser="mobile"]) .page-veil {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 30;
    pointer-events: none;
    background: radial-gradient(
      ellipse 160px 120px at calc(100% - var(--hint-right) - 26px) 0px,
      transparent 0%,
      transparent 35%,
      oklch(0.3 0.04 250 / 0.22) 100%
    );
    animation: toolbar-veil-in 600ms 160ms var(--ease-out) both;
  }
}

@keyframes toolbar-veil-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@media (max-width: 899px) {
  .download-hint,
  .page-veil {
    display: none !important;
  }
}

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

  .panel,
  .cta-hint,
  .download-hint,
  body.cta-ready .cta-btn {
    animation: none !important;
  }
}
