/* ============================================================
   LAYOUT.CSS — Graphic TECH
   Top bar, navbar + mega menu, footer, * 5. OVERLAY (Contact/Booking popup) & BACK TO TOP
   ============================================================ */

/* ------------------------------------------------------------
   TOP BAR
   ------------------------------------------------------------ */
.topbar {
  background: var(--primary-deep);
  color: rgba(255, 255, 255, .82);
  font-size: .82rem;
  position: relative;
  z-index: 60;
}
.topbar__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: 40px;
  padding-block: 6px;
}
.topbar__meta { display: flex; align-items: center; gap: 24px; flex-wrap: wrap; }
.topbar__meta a,
.topbar__meta span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  transition: color var(--t);
}
.topbar__meta a:hover { color: #fff; }
.topbar svg { width: 15px; height: 15px; opacity: .85; }

.topbar__social { display: flex; align-items: center; gap: 6px; }
.topbar__social a {
  width: 28px; height: 28px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: rgba(255, 255, 255, .10);
  transition: background var(--t), transform var(--t);
}
.topbar__social a:hover { background: var(--primary); transform: translateY(-2px); }

#app-header {
  display: contents;
}

/* ------------------------------------------------------------
   NAVBAR
   ------------------------------------------------------------ */
.navbar {
  position: sticky;
  top: 0;
  z-index: 90;
  background: rgba(255, 255, 255, .75);
  -webkit-backdrop-filter: blur(24px) saturate(200%);
  backdrop-filter: blur(24px) saturate(200%);
  border-bottom: 1px solid rgba(255, 255, 255, 0.4);
  transition: box-shadow var(--t), border-color var(--t), background var(--t), padding var(--t);
}
.navbar.is-stuck {
  background: rgba(255, 255, 255, .96);
  border-bottom-color: var(--line);
  box-shadow: 0 6px 26px rgba(13, 71, 161, .07);
}

.nav__inner {
  max-width: 1360px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: var(--nav-h);
}

/* Logo */
.nav__logo { display: flex; align-items: center; flex-shrink: 0; }
.nav__logo-img { height: 60px; width: auto; object-fit: contain; transition: height var(--t); }

/* Menu */
.nav__menu {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-left: auto;
}
.nav__item { position: relative; }

.nav__link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 10px 12px;
  border-radius: var(--r-sm);
  font-size: .88rem;
  font-weight: 500;
  color: var(--ink-2);
  white-space: nowrap;
  transition: color var(--t), background var(--t);
}
.nav__link:hover,
.nav__item:hover > .nav__link { color: var(--primary); background: var(--primary-soft); }
.nav__link.is-active { color: var(--primary); font-weight: 600; }
.nav__link .caret { width: 13px; height: 13px; transition: transform var(--t); }
.nav__item:hover .caret { transform: rotate(180deg); }

/* Mega dropdown */
.nav__mega {
  position: absolute;
  top: calc(100% + 12px);
  left: 50%;
  transform: translate(-50%, 12px);
  width: min(680px, 88vw);
  padding: 18px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity var(--t), transform var(--t), visibility var(--t);
}
.nav__item:hover > .nav__mega,
.nav__item:focus-within > .nav__mega {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translate(-50%, 0);
}
.nav__mega::before {
  content: '';
  position: absolute;
  top: -12px; left: 0; right: 0;
  height: 12px;
}
.nav__mega-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; }

.mega-link {
  display: flex;
  align-items: flex-start;
  gap: 13px;
  padding: 13px;
  border-radius: var(--r-md);
  transition: background var(--t), transform var(--t);
}
.mega-link:hover { background: var(--surface-2); transform: translateX(4px); }
.mega-link__icon {
  flex-shrink: 0;
  width: 40px; height: 40px;
  display: grid; place-items: center;
  border-radius: 11px;
  background: var(--primary-soft);
  color: var(--primary);
  transition: background var(--t), color var(--t);
}
.mega-link__icon svg { width: 19px; height: 19px; }
.mega-link:hover .mega-link__icon { background: var(--grad-primary); color: #fff; }
.mega-link b { display: block; font-size: .92rem; color: var(--ink); font-weight: 600; }
.mega-link p { font-size: .78rem; color: var(--muted); line-height: 1.55; margin-top: 2px; }

.nav__mega-foot {
  margin-top: 12px;
  padding: 14px 16px;
  border-radius: var(--r-md);
  background: var(--surface-2);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}
.nav__mega-foot p { font-size: .85rem; }

/* Nav actions */
.nav__actions { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }

.nav__phone {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-right: 14px;
  border-right: 1px solid var(--line);
}
.nav__phone-icon {
  width: 38px; height: 38px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary);
}
.nav__phone-icon svg { width: 18px; height: 18px; }
.nav__phone small { display: block; font-size: .7rem; color: var(--muted); line-height: 1.2; }
.nav__phone b { font-size: .95rem; color: var(--ink); font-weight: 600; }

/* Hamburger */
.nav__toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 44px; height: 44px;
  border-radius: var(--r-sm);
  border: 1px solid var(--line);
  background: #fff;
}
.nav__toggle span {
  display: block;
  width: 20px; height: 2px;
  margin-inline: auto;
  border-radius: 2px;
  background: var(--ink);
  transition: transform var(--t), opacity var(--t);
}
.nav__toggle.is-open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav__toggle.is-open span:nth-child(2) { opacity: 0; }
.nav__toggle.is-open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* Scroll progress bar */
.scroll-progress {
  position: absolute;
  left: 0; bottom: -1px;
  height: 3px;
  width: 0;
  background: var(--grad-primary);
  border-radius: 0 3px 3px 0;
  transition: width .1s linear;
}

/* ------------------------------------------------------------
   FOOTER
   ------------------------------------------------------------ */
.footer {
  background: #071A34;
  color: rgba(255, 255, 255, .68);
  position: relative;
  overflow: hidden;
}
.footer::before {
  content: '';
  position: absolute;
  top: -180px; right: -120px;
  width: 460px; height: 460px;
  border-radius: 50%;
  background: rgba(33, 150, 243, .16);
  filter: blur(100px);
}
.footer__top {
  position: relative;
  display: grid;
  grid-template-columns: 3.2fr 1.6fr 1.6fr auto;
  gap: clamp(16px, 2.5vw, 36px);
  padding: clamp(56px, 7vw, 84px) clamp(20px, 4vw, 50px) 52px clamp(20px, 6vw, 80px);
}
.footer__brand .nav__logo { margin-bottom: 20px; }
.footer__brand .nav__logo-text b { color: #fff; }
.footer__brand .nav__logo-text b span { color: var(--blue-200); }
.footer__brand .nav__logo-text small { color: rgba(255,255,255,.45); }
.footer__brand p { color: rgba(255, 255, 255, .62); font-size: 1.05rem; margin-bottom: 22px; }

.footer h4 {
  color: #fff;
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 22px;
  position: relative;
  padding-bottom: 12px;
}
.footer h4::after {
  content: '';
  position: absolute;
  left: 0; bottom: 0;
  width: 34px; height: 2px;
  border-radius: 2px;
  background: var(--blue-200);
}

.footer__links { display: flex; flex-direction: column; gap: 12px; }
.footer__links a {
  font-size: 1.0rem;
  color: rgba(255, 255, 255, .66);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: color var(--t), transform var(--t);
}
.footer__links a::before {
  content: '';
  width: 5px; height: 5px;
  border-radius: 50%;
  background: rgba(144, 202, 249, .55);
  transition: background var(--t);
}
.footer__links a:hover { color: #fff; transform: translateX(4px); }
.footer__links a:hover::before { background: var(--blue-200); }

.footer__contact { display: flex; flex-direction: column; gap: 16px; }
.footer__contact li { display: flex; gap: 13px; font-size: 1.0rem; line-height: 1.65; }
.footer__contact svg {
  width: 18px; height: 18px;
  flex-shrink: 0;
  margin-top: 4px;
  color: var(--blue-200);
}
.footer__contact a { transition: color var(--t); }
.footer__contact a:hover { color: #fff; }

.footer__social { display: flex; gap: 10px; }
.footer__social a {
  width: 38px; height: 38px;
  display: grid; place-items: center;
  border-radius: 11px;
  background: rgba(255, 255, 255, .08);
  color: #fff;
  transition: background var(--t), transform var(--t);
}
.footer__social a svg { width: 18px; height: 18px; }
.footer__social a:hover { background: var(--primary); transform: translateY(-3px); }

.footer__bottom {
  position: relative;
  border-top: 1px solid rgba(255, 255, 255, .10);
  padding: 22px 0 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  flex-wrap: wrap;
  font-size: .85rem;
}
.footer__bottom nav { display: flex; gap: 22px; flex-wrap: wrap; }
.footer__bottom a { transition: color var(--t); }
.footer__bottom a:hover { color: #fff; }

/* ------------------------------------------------------------
   FLOATING ACTION BUTTONS
   ------------------------------------------------------------ */
.fab-stack {
  position: fixed;
  right: 20px;
  bottom: 22px;
  z-index: 80;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.fab-group {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 12px;
  position: absolute;
  bottom: 100%;
  right: 0;
  margin-bottom: 12px;
  pointer-events: none;
}

.fab-group > * {
  opacity: 0;
  transform: translateY(20px) scale(0.8);
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.fab-stack.is-open .fab-group {
  pointer-events: auto;
}
.fab-stack.is-open .fab-group > * {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.fab-toggle {
  width: 54px; height: 54px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--blue-400); /* ฟ้าอ่อนตามคำขอ */
  color: #fff;
  border: none;
  box-shadow: 0 10px 26px rgba(4, 30, 66, .26);
  cursor: pointer;
  transition: background var(--t), transform var(--t);
  position: relative;
  z-index: 2;
}
.fab-toggle svg { width: 24px; height: 24px; transition: transform 0.4s ease; }
.fab-stack.is-open .fab-toggle svg { transform: rotate(135deg); }
.fab-toggle:hover { background: var(--primary); transform: scale(1.05); }

.fab {
  position: relative;
  width: 54px; height: 54px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  box-shadow: 0 10px 26px rgba(4, 30, 66, .26);
  transition: transform var(--t), box-shadow var(--t), filter var(--t);
}
.fab svg { width: 26px; height: 26px; }
.fab:hover { transform: translateY(-4px) scale(1.06); box-shadow: 0 16px 34px rgba(4, 30, 66, .32); }

.fab--fb     { background: #1877F2; }
.fab--line   { background: #00B900; }
.fab--ig     { background: linear-gradient(45deg, #f09433 0%, #e6683c 25%, #dc2743 50%, #cc2366 75%, #bc1888 100%); }
.fab--phone  { background: var(--grad-primary); }
.fab--wa     { background: #25D366; }
.fab--mail   { background: var(--primary-deep); }

/* Tooltip label */
.fab__label {
  position: absolute;
  right: calc(100% + 12px);
  top: 50%;
  transform: translateY(-50%) translateX(8px);
  padding: 7px 14px;
  background: var(--ink);
  color: #fff;
  font-size: .8rem;
  font-weight: 500;
  white-space: nowrap;
  border-radius: var(--r-sm);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--t), transform var(--t);
}
.fab__label::after {
  content: '';
  position: absolute;
  left: 100%; top: 50%;
  transform: translateY(-50%);
  border: 5px solid transparent;
  border-left-color: var(--ink);
}
.fab:hover .fab__label { opacity: 1; transform: translateY(-50%) translateX(0); }

/* Pulse ring on the primary contact button */
.fab--pulse::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: inherit;
  animation: fab-pulse 2.4s var(--ease-out) infinite;
  z-index: -1;
}

/* Back to top */
.to-top {
  position: absolute;
  bottom: 4px;
  right: 4px;
  width: 46px; height: 46px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: #fff;
  border: 1px solid var(--line);
  color: var(--primary);
  box-shadow: var(--shadow-md);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-40px) scale(0.8);
  transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  z-index: 1;
}
.to-top svg { width: 20px; height: 20px; }

/* When visible and stack is closed */
.to-top.is-visible { 
  opacity: 1; 
  visibility: visible; 
  transform: translateY(-62px) scale(1); /* Sits above the toggle */
}

/* When visible and stack is OPEN */
.fab-stack.is-open .to-top.is-visible {
  transform: translateX(-62px) scale(1); /* Moves to the left of the toggle */
}

.to-top:hover { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ------------------------------------------------------------
   OVERLAY PANEL (drawer for service/about detail pages)
   ------------------------------------------------------------ */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  visibility: hidden;
  pointer-events: none;
}
.overlay.open { visibility: visible; pointer-events: auto; }

.overlay-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(9, 25, 49, .45);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  opacity: 0;
  transition: opacity .4s var(--ease);
}
.overlay.open .overlay-backdrop { opacity: 1; }

.overlay-panel {
  position: absolute;
  top: 0; right: 0; bottom: 0;
  width: min(760px, 100vw);
  background: #fff;
  border-left: 1px solid var(--line);
  box-shadow: -30px 0 80px rgba(9, 25, 49, .18);
  transform: translateX(100%);
  transition: transform .45s var(--ease-out);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.overlay.open .overlay-panel { transform: translateX(0); }

.overlay-close {
  position: absolute;
  top: 22px; left: 22px;
  width: 42px; height: 42px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink);
  transition: all var(--t);
  z-index: 10;
}
.overlay-close svg { width: 18px; height: 18px; }
.overlay-close:hover {
  background: var(--grad-primary);
  border-color: transparent;
  color: #fff;
  transform: rotate(90deg);
}

.overlay-body {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 84px 52px 60px;
  scroll-behavior: smooth;
}
.overlay-body::-webkit-scrollbar { width: 6px; }
.overlay-body::-webkit-scrollbar-track { background: transparent; }
.overlay-body::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 4px; }

.overlay-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  gap: 16px;
  color: var(--muted);
  font-size: .9rem;
}
.spinner {
  width: 34px; height: 34px;
  border: 3px solid var(--line);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

@media (max-width: 700px) {
  .overlay-body { padding: 76px 24px 48px; }
}


/* ------------------------------------------------------------
   RESPONSIVE
   ------------------------------------------------------------ */
@media (max-width: 1240px) {
  .nav__phone { display: none; }
}

@media (max-width: 980px) {
  .footer__top { 
    grid-template-columns: repeat(2, minmax(0, 360px)); 
    justify-content: center; 
    gap: clamp(38px, 6vw, 60px); 
  }
}

@media (max-width: 1024px) {
  .navbar {
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
    background: rgba(255, 255, 255, 0.98);
  }

  .nav__toggle { 
    display: flex; 
    z-index: 96; 
    position: relative;
    margin-left: auto;
  }
  .nav__actions .btn { display: none; }

  .nav__menu {
    position: fixed;
    inset: 0 0 0 auto;
    width: min(320px, 86vw); /* slightly narrower for minimal look */
    height: 100vh;
    height: 100dvh;
    flex-direction: column;
    align-items: stretch;
    gap: 0px; /* remove gap, rely on padding */
    padding: 80px 24px 40px;
    background: #fff;
    box-shadow: -10px 0 40px rgba(0, 0, 0, .08); /* softer shadow */
    transform: translateX(100%);
    transition: transform .38s var(--ease-out);
    overflow-y: auto;
    z-index: 95;
  }
  .nav__menu.is-open { transform: translateX(0); }
  
  .nav__link { 
    padding: 16px 4px; 
    font-size: 1.05rem; 
    justify-content: space-between; 
    border-bottom: 1px solid rgba(0,0,0,0.04); /* minimal separator */
    border-radius: 0;
  }
  .nav__item:last-child .nav__link { border-bottom: none; }

  .nav__mega {
    position: static;
    transform: none;
    width: 100%;
    box-sizing: border-box;
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    box-shadow: none;
    border: none;
    background: transparent;
    padding: 0;
    margin: 0;
    max-height: 0;
    overflow: hidden;
    transition: max-height .38s var(--ease-out);
  }
  .nav__item:hover > .nav__mega,
  .nav__item:focus-within > .nav__mega {
    transform: none;
  }
  .nav__item.is-expanded > .nav__mega { max-height: 720px; }
  .nav__item.is-expanded .caret { transform: rotate(180deg); }
  
  .nav__mega-grid { 
    grid-template-columns: 1fr; 
    padding: 8px 0 16px 16px; /* move padding here so max-height:0 works cleanly */
    gap: 4px;
  }
  .nav__mega-foot { display: none; }
  
  .mega-link { 
    padding: 10px 8px; 
    background: transparent;
  }
  .mega-link:hover { background: rgba(0,0,0,0.02); }

  .nav__backdrop {
    position: fixed;
    inset: 0;
    background: rgba(7, 26, 52, .45);
    -webkit-backdrop-filter: blur(3px);
    backdrop-filter: blur(3px);
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--t), visibility var(--t);
    z-index: 94;
  }
  .nav__backdrop.is-open { opacity: 1; visibility: visible; }
}

@media (max-width: 700px) {
  .topbar__meta .topbar__hide-sm { display: none; }
  .topbar__inner { justify-content: center; }
  .footer__top { grid-template-columns: 1fr; gap: 34px; }
  .footer__bottom { flex-direction: column; text-align: center; padding-bottom: 90px; }
  .fab-stack { right: 14px; bottom: 16px; gap: 10px; }
  .fab { width: 48px; height: 48px; }
  .fab svg { width: 23px; height: 23px; }
  .fab__label { display: none; }

}

@media (max-width: 400px) {
  .nav__inner { gap: 10px; }
  .navbar .nav__logo-img, .footer .nav__logo-img { height: 40px !important; }
}

/* Mobile Footer Fixes */
@media (max-width: 980px) {
  .footer__top { text-align: center; padding-left: 0; padding-right: 0; }
  .footer__brand .nav__logo { justify-content: center; margin-bottom: 24px; }
  .footer h4::after { left: 50%; transform: translateX(-50%); }
  .footer__social { justify-content: center; margin-top: 10px; }
  .footer__links { width: max-content; margin: 0 auto; align-items: flex-start; }
  .footer__contact { align-items: center; padding-right: 0; }
  .footer__contact li { display: block; word-break: break-word; text-align: center; }
  .footer__contact svg { display: inline-block; vertical-align: middle; margin-right: 6px; margin-top: -3px; }
  
  .navbar .nav__logo-img { height: 50px !important; }
  .footer .nav__logo-img { height: 50px !important; }
}
