/* =====================================================================
   FULL-PAGE 3D CARD FLIP
   ---------------------------------------------------------------------
   DOM:   .ak-scene            perspective + dark "stage"
            .ak-dolly          pulls the card back slightly mid-turn
              .ak-card         the rotating slab (preserve-3d)
                .ak-face.ak-front   your portfolio
                .ak-face.ak-back    Developer Core
          .ak-pager            dots + hint (outside the card, never rotates)

   Everything is scoped to html.ak-on, which a one-line script in <head>
   adds. If scripts are off, the page falls back to the original layout.

   Tuning:  --ak-dur  (flip time)   --ak-ease  (easing)   --ak-persp (depth)
   ===================================================================== */

:root {
  --ak-dur: 1.2s;
  --ak-ease: cubic-bezier(0.65, 0, 0.35, 1);
}

/* ---------- document: no page scroll, each face scrolls itself ---------- */
html.ak-on,
html.ak-on body {
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;          /* also stops the browser's swipe-back gesture */
}
html.ak-on body::before { display: none; }   /* grain is redrawn on the front face */

/* ---------- scene (perspective) ---------- */
.ak-on .ak-scene {
  --ak-base: 0deg;                    /* resting angle of the card */
  --ak-tilt: 0deg;                    /* small "peek" while dragging */
  --ak-persp: clamp(900px, 160vw, 2600px);
  position: fixed;
  inset: 0;
  z-index: 1;
  overflow: hidden;
  overflow: clip;                     /* clip can't be scrolled by focus()/scrollIntoView() */
  perspective: var(--ak-persp);
  perspective-origin: 50% 50%;
  background:
    radial-gradient(ellipse 70% 60% at 50% 50%, #1c1646 0%, #0b0820 70%, #05040f 100%);
}
.ak-on .ak-scene[data-face="back"] { --ak-base: -180deg; }

.ak-on .ak-dolly {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
}

/* ---------- the card ----------
   Front → back turns by -180deg so the near edge follows a right-to-left
   swipe, like pushing the surface of a real card. The back face is
   pre-rotated 180deg, so its text is never mirrored. */
.ak-on .ak-card {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  transform: rotateY(calc(var(--ak-base) + var(--ak-tilt)));
  transition: transform var(--ak-dur) var(--ak-ease);
}
.ak-on .ak-scene.is-dragging .ak-card { transition: none; }
.ak-on .ak-scene.is-animating .ak-card { will-change: transform; }

/* ---------- faces ---------- */
.ak-on .ak-face {
  position: absolute;
  inset: 0;
  overflow: hidden;
  overflow: clip;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;        /* the face that points away is never drawn */
  outline: none;
  box-shadow: 0 0 0 1px rgba(170, 160, 255, .16), 0 30px 90px rgba(0, 0, 0, .6);
}
.ak-on .ak-face.is-inactive { visibility: hidden; pointer-events: none; }
.ak-on .ak-face[hidden] { display: none; }

/* depth cue: faces darken a little as they turn edge-on */
.ak-on .ak-face::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 200;
  background: #000;
  opacity: 0;
  pointer-events: none;
}
@keyframes ak-shade { 0%, 100% { opacity: 0; } 50% { opacity: .5; } }
.ak-on .ak-scene.is-animating .ak-face::after { animation: ak-shade var(--ak-dur) var(--ak-ease); }

/* back face is pre-rotated so it reads correctly once the card has turned */
.ak-on .ak-back { transform: rotateY(180deg); }

/* ---------- FRONT: your original page, now an opaque card ----------
   The background and grain below are copied from body / body::before in
   index.html. If you change those, update them here too. */
.ak-on .ak-front {
  color: var(--ink);
  background-color: var(--bg);
  background-image:
    radial-gradient(900px 600px at 85% -5%, rgba(150, 120, 230, .38), transparent 60%),
    radial-gradient(800px 700px at -10% 45%, rgba(245, 181, 208, .12), transparent 60%),
    radial-gradient(900px 800px at 110% 85%, rgba(140, 200, 230, .16), transparent 60%),
    linear-gradient(180deg, #241d4a, #2d2559 50%, #241d4a);
}
.ak-on .ak-front::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: .07;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* These were position:fixed to the window. They now pin to the face, which
   keeps them in place while the page scrolls underneath. --ak-sbw is the
   scrollbar width, so centring matches the original on classic scrollbars. */
.ak-on .ak-front nav { position: absolute; left: calc(50% - var(--ak-sbw, 0px) / 2); }
.ak-on .ak-front .bgfx { position: absolute; inset: 0 var(--ak-sbw, 0px) 0 0; }

/* ---------- scrollers (one per face) ---------- */
.ak-on .ak-scroll {
  position: absolute;
  inset: 0;
  z-index: 1;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  overscroll-behavior-x: none;
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;            /* html{scroll-behavior} moved here */
  scroll-padding-top: calc(84px + env(safe-area-inset-top, 0px));
  touch-action: pan-y pinch-zoom;     /* vertical scroll stays native; horizontal reaches the flip */
}

/* ---------- while dragging with a mouse ---------- */
html.ak-on body.ak-dragging,
html.ak-on body.ak-dragging * {
  -webkit-user-select: none !important;
  user-select: none !important;
  cursor: grabbing !important;
}

/* ---------- pager: dots + hint ---------- */
.ak-pager {
  position: fixed;
  left: 50%;
  bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  border-radius: 99px;
  font: 500 12px/1 Inter, system-ui, sans-serif;
  color: #e9e1ff;
  background: rgba(24, 18, 58, .62);
  border: 1px solid rgba(220, 200, 255, .22);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, .3);
  transition: background .6s, border-color .6s, color .6s;
}
.ak-pager[hidden] { display: none; }
.ak-pager[data-face="back"] {
  color: #d6e6ff;
  background: rgba(6, 16, 46, .72);
  border-color: rgba(150, 190, 255, .35);
}
.ak-dot {
  width: 22px;
  height: 22px;
  padding: 0;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: none;
  cursor: pointer;
}
.ak-dot::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  opacity: .35;
  transition: opacity .3s, transform .3s;
}
.ak-dot[aria-current="true"]::before { opacity: 1; transform: scale(1.25); }
.ak-dot:hover::before { opacity: .75; }
.ak-dot:focus-visible { outline: 2px solid currentColor; outline-offset: 1px; }
.ak-pager-label {
  max-width: 24em;
  overflow: hidden;
  white-space: nowrap;
  letter-spacing: .01em;
  transition: max-width .5s, opacity .4s;
}
.ak-pager.is-compact .ak-pager-label { max-width: 0; opacity: 0; }
.ak-pager.is-compact { gap: 2px; }
.ak-pager.is-compact:hover,
.ak-pager.is-compact:focus-within { gap: 10px; }
.ak-pager.is-compact:hover .ak-pager-label,
.ak-pager.is-compact:focus-within .ak-pager-label { max-width: 24em; opacity: 1; }

.ak-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ---------- motion: the card pulls back a touch while it turns ---------- */
@keyframes ak-dolly {
  0%   { transform: translateZ(0); animation-timing-function: ease-out; }
  50%  { transform: translateZ(calc(-1 * clamp(140px, 16vw, 320px))); animation-timing-function: ease-in; }
  100% { transform: translateZ(0); }
}
.ak-on .ak-scene.is-animating .ak-dolly { animation: ak-dolly var(--ak-dur) linear both; }

/* ---------- reduced motion: no spin, the faces simply swap ---------- */
@media (prefers-reduced-motion: reduce) {
  :root { --ak-dur: 0s; }
  .ak-on .ak-scene .ak-dolly,
  .ak-on .ak-scene .ak-face::after { animation: none !important; }
}

@media (max-width: 600px) {
  .ak-pager { font-size: 11.5px; }
}


/* ---------- scrollbar: lilac to pink pill, in line with the rest of the UI ---------- */
.ak-on .ak-scroll { scrollbar-width: thin; scrollbar-color: rgba(218, 200, 246, .6) transparent; }
@supports selector(::-webkit-scrollbar) {
  .ak-on .ak-scroll { scrollbar-width: auto; scrollbar-color: auto; }
  .ak-on .ak-scroll::-webkit-scrollbar { width: 14px; }
  .ak-on .ak-scroll::-webkit-scrollbar-track { background: transparent; margin: 86px 0 64px; }
  .ak-on .ak-scroll::-webkit-scrollbar-thumb {
    min-height: 52px; border: 4px solid transparent; border-radius: 99px; background-clip: padding-box;
    background-image: linear-gradient(180deg, #dac8f6, #f4b6d1 55%, #ffb98a);
    opacity: .8; transition: background-color .2s;
  }
  .ak-on .ak-scroll::-webkit-scrollbar-thumb:hover { border-width: 3px; }
  .ak-on .ak-scroll::-webkit-scrollbar-thumb:active { border-width: 3px; background-image: linear-gradient(180deg, #f4b6d1, #a8e6d8); }
  .ak-on .ak-scroll::-webkit-scrollbar-corner { background: transparent; }
}

/* front face: no visible scrollbar (scrolling still works) */
.ak-on #ak-front { scrollbar-width: none; -ms-overflow-style: none; }
.ak-on #ak-front::-webkit-scrollbar { width: 0; height: 0; display: none; }

/* front side: no visible scrollbar (scrolling still works) */
.ak-on #ak-front-scroll { scrollbar-width: none; -ms-overflow-style: none; }
.ak-on #ak-front-scroll::-webkit-scrollbar { width: 0; height: 0; display: none; }
