/* ---------- โหมดสว่าง ---------- */
:root {
  color-scheme: light;
  /* สีน้ำเงินจากภาพพื้นหลังที่ส่งมา */
  --navy: #111e3c;
  --text: var(--navy);
  --text-soft: #3a4a6b;
  /* สีกรมท่าอ่อนของข้อความที่ไม่ใช่หัวข้อ */
  --text-muted: #4a5878;
  --footer: var(--text-soft);
  --bg: #ffffff;
  --surface: #ffffff;
  --border: #e6e9f0;
  --border-hover: #cfd5e3;
  --hover: #f5f7fb;
  --icon-bg: var(--navy);
  --icon-fg: #ffffff;
  --shadow: rgba(17, 30, 60, .08);
  --radius: 16px;
}

/* ---------- โหมดมืด (สีจากภาพตัวอย่างโหมดมืด) ---------- */
:root[data-theme="dark"] {
  color-scheme: dark;
  --text: #eef2fa;
  --text-soft: #8a93a6;
  --text-muted: #a1a1a1;
  --footer: var(--text);
  --bg: #0a0a0a;
  --surface: #121212;
  --border: #262626;
  --border-hover: #3a3a3a;
  --hover: #1a1a1a;
  --icon-bg: #e6ecf8;
  --icon-fg: var(--navy);
  --shadow: rgba(0, 0, 0, .5);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: "Google Sans", "Noto Sans Thai", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  transition: background .2s, color .2s;
}

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

/* ---------- Top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 24px 40px;
}


.actions {
  display: flex;
  gap: 10px;
}

.tool-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 44px;
  min-width: 44px;
  padding: 0 16px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 12px;
  font: 600 14px "Google Sans", sans-serif;
  cursor: pointer;
  transition: background .15s;
}
.tool-btn:hover { background: var(--hover); }

/* ธงภาษา: แสดงธงตามภาษาที่เลือกอยู่ */
.flag {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}
.flag-en,
html[lang="en"] .flag-th { display: none; }
html[lang="en"] .flag-en { display: block; }

.theme-btn { padding: 0; }
.theme-btn svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
/* โหมดสว่างแสดงรูปพระจันทร์ โหมดมืดแสดงรูปพระอาทิตย์ */
.theme-btn .sun,
[data-theme="dark"] .theme-btn .moon { display: none; }
[data-theme="dark"] .theme-btn .sun { display: block; }

/* ---------- Layout ---------- */
.container {
  max-width: 760px;
  margin: 0 auto;
  padding: 40px 16px 64px;
}

section + section { margin-top: 48px; }

h2 {
  font-size: 17px;
  font-weight: 700;
  margin-bottom: 16px;
}

/* ---------- Profile ---------- */
.profile {
  position: relative;
  display: flex;
  align-items: center;
  gap: 24px;
}

.avatar {
  width: 156px;
  height: 156px;
  flex-shrink: 0;
  object-fit: cover;
  object-position: 50% 25%;
  border-radius: 20px;
  box-shadow: 0 4px 16px var(--shadow);
}

.info h1 {
  font-size: 34px;
  font-weight: 700;
  line-height: 1.15;
  margin-bottom: 10px;
}

.meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 16px;
  font-weight: 400;
  color: var(--text-muted);
  line-height: 1.4;
}
.meta + .meta { margin-top: 6px; }
.meta a:hover { text-decoration: underline; }

.meta svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  fill: none;
  stroke: var(--text);
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ปุ่มหลัก: สีกลับกันตามโหมดเหมือนกล่องไอคอน */
.primary-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 16px;
  padding: 11px 20px;
  background: var(--icon-bg);
  color: var(--icon-fg);
  border-radius: 12px;
  font-size: 15px;
  font-weight: 700;
  box-shadow: 0 4px 12px var(--shadow);
  transition: transform .15s, box-shadow .15s;
}
.primary-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px var(--shadow);
}
.primary-btn svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform .2s;
}
.primary-btn:hover svg { transform: translateX(3px); }

/* ปุ่มที่ยังกดไม่ได้ */
.primary-btn.is-disabled {
  opacity: .55;
  cursor: default;
  box-shadow: none;
}
.primary-btn.is-disabled:hover { transform: none; box-shadow: none; }
.soon {
  padding: 2px 8px;
  border-radius: 999px;
  background: color-mix(in srgb, currentColor 18%, transparent);
  font-size: 12px;
  font-weight: 600;
}

/* ---------- โน้ตบุ๊กตกแต่ง ---------- */
/* กล่องนอกลอยขึ้นลง ส่วนรูปข้างในเอียง แยกกันเพื่อให้สองท่าไม่ทับกัน */
.laptop {
  position: absolute;
  top: 58px;
  right: 4px;
  width: 160px;
  pointer-events: none;
  animation: laptop-float 3.2s ease-in-out infinite;
}

.laptop svg {
  display: block;
  width: 100%;
  height: auto;
  transform: rotate(-10deg);
  filter: drop-shadow(0 10px 14px var(--shadow));
}

@keyframes laptop-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

@media (prefers-reduced-motion: reduce) {
  .laptop { animation: none; }
}

/* จอขนาดกลาง ชื่อยาวจะชนโน้ตบุ๊ก เลยซ่อนไว้ */
@media (min-width: 601px) and (max-width: 860px) {
  .laptop { display: none; }
}

/* ---------- Link cards ---------- */
.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.card {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 82px;
  padding: 16px 72px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 1px 2px var(--shadow);
  font-size: 17px;
  font-weight: 700;
  text-align: center;
  transition: transform .15s, box-shadow .15s, border-color .15s, background .2s;
}
.card:hover {
  transform: translateY(-2px);
  border-color: var(--border-hover);
  box-shadow: 0 8px 20px var(--shadow);
}

.card.wide { grid-column: 1 / -1; }

.icon {
  position: absolute;
  left: 22px;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--icon-bg);
  /* เด้งนิด ๆ ตอนเอียง */
  transition: transform .4s cubic-bezier(.34, 1.56, .64, 1);
}

/* เอาเมาส์ชี้การ์ดแล้วไอคอนเอียง */
.card:hover .icon { transform: rotate(-12deg) scale(1.1); }

@media (prefers-reduced-motion: reduce) {
  .icon { transition: none; }
  .card:hover .icon { transform: none; }
}

/* โลโก้แบรนด์: ใช้สีจริงของแต่ละแบรนด์ ไม่ใช้กล่องสีน้ำเงิน */
.icon.brand {
  background: none;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, .15));
}
.icon.brand svg {
  width: 100%;
  height: 100%;
  stroke: none;
}

.icon svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: var(--icon-fg);
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.icon svg .fill { fill: var(--icon-fg); stroke: none; }

.footer {
  text-align: center;
  padding: 0 16px 32px;
  font-size: 13px;
  color: var(--footer);
}

/* ---------- หน้าประวัติส่วนตัวและผลงาน ---------- */
.topbar.split { justify-content: space-between; }
.back-btn svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.page-head {
  display: flex;
  align-items: center;
  gap: 20px;
}
.page-head .avatar { width: 96px; height: 96px; border-radius: 16px; }
.page-head h1 {
  font-size: 30px;
  font-weight: 700;
  line-height: 1.2;
  margin-bottom: 6px;
}

.lead {
  font-size: 16px;
  line-height: 1.75;
  color: var(--text-muted);
}

.skills {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}
.skill {
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 1px 2px var(--shadow);
}
.skill .icon { position: static; margin-bottom: 14px; }
.skill:hover .icon { transform: rotate(-12deg) scale(1.1); }
.skill h3 { font-size: 16px; font-weight: 700; margin-bottom: 6px; }
.skill p { font-size: 14px; line-height: 1.6; color: var(--text-muted); }

/* รายชื่อเครื่องมือในการ์ด */
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}
.chips .tag { margin-top: 0; }

/* เส้นเวลาประสบการณ์ */
/* จุดกับเส้นวาดจากจุดศูนย์กลางเดียวกัน (x = 7px) เส้นเชื่อมจากจุดหนึ่งไปจุดถัดไปเท่านั้น */
.timeline { list-style: none; }
.timeline li { position: relative; padding: 0 0 28px 32px; }
.timeline li:last-child { padding-bottom: 0; }
.timeline li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 4px;
  /* ::before ไม่โดนกฎ * ด้านบน ต้องใส่เอง ไม่งั้นขอบจะดันจุดกว้างเป็น 18px แล้วเส้นเยื้อง */
  box-sizing: border-box;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--surface);
  border: 2px solid var(--text);
}
/* รายการล่าสุดเป็นจุดทึบ */
.timeline li:first-child::before { background: var(--text); }
.timeline li::after {
  content: "";
  position: absolute;
  left: 6px;
  top: 20px;
  bottom: -2px;
  width: 2px;
  border-radius: 1px;
  background: var(--border-hover);
}
.timeline li:last-child::after { display: none; }
.when { font-size: 13px; font-weight: 600; color: var(--text-muted); }
.role { font-size: 16px; font-weight: 700; margin: 2px 0 4px; }
.timeline p { font-size: 14px; line-height: 1.6; color: var(--text-muted); }

/* การ์ดผลงาน */
.works {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.work {
  display: block;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 1px 2px var(--shadow);
  transition: transform .15s, box-shadow .15s, border-color .15s;
}
.work:hover {
  transform: translateY(-2px);
  border-color: var(--border-hover);
  box-shadow: 0 8px 20px var(--shadow);
}
/* พื้นภาพตัวอย่าง ใช้สีเดียวกับจอโน้ตบุ๊ก ใส่ <img> แทน svg ได้เมื่อมีภาพจริง */
.work-thumb {
  display: grid;
  place-items: center;
  aspect-ratio: 16 / 10;
  background: linear-gradient(135deg, #0b3156, #0d2441);
}
.work-thumb img { width: 100%; height: 100%; object-fit: cover; }
.work-thumb svg {
  width: 40px;
  height: 40px;
  fill: none;
  stroke: rgba(255, 255, 255, .55);
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.work-body { padding: 16px 18px 18px; }
.work h3 { font-size: 16px; font-weight: 700; }
.work p { margin-top: 4px; font-size: 14px; line-height: 1.6; color: var(--text-muted); }
.tag {
  display: inline-block;
  margin-top: 12px;
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--hover);
  font-size: 12px;
  font-weight: 600;
}

.cta {
  padding: 32px 20px;
  text-align: center;
  background: var(--hover);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.cta h2 { margin-bottom: 6px; }
.cta p { font-size: 15px; color: var(--text-muted); }

/* ---------- Mobile ---------- */
@media (max-width: 600px) {
  .topbar { padding: 16px; }

  .container { padding-top: 16px; }

  .profile {
    flex-direction: column;
    text-align: center;
  }
  .avatar { width: 128px; height: 128px; }
  /* มือถือ: ย่อแล้ววางข้างรูปโปรไฟล์ */
  .laptop { top: 34px; right: 0; width: 88px; }
  .info h1 { font-size: 28px; }
  /* ย่อนิดให้ตำแหน่งงานอยู่บรรทัดเดียวบนมือถือ */
  .meta { justify-content: center; font-size: 14px; }

  .grid { grid-template-columns: 1fr; }
  .card { min-height: 68px; font-size: 16px; }
  .icon { left: 14px; width: 40px; height: 40px; }

  .page-head .avatar { width: 72px; height: 72px; }
  .page-head h1 { font-size: 22px; }
  .page-head .meta { justify-content: flex-start; }
  .skills, .works { grid-template-columns: 1fr; }
}
