/* Shared CSS for the S8 Truyện mock. Values come from design/redesign/*.dc.html
   (<helmet><style>) and tokens.json; page markup keeps the boards' inline styles,
   this file holds what inline styles cannot express: hover/focus states,
   responsive overrides, the card v3 plate, the mobile hero cover and overlays. */

:root {
  --primary: #0A84F1;
  --primary-600: #0773D9;
  --primary-700: #0668C4;
  --primary-50: #EAF4FE;
  --ink: #172033;
  --ink-2: #3E4A5F;
  --muted: #5B6578;
  --subtle: #8A93A5;
  --line: #E5EAF1;
  --line-soft: #EEF2F7;
  --surface: #F4F7FB;
  --card: #FFFFFF;
  --footer: #EBF0F6;
  --footer-line: #DCE3EC;
}

html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--surface);
  color: var(--ink);
  font-family: "Be Vietnam Pro", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary-700); text-decoration: none; }
a:hover { color: var(--primary-600); }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
button { cursor: pointer; }
[hidden] { display: none !important; }
input[type="search"]::-webkit-search-cancel-button { -webkit-appearance: none; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

/* Page shells: desktop board from 768px, mobile board below. `clip` (not hidden) keeps
   sticky headers/bars working while hiding overflow such as a bottom bar slid out of view. */
.page-d, .page-m { min-height: 100vh; flex-direction: column; overflow: clip; }

/* Tailwind's container sets width: 100% + side padding; without preflight it needs border-box. */
.container { box-sizing: border-box; }

/* ---------- Text helpers ---------- */
.clamp2, .clamp3 { display: -webkit-box; -webkit-box-orient: vertical; overflow: hidden; }
.clamp2 { -webkit-line-clamp: 2; }
.clamp3 { -webkit-line-clamp: 3; }
.ellip { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hs { scrollbar-width: none; }
.hs::-webkit-scrollbar { display: none; }

/* ---------- Header (desktop glass, search suggestions) ---------- */
.navl:hover { color: var(--primary-700) !important; }
.sinput::placeholder { color: var(--subtle); }
.iconbtn:hover { border-color: var(--primary) !important; color: var(--primary-700) !important; }
.pgbtn:hover { border-color: var(--primary) !important; color: var(--primary-700) !important; background: #FFFFFF !important; }
.btnp:hover { background: var(--primary-700) !important; color: #FFFFFF; }
.btnw:hover { border-color: var(--primary) !important; color: var(--primary-700) !important; }
.chip:hover { border-color: var(--primary) !important; color: var(--primary-700) !important; }
.row:hover { background: #F5F9FE; }
.row:hover .ut { color: var(--primary-700) !important; }
.srow[aria-selected="true"] { background: #F5F9FE; }

/* ---------- Footer ---------- */
/* Below the xl container step the header has 976px: tighter menu so the search keeps some room. */
@media (max-width: 1279px) { .mainnav { gap: 18px !important; } }

.foot a { color: var(--ink-2); }
.foot a:hover { color: var(--primary-700); }

/* ---------- Hero (home, desktop): fanned back covers ---------- */
.hback img { transition: opacity .2s ease, transform .25s ease; }
.hback:hover img, .hback:focus-visible img { opacity: 1 !important; transform: translateY(-6px); }
.hfade { transition: opacity .25s ease; }

/* Home hero autoplay: the active pagination segment fills over the interval and its animationend
   advances the pick. Reduced motion removes the animation, which also turns autoplay off. */
@keyframes hero-fill { from { transform: scaleX(0); } to { transform: scaleX(1); } }
.seg-fill { position: absolute; inset: 0; border-radius: inherit; background: var(--primary); transform-origin: left; animation: hero-fill 6s linear forwards; }
.is-paused .seg-fill { animation-play-state: paused; }

/* ---------- Card v3: frameless; a white plate shows on hover/focus ---------- */
.cvr { transition: transform .25s ease, box-shadow .25s ease; }
.card:hover .cvr, .card:focus-visible .cvr { box-shadow: 0 18px 34px -18px rgba(10,48,96,.5) !important; }
.cvi { transition: transform .5s ease; }
.card:hover .cvi, .card:focus-visible .cvi { transform: scale(1.06); }
.card:hover .card-t, .card:focus-visible .card-t { color: var(--primary-700); }
/* !important: the plate carries the boards' inline `opacity: 0`, which would otherwise win. */
.card:hover .cplate, .card:focus-visible .cplate { opacity: 1 !important; }
.card:focus-visible { outline: none; }
.card:focus-visible .cplate { box-shadow: 0 0 0 2px var(--primary), 0 16px 34px -20px rgba(10,30,60,.35) !important; }
/* Off-ratio cover (width/height > 0.8): whole image on its own blurred copy, still 2:3. */
.cover-wide { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; filter: blur(16px) saturate(1.2); transform: scale(1.25); }
.cvi.is-wide { object-fit: contain !important; }

/* ---------- Home "Đọc tiếp": tickets tinted by their own cover; the cover breaks out of the top edge ---------- */
.ctile { position: relative; isolation: isolate; display: grid; grid-template-columns: 76px minmax(0, 1fr) auto; gap: 16px; align-items: center; padding: 14px 16px 14px 14px; border-radius: 18px; color: var(--ink); }
.ctile:hover, .ctile:focus-visible { color: var(--ink); }
.ctile:focus-visible { outline: 2px solid var(--primary); outline-offset: 3px; }
.ctile-bg { position: absolute; inset: 0; z-index: -1; border-radius: inherit; overflow: hidden; background: #EEF3F9; box-shadow: inset 0 0 0 1px rgba(255,255,255,.7), 0 14px 28px -22px rgba(10,30,60,.5); transition: box-shadow .25s ease; }
.ctile-bg img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; filter: blur(24px) saturate(1.8); transform: scale(1.5); opacity: .6; }
.ctile-bg .veil { position: absolute; inset: 0; background: linear-gradient(100deg, rgba(255,255,255,.3) 0%, rgba(255,255,255,.8) 42%, rgba(255,255,255,.92) 100%); }
.ctile:hover .ctile-bg, .ctile:focus-visible .ctile-bg { box-shadow: inset 0 0 0 1px rgba(255,255,255,.7), 0 22px 36px -22px rgba(10,48,96,.6); }
.ctile-cover { align-self: end; width: 76px; aspect-ratio: 2 / 3; margin-top: -44px; border-radius: 10px; overflow: hidden; background: #E5EAF1; box-shadow: 0 0 0 3px #FFFFFF, 0 18px 26px -14px rgba(10,30,60,.6); transform: rotate(-6deg); transform-origin: 30% 100%; transition: transform .3s ease; }
.ctile-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ctile:hover .ctile-cover, .ctile:focus-visible .ctile-cover { transform: rotate(0deg) translateY(-6px); }
.ctile-body { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.ctile-kicker { font-size: 10.5px; font-weight: 700; letter-spacing: 1.1px; text-transform: uppercase; color: #0668C4; }
.ctile-title { font-size: 15px; font-weight: 700; line-height: 1.3; transition: color .2s ease; }
.ctile:hover .ctile-title, .ctile:focus-visible .ctile-title { color: var(--primary-700); }
.ctile-meta { font-size: 12.5px; color: var(--muted); }
.ctile-meta b { color: var(--ink); }
.ctile-ago { display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; color: var(--muted); }
/* Progress ring (conic) with the percentage; becomes a play button on hover/focus. */
.ring { position: relative; width: 50px; height: 50px; flex-shrink: 0; border-radius: 999px; display: grid; place-items: center; background: conic-gradient(var(--primary) calc(var(--p) * 1%), rgba(10,132,241,.16) 0); }
.ring::before { content: ""; position: absolute; inset: 4px; border-radius: 999px; background: #FFFFFF; }
.ring-pct, .ring-play { position: relative; grid-area: 1 / 1; transition: opacity .2s ease, transform .2s ease; }
.ring-pct { font-size: 12.5px; font-weight: 800; color: var(--ink); font-variant-numeric: tabular-nums; }
.ring-play { width: 36px; height: 36px; border-radius: 999px; background: var(--primary-600); color: #FFFFFF; display: flex; align-items: center; justify-content: center; opacity: 0; transform: scale(.6); box-shadow: 0 10px 18px -8px rgba(10,132,241,.8); }
.ctile:hover .ring-pct, .ctile:focus-visible .ring-pct { opacity: 0; }
.ctile:hover .ring-play, .ctile:focus-visible .ring-play { opacity: 1; transform: none; }
/* Mobile: a swipeable row of tickets. */
.ctile-m { flex: 0 0 84%; scroll-snap-align: start; grid-template-columns: 64px minmax(0, 1fr) auto; gap: 12px; padding: 12px 14px 12px 12px; }
.ctile-m .ctile-cover { width: 64px; margin-top: -38px; }
.ctile-m .ctile-title { font-size: 14.5px; }
.ctile-m .ring { width: 46px; height: 46px; }
/* Below the xl container step (976px of content) the three tickets become a swipeable row instead of squeezing. */
@media (max-width: 1279px) {
  .cgrid { display: flex !important; overflow-x: auto; scroll-snap-type: x mandatory; scroll-padding: 0 24px; margin: 0 -24px; padding: 34px 24px 6px !important; }
  .cgrid .ctile { flex: 0 0 340px; scroll-snap-align: start; }
}

/* ---------- Home "Mới cập nhật": timeline (time · dot on a rail · cover · title · chapter) ---------- */
.tl { position: relative; }
.tl::before { content: ""; position: absolute; left: var(--tl-rail, 83px); top: 18px; bottom: 18px; width: 2px; border-radius: 2px; background: linear-gradient(#BFE6D6, #E5EAF1 30%, #EEF2F7); }
.tl-row { position: relative; display: grid; grid-template-columns: 56px 16px 36px minmax(0, 1fr) auto; align-items: center; gap: 0 12px; padding: 5px 8px; border-radius: 12px; color: var(--ink); }
.tl-time { text-align: right; font-size: 12px; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.tl-dot { position: relative; z-index: 1; justify-self: center; width: 10px; height: 10px; border-radius: 999px; background: #FFFFFF; box-shadow: 0 0 0 2px #CBD5E1; }
.is-fresh .tl-dot { background: #047857; box-shadow: 0 0 0 3px rgba(4,120,87,.18); }
.is-fresh .tl-dot::after { content: ""; position: absolute; inset: -3px; border-radius: 999px; border: 2px solid rgba(4,120,87,.45); animation: tl-pulse 1.8s ease-out infinite; }
@keyframes tl-pulse { from { transform: scale(.8); opacity: 1; } to { transform: scale(2.1); opacity: 0; } }
.is-fresh .tl-time { color: #047857; font-weight: 700; }
.tl-thumb { position: relative; display: block; width: 36px; aspect-ratio: 2 / 3; border-radius: 6px; overflow: hidden; background: #E5EAF1; box-shadow: 0 6px 12px -8px rgba(10,30,60,.5); }
.tl-body { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.tl-head { display: flex; align-items: center; gap: 8px; min-width: 0; }
.tl-title { font-size: 14.5px; font-weight: 600; color: var(--ink); }
.tl-sub { font-size: 12.5px; color: var(--muted); }
.tl-ch { display: inline-flex; align-items: center; gap: 2px; font-size: 13.5px; font-weight: 700; color: #0668C4; white-space: nowrap; }
.tl-ch svg { opacity: 0; transform: translateX(-4px); transition: opacity .2s ease, transform .2s ease; }
.tl-row:hover .tl-ch svg { opacity: 1; transform: none; }
/* Mobile: dot · cover · title · chapter over time. */
.tl-m { --tl-rail: 12px; }
.tl-m .tl-row { grid-template-columns: 14px 36px minmax(0, 1fr) auto; gap: 0 12px; padding: 6px; }
.tl-m .tl-title { font-size: 14px; }
.tl-m .tl-sub { font-size: 12px; }
.tl-end { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.tl-m .tl-ch { font-size: 12.5px; }
.tl-m .tl-time { font-size: 11px; }

/* ---------- Home "Truyện chữ nổi bật": bookshelf cards with a 3D book cover ---------- */
.nbook { position: relative; display: grid; grid-template-columns: 84px minmax(0, 1fr); gap: 18px; align-items: center; padding: 16px 18px 16px 20px; border-radius: 20px; background: #FFFFFF; box-shadow: 0 6px 18px -12px rgba(10,30,60,.25); color: var(--ink); transition: transform .25s ease, box-shadow .25s ease; }
.nbook:hover, .nbook:focus-visible { color: var(--ink); transform: translateY(-3px); box-shadow: 0 24px 40px -24px rgba(10,48,96,.45); }
.nbook:focus-visible { outline: 2px solid var(--primary); outline-offset: 3px; }
.nbook-cover { position: relative; display: block; width: 84px; aspect-ratio: 2 / 3; perspective: 520px; }
.nbook-cover .b { position: absolute; inset: 0; border-radius: 3px 8px 8px 3px; overflow: hidden; background: #E5EAF1; transform: rotateY(-24deg); transform-origin: left center; box-shadow: 12px 14px 20px -12px rgba(10,30,60,.55), inset -1px 0 0 rgba(255,255,255,.25); transition: transform .4s ease; }
/* Spine: darker fold at the left edge, a soft highlight just after it. */
.nbook-cover .b::before { content: ""; position: absolute; z-index: 1; left: 0; top: 0; bottom: 0; width: 12px; background: linear-gradient(90deg, rgba(0,0,0,.38), rgba(255,255,255,.22) 55%, rgba(255,255,255,0)); }
.nbook:hover .nbook-cover .b, .nbook:focus-visible .nbook-cover .b { transform: rotateY(0deg); }
.nbook-body { display: flex; flex-direction: column; align-items: flex-start; gap: 5px; min-width: 0; }
.nbook-body > * { max-width: 100%; }
.nbook-title { font-size: 16px; font-weight: 800; letter-spacing: -0.2px; transition: color .2s ease; }
.nbook:hover .nbook-title, .nbook:focus-visible .nbook-title { color: var(--primary-700); }
.nbook-sub { font-size: 12.5px; color: var(--muted); }
.nbook-stats { margin-top: 3px; display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 12.5px; color: var(--muted); }
.nbook-stats b { color: var(--ink-2); }
.nbook-star { display: inline-flex; align-items: center; gap: 3px; font-weight: 700; color: var(--ink); }
.nbook-m { grid-template-columns: 68px minmax(0, 1fr); gap: 14px; padding: 12px 14px 12px 16px; border-radius: 18px; }
.nbook-m .nbook-cover { width: 68px; }
.nbook-m .nbook-title { font-size: 15px; }
.nbook-m .nbook-sub, .nbook-m .nbook-stats { font-size: 12px; }

/* Ranking podium */
.podi { transition: transform .5s ease; }
.pod:hover .podi, .pod:focus-visible .podi { transform: scale(1.06); }
.pod:hover .clamp2 { color: var(--primary-700); }

/* Genre tiles */
.gtile { transition: transform .25s ease, box-shadow .25s ease; }
.gtile:hover { transform: translateY(-4px); box-shadow: 0 18px 32px -18px rgba(11,21,35,.6); }
.gimg { transition: transform .5s ease; }
.gtile:hover .gimg { transform: rotate(6deg) translateY(-8px) !important; }

/* ---------- Responsive overrides of the desktop board (design breakpoints) ---------- */
@media (max-width: 1100px) {
  .gc { grid-template-columns: repeat(4, minmax(0, 1fr)) !important; }
  .g4m { grid-template-columns: repeat(4, minmax(0, 1fr)) !important; }
  .g5 { grid-template-columns: repeat(4, minmax(0, 1fr)) !important; }
  .g6 { grid-template-columns: repeat(3, minmax(0, 1fr)) !important; }
}
/* The header ☰ menu only exists where the text menu is hidden. */
.show-md { display: none !important; }

@media (max-width: 1023px) {
  .hide-md { display: none !important; }
  .show-md { display: block !important; }
  .stack-md { grid-template-columns: minmax(0, 1fr) !important; }
  .g5 { grid-template-columns: repeat(3, minmax(0, 1fr)) !important; }
  .g3 { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
  /* Home hero stays side by side down to 768px: a smaller cover stage and title instead of stacking. */
  .hero-grid { gap: 32px !important; min-height: 420px !important; }
  .hero-grid .hero-t { font-size: 40px !important; letter-spacing: -1.2px !important; }
  .hero-grid .hstage { width: 300px !important; height: 380px !important; }
  .hero-grid .hfront img { max-width: 220px !important; max-height: 330px !important; }
  .hero-grid .hback { top: 80px !important; }
  .hero-grid .hback:first-child { left: -6px !important; }
  .hero-grid .hback:nth-child(2) { right: -6px !important; }
  .hero-grid .hback img { width: 132px !important; max-height: 198px !important; }
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
  .hstage { margin: 0 auto; }
}

/* ---------- Mobile hero cover: own-color glow, no white frame ---------- */
.mcov { position: relative; display: block; width: fit-content; margin: 0 auto; isolation: isolate; }
.mcov .glow { position: absolute; left: 6%; top: 16%; width: 88%; height: 90%; object-fit: cover; filter: blur(26px) saturate(1.8); opacity: .8; z-index: -1; border-radius: 22px; }
.mcov .main { display: block; width: auto; height: auto; max-width: 200px; max-height: 300px; border-radius: 16px; box-shadow: 0 1px 2px rgba(10,30,60,.16), 0 18px 32px -16px rgba(10,30,60,.45); }
.mcov .edge { position: absolute; inset: 0; border-radius: 16px; pointer-events: none; box-shadow: inset 0 0 0 1px rgba(255,255,255,.22), inset 0 1px 0 rgba(255,255,255,.4); }
.peek img { transition: opacity .25s ease; }
.peek:active img { opacity: .9 !important; }
.grain {
  position: absolute; inset: 0; pointer-events: none; opacity: .07; mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ---------- Mobile bottom bars ---------- */
.tabbar { padding-bottom: calc(8px + env(safe-area-inset-bottom)) !important; height: calc(72px + env(safe-area-inset-bottom)) !important; }
.bar-swap { transition: transform .2s ease, opacity .2s ease; }
.bar-swap.is-out { transform: translateY(100%); opacity: 0; pointer-events: none; }

/* ---------- Overlays: bottom sheet (mobile) and side drawer ---------- */
.overlay { position: fixed; inset: 0; z-index: 60; display: flex; visibility: hidden; pointer-events: none; transition: visibility 0s linear .28s; }
.overlay.is-open { visibility: visible; pointer-events: auto; transition: none; }
.overlay > .scrim { position: absolute; inset: 0; border: 0; padding: 0; background: rgba(15,23,42,.28); opacity: 0; transition: opacity .25s ease; }
.overlay.is-open > .scrim { opacity: 1; }
.overlay > .sheet { position: absolute; left: 0; right: 0; bottom: 0; max-height: 85vh; transform: translateY(100%); transition: transform .28s cubic-bezier(.2,.8,.2,1); }
.overlay > .drawer { position: absolute; top: 0; right: 0; bottom: 0; transform: translateX(100%); transition: transform .28s cubic-bezier(.2,.8,.2,1); }
.overlay.is-open > .sheet, .overlay.is-open > .drawer { transform: none; }
body.is-locked { overflow: hidden; }
[role="dialog"]:focus { outline: none; }

/* Skeleton shimmer (States) */
@keyframes shimmer { 0% { background-position: -400px 0; } 100% { background-position: 400px 0; } }
.sk { background: linear-gradient(90deg, #EEF2F7 0px, #F7F9FC 160px, #EEF2F7 320px); background-size: 800px 100%; animation: shimmer 1.4s linear infinite; }

/* Toast */
.toast { position: fixed; left: 50%; bottom: 96px; z-index: 80; transform: translate(-50%, 8px); opacity: 0; pointer-events: none; padding: 10px 16px; border-radius: 999px; background: #172033; color: #FFFFFF; font-size: 13.5px; font-weight: 600; box-shadow: 0 16px 32px -16px rgba(10,30,60,.6); transition: opacity .2s ease, transform .2s ease; white-space: nowrap; max-width: calc(100vw - 32px); box-sizing: border-box; overflow: hidden; text-overflow: ellipsis; }
.toast.is-on { opacity: 1; transform: translate(-50%, 0); }
.toast.has-action { pointer-events: auto; display: flex; align-items: center; gap: 14px; padding: 8px 8px 8px 16px; }
.toast-act { flex-shrink: 0; height: 30px; padding: 0 12px; border: 0; border-radius: 999px; background: rgba(255,255,255,.14); color: #8CC8FF; font: inherit; font-size: 13px; font-weight: 700; cursor: pointer; }
.toast-act:hover { background: rgba(255,255,255,.24); }
@media (min-width: 768px) { .toast { bottom: 32px; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0s !important; transition-delay: 0s !important; animation: none !important; scroll-behavior: auto !important; }
}
