/* ---------- tokens (neo-brutalist / โทนสดใส ขอบดำ เงาแข็ง) ---------- */
:root {
  --paper:   #fff4fc;   /* พื้นหลัง — ชมพูอ่อนมาก */
  --card:    #ffffff;   /* ผิวการ์ด */
  --ink:     #141018;   /* ดำ — ขอบ + ตัวอักษร */
  --muted:   #6b6b6b;
  --line:    #eadfe8;

  --accent:  #ff90e8;   /* ชมพูป๊อป */
  --accent-2:#90a8ff;   /* ฟ้าพีริวิงเคิล */
  --gold:    #ffc900;   /* เหลือง */
  --mint:    #7fe0b0;

  --bd:      2px solid var(--ink);
  --hard-sm: 2px 2px 0 var(--ink);
  --hard:    4px 4px 0 var(--ink);
  --hard-lg: 6px 6px 0 var(--ink);

  --head: 'Inter', 'Noto Sans Thai', system-ui, sans-serif;
  --body: 'Inter', 'Noto Sans Thai', system-ui, sans-serif;
  --mono: ui-monospace, 'SF Mono', Menlo, monospace;

  --wrap: 1080px;
  --r: 8px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--body);
  font-weight: 400;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }

.sr-only {
  position: absolute; width: 1px; height: 1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}

:focus-visible { outline: 3px solid var(--accent-2); outline-offset: 2px; }

/* ---------- header ---------- */
.bar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; padding: .7rem 1.25rem;
  background: var(--paper);
  border-bottom: var(--bd);
}
.wordmark {
  font-family: var(--head); font-weight: 800; font-size: 1.05rem;
  color: var(--ink); text-decoration: none; letter-spacing: -.01em;
  background: var(--accent); border: var(--bd); box-shadow: var(--hard-sm);
  padding: .3rem .75rem; border-radius: var(--r);
}
.bar nav { display: flex; gap: 1.1rem; font-size: .9rem; font-weight: 700; }
.bar nav a { color: var(--ink); text-decoration: none; }
.bar nav a:hover { text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 3px; }

/* ---------- hero + ชั้นหนังสือ (signature) ---------- */
.hero { max-width: var(--wrap); margin: 0 auto; padding: 3.25rem 1.25rem 1rem; }

.eyebrow {
  display: inline-block; font-family: var(--head); font-size: .72rem; font-weight: 800;
  letter-spacing: .12em; text-transform: uppercase; color: var(--ink);
  background: var(--gold); border: var(--bd); box-shadow: var(--hard-sm);
  padding: .25rem .6rem; border-radius: var(--r); margin: 0 0 1.25rem;
}
.hero h1 {
  font-family: var(--head); font-weight: 800; font-size: clamp(2rem, 6vw, 3.2rem);
  line-height: 1.18; letter-spacing: -.02em; margin: 0 0 2.25rem;
}
.hero h1 em {
  font-style: normal; display: inline-block;
  background: var(--accent-2); border: var(--bd); box-shadow: var(--hard-sm);
  padding: 0 .3em; border-radius: var(--r); transform: rotate(-2deg);
}

.bookcase { display: flex; flex-direction: column; gap: 1.1rem; }   /* ชั้นหนังสือหลายชั้นซ้อนกัน */
.shelf {
  display: flex; align-items: flex-end; gap: 6px;
  overflow-x: auto; overscroll-behavior-x: contain;
  padding: 14px .25rem 0; scrollbar-width: thin;
  scrollbar-color: var(--ink) transparent;
}
.shelf::-webkit-scrollbar { height: 8px; }
.shelf::-webkit-scrollbar-thumb { background: var(--ink); border-radius: 99px; }

.spine {
  flex: 0 0 auto;
  width: 46px; height: var(--h, 170px);
  background: var(--cloth, #ff90e8);
  border: var(--bd); border-bottom: none;
  border-radius: var(--r) var(--r) 0 0;
  box-shadow: var(--hard-sm);
  display: flex; align-items: center; justify-content: center;
  text-decoration: none; position: relative;
  transition: transform .18s cubic-bezier(.2,.7,.3,1);
  animation: rise .5s cubic-bezier(.2,.8,.3,1) backwards;
  animation-delay: calc(var(--i) * 28ms);
}
.spine-t {
  writing-mode: vertical-rl;          /* สันหนังสือไทยอ่านแบบตะแคง */
  font-family: var(--head); font-size: .8rem; font-weight: 800;
  color: var(--ink); letter-spacing: .02em;
  max-height: calc(var(--h) - 28px);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.spine:hover, .spine:focus-visible { transform: translateY(-12px); }

.shelf-plank {
  height: 16px; margin-top: 0; border-radius: 0 0 var(--r) var(--r);
  background: var(--gold); border: var(--bd);
  box-shadow: var(--hard);
}
.hint { font-size: .82rem; color: var(--muted); font-weight: 500; margin: 1.4rem 0 0; }

@keyframes rise { from { transform: translateY(26px); opacity: 0; } }

/* ---------- grid ---------- */
.grid-wrap { max-width: var(--wrap); margin: 0 auto; padding: 3rem 1.25rem 4rem; }

.filter { margin: 0 0 1.75rem; }
.filter input {
  width: 100%; padding: .8rem 1rem;
  background: #fff; color: var(--ink);
  border: var(--bd); border-radius: var(--r); box-shadow: var(--hard-sm);
  font-family: var(--body); font-size: .95rem; font-weight: 500;
}
.filter input::placeholder { color: var(--muted); font-weight: 400; }
.filter input:focus { outline: none; box-shadow: var(--hard); }

.grid {
  display: grid; gap: 1.1rem;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}

.card {
  display: flex; gap: 1rem; padding: 1rem;
  background: var(--card); border: var(--bd);
  border-radius: var(--r); box-shadow: var(--hard);
  transition: transform .15s ease, box-shadow .15s ease;
}
.card:hover { transform: translate(-2px, -2px); box-shadow: var(--hard-lg); }
.card[hidden] { display: none; }

.card-cover { flex: 0 0 82px; }
.card-cover img {
  width: 82px; height: auto; display: block;
  border: var(--bd); border-radius: 4px; box-shadow: var(--hard-sm);
}
.card-body { min-width: 0; display: flex; flex-direction: column; gap: .35rem; }
.card-body h3 {
  font-family: var(--head); font-weight: 800; font-size: 1.02rem;
  line-height: 1.35; letter-spacing: -.01em; margin: 0;
}
.card-body h3 a { text-decoration: none; }
.card-body h3 a:hover { text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 2px; }
.byline { margin: 0; font-size: .8rem; color: var(--muted); font-weight: 500; }
.hook {
  margin: .25rem 0 .5rem; font-size: .87rem; color: #3a3340; line-height: 1.55;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}

.buy {
  align-self: flex-start; margin-top: auto;
  font-family: var(--head); font-weight: 800; font-size: .8rem; letter-spacing: 0;
  color: var(--ink); background: var(--accent);
  border: var(--bd); border-radius: var(--r); box-shadow: var(--hard-sm);
  padding: .5rem .9rem; text-decoration: none;
  transition: transform .1s ease, box-shadow .1s ease;
}
.buy:hover { background: #ff7fe4; }
.buy:active { transform: translate(2px, 2px); box-shadow: 0 0 0 var(--ink); }
.buy.big { font-size: .92rem; padding: .7rem 1.4rem; margin-top: 1.25rem; box-shadow: var(--hard); }
.buy.big:active { box-shadow: 0 0 0 var(--ink); }

.empty { color: var(--muted); font-size: .9rem; font-weight: 500; }

/* ---------- detail ---------- */
.detail { max-width: 780px; margin: 0 auto; padding: 2.25rem 1.25rem 4rem; }
.back {
  display: inline-block; font-size: .82rem; font-weight: 700; color: var(--ink);
  text-decoration: none; background: #fff; border: var(--bd); box-shadow: var(--hard-sm);
  padding: .3rem .7rem; border-radius: var(--r);
}
.back:hover { background: var(--gold); }

.book-head { display: flex; gap: 1.75rem; flex-wrap: wrap; margin: 2rem 0 2.75rem; }
.book-cover {
  width: 200px; height: auto; border: var(--bd); border-radius: 4px;
  box-shadow: var(--hard-lg);
}
.book-head > div { flex: 1 1 260px; }
.book-head h1 {
  font-family: var(--head); font-weight: 800; letter-spacing: -.02em;
  font-size: clamp(1.6rem, 4.5vw, 2.2rem); line-height: 1.25; margin: 0 0 .5rem;
}
.who {
  display: inline-block; color: var(--ink); font-size: .9rem; font-weight: 700; margin: .9rem 0 0;
  background: var(--mint); border: var(--bd); box-shadow: var(--hard-sm);
  padding: .25rem .6rem; border-radius: var(--r);
}
.disclose { font-size: .74rem; color: var(--muted); font-weight: 500; margin: .7rem 0 0; }

.summary { border-top: var(--bd); padding-top: 2rem; }
.summary .hook {
  font-family: var(--head); font-size: 1.2rem; font-weight: 700; line-height: 1.6;
  color: var(--ink); display: block; margin: 0 0 2rem; -webkit-line-clamp: none;
}
.points { list-style: none; margin: 0; padding: 0; display: grid; gap: 1.35rem; }
.points li { display: flex; gap: 1rem; align-items: flex-start; }
.points .n {
  font-family: var(--head); font-size: .9rem; font-weight: 800; color: var(--ink);
  background: var(--cloth, var(--accent-2)); border: var(--bd); box-shadow: var(--hard-sm);
  border-radius: var(--r); padding: .1rem .45rem; flex: 0 0 auto;
}
.points p { margin: 0; padding-top: .1rem; }
.closing {
  margin: 2.25rem 0 0; padding: 1rem 1.1rem;
  background: #fff; border: var(--bd); border-radius: var(--r); box-shadow: var(--hard-sm);
  color: #3a3340; font-weight: 500;
}

.tags { list-style: none; display: flex; flex-wrap: wrap; gap: .5rem;
        padding: 0; margin: 2.5rem 0 0; }
.tags li {
  font-family: var(--head); font-size: .74rem; font-weight: 700; color: var(--ink);
  background: #fff; border: var(--bd); box-shadow: var(--hard-sm);
  border-radius: var(--r); padding: .2rem .7rem;
}

.related { margin-top: 4rem; }
.related h2 {
  display: inline-block; font-family: var(--head); font-weight: 800; font-size: 1.1rem;
  margin: 0 0 1.25rem; color: var(--ink);
  background: var(--accent); border: var(--bd); box-shadow: var(--hard-sm);
  padding: .25rem .7rem; border-radius: var(--r);
}

/* ---------- prose ---------- */
.prose { max-width: 660px; margin: 0 auto; padding: 3rem 1.25rem 4rem; }
.prose h1 { font-family: var(--head); font-weight: 800; letter-spacing: -.02em;
            font-size: 2rem; margin: 0 0 2rem; }
.prose h2 {
  display: inline-block; font-family: var(--head); font-weight: 800; font-size: 1.05rem;
  color: var(--ink); background: var(--gold); border: var(--bd); box-shadow: var(--hard-sm);
  padding: .2rem .6rem; border-radius: var(--r); margin: 2.25rem 0 .8rem;
}
.prose p { margin: 0 0 1rem; }
.prose a { font-weight: 700; text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 2px; }

/* ---------- footer ---------- */
.foot {
  border-top: var(--bd); margin-top: 2rem;
  padding: 2rem 1.25rem 3rem; text-align: center;
  font-size: .8rem; color: var(--muted); font-weight: 500;
}
.foot p { margin: .3rem 0; }
.foot a { color: var(--ink); font-weight: 700; }

/* ---------- responsive / a11y ---------- */
@media (max-width: 560px) {
  .hero { padding-top: 2.25rem; }
  .grid { grid-template-columns: 1fr; }
  .book-cover { width: 150px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important; animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}
