/*
 * Teepn — NFC social cards (card shuffle)
 * Mobile-first. The Figma frame is 1080 × 1920 (a 360pt phone at 3×) and the
 * card is 720 wide in it, so every card measurement below is written in card
 * units × --u, where --u = card width / 720. The card is a fixed-proportion
 * object that scales with the viewport; the page around it is flow layout.
 */

:root {
  --color-bg: #ffffff;
  --color-tx: #0a0a0a;
  --color-fa: #6b6b6b;
  --color-blk: #000;

  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);

  /* 720 / 1080 of the viewport on phones, capped by the height the stage
     really has (100cqh), so the stack, dots and Buy button always fit on one
     screen whatever the notch, home bar or browser toolbars take.
     Height needed = 1.74 x card (peek + card) + 124px (dots + Buy button). */
  --card-w: min(66.667vw, (100cqh - 124px) / 1.76, 400px);
  --gutter: 6.667vw; /* 72 / 1080 */

  color-scheme: light;
}

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

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

/* One fixed screen: nothing scrolls and nothing bounces. */
html,
body {
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  margin: 0;
  background: var(--color-bg);
  color: var(--color-tx);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1,
h2,
p {
  margin: 0;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

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

/* ------------------------------------------------------------------ Page */

.page {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  /* clip (not hidden) so a thrown card can never scroll the page sideways */
  overflow: clip;
  height: 100vh;
  height: 100svh; /* the visible area with browser toolbars showing */
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  padding:
    max(8vw, env(safe-area-inset-top))
    max(var(--gutter), env(safe-area-inset-right))
    max(8vw, env(safe-area-inset-bottom))
    max(var(--gutter), env(safe-area-inset-left));
}

/* Ambient glows: 900 / 1080 wide, drifting on the design's 8s loop. */
.glow {
  position: absolute;
  z-index: -1;
  width: min(83.333vw, 900px);
  aspect-ratio: 1;
  translate: -50% -50%;
  pointer-events: none;
  animation: 8s var(--ease-in-out) infinite;
}

.glow img {
  display: block;
  width: 100%;
  height: 100%;
}

.glow--violet {
  left: 17.59%; /* centre (190, 710) in the 1080 × 1920 frame */
  top: 36.98%;
  animation-name: drift-violet;
}

.glow--gold {
  left: 82.41%; /* centre (890, 1630) */
  top: 84.9%;
  animation-name: drift-gold;
}

@keyframes drift-violet {
  50% { transform: translate(13.333%, 8.889%); } /* 120, 80 of 900 */
}

@keyframes drift-gold {
  50% { transform: translate(-15.556%, -11.111%); } /* -140, -100 of 900 */
}

/* ---------------------------------------------------------------- Header */

.header {
  display: flex;
  justify-content: center;
  padding-bottom: 0.5em;
  font-size: clamp(26px, 8vw, 38px);
  color: var(--color-tx);
}

/*
 * Teepn lockup: wordmark with the red hand hooked over the "n". All offsets
 * are in em so the same lockup works in the page header and on the cards.
 */
.teepn {
  position: relative;
  display: inline-block;
  padding-right: 0.81em; /* the part of the hand that sticks out past the n */
  font-family: Poppins, Inter, sans-serif;
  font-size: 1em;
  font-weight: 400;
  line-height: 1;
  white-space: nowrap;
}

.teepn__text {
  position: relative;
  display: inline-block;
}

.teepn__hand {
  position: absolute;
  left: calc(100% - 0.24em);
  top: 0.04em;
  width: 1.07em;
  height: 1.35em;
  max-width: none;
}

/* Offsets here are in the mark's own (small) em. */
.teepn__reg {
  position: absolute;
  left: calc(100% - 0.7em);
  top: 5.5em;
  font-size: 0.17em;
  font-weight: 500;
  line-height: 1;
}

/* ----------------------------------------------------------------- Stage */

.stage {
  container-type: size; /* lets --card-w measure the space left (cqh) */
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.deck-wrap {
  position: relative;
  width: var(--card-w);
  /* Room for the back cards that peek above the deck. */
  margin-top: calc(var(--card-w) * 0.16);
}

.deck {
  position: relative;
  z-index: 1; /* thrown cards pass over the arrow button */
  width: 100%;
  aspect-ratio: 720 / 1136;
  container-type: inline-size;
  touch-action: none; /* the page never scrolls, so drags belong to the card */
  outline: none;
}

.deck:focus-visible .card.is-top {
  outline: 2px solid var(--color-tx);
  outline-offset: 4px;
}

/* ------------------------------------------------------------------ Card */

.card {
  --u: calc(100cqw / 720);

  /* Depth state, written by script.js. Units: card units / degrees. */
  --x: 0;
  --y: 0;
  --r: 0;
  --s: 1;
  --b: 0;
  --t: 0.01;
  --o: 1;

  position: absolute;
  inset: 0;
  overflow: hidden;
  border-radius: calc(36 * var(--u));
  background: #f3f1f4;
  color: #17171a;
  font-family: Poppins, Inter, ui-sans-serif, system-ui, sans-serif;
  box-shadow:
    0 0 0 1px rgba(10, 10, 10, 0.08),
    0 calc(24 * var(--u)) calc(60 * var(--u)) rgba(10, 10, 10, 0.18);

  transform:
    translate(calc(var(--x) * var(--u)), calc(var(--y) * var(--u)))
    rotate(calc(var(--r) * 1deg))
    scale(var(--s));
  filter: blur(calc(var(--b) * var(--u)));
  opacity: var(--o);
  transition:
    transform 760ms var(--ease-spring),
    filter 760ms var(--ease-out),
    opacity 760ms var(--ease-out);

  user-select: none;
  -webkit-user-select: none;
  touch-action: none; /* the page never scrolls, so drags belong to the card */
  will-change: transform;
}

.card.is-top {
  cursor: grab;
}

.card.is-dragging {
  cursor: grabbing;
}

.card.is-dragging,
.card.is-instant {
  transition: none;
}

.card.is-instant .card__tint {
  transition: none;
}

.card img {
  display: block;
  -webkit-user-drag: none;
  pointer-events: none;
}

/* Brand gradients: a base sweep, a cool glow top-right, a warm/deep one bottom-left. */
.card--instagram {
  --panel:
    radial-gradient(95% 55% at 100% 0%, #8a55c8 0%, rgba(138, 85, 200, 0) 72%),
    radial-gradient(85% 45% at 0% 100%, #ff8f62 0%, rgba(255, 143, 98, 0) 72%),
    linear-gradient(200deg, #c4168c 0%, #ea1a66 46%, #f02a58 100%);
}

.card--facebook {
  --panel:
    radial-gradient(95% 55% at 100% 0%, #58c4ff 0%, rgba(88, 196, 255, 0) 72%),
    radial-gradient(85% 45% at 0% 100%, #0a2f9e 0%, rgba(10, 47, 158, 0) 72%),
    linear-gradient(200deg, #2f8bff 0%, #1468e0 50%, #0f55cc 100%);
}

.card--youtube {
  --panel:
    radial-gradient(95% 55% at 100% 0%, #ff8a4c 0%, rgba(255, 138, 76, 0) 72%),
    radial-gradient(85% 45% at 0% 100%, #7c0019 0%, rgba(124, 0, 25, 0) 72%),
    linear-gradient(200deg, #ff3030 0%, #e0102b 50%, #bd0a24 100%);
}

.card--tiktok {
  --panel:
    radial-gradient(95% 55% at 100% 0%, rgba(37, 244, 238, 0.55) 0%, rgba(37, 244, 238, 0) 72%),
    radial-gradient(85% 45% at 0% 100%, rgba(254, 44, 85, 0.6) 0%, rgba(254, 44, 85, 0) 72%),
    linear-gradient(200deg, #1c1c22 0%, #0d0d10 50%, #050506 100%);
}

/* Coloured panel with the speech-bubble tail (shape lives in the mask). */
.card__panel {
  position: absolute;
  left: calc(10 * var(--u));
  top: calc(10 * var(--u));
  width: calc(700 * var(--u));
  height: calc(932 * var(--u));
  background: var(--panel);
  color: #fff;
  -webkit-mask: url("assets/panel-mask.svg") center / 100% 100% no-repeat;
  mask: url("assets/panel-mask.svg") center / 100% 100% no-repeat;
}

.card__nfc {
  position: absolute;
  top: calc(25 * var(--u));
  right: calc(40 * var(--u));
  display: flex;
  align-items: center;
  gap: calc(8 * var(--u));
}

.card__nfc-badge {
  display: grid;
  place-items: center;
  width: calc(104 * var(--u));
  height: calc(66 * var(--u));
  border: calc(4 * var(--u)) solid currentColor;
  border-radius: calc(10 * var(--u));
  font-size: calc(38 * var(--u));
  font-weight: 800;
  line-height: 1;
  letter-spacing: 0.02em;
}

.card__nfc img {
  width: calc(36 * var(--u));
  height: calc(56 * var(--u));
}

.card__brand {
  position: absolute;
  inset: calc(339 * var(--u)) 0 auto;
  translate: 0 -50%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: calc(18 * var(--u));
}

.card__glyph {
  flex: none;
  width: calc(150 * var(--u));
  height: calc(150 * var(--u));
}

.card__glyph--wide {
  height: calc(107 * var(--u));
}

.card__wordmark {
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
}

.card__wordmark--script {
  font-family: Lobster, "Brush Script MT", cursive;
  font-size: calc(76 * var(--u));
  font-weight: 400;
}

.card__wordmark--facebook {
  font-family: Inter, sans-serif;
  font-size: calc(76 * var(--u));
  letter-spacing: -0.045em;
}

.card__wordmark--youtube {
  font-family: Inter, sans-serif;
  font-size: calc(78 * var(--u));
  letter-spacing: -0.06em;
}

.card__wordmark--tiktok {
  font-family: Inter, sans-serif;
  font-size: calc(84 * var(--u));
  letter-spacing: -0.04em;
}

/* Footer: "let's be Social." on the left, maker's mark on the right. */
.card__lets,
.card__social,
.card__maker {
  position: absolute;
  line-height: 1;
}

.card__lets {
  left: calc(57 * var(--u));
  top: calc(926 * var(--u));
  font-size: calc(44 * var(--u));
  font-weight: 300;
  letter-spacing: 0.06em;
}

.card__social {
  left: calc(38 * var(--u));
  top: calc(976 * var(--u));
  font-size: calc(108 * var(--u));
  font-weight: 500;
  letter-spacing: -0.02em;
}

.card__maker {
  right: calc(84 * var(--u));
  top: calc(928 * var(--u));
  display: flex;
  flex-direction: column;
  align-items: center;
}

.card__maker-eyebrow {
  font-size: calc(9 * var(--u));
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.card__maker-with {
  margin-top: calc(20 * var(--u));
  font-size: calc(40 * var(--u));
  font-weight: 800;
  text-transform: uppercase;
}

.card__maker-name {
  margin-top: calc(14 * var(--u));
  padding-right: 0.4em; /* keeps "With" centred over the wordmark */
  font-size: calc(46 * var(--u));
}

/* Darkens cards as they sit deeper in the stack. */
.card__tint {
  position: absolute;
  inset: 0;
  z-index: 2;
  background: var(--color-blk);
  opacity: var(--t);
  transition: opacity 760ms var(--ease-out);
  pointer-events: none;
}

/* ------------------------------------------------- Next button (outside) */

.next {
  --size: clamp(40px, var(--card-w) * 0.16, 56px);

  position: absolute;
  left: calc(100% + clamp(8px, 3vw, 24px));
  top: 50%;
  translate: 0 -50%;
  display: grid;
  place-items: center;
  width: var(--size);
  height: var(--size);
  border-radius: 50%;
  background: rgba(10, 10, 10, 0.06);
  border: 1px solid rgba(10, 10, 10, 0.12);
  transition: transform 200ms var(--ease-out), background-color 200ms var(--ease-out);
}

/* Keep a 44px touch target. */
.next::after {
  content: "";
  position: absolute;
  inset: 50% auto auto 50%;
  width: max(100%, 44px);
  height: max(100%, 44px);
  translate: -50% -50%;
  border-radius: 50%;
}

.next img {
  width: calc(var(--size) * 0.38);
  height: auto;
}

.next:active {
  transform: scale(0.92);
}

.next:focus-visible {
  outline: 2px solid var(--color-tx);
  outline-offset: 3px;
}

@media (hover: hover) {
  .next:hover {
    background: rgba(10, 10, 10, 0.12);
    transform: scale(1.06);
  }
}

/* ------------------------------------------------------------------ Dots */

.dots {
  display: flex;
  margin-top: clamp(10px, var(--card-w) * 0.06, 24px);
}

.dots__btn {
  display: grid;
  place-items: center;
  width: calc(var(--card-w) * 48 / 720);
  min-width: 16px;
  height: 32px;
}

.dots__btn::before {
  content: "";
  width: max(6px, calc(var(--card-w) * 24 / 720));
  aspect-ratio: 1;
  border-radius: 50%;
  background: rgba(10, 10, 10, 0.2);
  transition: background-color 300ms var(--ease-out), scale 300ms var(--ease-out);
}

.dots__btn[aria-current="true"]::before {
  background: var(--color-tx);
}

.dots__btn:focus-visible {
  outline: none;
}

.dots__btn:focus-visible::before {
  outline: 2px solid var(--color-tx);
  outline-offset: 3px;
}

@media (hover: hover) {
  .dots__btn:hover::before {
    scale: 1.25;
  }
}

/* ------------------------------------------------------------- Buy button */

.buy {
  display: grid;
  place-items: center;
  min-width: min(100%, 200px);
  height: 48px;
  margin-top: 12px;
  padding: 0 32px;
  border-radius: 999px;
  background: #0a0a0a;
  color: #fff;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.01em;
  text-decoration: none;
  box-shadow: 0 8px 24px rgba(10, 10, 10, 0.18);
  transition: transform 200ms var(--ease-out), background-color 200ms var(--ease-out);
  -webkit-tap-highlight-color: transparent;
}

.buy:active {
  transform: scale(0.96);
}

.buy:focus-visible {
  outline: 2px solid var(--color-tx);
  outline-offset: 3px;
}

@media (hover: hover) {
  .buy:hover {
    background: #26262b;
    transform: translateY(-1px);
  }
}

/* ------------------------------------------------------------ Breakpoints */

@media (min-width: 600px) {
  :root {
    --card-w: min(52vw, (100cqh - 124px) / 1.76, 380px);
    --gutter: 48px;
  }

  .page {
    padding-top: max(48px, env(safe-area-inset-top));
  }
}

/* Desktop: same centred column, larger card. */
@media (min-width: 960px) {
  :root {
    --card-w: min(30vw, (100cqh - 124px) / 1.76, 420px);
    --gutter: clamp(48px, 6vw, 96px);
  }

  .page {
    max-width: 1440px;
    margin-inline: auto;
    padding-block: 40px;
  }

  .header {
    font-size: 44px;
  }

  .glow {
    width: min(62vw, 900px);
  }

  .glow--violet {
    left: 22%;
    top: 40%;
  }

  .glow--gold {
    left: 84%;
    top: 82%;
  }
}

/* ------------------------------------------------------- Reduced motion */

@media (prefers-reduced-motion: reduce) {
  .glow {
    animation: none;
  }

  .card {
    transition:
      transform 240ms ease,
      filter 240ms ease,
      opacity 240ms ease;
  }

  .card__tint {
    transition-duration: 240ms;
  }
}
