/* ============================================================
   Chalermkiat Phafongyun — Portfolio styles
   Soft light themes (mist / cream / sage) · mobile-first
   ============================================================ */

/* Default = mist (soft cool blue-gray / sky) */
:root,
[data-theme="mist"] {
  --bg: #f2f5f9;
  --bg-elevated: #ffffff;
  --bg-card: #ffffff;
  --bg-alt: #e8eef5;
  --border: rgba(100, 116, 139, 0.2);
  --text: #1e2a3a;
  --text-muted: #5b6b7c;
  --accent: #5b8ec9;
  --accent-2: #7b8fdb;
  --accent-soft: rgba(91, 142, 201, 0.14);
  --accent-2-soft: rgba(123, 143, 219, 0.14);
  --accent-hover: #3d6fa8;
  --accent-border: rgba(91, 142, 201, 0.4);
  --accent-2-border: rgba(123, 143, 219, 0.35);
  --on-accent: #f4f8fc;
  --btn-primary-from: #6b9ed4;
  --btn-primary-to: #5b8ec9;
  --btn-primary-text: #0f2438;
  --header-bg: rgba(242, 245, 249, 0.82);
  --nav-menu-bg: rgba(255, 255, 255, 0.98);
  --tag-text: #4a5a9e;
  --tag-border: rgba(123, 143, 219, 0.28);
  --surface-hover: rgba(91, 142, 201, 0.06);
  --tech-bg: rgba(91, 142, 201, 0.06);
  --glow-1: rgba(123, 143, 219, 0.22);
  --glow-2: rgba(91, 142, 201, 0.16);
  --timeline-line: rgba(91, 142, 201, 0.4);
  --timeline-ring: rgba(91, 142, 201, 0.2);
  --shadow: 0 14px 40px rgba(30, 42, 58, 0.08);
  --swatch-mist: #a8c4e0;
  --swatch-cream: #f0d4b8;
  --swatch-sage: #b5d4c0;
  --radius: 14px;
  --radius-sm: 10px;
  --nav-h: 64px;
  --max: 1080px;
  --font: "DM Sans", system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --theme-transition: background-color 0.25s ease, color 0.25s ease,
    border-color 0.25s ease, box-shadow 0.25s ease, fill 0.25s ease;
}

/* Warm cream / soft peach */
[data-theme="cream"] {
  --bg: #faf6f0;
  --bg-elevated: #ffffff;
  --bg-card: #fffbf7;
  --bg-alt: #f3ebe1;
  --border: rgba(148, 120, 96, 0.22);
  --text: #3a2e26;
  --text-muted: #7a6758;
  --accent: #d4926a;
  --accent-2: #e0a888;
  --accent-soft: rgba(212, 146, 106, 0.16);
  --accent-2-soft: rgba(224, 168, 136, 0.18);
  --accent-hover: #c07850;
  --accent-border: rgba(212, 146, 106, 0.45);
  --accent-2-border: rgba(224, 168, 136, 0.4);
  --on-accent: #fff8f2;
  --btn-primary-from: #e0a888;
  --btn-primary-to: #d4926a;
  --btn-primary-text: #3a2214;
  --header-bg: rgba(250, 246, 240, 0.85);
  --nav-menu-bg: rgba(255, 251, 247, 0.98);
  --tag-text: #9a5c3a;
  --tag-border: rgba(212, 146, 106, 0.32);
  --surface-hover: rgba(212, 146, 106, 0.08);
  --tech-bg: rgba(212, 146, 106, 0.08);
  --glow-1: rgba(224, 168, 136, 0.28);
  --glow-2: rgba(212, 146, 106, 0.16);
  --timeline-line: rgba(212, 146, 106, 0.45);
  --timeline-ring: rgba(212, 146, 106, 0.22);
  --shadow: 0 14px 40px rgba(58, 46, 38, 0.08);
}

/* Soft sage green / mint */
[data-theme="sage"] {
  --bg: #f3f7f4;
  --bg-elevated: #ffffff;
  --bg-card: #fafcf9;
  --bg-alt: #e6efe8;
  --border: rgba(100, 130, 110, 0.22);
  --text: #24332a;
  --text-muted: #5a6e60;
  --accent: #6a9e7e;
  --accent-2: #7eb89a;
  --accent-soft: rgba(106, 158, 126, 0.16);
  --accent-2-soft: rgba(126, 184, 154, 0.16);
  --accent-hover: #528466;
  --accent-border: rgba(106, 158, 126, 0.42);
  --accent-2-border: rgba(126, 184, 154, 0.38);
  --on-accent: #f2faf5;
  --btn-primary-from: #7eb89a;
  --btn-primary-to: #6a9e7e;
  --btn-primary-text: #14281c;
  --header-bg: rgba(243, 247, 244, 0.85);
  --nav-menu-bg: rgba(250, 252, 249, 0.98);
  --tag-text: #3d6b50;
  --tag-border: rgba(106, 158, 126, 0.3);
  --surface-hover: rgba(106, 158, 126, 0.08);
  --tech-bg: rgba(106, 158, 126, 0.08);
  --glow-1: rgba(126, 184, 154, 0.24);
  --glow-2: rgba(106, 158, 126, 0.16);
  --timeline-line: rgba(106, 158, 126, 0.42);
  --timeline-ring: rgba(106, 158, 126, 0.2);
  --shadow: 0 14px 40px rgba(36, 51, 42, 0.08);
}

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

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--nav-h) + 12px);
}

body {
  margin: 0;
  font-family: var(--font);
  font-size: 1.05rem;
  line-height: 1.65;
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 10% -10%, var(--glow-1), transparent 55%),
    radial-gradient(900px 500px at 90% 0%, var(--glow-2), transparent 50%),
    var(--bg);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  transition: var(--theme-transition);
}

img {
  max-width: 100%;
  display: block;
}

a {
  color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
  transition: color 0.2s var(--ease), opacity 0.2s var(--ease);
}

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

a:focus-visible,
button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

code {
  font-family: var(--mono);
  font-size: 0.88em;
  background: var(--accent-soft);
  color: var(--accent);
  padding: 0.12em 0.4em;
  border-radius: 6px;
}

.skip-link {
  position: absolute;
  left: 1rem;
  top: -100px;
  z-index: 1000;
  background: var(--accent);
  color: var(--btn-primary-text);
  padding: 0.6rem 1rem;
  border-radius: 8px;
  font-weight: 600;
  text-decoration: none;
}

.skip-link:focus {
  top: 1rem;
}

.container {
  width: min(100% - 2rem, var(--max));
  margin-inline: auto;
}

/* ---------- Header / Nav ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--nav-h);
  backdrop-filter: blur(14px);
  background: var(--header-bg);
  border-bottom: 1px solid var(--border);
  transition: var(--theme-transition);
}

.nav {
  width: min(100% - 2rem, var(--max));
  margin-inline: auto;
  height: var(--nav-h);
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 0.75rem;
}

.nav-brand {
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: 0.04em;
  text-decoration: none;
  width: 2.4rem;
  height: 2.4rem;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: var(--btn-primary-text);
  margin-right: auto;
  flex-shrink: 0;
  transition: var(--theme-transition);
}

.nav-menu {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  align-items: center;
  gap: 0.25rem 1.1rem;
}

.nav-menu a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.95rem;
  font-weight: 500;
  padding: 0.35rem 0;
  transition: color 0.2s var(--ease);
}

.nav-menu a:hover,
.nav-menu a.active {
  color: var(--text);
}

.nav-cta {
  padding: 0.45rem 0.9rem !important;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent) !important;
  border: 1px solid var(--accent-border);
  transition: var(--theme-transition);
}

.nav-cta:hover {
  background: var(--accent-soft);
  filter: brightness(0.97);
  color: var(--accent-hover) !important;
}

/* Theme picker — compact segmented control */
.theme-picker {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  flex-shrink: 0;
  transition: var(--theme-transition);
}

.theme-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin: 0;
  padding: 0.28rem 0.55rem;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: pointer;
  line-height: 1;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.theme-btn:hover {
  color: var(--text);
  background: var(--surface-hover);
}

.theme-btn.is-active,
.theme-btn[aria-pressed="true"] {
  background: var(--accent-soft);
  color: var(--accent);
}

.theme-swatch {
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.12);
  flex-shrink: 0;
}

.theme-btn[data-theme-set="mist"] .theme-swatch {
  background: var(--swatch-mist);
}

.theme-btn[data-theme-set="cream"] .theme-swatch {
  background: var(--swatch-cream);
}

.theme-btn[data-theme-set="sage"] .theme-swatch {
  background: var(--swatch-sage);
}

.theme-label {
  display: none;
}

@media (min-width: 900px) {
  .theme-label {
    display: inline;
  }
}

.nav-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 2.5rem;
  height: 2.5rem;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-elevated);
  cursor: pointer;
  flex-shrink: 0;
  transition: var(--theme-transition);
}

.nav-toggle-bar {
  display: block;
  width: 1.1rem;
  height: 2px;
  margin-inline: auto;
  background: var(--text);
  border-radius: 2px;
  transition: transform 0.25s var(--ease), opacity 0.2s, background-color 0.25s ease;
}

.nav-toggle[aria-expanded="true"] .nav-toggle-bar:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}
.nav-toggle[aria-expanded="true"] .nav-toggle-bar:nth-child(2) {
  opacity: 0;
}
.nav-toggle[aria-expanded="true"] .nav-toggle-bar:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

/* ---------- Hero ---------- */
.hero {
  padding: clamp(3.5rem, 10vw, 6.5rem) 0 clamp(3rem, 8vw, 5rem);
}

.hero-inner {
  max-width: 44rem;
}

.hero-eyebrow {
  margin: 0 0 0.75rem;
  font-family: var(--mono);
  font-size: 0.85rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
}

.hero h1 {
  margin: 0 0 0.5rem;
  font-size: clamp(2.2rem, 6vw, 3.35rem);
  line-height: 1.12;
  letter-spacing: -0.03em;
  font-weight: 700;
}

.hero-role {
  margin: 0 0 1.1rem;
  font-size: clamp(1.15rem, 2.5vw, 1.4rem);
  font-weight: 600;
  color: var(--accent-2);
}

.hero-tagline {
  margin: 0 0 1.75rem;
  color: var(--text-muted);
  font-size: 1.08rem;
  max-width: 38rem;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.7rem 1.25rem;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.98rem;
  text-decoration: none;
  border: 1px solid transparent;
  transition: transform 0.2s var(--ease), background 0.25s ease, border-color 0.25s ease,
    color 0.25s ease, filter 0.2s;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn-primary {
  background: linear-gradient(135deg, var(--btn-primary-from), var(--btn-primary-to));
  color: var(--btn-primary-text);
}

.btn-primary:hover {
  color: var(--btn-primary-text);
  filter: brightness(1.04);
}

.btn-ghost {
  background: transparent;
  color: var(--text);
  border-color: var(--border);
}

.btn-ghost:hover {
  border-color: var(--accent-border);
  background: var(--surface-hover);
  color: var(--text);
}

/* ---------- Sections ---------- */
.section {
  padding: clamp(3rem, 7vw, 4.5rem) 0;
}

.section-alt {
  background: var(--bg-alt);
  border-block: 1px solid var(--border);
  transition: var(--theme-transition);
}

.section h2 {
  margin: 0 0 0.5rem;
  font-size: clamp(1.6rem, 3.5vw, 2rem);
  letter-spacing: -0.02em;
}

.section h2::after {
  content: "";
  display: block;
  width: 2.5rem;
  height: 3px;
  margin-top: 0.65rem;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
}

.section-lead {
  margin: 0.85rem 0 1.75rem;
  color: var(--text-muted);
  max-width: 40rem;
}

/* About */
.about-grid {
  display: grid;
  gap: 1.5rem;
  margin-top: 1.5rem;
}

.about-copy p {
  margin: 0 0 1rem;
  color: var(--text-muted);
}

.about-copy p:last-child {
  margin-bottom: 0;
}

.about-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.35rem;
  box-shadow: var(--shadow);
  transition: var(--theme-transition);
}

.about-card h3 {
  margin: 0 0 0.75rem;
  font-size: 1rem;
  color: var(--accent);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.about-card ul {
  margin: 0;
  padding-left: 1.1rem;
  color: var(--text-muted);
}

.about-card li + li {
  margin-top: 0.4rem;
}

@media (min-width: 800px) {
  .about-grid {
    grid-template-columns: 1.6fr 1fr;
    align-items: start;
  }
}

/* Skills */
.skills-grid {
  display: grid;
  gap: 1rem;
  margin-top: 1.5rem;
  grid-template-columns: 1fr;
}

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

.skill-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.2rem 1.25rem;
  transition: border-color 0.25s var(--ease), transform 0.2s var(--ease),
    background-color 0.25s ease, box-shadow 0.25s ease;
}

.skill-card:hover {
  border-color: var(--accent-border);
  transform: translateY(-2px);
}

.skill-card h3 {
  margin: 0 0 0.85rem;
  font-size: 1rem;
  color: var(--text);
}

.skill-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  list-style: none;
  margin: 0;
  padding: 0;
}

.skill-tags li {
  font-size: 0.88rem;
  font-weight: 500;
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  background: var(--accent-2-soft);
  color: var(--tag-text);
  border: 1px solid var(--tag-border);
  transition: var(--theme-transition);
}

/* Projects */
.projects-grid {
  display: grid;
  gap: 1.1rem;
  grid-template-columns: 1fr;
}

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

.project-card {
  display: flex;
  flex-direction: column;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.35rem 1.4rem;
  box-shadow: var(--shadow);
  transition: border-color 0.25s var(--ease), transform 0.2s var(--ease),
    background-color 0.25s ease, box-shadow 0.25s ease;
}

.project-card:hover {
  border-color: var(--accent-2-border);
  transform: translateY(-3px);
}

.project-card h3 {
  margin: 0 0 0.55rem;
  font-size: 1.15rem;
  letter-spacing: -0.01em;
}

.project-card p {
  margin: 0 0 1rem;
  color: var(--text-muted);
  flex: 1;
  font-size: 0.98rem;
}

.project-tech {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  list-style: none;
  margin: 0 0 1.1rem;
  padding: 0;
}

.project-tech li {
  font-family: var(--mono);
  font-size: 0.75rem;
  padding: 0.28rem 0.55rem;
  border-radius: 6px;
  background: var(--tech-bg);
  color: var(--text-muted);
  border: 1px solid var(--border);
  transition: var(--theme-transition);
}

.project-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.85rem;
  margin-top: auto;
}

.project-links a {
  font-weight: 600;
  font-size: 0.92rem;
  text-decoration: none;
}

.project-links a::after {
  content: " →";
  opacity: 0.7;
}

/* Experience timeline */
.timeline {
  list-style: none;
  margin: 1.5rem 0 0;
  padding: 0;
  border-left: 2px solid var(--timeline-line);
}

.timeline-item {
  position: relative;
  padding: 0 0 1.75rem 1.4rem;
}

.timeline-item:last-child {
  padding-bottom: 0;
}

.timeline-item::before {
  content: "";
  position: absolute;
  left: -0.45rem;
  top: 0.35rem;
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px var(--timeline-ring);
  transition: background-color 0.25s ease, box-shadow 0.25s ease;
}

.timeline-period {
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--accent);
  margin: 0 0 0.25rem;
}

.timeline-item h3 {
  margin: 0 0 0.15rem;
  font-size: 1.1rem;
}

.timeline-company {
  margin: 0 0 0.65rem;
  color: var(--text-muted);
  font-weight: 500;
}

.timeline-company.is-placeholder {
  color: #c9892a;
  font-style: italic;
}

.timeline-item ul {
  margin: 0;
  padding-left: 1.15rem;
  color: var(--text-muted);
}

.timeline-item li + li {
  margin-top: 0.35rem;
}

/* Contact */
.contact-section {
  text-align: center;
}

.contact-inner {
  max-width: 36rem;
}

.contact-cta {
  color: var(--text-muted);
  font-size: 1.1rem;
  margin: 1rem 0 1.5rem;
}

.contact-links {
  list-style: none;
  margin: 0 0 1.5rem;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.75rem 1.25rem;
}

.contact-links a {
  font-weight: 600;
  text-decoration: none;
  color: var(--text);
  padding: 0.5rem 0.9rem;
  border-radius: 999px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  transition: var(--theme-transition);
}

.contact-links a:hover {
  border-color: var(--accent-border);
  color: var(--accent);
}

/* Footer */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 1.5rem 0 2rem;
  color: var(--text-muted);
  font-size: 0.92rem;
  transition: var(--theme-transition);
}

.footer-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.footer-inner p {
  margin: 0;
}

.back-top {
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 500;
}

.back-top:hover {
  color: var(--accent);
}

/* Mobile nav */
@media (max-width: 760px) {
  .theme-picker {
    order: 2;
  }

  .nav-toggle {
    display: flex;
    order: 3;
  }

  .nav-menu {
    order: 4;
    position: fixed;
    inset: var(--nav-h) 0 auto 0;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding: 0.75rem 1rem 1rem;
    background: var(--nav-menu-bg);
    border-bottom: 1px solid var(--border);
    transform: translateY(-120%);
    opacity: 0;
    pointer-events: none;
    transition: transform 0.3s var(--ease), opacity 0.25s, background-color 0.25s ease;
    backdrop-filter: blur(12px);
  }

  .nav-menu.is-open {
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
  }

  .nav-menu a {
    display: block;
    padding: 0.85rem 0.5rem;
    border-bottom: 1px solid var(--border);
  }

  .nav-cta {
    margin-top: 0.5rem;
    text-align: center;
    border-bottom: none !important;
  }

  /* Keep theme picker readable on narrow screens: swatches only */
  .theme-btn {
    padding: 0.32rem 0.4rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}
