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

html, body, #root {
  background-color: #0C0C0C;
  font-family: 'Kanit', sans-serif;
}

html {
  scroll-behavior: smooth;
}

body {
  overflow-x: clip;
}

.hero-nav {
  background: transparent;
}

.hero-nav-link {
  text-shadow: 0 1px 10px rgba(12, 12, 12, 0.65);
  transition: color 0.25s ease, opacity 0.2s ease, text-shadow 0.25s ease, filter 0.25s ease;
}

.hero-nav-link.is-active {
  color: #FFFFFF !important;
  filter: brightness(1.14);
  text-shadow:
    0 0 8px rgba(215, 226, 234, 0.72),
    0 0 18px rgba(182, 0, 168, 0.48),
    0 1px 10px rgba(12, 12, 12, 0.7);
}

.hero-heading {
  background: linear-gradient(180deg, #646973 0%, #BBCCD7 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero-title-track {
  display: inline-block;
}

.hero-title-group + .hero-title-group,
.hero-title-copy + .hero-title-copy {
  display: none;
}

@keyframes hero-title-marquee {
  from { transform: translate3d(-50%, 0, 0); }
  to   { transform: translate3d(0, 0, 0); }
}

@keyframes heroPortraitFloat {
  0%   { transform: translateY(0px) rotate(-1deg); }
  30%  { transform: translateY(-22px) rotate(0.5deg); }
  60%  { transform: translateY(-10px) rotate(-0.5deg); }
  100% { transform: translateY(0px) rotate(-1deg); }
}

@media (max-width: 767px) {
  .hero-title-stage {
    top: 27%;
  }

  .hero-title {
    font-size: clamp(10.5rem, 28vw, 14rem) !important;
  }

  .hero-title-track {
    animation-duration: 10s !important;
  }

  .hero-portrait-img {
    animation: heroPortraitFloat 4.5s ease-in-out infinite;
    transform-origin: bottom center;
  }

  .hero-intro-copy {
    font-size: clamp(0.82rem, 3.6vw, 0.97rem) !important;
    line-height: 1.5 !important;
    max-width: 270px !important;
  }
}

@media (max-width: 1279px) {
  .hero-nav {
    background: #0C0C0C;
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
  }

  .hero-nav-link.is-active {
    filter: brightness(1.28);
    text-shadow:
      0 0 6px rgba(255, 255, 255, 0.95),
      0 0 16px rgba(215, 226, 234, 0.86),
      0 0 30px rgba(182, 0, 168, 0.72);
  }

  .hero-title-stage {
    position: absolute;
    left: 0;
    right: 0;
    top: 25%;
    z-index: 4;
    pointer-events: none;
    transform: translateY(-50%);
  }
  .hero-title {
    width: 100vw !important;
    min-width: 100vw;
    margin-top: 0 !important;
    font-size: clamp(9rem, 28vw, 17rem) !important;
  }
  .hero-title-track {
    display: flex;
    width: max-content;
    animation: hero-title-marquee 14s linear infinite;
    backface-visibility: hidden;
    will-change: transform;
  }
  .hero-title-group {
    display: flex !important;
    flex: 0 0 auto;
    gap: 5ch;
    padding-right: 5ch;
  }
  .hero-title-copy {
    display: inline-block !important;
    transform: scaleX(1.28);
    transform-origin: left center;
  }
}

@media (min-width: 768px) and (max-width: 1279px) {
  .hero-nav {
    gap: clamp(4rem, 10vw, 8.5rem) !important;
    padding: 1.6rem 2.4rem !important;
  }

  .hero-nav-link {
    font-size: clamp(1.14rem, 1.52vw, 1.34rem) !important;
    line-height: 1;
  }

  .hero-intro-copy {
    max-width: 460px !important;
    font-size: clamp(1.16rem, 1.72vw, 1.36rem) !important;
    line-height: 1.28 !important;
  }

  .hero-title-stage {
    top: 24%;
  }

  .about-copy {
    max-width: 560px !important;
    font-size: clamp(1.34rem, 2vw, 1.55rem) !important;
    line-height: 1.55 !important;
  }

  .site-contact-button {
    min-width: 176px;
    padding: 0.9rem 2.45rem !important;
    font-size: 0.82rem !important;
    line-height: 1;
  }

  .site-live-button {
    min-width: 132px;
    padding: 0.68rem 1.45rem !important;
    font-size: 0.72rem !important;
    line-height: 1;
  }

  .project-card-category {
    font-size: 0.65rem;
  }

  .project-card-title {
    font-size: clamp(0.95rem, 1.7vw, 1.2rem);
  }

  .project-description-copy {
    font-size: clamp(1.1rem, 1.55vw, 1.26rem) !important;
    line-height: 1.55 !important;
  }

  .service-number {
    font-size: clamp(4rem, 8vw, 5.8rem) !important;
  }

  .service-title {
    font-size: clamp(1.55rem, 2.65vw, 2rem) !important;
  }

  .service-desc,
  .contact-subtitle {
    font-size: clamp(1.22rem, 1.8vw, 1.38rem) !important;
    line-height: 1.55 !important;
  }

  #contact input,
  #contact textarea {
    font-size: 1.2rem !important;
  }

  .contact-submit-button {
    padding: 1rem 1.25rem !important;
    font-size: 0.88rem !important;
  }

  .contact-card-label {
    font-size: 0.82rem !important;
    line-height: 1.1;
  }

  .contact-card-value {
    font-size: clamp(1.08rem, 1.55vw, 1.24rem) !important;
    line-height: 1.2;
  }

  .back-to-top-button {
    width: 64px !important;
    height: 64px !important;
  }

  .back-to-top-button svg {
    width: 22px;
    height: 22px;
  }

}

@media (max-width: 1279px) and (prefers-reduced-motion: reduce) {
  .hero-title-stage { display: flex; justify-content: center; }
  .hero-title { animation: none; transform: translateX(0); }
  .hero-title-track { animation: none; transform: translateX(0); }
  .hero-portrait-img { animation: none; }
}

@keyframes projectvideo-spin {
  to { transform: rotate(360deg); }
}

.project-media-grid {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.project-stack-section {
  --project-stack-top: clamp(4.5rem, 8vh, 6rem);
  --project-stack-gap: 22px;
}

.project-scroll-track {
  min-height: 0;
}

.project-card-header {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  column-gap: 0.55rem;
}

.project-card-number {
  color: #D7E2EA;
  font-size: clamp(2.15rem, 10vw, 3rem);
  line-height: 1;
}

.project-card-title-block { min-width: 0; }

.project-card-category {
  color: #D7E2EA;
  font-size: clamp(0.48rem, 2vw, 0.62rem);
  opacity: 0.5;
}

.project-card-title {
  color: #D7E2EA;
  font-size: clamp(0.76rem, 3.25vw, 0.95rem);
  line-height: 1.2;
}

.project-side-column { display: contents; }

.project-description-card {
  grid-column: 1;
  grid-row: 1;
}

.project-main-wrap {
  grid-column: 2;
  grid-row: 1;
  min-width: 0;
}

@media (min-width: 1280px) {
  .project-stack-section {
    --project-stack-top: clamp(4.5rem, 8vh, 6rem);
    --project-stack-gap: 48px;
  }
  .project-card-header { column-gap: 1.5rem; }
  .project-card-number { font-size: clamp(2.5rem, 8vw, 120px); }
  .project-card-category { font-size: clamp(0.65rem, 1.2vw, 1rem); }
  .project-card-title { font-size: clamp(1rem, 2.5vw, 2rem); }
  .project-media-grid { display: flex; flex-direction: row; gap: 1rem; }
  .project-side-column {
    display: flex;
    flex: 0 0 38%;
    flex-direction: column;
    gap: 1rem;
  }
  .project-description-card {
    min-height: 0;
    flex: 1;
    height: auto;
  }
  .project-main-wrap {
    flex: 1 1 0;
    min-width: 0;
    display: flex;
    align-items: stretch;
  }
  .project-main-wrap > div {
    flex: 1;
    aspect-ratio: auto !important;
    height: clamp(320px, 55vh, 640px);
  }
}

/* Landscape: every screen where width > height, width up to 1300px, height up to 900px (excludes square desktop windows) */
@media (orientation: landscape) and (max-width: 1300px) and (max-height: 900px) {

  /* ── Hero ── */
  .hero-title-stage {
    position: absolute;
    left: 0;
    right: 0;
    top: 22% !important;
    z-index: 4;
    pointer-events: none;
    transform: translateY(-50%);
  }

  .hero-title {
    font-size: clamp(4rem, 20vh, 9rem) !important;
    margin-top: 0 !important;
    width: 100vw !important;
    min-width: 100vw;
  }

  .hero-title-track {
    display: flex;
    width: max-content;
    animation: hero-title-marquee 14s linear infinite;
    backface-visibility: hidden;
    will-change: transform;
  }

  .hero-title-group {
    display: flex !important;
    flex: 0 0 auto;
    gap: 5ch;
    padding-right: 5ch;
  }

  .hero-title-copy {
    display: inline-block !important;
    transform: scaleX(1.28);
    transform-origin: left center;
  }

  .hero-portrait-img {
    width: clamp(180px, 52vh, 300px) !important;
  }

  .hero-intro-copy {
    font-size: clamp(0.6rem, 2vh, 0.82rem) !important;
    max-width: 320px !important;
    line-height: 1.4 !important;
  }

  .hero-nav {
    padding: 0.7rem 1.5rem !important;
    gap: 2rem !important;
  }

  .hero-nav-link {
    font-size: 0.78rem !important;
  }

  section.h-screen > div:last-child {
    padding-bottom: 1rem !important;
  }

  /* ── Marquee ── */
  .marquee-row-1 { gap: 1rem !important; }
  .marquee-row-2 { gap: 2rem !important; }

  /* ── Portrait animation ── */
  .hero-portrait-img {
    animation: heroPortraitFloat 4.5s ease-in-out infinite;
    transform-origin: bottom center;
  }

  /* ── About ── */
  .about-decoration { display: none !important; }

  /* ── Projects ── */
  .project-stack-section {
    --project-stack-top: clamp(2.5rem, 5vh, 3.5rem);
    --project-stack-gap: 14px;
    padding-top: 3rem !important;
    padding-bottom: 6rem !important;
  }

  .project-media-grid {
    flex-direction: row;
    gap: 0.65rem;
  }

  .project-side-column {
    display: flex;
    flex: 0 0 34%;
    flex-direction: column;
    gap: 0.65rem;
  }

  .project-description-card {
    flex: 1;
    min-height: 0;
    height: auto;
  }

  .project-main-wrap {
    flex: 1 1 0;
    min-width: 0;
    display: flex;
    align-items: stretch;
  }

  .project-main-wrap > div {
    flex: 1;
    aspect-ratio: auto !important;
    height: clamp(130px, 52vh, 220px);
  }

  .project-card-number { font-size: clamp(1.6rem, 5vw, 2rem) !important; }
  .project-card-title  { font-size: clamp(0.6rem, 1.5vw, 0.78rem) !important; }
  .project-card-category { font-size: clamp(0.38rem, 1vw, 0.5rem) !important; }
  .project-description-copy {
    font-size: clamp(0.6rem, 1.3vw, 0.74rem) !important;
    line-height: 1.4 !important;
  }
}
