:root {
  --black: #0a0a0a;
  --white: #ffffff;
  --grey: #6b6b6b;
  --grey-light: #ececec;
  --youtube: #ff0000;
  --facebook: #1877f2;
  --tiktok: #00f2ea;
  --radius-font: "Gluten", cursive;
  --body-font: "Prachamati", sans-serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--white);
  color: var(--black);
  font-family: var(--body-font);
  -webkit-font-smoothing: antialiased;
  padding-top: 100px;
  padding-bottom: 100px;
  transition: padding-top 0.3s ease;
}

body.header-scrolled {
  padding-top: 60px;
}

h1, h2, .tile-name, .tile-title {
  font-family: var(--radius-font);
}

a { text-decoration: none; color: inherit; }

/* ---------- Loading screen ---------- */
.loader {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: var(--black);
  animation: loaderFade 3s ease forwards;
}

@keyframes loaderFade {
  0%, 86.7% { opacity: 1; visibility: visible; }
  100% { opacity: 0; visibility: hidden; }
}

.loader-bg {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

.loader-blob {
  position: absolute;
  width: 380px;
  height: 380px;
  fill: rgba(255, 255, 255, 0.06);
  animation: blobDrift ease-in-out infinite;
}

.loader-blob-1 { top: -10%; left: -8%; animation-duration: 7s; }
.loader-blob-2 { bottom: -15%; right: -10%; width: 440px; height: 440px; animation-duration: 8.5s; animation-delay: -2s; }
.loader-blob-3 { top: 30%; right: 15%; width: 260px; height: 260px; animation-duration: 6s; animation-delay: -4s; }

@keyframes blobDrift {
  0%, 100% { transform: translate(0, 0) rotate(0deg); }
  50% { transform: translate(18px, -14px) rotate(8deg); }
}

.loader-content {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  padding: 1.5rem;
}

.loader-logo {
  width: 96px;
  height: 96px;
  object-fit: contain;
  background: var(--white);
  border-radius: 50%;
  animation: loaderPulse 1.4s ease-in-out infinite;
}

@keyframes loaderPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.06); }
}

.loader-text {
  font-family: var(--radius-font);
  color: var(--white);
  font-size: 1.4rem;
  margin: 0;
}

.loader-track {
  width: 260px;
  height: 81px;
}

.loader-supports {
  fill: none;
  stroke: rgba(255, 255, 255, 0.15);
  stroke-width: 2;
  stroke-dasharray: 3 4;
}

.loader-track-bg,
.loader-track-fill {
  fill: none;
  stroke-width: 4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.loader-track-bg {
  stroke: rgba(255, 255, 255, 0.2);
}

.loader-track-fill {
  stroke: var(--tiktok);
  stroke-dasharray: 100;
  stroke-dashoffset: 100;
  animation: trackFill 2.6s forwards;
}

@keyframes trackFill {
  0% { stroke-dashoffset: 100; animation-timing-function: linear; }
  45% { stroke-dashoffset: 85; animation-timing-function: ease-in; }
  100% { stroke-dashoffset: 0; }
}

.loader-cart {
  offset-path: path("M6,88 C20,88 30,20 50,15 C70,10 85,70 100,80 C115,90 125,40 145,35 C155,45 165,90 170,100 A20,20 0 1,0 170,60 A20,20 0 1,0 170,100 C190,100 205,60 245,42 C265,40 275,65 290,64 C300,63 305,55 316,58");
  offset-rotate: auto;
  offset-distance: 0%;
  animation: cartRide 2.6s forwards;
}

@keyframes cartRide {
  0% { offset-distance: 0%; animation-timing-function: linear; }
  45% { offset-distance: 15%; animation-timing-function: ease-in; }
  100% { offset-distance: 100%; }
}

.loader-cart-body {
  fill: var(--white);
  stroke: var(--black);
  stroke-width: 1.5;
}

.loader-cart-seat {
  fill: var(--tiktok);
  stroke: var(--black);
  stroke-width: 1.5;
}

.loader-cart-wheel {
  fill: var(--black);
}

@media (prefers-reduced-motion: reduce) {
  .loader {
    display: none;
  }
}

/* ---------- Fold (header + socials, sized to the viewport) ---------- */
/* Header (100px) and footer (~92px) are both fixed and reserved via body padding.
   This reserves the remaining space so the "Other Projects" heading and scroll cue
   peek in above the fixed footer at the bottom of the first screen. */
.fold {
  min-height: calc(100vh - 332px);
  display: flex;
  flex-direction: column;
}

/* ---------- Header ---------- */
.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 500;
  background: var(--black);
  color: var(--white);
  padding: 1.25rem 1.5rem 0.75rem;
  transition: padding 0.3s ease;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: center;
  max-width: 1100px;
  margin: 0 auto;
}

.logo {
  width: 68px;
  height: 68px;
  object-fit: contain;
  background: var(--white);
  border-radius: 50%;
  flex-shrink: 0;
  transition: width 0.3s ease, height 0.3s ease;
}

body.header-scrolled .site-header {
  padding: 0.6rem 1.5rem 0.4rem;
}

body.header-scrolled .logo {
  width: 44px;
  height: 44px;
}

/* ---------- Socials ---------- */
.socials-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 0.25rem 1.5rem 1.5rem;
}

.socials-title {
  text-align: center;
  font-size: clamp(1.6rem, 4vw, 2.4rem);
  margin: 0;
}

.total-followers {
  text-align: center;
  font-family: var(--radius-font);
  font-size: 1.1rem;
  color: var(--grey);
  margin: 0.3rem 0 1.5rem;
}

.total-followers span {
  color: var(--black);
  font-weight: 600;
}

.socials {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-auto-rows: 1fr;
  gap: 2rem;
  max-width: 1100px;
  width: 100%;
  margin: 0 auto;
}

.social-tile {
  position: relative;
  display: block;
  height: 100%;
  isolation: isolate;
  background: var(--black);
  border-radius: 24px;
  transition: background 0.35s ease, transform 0.35s ease;
}

.social-tile:hover,
.social-tile:focus-visible {
  transform: scale(1.02);
}

.social-tile.youtube:hover { background: var(--youtube); }
.social-tile.facebook:hover { background: var(--facebook); }
.social-tile.tiktok:hover { background: var(--tiktok); }

.blob-shape {
  position: absolute;
  inset: 0;
  z-index: -1;
}

.social-tile .blob-shape {
  display: none;
}

.tile-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  color: var(--white);
  padding: 1.5rem;
  text-align: center;
}

.social-tile .tile-content {
  height: 100%;
}

.icon-badge {
  width: 3.5rem;
  height: 3.5rem;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  transition: background 0.35s ease;
}

.social-tile:hover .icon-badge,
.social-tile:focus-visible .icon-badge {
  background: rgba(255, 255, 255, 0.85);
}

.social-tile.youtube:hover .icon-badge { color: var(--youtube); }
.social-tile.facebook:hover .icon-badge { color: var(--facebook); }
.social-tile.tiktok:hover .icon-badge { color: var(--black); }

.icon {
  width: 1.9rem;
  height: 1.9rem;
  flex-shrink: 0;
  fill: currentColor;
}

.tile-text {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  min-width: 0;
}

.tile-name {
  font-size: 1.75rem;
  font-weight: 600;
}

.tile-handle {
  font-size: 1rem;
  opacity: 0.8;
}

.tile-followers {
  font-size: 0.95rem;
  opacity: 0.75;
  margin-top: 0.2rem;
}

/* ---------- Projects ---------- */
.projects {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.25rem 1.5rem 5rem;
  text-align: center;
}

.projects-title {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  margin: 0 0 0.75rem;
  cursor: pointer;
}

.projects-title:focus-visible {
  outline: 2px solid var(--black);
  outline-offset: 4px;
}

.title-arrow {
  width: 1.4rem;
  height: 1.4rem;
  fill: currentColor;
  flex-shrink: 0;
  animation: bounce 2.4s ease-in-out infinite;
}

.title-arrow:last-child {
  animation-delay: 0.3s;
}

.section-sub {
  color: var(--grey);
  margin: 0;
}

.section-hint {
  color: var(--grey);
  font-size: 0.85rem;
  font-style: italic;
  margin: 0.35rem 0 2.5rem;
}

.project-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2rem;
}

.project-tile {
  position: relative;
  display: block;
  isolation: isolate;
}

.project-tile .blob-shape {
  border-radius: 35% 65% 55% 45% / 55% 45% 65% 35%;
  background: var(--grey-light);
  border: 2px solid var(--black);
}

.project-tile .tile-content {
  min-height: 260px;
  padding: 2.5rem 2.25rem;
}

.project-tile:hover .blob-shape,
.project-tile:focus-visible .blob-shape {
  border-radius: 55% 45% 35% 65% / 40% 55% 45% 60%;
  background: var(--black);
}

.project-tile .tile-content {
  color: var(--black);
  gap: 0.5rem;
}

.project-tile:hover .tile-content,
.project-tile:focus-visible .tile-content {
  color: var(--white);
}

.tile-image {
  width: 100%;
  max-width: 140px;
  aspect-ratio: 4 / 3;
  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: var(--white);
  border: 1px solid rgba(0, 0, 0, 0.15);
  padding: 0.75rem;
  transition: border-color 0.35s ease;
}

.tile-image img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.project-tile:hover .tile-image,
.project-tile:focus-visible .tile-image {
  border-color: rgba(255, 255, 255, 0.35);
}

.tile-title {
  font-size: 1.4rem;
  font-weight: 600;
}

.tile-desc {
  font-size: 0.95rem;
  line-height: 1.4;
}

.tile-info {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

/* ---------- Animations ---------- */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(28px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(6px); }
}

.logo,
.socials-title,
.total-followers,
.social-tile {
  opacity: 0;
  animation: fadeInUp 1.2s ease forwards;
}

.logo { animation-delay: 0.05s; }
.socials-title { animation-delay: 0.3s; }
.total-followers { animation-delay: 0.45s; }
.social-tile:nth-child(1) { animation-delay: 0.6s; }
.social-tile:nth-child(2) { animation-delay: 0.8s; }
.social-tile:nth-child(3) { animation-delay: 1s; }

.reveal {
  opacity: 0;
  transform: translateY(32px);
  transition: opacity 1.1s ease, transform 1.1s ease;
}

.reveal.in-view {
  opacity: 1;
  transform: translateY(0);
}

.project-grid .reveal:nth-child(1) { transition-delay: 0s; }
.project-grid .reveal:nth-child(2) { transition-delay: 0.2s; }
.project-grid .reveal:nth-child(3) { transition-delay: 0.4s; }

@media (prefers-reduced-motion: reduce) {
  .logo,
  .socials-title,
  .total-followers,
  .social-tile,
  .reveal {
    animation: none;
    transition: none;
    opacity: 1;
    transform: none;
  }

  .title-arrow {
    animation: none;
  }
}

/* ---------- Buy Me a Coffee floating tab ---------- */
.coffee-tab {
  position: fixed;
  top: 50%;
  right: 0;
  z-index: 400;
  transform: translateY(-50%);
  background: #ffdd00;
  color: var(--black);
  padding: 0.9rem 0.55rem;
  border-radius: 10px 0 0 10px;
  writing-mode: vertical-rl;
  text-orientation: mixed;
  font-family: var(--radius-font);
  font-weight: 600;
  font-size: 1rem;
  letter-spacing: 0.5px;
  box-shadow: -2px 2px 10px rgba(0, 0, 0, 0.25);
  transition: transform 0.25s ease;
}

.coffee-tab:hover,
.coffee-tab:focus-visible {
  transform: translateY(-50%) translateX(-4px);
}

/* ---------- Footer ---------- */
footer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 500;
  background: var(--black);
  color: #cfcfcf;
  text-align: center;
  padding: 1.5rem;
  font-size: 0.85rem;
}

/* ---------- Mobile ---------- */
@media (max-width: 760px) {
  body {
    padding-top: 120px;
  }

  body.header-scrolled {
    padding-top: 68px;
  }

  .fold {
    min-height: calc(100vh - 352px);
  }

  /* Header: logo on top, centered */
  .site-header {
    padding: 1.5rem 1.25rem;
  }

  .logo {
    width: 72px;
    height: 72px;
  }

  body.header-scrolled .site-header {
    padding: 0.6rem 1.25rem 0.4rem;
  }

  body.header-scrolled .logo {
    width: 48px;
    height: 48px;
  }

  /* Social cards: horizontal bars, icon | username | followers */
  .socials-section {
    padding: 0.5rem 1.25rem 2.5rem;
  }

  .socials {
    grid-template-columns: 1fr;
    grid-auto-rows: auto;
    flex: none;
    gap: 0.9rem;
  }

  .social-tile {
    height: auto;
    aspect-ratio: auto;
    max-width: none;
    width: 100%;
    margin: 0;
  }

  .social-tile .blob-shape {
    display: none;
  }

  .social-tile .tile-content {
    position: static;
    flex-direction: row;
    justify-content: flex-start;
    text-align: left;
    gap: 0.9rem;
    background: var(--black);
    border-radius: 18px;
    padding: 0.9rem 1.1rem;
  }

  .tile-name {
    display: none;
  }

  .tile-text {
    align-items: flex-start;
    min-width: 0;
    flex: 1;
    gap: 0;
  }

  .tile-handle {
    font-size: 1rem;
    font-weight: 600;
    opacity: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
  }

  .tile-followers {
    display: block;
    flex-shrink: 0;
    margin-left: auto;
    padding-left: 0.5rem;
    font-size: 0.85rem;
    opacity: 0.75;
  }

  .icon-badge {
    width: 3rem;
    height: 3rem;
  }

  .icon {
    width: 1.65rem;
    height: 1.65rem;
  }

  /* Project cards: name + description left, logo on the right */
  .projects {
    padding: 1.5rem 1.25rem 3rem;
  }

  .project-grid {
    grid-template-columns: 1fr;
    gap: 0.9rem;
  }

  .project-tile .blob-shape {
    display: none;
  }

  .project-tile .tile-content {
    flex-direction: row;
    align-items: center;
    text-align: left;
    gap: 1rem;
    min-height: auto;
    background: var(--grey-light);
    border: 1px solid rgba(0, 0, 0, 0.15);
    border-radius: 18px;
    padding: 1rem 1.1rem;
  }

  .project-tile .tile-image {
    order: 2;
    margin-left: auto;
    width: 64px;
    max-width: 64px;
    aspect-ratio: 1 / 1;
    flex-shrink: 0;
  }

  .project-tile .tile-info {
    order: 1;
    align-items: flex-start;
    text-align: left;
    gap: 0.25rem;
    flex: 1;
    min-width: 0;
  }

  .project-tile .tile-title {
    font-size: 1.1rem;
  }

  .project-tile .tile-desc {
    font-size: 0.85rem;
  }
}
