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

html,
body {
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
}

.dark .font-headline {
  color: #e8d8c3;
}

main > section + section {
  border-top: 3px solid rgba(31, 61, 43, 0.85);
}

html.dark main > section + section {
  border-top: 3px solid rgba(31, 61, 43, 0.85);
}

.hero-gradient {
  background: radial-gradient(circle at 70% 40%, rgba(31, 61, 43, 0.08) 0%, rgba(232, 216, 195, 1) 60%);
}

html.dark .hero-gradient {
  background: radial-gradient(circle at 70% 40%, rgba(46, 94, 69, 0.25) 0%, rgba(11, 11, 11, 1) 60%);
}

.noise-overlay {
  position: fixed;
  inset: 0;
  z-index: 0;
  opacity: 0.04;
  pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)'/%3E%3C/svg%3E");
}

.floating-orbs {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 3;
  overflow: hidden;
}

.orb {
  position: absolute;
  border-radius: 999px;
  filter: blur(0.5px);
  opacity: 0.38;
  animation: orb-float 7s ease-in-out infinite;
  background: radial-gradient(
    circle,
    rgba(82, 168, 129, 0.58) 0%,
    rgba(82, 168, 129, 0.22) 56%,
    transparent 100%
  );
  box-shadow: 0 0 30px rgba(82, 168, 129, 0.3);
}

.orb-1 {
  width: 230px;
  height: 230px;
  left: 8%;
  top: 12%;
}

.orb-2 {
  width: 300px;
  height: 300px;
  right: 9%;
  top: 26%;
  animation-delay: 1.3s;
}

.orb-3 {
  width: 210px;
  height: 210px;
  left: 18%;
  bottom: 18%;
  animation-delay: 2.1s;
}

.orb-4 {
  width: 250px;
  height: 250px;
  right: 20%;
  bottom: 10%;
  animation-delay: 3.2s;
}

@keyframes orb-float {
  0%, 100% {
    transform: translate3d(0, 0, 0) scale(0.95);
    opacity: 0.16;
  }
  50% {
    transform: translate3d(0, -16px, 0) scale(1.08);
    opacity: 0.32;
  }
}

html.dark .orb {
  opacity: 0.24;
}

html.dark .orb-1,
html.dark .orb-3 {
  background: radial-gradient(circle, rgba(120, 210, 168, 0.2) 0%, rgba(120, 210, 168, 0.02) 68%, transparent 100%);
}

html.dark .orb-2,
html.dark .orb-4 {
  background: radial-gradient(circle, rgba(242, 235, 225, 0.2) 0%, rgba(242, 235, 225, 0.02) 68%, transparent 100%);
}

/* Subtle floating wave animation for text content across the page. */
h1,
h2,
h3,
p,
a,
label,
button,
li,
span {
  animation: text-wave 5.6s ease-in-out infinite;
  will-change: transform;
}

h1 { animation-duration: 6s; }
h2,
h3 { animation-duration: 5.2s; }
p,
li { animation-duration: 5.8s; }
a,
button,
label,
span { animation-duration: 4.8s; }

@keyframes text-wave {
  0%,
  100% {
    transform: translate3d(0, 0, 0);
  }
  50% {
    transform: translate3d(0, -2px, 0);
  }
}

.ipad-section {
  position: relative;
  z-index: 5;
}

.work-content {
  position: relative;
  z-index: 6;
}

.ipad-scroll-track {
  min-height: 280vh;
  position: relative;
}

/* Mobile flat: no tall scroll track + no sticky pin — those were costing main-thread work. */
.ipad-scroll-track.ipad-scroll-track--compact {
  min-height: auto;
  touch-action: pan-y;
  contain: layout style;
}

.ipad-stage {
  position: sticky;
  top: 0;
  min-height: 100vh;
  display: grid;
  place-items: center;
  perspective: 1400px;
  transform-style: preserve-3d;
}

/* Mobile flat mode: no 3D context — avoids costly perspective + rotateY compositing. */
.ipad-stage.ipad-stage--flat {
  perspective: none;
  transform-style: flat;
  position: relative;
  top: auto;
  min-height: 0;
  padding: 2.25rem 0 1rem;
  place-items: center;
}

.ipad {
  width: min(760px, 88vw);
  transform-style: preserve-3d;
  filter: drop-shadow(0 35px 60px rgba(34, 26, 13, 0.2));
  position: relative;
  --front-alpha: 1;
  --back-alpha: 0;
  will-change: transform;
}

.ipad.ipad--flat {
  transform-style: flat;
  will-change: auto;
  filter: none;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  opacity: 0;
  transform: translate3d(0, 14px, 0);
  transition:
    opacity 0.55s cubic-bezier(0.22, 1, 0.36, 1),
    transform 0.55s cubic-bezier(0.22, 1, 0.36, 1);
}

.ipad.ipad--flat.ipad--visible {
  opacity: 1;
  transform: translate3d(0, 0, 0);
}

@media (prefers-reduced-motion: reduce) {
  .ipad.ipad--flat {
    opacity: 1;
    transform: none;
    transition: none;
  }
}

.ipad.ipad--flat .ipad-rotation-layer,
.ipad.ipad--flat .spark-field {
  display: none;
}

.ipad.ipad--flat .ipad-shell {
  transform: none;
  transform-style: flat;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.22);
}

.ipad.ipad--flat .ipad-edge {
  display: none;
}

/* Swiper cssMode: native horizontal overflow — keep momentum scrolling smooth on iOS. */
.ipad.ipad--flat .ipad-swiper.swiper-css-mode {
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
}

.ipad-swiper-pagination.swiper-pagination-horizontal {
  position: relative;
  inset: auto;
  margin-top: 0.35rem;
  display: flex;
  justify-content: center;
  gap: 0.35rem;
}

.ipad-swiper-pagination .swiper-pagination-bullet {
  width: 7px;
  height: 7px;
  margin: 0 !important;
  background: rgba(31, 61, 43, 0.35);
  opacity: 1;
}

.ipad-swiper-pagination .swiper-pagination-bullet-active {
  background: #1f3d2b;
  transform: scale(1.15);
}

html.dark .ipad-swiper-pagination .swiper-pagination-bullet {
  background: rgba(159, 210, 179, 0.35);
}

html.dark .ipad-swiper-pagination .swiper-pagination-bullet-active {
  background: #9fd2b3;
}

.ipad-swipe-hint {
  transition: opacity 0.35s ease, max-height 0.4s ease, margin 0.4s ease;
}

.ipad-swipe-hint--dismissed {
  opacity: 0;
  max-height: 0;
  margin-top: 0 !important;
  margin-bottom: 0 !important;
  overflow: hidden;
  pointer-events: none;
}

.ipad-rotation-layer {
  position: absolute;
  inset: 0;
  border-radius: 34px;
  background: #1c1c1c;
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.04),
    0 18px 32px rgba(0, 0, 0, 0.35);
  opacity: var(--back-alpha);
  z-index: 7;
  pointer-events: none;
  will-change: opacity;
}

.ipad-rotation-layer::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: min(96px, 22%);
  aspect-ratio: 1 / 1;
  transform: translate(-50%, -50%);
  border-radius: 14px;
  background-image: url("https://i.postimg.cc/sgJKmkHR/sample-Website.png");
  background-size: cover;
  background-position: center;
  opacity: 0.82;
  filter: saturate(0.9) contrast(1.05);
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.08),
    0 8px 18px rgba(0, 0, 0, 0.25);
}

html.dark .ipad-rotation-layer {
  background: #ebe1d4;
  border: 1px solid rgba(28, 28, 28, 0.16);
  box-shadow:
    inset 0 0 0 1px rgba(28, 28, 28, 0.06),
    0 16px 28px rgba(0, 0, 0, 0.2);
}

html.dark .ipad-rotation-layer::after {
  opacity: 0.9;
  box-shadow:
    0 0 0 1px rgba(28, 28, 28, 0.12),
    0 8px 16px rgba(0, 0, 0, 0.16);
}

.ipad-shell {
  aspect-ratio: 4 / 3;
  border-radius: 34px;
  padding: 0;
  border: 1px solid rgba(232, 216, 195, 0.2);
  background: transparent;
  box-shadow: 0 30px 70px rgba(0, 0, 0, 0.45);
  transform: rotateX(8deg);
  position: relative;
  transform-style: preserve-3d;
  overflow: visible;
  --ipad-thickness: 14px;
  z-index: 5;
}

.ipad-face {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  transform-style: preserve-3d;
  overflow: hidden;
}

.ipad-face--front {
  background: linear-gradient(160deg, #262626, #171717);
  border: 1px solid rgba(255, 255, 255, 0.08);
  transform: translateZ(calc(var(--ipad-thickness) / 2));
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  z-index: 2;
  opacity: var(--front-alpha);
  will-change: opacity;
}

.ipad-face--back {
  background: #1c1c1c;
  border: 1px solid rgba(255, 255, 255, 0.06);
  transform: rotateY(180deg) translateZ(calc(var(--ipad-thickness) / 2));
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  z-index: 1;
  display: none;
}

html.dark .ipad-face--front {
  background: linear-gradient(160deg, #f0e7da, #ddd2c0);
  border: 1px solid rgba(28, 28, 28, 0.18);
}

html.dark .ipad-face--back {
  background: #e7dccd;
  border: 1px solid rgba(28, 28, 28, 0.16);
}

.ipad-edge {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  border: calc(var(--ipad-thickness) / 2) solid #111111;
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.08),
    0 12px 24px rgba(0, 0, 0, 0.35);
  pointer-events: none;
  transform: translateZ(0);
}

html.dark .ipad-edge {
  border-color: #cbc0b0;
  box-shadow:
    inset 0 0 0 1px rgba(28, 28, 28, 0.08),
    0 12px 24px rgba(0, 0, 0, 0.22);
}

.ipad-shell::before {
  content: "";
  position: absolute;
  inset: 2px;
  border-radius: inherit;
  background: linear-gradient(
    140deg,
    rgba(255, 255, 255, 0.12) 0%,
    rgba(255, 255, 255, 0.03) 18%,
    rgba(0, 0, 0, 0.24) 55%,
    rgba(0, 0, 0, 0.45) 100%
  );
  transform: translateZ(0);
  pointer-events: none;
}

.ipad-camera {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #355646, #151515 65%);
  z-index: 5;
  backface-visibility: hidden;
}

html.dark .ipad-camera {
  background: radial-gradient(circle at 30% 30%, #3f6452, #707070 68%);
}

.ipad-screen {
  width: calc(100% - 2rem);
  height: calc(100% - 2rem);
  margin: 1rem;
  border-radius: 24px;
  overflow: hidden;
  position: relative;
  background: #0b0b0b;
  transform: translateZ(2px);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.ipad-swiper,
.ipad-swiper .swiper-wrapper,
.ipad-swiper .swiper-slide {
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  transform: translateZ(0);
}

.project-link-card {
  width: 100%;
  height: 100%;
  display: block;
  position: relative;
  overflow: hidden;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.project-link-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  transform: translateZ(0);
}

.project-link-card__overlay {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(to top, rgba(8, 8, 8, 0.8) 4%, rgba(8, 8, 8, 0.08) 50%),
    radial-gradient(circle at 20% 12%, rgba(46, 94, 69, 0.2), transparent 40%);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.project-link-card__title {
  margin: 0;
  font-size: clamp(1.2rem, 3vw, 1.9rem);
  font-weight: 700;
  color: #f3e9dc;
  position: absolute;
  left: 1rem;
  bottom: 2.5rem;
  z-index: 4;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.project-link-card__url {
  margin: 0;
  position: absolute;
  left: 1rem;
  bottom: 1rem;
  z-index: 4;
  font-size: clamp(0.8rem, 1.4vw, 0.95rem);
  color: #d8e8df;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.spark-field {
  position: absolute;
  inset: -28px;
  pointer-events: none;
  z-index: 8;
  --spark-alpha: 0.55;
}

.spark {
  position: absolute;
  width: 3px;
  height: 46px;
  border-radius: 999px;
  background: linear-gradient(to bottom, rgba(184, 255, 220, 0), rgba(130, 233, 180, var(--spark-alpha)), rgba(184, 255, 220, 0));
  box-shadow: 0 0 16px rgba(130, 233, 180, calc(var(--spark-alpha) * 0.8));
  animation: spark-breathe 2.4s ease-in-out infinite;
}

.spark.s1 { top: 8%; left: 10%; transform: rotate(20deg); animation-delay: 0s; }
.spark.s2 { top: 14%; right: 14%; transform: rotate(-24deg); animation-delay: 0.4s; }
.spark.s3 { bottom: 12%; left: 16%; transform: rotate(-14deg); animation-delay: 0.8s; }
.spark.s4 { bottom: 8%; right: 10%; transform: rotate(28deg); animation-delay: 1.1s; }
.spark.s5 { top: 48%; left: -2%; transform: rotate(90deg); animation-delay: 1.6s; }
.spark.s6 { top: 44%; right: -2%; transform: rotate(90deg); animation-delay: 1.9s; }

.spark::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 6px;
  height: 6px;
  border-radius: 999px;
  transform: translate(-50%, -50%);
  background: rgba(195, 255, 223, 0.95);
  box-shadow: 0 0 14px rgba(130, 233, 180, 0.9);
}

/* Freeze work text + bubbles during tablet rotation. */
.is-ipad-rotating .floating-orbs .orb {
  animation: none;
  transform: none;
}

.is-ipad-rotating .work-content h1,
.is-ipad-rotating .work-content h2,
.is-ipad-rotating .work-content h3,
.is-ipad-rotating .work-content p,
.is-ipad-rotating .work-content a,
.is-ipad-rotating .work-content span,
.is-ipad-rotating .work-content li,
.is-ipad-rotating .work-content button,
.is-ipad-rotating .work-content label {
  animation: none !important;
  transform: none !important;
}

@keyframes spark-breathe {
  0%, 100% {
    opacity: 0.25;
    transform: translateY(0) scaleY(0.85);
  }
  50% {
    opacity: 0.95;
    transform: translateY(-4px) scaleY(1.15);
  }
}

html.dark .spark {
  background: linear-gradient(to bottom, rgba(158, 230, 190, 0), rgba(72, 186, 124, var(--spark-alpha)), rgba(158, 230, 190, 0));
  box-shadow: 0 0 18px rgba(72, 186, 124, calc(var(--spark-alpha) * 0.85));
}

@media (max-width: 640px) {
  html {
    scroll-behavior: auto;
  }

  .ipad-scroll-track:not(.ipad-scroll-track--compact) {
    min-height: 185vh;
  }

  .ipad-stage:not(.ipad-stage--flat) {
    top: 0;
    min-height: 92vh;
  }

  .ipad-rotation-layer {
    border-radius: 22px;
  }

  .ipad-shell {
    border-radius: 22px;
    --ipad-thickness: 10px;
  }

  .ipad-screen {
    border-radius: 16px;
    width: calc(100% - 1.3rem);
    height: calc(100% - 1.3rem);
    margin: 0.65rem;
  }

  .spark-field {
    inset: -18px;
  }

  .work-content {
    padding-top: 1.25rem;
  }

  footer a {
    word-break: break-word;
  }
}

@media (max-width: 480px) {
  .ipad-scroll-track:not(.ipad-scroll-track--compact) {
    min-height: 170vh;
  }

  .ipad {
    width: min(760px, 92vw);
  }
}

@media (max-width: 768px) {
  /* Heavy continuous animations hurt mobile scroll performance. */
  h1,
  h2,
  h3,
  p,
  a,
  label,
  button,
  li,
  span {
    animation: none !important;
    transform: none !important;
  }

  .floating-orbs {
    display: none;
  }

  .spark {
    animation: none;
    opacity: 0.45;
  }

  .ipad:not(.ipad--flat) {
    filter: drop-shadow(0 20px 30px rgba(34, 26, 13, 0.16));
  }
}
