/* ==========================================
   BASE
   ========================================== */
:root {
  --bg: #0C0C0C;
  --bg-elev: #1A1A1A;
  --bg-modal: #121212;
  --text: #D7E2EA;
  --accent: #B600A8;
  --radius-xl: 40px;
}

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

html, body {
  background-color: var(--bg);
  margin: 0;
  padding: 0;
  font-family: 'Kanit', sans-serif;
}

body {
  min-height: 100vh;
  color: var(--text);
  overflow-x: clip;
  -webkit-font-smoothing: antialiased;
}

::selection { background: var(--accent); color: #fff; }

button { font-family: inherit; background: none; border: 0; color: inherit; cursor: pointer; padding: 0; }
a { color: inherit; }
img { display: block; max-width: 100%; }

.accent { color: var(--accent); }

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

.section-title {
  font-size: clamp(3rem, 12vw, 160px);
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: -0.025em;
  line-height: 1;
  margin: 0;
}

/* ==========================================
   FADE-IN (replaces framer-motion whileInView)
   ========================================== */
.fade-in {
  opacity: 0;
  transform: translate3d(var(--fx, 0px), var(--fy, 30px), 0);
  transition-property: opacity, transform;
  transition-duration: var(--fd, 0.7s);
  transition-delay: var(--fdl, 0s);
  transition-timing-function: cubic-bezier(0.25, 0.1, 0.25, 1);
  will-change: opacity, transform;
}
.fade-in.is-visible {
  opacity: 1;
  transform: translate3d(0, 0, 0);
}

/* ==========================================
   BUTTONS
   ========================================== */
.contact-btn {
  background: linear-gradient(123deg, #18011F 7%, #B600A8 37%, #7621B0 72%, #BE4C00 100%);
  box-shadow: 0px 4px 4px rgba(181, 1, 167, 0.25), inset 4px 4px 12px #7721B1;
  outline: 2px solid white;
  outline-offset: -3px;
  border-radius: 9999px;
  color: #fff;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: 0.75rem 2rem;
  font-size: 0.75rem;
  line-height: 1rem;
  transition: transform 0.15s ease;
}
.contact-btn:hover { transform: scale(1.05); }
.contact-btn:active { transform: scale(0.95); }
.contact-btn-full {
  width: 100%;
  padding-top: 1rem;
  padding-bottom: 1rem;
  display: flex;
  justify-content: center;
  text-align: center;
}

.live-btn {
  border-radius: 9999px;
  border: 2px solid var(--text);
  color: var(--text);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: 0.75rem 2rem;
  font-size: 0.875rem;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  transition: background-color 0.2s ease;
  white-space: nowrap;
}
.live-btn:hover { background-color: rgba(215, 226, 234, 0.1); }
.live-btn svg { width: 1rem; height: 1rem; }

/* ==========================================
   HERO
   ========================================== */
.hero {
  height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow-x: clip;
  padding: 1.5rem 1.5rem 1.75rem;
}

.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  z-index: 20;
}

.logo {
  font-size: 1.125rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  cursor: pointer;
}

.nav-links {
  display: none;
  align-items: center;
  gap: 2.5rem;
  font-size: 0.875rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.nav-links .nav-link { transition: opacity 0.2s ease; }
.nav-links .nav-link:hover { opacity: 0.75; }

.menu-toggle {
  display: inline-flex;
  padding: 0.5rem;
  color: var(--text);
}
.menu-toggle .icon-close { display: none; }
.menu-toggle.is-open .icon-menu { display: none; }
.menu-toggle.is-open .icon-close { display: block; }

.mobile-menu {
  position: absolute;
  top: 5rem;
  left: 0;
  width: 100%;
  background: rgba(12, 12, 12, 0.95);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-bottom: 1px solid rgba(215, 226, 234, 0.1);
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 2rem 0;
  gap: 1.5rem;
  opacity: 0;
  transform: translateY(-20px);
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
}
.mobile-menu.is-open {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}
.mobile-menu .nav-link {
  font-size: 1.25rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  transition: color 0.2s ease;
}
.mobile-menu .nav-link:hover { color: var(--accent); }

.hero-portrait {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 30;
  width: 280px;
  pointer-events: none;
  /* fade-in transform is combined with centering via the wrapper below */
}
.hero-portrait.fade-in {
  transform: translate3d(calc(-50% + var(--fx, 0px)), calc(-50% + var(--fy, 30px)), 0);
}
.hero-portrait.fade-in.is-visible {
  transform: translate3d(-50%, -50%, 0);
}

.magnet {
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  pointer-events: auto;
  will-change: transform;
}
.magnet img {
  width: 100%;
  height: auto;
  object-fit: contain;
  user-select: none;
  -webkit-user-drag: none;
  filter: drop-shadow(0 25px 25px rgba(0, 0, 0, 0.15));
}

.hero-heading-wrap {
  width: 100%;
  overflow: hidden;
  margin-top: 1.5rem;
  z-index: 20;
}
.hero-title {
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: -0.025em;
  line-height: 1;
  white-space: nowrap;
  width: 100%;
  text-align: center;
  font-size: 14vw; /* fallback; script.js fits this to the container width */
  margin: 0;
  display: block;
}
.hero-title.is-fitted { letter-spacing: -0.025em; }

.hero-bottom {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  width: 100%;
  z-index: 20;
}
.hero-tagline {
  font-weight: 300;
  text-transform: uppercase;
  letter-spacing: 0.025em;
  line-height: 1.375;
  font-size: clamp(0.75rem, 1.4vw, 1.5rem);
  max-width: 160px;
  margin: 0;
}

/* ==========================================
   MARQUEE
   ========================================== */
.marquee {
  padding: 6rem 0 2.5rem;
  overflow: hidden;
  background: var(--bg);
}
.marquee-rows { display: flex; flex-direction: column; gap: 0.75rem; }
.marquee-row { display: flex; gap: 0.75rem; overflow: hidden; will-change: transform; }
.marquee-track {
  display: flex;
  gap: 0.75rem;
  flex-shrink: 0;
  will-change: transform;
  transition: transform 0.1s linear;
}
.marquee-track img {
  width: 420px;
  height: 270px;
  border-radius: 1rem;
  object-fit: cover;
  flex-shrink: 0;
  user-select: none;
  background: var(--bg-elev);
}

/* ==========================================
   ABOUT
   ========================================== */
.about {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  padding: 5rem 1.25rem;
  overflow: hidden;
}

.deco { position: absolute; pointer-events: none; z-index: 0; }
.deco img { height: auto; object-fit: contain; user-select: none; }
.deco-tl { top: 4%; left: 1%; }
.deco-bl { bottom: 8%; left: 3%; }
.deco-tr { top: 4%; right: 1%; }
.deco-br { bottom: 8%; right: 3%; }
.deco-tl img, .deco-tr img { width: 120px; }
.deco-bl img { width: 100px; }
.deco-br img { width: 130px; }

.about-content {
  position: relative;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  max-width: 56rem;
  margin: 0 auto;
}
.about-title { margin-bottom: 2.5rem; }
.about-text-wrap { margin-bottom: 4rem; }

.animated-text {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  font-weight: 500;
  line-height: 1.625;
  max-width: 560px;
  font-size: clamp(1rem, 2vw, 1.35rem);
  margin: 0;
}
.animated-text .word {
  display: inline-block;
  white-space: nowrap;
  margin-right: 0.3em;
  margin-bottom: 0.2em;
}
.animated-text .char { display: inline-block; opacity: 0.2; }

/* ==========================================
   TECH STACK
   ========================================== */
.tech {
  background: var(--bg);
  padding: 5rem 0 6rem;
  position: relative;
  overflow: hidden;
  --cc-card-bg: rgba(14, 14, 14, 0.82);
  --cc-card-border: rgba(215, 226, 234, 0.16);
  --cc-text: var(--text);
  --cc-text-muted: rgba(215, 226, 234, 0.55);
}
.tech-header { max-width: 72rem; margin: 0 auto 2rem; padding: 0 1.25rem; text-align: center; }
.tech-stage {
  position: relative;
  width: min(92vw, 1100px);
  margin: 0 auto;
  isolation: isolate;
}
/* Backdrop sits in normal flow and defines the stage height */
.tech-backdrop { position: relative; width: 100%; z-index: 0; pointer-events: none; }
.tech-backdrop img { width: 100%; height: auto; object-fit: contain; user-select: none; -webkit-user-drag: none; }
/* Ring is centered on the monitor screens: monitors occupy roughly the top 68% of the image,
   so a 68%-tall carousel anchored to the top puts the ring's center at ~34% down. Keyboard/mouse stay clear. */
.tech-carousel {
  position: absolute;
  left: 50%;
  top: 0;
  width: 100vw;
  max-width: 100vw;
  height: 68%;
  transform: translateX(-50%);
  z-index: 1;
}
.tech .cc-title { font-family: 'Kanit', sans-serif; font-weight: 700; text-transform: uppercase; letter-spacing: 0.02em; }
.tech .cc-subtitle { font-family: 'Kanit', sans-serif; font-weight: 400; }
.tech .cc-card { backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
/* fade the ring edges into the background */
.tech::before, .tech::after {
  content: ""; position: absolute; top: 0; bottom: 0; width: 12%; z-index: 2; pointer-events: none;
}
.tech::before { left: 0; background: linear-gradient(90deg, var(--bg), transparent); }
.tech::after { right: 0; background: linear-gradient(270deg, var(--bg), transparent); }

/* ==========================================
   SERVICES
   ========================================== */
.services {
  background: #fff;
  color: var(--bg);
  border-top-left-radius: var(--radius-xl);
  border-top-right-radius: var(--radius-xl);
  padding: 5rem 1.25rem;
  position: relative;
  z-index: 10;
}
.services-inner { max-width: 64rem; margin: 0 auto; }
.services-title { text-align: center; margin-bottom: 4rem; color: var(--bg); }
.services-list { display: flex; flex-direction: column; }

.service {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  padding: 2rem 0;
  border-bottom: 1px solid rgba(12, 12, 12, 0.15);
  gap: 1.5rem;
}
.service-body { display: flex; flex-direction: column; gap: 0.75rem; flex: 1; min-width: 0; }
.service-num {
  font-size: clamp(3rem, 10vw, 140px);
  font-weight: 900;
  line-height: 1;
  color: var(--bg);
  flex-shrink: 0;
  min-width: 1.4em;
}
.service-title {
  font-size: clamp(1.1rem, 2.2vw, 2.1rem);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: -0.025em;
  color: var(--bg);
  margin: 0;
}
.service-desc {
  font-size: clamp(0.85rem, 1.6vw, 1.25rem);
  font-weight: 300;
  line-height: 1.625;
  max-width: 42rem;
  opacity: 0.6;
  color: var(--bg);
  margin: 0;
}

/* ==========================================
   PROJECTS
   ========================================== */
.projects {
  background: var(--bg);
  border-top-left-radius: var(--radius-xl);
  border-top-right-radius: var(--radius-xl);
  margin-top: -2.5rem;
  padding: 5rem 1.25rem 8rem;
  position: relative;
  z-index: 20;
}
.projects-header { max-width: 72rem; margin: 0 auto 4rem; text-align: center; }
.projects-stack {
  max-width: 64rem;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 3rem;
}

.project-card {
  position: sticky;
  height: 85vh;
  display: flex;
  flex-direction: column;
  border-radius: var(--radius-xl);
  border: 2px solid var(--text);
  background: var(--bg);
  padding: 1rem;
  overflow-y: auto;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  transform: scale(0.85);
  will-change: transform;
  scrollbar-width: none;      /* Firefox */
  -ms-overflow-style: none;   /* old Edge/IE */
}
.project-card::-webkit-scrollbar { display: none; width: 0; height: 0; } /* Chrome, Safari, Edge */

.project-top {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid rgba(215, 226, 234, 0.15);
  flex-shrink: 0;
}
.project-meta { display: flex; align-items: center; gap: 1rem; }
.project-id { font-size: 2.25rem; font-weight: 900; line-height: 1; }
.project-category {
  display: block;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent);
  font-weight: 700;
  margin-bottom: 0.25rem;
}
.project-name {
  font-size: 1.25rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: -0.025em;
  margin: 0;
}

.project-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  flex-grow: 1;
  padding-bottom: 1rem;
}
.project-col-left { display: flex; flex-direction: column; gap: 1rem; }
.project-col-right { display: flex; flex-direction: column; height: 100%; }

.img-frame {
  width: 100%;
  border-radius: var(--radius-xl);
  overflow: hidden;
  background: var(--bg-elev);
  border: 1px solid rgba(215, 226, 234, 0.1);
  flex-shrink: 0;
}
.img-frame-a { height: clamp(130px, 16vw, 230px); }
.img-frame-b { height: clamp(160px, 22vw, 340px); }
.img-frame-c { height: 100%; min-height: 240px; }
.img-frame img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.5s ease;
}
.img-frame img:hover { transform: scale(1.05); }

/* ==========================================
   FOOTER
   ========================================== */
.footer {
  background: var(--bg);
  border-top: 1px solid rgba(215, 226, 234, 0.1);
  padding: 3rem 1.5rem;
  text-align: center;
}
.footer-inner {
  max-width: 72rem;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
}
.footer-logo { font-size: 1.25rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; }
.footer-copy { font-size: 0.875rem; color: rgba(215, 226, 234, 0.6); text-transform: uppercase; letter-spacing: 0.1em; margin: 0; }
.footer-social { display: flex; align-items: center; gap: 1.5rem; }
.footer-social a { display: inline-flex; transition: color 0.2s ease; }
.footer-social a:hover { color: var(--accent); }

/* ==========================================
   CONTACT MODAL
   ========================================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}
.modal-overlay.is-open { opacity: 1; pointer-events: auto; }

.modal {
  background: var(--bg-modal);
  border: 2px solid rgba(215, 226, 234, 0.2);
  border-radius: 30px;
  padding: 1.5rem;
  max-width: 32rem;
  width: 100%;
  position: relative;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  transform: scale(0.9) translateY(20px);
  transition: transform 0.25s ease;
}
.modal-overlay.is-open .modal { transform: scale(1) translateY(0); }

.modal-close {
  position: absolute;
  top: 1.5rem;
  right: 1.5rem;
  padding: 0.5rem;
  border-radius: 9999px;
  background: var(--bg-elev);
  color: var(--text);
  display: inline-flex;
  transition: color 0.2s ease;
}
.modal-close:hover { color: #fff; }

.modal-title {
  font-size: 1.5rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: -0.025em;
  margin: 0 0 0.5rem;
}
.modal-desc { font-size: 0.875rem; color: rgba(215, 226, 234, 0.7); margin: 0 0 1.5rem; font-weight: 300; }

.modal-form { display: flex; flex-direction: column; gap: 1rem; }
.modal-form label {
  display: block;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: rgba(215, 226, 234, 0.6);
  margin-bottom: 0.25rem;
}
.modal-form input,
.modal-form textarea {
  width: 100%;
  background: var(--bg-elev);
  border: 1px solid rgba(215, 226, 234, 0.2);
  border-radius: 0.75rem;
  padding: 0.75rem 1rem;
  color: var(--text);
  font-family: inherit;
  font-size: 0.875rem;
  transition: border-color 0.2s ease;
}
.modal-form textarea { resize: none; }
.modal-form input:focus,
.modal-form textarea:focus { outline: none; border-color: var(--accent); }
.modal-submit { margin-top: 0.5rem; }
.hp-field { position: absolute; left: -10000px; top: auto; width: 1px; height: 1px; overflow: hidden; }
.form-status { min-height: 1.25rem; margin: 0; font-size: 0.875rem; font-weight: 400; line-height: 1.4; }
.form-status.is-error { color: #FF7A7A; }
.form-status.is-success { color: #7EE2A8; }
.modal-form.is-sending .contact-btn { opacity: 0.7; pointer-events: none; }
.modal-form input.is-invalid, .modal-form textarea.is-invalid { border-color: #FF7A7A; }

/* ==========================================
   RESPONSIVE: sm (640px)
   ========================================== */
@media (min-width: 640px) {
  .contact-btn { padding: 0.875rem 2.5rem; font-size: 0.875rem; line-height: 1.25rem; }
  .live-btn { padding: 0.875rem 2.5rem; font-size: 1rem; }
  .hero { padding-bottom: 2rem; }
  .hero-portrait { width: 360px; top: auto; bottom: 0; }
  .hero-portrait.fade-in { transform: translate3d(calc(-50% + var(--fx, 0px)), var(--fy, 30px), 0); }
  .hero-portrait.fade-in.is-visible { transform: translate3d(-50%, 0, 0); }
  .hero-heading-wrap { margin-top: 1rem; }
  .hero-tagline { max-width: 220px; }
  .marquee { padding-top: 8rem; }
  .about { padding-left: 2rem; padding-right: 2rem; }
  .deco-tl { left: 2%; } .deco-tr { right: 2%; }
  .deco-bl { left: 6%; } .deco-br { right: 6%; }
  .deco-tl img, .deco-tr img { width: 160px; }
  .deco-bl img { width: 140px; }
  .deco-br img { width: 170px; }
  .about-title { margin-bottom: 3.5rem; }
  .about-text-wrap { margin-bottom: 5rem; }
  .tech { padding: 6rem 0 7rem; }
  .tech-header { margin-bottom: 3rem; }
  .services { border-top-left-radius: 50px; border-top-right-radius: 50px; padding: 6rem 2rem; }
  .services-title { margin-bottom: 5rem; }
  .service { padding: 2.5rem 0; }
  .projects { border-top-left-radius: 50px; border-top-right-radius: 50px; margin-top: -3rem; padding-left: 2rem; padding-right: 2rem; }
  .projects-header { margin-bottom: 5rem; }
  .project-card { border-radius: 50px; padding: 1.5rem; }
  .project-top { flex-direction: row; align-items: center; margin-bottom: 2rem; }
  .project-meta { gap: 1.5rem; }
  .project-id { font-size: 3rem; }
  .project-name { font-size: 1.5rem; }
  .img-frame { border-radius: 50px; }
  .img-frame-c { min-height: 320px; }
  .modal { padding: 2.5rem; }
  .modal-title { font-size: 1.875rem; }
}

/* ==========================================
   RESPONSIVE: md (768px)
   ========================================== */
@media (min-width: 768px) {
  .contact-btn { padding: 1rem 3rem; font-size: 1rem; line-height: 1.5rem; }
  .hero { padding: 2rem 2.5rem 2.5rem; }
  .logo { font-size: 1.25rem; }
  .nav-links { display: flex; font-size: 1.4rem; }
  .menu-toggle { display: none; }
  .mobile-menu { display: none; }
  .hero-portrait { width: 440px; }
  .hero-heading-wrap { margin-top: -1.25rem; }
  .hero-tagline { max-width: 260px; }
  .marquee { padding-top: 10rem; }
  .about { padding-left: 2.5rem; padding-right: 2.5rem; }
  .deco-tl { left: 4%; } .deco-tr { right: 4%; }
  .deco-bl { left: 10%; } .deco-br { right: 10%; }
  .deco-tl img, .deco-tr img { width: 210px; }
  .deco-bl img { width: 180px; }
  .deco-br img { width: 220px; }
  .about-title { margin-bottom: 4rem; }
  .about-text-wrap { margin-bottom: 6rem; }
  .tech { padding: 8rem 0 8rem; }
  .tech-header { margin-bottom: 4rem; }
  .services { border-top-left-radius: 60px; border-top-right-radius: 60px; padding: 8rem 2.5rem; }
  .services-title { margin-bottom: 7rem; }
  .service { padding: 3rem 0; gap: 3rem; }
  .projects { border-top-left-radius: 60px; border-top-right-radius: 60px; margin-top: -3.5rem; padding-left: 2.5rem; padding-right: 2.5rem; }
  .projects-header { margin-bottom: 7rem; }
  .project-card { border-radius: 60px; padding: 2rem; }
  .project-id { font-size: 3.75rem; }
  .project-name { font-size: 1.875rem; }
  .project-grid { grid-template-columns: repeat(10, minmax(0, 1fr)); }
  .project-col-left { grid-column: span 4 / span 4; }
  .project-col-right { grid-column: span 6 / span 6; }
  .img-frame { border-radius: 60px; }
  .footer { padding-left: 2.5rem; padding-right: 2.5rem; }
  .footer-inner { flex-direction: row; }
}

/* ==========================================
   RESPONSIVE: lg (1024px)
   ========================================== */
@media (min-width: 1024px) {
  .hero-portrait { width: 520px; }
}

/* ==========================================
   REDUCED MOTION
   ========================================== */
@media (prefers-reduced-motion: reduce) {
  .fade-in { opacity: 1; transform: none; transition: none; }
  .hero-portrait.fade-in { transform: translate3d(-50%, -50%, 0); }
  .marquee-track { transition: none; }
  .animated-text .char { opacity: 1; }
}
@media (prefers-reduced-motion: reduce) and (min-width: 640px) {
  .hero-portrait.fade-in { transform: translate3d(-50%, 0, 0); }
}
