:root {
    --primary: #5a9fd4;
    --primary-hover: #4a8fc4;
    --primary-light: #eef6fc;
    --dark: #3d4a5c;
    --dark-soft: #5c6778;
    --gray: #6b7785;
    --gray-light: #e8ecf0;
    --bg: #f6f8fa;
    --white: #e8f4fc;
    --accent: #4aaf8a;
    --radius: 12px;
    --radius-lg: 16px;
    --shadow: 0 2px 12px rgba(0, 0, 0, 0.03);
    --shadow-lg: 0 6px 20px rgba(0, 0, 0, 0.05);
    --header-h: 64px;
    --safe-top: env(safe-area-inset-top, 0);
    --safe-bottom: env(safe-area-inset-bottom, 0);
    /* เว้นระยะจากขอบ – คอม */
    --space-edge: 24px;
    --space-section: 40px;
}

* {
    box-sizing: border-box;
}

html {
    /* ปิดการเลื่อนแบบลื่นทั้งหน้าเพื่อไม่ให้หน้าลื่นต่อเอง */
    /* scroll-behavior: smooth; */
    scroll-padding-top: 150px;
    min-height: 100%;
}

body {
    margin: 0;
    font-family: "Noto Sans Thai", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
    color: var(--dark);
    line-height: 1.6;
    font-size: 16px;
    position: relative;
    z-index: 0;
    min-height: 100%;
    -webkit-font-smoothing: antialiased;
    /* ท้องฟ้า + ทุ่งหญ้า โทนลื่น สบายตา */
    background: linear-gradient(to bottom, #d2eaf5 0%, #e2f2f9 30%, #b8e0b0 35%, #7bc96e 75%, #5fb855 100%);
    background-repeat: no-repeat;
    background-size: 100% 100%;
}


/* กล่องเนื้อหา – เว้นระยะจากขอบให้สวยงาม */
.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 var(--space-edge);
}

/* ========== HEADER – สบายตา มองทะลุได้เบาๆ ========== */
header {
    position: sticky;
    top: 0;
    left: 0;
    right: 0;
    padding-top: var(--safe-top);
    padding-bottom: 8px;
    background: rgba(90, 115, 135, 0.58);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow: 0 1px 16px rgba(0, 0, 0, 0.06);
    z-index: 100;
}

nav {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0;
    padding: 8px 0 0;
}

/* ปุ่มเปิดเมนูมือถือ – ซ่อนบนคอม */
.menu-toggle {
    display: none;
}

/* บรรทัดแรก: แบรนด์ (จัดกึ่งกลาง เว้นขอบสวยงาม) */
.brand {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    font-weight: 700;
    font-size: 0.9rem;
    color: #e8f4fc;
    padding-bottom: 8px;
    margin-bottom: 8px;
    text-align: center;
}

.brand > div:last-child {
    color: rgba(232, 244, 252, 0.98);
    font-weight: 600;
    line-height: 1.35;
}

/* โลโก้ IT โทนลื่น สบายตา */
.logo {
    width: 36px;
    height: 36px;
    min-width: 36px;
    border-radius: var(--radius);
    background: linear-gradient(135deg, #7ebce8, #5a9fd4);
    box-shadow: 0 2px 8px rgba(90, 159, 212, 0.25);
    display: grid;
    place-items: center;
    color: #e8f4fc;
    font-size: 0.9rem;
    font-weight: 700;
}

/* บรรทัดสอง: เมนูลิงก์ (คอม – จัดกึ่งกลาง) */
.menu {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 2px;
    width: 100%;
}

.menu a {
    padding: 6px 10px;
    border-radius: var(--radius);
    font-weight: 600;
    font-size: 0.85rem;
    color: rgba(232, 244, 252, 0.98);
    transition: background 0.2s, color 0.2s;
}

.menu a:hover {
    background: rgba(232, 244, 252, 0.25);
    color: #e8f4fc;
}

/* ========== HERO โทนเดียวกับท้องฟ้า ลื่น สบายตา ========== */
.hero {
    background: linear-gradient(180deg, #d2eaf5 0%, #dceff8 50%, #e4f3fa00 100%);
    padding: var(--space-section) 0 calc(var(--space-section) + 70px);
}

.hero-inner {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 40px;
    align-items: center;
}

.hero h1 {
    font-size: clamp(1.5rem, 4vw, 2rem);
    font-weight: 700;
    line-height: 1.3;
    color: var(--dark);
    margin: 12px 0 16px;
}

.hero p {
    color: var(--gray);
    font-size: 1rem;
    margin: 0;
    max-width: 480px;
}

.hero .pill {
    margin-bottom: 4px;
}

.hero-visual {
    padding: 20px;
    background: rgba(232, 244, 252, 0.75);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.04);
    border: none;
}

.hero-visual .grid-2 {
    gap: 12px;
}

.hero-visual .card {
    background: linear-gradient(#cce8f7);
    border: none;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.04);
}

/* ========== CARDS & PILLS – โทนลื่น สบายตา ========== */
.card {
    background: #c6e6f8;
    border: none;
    border-radius: var(--radius-lg);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.04);
    transition: box-shadow 0.2s, transform 0.2s;
}

.card:hover {
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.06);
    transform: translateY(-4px);
}


.pill {
    display: inline-block;
    background: var(--primary-light);
    color: var(--primary);
    padding: 6px 12px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
}

.feature.card {
    padding: 20px;
}

a.feature.card {
    display: block;
    text-decoration: none;
    color: inherit;
}

.feature h3 {
    font-size: 1rem;
    margin: 8px 0 6px;
    color: var(--dark);
}

.feature p {
    font-size: 0.875rem;
    color: var(--gray);
    margin: 0;
}
/* เอฟเฟกต์ชี้เมาส์ให้การ์ดทักษะ */
a.feature.card:hover {
    transform: translateY(-6px) scale(1.02);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.10);
    background: linear-gradient(135deg, #dff1ff, #c6e6f8);
}
/* ========== SECTIONS ========== */
section {
    padding: var(--space-section) 0;
}

section h2 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--dark);
    margin: 0 0 24px;
    padding-top: 12px;
    display: inline-block;
}

/* เกี่ยวกับแผนก หลักสูตร ผลงานนักศึกษา – จัดกึ่งกลาง */
#about .container,
#courses .container,
#projects .container {
    text-align: center;
}

#about .card.box {
    text-align: left;
}

#courses .container .course-list,
#projects .container .list {
    display: inline-block;
    text-align: left;
}

section .card.box {
    padding: 24px;
}

section .card.box p {
    margin: 0 0 16px;
    color: var(--dark-soft);
}

section .card.box p.link-drive {
    margin-top: 16px;
    margin-bottom: 0;
}

section .card.box p.link-drive a {
    font-weight: 600;
    color: var(--primary);
}

.list {
    margin: 0;
    padding-left: 20px;
    color: var(--dark-soft);
}

.list li {
    margin-bottom: 8px;
}

.list-numbers {
    list-style: decimal;
    padding-left: 24px;
}

.list-numbers li {
    margin-bottom: 16px;
}

.equipment-grid {
    margin-top: 16px;
    display: grid;
    grid-template-columns: 1fr;
    gap: 24px;
}

.equipment-card .equipment-img-wrap {
    margin-top: 12px;
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--gray-light);
    max-width: 280px;
}

.equipment-card .equipment-img-wrap img {
    display: block;
    width: 100%;
    height: auto;
    vertical-align: middle;
}

/* ========== หน้า Sound Sensor Light – กึ่งกลาง + ขนาดเหมาะสม ========== */
#equipment .container,
#howto .container,
#docs .container {
    text-align: center;
}

#equipment .card.box,
#howto .card.box,
#docs .card.box {
    max-width: 720px;
    margin-left: auto;
    margin-right: auto;
    font-size: 1.05rem;
    line-height: 1.7;
    text-align: center;
}

#howto .card.box .list-numbers {
    display: inline-block;
    text-align: left;
    margin: 0 auto;
    font-size: 1rem;
}

#howto .card.box .list-numbers li {
    margin-bottom: 18px;
}

#equipment .equipment-card {
    max-width: 560px;
    margin-left: auto;
    margin-right: auto;
    text-align: center;
    font-size: 1.05rem;
    line-height: 1.65;
}

#equipment .equipment-card p {
    text-align: center;
}

#equipment .equipment-card .equipment-img-wrap {
    max-width: 320px;
    margin-left: auto;
    margin-right: auto;
}

#equipment .equipment-card h3 {
    font-size: 1.15rem;
}

/* โค้ด Arduino – หน้า Sound Sensor */
#code .container {
    text-align: center;
}

#code .code-box {
    max-width: 640px;
    margin-left: auto;
    margin-right: auto;
    padding: 20px;
    text-align: left;
}

.code-block {
    margin: 0;
    padding: 16px 20px;
    background: #2d3748;
    color: #e2e8f0;
    border-radius: var(--radius);
    font-family: "Consolas", "Monaco", "Courier New", monospace;
    font-size: 0.9rem;
    line-height: 1.5;
    overflow-x: auto;
    white-space: pre;
}

.code-block code {
    font-size: inherit;
    color: inherit;
}

/* ========== GRID ========== */
.grid {
    display: grid;
    gap: 20px;
}

.grid-2 {
    grid-template-columns: repeat(2, 1fr);
}

.grid-3 {
    grid-template-columns: repeat(3, 1fr);
}

/* ========== COURSES ========== */
.course-list {
    margin: 0;
    padding-left: 18px;
    font-size: 0.875rem;
    color: var(--dark-soft);
    max-height: 320px;
    overflow-y: auto;
}

.course-list li {
    margin-bottom: 6px;
}

/* ========== PROJECTS ========== */
.project {
    padding: 20px;
}

.project h3 {
    font-size: 1.1rem;
    margin: 0 0 8px;
}

.project a {
    color: var(--primary);
    font-weight: 600;
}

.project a:hover {
    text-decoration: underline;
}

.project .small {
    font-size: 0.8rem;
    color: var(--gray);
    margin: 8px 0 0;
}

/* ========== TEACHERS ========== */
.center {
    text-align: center;
}

#teachers h2 {
    display: block;
    text-align: center;
    border-top: none;
    margin-bottom: 32px;
}

.teachers-row {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 32px;
    margin-bottom: 32px;
}

.teachers-row:last-child {
    margin-bottom: 0;
}

.teacher {
    text-align: center;
    max-width: 260px;
}

.teacher img {
    width: 100%;
    max-width: 220px;
    height: auto;
    aspect-ratio: 220 / 320;
    object-fit: cover;
    border-radius: var(--radius-lg);
    border: 4px solid #8b9aa8;
    background: #e8f4fc;
    box-shadow: var(--shadow-lg);
    margin-bottom: 12px;
}

.teacher b {
    display: block;
    font-size: 1rem;
    font-weight: 700;
    margin-top: 8px;
    color: var(--dark);
}

.teacher p {
    margin: 4px 0 0;
    font-size: 0.9rem;
    color: var(--gray);
}

/* ========== FOOTER โทนสบายตา ========== */
footer {
    background: #2d3748;
    color: #e8ecf0;
    padding: var(--space-section) 0;
    padding-bottom: calc(var(--space-section) + var(--safe-bottom));
    margin-top: var(--space-section);
}

/* รั้วติดกล่องดำ: ไม่มีช่องว่างระหว่างรั้วกับฟุตเตอร์ */
.fence + footer {
    margin-top: 0;
}

footer .container {
    max-width: 600px;
}

footer h3 {
    font-size: 1rem;
    font-weight: 600;
    margin: 0 0 8px;
}

footer p {
    margin: 0 0 12px;
    font-size: 0.9rem;
    line-height: 1.6;
}

footer .small {
    font-size: 0.8rem;
    opacity: 0.8;
    margin-top: 24px;
}

a {
    text-decoration: none;
    color: inherit;
}

/* ========== MOBILE – 768px ลงมา (เมนูแบบปุ่มเปิด) ========== */
@media (max-width: 768px) {
    html {
        scroll-padding-top: 65px;
    }

    :root {
        --space-edge: 20px;
        --space-section: 32px;
    }

    .container {
        padding: 0 var(--space-edge);
    }

    header {
        --header-h: 56px;
    }

    nav {
        flex-wrap: nowrap;
        justify-content: space-between;
        padding-bottom: 0;
        min-height: var(--header-h);
    }

    .brand {
        width: auto;
        max-width: calc(100% - 56px);
        padding-bottom: 0;
        border-bottom: none;
        margin-bottom: 0;
        justify-content: flex-start;
        text-align: left;
        gap: 8px;
    }

    .brand > div:last-child {
        font-size: 0.7rem;
        line-height: 1.3;
        max-width: none;
        word-break: keep-all;
    }

    .menu-toggle {
        display: flex;
        width: 44px;
        height: 44px;
        padding: 0;
        border: none;
        background: transparent;
        cursor: pointer;
        border-radius: var(--radius);
        align-items: center;
        justify-content: center;
        color: #e8f4fc;
    }

    .menu-toggle:hover {
        background: rgba(232, 244, 252, 0.25);
    }

    .menu-toggle svg {
        width: 24px;
        height: 24px;
    }

    .menu-toggle[aria-expanded="true"] .icon-open {
        display: none;
    }

    .menu-toggle .icon-close {
        display: none;
    }

    .menu-toggle[aria-expanded="true"] .icon-close {
        display: block;
    }

    /* เมนูเลื่อนจากขวา เปิดด้วยปุ่ม */
    .menu {
        position: fixed;
        top: calc(var(--header-h) + var(--safe-top));
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        background: #e8f4fc;
        flex-direction: column;
        align-items: stretch;
        justify-content: flex-start;
        padding: 16px;
        gap: 4px;
        transform: translateX(100%);
        visibility: hidden;
        transition: transform 0.25s ease, visibility 0.25s;
        overflow-y: auto;
        box-shadow: -4px 0 20px rgba(0, 0, 0, 0.1);
        z-index: 99;
    }

    .menu.is-open {
        transform: translateX(0);
        visibility: visible;
    }

    .menu a {
        padding: 14px 16px;
        font-size: 1rem;
        border-radius: var(--radius);
        display: block;
        color: var(--dark);
    }

    .menu a:hover {
        background: rgba(154, 107, 61, 0.1);
    }

    .hero {
        padding: var(--space-section) 0 calc(var(--space-section) + 8px);
    }

    .hero-inner {
        grid-template-columns: 1fr;
        gap: 28px;
        text-align: center;
    }

    .hero p {
        margin-left: auto;
        margin-right: auto;
    }

    .hero-visual {
        padding: 16px;
    }

    .grid-2,
    .grid-3 {
        grid-template-columns: 1fr;
    }

    section {
        padding: var(--space-section) 0;
    }

    section h2 {
        font-size: 1.35rem;
        margin-bottom: 20px;
    }

    .course-list {
        max-height: 280px;
    }

    .teachers-row.one .teacher,
    .teachers-row.two .teacher {
        max-width: 100%;
    }

    .teacher img {
        max-width: 200px;
    }
}

/* จอเล็กมาก (มือถือแนวตั้ง) – แบรนด์ยังเห็นได้ */
@media (max-width: 380px) {
    .brand > div:last-child {
        font-size: 0.65rem;
    }
}

/* ========== ธีมฟาร์ม: หิมะ รั้ว หมู โรงนา ไก่ ไข่ ========== */

/* หิมะตกแบบสุ่ม (เกล็ดสร้างด้วย JS) */
.snow {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: hidden;
    z-index: -1;
}

.snowflake {
    position: absolute;
    top: -20px;
    color: #e0f2fc;
    font-size: 14px;
    opacity: 0.7;
    user-select: none;
    text-shadow: 0 0 3px rgba(224, 242, 252, 0.9);
    animation: snowDrift linear infinite;
}

.snowflake::before {
    content: "❄";
}

@keyframes snowDrift {
    0% { transform: translateY(0) translateX(0); }
    25% { transform: translateY(25vh) translateX(8px); }
    50% { transform: translateY(50vh) translateX(-6px); }
    75% { transform: translateY(75vh) translateX(5px); }
    100% { transform: translateY(100vh) translateX(0); }
}

/* รั้วไม้ฟาร์ม โทนลื่น – อยู่บนแถบฟุตเตอร์ */


/* ธีมฟาร์ม – มือถือ: ลดขนาดองค์ประกอบตกแต่ง */
@media (max-width: 768px) {
    .fence { height: 64px; }
    .fence::before { box-shadow: 0 24px 0 #8a6d52; }
    
    .barn::before { border-left: 68px solid transparent; border-right: 68px solid transparent; border-bottom: 42px solid #a84a3d; top: -42px; left: -14px; }
    .barn::after { width: 32px; height: 48px; }
}
/* พื้นที่ปุ่มสมัคร */
.apply-section{

    text-align:center;
    padding:60px 20px 40px;
    background:transparent;
}

/* ตัวปุ่ม */
.apply-btn{
    display:inline-block;
    text-decoration:none;
    background:linear-gradient(135deg,#0095ff,#00b7ff);
    color:white;
    font-size:24px;
    font-weight:bold;
    padding:20px 48px;
    border-radius:60px;
    box-shadow:0 10px 25px rgba(0,149,255,0.45);
    transition:0.25s;
    letter-spacing:1px;
}

/* hover */
.apply-btn:hover{
    transform:translateY(-6px) scale(1.03);
    box-shadow:0 14px 35px rgba(0,149,255,0.65);
}

/* ===== เอฟเฟกต์แสดงตอนเลื่อน ===== */
.reveal{
  opacity:0;
  transform:translateY(40px);
  transition:all 0.9s ease;
}

.reveal.active{
  opacity:1;
  transform:translateY(0);
}

