/* =============================================================
   Samit Thippawan — Portfolio
   Dark-only, glassmorphism, blue gradient accent.
   Mobile first → progressively enhanced at larger breakpoints.
   -------------------------------------------------------------
   TABLE OF CONTENTS
   01. Design tokens (CSS variables)
   02. Reset & base
   03. Utilities & shared components (buttons, glass, cards)
   04. Animation primitives (Intersection Observer targets)
   05. Decorative background & cursor glow
   06. Loader / scroll progress
   07. Navbar
   08. Hero
   09. About
   10. Skills
   11. Projects
   12. Timeline
   13. Contact
   14. Footer & back-to-top
   15. Responsive breakpoints
   16. Reduced motion / print
============================================================= */


/* =============================================================
   01. DESIGN TOKENS
============================================================= */
:root {
  /* ---- Color ---- */
  --bg:              #0f172a;          /* base canvas  */
  --bg-alt:          #0b1120;          /* alternating section */
  --surface:         rgba(255, 255, 255, 0.045);
  --surface-strong:  rgba(255, 255, 255, 0.075);
  --border:          rgba(255, 255, 255, 0.10);
  --border-strong:   rgba(255, 255, 255, 0.18);

  --text:            #e2e8f0;
  --text-muted:      #94a3b8;
  --text-dim:        #64748b;
  --heading:         #f8fafc;

  --accent:          #3b82f6;
  --accent-2:        #06b6d4;
  --accent-soft:     rgba(59, 130, 246, 0.16);
  --gradient:        linear-gradient(135deg, #3b82f6 0%, #06b6d4 100%);
  --gradient-soft:   linear-gradient(135deg, rgba(59,130,246,.22), rgba(6,182,212,.22));

  /* ---- Elevation & glow ---- */
  --shadow-sm:  0 2px 10px rgba(0, 0, 0, .25);
  --shadow-md:  0 12px 32px rgba(0, 0, 0, .35);
  --shadow-lg:  0 24px 60px rgba(0, 0, 0, .45);
  --glow:       0 0 0 1px rgba(59,130,246,.35), 0 14px 40px rgba(59,130,246,.22);

  /* ---- Radius ---- */
  --r-sm: 10px;
  --r-md: 16px;
  --r-lg: 22px;
  --r-full: 999px;

  /* ---- Spacing scale ---- */
  --sp-1: .25rem;
  --sp-2: .5rem;
  --sp-3: .75rem;
  --sp-4: 1rem;
  --sp-5: 1.5rem;
  --sp-6: 2rem;
  --sp-7: 3rem;
  --sp-8: 4rem;
  --sp-9: 6rem;

  /* ---- Layout ---- */
  --container: 1180px;
  --gutter: 1.25rem;
  --nav-h: 68px;

  /* ---- Motion ---- */
  --ease: cubic-bezier(.22, 1, .36, 1);
  --t-fast: .18s;
  --t-mid: .35s;
  --t-slow: .6s;

  /* ---- Type ---- */
  --font: 'IBM Plex Sans Thai', system-ui, -apple-system, 'Segoe UI', sans-serif;
}


/* =============================================================
   02. RESET & BASE
============================================================= */
*, *::before, *::after { box-sizing: border-box; }

* { margin: 0; padding: 0; }

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--nav-h) + 12px);
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font);
  font-weight: 400;
  font-size: 1rem;
  line-height: 1.75;        /* สระบน/ล่างของไทยต้องการที่หายใจมากกว่าละติน */
  color: var(--text);
  background-color: var(--bg);
  overflow-x: hidden;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body.is-locked { overflow: hidden; }

h1, h2, h3, h4 {
  color: var(--heading);
  font-weight: 700;
  line-height: 1.35;        /* เผื่อวรรณยุกต์ไม่ให้ชนบรรทัดถัดไป */
  letter-spacing: -.02em;
}

a { color: inherit; text-decoration: none; transition: color var(--t-fast) var(--ease); }
a:hover { color: var(--accent-2); }

img { max-width: 100%; display: block; height: auto; }
ul, ol { list-style: none; }
button { font: inherit; cursor: pointer; border: 0; background: none; color: inherit; }
input, textarea { font: inherit; color: inherit; }

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

/* Focus visibility — never remove without a replacement */
:focus-visible {
  outline: 2px solid var(--accent-2);
  outline-offset: 3px;
  border-radius: 4px;
}

/* Custom scrollbar (progressive enhancement) */
::-webkit-scrollbar { width: 10px; }
::-webkit-scrollbar-track { background: var(--bg-alt); }
::-webkit-scrollbar-thumb { background: #1e293b; border-radius: var(--r-full); }
::-webkit-scrollbar-thumb:hover { background: #334155; }

/* Screen-reader only */
.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.skip-link {
  position: absolute; top: -60px; left: 1rem; z-index: 1000;
  background: var(--accent); color: #fff;
  padding: .6rem 1rem; border-radius: var(--r-sm);
  transition: top var(--t-mid) var(--ease);
}
.skip-link:focus { top: 1rem; color: #fff; }


/* =============================================================
   03. UTILITIES & SHARED COMPONENTS
============================================================= */
.container {
  width: 100%;
  max-width: var(--container);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.section {
  position: relative;
  padding-block: var(--sp-8);
}
.section--alt { background: var(--bg-alt); }

.section__head {
  text-align: center;
  max-width: 640px;
  margin: 0 auto var(--sp-7);
}
.section__kicker {
  display: inline-block;
  font-size: .78rem;
  font-weight: 600;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--accent-2);
  margin-bottom: var(--sp-2);
}
.section__title {
  font-size: clamp(1.9rem, 6vw, 2.75rem);
  margin-bottom: var(--sp-3);
}
.section__sub {
  color: var(--text-muted);
  font-size: .97rem;
}

.gradient-text {
  background: var(--gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  background-size: 200% 200%;
  animation: gradientShift 6s ease infinite;
}
@keyframes gradientShift {
  0%, 100% { background-position: 0% 50%; }
  50%      { background-position: 100% 50%; }
}

/* ---- Glassmorphism ---- */
.glass {
  background: var(--surface);
  border: 1px solid var(--border);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  backdrop-filter: blur(14px) saturate(140%);
}

.card {
  border-radius: var(--r-lg);
  padding: var(--sp-5);
  transition: transform var(--t-mid) var(--ease),
              border-color var(--t-mid) var(--ease),
              box-shadow var(--t-mid) var(--ease),
              background var(--t-mid) var(--ease);
}
.card:hover {
  transform: translateY(-6px);
  border-color: var(--border-strong);
  background: var(--surface-strong);
  box-shadow: var(--shadow-md);
}

/* ---- Buttons ---- */
.btn {
  position: relative;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .55rem;
  padding: .8rem 1.5rem;
  border-radius: var(--r-full);
  font-size: .92rem;
  font-weight: 600;
  letter-spacing: .01em;
  white-space: nowrap;
  isolation: isolate;
  transition: transform var(--t-fast) var(--ease),
              box-shadow var(--t-mid) var(--ease),
              background var(--t-mid) var(--ease),
              border-color var(--t-mid) var(--ease),
              color var(--t-mid) var(--ease);
}
.btn:active { transform: scale(.97); }

.btn--primary {
  background: var(--gradient);
  color: #fff;
  box-shadow: 0 8px 24px rgba(59, 130, 246, .28);
}
.btn--primary:hover {
  color: #fff;
  transform: translateY(-3px);
  box-shadow: 0 14px 34px rgba(6, 182, 212, .40);
}

.btn--ghost {
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
}
.btn--ghost:hover {
  color: #fff;
  border-color: var(--accent);
  background: var(--accent-soft);
  transform: translateY(-3px);
  box-shadow: var(--glow);
}

.btn--sm { padding: .58rem 1.05rem; font-size: .82rem; }
.btn--block { width: 100%; }

/* Ripple (JS injects .ripple__wave) */
.ripple__wave {
  position: absolute;
  border-radius: 50%;
  transform: scale(0);
  background: rgba(255, 255, 255, .45);
  pointer-events: none;
  animation: rippleOut .6s linear forwards;
  z-index: -1;
}
@keyframes rippleOut {
  to { transform: scale(4); opacity: 0; }
}


/* =============================================================
   04. ANIMATION PRIMITIVES
   Elements marked [data-animate] start hidden and are revealed
   by the IntersectionObserver in script.js (adds .is-visible).
============================================================= */
[data-animate] {
  opacity: 0;
  transition: opacity .7s var(--ease), transform .7s var(--ease);
  will-change: opacity, transform;
}
[data-animate="fade-up"]    { transform: translateY(38px); }
[data-animate="fade-right"] { transform: translateX(-38px); }
[data-animate="fade-left"]  { transform: translateX(38px); }
[data-animate="zoom"]       { transform: scale(.92); }

[data-animate].is-visible {
  opacity: 1;
  transform: none;
}

/* If JS is unavailable, show everything */
.no-js [data-animate] { opacity: 1; transform: none; }


/* =============================================================
   05. DECORATIVE BACKGROUND & CURSOR GLOW
============================================================= */
.bg-decor {
  position: fixed;
  inset: 0;
  z-index: -2;
  pointer-events: none;
  overflow: hidden;
}

.bg-grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(148, 163, 184, .045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(148, 163, 184, .045) 1px, transparent 1px);
  background-size: 60px 60px;
  mask-image: radial-gradient(ellipse 80% 60% at 50% 0%, #000 30%, transparent 75%);
  -webkit-mask-image: radial-gradient(ellipse 80% 60% at 50% 0%, #000 30%, transparent 75%);
}

.shape {
  position: absolute;
  border-radius: 50%;
  filter: blur(90px);
  opacity: .30;
  animation: float 18s ease-in-out infinite;
}
.shape--1 { width: 320px; height: 320px; background: #3b82f6; top: -80px;  left: -90px; }
.shape--2 { width: 260px; height: 260px; background: #06b6d4; top: 38%;    right: -100px; animation-delay: -4s; }
.shape--3 { width: 300px; height: 300px; background: #2563eb; bottom: 6%;  left: -110px;  animation-delay: -9s; }
.shape--4 { width: 200px; height: 200px; background: #0891b2; top: 66%;    left: 46%;     animation-delay: -13s; opacity: .18; }

@keyframes float {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33%      { transform: translate(28px, -34px) scale(1.08); }
  66%      { transform: translate(-24px, 22px) scale(.94); }
}

/* Cursor glow — only enabled on fine pointers via JS + media query */
.cursor-glow {
  position: fixed;
  top: 0; left: 0;
  width: 380px; height: 380px;
  margin: -190px 0 0 -190px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(59,130,246,.14) 0%, transparent 65%);
  pointer-events: none;
  z-index: -1;
  opacity: 0;
  transition: opacity .4s ease;
  will-change: transform;
}
@media (pointer: fine) {
  .cursor-glow.is-on { opacity: 1; }
}


/* =============================================================
   06. LOADER / SCROLL PROGRESS
============================================================= */
.loader {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: var(--sp-4);
  background: var(--bg);
  transition: opacity .6s var(--ease), visibility .6s var(--ease);
}
.loader.is-hidden { opacity: 0; visibility: hidden; }

.loader__ring {
  width: 58px; height: 58px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, .10);
  border-top-color: var(--accent);
  border-right-color: var(--accent-2);
  animation: spin .9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loader__text {
  font-weight: 700;
  letter-spacing: .32em;
  font-size: .9rem;
  color: var(--text-muted);
}
.loader__text span { color: var(--accent-2); }

.scroll-progress {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 3px;
  z-index: 1200;
  background: transparent;
}
.scroll-progress span {
  display: block;
  height: 100%;
  width: 0%;
  background: var(--gradient);
  box-shadow: 0 0 12px rgba(6, 182, 212, .6);
}


/* =============================================================
   07. NAVBAR
============================================================= */
.navbar {
  position: fixed;
  top: 0; left: 0;
  width: 100%;
  z-index: 1100;
  transition: background var(--t-mid) var(--ease),
              box-shadow var(--t-mid) var(--ease),
              border-color var(--t-mid) var(--ease);
  border-bottom: 1px solid transparent;
}
.navbar.is-stuck {
  background: rgba(15, 23, 42, .72);
  -webkit-backdrop-filter: blur(16px) saturate(160%);
  backdrop-filter: blur(16px) saturate(160%);
  border-bottom-color: var(--border);
  box-shadow: var(--shadow-sm);
}

.nav {
  height: var(--nav-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-4);
}

.nav__logo {
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: -.03em;
  color: var(--heading);
}
.nav__logo span {
  background: var(--gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* Mobile drawer */
.nav__menu {
  position: fixed;
  inset: 0 0 0 auto;
  width: min(78vw, 320px);
  padding: calc(var(--nav-h) + var(--sp-5)) var(--sp-5) var(--sp-6);
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  background: rgba(11, 17, 32, .92);
  -webkit-backdrop-filter: blur(18px);
  backdrop-filter: blur(18px);
  border-left: 1px solid var(--border);
  transform: translateX(100%);
  transition: transform var(--t-mid) var(--ease);
  z-index: 1090;
}
.nav__menu.is-open { transform: translateX(0); }

.nav__link {
  position: relative;
  display: block;
  padding: .7rem .4rem;
  font-size: .95rem;
  font-weight: 500;
  color: var(--text-muted);
}
.nav__link::after {
  content: '';
  position: absolute;
  left: .4rem; bottom: .35rem;
  width: 0; height: 2px;
  border-radius: 2px;
  background: var(--gradient);
  transition: width var(--t-mid) var(--ease);
}
.nav__link:hover,
.nav__link.is-active { color: var(--heading); }
.nav__link:hover::after,
.nav__link.is-active::after { width: calc(100% - .8rem); }

/* Hamburger */
.nav__toggle {
  position: relative;
  z-index: 1120;
  width: 42px; height: 42px;
  display: grid;
  place-content: center;
  gap: 5px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  background: var(--surface);
}
.nav__toggle span {
  display: block;
  width: 20px; height: 2px;
  border-radius: 2px;
  background: var(--text);
  transition: transform var(--t-mid) var(--ease), opacity var(--t-fast) var(--ease);
}
.nav__toggle.is-open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav__toggle.is-open span:nth-child(2) { opacity: 0; }
.nav__toggle.is-open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* Backdrop behind the drawer */
.nav-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, .6);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--t-mid) var(--ease), visibility var(--t-mid) var(--ease);
  z-index: 1080;
}
.nav-backdrop.is-open { opacity: 1; visibility: visible; }


/* =============================================================
   08. HERO
============================================================= */
.hero {
  position: relative;
  min-height: 100svh;
  display: flex;
  align-items: center;
  padding-top: calc(var(--nav-h) + var(--sp-7));
  padding-bottom: var(--sp-8);
}

.hero__inner {
  display: grid;
  gap: var(--sp-7);
  align-items: center;
}

.hero__greeting {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  padding: .4rem .9rem;
  border-radius: var(--r-full);
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: .8rem;
  color: var(--text-muted);
  margin-bottom: var(--sp-4);
}
.hero__greeting .dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 0 0 rgba(34, 197, 94, .6);
  animation: pulse 2s infinite;
}
@keyframes pulse {
  70%  { box-shadow: 0 0 0 9px rgba(34, 197, 94, 0); }
  100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); }
}

.hero__name {
  font-size: clamp(2.1rem, 9vw, 3.6rem);
  font-weight: 800;
  margin-bottom: var(--sp-3);
}

.hero__role {
  font-size: clamp(1.05rem, 4.6vw, 1.6rem);
  font-weight: 600;
  color: var(--text-muted);
  min-height: 2.1em;
  margin-bottom: var(--sp-4);
}
.typing { color: var(--accent-2); }
.caret {
  display: inline-block;
  width: 2px;
  height: 1.05em;
  vertical-align: text-bottom;
  margin-left: 3px;
  background: var(--accent);
  animation: blink 1s steps(2, start) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

.hero__text {
  color: var(--text-muted);
  max-width: 56ch;
  margin-bottom: var(--sp-5);
}

.hero__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-3);
  margin-bottom: var(--sp-5);
}

.hero__socials {
  display: flex;
  gap: var(--sp-3);
}
.hero__socials a {
  display: grid;
  place-content: center;
  width: 42px; height: 42px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  transition: transform var(--t-fast) var(--ease),
              color var(--t-fast) var(--ease),
              border-color var(--t-fast) var(--ease),
              box-shadow var(--t-mid) var(--ease);
}
.hero__socials a:hover {
  color: #fff;
  transform: translateY(-4px);
  border-color: var(--accent);
  box-shadow: var(--glow);
}

/* --- Visual / photo --- */
.hero__visual {
  position: relative;
  justify-self: center;
  width: min(300px, 78vw);
  aspect-ratio: 1;
}
/* Rotating conic ring: the wrapper carries the gradient, the inner
   .hero__photo re-establishes the dark glass surface on top of it. */
.hero__photo {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  padding: 5px;
  box-shadow: var(--shadow-lg);
  animation: bob 6s ease-in-out infinite;
}
.hero__photo::before {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  background: conic-gradient(from 0deg, #3b82f6, #06b6d4, #0ea5e9, #3b82f6);
  animation: spin 8s linear infinite;
  z-index: 0;
}
.hero__photo img {
  position: relative;
  z-index: 1;
  width: 100%; height: 100%;
  object-fit: cover;
  border-radius: 50%;
  background: var(--bg-alt);
}
@keyframes bob {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-14px); }
}

.hero__badge {
  position: absolute;
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  padding: .5rem .85rem;
  border-radius: var(--r-full);
  font-size: .76rem;
  font-weight: 600;
  color: var(--heading);
  box-shadow: var(--shadow-sm);
  animation: bob 5s ease-in-out infinite;
}
.hero__badge i { color: var(--accent-2); }
.hero__badge--1 { top: 8%;  left: -8%; animation-delay: -1.5s; }
.hero__badge--2 { bottom: 10%; right: -6%; animation-delay: -3s; }

.hero__scroll {
  position: absolute;
  left: 50%;
  bottom: var(--sp-5);
  transform: translateX(-50%);
}
.mouse {
  display: block;
  width: 24px; height: 38px;
  border: 2px solid var(--border-strong);
  border-radius: var(--r-full);
  position: relative;
}
.mouse span {
  position: absolute;
  top: 7px; left: 50%;
  width: 4px; height: 7px;
  margin-left: -2px;
  border-radius: 2px;
  background: var(--accent-2);
  animation: wheel 1.8s ease-in-out infinite;
}
@keyframes wheel {
  0%   { opacity: 0; transform: translateY(0); }
  30%  { opacity: 1; }
  100% { opacity: 0; transform: translateY(14px); }
}


/* =============================================================
   09. ABOUT
============================================================= */
.about {
  display: grid;
  gap: var(--sp-5);
}

.about__intro h3 {
  font-size: 1.35rem;
  margin-bottom: var(--sp-3);
}
.about__intro p {
  color: var(--text-muted);
  margin-bottom: var(--sp-4);
}

.about__grid {
  display: grid;
  gap: var(--sp-4);
  grid-template-columns: 1fr;
}

.about__card h3 {
  font-size: 1.02rem;
  margin-bottom: var(--sp-2);
}
.about__card p {
  font-size: .9rem;
  color: var(--text-muted);
}
.about__icon,
.contact__icon {
  display: grid;
  place-content: center;
  width: 46px; height: 46px;
  border-radius: var(--r-md);
  margin-bottom: var(--sp-3);
  font-size: 1.15rem;
  color: #fff;
  background: var(--gradient);
  box-shadow: 0 8px 20px rgba(59, 130, 246, .28);
  transition: transform var(--t-mid) var(--ease);
}
.card:hover .about__icon { transform: rotate(-8deg) scale(1.06); }


/* =============================================================
   10. SKILLS
============================================================= */
.skills {
  display: grid;
  gap: var(--sp-4);
}

.skills__title {
  display: flex;
  align-items: center;
  gap: .6rem;
  font-size: 1.1rem;
  padding-bottom: var(--sp-3);
  margin-bottom: var(--sp-4);
  border-bottom: 1px solid var(--border);
}
.skills__title i { color: var(--accent-2); }

/* Chip list — ใช้แทนแถบเปอร์เซ็นต์ (ระดับความชำนาญที่ตั้งเองเชื่อถือไม่ได้) */
.tags {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
}
.tag {
  padding: .38rem .85rem;
  border-radius: var(--r-full);
  font-size: .82rem;
  font-weight: 500;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  transition: color var(--t-fast) var(--ease),
              border-color var(--t-fast) var(--ease),
              background var(--t-fast) var(--ease),
              transform var(--t-fast) var(--ease);
}
.tag:hover {
  color: var(--accent-2);
  background: var(--accent-soft);
  border-color: rgba(59, 130, 246, .45);
  transform: translateY(-2px);
}


/* =============================================================
   11. PROJECTS
============================================================= */
.projects {
  display: grid;
  gap: var(--sp-5);
}

.project {
  padding: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.project__badge {
  align-self: flex-start;
  padding: .28rem .75rem;
  margin-bottom: var(--sp-3);
  border-radius: var(--r-full);
  font-size: .7rem;
  font-weight: 600;
  letter-spacing: .04em;
  color: #fff;
  background: var(--gradient);
  box-shadow: 0 6px 16px rgba(59, 130, 246, .25);
}

.project__body {
  display: flex;
  flex-direction: column;
  flex: 1;
  padding: var(--sp-5);
}
.project__title { font-size: 1.15rem; margin-bottom: var(--sp-4); }

/* Case study: ปัญหา → สิ่งที่ทำ → ผลลัพธ์ */
.case {
  display: grid;
  gap: var(--sp-3);
  margin-bottom: var(--sp-5);
}
.case__row {
  display: grid;
  gap: .25rem;
  padding-left: var(--sp-4);
  border-left: 2px solid var(--border);
}
.case__row:last-child { border-left-color: var(--accent); }
.case dt {
  font-size: .74rem;
  font-weight: 600;
  letter-spacing: .06em;
  color: var(--accent-2);
}
.case dd {
  font-size: .9rem;
  color: var(--text-muted);
}

.project__tech {
  display: flex;
  flex-wrap: wrap;
  gap: .45rem;
  margin-top: auto;
}
.project__tech li {
  padding: .25rem .65rem;
  border-radius: var(--r-full);
  font-size: .72rem;
  font-weight: 500;
  color: var(--accent-2);
  background: var(--accent-soft);
  border: 1px solid rgba(59, 130, 246, .28);
}

/* Glow ring on hover */
.project:hover {
  box-shadow: var(--shadow-lg), 0 0 0 1px rgba(59, 130, 246, .35);
}


/* =============================================================
   12. TIMELINE
============================================================= */
.timeline {
  position: relative;
  display: grid;
  gap: var(--sp-5);
  padding-left: 32px;
}
.timeline::before {
  content: '';
  position: absolute;
  top: 0; bottom: 0; left: 9px;
  width: 2px;
  border-radius: 2px;
  background: linear-gradient(to bottom, var(--accent), var(--accent-2), transparent);
}

.timeline__item { position: relative; }

.timeline__dot {
  position: absolute;
  top: 26px; left: -32px;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--bg);
  border: 3px solid var(--accent);
  box-shadow: 0 0 0 5px rgba(59, 130, 246, .14);
  transition: transform var(--t-mid) var(--ease), box-shadow var(--t-mid) var(--ease);
}
.timeline__item:hover .timeline__dot {
  transform: scale(1.22);
  box-shadow: 0 0 0 8px rgba(6, 182, 212, .18);
}

.timeline__year {
  display: inline-block;
  padding: .22rem .75rem;
  border-radius: var(--r-full);
  font-size: .76rem;
  font-weight: 700;
  letter-spacing: .06em;
  color: #fff;
  background: var(--gradient);
  margin-bottom: var(--sp-3);
}
.timeline__role { font-size: 1.15rem; margin-bottom: .1rem; }
.timeline__org {
  font-size: .84rem;
  font-weight: 500;
  color: var(--accent-2);
  margin-bottom: var(--sp-3);
}
.timeline__card p { font-size: .9rem; color: var(--text-muted); }
.timeline__card .project__tech { margin-top: var(--sp-4); }


/* =============================================================
   13. CONTACT
============================================================= */
.contact {
  display: grid;
  gap: var(--sp-5);
}

.contact__cards { display: grid; gap: var(--sp-4); }

.contact__card {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  padding: var(--sp-4);
}
.contact__card .contact__icon {
  margin-bottom: 0;
  flex-shrink: 0;
  width: 44px; height: 44px;
}
.contact__card h3 {
  font-size: .82rem;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--text-dim);
  margin-bottom: .15rem;
}
.contact__card a,
.contact__card p {
  font-size: .92rem;
  color: var(--text);
  word-break: break-word;
}
.contact__card a:hover { color: var(--accent-2); }

/* --- Form --- */
.contact__form { display: grid; gap: var(--sp-4); }

.field { display: grid; gap: .4rem; }
.field label {
  font-size: .82rem;
  font-weight: 500;
  color: var(--text-muted);
}
.field input,
.field textarea {
  width: 100%;
  padding: .8rem 1rem;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, .035);
  color: var(--text);
  font-size: .92rem;
  resize: vertical;
  transition: border-color var(--t-fast) var(--ease),
              box-shadow var(--t-mid) var(--ease),
              background var(--t-fast) var(--ease);
}
.field input::placeholder,
.field textarea::placeholder { color: var(--text-dim); }
.field input:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--accent);
  background: rgba(255, 255, 255, .06);
  box-shadow: 0 0 0 4px rgba(59, 130, 246, .16);
}
.field.has-error input,
.field.has-error textarea { border-color: #f87171; }

.field__error {
  font-size: .76rem;
  color: #f87171;
  min-height: 1em;
}

.form__status {
  font-size: .85rem;
  text-align: center;
  min-height: 1.4em;
}
.form__status.is-ok   { color: #34d399; }
.form__status.is-fail { color: #f87171; }


/* =============================================================
   14. FOOTER & BACK-TO-TOP
============================================================= */
.footer {
  border-top: 1px solid var(--border);
  background: var(--bg-alt);
  padding-block: var(--sp-7) var(--sp-5);
}
.footer__inner {
  display: grid;
  justify-items: center;
  gap: var(--sp-4);
  text-align: center;
}
.footer__tagline {
  font-size: .88rem;
  color: var(--text-muted);
  max-width: 42ch;
}
.footer__socials { display: flex; gap: var(--sp-3); }
.footer__socials a {
  display: grid;
  place-content: center;
  width: 40px; height: 40px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  transition: transform var(--t-fast) var(--ease),
              color var(--t-fast) var(--ease),
              border-color var(--t-fast) var(--ease),
              box-shadow var(--t-mid) var(--ease);
}
.footer__socials a:hover {
  color: #fff;
  transform: translateY(-4px);
  border-color: var(--accent);
  box-shadow: var(--glow);
}
.footer__copy {
  font-size: .8rem;
  color: var(--text-dim);
  border-top: 1px solid var(--border);
  padding-top: var(--sp-4);
  width: 100%;
}

.to-top {
  position: fixed;
  right: 1rem; bottom: 1rem;
  z-index: 1050;
  width: 46px; height: 46px;
  display: grid;
  place-content: center;
  border-radius: 50%;
  color: #fff;
  background: var(--gradient);
  box-shadow: 0 10px 26px rgba(59, 130, 246, .35);
  opacity: 0;
  visibility: hidden;
  transform: translateY(16px);
  transition: opacity var(--t-mid) var(--ease),
              visibility var(--t-mid) var(--ease),
              transform var(--t-mid) var(--ease);
}
.to-top.is-visible { opacity: 1; visibility: visible; transform: none; }
.to-top:hover { transform: translateY(-4px) scale(1.06); }


/* =============================================================
   15. RESPONSIVE BREAKPOINTS
============================================================= */

/* ---- ≥ 576px : small tablets ---- */
@media (min-width: 576px) {
  :root { --gutter: 1.75rem; }
  .about__grid { grid-template-columns: repeat(2, 1fr); }
  .to-top { right: 1.5rem; bottom: 1.5rem; }
}

/* ---- ≥ 768px : tablets ---- */
@media (min-width: 768px) {
  :root { --nav-h: 74px; }

  .section { padding-block: var(--sp-9); }

  .hero__visual { width: min(360px, 60vw); }

  .skills   { grid-template-columns: repeat(2, 1fr); }
  .projects { grid-template-columns: repeat(2, 1fr); }

  /* กลุ่มทักษะมี 5 กลุ่ม (เลขคี่) — ให้กลุ่มสุดท้ายกินเต็มแถว */
  .skills__group:last-child { grid-column: 1 / -1; }

  .about { grid-template-columns: 1fr; }
  .contact__cards { grid-template-columns: repeat(2, 1fr); }
}

/* ---- ≥ 992px : desktop ---- */
@media (min-width: 992px) {
  :root { --gutter: 2rem; }

  /* Navbar becomes a horizontal bar */
  .nav__toggle { display: none; }
  .nav__menu {
    position: static;
    width: auto;
    flex-direction: row;
    align-items: center;
    gap: var(--sp-2);
    padding: 0;
    background: none;
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
    border: 0;
    transform: none;
  }
  .nav__link { padding: .5rem .85rem; }
  .nav-backdrop { display: none; }

  /* Hero side-by-side */
  .hero__inner {
    grid-template-columns: 1.15fr .85fr;
    gap: var(--sp-8);
  }
  .hero__visual { justify-self: end; width: min(400px, 38vw); }

  /* About: intro beside the grid */
  .about { grid-template-columns: .9fr 1.1fr; align-items: start; }
  .about__grid { grid-template-columns: repeat(2, 1fr); }

  /* Alternating timeline */
  .timeline { padding-left: 0; }
  .timeline::before { left: 50%; transform: translateX(-50%); }
  .timeline__item { width: 50%; }
  .timeline__item:nth-child(odd) {
    padding-right: var(--sp-6);
    text-align: right;
  }
  .timeline__item:nth-child(even) {
    margin-left: 50%;
    padding-left: var(--sp-6);
  }
  .timeline__item:nth-child(odd)  .timeline__dot { left: auto; right: -10px; }
  .timeline__item:nth-child(even) .timeline__dot { left: -10px; }
  /* ชิปเทคโนโลยีต้องชิดขอบเดียวกับข้อความในการ์ดฝั่งนั้น */
  .timeline__item:nth-child(odd) .project__tech { justify-content: flex-end; }

  /* Contact: cards beside form */
  .contact { grid-template-columns: 1fr 1.05fr; align-items: start; }
  .contact__cards { grid-template-columns: 1fr; }
}

/* ---- ≥ 1200px : large desktop ---- */
@media (min-width: 1200px) {
  .skills { grid-template-columns: repeat(2, 1fr); }
  .about__grid { grid-template-columns: repeat(4, 1fr); }
  .about { grid-template-columns: 1fr; }
}


/* =============================================================
   16. REDUCED MOTION / PRINT
============================================================= */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
  [data-animate] { opacity: 1 !important; transform: none !important; }
  .cursor-glow { display: none; }
}

@media print {
  .navbar, .to-top, .bg-decor, .cursor-glow,
  .loader, .scroll-progress, .hero__scroll { display: none !important; }
  body { background: #fff; color: #000; }
  .glass { background: none; border: 1px solid #ccc; }
}
