/* ========================================================
   สกร. ชลบุรี — Premium Design System v2.0
   ======================================================== */

:root {
  /* Color System */
  --primary: #f7c948;
  --primary-dark: #d4a017;
  --primary-light: #fff3cd;
  --secondary: #5b21b6;
  --secondary-dark: #3b0764;
  --secondary-light: #8b5cf6;
  --accent: #7c3aed;
  --dark: #0f172a;
  --dark-soft: #1e293b;
  --text: #334155;
  --text-light: #64748b;
  --surface: #ffffff;
  --bg: #f8fafc;
  --border: rgba(0, 0, 0, 0.06);

  /* Spacing */
  --topbar-h: 36px;
  --header-h: 72px;
  --section-pad: 110px;
  --radius: 20px;
  --radius-sm: 12px;
  --radius-xs: 8px;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 8px 30px rgba(0, 0, 0, 0.07);
  --shadow-lg: 0 20px 50px rgba(0, 0, 0, 0.1);
  --shadow-xl: 0 30px 60px rgba(0, 0, 0, 0.12);
  --shadow-glow: 0 0 40px rgba(91, 33, 182, 0.15);

  /* Transitions */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-bounce: cubic-bezier(0.175, 0.885, 0.32, 1.275);
  --transition: 0.3s var(--ease-out);
}

/* ===== Reset ===== */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: "Sarabun", "Anuphan", sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.7;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3,
h4,
h5,
h6 {
  font-family: "Anuphan", "Sarabun", sans-serif;
  font-weight: 700;
  line-height: 1.3;
  color: var(--dark);
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

a {
  color: inherit;
  text-decoration: none;
}

.container {
  max-width: 1280px;
  width: 90%;
  margin: 0 auto;
  padding: 0 20px;
}

/* ===== Scroll Animations ===== */
.anim {
  opacity: 0;
  transform: translateY(35px);
  transition:
    opacity 0.7s var(--ease-out),
    transform 0.7s var(--ease-out);
}

.anim.visible {
  opacity: 1;
  transform: translateY(0);
}

/* Stagger children */
.stagger > .anim:nth-child(1) {
  transition-delay: 0s;
}
.stagger > .anim:nth-child(2) {
  transition-delay: 0.1s;
}
.stagger > .anim:nth-child(3) {
  transition-delay: 0.2s;
}
.stagger > .anim:nth-child(4) {
  transition-delay: 0.25s;
}
.stagger > .anim:nth-child(5) {
  transition-delay: 0.3s;
}
.stagger > .anim:nth-child(6) {
  transition-delay: 0.35s;
}
.stagger > .anim:nth-child(7) {
  transition-delay: 0.4s;
}
.stagger > .anim:nth-child(8) {
  transition-delay: 0.45s;
}
.stagger > .anim:nth-child(9) {
  transition-delay: 0.5s;
}
.stagger > .anim:nth-child(10) {
  transition-delay: 0.55s;
}
.stagger > .anim:nth-child(11) {
  transition-delay: 0.6s;
}

/* ===== Top Bar ===== */
.top-bar {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  z-index: 1100;
  background: linear-gradient(135deg, var(--secondary-dark), var(--secondary));
  color: rgba(255, 255, 255, 0.85);
  padding: 8px 0;
  font-size: 0.78rem;
  transition: transform 0.35s var(--ease-out);
}

.top-bar.hidden {
  transform: translateY(-100%);
}

.top-bar-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.top-bar-left {
  display: flex;
  align-items: center;
  gap: 8px;
  opacity: 0.85;
}

.user-info-top {
  display: flex;
  align-items: center;
  gap: 14px;
}

.user-status {
  font-weight: 500;
  color: #fff;
}

.btn-logout-top {
  color: var(--primary);
  text-decoration: none;
  font-weight: 700;
  font-size: 0.78rem;
  transition: opacity 0.2s;
}

.btn-logout-top:hover {
  opacity: 0.75;
}

.login-link {
  color: rgba(255, 255, 255, 0.8);
  font-size: 0.78rem;
  transition: color 0.2s;
}

.login-link:hover {
  color: var(--primary);
}

/* ===== Header ===== */
header {
  position: fixed;
  top: var(--topbar-h);
  width: 100%;
  z-index: 1000;
  background: rgba(255, 255, 255, 0.98);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-bottom: 1px solid var(--border);
  padding: 12px 0;
  transition:
    top 0.35s var(--ease-out),
    padding 0.35s var(--ease-out),
    box-shadow 0.35s var(--ease-out);
}

header.scrolled {
  top: 0;
  padding: 8px 0;
  box-shadow: 0 4px 30px rgba(0, 0, 0, 0.06);
}

.nav-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
  max-width: 1600px;
  width: 96%;
}

/* Logo */
.logo {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-shrink: 0;
}

.logo img {
  height: 48px;
  width: auto;
  transition: height 0.3s var(--ease-out);
}

header.scrolled .logo img {
  height: 38px;
}

.logo-text {
  display: flex;
  flex-direction: column;
}

.main-title {
  font-family: "Anuphan", sans-serif;
  font-weight: 700;
  font-size: 1rem;
  color: var(--secondary);
  line-height: 1.25;
}

.sub-title {
  font-size: 0.7rem;
  color: var(--text-light);
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

/* Nav */
nav {
  flex-grow: 1;
  display: flex;
  justify-content: flex-end;
}

nav ul {
  display: flex;
  list-style: none;
  gap: 4px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-start;
}

nav ul li {
  position: relative;
}

nav ul li a {
  text-decoration: none;
  color: var(--text);
  font-weight: 600;
  font-size: 0.9rem;
  padding: 8px 10px;
  border-radius: var(--radius-xs);
  position: relative;
  transition:
    color 0.25s,
    background 0.25s;
  white-space: nowrap;
  display: flex;
  align-items: center;
}

nav ul li a:hover {
  color: var(--secondary);
  background: rgba(91, 33, 182, 0.05);
}

/* Caret */
.caret {
  display: inline-block;
  width: 0;
  height: 0;
  margin-left: 5px;
  border-top: 4px solid currentColor;
  border-right: 4px solid transparent;
  border-left: 4px solid transparent;
  transition: transform 0.3s;
  opacity: 0.5;
}

nav ul li:hover .caret {
  transform: rotate(180deg);
  opacity: 1;
}

/* Dropdown */
nav ul li .dropdown {
  position: absolute;
  top: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%) translateY(10px);
  background: var(--surface);
  min-width: 230px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
  padding: 8px;
  list-style: none;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s var(--ease-out);
  z-index: 1001;
  pointer-events: none;
  display: flex;
  flex-direction: column;
}

nav ul li .dropdown::before {
  content: "";
  position: absolute;
  top: -14px;
  left: 0;
  width: 100%;
  height: 14px;
}

nav ul li:hover .dropdown {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
  pointer-events: auto;
}

nav ul li .dropdown li {
  width: 100%;
}

nav ul li .dropdown a {
  padding: 10px 16px;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text);
  display: flex;
  align-items: center;
  border-radius: var(--radius-xs);
  transition: all 0.2s;
}

nav ul li .dropdown a:hover {
  background: rgba(91, 33, 182, 0.06);
  color: var(--secondary);
  padding-left: 22px;
}

/* Dropdown arrow tip */
nav ul li .dropdown::after {
  content: "";
  position: absolute;
  top: -7px;
  left: 50%;
  transform: translateX(-50%) rotate(45deg);
  width: 14px;
  height: 14px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  border-left: 1px solid var(--border);
}

/* Flip dropdown to align right edge when near viewport edge */
nav ul li .dropdown.dropdown-flip {
  left: auto;
  right: 0;
  transform: translateX(0) translateY(10px);
}
nav ul li:hover .dropdown.dropdown-flip {
  transform: translateX(0) translateY(0);
}
nav ul li .dropdown.dropdown-flip::after {
  left: auto;
  right: 20px;
  transform: rotate(45deg);
}

/* Sub-Dropdown (Level 3) — Side Flyout */
nav ul li .dropdown .dropdown-submenu {
  position: absolute;
  top: 0;
  left: 100%;
  transform: translateX(8px) translateY(0);
  background: var(--surface);
  min-width: 220px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
  padding: 8px;
  list-style: none;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s, visibility 0.2s;
  z-index: 1002;
  display: flex;
  flex-direction: column;
}

/* Only show when THIS specific item is hovered */
nav ul li .dropdown li.has-dropdown-submenu:hover > .dropdown-submenu {
  opacity: 1;
  visibility: visible;
  transform: translateX(0) translateY(0);
  pointer-events: auto;
}

/* Small bridge to prevent gap between parent and submenu */
nav ul li .dropdown .dropdown-submenu::before {
  content: "";
  position: absolute;
  top: 0;
  left: -10px;
  width: 10px;
  height: 100%;
}

/* Flip submenu to open LEFT when near right viewport edge */
nav ul li .dropdown .dropdown-submenu.submenu-flip {
  left: auto;
  right: 100%;
  transform: translateX(-8px) translateY(0);
}
nav ul li .dropdown li.has-dropdown-submenu:hover > .dropdown-submenu.submenu-flip {
  transform: translateX(0) translateY(0);
}
nav ul li .dropdown .dropdown-submenu.submenu-flip::before {
  left: auto;
  right: -10px;
}

nav ul li .dropdown .dropdown-submenu::after {
  display: none;
}

.caret-right {
  display: inline-block;
  margin-left: auto;
  font-size: 0.7em;
  opacity: 0.5;
  transition: transform 0.3s;
}

nav ul li .dropdown li:hover .caret-right {
  transform: translateX(3px);
  opacity: 1;
}

/* ===== Mobile Menu Button ===== */
.mobile-menu-btn {
  display: none;
  flex-direction: column;
  gap: 5px;
  cursor: pointer;
  z-index: 1201;
  padding: 6px;
  border: none;
  background: none;
}

.mobile-menu-btn span {
  width: 24px;
  height: 2.5px;
  background: var(--secondary);
  border-radius: 4px;
  transition: all 0.35s var(--ease-out);
  display: block;
  transform-origin: center;
}

.mobile-menu-btn.active span:nth-child(1) {
  transform: rotate(45deg) translate(5px, 5.5px);
}

.mobile-menu-btn.active span:nth-child(2) {
  opacity: 0;
  transform: scaleX(0);
}

.mobile-menu-btn.active span:nth-child(3) {
  transform: rotate(-45deg) translate(5px, -5.5px);
}

/* ===== Hero Section ===== */
.hero {
  position: relative;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(var(--topbar-h) + var(--header-h) + 40px) 0 80px;
  overflow: hidden;
  text-align: center;
  background-color: var(--dark);
  background-size: cover;
  background-position: center;
}

.hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    180deg,
    rgba(15, 23, 42, 0.4) 0%,
    rgba(15, 23, 42, 0.65) 50%,
    rgba(15, 23, 42, 0.85) 100%
  );
  z-index: 1;
}

/* Decorative floating shapes */
.hero::after {
  content: "";
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 100%;
  height: 80px;
  background: var(--bg);
  clip-path: ellipse(55% 100% at 50% 100%);
  z-index: 2;
}

.hero-content {
  z-index: 3;
  color: #fff;
  max-width: 3000px;
  margin: 0 auto;
  padding: 0 20px;
  opacity: 0;
  transform: translateY(50px);
  transition:
    opacity 1s var(--ease-out),
    transform 1s var(--ease-out);
}

.hero-content.visible {
  opacity: 1;
  transform: translateY(0);
}

.hero h1 {
  font-size: 3.6rem;
  font-weight: 800;
  color: #ffd700;
  line-height: 1.2;
  margin-bottom: 24px;
  text-shadow: 0 4px 30px rgba(0, 0, 0, 0.3);
  letter-spacing: -0.5px;
  -webkit-text-stroke: 0.09px #000000;
}

.highlight {
  color: var(--primary);
  display: block;
  margin-top: 8px;
  text-shadow: 0 2px 20px rgba(247, 201, 72, 0.3);
}

.hero p {
  font-size: 1.25rem;
  font-weight: 300;
  margin: 0 auto 40px;
  max-width: 700px;
  color: rgba(255, 255, 255, 0.85);
  line-height: 1.8;
}

.hero-btns {
  display: flex;
  gap: 16px;
  justify-content: center;
  flex-wrap: wrap;
}

/* Scroll indicator */
.scroll-down {
  position: absolute;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-decoration: none;
  color: rgba(255, 255, 255, 0.6);
  z-index: 5;
  transition: color 0.3s;
}

.scroll-down:hover {
  color: #fff;
}

.scroll-down span {
  width: 26px;
  height: 42px;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-radius: 14px;
  position: relative;
  margin-bottom: 8px;
}

.scroll-down span::before {
  content: "";
  position: absolute;
  top: 7px;
  left: 50%;
  width: 4px;
  height: 4px;
  background: var(--primary);
  margin-left: -2px;
  border-radius: 50%;
  animation: scrollAnim 2s infinite;
}

@keyframes scrollAnim {
  0% {
    transform: translateY(0);
    opacity: 1;
  }
  100% {
    transform: translateY(16px);
    opacity: 0;
  }
}

.scroll-down p {
  font-size: 0.68rem;
  letter-spacing: 3px;
  text-transform: uppercase;
  margin: 0;
}

/* ===== Stats Counter ===== */
.stats-section {
  position: relative;
  z-index: 10;
  background: linear-gradient(135deg, #1e1145 0%, #2d1b69 40%, #0f172a 100%);
  padding: 80px 0;
  overflow: hidden;
}

.stats-section::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(
      circle at 20% 50%,
      rgba(124, 58, 237, 0.15) 0%,
      transparent 50%
    ),
    radial-gradient(
      circle at 80% 50%,
      rgba(247, 201, 72, 0.1) 0%,
      transparent 50%
    );
  pointer-events: none;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 24px;
  position: relative;
  z-index: 1;
}

.stat-card {
  background: rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(12px);
  border-radius: var(--radius);
  padding: 36px 24px 30px;
  text-align: center;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-top: 3px solid var(--accent, #ffd700);
  transition:
    transform 0.4s var(--ease-out),
    background 0.4s,
    box-shadow 0.4s;
}

.stat-card:hover {
  transform: translateY(-8px);
  background: rgba(255, 255, 255, 0.1);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
}

.stat-icon-wrap {
  width: 64px;
  height: 64px;
  margin: 0 auto 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.stat-icon {
  font-size: 2rem;
  display: block;
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.2));
}

.stat-number {
  font-family: "Anuphan", sans-serif;
  font-size: 3.2rem;
  font-weight: 800;
  color: #fff;
  line-height: 1;
  margin-bottom: 8px;
  text-shadow: 0 2px 12px rgba(255, 255, 255, 0.15);
}

.stat-label {
  font-size: 1rem;
  color: rgba(255, 255, 255, 0.85);
  font-weight: 600;
  margin-bottom: 6px;
  letter-spacing: 0.3px;
}

.stat-sub {
  font-size: 0.78rem;
  color: rgba(255, 255, 255, 0.4);
  font-weight: 400;
}

@media (max-width: 992px) {
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 480px) {
  .stats-section {
    padding: 50px 0;
  }
  .stats-grid {
    grid-template-columns: 1fr 1fr;
    gap: 14px;
  }
  .stat-number {
    font-size: 2.4rem;
  }
  .stat-card {
    padding: 24px 14px 20px;
  }
}

/* ===== Buttons ===== */
.btn {
  padding: 14px 34px;
  border-radius: 50px;
  font-weight: 700;
  text-decoration: none;
  transition: all 0.35s var(--ease-bounce);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
  font-family: inherit;
  cursor: pointer;
  border: none;
  letter-spacing: 0.3px;
  gap: 8px;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: var(--secondary-dark) !important;
  box-shadow: 0 6px 20px rgba(247, 201, 72, 0.35);
}

.btn-primary:hover {
  transform: translateY(-3px) scale(1.03);
  box-shadow: 0 12px 30px rgba(247, 201, 72, 0.45);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.08);
  color: #fff !important;
  border: 2px solid rgba(255, 255, 255, 0.5) !important;
  backdrop-filter: blur(5px);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.95);
  color: var(--secondary) !important;
  border-color: transparent !important;
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
}

/* ===== Sections ===== */
section {
  padding: var(--section-pad) 0;
}

.section-header {
  text-align: center;
  margin-bottom: 60px;
}

.section-header .badge {
  display: inline-block;
  background: linear-gradient(
    135deg,
    rgba(91, 33, 182, 0.08),
    rgba(124, 58, 237, 0.08)
  );
  color: var(--secondary);
  padding: 6px 20px;
  border-radius: 50px;
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  margin-bottom: 16px;
}

.section-header h2 {
  font-size: 2.6rem;
  color: var(--dark);
  margin-bottom: 14px;
  letter-spacing: -0.5px;
}

.section-header p {
  font-size: 1.08rem;
  color: var(--text-light);
  max-width: 600px;
  margin: 0 auto;
}

/* Legacy section-title support */
.section-title {
  text-align: center;
  margin-bottom: 50px;
}

.section-title h2 {
  font-size: 2.5rem;
  color: var(--dark);
  margin-bottom: 14px;
  letter-spacing: -0.5px;
}

.underline {
  width: 60px;
  height: 4px;
  background: linear-gradient(90deg, var(--primary), var(--secondary-light));
  margin: 0 auto;
  border-radius: 2px;
}

.section-desc {
  text-align: center;
  margin-top: -30px;
  margin-bottom: 40px;
  color: var(--text-light);
  font-size: 1.05rem;
}

/* ===== About Section ===== */
.about {
  background: var(--bg);
}

.about-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 28px;
}

.about-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 45px 35px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  transition: all 0.4s var(--ease-out);
  position: relative;
  overflow: hidden;
}

.about-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  background: linear-gradient(180deg, var(--primary), var(--secondary-light));
  border-radius: 0 4px 4px 0;
  opacity: 0;
  transition: opacity 0.3s;
}

.about-card:hover {
  transform: translateY(-6px);
  box-shadow: var(--shadow-lg);
}

.about-card:hover::before {
  opacity: 1;
}

.about-card h3 {
  color: var(--secondary);
  margin-bottom: 16px;
  font-size: 1.3rem;
}

.about-card p {
  color: var(--text);
  line-height: 1.85;
  font-size: 0.98rem;
}

.about-icon {
  font-size: 2.2rem;
  width: 64px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(
    135deg,
    rgba(247, 201, 72, 0.12),
    rgba(91, 33, 182, 0.08)
  );
  border-radius: 18px;
  margin-bottom: 20px;
}

/* ===== Core Values Strip ===== */
.values-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
  margin-top: 60px;
  padding: 40px 30px;
  background: linear-gradient(
    135deg,
    rgba(91, 33, 182, 0.03),
    rgba(247, 201, 72, 0.05)
  );
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.value-item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  transition: all 0.3s var(--ease-out);
}

.value-item:hover {
  background: var(--surface);
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

.value-icon {
  font-size: 1.6rem;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  border-radius: 14px;
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
}

.value-item h4 {
  font-size: 0.95rem;
  color: var(--dark);
  margin-bottom: 2px;
}

.value-item p {
  font-size: 0.82rem;
  color: var(--text-light);
  margin: 0;
  line-height: 1.4;
}

@media (max-width: 768px) {
  .values-strip {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    padding: 24px 16px;
  }
}

@media (max-width: 480px) {
  .values-strip {
    grid-template-columns: 1fr;
  }
}
/* ===== Director Section ===== */
.director {
  background: var(--surface);
  padding: var(--section-pad) 0;
  position: relative;
}

.director-grid {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 70px;
  align-items: center;
}

.director-img {
  position: relative;
}

.img-frame {
  border-radius: var(--radius);
  overflow: hidden;
  position: relative;
  box-shadow: var(--shadow-lg);
}

.img-frame::before {
  content: "";
  position: absolute;
  inset: -8px;
  border: 3px solid var(--primary);
  border-radius: calc(var(--radius) + 8px);
  z-index: -1;
}

.img-frame img {
  width: 100%;
  display: block;
  transition: transform 0.6s var(--ease-out);
}

.img-frame:hover img {
  transform: scale(1.03);
}

/* Decorative dot pattern */
.director-img::after {
  content: "";
  position: absolute;
  bottom: -20px;
  right: -20px;
  width: 120px;
  height: 120px;
  background-image: radial-gradient(
    var(--secondary-light) 2px,
    transparent 2px
  );
  background-size: 12px 12px;
  opacity: 0.3;
  z-index: -1;
}

.director-content h2 {
  margin-bottom: 20px;
}

.quote {
  font-size: 1.3rem;
  font-style: italic;
  color: var(--secondary);
  margin-bottom: 20px;
  font-weight: 500;
  line-height: 1.8;
  padding-left: 20px;
  border-left: 3px solid var(--primary);
}

.director-content > p {
  color: var(--text);
  line-height: 1.85;
  margin-bottom: 20px;
}

.director-info {
  margin-top: 30px;
  padding: 20px 24px;
  background: linear-gradient(
    135deg,
    rgba(91, 33, 182, 0.04),
    rgba(124, 58, 237, 0.04)
  );
  border-radius: var(--radius-sm);
  border-left: 4px solid var(--primary);
}

.director-info h4 {
  font-size: 1.15rem;
  color: var(--dark);
  margin-bottom: 3px;
}

.director-info p {
  color: var(--text-light);
  font-size: 0.92rem;
}

/* ===== News Section ===== */
.news {
  background: var(--bg);
}

.news-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 28px;
}

.news-card {
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  transition: all 0.4s var(--ease-out);
}

.news-card:hover {
  transform: translateY(-8px);
  box-shadow: var(--shadow-lg);
}

.news-img {
  overflow: hidden;
  height: 220px;
}

.news-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.6s var(--ease-out);
}

.news-card:hover .news-img img {
  transform: scale(1.08);
}

.news-info {
  padding: 28px;
}

.date {
  display: inline-block;
  font-size: 0.78rem;
  color: var(--secondary);
  background: rgba(91, 33, 182, 0.06);
  padding: 4px 14px;
  border-radius: 50px;
  margin-bottom: 14px;
  font-weight: 600;
}

.news-info h3 {
  font-size: 1.1rem;
  margin-bottom: 12px;
  color: var(--dark);
  line-height: 1.5;
}

.news-info p {
  font-size: 0.92rem;
  color: var(--text-light);
  margin-bottom: 16px;
  line-height: 1.7;
}

.read-more {
  color: var(--secondary);
  font-weight: 700;
  font-size: 0.88rem;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.read-more:hover {
  color: var(--accent);
  gap: 10px;
}

/* ===== Featured News Layout (Homepage) ===== */
.section-title-row {
  margin-bottom: 22px;
}

.news-featured-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  align-items: stretch;
}

.news-featured-main {
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  transition: all 0.4s var(--ease-out);
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
}
.news-featured-main:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
}
.news-featured-main .featured-img {
  width: 100%;
  height: 300px;
  overflow: hidden;
}
.news-featured-main .featured-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.6s var(--ease-out);
}
.news-featured-main:hover .featured-img img {
  transform: scale(1.05);
}
.news-featured-main .featured-body {
  padding: 22px 24px;
  flex: 1;
}
.news-featured-main .featured-body h3 {
  font-size: 1.05rem;
  line-height: 1.6;
  margin-bottom: 10px;
  color: var(--dark);
}
.news-featured-main .featured-body .meta-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.82rem;
  color: var(--text-light);
  margin-bottom: 12px;
}
.news-featured-main .featured-body .btn-read {
  display: inline-block;
  background: var(--secondary);
  color: #fff;
  padding: 7px 18px;
  border-radius: var(--radius-xs);
  font-size: 0.82rem;
  font-weight: 600;
  text-decoration: none;
  transition: var(--transition);
}
.news-featured-main .featured-body .btn-read:hover {
  background: var(--secondary-dark);
}

.news-sidebar-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.news-sidebar-card {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  text-decoration: none;
  color: inherit;
  transition: all 0.3s var(--ease-out);
}
.news-sidebar-card:hover {
  background: #f8fafc;
  box-shadow: var(--shadow-sm);
  transform: translateX(4px);
}
.news-sidebar-card .sidebar-thumb {
  width: 90px;
  height: 65px;
  flex-shrink: 0;
  border-radius: 6px;
  overflow: hidden;
}
.news-sidebar-card .sidebar-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.news-sidebar-card .sidebar-info {
  flex: 1;
  min-width: 0;
}
.news-sidebar-card .sidebar-info h4 {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--dark);
  line-height: 1.5;
  margin-bottom: 4px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ==========================================
   CKEditor 5 Content Styles (Frontend)
   ========================================== */
.news-content-body figure.image {
    display: inline-block;
    border: 1px solid solid transparent;
    border-radius: 8px;
    margin: 1em 0;
    clear: both;
}

.news-content-body figure.image img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
}

.news-content-body figure.image.image-style-side,
.news-content-body figure.image.image-style-align-right {
    float: right;
    margin-left: 1.5em;
}

.news-content-body figure.image.image-style-align-left {
    float: left;
    margin-right: 1.5em;
}

.news-content-body figure.image figcaption {
    background-color: #f8fafc;
    color: #475569;
    font-size: 0.85rem;
    padding: 6px;
    text-align: center;
    border-radius: 0 0 8px 8px;
}
.news-sidebar-card .sidebar-info .sidebar-date {
  font-size: 0.76rem;
  color: var(--text-light);
  display: flex;
  align-items: center;
  gap: 4px;
}

/* ===== Announcement Home List ===== */
.ann-home-list {
  display: flex;
  flex-direction: column;
  gap: 0;
  border-top: 1px solid var(--border);
}
.ann-home-row {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  border-left: 4px solid transparent;
  text-decoration: none;
  color: inherit;
  transition: all 0.3s var(--ease-out);
}
.ann-home-row:hover {
  background: #f0f9ff;
  border-left-color: #22d3ee;
}
.ann-home-row .ann-row-body {
  flex: 1;
  min-width: 0;
}
.ann-home-row .ann-row-body h4 {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--dark);
  line-height: 1.5;
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ann-home-row .ann-row-body .ann-row-author {
  font-size: 0.78rem;
  color: var(--text-light);
}
.ann-home-row .ann-row-date {
  white-space: nowrap;
  flex-shrink: 0;
  background: linear-gradient(135deg, #e0f2fe, #bae6fd);
  color: #0369a1;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 5px 14px;
  border-radius: 50px;
}

@media (max-width: 768px) {
  .news-featured-layout {
    grid-template-columns: 1fr;
  }
  .news-featured-main .featured-img {
    height: 200px;
  }
  .ann-home-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
  .ann-home-row .ann-row-date {
    align-self: flex-end;
  }
}

/* ===== Districts Section ===== */
.districts {
  background: var(--surface);
}

.district-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 20px;
}

.district-card {
  background: var(--bg);
  border-radius: var(--radius);
  padding: 28px 20px;
  text-align: center;
  transition: all 0.4s var(--ease-out);
  cursor: pointer;
  border: 1px solid transparent;
  position: relative;
  overflow: hidden;
}

.district-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, var(--secondary), var(--accent));
  opacity: 0;
  transition: opacity 0.4s;
  border-radius: var(--radius);
}

.district-card:hover {
  transform: translateY(-6px);
  box-shadow: var(--shadow-lg);
}

.district-card:hover::before {
  opacity: 1;
}

.district-card > * {
  position: relative;
  z-index: 1;
}

.district-card:hover h4,
.district-card:hover p {
  color: #fff;
}

.d-icon {
  font-size: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 60px;
  height: 60px;
  margin: 0 auto 14px;
  border-radius: 16px;
  background: rgba(91, 33, 182, 0.06);
  transition: all 0.4s;
}

.district-card:hover .d-icon {
  background: rgba(255, 255, 255, 0.2);
  transform: scale(1.1) rotate(-5deg);
}

.district-card h4 {
  margin-bottom: 6px;
  font-size: 0.98rem;
  color: var(--dark);
  transition: color 0.3s;
}

.district-card p {
  font-size: 0.85rem;
  color: var(--text-light);
  transition: color 0.3s;
}

/* ===== Contact Section ===== */
.contact {
  background: var(--bg);
}

.contact-grid {
  display: grid;
  grid-template-columns: 1fr 1.2fr;
  gap: 40px;
  align-items: start;
}

.contact-info {
  padding: 20px 0;
}

.info-item {
  display: flex;
  align-items: flex-start;
  gap: 18px;
  margin-bottom: 28px;
}

.info-item .icon {
  font-size: 1.3rem;
  background: var(--surface);
  width: 52px;
  height: 52px;
  min-width: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
}

.info-item p {
  color: var(--text);
  line-height: 1.6;
  padding-top: 12px;
}

.contact-form {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 40px;
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border);
}

.contact-form form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.contact-form input,
.contact-form textarea {
  padding: 14px 18px;
  border: 2px solid rgba(0, 0, 0, 0.06);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.95rem;
  background: var(--bg);
  transition:
    border-color 0.3s,
    box-shadow 0.3s;
  color: var(--text);
}

.contact-form input:focus,
.contact-form textarea:focus {
  outline: none;
  border-color: var(--secondary-light);
  box-shadow: 0 0 0 4px rgba(91, 33, 182, 0.06);
  background: var(--surface);
}

.contact-form .btn {
  align-self: flex-start;
  margin-top: 4px;
}

/* ===== Footer ===== */
footer {
  background: var(--dark);
  color: rgba(255, 255, 255, 0.75);
  padding: 70px 0 0;
}

.footer-content {
  display: grid;
  grid-template-columns: 1.5fr 1fr 1fr 1fr;
  gap: 40px;
  padding-bottom: 50px;
}

.footer-logo h3 {
  font-size: 1.4rem;
  color: var(--primary);
  margin-bottom: 12px;
}

.footer-logo p {
  font-size: 0.88rem;
  color: rgba(255, 255, 255, 0.5);
  line-height: 1.7;
}

.footer-links h4,
.footer-social h4,
.footer-contact-col h4 {
  color: #fff;
  margin-bottom: 18px;
  font-size: 1rem;
  font-weight: 700;
}

.footer-links ul {
  list-style: none;
}

.footer-links ul li {
  margin-bottom: 10px;
}

.footer-links ul li a {
  color: rgba(255, 255, 255, 0.5);
  font-size: 0.88rem;
  transition:
    color 0.2s,
    padding-left 0.2s;
}

.footer-links ul li a:hover {
  color: var(--primary);
  padding-left: 4px;
}

.social-icons {
  display: flex;
  gap: 10px;
}

.social-icons a {
  background: rgba(255, 255, 255, 0.06);
  width: 42px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  color: rgba(255, 255, 255, 0.6);
  font-size: 0.82rem;
  font-weight: 700;
  transition: all 0.3s var(--ease-out);
}

.social-icons a:hover {
  background: var(--primary);
  color: var(--secondary-dark);
  transform: translateY(-3px);
}

.copyright {
  text-align: center;
  padding: 20px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  color: rgba(255, 255, 255, 0.3);
  font-size: 0.82rem;
}

/* ===== Personnel Page ===== */
.personnel-page {
  background: var(--bg);
}

.hero-mini {
  background: linear-gradient(135deg, var(--primary) 0%, #4a0082 100%);
  color: white;
  padding: calc(var(--topbar-h) + var(--header-h) + 50px) 0 70px;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.hero-mini::before {
  content: "";
  position: absolute;
  top: -60%;
  right: -15%;
  width: 500px;
  height: 500px;
  background: rgba(247, 201, 72, 0.06);
  border-radius: 50%;
}

.hero-mini::after {
  content: "";
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 100%;
  height: 60px;
  background: var(--bg);
  clip-path: ellipse(55% 100% at 50% 100%);
}

.hero-mini h1 {
  font-size: 2.6rem;
  font-weight: 800;
  margin-bottom: 10px;
  color: #fff;
}

.hero-mini p {
  font-size: 1.1rem;
  opacity: 0.8;
  color: rgba(255, 255, 255, 0.85);
}

.personnel-container {
  padding: 70px 20px;
}

.personnel-level {
  margin-bottom: 80px;
}

.personnel-center {
  display: flex;
  justify-content: center;
  margin-top: 40px;
}

.personnel-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 28px;
  margin-top: 40px;
}

.personnel-card {
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  transition: all 0.4s var(--ease-out);
  text-align: center;
}

.personnel-card:hover {
  transform: translateY(-10px);
  box-shadow: var(--shadow-lg);
}

.p-img {
  width: 100%;
  aspect-ratio: 3 / 4;
  overflow: hidden;
  background: linear-gradient(135deg, #f1f5f9, #e2e8f0);
}

.p-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.6s var(--ease-out);
}

.personnel-card:hover .p-img img {
  transform: scale(1.05);
}

.p-info {
  padding: 24px 20px;
}

.p-info h3 {
  color: var(--primary-dark);
  font-size: 1.1rem;
  margin-bottom: 6px;
}

.p-info p {
  color: var(--text-light);
  font-size: 0.9rem;
  font-weight: 500;
}

.director-card {
  width: 360px;
  border: 2px solid var(--secondary);
}

.deputy-card {
  width: 300px;
}

/* ===== Glass (legacy support) ===== */
.glass {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  transition: all 0.4s var(--ease-out);
}

.glass:hover {
  box-shadow: var(--shadow-lg);
}

/* ===== Responsive ===== */
@media (max-width: 1200px) {
  .hero h1 {
    font-size: 3rem;
  }
  .hero p {
    font-size: 1.15rem;
  }
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .footer-content {
    grid-template-columns: repeat(2, 1fr);
  }
  .director-grid {
    grid-template-columns: 320px 1fr;
    gap: 40px;
  }
}

@media (max-width: 992px) {
  :root {
    --section-pad: 80px;
  }

  .top-bar {
    position: relative;
    top: auto;
  }

  header {
    position: fixed;
    top: 0;
    z-index: 1500;
  }

  .hero {
    padding: calc(var(--header-h) + 40px) 20px 80px;
    min-height: 85vh;
  }

  .hero::after {
    height: 50px;
  }

  .hero h1 {
    font-size: 2.5rem;
  }
  .hero p {
    font-size: 1.05rem;
  }

  .hero-mini {
    padding: calc(var(--header-h) + 40px) 20px 60px;
  }

  .director-grid {
    grid-template-columns: 1fr;
    text-align: center;
    gap: 40px;
  }

  .director-img {
    max-width: 320px;
    margin: 0 auto;
  }

  .director-img::after {
    display: none;
  }

  .director-content .section-title,
  .director-content .section-header {
    text-align: center !important;
  }

  .director-content .underline {
    margin: 0 auto !important;
  }

  .quote {
    border-left: none;
    padding-left: 0;
    text-align: center;
    border-top: 3px solid var(--primary);
    padding-top: 16px;
  }

  .director-info {
    border-left: none;
    text-align: center;
  }

  .contact-grid {
    grid-template-columns: 1fr;
  }

  .section-header h2,
  .section-title h2 {
    font-size: 2rem;
  }

  /* Mobile Nav */
  nav {
    position: fixed;
    top: 0;
    right: -320px;
    width: 300px;
    height: 100vh;
    height: 100dvh;
    background: var(--surface);
    box-shadow: -10px 0 40px rgba(0, 0, 0, 0.1);
    transition: right 0.4s var(--ease-out);
    z-index: 2000;
    display: flex;
    flex-direction: column;
    padding-top: 80px;
    overflow-y: auto;
    pointer-events: auto;
  }

  nav.mobile-open {
    right: 0;
  }

  nav ul {
    flex-direction: column;
    gap: 0;
    width: 100%;
    padding: 0;
  }

  nav ul li a {
    padding: 15px 24px;
    font-size: 1rem;
    border-bottom: 1px solid var(--border);
    border-radius: 0;
  }

  nav ul li .dropdown {
    position: static;
    transform: none;
    box-shadow: none;
    border: none;
    border-radius: 0;
    min-width: 0;
    padding: 0;
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    background: var(--bg);
    margin: 0;
    display: flex;
    flex-direction: column;
  }

  nav ul li .dropdown::before,
  nav ul li .dropdown::after {
    display: none;
  }

  nav ul li .dropdown a {
    padding: 12px 24px 12px 36px;
    font-size: 0.9rem;
    border-radius: 0;
  }

  nav ul li .dropdown .dropdown-submenu {
    position: static;
    transform: none;
    box-shadow: none;
    border: none;
    padding: 0;
    margin: 0;
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
  }
  
  nav ul li .dropdown .dropdown-submenu a {
    padding-left: 48px;
    background: rgba(0,0,0,0.02);
  }

  .mobile-menu-btn {
    display: flex;
    z-index: 2100;
  }

  .mobile-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 1199;
    opacity: 0;
    transition: opacity 0.35s;
  }

  .mobile-overlay.active {
    display: block;
    opacity: 1;
  }

  .director-card,
  .deputy-card {
    width: 100%;
    max-width: 300px;
  }
}

@media (max-width: 576px) {
  .hero h1 {
    font-size: 2rem;
  }
  .hero p {
    font-size: 0.95rem;
  }
  .container {
    width: 94%;
    padding: 0 12px;
  }
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }
  .stat-card {
    padding: 24px 14px;
  }
  .stat-number {
    font-size: 2rem;
  }
  .about-grid,
  .news-grid {
    grid-template-columns: 1fr;
  }
  .district-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }
  .contact-form {
    padding: 24px;
  }
  .hero-mini h1 {
    font-size: 1.8rem;
  }
  .personnel-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 14px;
  }
  .footer-content {
    grid-template-columns: 1fr;
  }
  .scroll-down {
    bottom: 20px;
  }
  section {
    padding: 70px 0;
  }
}

/* ===== News Detail Page ===== */
.news-detail-section {
  padding: 120px 0 80px;
  min-height: 60vh;
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 32px;
  font-size: 0.88rem;
  flex-wrap: wrap;
}

.breadcrumb a {
  color: var(--secondary);
  text-decoration: none;
  transition: color 0.2s;
}

.breadcrumb a:hover {
  color: var(--accent);
}

.breadcrumb span {
  color: var(--text-light);
}

.breadcrumb .current {
  color: var(--dark);
  font-weight: 600;
}

.news-article {
  background: var(--bg);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border);
}

.news-article-img {
  width: 100%;
  max-height: 480px;
  overflow: hidden;
}

.news-article-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.news-article-body {
  padding: 40px;
}

.news-meta {
  margin-bottom: 20px;
}

.news-date-badge {
  display: inline-block;
  background: rgba(91, 33, 182, 0.08);
  color: var(--secondary);
  padding: 6px 16px;
  border-radius: 50px;
  font-size: 0.88rem;
  font-weight: 600;
}

.news-article-body h1 {
  font-size: 2rem;
  color: var(--dark);
  line-height: 1.5;
  margin-bottom: 28px;
  padding-bottom: 20px;
  border-bottom: 2px solid var(--border);
}

.news-content-body {
  font-size: 1.05rem;
  line-height: 2;
  color: var(--text);
}

.news-content-body p {
  margin-bottom: 16px;
}

.news-content-body img {
  max-width: 100%;
  border-radius: var(--radius-sm);
  margin: 20px 0;
}

.news-back {
  margin-top: 40px;
  text-align: center;
}

.news-not-found {
  text-align: center;
  padding: 80px 20px;
}

.not-found-icon {
  font-size: 5rem;
  margin-bottom: 20px;
  opacity: 0.4;
}

.news-not-found h2 {
  font-size: 1.6rem;
  color: var(--dark);
  margin-bottom: 12px;
}

.news-not-found p {
  color: var(--text-light);
  margin-bottom: 28px;
}

@media (max-width: 768px) {
  .news-article-body {
    padding: 24px;
  }
  .news-article-body h1 {
    font-size: 1.4rem;
  }
  .news-detail-section {
    padding: 100px 0 60px;
  }
}

/* ===== Global Popup Slider ===== */
.global-popup-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(5px);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition:
    opacity 0.4s ease,
    visibility 0.4s ease;
}

.global-popup-overlay.active {
  opacity: 1;
  visibility: visible;
}

.global-popup-content {
  position: relative;
  width: 90%;
  max-width: 800px;
  background: transparent;
  border-radius: 12px;
  transform: scale(0.9);
  transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.global-popup-overlay.active .global-popup-content {
  transform: scale(1);
}

.global-popup-slider {
  position: relative;
  width: 100%;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 200px;
}

.global-popup-slide {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.6s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.global-popup-slide.active {
  opacity: 1;
  visibility: visible;
  position: relative;
}

.global-popup-slide img {
  max-width: 100%;
  max-height: 80vh;
  object-fit: contain;
  display: block;
}

.global-popup-close {
  position: absolute;
  top: -40px;
  right: 0;
  background: transparent;
  color: #fff;
  border: none;
  font-size: 2.5rem;
  line-height: 1;
  cursor: pointer;
  z-index: 10;
  transition: transform 0.2s;
}

.global-popup-close:hover {
  transform: scale(1.1);
  color: #ff4d4d;
}

.global-popup-prev,
.global-popup-next {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(0, 0, 0, 0.5);
  color: #fff;
  border: none;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  font-size: 1.2rem;
  cursor: pointer;
  z-index: 5;
  transition: background 0.3s;
  display: none;
}

.global-popup-prev:hover,
.global-popup-next:hover {
  background: var(--primary);
  color: #000;
}

.global-popup-prev {
  left: -22px;
}
.global-popup-next {
  right: -22px;
}

.global-popup-dots {
  position: absolute;
  bottom: -30px;
  left: 0;
  width: 100%;
  text-align: center;
}

.global-popup-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  background: rgba(255, 255, 255, 0.4);
  border-radius: 50%;
  margin: 0 5px;
  cursor: pointer;
  transition:
    background 0.3s,
    transform 0.3s;
}

.global-popup-dot.active {
  background: var(--primary);
  transform: scale(1.3);
}

@media (max-width: 768px) {
  .global-popup-content {
    width: 95%;
  }
  .global-popup-prev {
    left: 10px;
  }
  .global-popup-next {
    right: 10px;
  }
  .global-popup-close {
    top: -35px;
    right: 5px;
    font-size: 2rem;
  }
}

/* ==========================================================================
   HOMEPAGE MEDIA SECTION
   ========================================================================== */

.homepage-media-section {
    background: #f8fafc;
    position: relative;
    padding: 80px 0;
}

.homepage-media-section::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 100px;
    background: linear-gradient(to bottom, #f1f5f9, rgba(248, 250, 252, 0));
    pointer-events: none;
}

.media-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 30px;
    margin-top: 50px;
}

.media-card {
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
    overflow: hidden;
    transition: all 0.3s ease;
    border: 1px solid rgba(226, 232, 240, 0.8);
    display: flex;
    flex-direction: column;
}

.media-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    border-color: var(--primary-light);
}

.media-content-wrapper {
    position: relative;
    width: 100%;
    padding-top: 56.25%; /* 16:9 Aspect Ratio */
    background: #000;
    overflow: hidden;
}

.media-video,
.youtube-wrapper iframe,
.iframe-wrapper iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: none;
    object-fit: cover;
}

.iframe-wrapper {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    background: #fff; /* In case the iframe is smaller or transparent */
}

/* Make inner iframes responsive if the user pastes arbitrary HTML */
.iframe-wrapper > * {
    max-width: 100%;
    max-height: 100%;
}

.media-info {
    padding: 20px;
    background: #ffffff;
    flex-grow: 1;
    display: flex;
    align-items: center;
}

.media-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-dark);
    line-height: 1.5;
    margin: 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

@media (max-width: 768px) {
    .media-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }
}

/* ===== External Link Previews ===== */
.external-preview-container {
    margin: 30px 0;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: #fff;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.3s var(--ease-out), transform 0.3s var(--ease-out);
    clear: both;
}
.external-preview-container:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}
.preview-header {
    padding: 14px 20px;
    background: #f8fafc;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--dark);
}
.preview-title {
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 70%;
}
.btn-open-full {
    color: var(--secondary);
    font-size: 0.85rem;
    text-decoration: none;
    font-weight: 600;
    transition: all 0.2s;
    background: rgba(91, 33, 182, 0.05);
    padding: 6px 14px;
    border-radius: 50px;
}
.btn-open-full:hover {
    background: var(--secondary);
    color: #fff;
    text-decoration: none;
}
.preview-body {
    position: relative;
    width: 100%;
    padding-top: 56.25%; /* 16:9 Aspect Ratio */
    background: #f1f5f9;
}
.preview-body iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: none;
}
@media (min-width: 992px) {
    .preview-body {
        padding-top: 0;
        height: 700px;
    }
}
@media (max-width: 768px) {
    .preview-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    .preview-title { max-width: 100%; }
    .preview-body { padding-top: 130%; } /* More vertical for mobile */
}

