/* ===================================================================
   bookspice · ป้ายยาหนังสือ
   Design: warm parchment / terracotta / sage — Bookery style
   =================================================================== */

:root {
  /* warm parchment palette */
  --bg: #f5f0e6;          /* page background — aged paper */
  --bg-2: #ede4d2;        /* warm sand */
  --bg-3: #faf6ee;        /* ivory card */
  --paper: #fffaef;       /* card paper */
  --ink: #3d2e1f;         /* warm near-black */
  --ink-2: #5e3023;       /* warm brown */
  --ink-3: #8a6f56;       /* muted brown */
  --line: #d8c8ad;        /* warm border */
  --line-2: #c9b48f;
  /* brand */
  --spice: #c96442;       /* terracotta */
  --spice-2: #d97757;     /* coral */
  --spice-3: #e89171;     /* peach */
  --sage: #7a8c6e;        /* sage green */
  --sage-2: #a8b89a;
  --gold: #c89b3c;        /* honey */
  --rose: #d4826e;        /* warm rose */
  /* type */
  --serif: 'Noto Serif Thai', Georgia, serif;
  --sans: 'Sarabun', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --hand: 'Caveat', cursive;
  /* effects */
  --shadow-sm: 0 1px 2px rgba(94, 48, 35, 0.08);
  --shadow: 0 4px 14px rgba(94, 48, 35, 0.12);
  --shadow-lg: 0 12px 32px rgba(94, 48, 35, 0.18);
  --radius: 14px;
  --radius-sm: 8px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--ink);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  /* subtle paper texture */
  background-image:
    radial-gradient(circle at 20% 30%, rgba(201, 149, 60, 0.04) 0, transparent 50%),
    radial-gradient(circle at 80% 70%, rgba(201, 100, 66, 0.05) 0, transparent 50%);
}

a { color: var(--spice); text-decoration: none; }
a:hover { color: var(--spice-2); }
button { font-family: inherit; cursor: pointer; border: none; background: none; }
input, textarea, select { font-family: inherit; font-size: 14px; }

/* ========== NAV ========== */
.nav {
  position: sticky; top: 0; z-index: 50;
  background: rgba(250, 246, 238, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.nav-inner {
  max-width: 1280px; margin: 0 auto;
  padding: 14px 24px;
  display: flex; align-items: center; gap: 24px;
}
.brand {
  display: flex; align-items: center; gap: 8px;
  color: var(--ink-2); font-weight: 700;
}
.brand-logo { font-size: 24px; }
.brand-name { font-family: var(--serif); font-size: 22px; letter-spacing: -0.5px; color: var(--ink); }
.brand-tag {
  font-size: 12px; color: var(--ink-3); font-weight: 400;
  padding-left: 10px; margin-left: 4px;
  border-left: 1px dashed var(--line-2);
}
.nav-links { display: flex; gap: 4px; margin-left: auto; }
.nav-links a {
  color: var(--ink-3); padding: 8px 14px;
  border-radius: 8px; font-size: 14px; font-weight: 500;
  transition: all 0.15s;
}
.nav-links a:hover { background: var(--bg-2); color: var(--ink-2); }
.nav-links a.active {
  background: var(--spice); color: #fff;
  box-shadow: var(--shadow-sm);
}
.nav-user { position: relative; }
.user-btn {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 12px 6px 6px;
  background: var(--bg-2); border-radius: 30px;
  border: 1px solid var(--line);
  transition: all 0.15s;
}
.user-btn:hover { background: var(--bg-3); border-color: var(--line-2); }
.user-avatar { font-size: 20px; }
.user-name { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.user-menu {
  position: absolute; right: 0; top: calc(100% + 8px);
  background: var(--paper); border: 1px solid var(--line);
  border-radius: var(--radius-sm); min-width: 200px;
  box-shadow: var(--shadow-lg);
  padding: 6px;
}
.user-menu a, .user-menu button {
  display: block; width: 100%; text-align: left;
  padding: 10px 12px; border-radius: 6px;
  font-size: 14px; color: var(--ink-2);
}
.user-menu a:hover, .user-menu button:hover { background: var(--bg-2); }

/* ========== HERO ========== */
.hero {
  padding: 60px 24px 40px;
  background: linear-gradient(180deg, var(--bg) 0%, var(--bg-2) 100%);
  border-bottom: 1px solid var(--line);
}
.hero-inner {
  max-width: 1280px; margin: 0 auto;
  display: grid; grid-template-columns: 1.1fr 1fr; gap: 60px;
  align-items: center;
}
.hero-eyebrow {
  font-size: 13px; font-weight: 600;
  color: var(--spice); letter-spacing: 0.5px;
  margin-bottom: 16px;
}
.hero-title {
  font-family: var(--serif);
  font-size: 56px; line-height: 1.1; font-weight: 600;
  color: var(--ink); margin-bottom: 20px;
  letter-spacing: -1px;
}
.hero-title em {
  font-style: normal; color: var(--spice);
  position: relative;
}
.hero-title em::after {
  content: ''; position: absolute;
  left: 0; right: 0; bottom: 4px;
  height: 8px; background: rgba(201, 100, 66, 0.18);
  z-index: -1; border-radius: 4px;
}
.hero-sub {
  font-size: 17px; color: var(--ink-3);
  margin-bottom: 28px; max-width: 480px;
}
.hero-cta { display: flex; gap: 12px; margin-bottom: 36px; flex-wrap: wrap; }
.btn-primary, .btn-ghost {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 12px 22px; border-radius: 30px;
  font-size: 15px; font-weight: 600;
  transition: all 0.15s;
  text-decoration: none;
  border: 1px solid transparent;
}
.btn-primary {
  background: var(--spice); color: #fff;
  box-shadow: var(--shadow);
}
.btn-primary:hover { background: var(--spice-2); transform: translateY(-1px); box-shadow: var(--shadow-lg); color: #fff; }
.btn-ghost {
  background: transparent; color: var(--ink-2);
  border-color: var(--line-2);
}
.btn-ghost:hover { background: var(--bg-3); border-color: var(--ink-3); }
.hero-stats { display: flex; gap: 32px; padding-top: 24px; border-top: 1px dashed var(--line-2); }
.hero-stats > div { display: flex; flex-direction: column; }
.hero-stats strong { font-family: var(--serif); font-size: 28px; color: var(--ink); font-weight: 600; }
.hero-stats span { font-size: 12px; color: var(--ink-3); }

/* hero card sample */
.hero-card {
  position: relative; height: 420px;
}
.card-sample {
  position: absolute;
  width: 360px;
  background: var(--bg);
  border-radius: 18px;
  padding: 28px;
  box-shadow: var(--shadow-lg), inset 0 0 0 1px rgba(94, 48, 35, 0.08);
  transform: rotate(var(--rot, 0deg));
  transition: transform 0.3s;
}
.card-sample:first-of-type { left: 0; top: 30px; z-index: 2; }
.card-sample.card-back { right: 0; top: 80px; z-index: 1; transform: rotate(5deg); }
.card-sample:hover { transform: rotate(0deg) translateY(-4px); z-index: 3; }

.card-tape {
  position: absolute; top: -10px; left: 50%;
  transform: translateX(-50%);
  width: 80px; height: 22px;
  background: rgba(200, 155, 60, 0.4);
  border: 1px solid rgba(200, 155, 60, 0.6);
  border-radius: 2px;
}
.card-stamp {
  position: absolute; top: 14px; right: 14px;
  background: var(--spice); color: #fff;
  padding: 4px 10px; border-radius: 4px;
  font-size: 11px; font-weight: 700; letter-spacing: 0.5px;
  transform: rotate(8deg);
  font-family: var(--sans);
}
.card-body { padding-top: 8px; }
.book-mini { display: flex; gap: 12px; margin-bottom: 14px; }
.book-cover {
  width: 56px; height: 80px; flex-shrink: 0;
  border-radius: 4px;
  display: flex; align-items: center; justify-content: center;
  font-size: 32px;
  box-shadow: var(--shadow-sm);
  color: #fff;
  overflow: hidden;
  position: relative;
  background: linear-gradient(135deg, var(--spice), var(--spice-2));
}
.book-cover img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
  border-radius: 4px;
}
.book-cover .cover-fallback {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 32px;
  background: linear-gradient(135deg, var(--spice), var(--spice-2));
  color: #fff;
}
.book-cover.has-cover .cover-fallback { display: none; }
.book-info h3 {
  font-family: var(--serif);
  font-size: 17px; color: var(--ink);
  font-weight: 600; line-height: 1.2;
  margin-bottom: 4px;
}
.book-info .by { font-size: 12px; color: var(--ink-3); }
.card-quote {
  font-family: var(--hand);
  font-size: 22px; color: var(--ink-2);
  line-height: 1.3; margin: 12px 0;
  border-left: 3px solid var(--spice);
  padding-left: 12px;
}
.card-tags { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.tag {
  font-size: 11px; color: var(--spice);
  background: rgba(201, 100, 66, 0.1);
  padding: 3px 8px; border-radius: 12px;
  font-weight: 500;
}
.card-footer {
  display: flex; justify-content: space-between; align-items: center;
  padding-top: 10px; border-top: 1px dashed var(--line);
  font-size: 12px;
}
.card-footer .rating { font-size: 14px; letter-spacing: 1px; }
.card-footer .hype { color: var(--ink-3); }

/* ========== FILTERS ========== */
.filters {
  padding: 32px 24px 0;
  max-width: 1280px; margin: 0 auto;
}
.section-title {
  font-family: var(--serif);
  font-size: 26px; color: var(--ink);
  font-weight: 600; margin-bottom: 16px;
}
.filter-chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  padding: 8px 16px; border-radius: 20px;
  background: var(--bg-3); color: var(--ink-3);
  font-size: 13px; font-weight: 500;
  border: 1px solid var(--line);
  transition: all 0.15s;
}
.chip:hover { border-color: var(--spice); color: var(--spice); }
.chip.active {
  background: var(--ink-2); color: var(--bg-3);
  border-color: var(--ink-2);
}

/* ========== FEED ========== */
.feed {
  max-width: 1280px; margin: 0 auto;
  padding: 24px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 22px;
}
.feed-card {
  background: var(--paper);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--line);
  position: relative;
  transition: all 0.2s;
  cursor: pointer;
}
.feed-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
  border-color: var(--line-2);
}
.feed-card .card-stamp { top: 10px; right: 10px; transform: rotate(4deg); }
.feed-card .card-tape { display: none; }
.feed-card .book-mini { margin-bottom: 12px; }
.feed-card .book-cover { width: 64px; height: 90px; font-size: 24px; box-shadow: 0 2px 8px rgba(0,0,0,0.18), 0 0 0 1px rgba(0,0,0,0.06); }
.feed-card .book-cover img { box-shadow: 0 2px 8px rgba(0,0,0,0.18); }
.feed-card .book-info h3 { font-size: 15px; }
.feed-card .card-quote {
  font-size: 19px;
  margin: 10px 0;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.feed-card .card-footer { font-size: 11px; }
.feed-card .card-tags { margin-bottom: 6px; }
.feed-card .author-line {
  display: flex; align-items: center; gap: 8px;
  margin-top: 10px; padding-top: 10px;
  border-top: 1px dashed var(--line);
  font-size: 12px; color: var(--ink-3);
}
.feed-card .author-line .avatar { font-size: 16px; }
.feed-card.cw-blurred .card-quote,
.feed-card.cw-blurred .card-tags { filter: blur(5px); }
.cw-badge {
  position: absolute; top: 12px; left: 12px;
  background: var(--ink-2); color: var(--bg-3);
  padding: 3px 8px; border-radius: 4px;
  font-size: 10px; font-weight: 700;
  z-index: 4;
}
.feed-card .cw-overlay {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  flex-direction: column;
  background: rgba(250, 246, 238, 0.5);
  backdrop-filter: blur(2px);
  border-radius: var(--radius);
  font-size: 14px; color: var(--ink-2);
  font-weight: 700;
  text-align: center;
  padding: 20px;
  cursor: pointer;
  z-index: 5;
  transition: background 0.2s;
}
.feed-card .cw-overlay:hover { background: rgba(250, 246, 238, 0.35); }
.feed-card .cw-overlay small { font-size: 11px; font-weight: 500; opacity: 0.7; margin-top: 4px; }

/* ========== TRENDING WIDGET ========== */
.trending {
  max-width: 1280px; margin: 32px auto;
  padding: 24px;
  background: var(--bg-3);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.trending h3 {
  font-family: var(--serif);
  font-size: 18px; color: var(--ink);
  font-weight: 600; margin-bottom: 16px;
}
.trending-list {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
}
.trending-list li {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px;
  background: var(--paper);
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
}
.trending-list .rank {
  font-family: var(--serif);
  font-size: 24px; font-weight: 700; color: var(--spice);
  min-width: 32px;
}
.trending-list .info { flex: 1; min-width: 0; }
.trending-list .title { font-weight: 600; color: var(--ink); font-size: 14px; }
.trending-list .meta { font-size: 11px; color: var(--ink-3); }
.trending-list .hype { color: var(--spice); font-weight: 600; font-size: 13px; }

/* ========== EMPTY ========== */
.empty-state {
  text-align: center;
  padding: 80px 24px;
  max-width: 480px; margin: 0 auto;
}
.empty-emoji { font-size: 64px; margin-bottom: 16px; }
.empty-state h3 { font-family: var(--serif); font-size: 22px; color: var(--ink); margin-bottom: 8px; }
.empty-state p { color: var(--ink-3); margin-bottom: 24px; }

/* ========== FOOTER ========== */
.site-footer {
  margin-top: 60px;
  border-top: 1px solid var(--line);
  background: var(--bg-2);
  padding: 32px 24px;
}
.footer-inner {
  max-width: 1280px; margin: 0 auto;
  display: flex; justify-content: space-between; align-items: center;
  flex-wrap: wrap; gap: 16px;
  color: var(--ink-3); font-size: 13px;
}
.footer-inner strong { color: var(--ink-2); }

/* ========== PROFILE ========== */
.profile-header {
  padding: 48px 24px 32px;
  background: linear-gradient(180deg, var(--bg) 0%, var(--bg-2) 100%);
  border-bottom: 1px solid var(--line);
}
.profile-inner {
  max-width: 1280px; margin: 0 auto;
  display: flex; align-items: center; gap: 24px;
}
.avatar-big {
  width: 96px; height: 96px;
  background: var(--bg-3);
  border: 2px solid var(--line-2);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 48px;
  box-shadow: var(--shadow);
}
.profile-meta { flex: 1; }
.profile-meta h1 {
  font-family: var(--serif);
  font-size: 32px; color: var(--ink);
  font-weight: 600; margin-bottom: 4px;
}
.profile-bio { color: var(--ink-3); font-size: 14px; margin-bottom: 16px; }
.profile-stats { display: flex; gap: 24px; }
.profile-stats > div { display: flex; flex-direction: column; }
.profile-stats strong { font-family: var(--serif); font-size: 22px; color: var(--ink); font-weight: 600; }
.profile-stats span { font-size: 11px; color: var(--ink-3); }

.shelf-tabs {
  display: flex; gap: 6px; flex-wrap: wrap;
  max-width: 1280px; margin: 0 auto;
  padding: 24px 24px 0;
}
.shelf-tab {
  padding: 10px 18px;
  background: var(--bg-3);
  color: var(--ink-3);
  border: 1px solid var(--line);
  border-radius: 24px;
  font-size: 14px; font-weight: 500;
  transition: all 0.15s;
}
.shelf-tab:hover { border-color: var(--spice); color: var(--spice); }
.shelf-tab.active {
  background: var(--ink-2); color: var(--bg-3);
  border-color: var(--ink-2);
}
.add-shelf {
  margin-left: auto;
  padding: 10px 18px;
  background: var(--spice); color: #fff;
  border-radius: 24px;
  font-size: 14px; font-weight: 600;
}
.add-shelf:hover { background: var(--spice-2); }

.shelf-view {
  max-width: 1280px; margin: 0 auto;
  padding: 24px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 18px;
}
.book-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  display: flex; gap: 14px;
  transition: all 0.15s;
}
.book-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}
.book-card .cover {
  width: 60px; height: 86px; flex-shrink: 0;
  background: linear-gradient(135deg, var(--spice), var(--spice-2));
  border-radius: 4px;
  display: flex; align-items: center; justify-content: center;
  font-size: 28px; color: #fff;
  box-shadow: var(--shadow-sm);
}
.book-card .info { flex: 1; min-width: 0; }
.book-card h4 {
  font-family: var(--serif);
  font-size: 15px; color: var(--ink);
  font-weight: 600; margin-bottom: 4px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.book-card .author { font-size: 12px; color: var(--ink-3); margin-bottom: 8px; }
.book-card .book-actions { display: flex; gap: 6px; }
.book-card .book-actions button {
  font-size: 11px; padding: 4px 8px;
  border-radius: 4px;
  background: var(--bg-2); color: var(--ink-2);
}
.book-card .book-actions button:hover { background: var(--spice); color: #fff; }

/* ========== EXPLORE ========== */
.explore-header {
  max-width: 1280px; margin: 0 auto;
  padding: 48px 24px 24px;
  text-align: center;
}
.explore-header h1 {
  font-family: var(--serif);
  font-size: 36px; color: var(--ink);
  font-weight: 600; margin-bottom: 20px;
}
.search-box { max-width: 520px; margin: 0 auto 20px; }
.search-box input {
  width: 100%; padding: 14px 20px;
  background: var(--paper);
  border: 1px solid var(--line-2);
  border-radius: 30px;
  font-size: 15px;
  color: var(--ink);
  outline: none;
  transition: border-color 0.15s;
}
.search-box input:focus { border-color: var(--spice); }

/* ========== TOAST ========== */
.toast {
  position: fixed; bottom: 32px; left: 50%;
  transform: translateX(-50%);
  background: var(--ink-2); color: var(--bg-3);
  padding: 12px 22px; border-radius: 24px;
  font-size: 14px; font-weight: 500;
  box-shadow: var(--shadow-lg);
  z-index: 1000;
  animation: toastIn 0.2s ease-out;
}
@keyframes toastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(20px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ========== MODAL ========== */
.modal[hidden] { display: none !important; }
.modal {
  position: fixed; inset: 0;
  background: rgba(61, 46, 31, 0.5);
  display: flex; align-items: center; justify-content: center;
  z-index: 200; padding: 24px;
}
.modal-box {
  background: var(--paper);
  border-radius: var(--radius);
  padding: 28px;
  max-width: 440px; width: 100%;
  box-shadow: var(--shadow-lg);
}
.modal-box h3 { font-family: var(--serif); font-size: 22px; margin-bottom: 18px; color: var(--ink); }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; }
.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: 12px; color: var(--ink-3); margin-bottom: 4px; font-weight: 500; }
.field input, .field textarea, .field select {
  width: 100%; padding: 10px 14px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-size: 14px; color: var(--ink);
  outline: none;
  transition: border-color 0.15s;
}
.field input:focus, .field textarea:focus, .field select:focus { border-color: var(--spice); }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--ink-2); cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--spice); }

/* ========== RESPONSIVE ========== */
@media (max-width: 900px) {
  .hero-inner { grid-template-columns: 1fr; gap: 32px; }
  .hero-card { display: none; }
  .hero-title { font-size: 40px; }
  .nav-links { gap: 0; }
  .nav-links a { padding: 6px 10px; font-size: 13px; }
  .brand-tag { display: none; }
  .profile-inner { flex-direction: column; text-align: center; }
  .profile-stats { justify-content: center; }
  .shelf-tabs .add-shelf { margin-left: 0; }
}
@media (max-width: 600px) {
  .nav-inner { padding: 10px 16px; gap: 8px; flex-wrap: wrap; }
  .nav-links { order: 3; width: 100%; justify-content: center; }
  .hero { padding: 32px 16px 24px; }
  .hero-title { font-size: 32px; }
  .feed, .shelf-view { grid-template-columns: 1fr; padding: 16px; }
}
