/* =========================
   OBJECT ITEM (circle icon)
========================= */
.object-item .circle {
  border-radius: 50%;
  margin: 0 auto 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #0d6efd;
  color: #fff;
  box-shadow: 0 4px 12px rgba(0,0,0,.15);
  transition: transform .2s ease, box-shadow .2s ease;
}
.object-item .circle-sm { width: 70px; height: 70px; font-size: 24px; }
.object-item .circle-md { width: 90px; height: 90px; font-size: 32px; }
.object-item .circle-lg { width: 110px; height: 110px; font-size: 40px; }

.object-item .circle:hover {
  transform: translateY(-4px);
  box-shadow: 0 6px 18px rgba(0,0,0,.2);
}

.object-item .object-text p { font-weight: normal; margin-bottom: 2px; }
.object-item .object-text small { display: block; font-size: 0.875rem; }

.circle img.icon-img {
  max-width: 60%;
  max-height: 60%;
  object-fit: contain;
}

/* =========================
   OCTAGON (rounded)
========================= */
.octagon-rounded {
  --r: 8;
  width: 220px;
  height: 220px;
  background: url('your-photo.jpg') center/cover no-repeat;
  clip-path: path("M30,0 H70 A var(--r) var(--r) 0 0 1 78,8 L100,30 A var(--r) var(--r) 0 0 1 100,42 V70 A var(--r) var(--r) 0 0 1 92,78 L70,100 A var(--r) var(--r) 0 0 1 58,100 H42 A var(--r) var(--r) 0 0 1 30,100 L8,78 A var(--r) var(--r) 0 0 1 0,70 V42 A var(--r) var(--r) 0 0 1 0,30 L22,8 A var(--r) var(--r) 0 0 1 30,0 Z");
  box-shadow: 0 6px 18px rgba(0,0,0,.18);
  transition: transform .25s ease, box-shadow .25s ease;
}
.octagon-rounded:hover{
  transform: translateY(-4px);
  box-shadow: 0 10px 26px rgba(0,0,0,.22);
}
@supports not (clip-path: path("M0,0 L1,1")) {
  .octagon-rounded {
    clip-path: polygon(
      30% 0%, 70% 0%,
      100% 30%, 100% 70%,
      70% 100%, 30% 100%,
      0% 70%, 0% 30%
    );
  }
}

/* =========================
   THEME VARIABLES
========================= */
:root {
  --card-bg: #fff;
  --card-text: #334155;
  --muted: #6b7280;
  --ring: #60a5fa;
  --shadow: 0 8px 22px rgba(0,0,0,.12);
  --shadow-hover: 0 14px 30px rgba(0,0,0,.16);

  --brand-circle: #2f6cf0;
  --internet: #16a34a;
  --intranet: #e11d48;

  --icon-bg: #294780;
  --icon-shadow: 0 10px 22px rgba(0,0,0,.18);

  --mz-gap: .5rem;
}

@media (prefers-color-scheme: dark){
  :root{ --icon-bg:#4f67d9; }
}

/* =========================
   SERVICE CARDS
========================= */
.services { margin-top: 12px; }
.section-head { margin-bottom: 18px; }
.section-title{
  font-size: 1.25rem;
  font-weight: 600;
  text-align: center;
  background: #e3f2fd;
  color: #1e3a8a;
  padding: 10px 16px;
  border-radius: 12px;
}

.service-card{
  display: grid;
  grid-template-rows: auto auto auto;
  align-items: start;
  justify-items: center;

  background: var(--card-bg);
  border-radius: 16px;
  text-decoration: none;
  color: var(--card-text);
  padding: 20px 16px;
  margin-bottom: 24px;

  box-shadow: var(--shadow);
  transition: transform .2s ease, box-shadow .2s ease;
}
.service-card:hover{
  transform: translateY(-4px);
  box-shadow: var(--shadow-hover);
}
.service-card:focus-visible{
  outline: 3px solid var(--ring);
  outline-offset: 2px;
  box-shadow: none;
}

/* icon circle (final version kept) */
.service-icon{
  --d: 120px;
  width: var(--d);
  height: var(--d);
  border-radius: 50%;
  background: var(--icon-bg);
  display: grid;
  place-items: center;
  margin-bottom: 14px;
  box-shadow: var(--icon-shadow);
  transition: transform .18s ease;
}
.service-card:hover .service-icon{ transform: scale(1.03); }

.service-icon img{
  width: 64%;
  height: 64%;
  object-fit: contain;
  display: block;
}

@media (max-width: 991.98px){ .service-icon{ --d: 104px; } }
@media (max-width: 575.98px){ .service-icon{ --d: 88px; } }

/* ring option */
.service-icon.is-ring{
  background: transparent;
  box-shadow: none;
  outline: 8px solid color-mix(in srgb, var(--icon-bg) 18%, white);
}

.service-title{
  font-weight: 400;
  font-size: 1.05rem;
  line-height: 1.35;
  text-align: center;
  margin: 4px 0 10px;
  min-height: 2.7em;
  color: var(--card-text);
}
.service-card .badge{ margin-top: -2px; }

/* badge */
.badge{
  display: inline-block;
  padding: .35rem .6rem;
  font-size: .78rem;
  border-radius: 999px;
  font-weight: 600;
  line-height: 1;
  letter-spacing: .2px;
  color: #fff;
}
.badge-internet{ background: var(--internet); }
.badge-intranet{ background: var(--intranet); }

/* reduce motion */
@media (prefers-reduced-motion: reduce){
  .service-card, .service-card:hover {
    transition: none;
    transform: none;
  }
}

/* spacing row */
.row.text-center.m-t-40{ row-gap: 28px; }

/* =========================
   HR ICON PLAIN (no circle)
========================= */
.hr-card-icon-plain {
  width: 180px;
  height: 254px;
  margin: 0 auto 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.hr-card-icon-plain img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  display: block;
}

/* =========================
   HR STAT CARD (upgraded)
========================= */
.hr-stat-card {
  container-type: inline-size;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;

  border-radius: 12px;
  padding: 20px;
  min-height: 200px;

  background-color: var(--card-bg, #f5f7ff);
  border: 1.5px solid var(--card-border, #90A4D4);

  transition:
    background-color .25s ease,
    border-color .25s ease,
    box-shadow .25s ease,
    transform .25s ease,
    filter .25s ease;

  text-decoration: none;
  box-shadow: 0 2px 6px rgba(0,0,0,.05);
}

.hr-stat-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 6px 16px rgba(0,0,0,.12);
  filter: brightness(0.97);
  border-color: var(--card-border-hover, #9fb6ee);
}

/* media */
.hr-stat-media {
  width: 72px;
  height: 72px;
  margin-bottom: 10px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  overflow: hidden;
  background: #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,.08);
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}
.hr-stat-card:hover .hr-stat-media {
  transform: translateY(-4px) scale(1.08);
  box-shadow: 0 6px 14px rgba(0,0,0,.15);
}
.hr-stat-media img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  display: block;
}
.hr-stat-media .emoji { font-size: 34px; line-height: 1; }

/* month */
.hr-stat-month {
  font-size: clamp(1.6rem, 7cqi, 2.4rem);
  line-height: 1.4;
  font-weight: 800;
  letter-spacing: .5px;
  margin: 2px 0 10px;
  color: #223b7b;
  text-wrap: balance;
  overflow-wrap: hidden;
}
@supports not (font-size: 1cqi){
  .hr-stat-month{ font-size: clamp(1.25rem, 4.5vw, 2.5rem); }
  @media (max-width: 1200px){ .hr-stat-month{ font-size: 2.1rem; } }
  @media (max-width: 992px) { .hr-stat-month{ font-size: 1.9rem; } }
  @media (max-width: 768px) { .hr-stat-month{ font-size: 1.7rem; } }
  @media (max-width: 576px) { .hr-stat-month{ font-size: 1.5rem; } }
}

.hr-stat-meta {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0px;
  font-size: 0.875em;
}

.hr-stat-event {
  display: block;
  text-align: center;
  margin: 0;
  line-height: 1.3;
}
.hr-stat-event label {
  display: inline-block;
  margin-bottom: 2px;
}
.hr-stat-event span {
  display: block;
  font-size: 0.875em;
}

.hr-stat-date {
  background: #294780;
  color: #fff;
  line-height: 13px;
  font-weight: 400;
  font-size: 75%;
  padding: 2px 6px;
  border-radius: 4px;
}
.hr-stat-place {
  font-weight: 600;
  font-size: 0.95rem;
  color: #1f2f55;
}

/* misc */
.hr-stat-card .hr-stat-icon { font-size: 32px; margin-bottom: 10px; }
.hr-stat-card .hr-stat-title { font-size: 1rem; margin-bottom: 4px; font-weight: 500; }
.hr-stat-card .hr-stat-value { font-size: 1.25rem; font-weight: 600; }

/* color schemes */
.hr-stat-blue   { --card-bg:#EEF4FF; --card-border:#C2D4F6; --card-border-hover:#90B4F0; }
.hr-stat-green  { --card-bg:#E8FDF6; --card-border:#A7E3CD; --card-border-hover:#6CD0AF; }
.hr-stat-red    { --card-bg:#FFF3F2; --card-border:#F5B7B1; --card-border-hover:#EE8E86; }
.hr-stat-cyan   { --card-bg:#F0F8FF; --card-border:#B5D9F6; --card-border-hover:#8BC0EE; }
.hr-stat-orange { --card-bg:#FFF9F0; --card-border:#F5D6A0; --card-border-hover:#E8BF77; }
.hr-stat-purple { --card-bg:#F5F2FF; --card-border:#C6B6F5; --card-border-hover:#A798EE; }
.hr-stat-muted  { --card-bg:#F5F6F8; --card-border:#D1D5DB; --card-border-hover:#C7CDD6; }

/* muted final */
.hr-stat-muted{
  opacity: 0.75;
}

/* บังคับขาวดำที่รูปโดยตรง */
.hr-stat-muted img{
  filter: grayscale(100%) !important;
  -webkit-filter: grayscale(100%) !important;
  transition: none !important;
}

/* กัน hover ทุกกรณี */
.hr-stat-muted:hover img,
.hr-stat-muted img:hover{
  filter: grayscale(100%) !important;
  -webkit-filter: grayscale(100%) !important;
}

/* ตัวหนังสือ */
.hr-stat-muted .hr-stat-month{
  color: #6B7280;
}

/* ปุ่ม */
.hr-stat-muted .btn{
  background-color: #E5E7EB;
  color: #6B7280;
  border-color: #D1D5DB;
}


/* responsive tweaks */
@media (max-width: 575.98px){
  .hr-stat-card { min-height: 180px; padding: 16px; }
  .hr-stat-media { width: 60px; height: 60px; }
  .hr-stat-month { font-size: 1.8rem; }
  .hr-stat-date { font-size: .8rem; }
}

/* =========================
   MASONRY (mobile only)
   < md : เรียงซ้าย → ขวา
========================= */

@media (max-width: 767.98px){

  /* override d-block จาก bootstrap */
  .masonry{
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)); /* 2 เดือนต่อแถว */
    gap: var(--mz-gap);
  }

  .masonry-item{
    display: block;
    width: 100%;
    margin: 0 !important;

    break-inside: unset;
    -webkit-column-break-inside: unset;
    -moz-column-break-inside: unset;
    page-break-inside: unset;
  }

  .masonry .masonry-item,
  .masonry .masonry-item > [class*="mb-"]{
    margin-bottom: 0 !important;
  }

  .masonry-item .hr-stat-card{
    margin: 0;
    height: auto;
  }

}



/* =========================
   CURRENT MONTH CARD
========================= */
.hr-current-card{
  padding: 0;
  min-height: 220px;
  /* pointer-events: none; */
}

@media (min-width: 992px){
  .hr-current-right{
    border-left: 1px solid rgba(0,0,0,.10);
    min-height: 100%;
  }
}

.hr-current-left{
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  height: 100%;
  padding: 24px;
}
.hr-current-left-card{
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  height: 100%;
}

.hr-stat-current{
  position: relative;
  z-index: 1;
  box-shadow:
    0 0 0 1px rgba(47,108,240,.25),
    0 8px 22px rgba(47,108,240,.25),
    0 0 24px rgba(47,108,240,.18);
}
.hr-stat-current:hover{
  box-shadow:
    0 0 0 1px rgba(47,108,240,.35),
    0 12px 30px rgba(47,108,240,.30),
    0 0 34px rgba(47,108,240,.22);
}

/* current scope */
#currentWrap .hr-stat-month { font-size: 44px; line-height: 1.1; }
#currentWrap .hr-stat-card  { min-height: 220px; }
#currentWrap .hr-current-left-card{
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  text-align:center;
  height:100%;
}

/* =========================
   FLIP CLONE / STATE
========================= */
.flip-clone{
  position: fixed;
  left: 0;
  top: 0;
  margin: 0 !important;
  z-index: 9999;
  pointer-events: none;
  transform-origin: top left;
  transition: transform .55s cubic-bezier(.2,.8,.2,1);
  will-change: transform;
}
html.is-flipping, html.is-flipping *{ cursor: progress !important; }

/* month text ellipsis in month card */
.hr-month-card .hr-stat-month{
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ecal-search-wrap{ min-width:240px; }
.w-date{
  width: fit-content;
  white-space: nowrap;
}
.w-place{ width:180px; }
.w-contact{ width:120px; }

/* ===== HARDCORE ECAL MODAL ONLY ===== */
/* อย่าไปทับ .modal ทุกตัวทั่วระบบแรงๆ ให้ล็อคเฉพาะ modal เรา */
#exampleModal.modal{
  position: fixed !important;
  inset: 0 !important;
  z-index: 2147483646 !important;
  display: none;              /* default hidden */
  overflow: auto;             /* ช่วยกรณีเนื้อหายาว */
  -webkit-overflow-scrolling: touch;
}

/* เปิดแบบ fallback */
#exampleModal.modal.ecal-show{
  display: block !important;
}

/* dialog/content ให้อยู่บนสุด */
#exampleModal .modal-dialog,
#exampleModal .modal-content{
  position: relative;
  z-index: 2147483647 !important;
}

/* backdrop ของเรา */
.ecal-backdrop{
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 2147483645 !important;
  pointer-events: auto !important; /* ให้คลิกได้ชัวร์ */
}

/* lock scroll เฉพาะตอนเราเปิด fallback */
body.ecal-modal-open{
  overflow: hidden !important;
}

/* อย่า nuke ทั้ง html,body แนะนำให้ล็อคเฉพาะ wrapper ที่เป็นปัญหา */
.page-wrapper, .container-fluid{
  transform: none !important;
  filter: none !important;
  perspective: none !important;
  overflow: visible !important;
}

/* === ECAL SMOOTH FADE (CSP-safe, class-only) === */

/* modal base (ยังคง hardcore z-index ของมึง) */
.modal {
  display: none;
}

/* โผล่ขึ้นมาแล้ว แต่ยัง "ยังไม่ in" -> โปร่งใส */
.modal.ecal-show{
  display:block !important;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity .18s ease, transform .18s ease;
  will-change: opacity, transform;
}

/* เข้าสถานะ in -> ทึบ + ขยับเข้าที่ */
.modal.ecal-show.ecal-in{
  opacity: 1;
  transform: translateY(0);
}

/* backdrop */
.ecal-backdrop{
  opacity: 0;
  transition: opacity .18s ease;
  will-change: opacity;
}
.ecal-backdrop.ecal-in{
  opacity: 1;
}

/* ถ้าผู้ใช้ตั้ง reduce motion */
@media (prefers-reduced-motion: reduce){
  .modal.ecal-show,
  .ecal-backdrop{
    transition: none !important;
  }
}

/* วันที่ + ประเภท = กว้างเท่าข้อความจริง และไม่ขึ้นบรรทัด */
.ecal-table th.col-date,
.ecal-table td.col-date,
.ecal-table th.col-cate,
.ecal-table td.col-cate {
  white-space: nowrap;   /* ห้ามตัดบรรทัด */
  width: 1%;             /* บังคับให้ shrink ตาม content */
  vertical-align: middle;
}

/* กิจกรรม = รับพื้นที่ที่เหลือ */
.ecal-table th.col-title,
.ecal-table td.col-title {
  width: auto;
}


