/* ============================================================
   Ayaz Mirza — interactive digital ID card
   Everything inside a face is sized in cqw (container query
   width units) so both sides scale pixel-perfectly at any size.
   Exception: the face itself IS the container, and cqw on a
   container resolves against its ancestor (i.e. the viewport
   here), so the face's own radius and padding are derived from
   --card-w instead.
   ============================================================ */

:root {
  --green: #1fe03f;
  --green-bright: #4dff6b;
  --green-deep: #0b8f22;
  --ink: #050705;
  --card-ink: #080b09;
  --text: #f2fff4;
  --muted: #9fb3a4;
  --ease: cubic-bezier(0.22, 0.85, 0.28, 1);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--ink);
  color: var(--text);
  font-family: 'Archivo', 'Helvetica Neue', Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
}

/* Ambient green wall behind the card ------------------------------------ */
.glow {
  position: fixed;
  inset: -10%;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(60% 45% at 8% 62%, rgba(31, 224, 63, 0.85), transparent 62%),
    radial-gradient(48% 38% at 96% 30%, rgba(31, 224, 63, 0.42), transparent 65%),
    radial-gradient(90% 70% at 50% 120%, rgba(11, 143, 34, 0.35), transparent 70%),
    #000;
  filter: saturate(1.15);
  animation: breathe 9s ease-in-out infinite alternate;
}

.glow::after {
  content: '';
  position: absolute;
  inset: 0;
  opacity: 0.5;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4'/%3E%3C/filter%3E%3Crect width='220' height='220' filter='url(%23n)' opacity='0.55'/%3E%3C/svg%3E");
}

@keyframes breathe {
  from { transform: scale(1); opacity: 0.85; }
  to   { transform: scale(1.06); opacity: 1; }
}

/* Stage / scene ---------------------------------------------------------- */
.stage {
  position: relative;
  z-index: 1;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3vh;
  padding: max(2.5vh, env(safe-area-inset-top)) 4vw max(2.5vh, env(safe-area-inset-bottom));
}

.scene {
  --card-w: min(86vw, 390px, calc((100dvh - 15vh) * 0.66));
  --radius: calc(var(--card-w) * 0.07);
  perspective: 1500px;
  perspective-origin: 50% 45%;
  width: var(--card-w);
  aspect-ratio: 660 / 1000;
}

.card {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transform: rotateY(0deg);
  cursor: pointer;
  touch-action: none;
  will-change: transform;
  outline: none;
}

.card:focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 1.6vh;
  border-radius: calc(var(--radius) * 1.2);
}

/* Faces ------------------------------------------------------------------ */
.face {
  container-type: inline-size;
  position: absolute;
  inset: 0;
  border-radius: var(--radius);
  overflow: hidden;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  background:
    linear-gradient(160deg, rgba(255, 255, 255, 0.09), rgba(255, 255, 255, 0) 26%),
    linear-gradient(#0a0e0b, #05070600 40%, #060908);
  background-color: var(--card-ink);
  border: 1px solid rgba(190, 255, 205, 0.22);
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.6),
    0 2.4vh 6vh rgba(0, 0, 0, 0.75),
    0 0 9vh rgba(31, 224, 63, 0.22);
}

.face--back {
  transform: rotateY(180deg);
  padding: calc(var(--card-w) * 0.046) calc(var(--card-w) * 0.046)
           calc(var(--card-w) * 0.036);
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* Moving specular highlight (driven from JS) ----------------------------- */
.glare {
  position: absolute;
  inset: 0;
  z-index: 6;
  pointer-events: none;
  opacity: 0.55;
  mix-blend-mode: screen;
  background: radial-gradient(
    38% 30% at calc(var(--gx, 50%)) calc(var(--gy, 18%)),
    rgba(255, 255, 255, 0.3),
    rgba(255, 255, 255, 0.05) 45%,
    transparent 70%
  );
  transition: opacity 0.4s ease;
}

/* ============================ FRONT ============================ */
.portrait {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  aspect-ratio: 770 / 936;
  z-index: 1;
  background-size: 100% 100%;
  background-repeat: no-repeat;
  user-select: none;
  pointer-events: none;
}

.portrait__fade {
  position: absolute;
  inset: auto 0 0;
  height: 46cqw;
  z-index: 2;
  background: linear-gradient(to top, #070a08 26%, rgba(7, 10, 8, 0.72) 62%, transparent);
  pointer-events: none;
}

/* Stitched developer ribbon, hanging off the top edge */
.ribbon {
  position: absolute;
  top: 0;
  left: 5.6cqw;
  z-index: 5;
  width: max-content;
  min-width: 17cqw;
  padding: 3.4cqw 2.4cqw 5.2cqw;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.4cqw;
  background: linear-gradient(160deg, #232a24, #0d110e 62%);
  border-radius: 0 0 1.2cqw 1.2cqw;
  clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 78%, 0 100%);
  box-shadow: 0 1.6cqw 3.4cqw rgba(0, 0, 0, 0.7);
}

.ribbon::before {
  content: '';
  position: absolute;
  inset: 1.1cqw 1.1cqw 2.6cqw;
  border: 0.3cqw dashed rgba(31, 224, 63, 0.55);
  border-top: 0;
  border-radius: 0 0 0.8cqw 0.8cqw;
  pointer-events: none;
}

.ribbon__label {
  font-size: 2.15cqw;
  font-weight: 800;
  letter-spacing: 0.04em;
  white-space: nowrap;
  line-height: 1;
  color: var(--green);
  text-shadow: 0 0 1.4cqw rgba(31, 224, 63, 0.6);
}

.ribbon__icon {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 4.2cqw;
  font-weight: 700;
  line-height: 1;
  color: var(--green-bright);
  text-shadow: 0 0 2.2cqw rgba(31, 224, 63, 0.85);
}

/* Rating pill */
.rating {
  position: absolute;
  top: 4.4cqw;
  right: 4.6cqw;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 1.6cqw;
  padding: 1.9cqw 3.6cqw;
  border-radius: 99cqw;
  font-size: 5.4cqw;
  font-weight: 600;
  line-height: 1;
  background: rgba(10, 16, 11, 0.66);
  border: 0.28cqw solid rgba(31, 224, 63, 0.5);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.rating__star {
  width: 5cqw;
  height: 5cqw;
  fill: var(--green);
  filter: drop-shadow(0 0 1.4cqw rgba(31, 224, 63, 0.7));
}

.front__body {
  position: absolute;
  inset: auto 0 0;
  z-index: 4;
  padding: 0 5.6cqw 5.8cqw;
}

.name {
  margin: 0;
  font-size: 12.4cqw;
  font-weight: 900;
  letter-spacing: -0.02em;
  line-height: 1;
  text-shadow: 0 0.6cqw 2.4cqw rgba(0, 0, 0, 0.75);
}

.name span {
  color: var(--green);
  text-shadow: 0 0 3.6cqw rgba(31, 224, 63, 0.55);
}

.tagline {
  margin: 3.4cqw 0 0;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 4.05cqw;
  line-height: 1.55;
  color: #dfe9e1;
}

.front__foot {
  margin-top: 5.6cqw;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 3cqw;
}

.stats {
  margin: 0;
  display: flex;
  gap: 3.4cqw;
  white-space: nowrap;
}

.stat + .stat {
  padding-left: 3.4cqw;
  border-left: 0.3cqw solid rgba(230, 255, 235, 0.28);
}

.stat dt {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 3.2cqw;
  color: var(--green);
  letter-spacing: 0.02em;
}

.stat dd {
  margin: 1.1cqw 0 0;
  font-size: 4.1cqw;
  font-weight: 600;
}

.connect {
  flex: none;
  font: inherit;
  font-size: 4.5cqw;
  font-weight: 700;
  color: var(--green);
  padding: 2.8cqw 4.8cqw;
  border-radius: 99cqw;
  background: rgba(8, 14, 9, 0.7);
  border: 0.34cqw solid var(--green);
  box-shadow: 0 0 3.4cqw rgba(31, 224, 63, 0.35), inset 0 0 2.4cqw rgba(31, 224, 63, 0.16);
  cursor: pointer;
  transition: transform 0.25s var(--ease), box-shadow 0.25s ease, background 0.25s ease;
}

.connect:hover,
.connect:focus-visible {
  background: rgba(31, 224, 63, 0.16);
  box-shadow: 0 0 5.6cqw rgba(31, 224, 63, 0.6);
}

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

/* ============================= BACK ============================= */
.back__head {
  text-align: center;
  flex: none;
}

.code-glyph {
  display: block;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 5.4cqw;
  font-weight: 700;
  color: var(--green-bright);
  text-shadow: 0 0 2.6cqw rgba(31, 224, 63, 0.8);
}

.motto {
  margin: 2cqw 0 0;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 3.2cqw;
  letter-spacing: 0.14em;
  color: var(--green);
}

/* QR block */
.qr {
  margin-top: 3.2cqw;
  width: 53cqw;
  padding: 2.6cqw 2.6cqw 2.4cqw;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-decoration: none;
  color: var(--text);
  border: 0.3cqw solid rgba(31, 224, 63, 0.42);
  border-radius: 3.4cqw;
  background: rgba(10, 18, 12, 0.55);
  transition: box-shadow 0.3s ease, border-color 0.3s ease;
}

.qr:hover,
.qr:focus-visible {
  border-color: var(--green);
  box-shadow: 0 0 6cqw rgba(31, 224, 63, 0.35);
}

.qr__frame {
  display: block;
  padding: 1.6cqw;
  border-radius: 2cqw;
  background: var(--green);
  box-shadow: 0 0 7cqw rgba(31, 224, 63, 0.65);
}

.qr__frame img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 0.6cqw;
}

.qr__url {
  margin-top: 2.4cqw;
  display: flex;
  align-items: center;
  gap: 1.8cqw;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 3.9cqw;
}

.qr__url .icon {
  width: 4.6cqw;
  height: 4.6cqw;
  fill: none;
  stroke: var(--green);
  stroke-width: 1.6;
}

.qr__hint {
  margin-top: 1.4cqw;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 2.7cqw;
  white-space: nowrap;
  color: var(--muted);
}

/* Contact rows */
.contacts {
  list-style: none;
  margin: 3.2cqw 0 0;
  padding: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 1.9cqw;
}

.contacts a {
  display: flex;
  align-items: center;
  gap: 3cqw;
  padding: 2cqw 3.4cqw;
  border-radius: 99cqw;
  text-decoration: none;
  color: var(--text);
  background: rgba(12, 20, 14, 0.6);
  border: 0.28cqw solid rgba(31, 224, 63, 0.3);
  transition: transform 0.22s var(--ease), border-color 0.22s ease, background 0.22s ease;
}

.contacts a:hover,
.contacts a:focus-visible {
  border-color: var(--green);
  background: rgba(31, 224, 63, 0.12);
  transform: translateX(0.8cqw);
}

.contacts a:active { transform: scale(0.985); }

.contact__icon {
  flex: none;
  display: grid;
  place-items: center;
  width: 7.4cqw;
  padding-right: 2.8cqw;
  border-right: 0.28cqw solid rgba(31, 224, 63, 0.35);
  color: var(--green);
}

.contact__icon svg {
  width: 6.1cqw;
  height: 6.1cqw;
  fill: var(--green);
  filter: drop-shadow(0 0 1.6cqw rgba(31, 224, 63, 0.55));
}

.contact__text {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5cqw;
}

.contact__label {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 2.6cqw;
  letter-spacing: 0.1em;
  color: var(--green);
}

.contact__value {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 3.5cqw;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Footer */
.back__foot {
  margin-top: auto;
  padding-top: 2.8cqw;
  width: 100%;
  text-align: center;
}

.dashes {
  display: block;
  height: 0.3cqw;
  background-image: linear-gradient(to right, rgba(31, 224, 63, 0.75) 55%, transparent 0);
  background-size: 3.4cqw 0.3cqw;
  background-repeat: repeat-x;
}

.back__foot p {
  margin: 2.4cqw 0 0;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 2.8cqw;
  line-height: 1.55;
  letter-spacing: 0.09em;
  color: var(--muted);
}

/* Flip-back control */
.flip-back {
  position: absolute;
  top: 3.4cqw;
  right: 10cqw;
  z-index: 7;
  width: 8.6cqw;
  height: 8.6cqw;
  display: grid;
  place-items: center;
  padding: 0;
  border-radius: 50%;
  color: var(--green);
  background: rgba(10, 18, 12, 0.7);
  border: 0.28cqw solid rgba(31, 224, 63, 0.5);
  cursor: pointer;
  transition: transform 0.25s var(--ease), background 0.25s ease, box-shadow 0.25s ease;
}

.flip-back svg {
  width: 5cqw;
  height: 5cqw;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.flip-back:hover,
.flip-back:focus-visible {
  background: rgba(31, 224, 63, 0.16);
  box-shadow: 0 0 4cqw rgba(31, 224, 63, 0.45);
}

.flip-back:active { transform: scale(0.92); }

/* Corner brackets */
.bracket {
  position: absolute;
  width: 4.4cqw;
  height: 4.4cqw;
  border: 0.34cqw solid rgba(31, 224, 63, 0.6);
  pointer-events: none;
}

.bracket--tl { top: 3.4cqw; left: 3.4cqw; border-right: 0; border-bottom: 0; }
.bracket--tr { top: 3.4cqw; right: 3.4cqw; border-left: 0; border-bottom: 0; }
.bracket--bl { bottom: 3.4cqw; left: 3.4cqw; border-right: 0; border-top: 0; }
.bracket--br { bottom: 3.4cqw; right: 3.4cqw; border-left: 0; border-top: 0; }

/* ============================ HINT ============================= */
.hint {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 2.2vw;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: clamp(11px, 3.2vw, 13px);
  letter-spacing: 0.06em;
  color: var(--muted);
  transition: opacity 0.5s ease;
}

.hint__pulse {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 10px var(--green);
  animation: pulse 1.9s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(0.7); opacity: 0.5; }
  50%      { transform: scale(1.15); opacity: 1; }
}

.motion-btn {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 12px;
  color: var(--green);
  background: rgba(10, 18, 12, 0.7);
  border: 1px solid rgba(31, 224, 63, 0.5);
  border-radius: 99px;
  padding: 8px 16px;
  cursor: pointer;
}

.motion-btn[hidden] { display: none; }

/* Landscape phones: keep the card fully visible */
@media (orientation: landscape) and (max-height: 560px) {
  .stage { gap: 1.2vh; padding-block: 1.2vh; }
  .scene { --card-w: min(80vw, 320px, calc((100dvh - 11vh) * 0.66)); }
  .hint { font-size: 11px; }
  .motion-btn { padding: 5px 12px; }
}

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

/* The side facing away must not swallow taps or focus */
.face[aria-hidden='true'] { pointer-events: none; }
