/* ============ ตัวแปรธีม ============ */
:root {
  --bg: #eef0f3;
  --card: #ffffff;
  --sidebar: #f6f7f9;
  --text: #1e293b;
  --muted: #64748b;
  --accent: #475569;
  --accent-soft: #e8ebef;
  --line: #e4e7ec;
  --header-from: #1e293b;
  --header-to: #0f172a;
  --bg-line: rgba(71, 85, 105, 0.06);
  --shadow: 0 10px 40px rgba(15, 23, 42, 0.10);
}
[data-theme="dark"] {
  --bg: #0b1120;
  --card: #131a26;
  --sidebar: #0f1626;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --accent: #cbd5e1;
  --accent-soft: #1f2a3d;
  --line: #26324a;
  --header-from: #1e293b;
  --header-to: #0b1120;
  --bg-line: rgba(148, 163, 184, 0.06);
  --shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

/* ============ พื้นฐาน ============ */
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: "Sarabun", "Segoe UI", Tahoma, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
  padding: 32px 16px;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ============ พื้นหลังลายเส้นจางๆ แบบนิ่ง (หลังกล่องเนื้อหา) ============ */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-image:
    repeating-linear-gradient(45deg, var(--bg-line) 0 1px, transparent 1px 40px),
    repeating-linear-gradient(-45deg, var(--bg-line) 0 1px, transparent 1px 40px);
}

/* ============ แถบเครื่องมือ ============ */
.toolbar {
  max-width: 860px;
  margin: 0 auto 16px;
  display: flex;
  gap: 10px;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
}
.toolbar__actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.toolbar button {
  padding: 9px 16px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text);
  border-radius: 8px;
  cursor: pointer;
  font: inherit;
  font-size: 14px;
  transition: border-color .15s, transform .05s;
}
.toolbar button:hover { border-color: var(--accent); }
.toolbar button:active { transform: translateY(1px); }
.toolbar button:disabled { opacity: .6; cursor: default; }
.views {
  align-self: center;
  font-size: 13px;
  color: var(--muted);
}
/* เมนูนำทาง (เรซูเม่ / ผลงาน) — อยู่ทั้งสองหน้า */
.nav { display: flex; gap: 4px; }
.nav__link {
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  text-decoration: none;
  padding: 8px 14px;
  border-radius: 8px;
  transition: color .15s, background .15s;
}
.nav__link:hover { color: var(--text); background: var(--accent-soft); }
.nav__link--active,
.nav__link--active:hover {
  color: var(--card);
  background: var(--accent);
}

/* ============ หน้ากระดาษ ============ */
.page {
  max-width: 860px;
  margin: 0 auto;
  background: var(--card);
  border-radius: 14px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

/* ============ กริด 2 คอลัมน์ ============ */
/* DOM เรียง content (H1) มาก่อน sidebar เพื่อ SEO — แต่ใช้ grid-areas
   จัดให้ sidebar อยู่ซ้าย content อยู่ขวาเหมือนเดิม */
.grid {
  display: grid;
  grid-template-columns: 280px 1fr;
  grid-template-areas: "side main";
  align-items: start;
}
.sidebar {
  grid-area: side;
  background: var(--sidebar);
  border-right: 1px solid var(--line);
}
.content { grid-area: main; }
.sidebar__body { padding: 26px 24px; }

/* รูปโปรไฟล์เต็มความกว้างคอลัมน์ */
.photo {
  display: block;
  width: 100%;
  height: 340px;
  object-fit: cover;
  object-position: top center;
}

.content { padding: 0 0 32px; }

/* ============ แถบหัว: ชื่อ + ตำแหน่ง ============ */
.namebar {
  padding: 30px 34px;
  margin-bottom: 28px;
  background: linear-gradient(135deg, var(--header-from), var(--header-to));
  color: #fff;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}
.namebar__name { font-size: 30px; font-weight: 700; letter-spacing: .5px; }
.namebar__role { font-size: 16px; font-weight: 600; opacity: .95; margin: 4px 0 10px; }
.namebar__meta {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.namebar__meta li {
  font-size: 12.5px;
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.25);
  padding: 3px 10px;
  border-radius: 999px;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}
.namebar__metakey { opacity: .8; margin-right: 3px; }
.namebar__objective {
  margin-top: 14px;
  font-size: 13.5px;
  line-height: 1.6;
  opacity: .95;
  max-width: 58ch;
}
.namebar__seeking {
  font-weight: 700;
  color: #fff;
  opacity: 1;
}
.namebar__summary { font-size: 13.5px; opacity: .92; max-width: 54ch; }

/* padding ด้านข้างให้เนื้อหาคอลัมน์ขวา (ยกเว้นแถบหัวที่เต็มขอบ) */
.content > .block { padding-left: 34px; padding-right: 34px; }

/* ============ บล็อกหัวข้อ ============ */
.block { margin-bottom: 26px; }
.block:last-child { margin-bottom: 0; }
.block__title {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--accent);
  margin-bottom: 14px;
  padding-bottom: 6px;
  border-bottom: 2px solid var(--accent-soft);
}

/* ============ จุดมุ่งหมายการทำงาน ============ */
.objective { font-size: 13.5px; color: var(--muted); line-height: 1.7; }

/* ============ ติดต่อ ============ */
.contact { list-style: none; font-size: 14px; }
.contact li { display: flex; align-items: baseline; gap: 9px; margin-bottom: 8px; word-break: break-word; }
.contact__ico {
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  width: 38px;
  flex: 0 0 auto;
}

/* ============ โปรแกรม & เครื่องมือ (กริดโลโก้) ============ */
.tools-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px 8px;
}
.toolcell {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  text-align: center;
  cursor: help;
}
.toolcell__logo {
  width: 46px;
  height: 46px;
  border-radius: 10px;
  background: #ffffff;
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
  padding: 6px;
  transition: transform .18s ease, box-shadow .18s ease;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}
.toolcell:hover .toolcell__logo {
  transform: translateY(-3px);
  box-shadow: 0 6px 14px rgba(30, 41, 59, .15);
}
.toolcell__logo img { max-width: 100%; max-height: 100%; object-fit: contain; }
.toolcell__name { font-size: 11px; color: var(--muted); line-height: 1.3; }

/* ============ ใบรับรอง ============ */
.certs { list-style: none; }
.certs li {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 9px;
  font-size: 14px;
}
.certs li:last-child { margin-bottom: 0; }
.cert__name { line-height: 1.35; }
.cert__links { flex: 0 0 auto; white-space: nowrap; font-size: 12px; font-weight: 600; }

/* ============ การศึกษา / ภาษา ============ */
.edu__deg { font-weight: 600; }
.edu__meta, .plain li { font-size: 14px; color: var(--muted); }
.plain { list-style: none; }
.plain li { margin-bottom: 4px; }

/* ============ ประสบการณ์ทำงาน — ไทม์ไลน์ ============ */
.item {
  display: grid;
  grid-template-columns: 86px 1fr;
  column-gap: 18px;
}
.item__date {
  grid-column: 1;
  text-align: right;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  padding-top: 1px;
}
.item__ago {
  display: block;
  margin-top: 2px;
  font-size: 10.5px;
  font-weight: 400;
  color: var(--muted);
  white-space: normal;
  line-height: 1.35;
}
.item__body {
  grid-column: 2;
  position: relative;
  padding-left: 22px;
  padding-bottom: 22px;
  border-left: 2px solid var(--line);
}
.item:last-child .item__body { padding-bottom: 0; }
/* เพชร ◆ บนเส้นไทม์ไลน์ */
.item__body::before {
  content: "";
  position: absolute;
  left: -8px;
  top: 3px;
  width: 13px;
  height: 13px;
  background: var(--accent);
  border: 3px solid var(--card);
  transform: rotate(45deg);
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}
/* แถวรูปตัวอย่างงาน (เหนือชื่อตำแหน่ง) */
.item__samples {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}
.item__samples a { display: block; line-height: 0; }
.item__samples img {
  height: 100px;
  width: auto;
  max-width: 100%;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--line);
  transition: transform .15s, box-shadow .15s;
}
.item__samples a:hover img {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(30, 41, 59, .15);
}
/* ภาพแค็ปเจอร์หน้าเว็บ (เต็มหน้ายาว) — แสดงเป็นแนวนอนโชว์ส่วนหัว */
.item__samples img.shot {
  width: 165px;
  height: 100px;
  object-position: top center;
}
.item__title { font-size: 16px; font-weight: 600; }
.item__org { color: var(--accent); font-size: 14px; font-weight: 600; margin: 1px 0 7px; }
.item__note {
  display: inline-block;
  font-size: 12px;
  color: var(--muted);
  background: var(--accent-soft);
  border-radius: 5px;
  padding: 1px 8px;
  margin: 0 0 6px;
}
.item__points { list-style: none; padding-left: 12px; font-size: 14px; margin: 0; }
.item__points li { position: relative; padding-left: 13px; margin-bottom: 3px; }
.item__points li::before {
  content: "–";
  position: absolute;
  left: 0;
  color: var(--muted);
}

/* หัวข้อ/ลิงก์การ์ดผลงาน (Portfolio) ใช้ item__head แยกจากไทม์ไลน์ */
.item__head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}
.item__desc { font-size: 14px; color: var(--muted); margin-bottom: 8px; }

/* หมวดย่อยในงาน (H4 โทนเดียวสม่ำเสมอ) + bullet ซ้อน */
.cats { margin-top: 2px; }
.cat {
  font-size: 14px;
  font-weight: 700;
  color: var(--accent);
  margin: 10px 0 4px;
  padding-left: 10px;
  border-left: 3px solid currentColor;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}
.sublist { list-style: none; padding-left: 12px; margin: 0; font-size: 14px; }
.sublist li {
  position: relative;
  padding-left: 13px;
  margin-bottom: 2px;
}
.sublist li::before {
  content: "–";
  position: absolute;
  left: 0;
  color: var(--muted);
}

/* ============ จุดแข็งที่ส่งมอบให้องค์กร ============ */
.highlights { list-style: none; }
.highlights li {
  position: relative;
  padding-left: 20px;
  margin-bottom: 10px;
  font-size: 14px;
  line-height: 1.6;
}
.highlights li:last-child { margin-bottom: 0; }
.highlights li::before {
  content: "›";
  position: absolute;
  left: 2px;
  top: -1px;
  color: var(--accent);
  font-weight: 700;
  font-size: 16px;
}
.highlights strong { color: var(--text); }

/* ============ ความเชี่ยวชาญ ============ */
.expertise {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}
.exp__title {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 2px;
  padding-left: 10px;
  border-left: 3px solid var(--accent);
}
.exp__desc { font-size: 13px; color: var(--muted); line-height: 1.5; padding-left: 10px; }

/* ============ Portfolio ============ */
.portfolio__note { font-size: 13px; color: var(--muted); margin: -6px 0 14px; }
.pf-morelink {
  display: inline-block;
  margin-top: 14px;
  font-size: 14px;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
}
.pf-morelink:hover { text-decoration: underline; }
.projects { display: grid; gap: 16px; }
.project {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px 18px;
  transition: border-color .15s, box-shadow .15s;
}
.project:hover { border-color: var(--accent); box-shadow: 0 4px 16px rgba(30, 41, 59, .12); }
.project__link { font-size: 13px; font-weight: 600; white-space: nowrap; }

/* ============ tags ============ */
.tags { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; }
.tags li {
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 999px;
}

/* ============ หน้า Portfolio แยก ============ */
.backlink {
  font-size: 14px;
  color: var(--text);
  text-decoration: none;
  padding: 9px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card);
}
.backlink:hover { border-color: var(--accent); text-decoration: none; }
.toolbar .backlink { margin-right: auto; }

.pf {
  max-width: 860px;
  margin: 0 auto;
  background: var(--card);
  border-radius: 14px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.pf-hero {
  padding: 40px 40px 32px;
  background: linear-gradient(135deg, var(--header-from), var(--header-to));
  color: #fff;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}
.pf-hero__title { font-size: 30px; font-weight: 700; letter-spacing: .5px; }
.pf-hero__sub { font-size: 15px; opacity: .92; margin-top: 6px; }

.pf-block { padding: 30px 40px; }
.pf-block + .pf-block { padding-top: 6px; }
.pf-block__title {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--accent);
  margin-bottom: 16px;
  padding-bottom: 6px;
  border-bottom: 2px solid var(--accent-soft);
}
.pf-note { font-size: 13.5px; color: var(--muted); margin-bottom: 16px; }

.pf-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; }
.pf-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: border-color .15s, box-shadow .15s;
}
.pf-card:hover { border-color: var(--accent); box-shadow: 0 8px 22px rgba(30, 41, 59, .12); }
.pf-thumb {
  display: grid;
  place-items: center;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  text-align: center;
  background: var(--sidebar);
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
  border-bottom: 1px solid var(--line);
}
.pf-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
  transition: transform .35s ease;
}
.pf-card:hover .pf-thumb img { transform: scale(1.04); }
.pf-card__body { padding: 16px 18px; }
.pf-card__head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}
.pf-card__title { font-size: 17px; font-weight: 700; }
.pf-card__desc { font-size: 13.5px; color: var(--muted); line-height: 1.6; margin-bottom: 10px; }

/* แกลเลอรีตารางรูปผลงาน */
.pf-gallery {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}
.pf-gallery__item {
  display: block;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--sidebar);
}
.pf-gallery__item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform .35s ease;
}
.pf-gallery__item:hover img { transform: scale(1.06); }
/* แกลเลอรีรูปเดียว — แสดงภาพเต็มความกว้าง */
.pf-gallery--single { display: block; }
.pf-gallery--single .pf-gallery__item { aspect-ratio: auto; }
.pf-gallery--single .pf-gallery__item img { height: auto; }
/* แกลเลอรี 3 คอลัมน์ */
.pf-gallery--3 { grid-template-columns: repeat(3, 1fr); }
.pf-gallery--single + .pf-gallery { margin-top: 10px; }
/* หัวข้อย่อยในหมวด */
.pf-subhead {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  margin: 20px 0 10px;
}
.pf-foot { padding: 8px 40px 36px; }

/* ============ Lightbox ============ */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 40px;
  background: rgba(15, 23, 42, 0.92);
}
.lightbox[hidden] { display: none; }
.lightbox__img {
  max-width: 92vw;
  max-height: 86vh;
  object-fit: contain;
  border-radius: 6px;
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.55);
}
.lightbox__close,
.lightbox__nav {
  position: absolute;
  border: none;
  color: #fff;
  background: rgba(255, 255, 255, 0.14);
  cursor: pointer;
  display: grid;
  place-items: center;
  line-height: 1;
  transition: background .15s;
}
.lightbox__close:hover,
.lightbox__nav:hover { background: rgba(255, 255, 255, 0.28); }
.lightbox__close {
  top: 16px;
  right: 18px;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  font-size: 28px;
}
.lightbox__nav {
  top: 50%;
  transform: translateY(-50%);
  width: 50px;
  height: 50px;
  border-radius: 50%;
  font-size: 32px;
}
.lightbox__prev { left: 16px; }
.lightbox__next { right: 16px; }
@media (max-width: 680px) {
  .lightbox { padding: 16px; }
  .lightbox__nav { width: 42px; height: 42px; font-size: 26px; }
}

/* ============ มือถือ ============ */
@media (max-width: 680px) {
  body { padding: 16px 10px; }
  /* จอมือถือ: รวมทุกหมวดเป็นคอลัมน์เดียวแล้วจัดลำดับด้วย order
     (รูป → ชื่อ → ติดต่อ → ที่เหลือตามลำดับความสำคัญ) */
  .grid { display: flex; flex-direction: column; }
  .sidebar, .sidebar__body, .content { display: contents; }
  .photo { order: 0; }
  .namebar { order: 1; }
  .blk-contact { order: 2; }
  .blk-tools { order: 3; }
  .blk-experience { order: 5; }
  .blk-expertise { order: 6; }
  .blk-strengths { order: 7; }
  .blk-education { order: 8; }
  .blk-certificate { order: 9; }
  .blk-language { order: 10; }
  .sidebar .block { padding-left: 22px; padding-right: 22px; }
  .photo { height: 300px; }
  .namebar { padding: 24px 22px; }
  .namebar__summary { max-width: none; }
  .content > .block { padding-left: 22px; padding-right: 22px; }
  .expertise { grid-template-columns: 1fr; }
  .tools-grid { grid-template-columns: repeat(4, 1fr); }
  /* ไทม์ไลน์บนมือถือ: วันที่บรรทัดบน เนื้อหาเต็มกว้าง (เอาเส้น/เพชรออก) */
  .item { display: block; }
  .item + .item { border-top: 1px solid var(--line); padding-top: 16px; }
  .item__date {
    text-align: left;
    font-size: 12px;
    font-weight: 700;
    color: var(--accent);
    margin-bottom: 6px;
  }
  .item__ago { display: inline; margin: 0 0 0 8px; }
  .item__body { border-left: none; padding-left: 0; padding-bottom: 0; }
  .item__body::before { display: none; }
  .item__samples img { height: 88px; }
  .item__samples img.shot { width: 148px; height: 88px; }
  .pf-hero { padding: 28px 22px; }
  .pf-block { padding: 24px 22px; }
  .pf-foot { padding: 4px 22px 28px; }
  .pf-grid { grid-template-columns: 1fr; }
  .pf-gallery { grid-template-columns: repeat(3, 1fr); gap: 8px; }
}

/* ============ Scroll reveal (จางเลื่อนขึ้น) ============ */
/* ซ่อนเฉพาะเมื่อ JS ทำงาน (มีคลาส js-anim) — ถ้า JS ปิด เนื้อหาแสดงครบ */
.js-anim .reveal {
  opacity: 0;
  transform: translateY(16px);
  transition: opacity .55s ease, transform .55s ease;
  will-change: opacity, transform;
}
.js-anim .reveal.is-visible { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) {
  .js-anim .reveal { opacity: 1 !important; transform: none !important; transition: none; }
}

/* ============ ตอนพิมพ์ / PDF ============ */
@media print {
  body { background: #fff; padding: 0; }
  body::before, body::after { display: none; }
  .no-print { display: none; }
  .page { box-shadow: none; border-radius: 0; max-width: 100%; }
  .namebar { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .project { break-inside: avoid; }
  .item { break-inside: avoid; }
  /* แสดงทุกส่วนเต็มตอนพิมพ์ ไม่ให้อนิเมชันซ่อนเนื้อหา */
  .reveal { opacity: 1 !important; transform: none !important; }
}
