/* ==========================================================================
   mobile.css — Mobile-first UX/UI + Core Web Vitals (LCP / CLS / INP)
   โหลดเป็นไฟล์สุดท้ายเสมอ เพื่อ override style.css / shop.css ได้
   ========================================================================== */

/* ==========================================================================
   1. STABILITY — ลด CLS
   ========================================================================== */

/* หมายเหตุ: รูปที่มี width+height attribute เบราว์เซอร์คำนวณ aspect-ratio ให้เอง
   คู่กับ `img{max-width:100%;height:auto}` ใน style.css → จองพื้นที่ได้ถูกต้อง
   จึงไม่ต้องเขียนกฎซ้ำตรงนี้ งานที่เหลือคือรูปที่ยังไม่มีขนาดกำกับ */

/* พื้นรองรูประหว่างโหลด — ใส่แค่สีพื้น ไม่ไปยุ่งกับ position/height
   (เคยพลาดตรงนี้: เคยบังคับ position:relative + height:100% ให้กลุ่มนี้ทั้งก้อน
    ซึ่งทับค่าที่ style.css ตั้งไว้ถูกแล้ว —
      .ps-img-slide ต้องเป็น position:absolute สำหรับอนิเมชันสไลด์ พอถูกเปลี่ยน
      เป็น relative รูปพืชน้ำมันเลยหายทั้งบล็อก
      .article-img-wrap img มี height คงที่ 220/260px อยู่แล้ว พอถูกเปลี่ยนเป็น
      height:100% บนพ่อที่สูง auto รูปเลยยืดจนดันข้อความบทความหลุดจอ
    ทั้งสามตัวจองพื้นที่ไว้เองอยู่แล้ว จึงไม่ต้องมีกฎกัน CLS ซ้ำตรงนี้) */
.testimonial-img-wrap,
.article-img-wrap,
.ps-col-image,
.product-img { background: var(--green-bg, #f0f9f0); }

/* ขวดสินค้าใน hero — เดิมกำหนดความกว้างด้วย inline style ที่ตัว <img>
   ย้ายมาไว้ที่ CSS และจองความสูงของช่องไว้ เพราะแต่ละรูปสัดส่วนไม่เท่ากัน */
.showcase-bottle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 200px;
  min-height: 240px;
}
.showcase-bottle img { width: 200px; height: auto; }

/* ใบไม้ตกแต่ง hero: จองขนาดไว้ก่อน JS ใส่ src (เดิม src="" → ยุบ 0px) */
.hero-leaves .leaf {
  width: 120px;
  height: 135px;
  object-fit: contain;
  contain: layout paint;
}
.hero-leaves .leaf:not([src]),
.hero-leaves .leaf[src=""] { visibility: hidden; }

/* กันแถบเลื่อนหายไป-โผล่มา แล้วเนื้อหาขยับซ้ายขวา */
html { scrollbar-gutter: stable; }

/* ==========================================================================
   2. RENDERING BUDGET — ลดงาน main thread (ช่วย INP + LCP)
   ========================================================================== */

/* ข้ามการ layout/paint ส่วนที่ยังไม่เข้าจอ
   contain-intrinsic-size จองความสูงคร่าว ๆ ไว้ ทำให้ scrollbar ไม่กระโดด
   ("auto" = จำความสูงจริงไว้หลังเรนเดอร์รอบแรก) */
.section.plants-section,
.section.oil-info-section,
.articles-section,
.contact-brief {
  content-visibility: auto;
  contain-intrinsic-size: auto 700px;
}
.footer {
  content-visibility: auto;
  contain-intrinsic-size: auto 420px;
}

/* บอกเบราว์เซอร์ว่าอนิเมชันของการ์ดจำกัดอยู่ในกล่องตัวเอง */
.product-card,
.testimonial-card,
.article-card { contain: layout paint style; }

/* will-change ค้างไว้ตลอดกิน GPU memory — ให้ทำงานเฉพาะตอนกำลังเคลื่อนไหว */
.hero-photo { will-change: auto; }
.hero.hero-bg-loading .hero-photo { will-change: filter, transform; }
.showcase-slide { will-change: auto; }
.showcase-slide.active,
.showcase-slide.prev,
.showcase-slide.next { will-change: opacity, transform; }

/* ==========================================================================
   3. TOUCH ERGONOMICS — เป้าแตะขั้นต่ำ 44×44px (WCAG 2.5.5)
   ========================================================================== */

a, button, [role="button"], input[type="submit"], label {
  -webkit-tap-highlight-color: rgba(45, 106, 79, 0.15);
  touch-action: manipulation; /* ตัด delay 300ms ของ double-tap zoom */
}

@media (hover: none) and (pointer: coarse) {
  .nav-toggle,
  .cart-close,
  .site-popup-close,
  .carousel-arrow,
  .ps-nav-btn,
  .btn-wishlist {
    min-width: 44px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .filter-btn,
  .btn-cart,
  .btn-quickview,
  .feature-btn,
  .ps-read-more,
  .art-readmore,
  .cc-btn,
  .social-btn {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
  .social-btn { min-width: 44px; }

  /* จุดบอกสไลด์กว้างแค่ 10px — ขยาย hit area ด้วย ::after ให้ครบ 44px
     (10 + 17×2 = 44) โดยหน้าตาที่มองเห็นยังเท่าเดิม */
  .carousel-dot,
  .site-popup-dot,
  .swiper-pagination-bullet { position: relative; }
  .carousel-dot::after,
  .site-popup-dot::after,
  .swiper-pagination-bullet::after {
    content: "";
    position: absolute;
    inset: -17px;
  }

  /* ลิงก์นโยบาย/เงื่อนไข ที่แทรกอยู่ในย่อหน้าท้ายเว็บ สูงแค่ 17px */
  .footer-bottom p a,
  .cc-banner p a {
    display: inline-block;
    min-height: 44px;
    line-height: 44px;
    padding-inline: 0.25rem;
    text-decoration: underline;
    text-underline-offset: 3px;
  }

  /* ลิงก์ใน footer อยู่ชิดกันเกินไปสำหรับนิ้วโป้ง */
  .footer-links li a {
    display: block;
    padding: 0.55rem 0;
    min-height: 44px;
  }

  /* :hover ค้างบนมือถือ — ปิดเอฟเฟกต์ยกการ์ดทิ้ง */
  .product-card:hover,
  .testimonial-card:hover,
  .article-card:hover { transform: none; }

  /* overlay "ดูสินค้า / ♡" โผล่ตอน hover เท่านั้น จึงแตะไม่ติดบนจอสัมผัส
     ซ่อนทิ้งไปเลย: ทั้งการ์ดกดได้อยู่แล้ว (onclick ที่ .product-img) และการดัน
     overlay ให้อยู่ในโฟลว์ถาวรทำให้เกิดแถบว่างใต้รูปสินค้าทุกใบ */
  .product-overlay { display: none; }
}

/* ==========================================================================
   4. MOBILE NAVIGATION — drawer เลื่อนจากขวา
   ========================================================================== */

@media (max-width: 768px) {
  .navbar {
    /* backdrop-filter 24px แพงมากบน GPU มือถือตอน scroll */
    backdrop-filter: blur(12px) saturate(140%);
    -webkit-backdrop-filter: blur(12px) saturate(140%);
    padding-top: env(safe-area-inset-top, 0px);
  }
  /* ชั้น grain ของ navbar ใช้ SVG feTurbulence (filter:url(#lg-noise)) ซึ่ง
     raster บน CPU และมองแทบไม่เห็นบนจอเล็ก — ปิดทิ้ง
     (::after คือเส้นขอบล่าง ต้องเก็บไว้) */
  .navbar::before { display: none; }

  .nav-container { padding-inline: 1rem; }

  .nav-toggle {
    display: flex;
    justify-content: center;
    gap: 5px;
    border-radius: 12px;
  }

  /* Drawer — js/ui.js ย้าย #navMenu มาเป็นลูกของ <body> ในโหมดมือถือ
     (ถ้าปล่อยไว้ใน .navbar ซึ่งมี backdrop-filter มันจะกลายเป็น containing block
     ทำให้ bottom:0 วัดจากขอบล่าง navbar แทนขอบล่างจอ) */
  .nav-menu {
    display: flex !important;      /* คุมด้วย transform ไม่ใช่ display → animate ได้ */
    position: fixed;
    top: 0;
    right: 0;
    left: auto;
    bottom: 0;
    height: 100dvh;                /* กันแถบ URL ของ Safari/Chrome มือถือบังท้าย drawer */
    width: min(84vw, 340px);
    flex-direction: column;
    align-items: stretch;
    gap: 0.15rem;
    padding: calc(env(safe-area-inset-top, 0px) + 4.75rem) 1.25rem
             calc(env(safe-area-inset-bottom, 0px) + 2rem);
    background: #fff;
    box-shadow: -8px 0 40px rgba(26, 61, 39, 0.22);
    overflow-y: auto;
    overscroll-behavior: contain;  /* ปัดจนสุด drawer แล้วหน้าหลังไม่เลื่อนตาม */
    -webkit-overflow-scrolling: touch;
    transform: translateX(100%);
    visibility: hidden;
    /* visibility สลับทันทีตอนเปิด แต่หน่วงไว้จนสไลด์ปิดจบตอนปิด
       ถ้าใส่ transition ให้ visibility ตรง ๆ ตอนเปิดมันจะยังเป็น hidden ในเฟรมแรก
       ทำให้ .focus() ไม่ติด (element ที่ visibility:hidden รับโฟกัสไม่ได้) */
    transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1),
                visibility 0s linear 0.28s;
    z-index: 1200;
  }
  .nav-menu.open {
    transform: translateX(0);
    visibility: visible;
    transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1),
                visibility 0s linear 0s;
  }

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

  .nav-menu .nav-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 52px;
    padding: 0.75rem 1rem;
    font-size: 1.05rem;
    border-radius: 12px;
  }
  .nav-menu .nav-link.active {
    background: var(--green-pale, #d8f3dc);
    color: var(--green-dark, #1a3d27);
    font-weight: 700;
  }

  /* เมนูย่อย "สินค้า" — พับเก็บได้ ไม่กางยาวจนต้องเลื่อนหา
     ใช้ max-height ไม่ใช่ grid-template-rows:0fr เพราะทริก 0fr ย่อได้เฉพาะ
     "แถวแรก" เมนูนี้มี <li> 7 ตัว อีก 6 ตัวจะตกไปอยู่ในแถว implicit ขนาด auto
     แล้วกางค้างทับข้อความอื่น */
  .nav-dropdown .dropdown-menu {
    position: static;
    display: block;
    visibility: visible;
    opacity: 1;
    transform: none;
    box-shadow: none;
    border: none;
    background: var(--green-bg, #f0f9f0);
    border-radius: 12px;
    margin: 0.15rem 0 0.35rem;
    padding: 0 0.35rem;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.28s ease, padding 0.28s ease;
  }
  .nav-dropdown.expanded .dropdown-menu {
    max-height: 460px;
    padding: 0.35rem;
  }
  .nav-dropdown .dropdown-menu li a {
    display: flex;
    align-items: center;
    min-height: 46px;
    padding: 0 0.9rem;
    border-radius: 10px;
  }
  .nav-dropdown .nav-link .arrow { transition: transform 0.25s ease; }
  .nav-dropdown.expanded .nav-link .arrow { transform: rotate(180deg); }

  .nav-menu .nav-cart,
  .nav-menu .nav-btn,
  .nav-menu .nav-btn-user {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    min-height: 50px;
    width: 100%;
    margin-top: 0.5rem;
    border-radius: 12px;
    font-size: 1rem;
  }
  /* ในแถบเมนูตัวนับตะกร้าเป็นวงกลมลอยมุมขวาบนของไอคอน แต่พอยืดเป็นแถวเต็มความกว้าง
     มันไปค้างอยู่สุดขอบขวาแบบไม่เข้าพวก — จับกลับมาวางต่อท้ายไอคอนในแถวเดียวกัน */
  .nav-menu .nav-cart {
    background: var(--green-bg, #f0f9f0);
    color: var(--green-dark, #1a3d27);
    font-weight: 600;
    width: 100%;
    height: auto;
    border-radius: 12px;
  }
  .nav-menu .nav-cart .cart-count {
    position: static;
    width: auto;
    min-width: 22px;
    height: 22px;
    padding: 0 7px;
    border-radius: 11px;
    font-size: 0.75rem;
  }
  .nav-user-wrap { display: flex; gap: 0.5rem; width: 100%; }
  .nav-user-wrap .nav-btn-user { flex: 1; }

  /* ปุ่มแชท (z-index 9000) ลอยทับ drawer — ซ่อนไว้ระหว่างเมนูเปิด */
  body.nav-open .chat-launcher,
  body.nav-open .m-bottombar { opacity: 0; pointer-events: none; }

  /* ฉากหลังมืดหลัง drawer */
  .nav-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 32, 22, 0.45);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.28s ease, visibility 0.28s;
    z-index: 1100;
  }
  .nav-backdrop.show { opacity: 1; visibility: visible; }

  /* ล็อกหน้าหลังไม่ให้เลื่อนตอน drawer เปิด (JS เติม class ที่ <body>) */
  body.nav-open { overflow: hidden; }
}

/* ==========================================================================
   5. MOBILE BOTTOM BAR — ทางลัดที่นิ้วโป้งเอื้อมถึง
   ========================================================================== */

.m-bottombar { display: none; }

@media (max-width: 768px) {
  .m-bottombar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 900;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    background: rgba(255, 255, 255, 0.94);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-top: 1px solid var(--border, #c8e6c8);
    padding-bottom: env(safe-area-inset-bottom, 0px);
    box-shadow: 0 -2px 20px rgba(26, 61, 39, 0.1);
    /* ซ่อนตอนเลื่อนลง โผล่ตอนเลื่อนขึ้น */
    transform: translateY(0);
    transition: transform 0.25s ease, opacity 0.2s ease;
  }
  .m-bottombar.hidden { transform: translateY(110%); }

  .m-bottombar a {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    min-height: 56px;
    padding: 6px 2px;
    font-size: 0.68rem;
    font-weight: 600;
    color: var(--text-mid, #3d5a3d);
    position: relative;
  }
  .m-bottombar a.active { color: var(--green-main, #2d6a4f); }
  .m-bottombar a.active::before {
    content: "";
    position: absolute;
    top: 0;
    width: 28px;
    height: 3px;
    border-radius: 0 0 3px 3px;
    background: var(--green-main, #2d6a4f);
  }
  .m-bottombar svg { width: 22px; height: 22px; }

  .m-bottombar .m-badge {
    position: absolute;
    top: 4px;
    left: 50%;
    margin-left: 4px;
    min-width: 17px;
    height: 17px;
    padding: 0 4px;
    border-radius: 9px;
    background: #e63946;
    color: #fff;
    font-size: 0.62rem;
    line-height: 17px;
    text-align: center;
  }
  .m-bottombar .m-badge:empty,
  .m-bottombar .m-badge[data-count="0"] { display: none; }

  /* เผื่อที่ให้ bottom bar ไม่ทับเนื้อหาท้ายหน้า — เฉพาะหน้าที่มี bar จริง
     (หน้า login/checkout ไม่มี จะได้ไม่เหลือช่องว่างเปล่า ๆ ท้ายหน้า) */
  body:has(.m-bottombar) { padding-bottom: calc(56px + env(safe-area-inset-bottom, 0px)); }
  .footer-bottom { padding-bottom: 1rem; }

  /* ปุ่มแชทลอยและ toast ต้องขยับขึ้นเหนือ bottom bar ไม่งั้นทับกัน */
  .chat-launcher { bottom: calc(70px + env(safe-area-inset-bottom, 0px)); }
  .chat-panel    { bottom: calc(140px + env(safe-area-inset-bottom, 0px)); }
  .toast         { bottom: calc(74px + env(safe-area-inset-bottom, 0px)); }
}

/* ==========================================================================
   6. LAYOUT — mobile-first tuning
   ========================================================================== */

@media (max-width: 768px) {
  .container { padding-inline: 1.1rem; }
  .section { padding: 3rem 0; }
  .section-header { margin-bottom: 2rem; }

  /* HERO */
  .hero {
    min-height: auto;
    padding: calc(env(safe-area-inset-top, 0px) + 92px) 1.1rem 3rem;
    gap: 2rem;
  }
  .hero-content { text-align: center; }
  .hero-desc { font-size: 1rem; margin-bottom: 1.5rem; }
  .hero-actions { gap: 0.75rem; margin-bottom: 1.75rem; }
  .hero-actions .btn-primary,
  .hero-actions .btn-outline {
    flex: 1 1 100%;
    justify-content: center;
    min-height: 50px;
  }
  .hero-stats {
    gap: 0.75rem;
    justify-content: space-between;
    width: 100%;
  }
  .hero-stats .stat { flex: 1; }
  .stat-num { font-size: 1.5rem; }
  .stat span:last-child { font-size: 0.7rem; line-height: 1.3; text-align: center; }

  /* ลูกแก้วเบลอ 80px สามลูกทับกัน = งาน paint หนักโดยไม่จำเป็นบนจอเล็ก */
  .hero-orb { filter: blur(50px); }
  .orb-3 { display: none; }

  /* ใบไม้ 4 ใบเป็นงานตกแต่งล้วน แต่รวมกันราว 500KB (a1–a5.webp ใบละ ~120KB)
     ซ่อนไว้ + คู่กับ loading="lazy" เบราว์เซอร์จะไม่ดาวน์โหลดเลยบนมือถือ */
  .hero-leaves { display: none; }

  /* ป้ายลอยรอบขวด เดิมตั้ง right/left 160-200px บนกล่องกว้าง 280px → ล้นจอ */
  .floating-tag {
    font-size: 0.72rem;
    padding: 4px 9px;
    max-width: 46vw;
    white-space: normal;
    text-align: center;
    line-height: 1.35;
  }
  .tag-1 { top: 10px;    right: 0;    left: auto;   bottom: auto; }
  .tag-2 { bottom: 46px; left: 0;     right: auto;  top: auto; }
  .tag-3 { bottom: 0;    right: 0;    left: auto;   top: auto; }

  .hero-scroll { display: none; }

  /* รูปขวดสูงกว่ากรอบ .product-showcase (สูง 340px) มาก และ overflow เป็น visible
     ผลคือขวดล้นขึ้นไปทับปุ่ม "เลือกซื้อสินค้า" กับแถบตัวเลขสถิติจนกดไม่ได้
     บนมือถือจึงบังคับให้ย่อลงมาอยู่ในกรอบ (คงสัดส่วนเดิมด้วย object-fit) */
  .product-showcase { height: auto; min-height: 340px; }
  .showcase-slides  { min-height: 340px; }
  .showcase-bottle  { width: auto; min-height: 0; }
  .showcase-bottle img {
    width: auto;
    height: auto;
    max-width: min(190px, 46vw);
    max-height: 320px;
    object-fit: contain;
  }

  /* หัวข้อ/เนื้อหา */
  .section-title,
  .section-title-header { line-height: 1.3; }
  .testimonials-grid { grid-template-columns: 1fr; gap: 1.1rem; }

  /* สินค้า: 2 คอลัมน์ ดูสินค้าได้มากขึ้นต่อหนึ่งจอ */
  .products-grid { grid-template-columns: repeat(2, 1fr); gap: 0.85rem; }
  .product-card { border-radius: 14px; }
  .product-img img,
  .product-img > div {
    width: 100% !important;
    height: auto !important;
    aspect-ratio: 1 / 1;
  }
  /* style.css ตรึง .product-img ไว้ที่ height:300px ซึ่งเกินความกว้างการ์ด (171px)
     บนมือถือเกือบเท่าตัว เหลือเป็นแถบว่างใต้รูปทุกใบ — ให้เป็นสี่เหลี่ยมจัตุรัสแทน */
  .product-img { height: auto; aspect-ratio: 1 / 1; }

  .product-info { padding: 0.7rem; }
  .product-info h4 {
    font-size: 0.86rem;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
  .product-price { font-size: 1.05rem; }
  .product-footer { flex-wrap: wrap; gap: 0.5rem; }
  .btn-cart { width: 100%; font-size: 0.8rem; }

  /* แถบกรองหมวด — เลื่อนแนวนอนแทนการตัดบรรทัดจนสูงเป็นบล็อก
     บั๊กที่เจอ: style.css ตั้ง .products-filter ไว้ที่ justify-content:center
     สำหรับเดสก์ท็อป (ปุ่มน้อย พอในบรรทัดเดียว) แต่ตรงนี้ยังไม่เคยสั่งรีเซ็ตค่านั้น
     พอปุ่มรวมกันกว้างกว่าจอ (544px > 390px) เบราว์เซอร์จะจัดกึ่งกลางเนื้อหาที่ล้น
     ผลคือปุ่มแรก "ทั้งหมด" ถูกดันไปอยู่นอกจอฝั่งซ้ายตั้งแต่โหลดมาโดยที่ scrollLeft
     ยังเป็น 0 (มองไม่เห็นและเลื่อนย้อนไปหาไม่ได้ในบางเบราว์เซอร์) ส่วนขวาก็ถูกตัด
     เท่ากัน — ต้องสั่ง flex-start ให้แถวเริ่มจากซ้ายเหมือน list ปกติ */
  .products-filter {
    display: flex;
    flex-wrap: nowrap;
    justify-content: flex-start;
    gap: 0.5rem;
    overflow-x: auto;
    scroll-snap-type: x proximity;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding: 0.25rem 1.1rem;
    margin-inline: -1.1rem;
  }
  .products-filter::-webkit-scrollbar { display: none; }
  .products-filter .filter-btn {
    flex: 0 0 auto;
    scroll-snap-align: start;
    white-space: nowrap;
  }

  /* ── พืชน้ำมันของเรา ─────────────────────────────────────────────
     เดสก์ท็อปเป็น 3 คอลัมน์ (เลขลำดับ+ธัมบ์ / รูป / ข้อความ) พอยุบเหลือ
     คอลัมน์เดียวบนมือถือ สัดส่วนเลยเพี้ยน — จัดใหม่เป็นการ์ดแนวตั้ง */
  .plants-section { padding: 3rem 0; }
  .plant-slider { gap: 1rem; }

  /* แถวบน: เลขลำดับซ้าย ธัมบ์เนลขวา
     ต้องกัน .ps-meta ไม่ให้ถูกบีบ ไม่งั้น "02 / 04" กับ "พืชน้ำมัน" จะตกบรรทัด
     เพราะธัมบ์ 4 รูปกินความกว้างไปเกือบหมด */
  .ps-col-left { gap: .75rem; align-items: center; }
  .ps-meta { gap: .5rem; align-items: baseline; flex-shrink: 0; white-space: nowrap; }
  .ps-counter { font-size: .9rem; color: rgba(255,255,255,.72); letter-spacing: .1em; }
  .ps-vert-label {
    font-size: .6rem; color: rgba(255,255,255,.4);
    letter-spacing: .16em; writing-mode: horizontal-tb; transform: none;
  }
  .ps-thumbs {
    gap: .4rem;
    overflow-x: auto;          /* ถ้าพืชเยอะกว่านี้ก็ยังเลื่อนดูได้ ไม่ดันบรรทัด */
    scrollbar-width: none;
    padding: 2px;
  }
  .ps-thumbs::-webkit-scrollbar { display: none; }
  .ps-thumb {
    width: 46px; height: 58px; flex-shrink: 0;
    border-radius: 10px; opacity: .45; border: 2px solid transparent;
  }
  .ps-thumb-active {
    opacity: 1;
    border-color: #fff;
    box-shadow: 0 0 0 2px rgba(255,255,255,.22);
  }

  /* รูปหลัก: สี่เหลี่ยมจัตุรัส กระชับกว่า 4:5 ที่สูงเกือบเต็มจอ */
  .ps-col-image {
    min-height: 0;
    aspect-ratio: 1 / 1;
    border-radius: 20px;
  }
  .ps-img-slide img { min-height: 0; height: 100%; }
  /* ไล่เฉดด้านล่างรูปให้กลืนกับพื้นหลังเข้มของ section */
  .ps-col-image::after {
    background: linear-gradient(to top, rgba(11,31,20,.85) 0%, rgba(11,31,20,.25) 26%, transparent 55%);
    border-radius: 20px;
  }

  /* ข้อความ */
  .ps-text-track { min-height: 0; overflow: visible; }
  .ps-txt-slide  { position: relative; inset: auto; padding-top: 0; }
  .ps-txt-slide:not(.ps-active) { display: none; }   /* ไม่ซ้อนทับกันเมื่อ track สูง auto */
  .ps-eng-name   { font-size: .78rem; color: rgba(255,255,255,.5); }
  .ps-plant-name { font-size: 1.75rem; margin-bottom: .85rem; }
  .ps-plant-desc { font-size: .95rem; line-height: 1.75; margin-bottom: 1.1rem; }
  .ps-benefits   { gap: .45rem; margin-bottom: 1.25rem; }
  .ps-benefits span {
    font-size: .75rem; padding: .4rem 1rem;
    background: rgba(255,255,255,.1); color: rgba(255,255,255,.82);
  }
  .ps-read-more { font-size: .88rem; padding-bottom: .3rem; }

  /* ปุ่มเลื่อนสไลด์: จัดกึ่งกลาง ขยับขึ้นมาใกล้เนื้อหา */
  .ps-nav-btns { margin-top: 1.25rem; justify-content: center; gap: 1rem; }
  .ps-nav-btn { width: 50px; height: 50px; }

  /* ── สาระน่ารู้ ───────────────────────────────────────────────── */
  .articles-grid { gap: 1.1rem; }
  .article-card {
    /* backdrop-filter บนพื้นโปร่ง 62% ทำให้ตัวหนังสืออ่านยากและกิน GPU
       บนมือถือใช้พื้นทึบไปเลย คมชัดกว่าและเบากว่า */
    background: #fff;
    backdrop-filter: none; -webkit-backdrop-filter: none;
    border: 1px solid #e8f0e8;
    border-radius: 16px;
    box-shadow: 0 2px 12px rgba(26,61,39,.07);
  }
  .article-img-wrap img,
  .article-img-ph {
    height: auto;
    aspect-ratio: 16 / 10;   /* ครอบรูปให้สูงเท่ากันทุกใบ การ์ดจะได้ไม่สูงต่ำสลับกัน */
    width: 100%;
    object-fit: cover;
  }
  .article-img-ph { display: flex; align-items: center; justify-content: center; font-size: 3.5rem; }

  /* ป้ายหมวดหมู่: จากสี่เหลี่ยมทึบชิดมุม → เป็นชิปลอยมีระยะขอบ */
  .article-badge {
    top: .7rem; left: .7rem;
    padding: .3rem .75rem;
    border-radius: 50px;
    background: rgba(11,31,20,.72);
    color: #fff;
    backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
    font-size: .64rem;
  }

  .article-body { padding: .9rem 1rem 1rem; }
  .article-body h4 {
    font-size: 1rem; line-height: 1.45; margin-bottom: .4rem;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  }
  .article-body p {
    font-size: .84rem; line-height: 1.6; margin-bottom: .9rem;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  }
  .article-footer {
    flex-wrap: nowrap;
    padding-top: .75rem;
    border-top: 1px solid #eef4ee;
  }
  .art-readmore { font-size: .82rem; gap: 6px; }
  .art-arrow-box { width: 30px; height: 30px; }
  .art-date { font-size: .72rem; white-space: nowrap; }
  .art-date-line { display: none; }   /* เส้นขีดยาวท้ายวันที่ ทำให้แถวดูรกบนจอแคบ */

  .footer-grid { gap: 0; }
  .footer-newsletter form { display: flex; gap: 0.5rem; }
  .footer-newsletter input { flex: 1; min-width: 0; }

  /* footer แบบ accordion — เดิมโชว์ลิงก์ทั้ง 13 รายการเรียงเป็นแถวยาวรวด
     พับเก็บเป็นหัวข้อที่แตะขยายได้ ลดความยาวหน้าจอ อ่านง่ายขึ้น */
  .footer-brand { padding-bottom: 1.5rem; }
  .footer-acc {
    border-top: 1px solid rgba(255,255,255,0.12);
    padding: 0;
  }
  .footer-acc summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.1rem 0.15rem;
    cursor: pointer;
  }
  .footer-acc summary h4 { margin: 0; }
  .footer-acc summary::after {
    content: "";
    width: 9px; height: 9px;
    border-right: 2px solid rgba(255,255,255,0.6);
    border-bottom: 2px solid rgba(255,255,255,0.6);
    transform: rotate(45deg);
    transition: transform 0.25s ease;
    flex-shrink: 0;
  }
  .footer-acc[open] summary::after { transform: rotate(-135deg); }
  .footer-acc ul { padding-bottom: 1.1rem; }
  .footer-acc ul li { margin-bottom: 0; }
  .footer-acc ul li a {
    padding: 0.6rem 0.15rem;
    min-height: 44px;
    display: flex;
    align-items: center;
  }
  .footer-newsletter { border-top: 1px solid rgba(255,255,255,0.12); padding-top: 1.5rem; }

  /* หมวดสินค้า: เปลี่ยนจากลิสต์แนวตั้งเป็นชิป 2 คอลัมน์ แตะง่าย สแกนสายตาไว */
  .footer-cat-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.6rem;
  }
  .footer-cat-grid li { margin-bottom: 0 !important; }
  .footer-cat-grid li a {
    background: rgba(255,255,255,0.07);
    border-radius: 10px;
    padding: 0.7rem 0.7rem !important;
    gap: 0.5rem;
    font-size: 0.82rem;
  }
  .footer-cat-grid li a:hover,
  .footer-cat-grid li a:active { background: rgba(255,255,255,0.14); padding-left: 0.7rem !important; }
  .footer-cat-grid .fc-ico { font-size: 1.05rem; line-height: 1; }
}

@media (max-width: 480px) {
  .product-showcase { min-height: 300px; }
  .showcase-slides  { min-height: 300px; }
  .showcase-bottle img { max-width: min(160px, 44vw); max-height: 280px; }

  /* คงไว้ 2 คอลัมน์ (style.css เดิมบีบเหลือ 1 — การ์ดใหญ่จนต้องเลื่อนนาน) */
  .products-grid { grid-template-columns: repeat(2, 1fr); }
  .hero-actions { flex-direction: row; }
  .stat-div { display: none; }
}

/* ==========================================================================
   7. FORMS — iOS ไม่ซูมเข้าตอนโฟกัส ถ้า font-size ≥ 16px
   ========================================================================== */

@media (max-width: 768px) {
  input, select, textarea {
    font-size: 16px !important;
    min-height: 46px;
    border-radius: 10px;
  }
  textarea { min-height: 110px; }
  button[type="submit"], .btn-primary.full { min-height: 50px; }

  /* ── ตะกร้าสินค้าบนมือถือ ── */
  .cart-sidebar {
    width: 100%;
    padding-top: env(safe-area-inset-top, 0px);
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  .cart-header { padding: 1rem 1.1rem; }
  .cart-items  { padding: .85rem; }

  /* แถบเมนูล่างลอยทับตะกร้า — ซ่อนระหว่างเปิดตะกร้า
     (ปุ่มแชทจัดการไว้ใน style.css แล้ว เพราะต้องซ่อนบนเดสก์ท็อปด้วย) */
  body.cart-open .m-bottombar { opacity: 0; pointer-events: none; }

  /* เป้าแตะ 40–44px ตามนิ้ว ไม่ใช่ 26px แบบเดิม */
  .cart-qty-btn { width: 40px; height: 40px; font-size: 1.15rem; }
  .cart-qty-val { min-width: 40px; font-size: .92rem; }
  .cart-item-remove { width: 40px; height: 40px; margin: -6px -6px 0 0; font-size: 1rem; }

  /* กระชับระยะลง เพราะปุ่มเป้าแตะ 40px กินความสูงไปแล้ว จะได้เห็นสินค้าต่อจอมากขึ้น */
  .cart-item { padding: .7rem; gap: .65rem; margin-bottom: .5rem; }
  .cart-item-thumb { width: 48px; height: 48px; }
  .cart-item-name { font-size: .88rem; }
  .cart-item-bottom { margin-top: .45rem; }
  .cart-item-subtotal { font-size: 1.05rem; }

  /* ยอดสุทธิ + ปุ่มท้ายตะกร้าเกาะขอบล่างไว้ ไม่ต้องเลื่อนหา */
  .cart-footer {
    padding: .9rem 1.1rem calc(.9rem + env(safe-area-inset-bottom, 0px));
    box-shadow: 0 -4px 20px rgba(26, 61, 39, .08);
  }
  .cart-footer .btn-primary.full { min-height: 50px; font-size: .98rem; }
  .btn-shop-more { min-height: 48px; }
}

/* ==========================================================================
   8. MOTION / DATA PREFERENCES
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  html { scroll-behavior: auto; }
  .beams-canvas,
  .hero-orb,
  .showcase-ring { display: none; }
}

/* จอเล็ก: หยุดอนิเมชันวนไม่รู้จบที่ไม่ได้สื่อความหมาย — คืน CPU/แบตให้การ scroll */
@media (max-width: 768px) {
  .showcase-ring,
  .hero-orb,
  .oil-drop-anim .wave { animation: none; }
  .beams-canvas { display: none; }
}
