/* ===================================================================
   ภาพพื้นหลังของไทม์ไลน์ เปลี่ยนจาก PNG เป็น WebP

   ที่มา
     วัดการโหลดจริงของหน้าประวัติที่จอ 390px ได้รูปรวม 7,146 KB
     ในจำนวนนั้นเป็นภาพพื้นหลังหกภาพนี้ถึง 6,367 KB คือ 89% ของทั้งหมด
     ทุกภาพเป็น PNG ขนาด 1265x656 หนักภาพละราว 1 MB

     PNG เก็บภาพถ่ายได้แย่มาก เพราะออกแบบมาสำหรับภาพลายเส้นและพื้นสีเรียบ
     แปลงเป็น WebP คุณภาพ 82 ได้ 110 KB รวมหกภาพ คือลดลง 98%

   ตรวจแล้วว่าภาพไม่เสีย
     สุ่มเทียบสีทีละจุด 4,000 จุดต่อภาพ เทียบกับ PNG ต้นฉบับ
       ต่างเฉลี่ย 1.05 ถึง 1.82 จาก 255 คือไม่ถึง 0.7%
       ต่างมากสุด 10 จาก 255
       ค่าความโปร่งใสตรงกันทุกจุด (bg-2497 โปร่งใสทั้งภาพที่ค่า 89)
     ซึ่งตาคนแยกไม่ออก

   ทำไมใช้ image-set ไม่ใช่เปลี่ยน url ตรง ๆ
     image-set บอกชนิดไฟล์ไว้ด้วย เบราว์เซอร์ที่ไม่รองรับ WebP จะข้ามไปใช้ PNG เอง
     และเบราว์เซอร์เก่าที่ไม่รู้จัก image-set เลย จะมองว่าทั้งบรรทัดใช้ไม่ได้
     แล้วตกกลับไปใช้ค่าเดิมใน timeline.css ซึ่งเป็น PNG อยู่แล้ว
     จึงไม่มีทางที่ใครจะเห็นพื้นหลังหายไป

   ไฟล์ PNG เดิมยังอยู่ครบ ไม่ได้ลบ
   =================================================================== */

#parallax_2527{background-image:-webkit-image-set(url('../images/profile/bg-2497.webp') type('image/webp'), url('../images/profile/bg-2497.png') type('image/png'));
  background-image:image-set(url('../images/profile/bg-2497.webp') type('image/webp'), url('../images/profile/bg-2497.png') type('image/png'))}
#parallax_2543{background-image:-webkit-image-set(url('../images/profile/bg-2516.webp') type('image/webp'), url('../images/profile/bg-2516.png') type('image/png'));
  background-image:image-set(url('../images/profile/bg-2516.webp') type('image/webp'), url('../images/profile/bg-2516.png') type('image/png'))}
#parallax_2550{background-image:-webkit-image-set(url('../images/profile/bg-2520.webp') type('image/webp'), url('../images/profile/bg-2520.png') type('image/png'));
  background-image:image-set(url('../images/profile/bg-2520.webp') type('image/webp'), url('../images/profile/bg-2520.png') type('image/png'))}
#parallax_2553{background-image:-webkit-image-set(url('../images/profile/bg-2533-2.webp') type('image/webp'), url('../images/profile/bg-2533-2.png') type('image/png'));
  background-image:image-set(url('../images/profile/bg-2533-2.webp') type('image/webp'), url('../images/profile/bg-2533-2.png') type('image/png'))}
#parallax_2557{background-image:-webkit-image-set(url('../images/profile/bg-2533-3.webp') type('image/webp'), url('../images/profile/bg-2533-3.png') type('image/png'));
  background-image:image-set(url('../images/profile/bg-2533-3.webp') type('image/webp'), url('../images/profile/bg-2533-3.png') type('image/png'))}
#parallax_2558{background-image:-webkit-image-set(url('../images/profile/bg-2533-4.webp') type('image/webp'), url('../images/profile/bg-2533-4.png') type('image/png'));
  background-image:image-set(url('../images/profile/bg-2533-4.webp') type('image/webp'), url('../images/profile/bg-2533-4.png') type('image/png'))}

/* จอไม่เกิน 991px ใช้ไฟล์กว้าง 768px
   กรอบกว้างสุดบนมือถือคือความกว้างจอ ที่ 390px ต้องการ 780px เมื่อคิดความหนาแน่นสองเท่า
   768 จึงพอดี ไม่ต้องโหลดไฟล์ 1265px ซึ่งใหญ่กว่าที่ต้องใช้เกือบเท่าตัว
   รวมหกภาพเหลือ 48 KB */
@media (max-width:991px){
  #parallax_2527{background-image:-webkit-image-set(url('../images/profile/bg-2497-768.webp') type('image/webp'), url('../images/profile/bg-2497.png') type('image/png'));
    background-image:image-set(url('../images/profile/bg-2497-768.webp') type('image/webp'), url('../images/profile/bg-2497.png') type('image/png'))}
  #parallax_2543{background-image:-webkit-image-set(url('../images/profile/bg-2516-768.webp') type('image/webp'), url('../images/profile/bg-2516.png') type('image/png'));
    background-image:image-set(url('../images/profile/bg-2516-768.webp') type('image/webp'), url('../images/profile/bg-2516.png') type('image/png'))}
  #parallax_2550{background-image:-webkit-image-set(url('../images/profile/bg-2520-768.webp') type('image/webp'), url('../images/profile/bg-2520.png') type('image/png'));
    background-image:image-set(url('../images/profile/bg-2520-768.webp') type('image/webp'), url('../images/profile/bg-2520.png') type('image/png'))}
  #parallax_2553{background-image:-webkit-image-set(url('../images/profile/bg-2533-2-768.webp') type('image/webp'), url('../images/profile/bg-2533-2.png') type('image/png'));
    background-image:image-set(url('../images/profile/bg-2533-2-768.webp') type('image/webp'), url('../images/profile/bg-2533-2.png') type('image/png'))}
  #parallax_2557{background-image:-webkit-image-set(url('../images/profile/bg-2533-3-768.webp') type('image/webp'), url('../images/profile/bg-2533-3.png') type('image/png'));
    background-image:image-set(url('../images/profile/bg-2533-3-768.webp') type('image/webp'), url('../images/profile/bg-2533-3.png') type('image/png'))}
  #parallax_2558{background-image:-webkit-image-set(url('../images/profile/bg-2533-4-768.webp') type('image/webp'), url('../images/profile/bg-2533-4.png') type('image/png'));
    background-image:image-set(url('../images/profile/bg-2533-4-768.webp') type('image/webp'), url('../images/profile/bg-2533-4.png') type('image/png'))}
}

/* -------------------------------------------------------------------
   ลายเส้นท้ายหน้า

   style.css:1409 ใช้ไฟล์ PNG 1500x398 หนัก 116 KB เป็นพื้นหลัง
   ภาพนี้อยู่ท้ายทุกหน้า จึงโหลดทุกครั้งที่เข้าเว็บ
   แปลงเป็น WebP แล้วคงความโปร่งใสไว้ครบ
   ------------------------------------------------------------------- */
.inner-footer{
  background-image:-webkit-image-set(url('../images/inner-footer.webp') type('image/webp'), url('../images/inner-footer.png') type('image/png'));
  background-image:image-set(url('../images/inner-footer.webp') type('image/webp'), url('../images/inner-footer.png') type('image/png'));
  background-repeat:no-repeat}

/* -------------------------------------------------------------------
   พื้นหลังอื่นของธีมที่เป็น PNG ภาพถ่าย

   สร้างจากการไล่อ่านไฟล์ CSS ของธีมทุกไฟล์ แล้วคัดเฉพาะกฎที่ใช้ภาพพื้นหลัง
   ขนาดเกิน 60 KB ตัวเลือกและเงื่อนไข @media คัดลอกมาตรงตามของเดิมทุกตัวอักษร
   จึงทับได้พอดีโดยไม่กระทบกฎอื่น

   ตรวจคุณภาพแล้วทุกไฟล์ ต่างเฉลี่ยไม่เกิน 2.6 จาก 255 และความโปร่งใสตรงกันทุกจุด
   ยกเว้น thumb-logo ซึ่งเป็นโลโก้มีขอบคม ใช้ WebP แบบไม่สูญเสียข้อมูล
   ได้ภาพเหมือนต้นฉบับทุกพิกเซล (ต่าง 0.00) และยังเล็กกว่า PNG เดิม 106 KB เหลือ 73 KB
   ------------------------------------------------------------------- */

#loading-content{background-image:-webkit-image-set(url('../images/thumb-logo.webp') type('image/webp'), url('../images/thumb-logo.png') type('image/png'));
  background-image:image-set(url('../images/thumb-logo.webp') type('image/webp'), url('../images/thumb-logo.png') type('image/png'))}
#modalpopup .modal-dialog{background-image:-webkit-image-set(url('../images/1348.webp') type('image/webp'), url('../images/1348.png') type('image/png'));
  background-image:image-set(url('../images/1348.webp') type('image/webp'), url('../images/1348.png') type('image/png'))}
.wrapper-organize .block-organize.organize-slot-1{background-image:-webkit-image-set(url('../images/organize/organize-bg-01.webp') type('image/webp'), url('../images/organize/organize-bg-01.png') type('image/png'));
  background-image:image-set(url('../images/organize/organize-bg-01.webp') type('image/webp'), url('../images/organize/organize-bg-01.png') type('image/png'))}
.wrapper-organize .block-organize.organize-slot-2{background-image:-webkit-image-set(url('../images/organize/organize-bg-02.webp') type('image/webp'), url('../images/organize/organize-bg-02.png') type('image/png'));
  background-image:image-set(url('../images/organize/organize-bg-02.webp') type('image/webp'), url('../images/organize/organize-bg-02.png') type('image/png'))}
.wrapper-organize .block-organize.organize-slot-3{background-image:-webkit-image-set(url('../images/organize/organize-bg-03.webp') type('image/webp'), url('../images/organize/organize-bg-03.png') type('image/png'));
  background-image:image-set(url('../images/organize/organize-bg-03.webp') type('image/webp'), url('../images/organize/organize-bg-03.png') type('image/png'))}
.wrapper-organize .block-organize.organize-slot-4{background-image:-webkit-image-set(url('../images/organize/organize-bg-04.webp') type('image/webp'), url('../images/organize/organize-bg-04.png') type('image/png'));
  background-image:image-set(url('../images/organize/organize-bg-04.webp') type('image/webp'), url('../images/organize/organize-bg-04.png') type('image/png'))}
.wrapper-organize .block-organize.organize-slot-5{background-image:-webkit-image-set(url('../images/organize/organize-bg-05.webp') type('image/webp'), url('../images/organize/organize-bg-05.png') type('image/png'));
  background-image:image-set(url('../images/organize/organize-bg-05.webp') type('image/webp'), url('../images/organize/organize-bg-05.png') type('image/png'))}
@media screen and (max-width: 768px){
  }

/* -------------------------------------------------------------------
   .wrapper-objective ใช้ภาพพื้นหลังซ้อนกันสองชั้น ต้องเขียนให้ครบทั้งสอง

   ของเดิมใน style.css:423
     background: url(bg-obj-3.png) no-repeat center left,
                 url(bg-obj-4.png) no-repeat 104% 50%;
   และ style.css:1817 เปลี่ยนตำแหน่งบนจอไม่เกิน 768px เป็น
     bottom left กับ 104% bottom

   ตอนแรกตัวสร้างกฎของผมหยิบมาแค่ชั้นเดียว ซึ่งจะทำให้ bg-obj-3 หายไปทั้งภาพ
   และตำแหน่งเพี้ยนด้วย จึงเขียนมือทั้งสองชั้นพร้อมตำแหน่งเดิมทุกค่า
   ------------------------------------------------------------------- */
.wrapper-objective{
  background-image:-webkit-image-set(url('../images/bg-obj-3.webp') type('image/webp'), url('../images/bg-obj-3.png') type('image/png')),
                   -webkit-image-set(url('../images/bg-obj-4.webp') type('image/webp'), url('../images/bg-obj-4.png') type('image/png'));
  background-image:image-set(url('../images/bg-obj-3.webp') type('image/webp'), url('../images/bg-obj-3.png') type('image/png')),
                   image-set(url('../images/bg-obj-4.webp') type('image/webp'), url('../images/bg-obj-4.png') type('image/png'));
  background-repeat:no-repeat,no-repeat;
  background-position:center left,104% 50%}

@media screen and (max-width:768px){
  .wrapper-objective{background-position:bottom left,104% bottom}
}

/* ===================================================================
   ม่านคลุมภาพพื้นหลังในส่วนวัตถุประสงค์ ให้ตัวหนังสืออ่านออก

   ภาพพื้นหลังสองชั้นของส่วนนี้เป็นภาพถ่ายที่มีทั้งส่วนมืดและส่วนสว่างมาก
   วัดความสว่างของไฟล์จริงทีละพิกเซลได้

     มัธยฐาน 64 · p90 190 · p95 205 · p99 219 · สูงสุด 245  (จาก 255)

   ตัวหนังสือเป็นสีครีม rgb(241,224,198) เมื่ออยู่บนจุดสว่างระดับ p95
   อัตราส่วนความต่างเหลือเพียง 1.23 ต่อ 1 ซึ่งแทบมองไม่เห็นตัวอักษร
   WCAG กำหนดขั้นต่ำ 4.5 ต่อ 1 สำหรับเนื้อความ และ 3 ต่อ 1 สำหรับตัวใหญ่

   ปูม่านสีเดียวกับพื้นของส่วนนี้ทับภาพ แล้ววัดใหม่

     ไม่มีม่าน  1.23    ม่าน 60%  2.50    ม่าน 70%  3.02
     ม่าน 80%   3.82    ม่าน 88%  4.85

   เลือก 88% ได้ 4.85 ที่จุดสว่าง p95 และ 3.99 ที่จุดสว่างที่สุดของภาพ
   ภาพยังเห็นเป็นลวดลางอยู่ข้างหลัง ไม่ได้หายไป แต่ไม่แย่งสายตากับข้อความอีก

   ใช้ ::after เพราะ ::before ของส่วนนี้ถูกใช้ทำแถบไล่สีด้านบนอยู่แล้ว
   ไม่ต้องแตะลูกของมันเลย เพราะ div.container ข้างในเป็น position:relative z-index:1 อยู่ก่อนแล้ว
   =================================================================== */
.wrapper-objective::after{
  content:"";position:absolute;inset:0;z-index:0;
  background:rgba(68,63,47,.88);
  pointer-events:none}

/* ===================================================================
   iPhone และ iPad ที่ยังเป็น iOS 15 กับ 16 ไม่ได้ไฟล์ WebP (แก้ 3 ธ.ค. 2569)

   อาการ
     Safari บน iOS 14 ถึง 16 รู้จัก image-set() แต่ยังอ่าน type() ข้างในไม่ออก
     ทั้งบรรทัดจึงถูกทิ้ง แล้วตกกลับไปใช้ PNG ก้อนใหญ่ใน style.css กับ timeline.css
     วัดโดยจำลองการทิ้งบรรทัดนั้นผ่าน CSSOM ที่หน้าประวัติพลเอกสุนทร จอ 375
       ได้ bg-2497.png 1,238 KB, bg-2516.png 889 KB, bg-2520.png 963 KB,
       bg-2533-2.png 1,117 KB, bg-2533-3.png 967 KB, bg-2533-4.png 1,190 KB
       รวมราว 6.4 MB ทั้งที่ Chrome โหลดไฟล์ -768.webp แค่ไฟล์ละ 4 ถึง 15 KB
     หน้าแรกโดนด้วย คือ bg-obj-3/4 กับ organize-bg-01..05 รวมอีกราว 1.8 MB
     เครื่องที่ช้าที่สุดจึงต้องโหลดหนักที่สุด ตรงข้ามกับที่ควรเป็น

   วิธีแก้
     iOS ตั้งแต่ 14 ขึ้นไปอ่าน WebP ได้อยู่แล้ว จึงชี้ไป .webp ตรง ๆ ไม่ต้องผ่าน image-set
     ตัวเลือกและ @media คัดลอกจากกฎข้างบนทุกตัวอักษร ไฟล์ -768 จึงยังอยู่ใน (max-width:991px)
     .wrapper-objective ต้องเขียนครบสองชั้นเหมือนเดิม ไม่อย่างนั้นภาพชั้นแรกจะหาย

   เงื่อนไขสามข้อ อ่านว่า "เครื่องนี้เป็น iOS ที่ยังอ่าน type() ไม่ออก และไม่เก่าเกินไป"
     -webkit-touch-callout มีเฉพาะ iOS กับ iPadOS
       Safari บนแมคจึงไม่เข้าเงื่อนไข เพราะ macOS รุ่นเก่าบางรุ่นยังอ่าน WebP ไม่ได้
     selector(:is(a)) มีตั้งแต่ Safari 14 เป็นด่านกัน iOS 13 ซึ่งอ่าน WebP ไม่ได้
       iOS 13 จะไม่เข้าเงื่อนไขนี้และยังได้ PNG เหมือนเดิม ไม่ใช่พื้นหลังหาย
     not (image-set + type) เป็นด่านกัน Safari 17 ขึ้นไป และ Chrome/Edge/Firefox
       ซึ่งอ่าน type() ได้อยู่แล้ว ทั้งบล็อกนี้จึงไม่มีผลกับเบราว์เซอร์เหล่านั้นเลย
   =================================================================== */
@supports (-webkit-touch-callout: none) and selector(:is(a)) and (not (background-image: image-set(url("x.png") type("image/png")))) {
  #parallax_2527{background-image:url('../images/profile/bg-2497.webp')}
  #parallax_2543{background-image:url('../images/profile/bg-2516.webp')}
  #parallax_2550{background-image:url('../images/profile/bg-2520.webp')}
  #parallax_2553{background-image:url('../images/profile/bg-2533-2.webp')}
  #parallax_2557{background-image:url('../images/profile/bg-2533-3.webp')}
  #parallax_2558{background-image:url('../images/profile/bg-2533-4.webp')}
  @media (max-width:991px){
    #parallax_2527{background-image:url('../images/profile/bg-2497-768.webp')}
    #parallax_2543{background-image:url('../images/profile/bg-2516-768.webp')}
    #parallax_2550{background-image:url('../images/profile/bg-2520-768.webp')}
    #parallax_2553{background-image:url('../images/profile/bg-2533-2-768.webp')}
    #parallax_2557{background-image:url('../images/profile/bg-2533-3-768.webp')}
    #parallax_2558{background-image:url('../images/profile/bg-2533-4-768.webp')}
  }
  .inner-footer{background-image:url('../images/inner-footer.webp')}
  #loading-content{background-image:url('../images/thumb-logo.webp')}
  #modalpopup .modal-dialog{background-image:url('../images/1348.webp')}
  .wrapper-organize .block-organize.organize-slot-1{background-image:url('../images/organize/organize-bg-01.webp')}
  .wrapper-organize .block-organize.organize-slot-2{background-image:url('../images/organize/organize-bg-02.webp')}
  .wrapper-organize .block-organize.organize-slot-3{background-image:url('../images/organize/organize-bg-03.webp')}
  .wrapper-organize .block-organize.organize-slot-4{background-image:url('../images/organize/organize-bg-04.webp')}
  .wrapper-organize .block-organize.organize-slot-5{background-image:url('../images/organize/organize-bg-05.webp')}
  .wrapper-objective{background-image:url('../images/bg-obj-3.webp'),
                     url('../images/bg-obj-4.webp')}
}
