/* ฟอนต์เก็บบนเซิร์ฟเวอร์เอง (Mali, Mitr — SIL Open Font License, ดู fonts/OFL.txt) */
@font-face { font-family: "Mali"; font-weight: 400; font-display: swap; src: url("fonts/mali-400.woff") format("woff"); }
@font-face { font-family: "Mali"; font-weight: 700; font-display: swap; src: url("fonts/mali-700.woff") format("woff"); }
@font-face { font-family: "Mitr"; font-weight: 600; font-display: swap; src: url("fonts/mitr-600.woff") format("woff"); }

:root { --orange: #F28C28; --cream: #FFF6E9; --cream2: #FFE9CC; --brown: #3E2614; --soft: #6B4A33;
        --head: "Mitr", "Mali", "Leelawadee UI", Tahoma, sans-serif; }
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-height: 100vh; display: flex; flex-direction: column; color: var(--brown); background: var(--cream);
       font-family: "Mali", "Itim", "Sarabun", "Noto Sans Thai", "Leelawadee UI", Tahoma, sans-serif; font-size: 1.05rem; line-height: 1.6; }
h1, h2, h3, .chip, .badge, .btn { font-family: var(--head); font-weight: 600; }
a { color: inherit; }

.top { background: var(--orange); border-bottom: 4px solid var(--brown); padding: 1.6rem 1rem 2rem; text-align: center; position: relative; }
.back { position: absolute; left: .8rem; top: .7rem; padding: .05rem .8rem; background: var(--cream); border: 3px solid var(--brown); border-radius: 999px;
        text-decoration: none; font-size: .9rem; font-family: var(--head); }
.back:focus-visible { outline: 3px solid var(--brown); outline-offset: 2px; }
.cats { display: flex; justify-content: center; align-items: flex-end; gap: clamp(.4rem, 3vw, 1.4rem); margin: 1.4rem auto .6rem; padding: 0; list-style: none; }
.cats img { height: clamp(64px, 17vw, 108px); width: auto; display: block; filter: drop-shadow(2px 4px 0 rgba(62, 38, 20, .35)); }
.top h1 { margin: 0; font-size: clamp(1.8rem, 6.5vw, 2.8rem); line-height: 1.15; text-shadow: 2px 3px 0 rgba(255, 246, 233, .75); }
.top p { margin: .4rem auto 0; max-width: 34rem; }
@media (prefers-reduced-motion: no-preference) {
  .cats img { animation: bob 3s ease-in-out infinite; }
  .cats li:nth-child(2) img { animation-delay: .4s; }
  .cats li:nth-child(3) img { animation-delay: .8s; }
}
@keyframes bob { 50% { transform: translateY(-5px); } }

main { width: min(980px, 100% - 2rem); margin: 1.6rem auto 2rem; flex: 1; }

.filters { display: grid; gap: .6rem; margin: 0 0 1.4rem; }
.row { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.row > b { font-family: var(--head); font-weight: 600; min-width: 4.5rem; }
.chip { font-size: .95rem; padding: .1rem .9rem; background: #fff; color: inherit; border: 3px solid var(--brown); border-radius: 999px; cursor: pointer; }
.chip[aria-pressed="true"] { background: var(--orange); box-shadow: 2px 3px 0 var(--brown); }
.chip:focus-visible, .btn:focus-visible, .thumb:focus-visible { outline: 3px solid var(--brown); outline-offset: 3px; }

.sets { list-style: none; margin: 0; padding: 0; display: grid; gap: 1.3rem; grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr)); }
a.card { display: block; height: 100%; color: inherit; text-decoration: none; background: #fff; border: 3px solid var(--brown); border-radius: 22px;
         box-shadow: 4px 5px 0 var(--brown); overflow: hidden; transition: transform .12s, box-shadow .12s; }
a.card:hover, a.card:focus-visible { transform: translate(2px, 3px); box-shadow: 2px 2px 0 var(--brown); }
a.card:focus-visible { outline: 3px solid var(--brown); outline-offset: 3px; }
.card .pic { display: grid; place-items: center; aspect-ratio: 4 / 3; background: var(--cream2); border-bottom: 3px solid var(--brown); }
.card .pic img { max-width: 68%; max-height: 82%; height: auto; width: auto; filter: drop-shadow(2px 3px 0 rgba(62, 38, 20, .25)); }
.card .pic img.emo { width: 96px; image-rendering: auto; }
.card .info { padding: .9rem 1.1rem 1.1rem; }
.card h3 { margin: 0 0 .15rem; font-size: 1.15rem; line-height: 1.3; }
.card p { margin: 0; color: var(--soft); font-size: .95rem; }
.badge { display: inline-block; margin-bottom: .35rem; padding: 0 .7rem; font-size: .8rem; background: var(--cream2); border: 2px solid var(--brown); border-radius: 999px; }
.empty { text-align: center; color: var(--soft); padding: 2rem 0; }

/* หน้าชุด */
.head { display: flex; flex-wrap: wrap; align-items: baseline; gap: .3rem 1rem; margin: 0 0 1.2rem; padding-bottom: .4rem; border-bottom: 4px dashed var(--orange); }
.head h2 { margin: 0; font-size: 1.5rem; }
.head p { margin: 0; color: var(--soft); }
.grid { list-style: none; margin: 0; padding: 0; display: grid; gap: .8rem; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); }
.grid.emoji { grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); }
.thumb { display: grid; place-items: center; width: 100%; aspect-ratio: 1; padding: .4rem; background: #fff; border: 3px solid var(--brown); border-radius: 16px; cursor: zoom-in;
         transition: transform .12s; }
.thumb:hover { transform: translateY(-2px); }
.thumb img { max-width: 100%; max-height: 100%; width: auto; height: auto; }
.hint { margin: 1.4rem 0 0; color: var(--soft); font-size: .95rem; text-align: center; }

dialog { width: min(92vw, 520px); padding: 0; background: var(--cream); color: var(--brown); border: 4px solid var(--brown); border-radius: 26px; box-shadow: 6px 8px 0 var(--brown); }
dialog::backdrop { background: rgba(62, 38, 20, .72); }
.lb { padding: 1rem 1rem 1.1rem; display: grid; gap: .8rem; justify-items: center; }
.lb .stage { display: grid; place-items: center; width: 100%; aspect-ratio: 1; background: #fff; border: 3px solid var(--brown); border-radius: 18px; touch-action: pan-y; }
.lb img { max-width: 86%; max-height: 86%; width: auto; height: auto; }
.lb img.emo { width: 55%; max-width: 55%; max-height: none; }
.bar { display: flex; align-items: center; justify-content: space-between; gap: .6rem; width: 100%; }
.btn { padding: .1rem 1rem; font-size: 1rem; background: var(--cream2); color: inherit; border: 3px solid var(--brown); border-radius: 999px; box-shadow: 2px 3px 0 var(--brown); cursor: pointer; }
.btn:active { transform: translate(1px, 2px); box-shadow: 1px 1px 0 var(--brown); }
.count { font-family: var(--head); }

footer { text-align: center; padding: 1.2rem 1rem 2rem; color: var(--soft); font-size: .95rem; }
@media (prefers-reduced-motion: reduce) { a.card, .thumb { transition: none; } }
