/* ==========================================================================
   RopeWeb / ROPEMAN — สไตล์หลัก โทนสีอิงจาก Crane Accident Dashboard เดิม
   ========================================================================== */

:root {
  --navy-950: #0a1330;
  --navy-900: #0f1a3d;
  --navy-800: #16244f;
  --navy-700: #1d2f63;
  /* สีฟ้า = สีหลัก ใช้กับลิงก์ แท็ก และองค์ประกอบให้ข้อมูล */
  --accent-500: #2f8fff;
  --accent-400: #7ab8ff;
  /* สีส้ม = สีเน้น ดึงจากหมวกนิรภัยในโลโก้ ใช้กับปุ่มกดและตัวเลขเครดิตเท่านั้น */
  --orange-500: #f06820;
  --orange-400: #ff8b45;
  --text-light: #eef1fa;
  --text-muted: #9aa5c7;
  --bg-page: #f5f6fa;
  --bg-card: #ffffff;
  --text-dark: #1a2138;
  --text-body: #4a5170;
  --border-soft: #e4e7f1;
  --radius: 14px;
  --shadow: 0 8px 24px rgba(16, 26, 61, 0.08);
  --max-width: 1160px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: "Kanit", "Noto Sans Thai", system-ui, sans-serif;
  background: var(--bg-page);
  color: var(--text-body);
  line-height: 1.6;
}

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

a {
  color: inherit;
}

.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 24px;
}

section {
  padding: 72px 0;
}

.section-heading {
  text-align: center;
  margin-bottom: 40px;
}

.section-heading .eyebrow {
  display: inline-block;
  color: var(--accent-500);
  font-weight: 600;
  letter-spacing: 0.08em;
  font-size: 0.85rem;
  text-transform: uppercase;
  margin-bottom: 8px;
}

.section-heading h2 {
  color: var(--text-dark);
  font-size: clamp(1.6rem, 3vw, 2.2rem);
  margin: 0 0 12px;
}

.section-heading p {
  color: var(--text-body);
  max-width: 640px;
  margin: 0 auto;
}

/* ---- Header / Nav ------------------------------------------------------ */

.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--navy-950);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 72px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text-light);
  font-weight: 700;
  font-size: 1.15rem;
}

.brand img {
  height: 46px;
  width: 46px;
  object-fit: cover;
  background: #fff;
  border-radius: 10px;
}

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

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

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

.nav-cta {
  background: var(--orange-500) !important;
  color: var(--navy-950) !important;
  padding: 9px 18px;
  border-radius: 999px;
}

.nav-toggle {
  display: none;
  flex-direction: column;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
}

.nav-toggle span {
  width: 22px;
  height: 2px;
  background: var(--text-light);
  transition: transform 0.2s ease, opacity 0.2s ease;
}

/* ---- Hero ---------------------------------------------------------------- */

.hero {
  background: linear-gradient(160deg, var(--navy-950), var(--navy-800) 70%);
  color: var(--text-light);
  padding: 96px 0 64px;
}

.hero .container {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 48px;
  align-items: center;
}

.hero-eyebrow {
  display: inline-block;
  background: rgba(47, 143, 255, 0.15);
  color: var(--accent-400);
  border: 1px solid rgba(47, 143, 255, 0.35);
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 18px;
}

.hero h1 {
  font-size: clamp(2.4rem, 5vw, 3.4rem);
  line-height: 1.15;
  margin: 0 0 16px;
  color: var(--accent-400);
  letter-spacing: 0.02em;
}

.hero-title {
  font-size: 1.1rem;
  color: var(--text-muted);
  margin: 0 0 20px;
}

.hero-bio {
  color: var(--text-muted);
  margin: 0 0 32px;
  max-width: 520px;
}

.hero-actions {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
}

.btn {
  display: inline-block;
  padding: 13px 26px;
  border-radius: 999px;
  font-weight: 600;
  text-decoration: none;
  font-size: 0.95rem;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

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

.btn-primary {
  background: var(--orange-500);
  color: var(--navy-950);
  box-shadow: 0 10px 24px rgba(240, 104, 32, 0.35);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-light);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.hero-visual {
  display: flex;
  justify-content: center;
}

.hero-visual img {
  width: 100%;
  max-width: 340px;
  background: #fff;
  border-radius: 28px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.30);
}

/* ---- Highlights strip ----------------------------------------------------- */

.highlights {
  background: var(--navy-900);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.highlights .container {
  display: flex;
  justify-content: space-around;
  flex-wrap: wrap;
  gap: 24px;
  padding: 32px 24px;
}

.highlight {
  flex: 1 1 200px;
  max-width: 270px;
  text-align: center;
  color: var(--text-light);
}

.highlight-number {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--orange-400);
}

.highlight-label {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-top: 4px;
}

/* ---- About (เบื้องหลัง ROPEMAN) — เดิมตั้งใจให้ดูไม่เด่นเกินไป ------------- */

.about-compact {
  max-width: 720px;
  margin: 0 auto;
}

.about-bio {
  font-size: 1.02rem;
  text-align: center;
  margin: 0 0 28px;
}

.about-details {
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  background: var(--bg-card);
  padding: 18px 24px;
}

.about-details summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--text-dark);
  font-size: 0.95rem;
  list-style: none;
}

.about-details summary::-webkit-details-marker {
  display: none;
}

.about-details summary::before {
  content: "▸ ";
  color: var(--accent-500);
}

.about-details[open] summary::before {
  content: "▾ ";
}

.about-details[open] summary {
  margin-bottom: 20px;
}

/* ---- Credentials & Timeline ------------------------------------------------ */

.credentials-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 48px;
  align-items: start;
}

.subsection-title {
  color: var(--text-dark);
  font-size: 1.05rem;
  margin: 0 0 16px;
}

.credential-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.credential-item {
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-left: 3px solid var(--accent-500);
  border-radius: 10px;
  padding: 14px 16px;
  font-size: 0.92rem;
  color: var(--text-body);
  box-shadow: var(--shadow);
}

.timeline {
  display: flex;
  flex-direction: column;
  gap: 0;
  border-left: 2px solid var(--border-soft);
  padding-left: 24px;
}

.timeline-item {
  position: relative;
  padding-bottom: 24px;
}

.timeline-item::before {
  content: "";
  position: absolute;
  left: -30px;
  top: 4px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent-500);
  border: 2px solid #fff;
  box-shadow: 0 0 0 2px var(--accent-500);
}

.timeline-year {
  color: var(--accent-500);
  font-weight: 700;
  font-size: 0.85rem;
  margin-bottom: 2px;
}

.timeline-title {
  color: var(--text-dark);
  font-weight: 600;
  font-size: 0.95rem;
}

.timeline-place {
  color: var(--text-body);
  font-size: 0.85rem;
}

/* ---- Cards grid (shared: apps / courses / content) ------------------------ */

/* auto-fill (ไม่ใช่ auto-fit) เพื่อไม่ให้การ์ดใบเดียวยืดเต็มความกว้าง */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 24px;
}

.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border-soft);
}

.card-media {
  position: relative;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: linear-gradient(135deg, var(--navy-800), var(--navy-950));
  display: flex;
  align-items: center;
  justify-content: center;
}

/* วางแบบ absolute เพื่อไม่ให้รูปสูง ๆ ดันกรอบให้ยืดเกินสัดส่วน 16:9 */
.card-media img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  /* ยึดขอบบน เวลาใช้ภาพแนวตั้งเป็นปก จะได้เห็นหัวเรื่อง ไม่ใช่ท่อนกลาง */
  object-position: center top;
}

.card-media-placeholder {
  font-size: 2.5rem;
  opacity: 0.7;
}

.card-body {
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}

.card-title {
  margin: 0;
  font-size: 1.15rem;
  color: var(--text-dark);
}

.card-subtitle {
  margin: 0;
  color: var(--accent-500);
  font-size: 0.85rem;
  font-weight: 600;
}

.card-description {
  margin: 0;
  font-size: 0.92rem;
  color: var(--text-body);
  flex: 1;
}

.card-link {
  margin-top: 8px;
  align-self: flex-start;
  color: var(--accent-500);
  font-weight: 600;
  text-decoration: none;
  font-size: 0.92rem;
}

.card-link:hover {
  text-decoration: underline;
}

.card-link-disabled {
  color: var(--text-muted);
  cursor: default;
}

.badge {
  display: inline-block;
  align-self: flex-start;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--navy-900);
  color: var(--text-light);
}

.badge-gated {
  background: #e8f2ff;
  color: #0b5fcc;
}

.badge-soon {
  background: #eef0f6;
  color: var(--text-body);
}

.badge-duration {
  background: #eef0f6;
  color: var(--text-body);
}

.badge-type {
  background: #e8f2ff;
  color: #0b5fcc;
}

.badge-format {
  background: #eef7ee;
  color: #2c6b34;
}

/* ---- Course card ----------------------------------------------------------- */

.course-card {
  padding: 24px;
  gap: 10px;
}

.course-card .card-description {
  flex: 0 0 auto;
}

.course-audience {
  margin: 0;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.course-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 2px;
}

.course-card .card-link {
  margin-top: auto;
  padding-top: 10px;
}

.card-date {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  color: var(--text-muted);
  padding: 48px 0;
  border: 1px dashed var(--border-soft);
  border-radius: var(--radius);
}

/* ---- เมนูหน้าที่กำลังเปิดอยู่ ------------------------------------------------ */

.nav-menu a.is-current {
  color: var(--text-light);
  font-weight: 600;
}

/* ---- หัวหน้ารอง (tools.html / knowledge.html) -------------------------------- */

.page-hero {
  background: linear-gradient(160deg, var(--navy-950), var(--navy-800) 70%);
  color: var(--text-light);
  padding: 72px 0 56px;
  text-align: center;
}

.page-hero h1 {
  font-size: clamp(1.9rem, 4vw, 2.8rem);
  margin: 0 0 18px;
  line-height: 1.25;
}

.page-hero-lead {
  color: var(--text-muted);
  max-width: 680px;
  margin: 0 auto;
  font-size: 1.02rem;
  line-height: 1.75;
}

/* ---- DASHBOARD showcase (หน้าแรก) ------------------------------------------- */

.dashboard-list {
  display: flex;
  flex-direction: column;
  gap: 64px;
}

.dashboard-card {
  display: grid;
  grid-template-columns: 1.15fr 1fr;
  gap: 48px;
  align-items: center;
}

.dashboard-card.is-reversed .dashboard-media {
  order: 2;
}

.dashboard-frame {
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border-soft);
  box-shadow: 0 22px 50px rgba(16, 26, 61, 0.18);
  background: var(--navy-950);
  line-height: 0;
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.dashboard-card:hover .dashboard-frame {
  transform: translateY(-4px);
  box-shadow: 0 28px 60px rgba(16, 26, 61, 0.26);
}

.dashboard-frame img {
  width: 100%;
  display: block;
}

.dashboard-stat {
  display: inline-block;
  background: #e8f2ff;
  color: #0b5fcc;
  font-weight: 700;
  font-size: 0.88rem;
  padding: 6px 16px;
  border-radius: 999px;
  margin-bottom: 14px;
}

.dashboard-title {
  font-size: clamp(1.4rem, 2.6vw, 1.9rem);
  color: var(--text-dark);
  margin: 0 0 8px;
  line-height: 1.3;
}

.dashboard-subtitle {
  color: var(--accent-500);
  font-weight: 600;
  margin: 0 0 14px;
  font-size: 1rem;
}

.dashboard-description {
  margin: 0 0 24px;
  line-height: 1.8;
}

.dashboard-actions {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

/* ---- แถบชวนไปหน้าเครื่องมือ --------------------------------------------------- */

.tools-teaser-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 40px;
  flex-wrap: wrap;
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 40px 44px;
  box-shadow: var(--shadow);
}

.tools-teaser-panel h2 {
  color: var(--text-dark);
  margin: 6px 0 12px;
  font-size: clamp(1.3rem, 2.4vw, 1.8rem);
}

.tools-teaser-panel p {
  margin: 0;
  max-width: 620px;
  line-height: 1.75;
}

.section-footer-cta {
  margin-top: 36px;
  text-align: center;
}

.btn-secondary-dark {
  background: transparent;
  color: var(--accent-500);
  border: 1.5px solid var(--accent-500);
}

.btn-secondary-dark:hover {
  background: var(--accent-500);
  color: #fff;
}

/* ---- คลังความรู้: ค้นหา + แท็บหมวดหมู่ ------------------------------------- */

.knowledge-section {
  padding-top: 44px;
}

.knowledge-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.search-box {
  flex: 1 1 320px;
  max-width: 460px;
}

.search-box input {
  width: 100%;
  font-family: inherit;
  font-size: 0.98rem;
  padding: 13px 20px;
  border-radius: 999px;
  border: 1.5px solid var(--border-soft);
  background: var(--bg-card);
  color: var(--text-dark);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.search-box input:focus {
  border-color: var(--accent-500);
  box-shadow: 0 0 0 4px rgba(47, 143, 255, 0.12);
}

.result-count {
  color: var(--text-muted);
  font-size: 0.9rem;
  white-space: nowrap;
}

.category-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 32px;
}

.category-tab {
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-body);
  background: var(--bg-card);
  border: 1.5px solid var(--border-soft);
  border-radius: 999px;
  padding: 9px 18px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.category-tab:hover {
  border-color: var(--accent-400);
  color: var(--accent-500);
}

.category-tab.is-active {
  background: var(--navy-900);
  border-color: var(--navy-900);
  color: #fff;
}

.category-count {
  display: inline-block;
  margin-left: 6px;
  font-size: 0.78rem;
  opacity: 0.7;
}

/* ---- Gallery (บรรยากาศงานอบรม) --------------------------------------------- */

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 20px;
}

.gallery-item {
  margin: 0;
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.gallery-item img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  display: block;
}

.gallery-item figcaption {
  padding: 12px 16px;
  font-size: 0.85rem;
  color: var(--text-body);
  line-height: 1.5;
}

/* ---- Alternating section background ---------------------------------------- */

.section-alt {
  background: #fff;
  border-top: 1px solid var(--border-soft);
  border-bottom: 1px solid var(--border-soft);
}

/* ---- Contact --------------------------------------------------------------- */

.contact-panel {
  background: linear-gradient(160deg, var(--navy-950), var(--navy-800) 70%);
  border-radius: var(--radius);
  padding: 56px;
  color: var(--text-light);
  text-align: center;
}

.contact-panel h2 {
  margin: 0 0 12px;
  font-size: clamp(1.5rem, 3vw, 2rem);
}

.contact-panel p {
  color: var(--text-muted);
  max-width: 520px;
  margin: 0 auto 28px;
}

.contact-actions {
  display: flex;
  justify-content: center;
  gap: 14px;
  flex-wrap: wrap;
}

/* ---- Footer ------------------------------------------------------------------ */

.site-footer {
  background: var(--navy-950);
  color: var(--text-muted);
  padding: 32px 0;
  text-align: center;
  font-size: 0.85rem;
}

.site-footer strong {
  color: var(--text-light);
}

/* ---- Responsive --------------------------------------------------------------- */

@media (max-width: 860px) {
  .hero .container {
    grid-template-columns: 1fr;
  }

  .hero-visual {
    order: -1;
  }

  .hero-visual img {
    max-width: 220px;
  }

  .contact-panel {
    padding: 40px 24px;
  }

  .credentials-grid {
    grid-template-columns: 1fr;
    gap: 32px;
  }

  /* Dashboard: มือถือให้เรียงบนล่าง ภาพอยู่บนเสมอ */
  .dashboard-card,
  .dashboard-card.is-reversed {
    grid-template-columns: 1fr;
    gap: 24px;
  }

  .dashboard-card.is-reversed .dashboard-media {
    order: 0;
  }

  .dashboard-list {
    gap: 48px;
  }

  .tools-teaser-panel {
    padding: 28px 24px;
  }
}

@media (max-width: 720px) {
  .nav-toggle {
    display: flex;
  }

  .nav-menu {
    position: absolute;
    top: 72px;
    left: 0;
    right: 0;
    background: var(--navy-950);
    flex-direction: column;
    align-items: flex-start;
    padding: 0 24px;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.2s ease;
  }

  .nav-menu.is-open {
    max-height: 400px;
    padding: 16px 24px 24px;
  }

  .nav-menu li {
    width: 100%;
  }

  section {
    padding: 56px 0;
  }
}

/* ================= LIVE ACCIDENT FEED (หน้าแรก) ================= */
.accident-feed {
  background: linear-gradient(180deg, var(--navy-950) 0%, var(--navy-900) 100%);
  padding: 36px 0 40px;
}

.accident-feed-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 18px;
}

.accident-feed-title {
  display: flex;
  align-items: center;
  gap: 10px;
}

.accident-feed-title h2 {
  color: var(--text-light);
  font-size: clamp(1.1rem, 2vw, 1.4rem);
  margin: 0;
}

.live-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #ff4d4d;
  box-shadow: 0 0 0 0 rgba(255, 77, 77, 0.7);
  animation: live-pulse 1.6s infinite;
  flex-shrink: 0;
}

@keyframes live-pulse {
  0% { box-shadow: 0 0 0 0 rgba(255, 77, 77, 0.6); }
  70% { box-shadow: 0 0 0 8px rgba(255, 77, 77, 0); }
  100% { box-shadow: 0 0 0 0 rgba(255, 77, 77, 0); }
}

.accident-feed-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}

@media (max-width: 900px) {
  .accident-feed-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 560px) {
  .accident-feed-grid {
    grid-template-columns: 1fr;
  }
}

.accident-col-head {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.accident-card {
  background: var(--navy-800);
  border: 1px solid var(--navy-700);
  border-radius: 12px;
  padding: 16px;
  display: block;
  text-decoration: none;
  color: var(--text-light);
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.accident-card:hover {
  transform: translateY(-3px);
  border-color: var(--orange-500);
}

.accident-card.skeleton {
  height: 180px;
  background: linear-gradient(90deg, var(--navy-800) 25%, var(--navy-700) 50%, var(--navy-800) 75%);
  background-size: 200% 100%;
  animation: skeleton-shine 1.4s infinite;
}

@keyframes skeleton-shine {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.accident-card-top {
  display: flex;
  justify-content: space-between;
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.accident-location {
  font-weight: 600;
  font-size: 0.92rem;
  margin-bottom: 4px;
  color: var(--text-light);
}

.accident-equip {
  display: inline-block;
  font-size: 0.72rem;
  color: var(--orange-400);
  background: rgba(240, 104, 32, 0.12);
  border-radius: 99px;
  padding: 2px 10px;
  margin-bottom: 8px;
}

.accident-desc {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin: 0 0 8px;
  line-height: 1.5;
}

.accident-source-link {
  font-size: 0.78rem;
  color: var(--orange-400);
  font-weight: 600;
}

.accident-feed-error {
  color: var(--text-muted);
  font-size: 0.85rem;
}
