/* =========================================================================
   02._.library — motion web (หน้าแรก)
   ========================================================================= */

/* ---------------------------------------------------------------- cursor */
.has-cursor, .has-cursor a, .has-cursor button { cursor: none; }
#cursor-dot, #cursor-ring {
  position: fixed; top: 0; left: 0; z-index: 900; pointer-events: none; border-radius: 50%;
  transition: opacity .3s var(--ease-out);
}
#cursor-dot { width: 6px; height: 6px; margin: -3px 0 0 -3px; background: var(--gold); }
#cursor-ring {
  width: 34px; height: 34px; margin: -17px 0 0 -17px; border: 1px solid var(--line-2);
  transition: width .25s var(--ease-out), height .25s var(--ease-out), margin .25s var(--ease-out), border-color .25s, background .25s, opacity .3s;
}
#cursor-ring.is-active { width: 62px; height: 62px; margin: -31px 0 0 -31px; border-color: var(--gold); background: rgba(201, 162, 39, .08); }
@media (hover: none) { #cursor-dot, #cursor-ring { display: none; } }

/* ---------------------------------------------------------------- scroll progress */
#scroll-progress {
  position: fixed; top: 0; left: 0; right: 0; height: 2px; z-index: 200;
  background: linear-gradient(90deg, var(--gold), var(--navy));
  transform: scaleX(0); transform-origin: left; pointer-events: none;
}

/* ---------------------------------------------------------------- hero */
.hero {
  position: relative; overflow: clip; padding: clamp(38px, 6vw, 84px) 0 clamp(30px, 4vw, 54px);
  isolation: isolate;
}
.hero-canvas { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 0; opacity: .9; }
.hero-glow {
  position: absolute; z-index: 0; inset: -20% -10% auto; height: 90%;
  background:
    radial-gradient(46% 40% at 16% 6%, rgba(201, 162, 39, .22), transparent 66%),
    radial-gradient(40% 36% at 88% 18%, rgba(14, 23, 40, .12), transparent 70%);
  pointer-events: none;
  animation: glow-drift 16s ease-in-out infinite alternate;
}
@keyframes glow-drift { to { transform: translate3d(3%, -4%, 0) scale(1.06); } }

.hero-grid { position: relative; z-index: 2; display: grid; grid-template-columns: 1.04fr .96fr; gap: clamp(28px, 4vw, 56px); align-items: center; }
.hero-copy { position: relative; }

.hero-kicker {
  display: inline-flex; align-items: center; gap: 10px; padding: 7px 8px 7px 14px; border-radius: var(--r-pill);
  background: color-mix(in srgb, var(--surface) 78%, transparent); border: 1px solid var(--line);
  font-size: var(--fs-2xs); font-weight: 600; letter-spacing: .04em; color: var(--ink-2);
  box-shadow: var(--shadow-1); backdrop-filter: blur(8px);
}
.hero-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--gold); box-shadow: 0 0 0 4px rgba(201, 162, 39, .18); animation: pulse-dot 2.4s infinite; }
@keyframes pulse-dot { 50% { box-shadow: 0 0 0 8px rgba(201, 162, 39, 0); } }
.hero-chip { padding: 4px 10px; border-radius: var(--r-pill); background: var(--navy); color: #fbf7ee; font-size: var(--fs-2xs); font-weight: 600; }

.hero-title { margin-top: 22px; font-family: var(--display); font-weight: 600; font-size: var(--fs-3xl); line-height: 1.02; letter-spacing: -.035em; }
.hero-title .line { display: block; overflow: hidden; }
.hero-title .line > span {
  display: inline-block; transform: translateY(110%) rotate(2deg);
  animation: line-up 1.05s var(--ease-out) forwards;
}
.hero-title .line:nth-child(1) > span { animation-delay: .08s; }
.hero-title .line:nth-child(2) > span { animation-delay: .18s; }
.hero-title .line:nth-child(3) > span { animation-delay: .28s; }
.hero-title .accent {
  color: var(--navy);
  background-image: linear-gradient(180deg, transparent 58%, rgba(201, 162, 39, .55) 58%, rgba(201, 162, 39, .55) 92%, transparent 92%);
  background-repeat: no-repeat;
  background-size: 0% 100%;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
  animation: swash 1.1s 1s var(--ease-out) forwards;
}
@keyframes swash { to { background-size: 100% 100%; } }
@keyframes line-up { to { transform: none; } }

.hero-lead { margin-top: 22px; font-size: clamp(14.5px, 1.5vw, 17px); color: var(--muted); max-width: 46ch; }
.hero-cta { display: flex; gap: 12px; margin-top: 30px; flex-wrap: wrap; }
.hero-cta .btn { will-change: transform; }

.hero-stats { display: flex; gap: clamp(20px, 3vw, 38px); margin-top: 40px; flex-wrap: wrap; }
.hero-stat b { display: block; font-family: var(--display); font-weight: 600; font-size: clamp(24px, 2.6vw, 32px); line-height: 1.05; letter-spacing: -.02em; }
.hero-stat span { font-size: var(--fs-2xs); color: var(--muted); }
.hero-stat b[data-count] { font-variant-numeric: tabular-nums; }

/* ---- hero visual ---- */
.hero-visual { position: relative; }
.hero-stage {
  position: relative; height: clamp(340px, 42vw, 520px); border-radius: var(--r-xl);
  background: linear-gradient(165deg, color-mix(in srgb, var(--surface) 92%, transparent), color-mix(in srgb, var(--paper-2) 88%, transparent));
  border: 1px solid var(--line); box-shadow: var(--shadow-3);
  overflow: hidden; transform-style: preserve-3d; transition: transform .4s var(--ease-out);
}
.hero-stage::before {
  content: ''; position: absolute; inset: 0;
  background:
    linear-gradient(rgba(14, 23, 40, .05) 1px, transparent 1px) 0 0 / 40px 40px,
    linear-gradient(90deg, rgba(14, 23, 40, .05) 1px, transparent 1px) 0 0 / 40px 40px;
  mask-image: radial-gradient(70% 70% at 50% 40%, #000 40%, transparent 100%);
}
.hero-stage__shelf {
  position: absolute; left: 24px; right: 24px; bottom: 74px; display: flex; align-items: flex-end;
  justify-content: center; gap: 5px; height: 66%;
}
.spine {
  position: relative; width: clamp(22px, 3.4vw, 34px); border-radius: 3px 3px 2px 2px;
  transform-origin: bottom center; cursor: pointer; overflow: hidden;
  box-shadow: inset -7px 0 12px rgba(0, 0, 0, .26), inset 5px 0 9px rgba(255, 255, 255, .12), 0 12px 22px rgba(14, 23, 40, .18);
  transition: transform .45s var(--ease-out), box-shadow .45s var(--ease-out), filter .3s;
  animation: spine-in .9s var(--ease-out) backwards;
}
@keyframes spine-in { from { transform: translateY(34px) scaleY(.9); opacity: 0; } }
.spine:hover { transform: translateY(-26px) rotate(-1.5deg) scale(1.05); box-shadow: inset -7px 0 12px rgba(0, 0, 0, .2), 0 26px 44px rgba(14, 23, 40, .3); filter: saturate(1.1); z-index: 3; }
.spine__label {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  writing-mode: vertical-rl; rotate: 180deg; padding: 10px 0;
  font-family: var(--display); font-weight: 500; font-size: clamp(10px, 1.1vw, 12.5px);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.spine__edge { position: absolute; left: 0; right: 0; top: 18%; height: 1px; background: rgba(255, 255, 255, .22); }
.spine--filler { pointer-events: none; }
.spine__shine { position: absolute; inset: 0; background: linear-gradient(102deg, transparent 32%, rgba(255, 255, 255, .26) 46%, transparent 60%); transform: translateX(-130%); animation: shine 6.5s 1.4s infinite var(--ease-out); }
@keyframes shine { 0%, 58% { transform: translateX(-130%); } 78%, 100% { transform: translateX(130%); } }
.hero-stage__rail { position: absolute; left: 18px; right: 18px; bottom: 62px; height: 12px; border-radius: 8px;
  background: linear-gradient(180deg, #ded3bd, #b3a68d 55%, #9c8f76); box-shadow: 0 12px 24px rgba(14, 23, 40, .2); }
.hero-stage__rail::before { content: ''; position: absolute; left: 0; right: 0; top: -3px; height: 5px; border-radius: 4px; background: linear-gradient(180deg, #f5efe2, #ded3bd); }
.hero-stage__tag {
  position: absolute; top: 16px; left: 18px; display: grid; gap: 2px; font-size: var(--fs-2xs); color: var(--muted);
  background: color-mix(in srgb, var(--surface) 86%, transparent); border: 1px solid var(--line);
  border-radius: var(--r-sm); padding: 8px 12px; backdrop-filter: blur(8px);
}
.hero-stage__tag b { font-family: var(--display); font-size: var(--fs-sm); color: var(--ink); }
.hero-stage__meta {
  position: absolute; left: 18px; bottom: 18px; display: grid; gap: 2px;
  background: color-mix(in srgb, var(--surface) 92%, transparent); border: 1px solid var(--line);
  border-radius: var(--r-sm); padding: 8px 12px; backdrop-filter: blur(8px);
}
.hero-stage__meta-k { font-size: var(--fs-2xs); letter-spacing: .14em; text-transform: uppercase; color: var(--muted-2); }
.hero-stage__meta b { font-family: var(--display); font-weight: 500; font-size: var(--fs-xs); }
.hero-stage__hint {
  position: absolute; right: 18px; bottom: 16px; font-size: var(--fs-2xs); color: var(--muted-2);
  display: inline-flex; align-items: center; gap: 6px;
}

.scroll-cue {
  position: relative; z-index: 2; margin-top: 26px; display: inline-flex; align-items: center; gap: 9px;
  font-size: var(--fs-2xs); letter-spacing: .12em; text-transform: uppercase; color: var(--muted-2);
}
.scroll-cue i { display: block; width: 1px; height: 26px; background: linear-gradient(var(--muted-2), transparent); animation: cue 1.8s infinite var(--ease-inout); }
@keyframes cue { 0%, 100% { transform: scaleY(.55); opacity: .4; } 50% { transform: scaleY(1); opacity: 1; } }

/* ---------------------------------------------------------------- marquee */
.marquee-band { border-block: 1px solid var(--line); background: var(--surface-2); overflow: hidden; padding: 14px 0; }
.marquee-track { display: flex; gap: 44px; width: max-content; animation: marquee 38s linear infinite; will-change: transform; }
.marquee-item { display: inline-flex; align-items: center; gap: 14px; font-family: var(--display); font-weight: 500; font-size: var(--fs-md); color: var(--muted); white-space: nowrap; }
.marquee-item::after { content: '✦'; color: var(--gold); font-size: 13px; }
@keyframes marquee { to { transform: translateX(-50%); } }

/* ---------------------------------------------------------------- rail (pinned) */
.rail-section { position: relative; background: linear-gradient(180deg, var(--paper), color-mix(in srgb, var(--navy) 4%, var(--paper))); }
.rail-sticky { position: sticky; top: 68px; }
.rail-head { display: flex; align-items: end; justify-content: space-between; gap: 24px; padding: 52px 0 20px; flex-wrap: wrap; }
.rail {
  display: flex; gap: 18px; overflow-x: auto; scroll-behavior: auto; padding: 6px 0 42px;
  scrollbar-width: none;
}
.rail::-webkit-scrollbar { display: none; }
.rail-card {
  flex: 0 0 auto; width: clamp(196px, 21vw, 240px); background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); padding: 12px; box-shadow: var(--shadow-2); transition: transform .4s var(--ease-out), box-shadow .4s var(--ease-out);
}
.rail-card:hover { transform: translateY(-8px) rotate(-.4deg); box-shadow: var(--shadow-4); }
.rail-card .cover { aspect-ratio: 3 / 4.1; border-radius: var(--r-md); }
.rail-card__meta { padding: 12px 4px 4px; display: grid; gap: 3px; }
.rail-card__title { font-family: var(--display); font-weight: 500; font-size: var(--fs-sm); line-height: 1.32; }
.rail-card__sub { font-size: var(--fs-2xs); color: var(--muted); }
.rail-hint { display: flex; justify-content: space-between; align-items: center; padding-bottom: 34px; font-size: var(--fs-2xs); color: var(--muted-2); }

/* ---------------------------------------------------------------- covers */
.cover { position: relative; overflow: hidden; border-radius: 6px; background: var(--paper-2); }
.cover img { width: 100%; height: 100%; object-fit: cover; }
.cover--type {
  display: grid; align-content: space-between; padding: 16px 13px;
  background: linear-gradient(160deg, var(--cover-accent, #0e1728), #070d17 88%);
  color: #f6f1e7;
}
.cover--type::before { content: ''; position: absolute; inset: 10px; border: 1px solid rgba(246, 241, 231, .2); border-radius: 3px; pointer-events: none; }
.cover__rule { width: 26px; height: 2px; background: var(--gold); border-radius: 2px; }
.cover__title { font-family: var(--display); font-weight: 500; font-size: 15px; line-height: 1.25; margin-top: 8px; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.cover__author { font-size: 9.5px; letter-spacing: .18em; text-transform: uppercase; opacity: .7; margin-top: auto; padding-top: 10px; }

/* ---------------------------------------------------------------- features */
.features-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.feature-card {
  position: relative; overflow: hidden; padding: 26px 22px; border-radius: var(--r-lg);
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-1);
  transition: transform .4s var(--ease-out), box-shadow .4s var(--ease-out), border-color .3s;
}
.feature-card::after {
  content: ''; position: absolute; inset: 0; opacity: 0; transition: opacity .4s;
  background: radial-gradient(220px 160px at var(--mx, 50%) var(--my, 0%), rgba(201, 162, 39, .16), transparent 70%);
}
.feature-card:hover { transform: translateY(-6px); box-shadow: var(--shadow-3); border-color: color-mix(in srgb, var(--gold) 40%, var(--line)); }
.feature-card:hover::after { opacity: 1; }
.feature-card__icon { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 12px; background: var(--navy); color: #fbf7ee; margin-bottom: 16px; }
.feature-card h3 { font-family: var(--display); font-weight: 600; font-size: var(--fs-md); margin-bottom: 6px; }
.feature-card p { font-size: var(--fs-xs); color: var(--muted); line-height: 1.6; }

/* ---------------------------------------------------------------- random picker */
.picker {
  position: relative; overflow: hidden; border-radius: var(--r-xl); padding: clamp(26px, 3.6vw, 46px);
  background: linear-gradient(150deg, #0d1626, #070c15 70%); color: #f2eee4; isolation: isolate;
}
.picker::before {
  content: ''; position: absolute; inset: 0; z-index: -1;
  background: radial-gradient(340px 240px at var(--mx, 70%) var(--my, 20%), rgba(201, 162, 39, .3), transparent 70%);
  transition: background .3s;
}
.picker-grid { display: grid; grid-template-columns: 1.1fr .9fr; gap: 30px; align-items: center; }
.picker h2 { font-family: var(--display); font-weight: 600; font-size: var(--fs-xl); line-height: 1.15; }
.picker p { color: rgba(242, 238, 228, .72); font-size: var(--fs-sm); margin-top: 10px; max-width: 40ch; }
.picker-card {
  position: relative; border-radius: var(--r-lg); padding: 16px; background: rgba(242, 238, 228, .06);
  border: 1px solid rgba(242, 238, 228, .14); display: grid; gap: 12px; justify-items: center; text-align: center;
}
.picker-card .cover { width: 148px; aspect-ratio: 3 / 4.1; box-shadow: var(--shadow-4); }
.picker-card__title { font-family: var(--display); font-weight: 500; font-size: var(--fs-sm); line-height: 1.3; }
.picker-card__price { font-size: var(--fs-2xs); color: rgba(242, 238, 228, .68); }
.picker.is-shuffling .cover { animation: shuffle .5s var(--ease-inout); }
@keyframes shuffle { 25% { transform: rotateY(24deg) scale(.96); } 60% { transform: rotateY(-18deg) scale(1.01); } }

/* ---------------------------------------------------------------- zones */
.zones { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.zone-card {
  position: relative; overflow: hidden; padding: clamp(24px, 3vw, 34px); border-radius: var(--r-xl);
  min-height: 248px; display: grid; align-content: space-between; gap: 22px; text-align: left;
  transition: transform .45s var(--ease-out), box-shadow .45s var(--ease-out);
}
.zone-card:hover { transform: translateY(-6px); box-shadow: var(--shadow-3); }
.zone-card--light { background: var(--surface); border: 1px solid var(--line); }
.zone-card--dark { background: linear-gradient(155deg, #111c2e, #060b14); color: #f2eee4; }
.zone-card h3 { font-family: var(--display); font-weight: 600; font-size: var(--fs-xl); line-height: 1.2; }
.zone-card p { font-size: var(--fs-xs); max-width: 40ch; opacity: .82; margin-top: 8px; }
.zone-card--dark .eyebrow { color: var(--gold-2); }
.zone-card__badge { display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border-radius: var(--r-pill); background: rgba(242, 238, 228, .12); font-size: var(--fs-2xs); font-weight: 600; }

/* ---------------------------------------------------------------- steps */
.steps { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; counter-reset: step; }
.step-item { position: relative; padding: 26px 22px; border-radius: var(--r-lg); background: var(--surface); border: 1px solid var(--line); }
.step-item::before {
  counter-increment: step; content: counter(step, decimal-leading-zero);
  font-family: var(--display); font-weight: 600; font-size: var(--fs-xs); letter-spacing: .12em;
  color: var(--gold-3); display: block; margin-bottom: 12px;
}
.step-item h4 { font-family: var(--display); font-weight: 500; font-size: var(--fs-sm); margin-bottom: 6px; }
.step-item p { font-size: var(--fs-xs); color: var(--muted); }

/* ---------------------------------------------------------------- cta band */
.cta-band {
  position: relative; overflow: hidden; border-radius: var(--r-xl); padding: clamp(30px, 4vw, 52px);
  background: linear-gradient(150deg, #101b2c, #05090f 72%); color: #f2eee4;
  display: flex; align-items: center; justify-content: space-between; gap: 30px; flex-wrap: wrap;
}
.cta-band::before {
  content: ''; position: absolute; right: -80px; top: -100px; width: 380px; height: 380px; border-radius: 50%;
  background: radial-gradient(circle, rgba(201, 162, 39, .32), transparent 66%);
  animation: glow-drift 12s ease-in-out infinite alternate;
}
.cta-band h2 { font-family: var(--display); font-weight: 600; font-size: var(--fs-xl); line-height: 1.2; }
.cta-band p { color: rgba(242, 238, 228, .72); margin-top: 8px; font-size: var(--fs-sm); }

/* ---------------------------------------------------------------- search overlay */
.search-overlay {
  position: fixed; inset: 0; z-index: 500; display: grid; align-items: start; justify-items: center;
  padding: clamp(40px, 10vh, 120px) 20px; background: rgba(10, 14, 22, .5); backdrop-filter: blur(6px);
  opacity: 0; pointer-events: none; transition: opacity .22s var(--ease-out);
}
.search-overlay.is-open { opacity: 1; pointer-events: all; }
.search-panel {
  width: min(100%, 620px); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-xl);
  box-shadow: var(--shadow-4); overflow: hidden; transform: translateY(-10px) scale(.99); transition: transform .26s var(--ease-out);
}
.search-overlay.is-open .search-panel { transform: none; }
.search-field { display: flex; align-items: center; gap: 12px; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.search-field input { flex: 1; border: 0; background: none; font-size: var(--fs-md); outline: none; }
.search-field kbd { font-family: var(--font); font-size: var(--fs-2xs); color: var(--muted-2); border: 1px solid var(--line-2); border-radius: 6px; padding: 2px 7px; }
.search-list { max-height: 52vh; overflow-y: auto; padding: 8px; }
.search-item {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; padding: 10px 12px;
  border-radius: var(--r-md); transition: background var(--dur-fast);
}
.search-item:hover, .search-item.is-active { background: color-mix(in srgb, var(--ink) 6%, transparent); }
.search-item .cover { width: 30px; aspect-ratio: 3 / 4.1; border-radius: 4px; flex: 0 0 auto; }
.search-item__body { min-width: 0; }
.search-item__title { font-size: var(--fs-sm); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search-item__meta { font-size: var(--fs-2xs); color: var(--muted); }
.search-empty { padding: 26px 18px; text-align: center; font-size: var(--fs-xs); color: var(--muted); }
.search-foot { display: flex; gap: 14px; padding: 10px 18px; border-top: 1px solid var(--line); font-size: var(--fs-2xs); color: var(--muted-2); }

/* ---------------------------------------------------------------- reveal */
[data-reveal] { opacity: 0; transform: translateY(22px); transition: opacity .8s var(--ease-out), transform .8s var(--ease-out); }
[data-reveal].is-in { opacity: 1; transform: none; }
[data-reveal='mask'] > * { opacity: 0; transform: translateY(110%); transition: opacity .7s var(--ease-out), transform .9s var(--ease-out); display: block; }
[data-reveal='mask'].is-in > * { opacity: 1; transform: none; }

/* ---------------------------------------------------------------- responsive */
@media (max-width: 1040px) {
  .hero-grid { grid-template-columns: 1fr; }
  .hero-visual { order: -1; }
  .hero-stage { height: clamp(280px, 48vw, 380px); }
  .features-grid { grid-template-columns: repeat(2, 1fr); }
  .steps { grid-template-columns: repeat(2, 1fr); }
  .picker-grid { grid-template-columns: 1fr; }
  .rail { overflow-x: auto; }
}
@media (max-width: 720px) {
  .zones { grid-template-columns: 1fr; }
  .features-grid, .steps { grid-template-columns: 1fr; }
  .search-panel { border-radius: var(--r-lg); }
  .hero-stage__tag { display: none; }
}
