/* ==========================================================================
   1. DESIGN TOKENS (CSS VARIABLES)
   ========================================================================== */
:root {
  /* --- Color Tokens --- */
  --bg-primary: #FBF7EE;      /* Warm Beige / Soft Cream Background — Hero only */
  --bg-secondary: #FFFEFC;    /* NEW — background for every section other than the Hero */
  --surface: #FFFFFF;         /* White Surface for Cards & Containers */
  --border-color: #EBE0D0;    /* Soft Warm Sand Border */

  /* Typography Colors (Pass WCAG Accessibility) */
  --text-primary: #3A231C;    /* Dark Espresso Brown for Main Text & Headings */
  --text-secondary: #6E5A51;  /* Warm Muted Brown for Subtitles & Meta */
  --text-disabled: #AA9A90;   /* Ash Brown for Placeholders / Muted Elements */

  /* Accent Colors */
  --accent-primary: #D65B3E;   /* Terracotta Coral (Buttons, Links, Highlights) */
  --accent-hover: #B8472C;     /* Darker Terracotta for Hover States */
  --accent-secondary: #E5A754; /* Warm Amber for Badges & Tag Highlights */

  /* --- Typography Scale (Mobile First Defaults) --- */
  --font-family: 'Plus Jakarta Sans', 'Kanit', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', 'SFMono-Regular', Consolas, monospace;
  
  --fs-hero: 2rem;            /* 32px */
  --fs-h1: 1.75rem;           /* 28px */
  --fs-h2: 1.5rem;            /* 24px */
  --fs-h3: 1.25rem;           /* 20px */
  --fs-body: 1rem;            /* 16px */
  --fs-small: 0.875rem;       /* 14px */

  --lh-tight: 1.2;
  --lh-heading: 1.3;
  --lh-body: 1.6;

  /* --- Spacing & Container (8pt Grid System) --- */
  --container-max-width: 1200px;
  --section-padding-y: 64px;
  --container-padding-x: 20px;
  --gap-grid: 24px;
  --radius-card: 16px;
  --radius-button: 8px;

  /* --- Elevation / Shadow --- */
  --shadow-card: 0 4px 20px rgba(58, 35, 28, 0.05);
  --shadow-hover: 0 8px 30px rgba(58, 35, 28, 0.1);
}

/* --- Responsive Adjustments for Desktop (768px and up) --- */
@media (min-width: 768px) {
  :root {
    --fs-hero: 3.25rem;       /* 52px */
    --fs-h1: 2.25rem;         /* 36px */
    --fs-h2: 1.75rem;         /* 28px */
    --fs-h3: 1.5rem;          /* 24px */
    
    --section-padding-y: 112px;
    --container-padding-x: 40px;
    --gap-grid: 32px;
  }
}

/* ==========================================================================
   2. BASE STYLES & RESET
   ========================================================================== */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background-color: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font-family);
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  -webkit-font-smoothing: antialiased;
}

/* Layout Container */
.container {
  width: 100%;
  max-width: var(--container-max-width);
  margin-left: auto;
  margin-right: auto;
  padding-left: var(--container-padding-x);
  padding-right: var(--container-padding-x);
}

.section {
  padding-top: var(--section-padding-y);
  padding-bottom: var(--section-padding-y);
}

/* ==========================================================================
   3. TYPOGRAPHY CLASSES
   ========================================================================== */
.hero-title {
  font-size: var(--fs-hero);
  line-height: var(--lh-tight);
  font-weight: 700;
  color: var(--text-primary);
}

h1, .h1 {
  font-size: var(--fs-h1);
  line-height: var(--lh-heading);
  font-weight: 700;
  color: var(--text-primary);
}

h2, .h2 {
  font-size: var(--fs-h2);
  line-height: var(--lh-heading);
  font-weight: 600;
  color: var(--text-primary);
}

h3, .h3 {
  font-size: var(--fs-h3);
  line-height: var(--lh-heading);
  font-weight: 600;
  color: var(--text-primary);
}

.text-sub {
  color: var(--text-secondary);
}

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

/* ==========================================================================
   4. UI COMPONENTS & UTILITIES
   ========================================================================== */
/* Card Component */
.card {
  background-color: var(--surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-card);
  padding: 24px;
  box-shadow: var(--shadow-card);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-hover);
}

/* Primary Button */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background-color: var(--accent-primary);
  color: #FFFFFF;
  font-weight: 600;
  padding: 12px 24px;
  border-radius: var(--radius-button);
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: background-color 0.2s ease;
}

.btn-primary:hover {
  background-color: var(--accent-hover);
}

/* Skill / Category Tag */
.tag {
  display: inline-block;
  background-color: rgba(229, 167, 84, 0.15); /* Amber tint */
  color: var(--text-primary);
  font-size: var(--fs-small);
  font-weight: 500;
  padding: 4px 12px;
  border-radius: 20px;
}

/* Responsive Grid for Case Studies */
.portfolio-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--gap-grid);
}

@media (min-width: 768px) {
  .portfolio-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.section-title {
  margin-bottom: var(--gap-grid);
}

/* ==========================================================================
   5. BASE LINK STYLES
   ========================================================================== */
a {
  color: var(--accent-primary);
  text-decoration: underline;
  text-decoration-color: transparent;
  transition: color 0.2s ease, text-decoration-color 0.2s ease;
}

a:hover {
  color: var(--accent-hover);
  text-decoration-color: currentColor;
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
label:focus-visible {
  outline: 2px solid var(--accent-primary);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ==========================================================================
   6. NAVIGATION
   ========================================================================== */
.site-header {
  background-color: var(--bg-primary);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 100;
}

.main-nav {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 16px;
  padding-bottom: 16px;
}

.nav-logo {
  font-family: 'Gaegu', cursive;
  font-size: clamp(1.4rem, 1rem + 1.5vw, 1.75rem);
  font-weight: 700;
  line-height: 1;
  color: var(--accent-primary);
  text-decoration: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.nav-logo:hover {
  opacity: 0.72;
  transform: rotate(-1.5deg);
}

/* Hamburger toggle (CSS-only, checkbox hack — no JS needed until Phase 3) */
.nav-toggle-checkbox {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

.nav-toggle-label {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  cursor: pointer;
  border-radius: var(--radius-button);
}

.nav-toggle-icon,
.nav-toggle-icon::before,
.nav-toggle-icon::after {
  display: block;
  width: 24px;
  height: 2px;
  background-color: var(--text-primary);
  border-radius: 2px;
  transition: transform 0.2s ease, opacity 0.2s ease, background-color 0.2s ease;
}

.nav-toggle-icon {
  position: relative;
}

.nav-toggle-icon::before,
.nav-toggle-icon::after {
  content: "";
  position: absolute;
  left: 0;
}

.nav-toggle-icon::before {
  top: -7px;
}

.nav-toggle-icon::after {
  top: 7px;
}

.nav-toggle-checkbox:checked ~ .nav-toggle-label .nav-toggle-icon {
  background-color: transparent;
}

.nav-toggle-checkbox:checked ~ .nav-toggle-label .nav-toggle-icon::before {
  transform: translateY(7px) rotate(45deg);
}

.nav-toggle-checkbox:checked ~ .nav-toggle-label .nav-toggle-icon::after {
  transform: translateY(-7px) rotate(-45deg);
}

/* Nav links — mobile: hidden dropdown revealed by the checkbox above */
.nav-list {
  display: none;
  flex-direction: column;
  gap: 4px;
  list-style: none;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background-color: var(--bg-primary);
  border-bottom: 1px solid var(--border-color);
  padding: 16px var(--container-padding-x);
  box-shadow: var(--shadow-card);
}

.nav-toggle-checkbox:checked ~ .nav-list {
  display: flex;
}

.nav-link {
  display: inline-block;
  color: var(--text-primary);
  font-weight: 500;
  text-decoration: none;
  padding: 8px 4px;
  border-bottom: 2px solid transparent;
}

.nav-link:hover {
  color: var(--accent-primary);
}

.nav-link[aria-current="page"] {
  color: var(--accent-primary);
  font-weight: 700;
  border-bottom-color: var(--accent-primary);
}

/* Nav links — desktop: always-visible horizontal row, hamburger hidden */
@media (min-width: 768px) {
  .nav-toggle-label {
    display: none;
  }

  .nav-list {
    display: flex;
    position: static;
    flex-direction: row;
    align-items: center;
    gap: var(--gap-grid);
    background-color: transparent;
    border-bottom: none;
    box-shadow: none;
    padding: 0;
  }
}

/* Scroll progress bar — fills left-to-right as the reader scrolls down the
   page. Lives inside .site-header (last child) so it's pinned to the
   header's bottom edge and scrolls/sticks with it — no need to track
   header height, since .site-header is already position: sticky (a
   positioned element), which makes it the containing block here.

   Shown on the 4 case-study pages + About Me; index.html and resume.html
   don't include the markup for it at all, so this rule is simply unused
   there. Breakpoint is 1400px so it hands off to the case-study pages'
   .toc-side (styles/project-detail.css) right where that becomes visible
   — below 1400px there's no room for the side TOC, so this bar is the
   wayfinding/progress cue instead; at 1400px+ the TOC takes over and this
   hides. Keep these two breakpoints in sync if either one changes. */
.scroll-progress {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 0%;
  height: 3px;
  background: var(--accent-primary);
  transition: width 0.1s ease-out;
}

@media (min-width: 1401px) {
  .scroll-progress {
    display: none;
  }
}

/* ==========================================================================
   7. FOOTER — minimal single-row footer, shared across every page
   (site index pages via main.css, case studies via main.css + project-detail.css)
   ========================================================================== */
.site-footer-mini {
  background: var(--bg-primary);
  border-top: 1px solid var(--border-color); /* full-width divider */
}

.site-footer-mini__row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 20px 32px;
  max-width: var(--container-max-width);
  margin: 0 auto;
  padding: 48px clamp(20px, 5vw, 64px);
}

.site-footer-mini__contact {
  display: flex;
  align-items: center;
  gap: 14px;
}

.site-footer-mini__label {
  color: var(--text-primary);
  font-weight: 500;
  font-size: 0.95rem;
}

.site-footer-mini__icons {
  display: flex;
  align-items: center;
  gap: 8px;
}

.site-footer-mini__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--accent-primary);
  background: transparent;
  color: var(--accent-primary);
  text-decoration: none;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.site-footer-mini__icon svg {
  width: 16px;
  height: 16px;
}

.site-footer-mini__icon:hover,
.site-footer-mini__icon:focus-visible {
  background: var(--accent-primary);
  color: var(--bg-primary);
}

.site-footer-mini__icon:focus-visible {
  outline: 2px solid var(--accent-primary);
  outline-offset: 3px;
}

.site-footer-mini__credit {
  margin: 0;
  font-style: italic;
  font-size: 0.8125rem;
  color: var(--text-secondary);
}

@media (max-width: 560px) {
  .site-footer-mini__row {
    flex-direction: column;
    align-items: flex-start;
    gap: 24px;
    padding-top: 40px;
    padding-bottom: 40px;
  }
}

/* ==========================================================================
   8. HOME PAGE (index.html)
   ========================================================================== */
/* Scoped to index.html only (via <body class="page-home">) — every other
   page keeps the base body background from section 2. */
body.page-home {
  background: var(--bg-secondary);
}

.hero-section {
  display: grid;
  grid-template-columns: 1fr;
  justify-items: center;
  text-align: center;
  
  gap: var(--gap-grid);
  background-color: var(--bg-primary);
}

.hero-profile-image {
  width: 300px;
  height: 300px;
}

.hero-profile-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
  border: 4px solid var(--surface);
  box-shadow: var(--shadow-card);
}

/* --- Hero copy block (redesign) ------------------------------------------
   Replaces the old hero-name / hero-intro / hero-skills-list trio with a
   single stacked column: greeting -> role -> tagline -> meta -> CTAs.
   Reuses the site's existing tokens (accent-primary, font-family,
   font-mono, Gaegu) rather than the one-off colors/fonts in the Figma
   export, so the hero stays consistent with the rest of the portfolio.
--------------------------------------------------------------------------- */
.hero-content {
  display: flex;
  flex-direction: column;
  
  align-items: center;
  gap: 12px;
}

.hero-greeting {
  font-family: 'Gaegu', cursive; /* reuses the nav-logo's signature font */
  font-weight: 700;
  font-size: clamp(2.25rem, 1.7rem + 2.2vw, 3rem);
  line-height: 1.15;
  color: var(--accent-primary);
}

.hero-role {
  font-family: var(--font-mono);
  font-size: var(--fs-body);
  color: var(--accent-primary);
}

.hero-intro {
  max-width: 560px;
  color: var(--text-primary);
  font-size: 1.15rem;
  line-height: var(--lh-body);
}

.hero-bg-full {
  width: 100%;
  /* ย้ายคำสั่งพื้นหลัง หรือ linear-gradient มาใส่ที่กล่องนอกแทน */
  background: var(--bg-primary);
}

/* Full subline by default; short version swaps in on very small screens
   where the full sentence reads as cramped next to the hero headline. */
.hero-intro-short { display: none; }
@media (max-width: 480px) {
  .hero-intro-full { display: none; }
  .hero-intro-short { display: inline; }
}

.hero-meta {
  font-family: var(--font-mono);
  font-size: var(--fs-small);
  color: var(--text-secondary);
}

.hero-cta-group {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 16px;
  margin-top: 8px;
}

.hero-btn-primary {
  border-radius: 100px;
  padding: 4px 32px;
}

.hero-btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background-color: transparent;
  color: var(--accent-primary);
  font-weight: 600;
  padding: 14px 32px;
  border-radius: 100px;
  border: 1.5px solid var(--accent-primary);
  text-decoration: none;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.hero-btn-secondary:hover {
  background-color: var(--accent-primary);
  color: #FFFFFF;
}

@media (min-width: 768px) {
  .hero-section {
    grid-template-columns: auto 1fr;
    align-items: center;
    justify-items: start;
    text-align: left;
    column-gap: calc(var(--gap-grid) * 2);
  }

  .hero-profile-image {
    width: 400px;
    height: 400px;
  }

  .hero-content {
    align-items: flex-start;
  }

  .hero-intro {
    font-size: 1.375rem;
  }

  .hero-cta-group {
    justify-content: flex-start;
  }
}

/* --- Skills marquee --------------------------------------------------------
   Pure CSS infinite loop: the track holds two identical <ul> lists side by
   side (the second is aria-hidden) and animates translateX(-50%), which is
   exactly the width of one list — so it wraps seamlessly. No JS required.
--------------------------------------------------------------------------- */
.skills-marquee-section {
  overflow: hidden;
  background: linear-gradient(180deg, var(--bg-primary) 0%, var(--bg-secondary) 100%);
  /* border-top: 1px solid var(--border-color);
  border-bottom: 1px solid var(--border-color); */
  padding: 16px 0;
}

.skills-marquee-track {
  display: flex;
  width: max-content;
  animation: skills-marquee-scroll 60s linear infinite;
}

.skills-marquee-list {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  gap: 36px;
  padding: 0 18px;
  list-style: none;
}

.skills-marquee-item {
  display: flex;
  align-items: center;
  gap: 10px;
  white-space: nowrap;
  color: var(--accent-primary);
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 0.95rem;
  /* text-transform: uppercase; */
  letter-spacing: 0.03em;
}

.skills-marquee-icon {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
}

@keyframes skills-marquee-scroll {
  from { transform: translateX(0); }
  to   { transform: translateX(-50%); }
}

@media (min-width: 768px) {
  .skills-marquee-item {
    font-size: 1.15rem;
  }

  .skills-marquee-icon {
    width: 30px;
    height: 30px;
  }
}

/* Respect reduced-motion preference: freeze the marquee instead of animating */
@media (prefers-reduced-motion: reduce) {
  .skills-marquee-track {
    animation: none;
  }
}

/* Case study preview cards — built on top of .portfolio-grid + .card */
.case-study-preview-section {
  background-color: var(--bg-secondary); /* NEW — every non-hero section sits on this off-white */
}

.case-study-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  color: var(--text-primary);
  text-decoration: none;
}

.case-study-card-image {
  width: 100%;
  aspect-ratio: 1/1;
  object-fit: cover;
  border-radius: calc(var(--radius-card) - 8px);
  background-color: var(--bg-primary);
}

.case-study-card-title {
  margin-top: 4px;
  color: var(--accent-primary);
  font-weight: 700;
  
}

.case-study-card-desc {
  color: var(--text-secondary);
  font-size: var(--fs-small);
}

/* Project tags — pill-chip version of the case-study pages' .tag-label:
   same accent-secondary background + JetBrains Mono treatment, but a
   plain rounded pill since several of these sit in a row on one card. */
.case-study-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 2px;
  list-style: none;
}

.project-tag {
  display: inline-flex;
  align-items: center;
  /* background-color: var(--accent-secondary); */
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 5px 12px;
  border: 1px solid var(--accent-secondary);
  border-radius: 100px;
  white-space: nowrap;
}

.case-study-card-role {
  font-size: var(--fs-small);
  color: var(--text-secondary);
  margin-top: 2px;
}

/* ==========================================================================
   9. CASE STUDY PAGE (case-studies/template.html + copies)
   ========================================================== */
.case-study-hero-section {
  display: flex;
  flex-direction: column;
  gap: var(--gap-grid);
}

.case-study-hero-image {
  width: 100%;
  border-radius: var(--radius-card);
  overflow: hidden;
  box-shadow: var(--shadow-card);
  background-color: var(--surface);
}

.case-study-hero-img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  object-fit: cover;
}

.case-study-hook {
  color: var(--text-secondary);
  font-size: var(--fs-h3);
  max-width: 720px;
}

.case-study-meta {
  display: flex;
  flex-direction: column;
  gap: var(--gap-grid);
}

.case-study-meta-label {
  color: var(--text-secondary);
  font-size: var(--fs-small);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
}

.case-study-tools-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  list-style: none;
}

.case-study-time-value {
  font-weight: 600;
}

@media (min-width: 768px) {
  .case-study-meta {
    flex-direction: row;
    gap: calc(var(--gap-grid) * 2);
  }

  .case-study-tools,
  .case-study-time {
    flex: 1;
  }
}

/* Details section is intentionally minimal here — content/structure
   varies per project and gets filled in per case study later. */
.case-study-details-section {
  display: flex;
  flex-direction: column;
  gap: var(--gap-grid);
}

/* ==========================================================================
   10. RESUME PAGE (resume.html)
   ========================================================================== */
.resume-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: var(--gap-grid);
}

.resume-title {
  margin-bottom: 8px;
}

.resume-preview-image {
  width: 100%;
  max-width: 760px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-card);
  overflow: hidden;
  box-shadow: var(--shadow-hover);
  cursor: zoom-in;
}

/* Static image of the actual resume — natural aspect ratio, no PDF viewer
   chrome, so it always fills the frame edge-to-edge on every browser/OS. */
.resume-preview-frame {
  display: block;
  width: 100%;
  height: auto;
}