/* ===========================================
   Chiang Mai Services — Global Stylesheet
   Mobile-first · Accessible · Performant
   =========================================== */

/* --- Custom Properties --- */
:root {
  --primary: #1B3B6F;
  --primary-light: #2A5298;
  --primary-dark: #0F2340;
  --secondary: #D47B0A;
  --secondary-light: #E8941A;
  --accent: #F5C542;
  --accent-light: #FDE68A;
  --forest: #1E6B30;
  --forest-light: #2D8A3E;
  --bg: #FFFAF5;
  --bg-alt: #FFF3E8;
  --bg-card: #FFFFFF;
  --text: #1A202C;
  --text-secondary: #4A5568;
  --text-light: #718096;
  --border: #E2E8F0;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
  --shadow: 0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 12px 32px rgba(0,0,0,0.1);
  --radius: 0.75rem;
  --radius-lg: 1.25rem;
  --max-w: 1100px;
  --transition: 0.25s ease;
}

/* --- Reset --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Noto Sans', 'Noto Sans Thai', Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
img { max-width: 100%; height: auto; display: block; }
a { color: var(--primary); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--primary-light); }
ul, ol { list-style: none; }
h1, h2, h3, h4 { line-height: 1.3; color: var(--primary); }

/* --- Skip Link (Accessibility) --- */
.skip-link {
  position: absolute;
  top: -100%;
  left: 1rem;
  background: var(--primary);
  color: #fff;
  padding: 0.75rem 1.5rem;
  border-radius: 0 0 var(--radius) var(--radius);
  z-index: 1000;
  font-weight: 600;
  transition: top var(--transition);
}
.skip-link:focus {
  top: 0;
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

/* --- Focus Styles --- */
:focus-visible {
  outline: 3px solid var(--primary-light);
  outline-offset: 3px;
  border-radius: 4px;
}

/* --- Container --- */
.container {
  width: 100%;
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 1.25rem;
}

/* --- Header --- */
.site-header {
  padding: 0.5rem 0;
  background: var(--bg);
  z-index: 100;
  border-bottom: 1px solid var(--border);
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.logo-link {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.logo-img {
  width: 120px;
  height: auto;
}
.lang-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 0.85rem;
  border: 2px solid var(--primary);
  border-radius: 2rem;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--primary);
  background: transparent;
  transition: background var(--transition), color var(--transition);
}
.lang-toggle:hover, .lang-toggle:focus-visible {
  background: var(--primary);
  color: #fff;
}
.lang-toggle svg { width: 18px; height: 18px; flex-shrink: 0; }

/* --- Hero --- */
.hero {
  text-align: center;
  padding: 3rem 0 2.5rem;
  background: linear-gradient(170deg, var(--bg) 0%, var(--bg-alt) 50%, #FFE8CC 100%);
  position: relative;
  overflow: hidden;
}
.hero::before {
  content: '';
  position: absolute;
  top: -60%;
  right: -30%;
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, rgba(245,197,66,0.15) 0%, transparent 70%);
  border-radius: 50%;
  pointer-events: none;
}
.hero::after {
  content: '';
  position: absolute;
  bottom: -40%;
  left: -20%;
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, rgba(27,59,111,0.06) 0%, transparent 70%);
  border-radius: 50%;
  pointer-events: none;
}
.badge {
  display: inline-block;
  background: linear-gradient(135deg, var(--secondary), var(--accent));
  color: #fff;
  padding: 0.4rem 1.25rem;
  border-radius: 2rem;
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-bottom: 1.25rem;
  animation: pulse-badge 2.5s ease-in-out infinite;
}
.hero h1 {
  font-size: clamp(2rem, 6vw, 3.5rem);
  font-weight: 800;
  margin-bottom: 0.5rem;
  color: var(--primary);
  position: relative;
  z-index: 1;
}
.hero .subtitle {
  font-size: clamp(1.05rem, 3vw, 1.35rem);
  color: var(--secondary);
  font-weight: 600;
  margin-bottom: 1rem;
}
.hero .description {
  font-size: 1.05rem;
  color: var(--text-secondary);
  max-width: 680px;
  margin: 0 auto;
  line-height: 1.8;
  position: relative;
  z-index: 1;
}

/* --- Section Heading --- */
.section-heading {
  text-align: center;
  margin-bottom: 2.5rem;
}
.section-heading h2 {
  font-size: clamp(1.5rem, 4vw, 2.25rem);
  font-weight: 800;
  margin-bottom: 0.5rem;
}
.section-heading p {
  color: var(--text-secondary);
  font-size: 1.05rem;
  max-width: 550px;
  margin: 0 auto;
}

/* --- Services Section --- */
.services-section {
  padding: 3rem 0;
}
.services-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}
.service-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  transition: transform var(--transition), box-shadow var(--transition);
  display: flex;
  gap: 1rem;
  align-items: flex-start;
}
.service-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
}
.service-icon {
  width: 48px;
  height: 48px;
  min-width: 48px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-alt);
}
.service-icon svg {
  width: 24px;
  height: 24px;
  color: var(--secondary);
}
.service-card h3 {
  font-size: 1.05rem;
  font-weight: 700;
  margin-bottom: 0.3rem;
  color: var(--primary);
}
.service-card p {
  font-size: 0.92rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

/* --- CTA Section --- */
.cta-section {
  padding: 3rem 0;
  text-align: center;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: #fff;
}
.cta-section h2 {
  color: #fff;
  font-size: clamp(1.5rem, 4vw, 2rem);
  margin-bottom: 0.75rem;
}
.cta-section p {
  color: rgba(255,255,255,0.85);
  font-size: 1.05rem;
  max-width: 550px;
  margin: 0 auto 1.5rem;
}
.cta-badge {
  display: inline-block;
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.3);
  color: var(--accent-light);
  padding: 0.6rem 1.5rem;
  border-radius: 2rem;
  font-weight: 600;
  font-size: 0.95rem;
}

/* --- Footer --- */
.site-footer {
  margin-top: auto;
  padding: 2rem 0;
  background: var(--primary-dark);
  color: rgba(255,255,255,0.7);
  font-size: 0.88rem;
  text-align: center;
}
.footer-inner {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  align-items: center;
}
.site-footer a {
  color: var(--accent-light);
  font-weight: 600;
  transition: color var(--transition);
}
.site-footer a:hover { color: var(--accent); }

/* --- Developer Page --- */
.dev-hero {
  text-align: center;
  padding: 3rem 0 2rem;
  background: linear-gradient(170deg, var(--bg) 0%, var(--bg-alt) 100%);
}
.dev-hero .badge {
  background: var(--primary);
  animation: none;
}
.dev-hero h1 {
  font-size: clamp(1.8rem, 5vw, 3rem);
}
.dev-hero .subtitle {
  font-size: 1.1rem;
  color: var(--text-secondary);
  max-width: 600px;
  margin: 0.5rem auto 0;
}
.dev-section {
  padding: 2.5rem 0;
}
.dev-section:nth-child(even) {
  background: var(--bg-alt);
}
.about-text {
  max-width: 750px;
  margin: 0 auto;
  text-align: center;
  color: var(--text-secondary);
  font-size: 1.05rem;
  line-height: 1.85;
}
.projects-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.25rem;
}
.project-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  transition: transform var(--transition), box-shadow var(--transition);
}
.project-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
}
.project-card h3 {
  font-size: 1.15rem;
  margin-bottom: 0.25rem;
}
.project-card .project-loc {
  font-size: 0.88rem;
  color: var(--text-light);
  font-weight: 500;
  margin-bottom: 0.5rem;
}
.project-card .project-desc {
  font-size: 0.93rem;
  color: var(--text-secondary);
  line-height: 1.7;
  margin-bottom: 0.75rem;
}
.project-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.75rem;
}
.project-tag {
  display: inline-block;
  background: var(--bg-alt);
  color: var(--secondary);
  padding: 0.2rem 0.65rem;
  border-radius: 1rem;
  font-size: 0.78rem;
  font-weight: 600;
}
.project-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
}
.project-link {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--primary);
}
.project-link:hover { color: var(--primary-light); }
.project-link svg { width: 16px; height: 16px; }
.project-link--secondary { color: var(--text-light); }
.project-link--secondary:hover { color: var(--primary); }

/* Developer services compact */
.dev-services-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  max-width: 800px;
  margin: 0 auto;
}
.dev-service-item {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  padding: 1rem;
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}
.dev-service-icon {
  width: 40px;
  height: 40px;
  min-width: 40px;
  background: var(--bg-alt);
  border-radius: 0.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
}
.dev-service-icon svg {
  width: 20px;
  height: 20px;
  color: var(--secondary);
}
.dev-service-item h3 {
  font-size: 0.98rem;
  margin-bottom: 0.15rem;
}
.dev-service-item p {
  font-size: 0.88rem;
  color: var(--text-secondary);
}

/* Dev CTA */
.dev-cta {
  text-align: center;
  padding: 3rem 0;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: #fff;
}
.dev-cta h2 { color: #fff; margin-bottom: 0.75rem; }
.dev-cta p { color: rgba(255,255,255,0.8); margin-bottom: 1.25rem; }
.dev-cta a {
  color: var(--accent-light);
  font-weight: 700;
  font-size: 1.1rem;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.dev-cta a:hover { color: #fff; }

/* Breadcrumb */
.breadcrumb {
  padding: 0.75rem 0;
  font-size: 0.85rem;
  color: var(--text-light);
}
.breadcrumb a { color: var(--text-light); }
.breadcrumb a:hover { color: var(--primary); }
.breadcrumb span { margin: 0 0.35rem; }

/* --- FAQ Section --- */
.faq-list { max-width: 800px; margin: 0 auto; }
details {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 0.75rem;
  background: var(--bg-card);
  transition: box-shadow var(--transition);
}
details[open] { box-shadow: var(--shadow-sm); }
summary {
  padding: 1rem 1.25rem;
  font-weight: 600;
  cursor: pointer;
  color: var(--primary);
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
summary::-webkit-details-marker { display: none; }
summary::after {
  content: '+';
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--secondary);
  flex-shrink: 0;
}
details[open] summary::after { content: '\2212'; }
.faq-answer {
  padding: 0 1.25rem 1rem;
  color: var(--text-secondary);
  line-height: 1.7;
  font-size: 0.95rem;
}

/* --- Service Categories (Developer page expanded) --- */
.service-category {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
}
.service-category h3 {
  font-size: 1.1rem;
  margin-bottom: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.service-category h3 svg { width: 22px; height: 22px; color: var(--secondary); flex-shrink: 0; }
.service-sub-list li {
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--border);
}
.service-sub-list li:last-child { border-bottom: none; }
.service-sub-list strong {
  color: var(--primary);
  display: block;
  font-size: 0.93rem;
}
.service-sub-list p {
  font-size: 0.86rem;
  color: var(--text-secondary);
  margin-top: 0.15rem;
  line-height: 1.6;
}

/* --- Animations --- */
@keyframes pulse-badge {
  0%, 100% { box-shadow: 0 0 0 0 rgba(212,123,10,0.35); }
  50% { box-shadow: 0 0 0 12px rgba(212,123,10,0); }
}

/* --- Responsive — Tablet + --- */
@media (min-width: 600px) {
  .site-header {
    padding: 1rem 0;
    position: sticky;
    top: 0;
  }
  .services-grid { grid-template-columns: 1fr 1fr; }
  .projects-grid { grid-template-columns: 1fr 1fr; }
  .dev-services-list { grid-template-columns: 1fr 1fr; }
  .hero { padding: 4rem 0 3rem; }
  .logo-img { width: 200px; }
}

/* --- Responsive — Desktop --- */
@media (min-width: 900px) {
  .container { padding: 0 2rem; }
  .hero { padding: 5rem 0 4rem; }
  .services-section { padding: 4rem 0; }
  .cta-section { padding: 4rem 0; }
  .service-card { padding: 1.75rem; }
}

/* --- Reduced Motion --- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* --- Print --- */
@media print {
  body { background: #fff; color: #000; }
  .site-header, .site-footer, .badge, .cta-section { display: none; }
  .hero { background: none; padding: 1rem 0; }
  a { color: #000; }
  a[href]::after { content: ' (' attr(href) ')'; font-size: 0.8em; }
}
