:root {
  --page-max-width: 1100px;
  --section-gap: 5px;
  --content-gap: 16px;
  --bg-main: #f8fafc;
  --bg-card: #ffffff;
  --text-main: #0f172a;
  --text-muted: #475569;
  --border-soft: #e2e8f0;
  --accent: #2563eb;       /* blue-600 */
  --accent-soft: #dbeafe;  /* blue-100 */
  --shadow-soft: 0 8px 24px rgba(15, 23, 42, 0.06);

  --border-light: rgba(15,23,42,0.08);

  --radius-sm: 8px;
  --radius-md: 12px;

  --shadow-sm: 0 2px 8px rgba(15,23,42,0.06);
  --shadow-md: 0 10px 30px rgba(15,23,42,0.08);
}

.page {
  max-width: var(--page-max-width);
  padding: 0 24px;
}

.page-container {
  max-width: 1280px;   /* sweet spot */
  margin-left: auto;
  margin-right: auto;
  padding: 0 24px;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;

  background:
    linear-gradient(
      rgba(15, 23, 42, 0.04) 1px,
      transparent 1px
    ),
    linear-gradient(
      90deg,
      rgba(15, 23, 42, 0.04) 1px,
      transparent 1px
    ),
    radial-gradient(
      500px at var(--mx, 50%) var(--my, 50%),
      rgba(37, 99, 235, 0.06),
      transparent 45%
    );

  background-size:
    40px 40px,
    40px 40px,
    auto;

  background-position:
    0 0,
    0 0,
    center;

  animation: grid-drift 40s linear infinite;
  z-index: -1;
  transition: background-position 0.05s ease-out;
}

@keyframes grid-drift {
  from {
    background-position:
      0 0,
      0 0,
      center;
  }
  to {
    background-position:
      40px 40px,
      40px 40px,
      center;
  }
}

@keyframes bg-move {
  from {
    transform: translateY(0);
  }
  to {
    transform: translateY(-40px);
  }
}

.section-hint {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

code, pre {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont,
               "Segoe UI", Roboto, sans-serif;
  line-height: 1.6;
  background: var(--bg-main);
  background-color: var(--bg-main);
  color: var(--text-main);
  line-height: 1.6;
  position: relative;
  overflow-x: hidden;
}

header {
  padding: 32px 0 24px;
}

header h1 {
  font-size: 36px;
  margin-bottom: 8px;
}

header p {
  font-size: 18px;
  color: var(--text-muted);
}

header img {
  border-radius: 50%;
  border: 2px solid var(--border-soft);
  width: 120px;
}

section {
  max-width: 1100px;
  margin: 0 auto;
  padding: 20px 20px;
  margin-bottom: var(--section-gap);
  border-bottom: 1px solid rgba(0,0,0,0.04);
}

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

h1, h2, h3 {
  font-weight: 600;
}

p {
  color: var(--text-muted);
}

section p {
  max-width: 720px;
  margin-top: 8px;
}

section h2 {
  font-size: 26px;
  font-weight: 600;
  padding-bottom: 12px;
  position: relative;
}

section h2::after {
  box-shadow: 0 0 12px rgba(37,99,235,0.35);
  content: '';
  display: block;
  width: 40px;
  height: 3px;
  background: var(--accent);
  margin-top: 6px;
  position: absolute;
  bottom: 0;
  left: 0;
  border-radius: 2px;
}

@media (max-width: 480px) {
  .modal-content {
    max-width: 95%;
    padding: 16px;
  }

  #modal-image {
    max-height: 220px;
    object-fit: contain;
  }

  #modal-title {
    font-size: 1.1rem;
  }

  #modal-issuer,
  #modal-date {
    font-size: 0.9rem;
  }

  .modal-content {
    padding: 16px;
  }

  .modal-image {
    max-height: 45vh;
  }

  section {
    padding: 40px 16px;
  }

  .project-card {
    padding: 14px;
  }
}

@media (max-width: 768px) {
  :root {
    --section-gap: 48px;
  }

  .page {
    padding: 0 16px;
  }
}

@media (min-width: 1600px) {
  .page-container {
    max-width: 1360px;
  }
}

@media (min-width: 1024px) and (max-width: 1366px) {
  .page-container {
    max-width: 1000px;
  }
}

.container {
    padding-left: 20px;
	display: flex; /*บล็อคแนวนอน*/
	align-items: center;       /* จัดแนวตั้ง */
	justify-content: left; /* กระจายแนวนอน */
	gap: 30px;
    margin: auto;
}

.container-aboutme, .container-cer, .container-project, footer{
    padding-left: 20px;
}

#contact {
    margin: auto;
    display: flex;
    justify-content: space-evenly;
    gap: 30px;
    padding: 20px;
    list-style: none;
    align-items: center;
}

#contact i{
    width: auto;
    height: auto;
}

#cer-type {
    display: flex;
    list-style: none;
    gap : 10px;
    padding: 10px;
    justify-content: space-evenly;
    text-align: center;
}

#cer-type button {
  background: transparent;
  border: 1px solid var(--border-soft);
  color: var(--text-main);
}

#cer-type button:hover {
    background-color: #e5e7eb;
    transform: translateY(-1px);
}

#cer-type button.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.cert-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 20px;
  list-style: none;
  padding: 0;
  justify-content: flex-start;
}

.cer-item:hover {
  transform: translateY(-4px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.filter-bar {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
}

.filter-btn {
  padding: 6px 14px;
  font-size: 14px;
  font-weight: 500;

  border: 1px solid var(--border-light);
  background: #fff;
  color: var(--text-main);
  border-radius: 999px; /* pill style ดู professional */

  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

/* filter bar */
.filter-btn.active,
.filter-btn:hover {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.card,
.cer-item,
.project-card {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.cert-item:hover,
.project-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.cer-item {
  padding: 12px;
  border-radius: 12px;
  text-align: center;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.cer-card p{
    padding-left: 15px;
}

.cer-card:hover{
    background-color: rgb(207, 207, 207);
}

.cer-item img{
    width: 50%;
    max-height: 140ox;
    height: auto;
    object-fit: contain;
    border-radius: 15px;
}

#cer-pic p {
    width: 100%;
    height: auto;
    padding: 10px;
}

/* Modal overlay */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.6);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 999;

  /* animation */
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.modal.show {
  opacity: 1;
  pointer-events: auto;
}

/* Hide modal */
.hidden {
  display: none;
}

.modal.show .modal-content {
  transform: translateY(0);
}

/* Close button */
.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;

  width: 32px;
  height: 32px;

  border: none;
  border-radius: 50%;

  background: transparent;
  color: var(--text-muted);

  font-size: 20px;
  line-height: 1;
  cursor: pointer;

  display: flex;
  align-items: center;
  justify-content: center;

  transition: background 0.15s ease, color 0.15s ease;
}

.modal-close:hover {
  background: var(--accent-soft);
  color: var(--accent);
}

.modal-close:focus {
  outline: none;
  box-shadow: 0 0 0 2px var(--accent-soft);
}

.cert-modal-image {
  display: block;
  max-width: 100%;
  max-height: 75vh;     /* สำคัญ: จำกัดตามจอ */
  width: auto;
  height: auto;
  object-fit: contain; /* ห้ามใช้ cover */
  margin: 0 auto 20px; /* center ภายใน modal */
  border-radius: 8px;
}

.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
  justify-content: flex-start;
}

.project-card {
  padding: 18px;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.project-card:hover{
  transform: translateY(-3px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.06);
}

.project-card h3 {
  font-size: 18px;
  margin: 12px 0 8px;
}

.project-card p {
  margin: 0 0 8px;
  color: var(--text-muted);
  font-size: 15px;
}

.project-links a {
  margin-right: 10px;
}

.project-img {
  width: 100%;
  height: 160px;
  object-fit: cover;
  border-radius: 6px;
  margin-bottom: 10px;
}

.project-image-carousel {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 10px;
  margin-bottom: 16px;
}

.project-image-carousel::-webkit-scrollbar {
  height: 6px;
}

.project-image-carousel::-webkit-scrollbar-thumb {
  background: #ccc;
  border-radius: 3px;
}

.project-image-carousel.multi-image img {
  height: 120px;
  border-radius: 12px;
}

.modal-image {
  width: 100%;
  max-height: 60vh;      /* หัวใจของปัญหานี้ */
  object-fit: contain;
  border-radius: 8px;
  height: 120px;
}

.modal-content {
  background: var(--bg-card);
  box-shadow: var(--shadow-soft);
  padding: 24px;
  max-width: 600px;
  width: 92%;
  border-radius: var(--radius-md);
  position: relative;
  max-height: 90vh;
  overflow-y: auto;
  transform: translateY(10px);
  transition: transform 0.2s ease;
}

.modal-content h2 {
  margin-bottom: 8px;
  font-size: 22px;
}

.modal-content p {
  color: var(--text-muted);
}

.modal-content a {
  display: inline-block;
  margin-right: 12px;
  color: var(--accent);
  font-weight: 500;
}

.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.lightbox.show {
  display: flex;
}

.lightbox img {
  max-width: 90vw;
  max-height: 90vh;
  object-fit: contain;
  border-radius: 8px;
  transition: opacity 0.2s ease;
}

#lightbox-close {
  position: absolute;
  top: 20px;
  right: 30px;
  font-size: 32px;
  color: white;
  cursor: pointer;
}

.lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(0,0,0,0.5);
  border: none;
  color: white;
  font-size: 32px;
  padding: 8px 12px;
  cursor: pointer;
  border-radius: 4px;
  user-select: none;
  opacity: 0.7;
}

#lightbox-prev {
  left: 20px;
}

#lightbox-next {
  right: 20px;
}

.lightbox-nav:hover {
  background: rgba(0,0,0,0.8);
  opacity: 1;
}

/* ===== Skills Section ===== */

#skills {
  margin-top: 64px;
}

.skills-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 24px;
  margin-top: 24px;
}

.skill-card {
  background: var(--card-bg, #ffffff);
  border-radius: 14px;
  padding: 20px;
  box-shadow: 0 6px 18px rgba(0,0,0,0.06);
}

.skill-card h3 {
  margin-bottom: 16px;
  font-size: 1.1rem;
  color: var(--text-main);
}

.skill-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.skill-list li {
  display: grid;
  grid-template-columns: 1fr 80px;
  align-items: center;
  margin-bottom: 12px;
  font-size: 0.95rem;
}

/* Skill level bars */
.level {
  height: 6px;
  border-radius: 6px;
  background: #e5e7eb;
  position: relative;
  overflow: hidden;
}

.level::after {
  content: "";
  position: absolute;
  height: 100%;
  left: 0;
  top: 0;
  background: linear-gradient(90deg, #2563eb, #38bdf8);
}

/* Levels */
.level-2::after { width: 40%; }
.level-3::after { width: 60%; }
.level-4::after { width: 80%; }

.skills-footer {
  margin-top: 32px;
  font-size: 0.95rem;
  color: var(--text-muted);
  line-height: 1.6;
}

/* Responsive tweaks */
@media (max-width: 768px) {
  #skills {
    margin-top: 48px;
  }
}

.contact-badge {
  display: inline-flex;
  flex-direction: column;
  padding: 6px 10px;
  border: 1px solid var(--border-light);
  border-radius: 8px;
  font-size: 12px;
  text-decoration: none;
  color: var(--text-main);
  transition: background 0.15s ease, border-color 0.15s ease;
}

.contact-badge:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.badge-label {
  font-weight: 600;
}

.badge-sub {
  font-size: 11px;
  color: var(--text-muted);
}
