/* base.css — reset + element พื้นฐาน + คลาสร่วม
 * ฟอนต์ Kanit โหลดผ่าน <link> ใน index.html (ไม่ใช้ @import)
 * ห้ามมีค่า hex / radius px / ชื่อฟอนต์ในไฟล์นี้ — อ้างจาก tokens.css เท่านั้น
 */

/* ---------- Reset ---------- */

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  background-color: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-main);
}

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

img {
  max-width: 100%;
  height: auto;
  display: block;
}

/* ---------- ตัวห่อหลัก ---------- */

/* กัน marquee / หัวเรื่องใหญ่ดันหน้าจอให้เลื่อนแนวนอน (DESIGN.md ข้อ 4) */
.page {
  overflow-x: clip;
}

/* ---------- คลาสร่วมของหัวเรื่อง (DESIGN.md ข้อ 5) ---------- */

/* ทุกหัวเรื่องใหญ่ */
.display-heading {
  font-weight: 900;
  text-transform: uppercase;
  line-height: 1;
  letter-spacing: -0.025em;
}

/* gradient สำหรับหัวเรื่องบนพื้นมืด: Hero, About me, Projects, Price, Contact
   สีทึบสำรองก่อน — ใส่ gradient เฉพาะเบราว์เซอร์ที่รองรับ background-clip: text (DESIGN.md ข้อ 5)
   ถ้าไม่ห่อ @supports เบราว์เซอร์ที่ไม่รองรับจะได้ตัวอักษรใส = หัวเรื่องหายทั้งหน้า */
.hero-heading {
  color: var(--color-text);
}

@supports ((-webkit-background-clip: text) or (background-clip: text)) {
  .hero-heading {
    background: var(--grad-heading);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: transparent;
  }
}

/* ---------- Focus ---------- */

a:focus-visible,
button:focus-visible {
  outline: 2px solid var(--color-text);
  outline-offset: 2px;
}

/* ---------- FadeIn (DESIGN.md ข้อ 14) ---------- */

/* คลาส .fade-in ถูกใส่โดย main.js เท่านั้น — ถ้า JS ไม่ทำงาน เนื้อหาจะแสดงตามปกติ */
.fade-in {
  opacity: 0;
  transform: translate(var(--fade-x, 0), var(--fade-y, 30px));
  transition:
    opacity var(--dur-fade) var(--ease-soft),
    transform var(--dur-fade) var(--ease-soft);
  transition-delay: var(--fade-delay, 0s);
}

.fade-in.is-visible {
  opacity: 1;
  transform: none;
}

/* ---------- Reduced motion (DESIGN.md ข้อ 16) ---------- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }

  .fade-in {
    opacity: 1;
    transform: none;
  }
}
