:root {
  color-scheme: dark;
  --bg: #09070b;
  --ink: #f8f2ea;
  --muted: #b8aebc;
  --line: rgba(248, 242, 234, 0.18);
  --pink: #ff4fb8;
  --yellow: #ffea3a;
  --green: #41f27d;
  --cyan: #49d9ff;
  --panel: rgba(9, 7, 11, 0.78);
  --card-text-scale: 1;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--ink);
}

body {
  min-height: 100svh;
  overflow: hidden;
}

button {
  border: 0;
  border-radius: 8px;
  font: inherit;
  cursor: pointer;
  touch-action: manipulation;
}

.app,
.intro,
.lens {
  position: fixed;
  inset: 0;
}

.app {
  overflow: hidden;
  background:
    linear-gradient(90deg, rgba(255, 79, 184, 0.08) 1px, transparent 1px),
    linear-gradient(rgba(255, 234, 58, 0.06) 1px, transparent 1px),
    radial-gradient(circle at 16% 20%, rgba(255, 79, 184, 0.24), transparent 30%),
    radial-gradient(circle at 88% 84%, rgba(65, 242, 125, 0.16), transparent 28%),
    #09070b;
  background-size: 48px 48px, 48px 48px, auto, auto, auto;
}

.intro {
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 24px;
  padding: max(18px, env(safe-area-inset-top)) max(18px, env(safe-area-inset-right)) max(24px, env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left));
  transition: opacity 240ms ease, transform 240ms ease, visibility 240ms ease;
  z-index: 5;
}

.intro::before,
.intro::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.intro::before {
  background:
    radial-gradient(circle, var(--yellow) 0 2px, transparent 3px),
    radial-gradient(circle, var(--cyan) 0 2px, transparent 3px);
  background-position: 0 0, 22px 28px;
  background-size: 52px 52px;
  opacity: 0.14;
}

.intro::after {
  border: 12px solid transparent;
  border-image: repeating-linear-gradient(135deg, var(--pink) 0 12px, var(--yellow) 12px 24px, var(--green) 24px 36px, var(--cyan) 36px 48px) 12;
  opacity: 0.44;
}

.intro.is-hidden {
  opacity: 0;
  transform: scale(1.02);
  visibility: hidden;
  pointer-events: none;
}

.brand,
.intro-copy,
.intro-actions {
  position: relative;
  z-index: 1;
}

.brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand img {
  width: 118px;
  height: auto;
  object-fit: contain;
}

.brand span,
.eyebrow,
.lens-status,
.work-card span,
dt,
dd {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

.brand span {
  color: var(--cyan);
  font-size: 0.68rem;
  text-transform: uppercase;
}

.intro-copy {
  align-self: end;
  display: grid;
  gap: 16px;
  padding-bottom: 3vh;
}

.eyebrow {
  margin: 0;
  color: var(--green);
  font-size: 0.76rem;
  text-transform: uppercase;
}

h1 {
  max-width: 8ch;
  margin: 0;
  font-size: clamp(4.4rem, 23vw, 8rem);
  line-height: 0.78;
  letter-spacing: 0;
  text-transform: uppercase;
  text-shadow:
    5px 0 0 rgba(255, 79, 184, 0.85),
    -4px 4px 0 rgba(73, 217, 255, 0.75);
}

.intro-copy p:last-child {
  max-width: 31ch;
  margin: 0;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.48;
}

.intro-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.primary-button,
.ghost-button,
.card-button {
  min-height: 52px;
  padding: 0 18px;
  font-weight: 850;
  text-transform: uppercase;
}

.primary-button {
  background: linear-gradient(135deg, var(--yellow), var(--pink));
  color: #11090e;
  box-shadow: 0 0 30px rgba(255, 79, 184, 0.26);
}

.ghost-button,
.card-button {
  border: 1px solid var(--line);
  background: rgba(248, 242, 234, 0.06);
  color: var(--ink);
}

.intro-actions p {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.42;
}

.intro-actions p.is-error {
  color: var(--yellow);
}

.lens {
  opacity: 0;
  visibility: hidden;
  background: #09070b;
  transition: opacity 240ms ease, visibility 240ms ease;
  z-index: 2;
}

.lens.is-active {
  opacity: 1;
  visibility: visible;
}

.camera-preview,
.card-bg-video,
.lens > canvas,
.lens > video,
.art-stage {
  position: absolute !important;
  inset: 0 !important;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.lens > video:not(#cameraPreview):not(#cardBgVideo) {
  z-index: 0;
}

.camera-preview {
  opacity: 0;
  transition: opacity 180ms ease;
  z-index: 0;
}

.card-bg-video {
  background: #09070b;
  opacity: 0;
  transform: scale(1.04);
  transition: opacity 280ms ease, filter 280ms ease;
  filter: saturate(1.22) contrast(1.08) brightness(0.66);
  pointer-events: none;
  z-index: 2;
}

.lens.has-card .card-bg-video {
  opacity: 1;
}

.lens.has-preview .camera-preview {
  opacity: 1;
}

.lens > canvas {
  z-index: 1;
}

.art-stage {
  display: grid;
  place-items: center;
  overflow: hidden;
  opacity: 0;
  transform: scale(1.02);
  transition: opacity 280ms ease;
  pointer-events: none;
  z-index: 2;
}

.lens.is-demo .art-stage {
  opacity: 1;
}

.art-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: saturate(1.18) contrast(1.08);
}

.marker-lines,
.dot-field {
  position: absolute;
  inset: 0;
}

.marker-lines {
  background:
    linear-gradient(115deg, transparent 15%, rgba(255, 234, 58, 0.36) 16%, transparent 18%),
    linear-gradient(40deg, transparent 42%, rgba(255, 79, 184, 0.34) 43%, transparent 45%),
    linear-gradient(150deg, transparent 66%, rgba(73, 217, 255, 0.28) 67%, transparent 69%);
  mix-blend-mode: screen;
}

.dot-field {
  background-image: radial-gradient(circle, rgba(248, 242, 234, 0.85) 0 1px, transparent 2px);
  background-size: 22px 22px;
  opacity: 0.18;
  animation: dotDrift 10s linear infinite;
}

.scan-frame {
  position: absolute;
  left: 50%;
  top: 44%;
  width: min(68vw, 310px);
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
  border: 1px solid rgba(248, 242, 234, 0.28);
  background: rgba(9, 7, 11, 0.08);
  transition: opacity 180ms ease, transform 180ms ease;
  z-index: 4;
  pointer-events: none;
}

.scan-frame::before {
  content: "INQUADRA OPERA";
  position: absolute;
  left: 50%;
  bottom: -30px;
  transform: translateX(-50%);
  color: var(--yellow);
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 0.68rem;
  white-space: nowrap;
}

.scan-frame span {
  position: absolute;
  width: 34px;
  height: 34px;
  border-style: solid;
  border-color: var(--yellow);
  filter: drop-shadow(0 0 8px var(--yellow));
}

.scan-frame span:nth-child(1) {
  top: -2px;
  left: -2px;
  border-width: 4px 0 0 4px;
}

.scan-frame span:nth-child(2) {
  top: -2px;
  right: -2px;
  border-width: 4px 4px 0 0;
}

.scan-frame span:nth-child(3) {
  right: -2px;
  bottom: -2px;
  border-width: 0 4px 4px 0;
}

.scan-frame span:nth-child(4) {
  bottom: -2px;
  left: -2px;
  border-width: 0 0 4px 4px;
}

.scan-brush {
  position: absolute;
  left: 10%;
  right: 10%;
  top: 18%;
  height: 3px;
  border-radius: 999px;
  background: linear-gradient(90deg, transparent, var(--yellow), var(--pink), var(--cyan), transparent);
  box-shadow: 0 0 16px rgba(255, 234, 58, 0.42);
  opacity: 0.86;
  transform: translateY(0) rotate(-3deg);
  animation: brushScan 2.7s ease-in-out infinite;
}

.scan-spark {
  position: absolute;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ink);
  box-shadow:
    0 0 10px currentColor,
    0 0 18px currentColor;
  opacity: 0;
  animation: sparkPulse 2.7s ease-in-out infinite;
}

.spark-one {
  left: 22%;
  top: 28%;
  color: var(--cyan);
}

.spark-two {
  right: 26%;
  top: 52%;
  color: var(--yellow);
  animation-delay: 0.32s;
}

.spark-three {
  left: 48%;
  bottom: 24%;
  color: var(--pink);
  animation-delay: 0.64s;
}

.lens.has-card .scan-frame::before {
  content: "OPERA RICONOSCIUTA";
}

.lens.has-card .scan-frame {
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.96);
}

.lens-status {
  position: absolute;
  left: max(12px, env(safe-area-inset-left));
  right: max(78px, env(safe-area-inset-right));
  top: max(12px, env(safe-area-inset-top));
  display: grid;
  gap: 5px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  backdrop-filter: blur(14px);
  z-index: 5;
}

.lens-status strong {
  color: var(--green);
  font-size: 0.74rem;
}

.lens-status span {
  color: var(--muted);
  font-size: 0.68rem;
  line-height: 1.35;
}

.work-card {
  position: absolute;
  left: max(12px, env(safe-area-inset-left));
  right: max(12px, env(safe-area-inset-right));
  bottom: max(12px, env(safe-area-inset-bottom));
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 10px;
  max-height: min(82svh, 680px);
  overflow: auto;
  padding: 12px;
  border: 1px solid rgba(255, 234, 58, 0.48);
  border-radius: 8px;
  background: rgba(9, 7, 11, 0.88);
  box-shadow: 0 0 36px rgba(255, 79, 184, 0.2);
  backdrop-filter: blur(16px);
  opacity: 0;
  transform: translateY(18px);
  transition: opacity 220ms ease, transform 220ms ease;
  pointer-events: none;
  z-index: 6;
}

.work-card[hidden] {
  display: none;
}

.lens.has-card .work-card {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.work-card-copy {
  display: grid;
  gap: 10px;
  min-width: 0;
  overflow: visible;
}

.work-heading {
  display: grid;
  grid-template-columns: 58px 1fr;
  gap: 10px;
  align-items: center;
}

.work-heading img {
  width: 58px;
  aspect-ratio: 0.72;
  border-radius: 6px;
  object-fit: cover;
}

.work-card span {
  color: var(--cyan);
  font-size: 0.64rem;
  text-transform: uppercase;
}

.work-card h2 {
  margin: 0;
  font-size: 1.18rem;
  line-height: 1.05;
}

.work-card p {
  margin: 0;
  color: var(--muted);
  font-size: calc(0.78rem * var(--card-text-scale));
  line-height: 1.38;
  white-space: pre-line;
}

.youtube-embed {
  position: relative;
  width: 100%;
  height: clamp(150px, 28svh, 230px);
  overflow: hidden;
  flex: none;
  border: 1px solid rgba(248, 242, 234, 0.16);
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.32);
}

.youtube-embed[hidden] {
  display: none;
}

.youtube-embed iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

dl {
  display: grid;
  gap: 5px;
  margin: 0;
}

dl div {
  display: grid;
  grid-template-columns: 80px 1fr;
  gap: 10px;
}

dt,
dd {
  margin: 0;
  font-size: calc(0.64rem * var(--card-text-scale));
}

dt {
  color: var(--muted);
}

dd {
  color: var(--ink);
  text-align: right;
}

.card-button {
  min-height: 40px;
  margin-bottom: max(14px, env(safe-area-inset-bottom));
  font-size: 0.72rem;
}

.text-size-control {
  display: grid;
  grid-template-columns: 1fr 44px 44px;
  gap: 8px;
  align-items: center;
  padding: 8px;
  border: 1px solid rgba(248, 242, 234, 0.14);
  border-radius: 6px;
  background: rgba(248, 242, 234, 0.05);
}

.text-size-control span {
  color: var(--muted);
  font-size: 0.64rem;
  text-transform: uppercase;
}

.text-size-control button {
  min-height: 34px;
  border: 1px solid rgba(248, 242, 234, 0.18);
  background: rgba(9, 7, 11, 0.56);
  color: var(--ink);
  font-weight: 800;
  font-size: 0.72rem;
}

.text-size-control button.is-active {
  border-color: var(--yellow);
  color: var(--yellow);
}

.text-size-control button:disabled {
  opacity: 0.42;
}

.exit-button {
  position: absolute;
  right: max(12px, env(safe-area-inset-right));
  top: max(12px, env(safe-area-inset-top));
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line);
  background: rgba(9, 7, 11, 0.72);
  color: var(--ink);
  font-size: 0.72rem;
  z-index: 7;
}

@keyframes dotDrift {
  to {
    background-position: 44px 44px;
  }
}

@keyframes brushScan {
  0%,
  100% {
    transform: translateY(0) rotate(-3deg) scaleX(0.7);
    opacity: 0.18;
  }

  18% {
    opacity: 0.9;
  }

  50% {
    transform: translateY(42vw) rotate(2deg) scaleX(1);
    opacity: 0.84;
  }

  82% {
    opacity: 0.9;
  }
}

@keyframes sparkPulse {
  0%,
  28%,
  100% {
    opacity: 0;
    transform: scale(0.4);
  }

  45% {
    opacity: 0.92;
    transform: scale(1);
  }

  58% {
    opacity: 0.2;
    transform: scale(1.7);
  }
}

@media (min-width: 720px) {
  .intro {
    padding-inline: max(32px, env(safe-area-inset-left));
  }

  .intro-actions {
    grid-template-columns: minmax(220px, 340px) minmax(160px, 220px);
    align-items: start;
  }

  .intro-actions p {
    grid-column: 1 / -1;
  }

  .work-card {
    left: 24px;
    right: auto;
    width: min(560px, calc(100vw - 48px));
  }

  .youtube-embed {
    height: 260px;
  }
}

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