/* LakornFin — night-blue karaoke screen frame around a calm reading column */
:root {
  --screen: #0c1546;
  --screen-deep: #070d33;
  --screen-line: #26307a;
  --screen-ink: #e9ecff;
  --screen-dim: #aab2e8;
  --outline: #01020d;
  --wipe: #ffd23f;
  --paper: #f8f4ec;
  --paper-2: #efe8db;
  --ink: #15183a;
  --ink-2: #464b74;
  --rule: #e3dac9;
  --link: #2b3aa8;
  --link-hover: #0c1546;
  --display: 'Kanit', 'Sarabun', system-ui, sans-serif;
  --body: 'Sarabun', system-ui, sans-serif;
  --column: 40rem;
  --wide: 68rem;
  --gutter: clamp(1rem, 4vw, 2rem);
  /* subtitle outline: real stroke under the fill + a faint outer ring and drop */
  --sub-stroke: 0.14em;
  --sub-shadow: 0 0 1px var(--screen-line), 0 5px 14px rgb(2 4 20 / 0.6);
}

* , *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scrollbar-color: var(--screen-line) var(--paper-2); }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 1.0625rem/1.8 var(--body);
  text-rendering: optimizeLegibility;
}
::selection { background: var(--wipe); color: var(--screen-deep); }
a { color: var(--link); text-underline-offset: 0.22em; text-decoration-thickness: 1px; }
a:hover { color: var(--link-hover); text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--wipe); outline-offset: 3px; border-radius: 4px; }
img, svg { max-width: 100%; height: auto; }
.skip { position: absolute; left: -999px; top: 0; }
.skip:focus { left: 1rem; top: 1rem; z-index: 10; background: var(--wipe); color: var(--screen-deep); padding: 0.5rem 1rem; }

/* ---------- the screen (frame) ---------- */
.screen {
  background:
    radial-gradient(120% 90% at 50% 0%, #17227060 0%, transparent 60%),
    var(--screen);
  color: var(--screen-ink);
}
.screen a { color: var(--screen-ink); }
.bar {
  max-width: var(--wide);
  margin: 0 auto;
  padding: 0.75rem var(--gutter) 0;
  display: flex;
  align-items: center;
  gap: 1rem;
}
.logo {
  font: 800 1.6rem/1 var(--display);
  color: #fff;
  text-decoration: none;
  -webkit-text-stroke: var(--sub-stroke) var(--outline);
  paint-order: stroke fill;
  text-shadow: var(--sub-shadow);
  letter-spacing: 0;
  padding: 0.2rem 0;
}
.logo:hover { color: #fff; text-decoration: none; }
.logo small {
  display: block;
  font: 600 0.72rem/1.2 var(--display);
  color: var(--screen-dim);
  -webkit-text-stroke: 0;
  text-shadow: none;
  letter-spacing: 0.08em;
  margin-top: 0.2rem;
}
.tabs {
  max-width: var(--wide);
  margin: 0 auto;
  padding: 0 var(--gutter);
  display: flex;
  gap: 1.4rem;
  overflow-x: auto;
  scrollbar-width: none;
  border-bottom: 1px solid var(--screen-line);
  -webkit-mask-image: linear-gradient(90deg, #000 85%, transparent);
  mask-image: linear-gradient(90deg, #000 85%, transparent);
}
.tabs::after { content: ""; flex: none; width: 2rem; }
.tabs::-webkit-scrollbar { display: none; }
.tabs a {
  flex: none;
  font: 600 0.95rem/1 var(--display);
  color: var(--screen-dim);
  text-decoration: none;
  padding: 0.95rem 0 0.8rem;
  border-bottom: 3px solid transparent;
}
.tabs a:hover { color: #fff; }
.tabs a[aria-current="page"] { color: var(--wipe); border-bottom-color: var(--wipe); }

.screen-head {
  max-width: var(--wide);
  margin: 0 auto;
  padding: 1.4rem var(--gutter) 2rem;
}
.crumbs { font: 400 0.85rem/1.4 var(--body); color: var(--screen-dim); margin: 0 0 0.9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crumbs a { color: var(--screen-dim); }
.crumbs span[aria-hidden] { margin: 0 0.4rem; }

/* subtitle titles: white fill, dark outline, one karaoke wipe */
.sub {
  position: relative;
  margin: 0;
  max-width: 22ch;
  font: 800 clamp(1.75rem, 1.1rem + 3.4vw, 3.1rem)/1.32 var(--display);
  color: #fff;
  -webkit-text-stroke: var(--sub-stroke) var(--outline);
  paint-order: stroke fill;
  text-shadow: var(--sub-shadow);
  text-wrap: balance;
}
.sub a, .sub a:hover { color: inherit; text-decoration: none; }
.sub::after {
  content: attr(data-text);
  position: absolute;
  inset: 0;
  color: var(--wipe);
  -webkit-text-stroke: var(--sub-stroke) var(--outline);
  paint-order: stroke fill;
  /* the wipe settles on the first line only: the "current lyric" */
  clip-path: inset(0 100% calc(100% - 1.32em) 0);
  animation: wipe 2.2s cubic-bezier(0.16, 1, 0.3, 1) 0.25s forwards;
  pointer-events: none;
}
@keyframes wipe { to { clip-path: inset(0 0 calc(100% - 1.32em) 0); } }
@media (prefers-reduced-motion: reduce) {
  .sub::after { animation: none; clip-path: inset(0 0 calc(100% - 1.32em) 0); }
}
.screen-dek {
  margin: 1rem 0 0;
  max-width: 38rem;
  color: var(--screen-dim);
  font-size: 1rem;
  line-height: 1.7;
}

/* part markers: which part of the summary you are on */
.parts { display: flex; align-items: center; gap: 0.6rem; margin: 1.2rem 0 0; font: 600 0.9rem/1 var(--display); color: var(--screen-dim); }
.parts ol { display: flex; gap: 0.35rem; list-style: none; margin: 0; padding: 0; }
.parts li a, .parts li span {
  display: grid; place-items: center;
  min-width: 2.25rem; height: 2.25rem; padding: 0 0.5rem;
  border: 1px solid var(--screen-line); border-radius: 6px;
  color: var(--screen-ink); text-decoration: none;
}
.parts li [aria-current="page"] { background: var(--wipe); border-color: var(--wipe); color: var(--screen-deep); }

/* last-read flag */
.flag[hidden] { display: none; }
.flag {
  display: flex; align-items: center; gap: 0.7rem;
  margin: 1.4rem 0 0; padding: 0.75rem 1rem;
  border: 1px solid var(--screen-line); border-radius: 10px;
  background: var(--screen-deep);
  font-size: 0.95rem; line-height: 1.5;
}
.flag svg { flex: none; color: var(--wipe); }
.flag a { font-weight: 600; color: #fff; }
.flag .flag-label { color: var(--wipe); font: 600 0.85rem/1 var(--display); }

/* ---------- reading column ---------- */
main { display: block; }
.column { max-width: var(--column); margin: 0 auto; padding: 0 var(--gutter); }
.byline {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 1.1rem 0; border-bottom: 1px solid var(--rule);
  font-size: 0.92rem; line-height: 1.45; color: var(--ink-2);
}
.byline img { width: 40px; height: 40px; border-radius: 50%; flex: none; }
.byline a { font-weight: 600; color: var(--ink); text-decoration: none; }
.byline a:hover { text-decoration: underline; }
.prose { padding: 1.6rem 0 0.5rem; }
.prose > * { margin-top: 0; margin-bottom: 0; }
.prose > * + * { margin-top: 1.1em; }
.prose h2 {
  font: 600 1.45rem/1.45 var(--display);
  color: var(--ink);
  margin: 2.2em 0 0.55em;
  text-wrap: balance;
}
.prose h3 { font: 600 1.15rem/1.5 var(--display); margin: 1.8em 0 0.4em; }
.prose h2 + *, .prose h3 + * { margin-top: 0; }
.prose ul, .prose ol { padding-left: 1.4rem; }
.prose li + li { margin-top: 0.35em; }
.prose strong { font-weight: 700; }
.prose blockquote {
  margin: 1.6em 0; padding: 0.9rem 1.1rem;
  background: var(--paper-2); border-radius: 10px;
  font-style: italic;
}
.prose figure { margin: 1.8em 0; }
.prose figcaption { font-size: 0.88rem; color: var(--ink-2); margin-top: 0.5rem; line-height: 1.55; }
.prose table { width: 100%; border-collapse: collapse; font-size: 0.95rem; line-height: 1.55; }
.prose th, .prose td { text-align: left; padding: 0.6rem 0.5rem; border-bottom: 1px solid var(--rule); vertical-align: top; }
.prose th { font: 600 0.9rem/1.4 var(--display); color: var(--ink-2); }
.table-wrap { overflow-x: auto; }
.note {
  padding: 1rem 1.15rem; border-radius: 10px;
  background: #fff; border: 1px solid var(--rule);
  font-size: 0.97rem;
}
.note b { font-family: var(--display); font-weight: 600; }

/* numbered tracks: used only where order carries meaning (rankings, steps) */
.tracks, .prose .tracks { list-style: none; padding: 0; margin: 0; counter-reset: track; }
.tracks > li { counter-increment: track; display: grid; grid-template-columns: 3.1rem 1fr; gap: 0 0.9rem; padding: 1.1rem 0; border-bottom: 1px solid var(--rule); }
.tracks > li + li { margin-top: 0; }
.tracks > li::before {
  content: counter(track, decimal-leading-zero);
  grid-row: span 3;
  font: 800 1.7rem/1.1 var(--display);
  color: var(--screen);
  font-variant-numeric: tabular-nums;
}
.tracks h3 { margin: 0; font: 600 1.15rem/1.45 var(--display); }
.tracks p { margin: 0.3rem 0 0; }

/* buttons */
.btn {
  display: inline-flex; align-items: center; gap: 0.5rem;
  padding: 0.85rem 1.3rem; border-radius: 10px;
  background: var(--screen); color: #fff; text-decoration: none;
  font: 600 1rem/1.2 var(--display);
  box-shadow: 0 6px 16px -8px rgb(12 21 70 / 0.6);
  transition: background 160ms ease-out, transform 160ms ease-out;
}
.btn:hover { background: var(--screen-deep); color: #fff; text-decoration: none; transform: translateY(-1px); }
.btn-row { display: flex; flex-wrap: wrap; gap: 0.75rem; margin: 2rem 0 0.5rem; }
.next-part {
  margin: 2.2rem 0 0.5rem; padding: 1.2rem; border-radius: 12px;
  background: var(--screen); color: var(--screen-ink);
}
.next-part p { margin: 0 0 0.8rem; color: var(--screen-dim); font-size: 0.95rem; }
.next-part .btn, .screen .btn-screen { background: var(--screen-ink); color: var(--screen-deep); }
.next-part .btn:hover, .screen .btn-screen:hover { background: #fff; color: var(--screen-deep); }

/* ad slots: reserved only once the ad wrapper is switched on (html.ads-on) */
.ad { display: none; }
html.ads-on .ad {
  display: grid; place-items: center;
  margin: 1.5rem auto; max-width: 100%;
  background: var(--paper-2); border-radius: 6px;
}
html.ads-on .ad-top { min-height: 250px; }
html.ads-on .ad-in { min-height: 280px; }
html.ads-on .ad::before { content: 'โฆษณา'; font-size: 0.7rem; color: var(--ink-2); }

/* related + lists */
.section-title { font: 600 1.3rem/1.4 var(--display); margin: 0 0 0.6rem; }
.related { margin: 2.5rem 0 0; padding: 1.5rem 0 0; border-top: 2px solid var(--ink); }
.entries { list-style: none; margin: 0; padding: 0; }
.entries li { padding: 1rem 0; border-bottom: 1px solid var(--rule); }
.entries a { font: 600 1.08rem/1.5 var(--display); color: var(--ink); text-decoration: none; }
.entries a:hover { color: var(--link); text-decoration: underline; }
.entries p { margin: 0.25rem 0 0; color: var(--ink-2); font-size: 0.95rem; line-height: 1.6; }
.entries .meta { display: block; margin-top: 0.35rem; font-size: 0.82rem; color: var(--ink-2); }
.cat-tag { font: 600 0.8rem/1 var(--display); color: var(--link); }

/* home */
.home-grid { max-width: var(--wide); margin: 0 auto; padding: 1.8rem var(--gutter) 1rem; display: grid; gap: 2.2rem; }
@media (min-width: 900px) {
  .home-grid { grid-template-columns: 1.4fr 1fr; gap: 3rem; align-items: start; }
}
.home-block + .home-block { margin-top: 2.2rem; }
.home-block .more { display: inline-block; margin-top: 0.8rem; font-weight: 600; font-size: 0.95rem; }
.lead-entry { padding: 0 0 1.2rem; border-bottom: 2px solid var(--ink); }
.lead-entry a { font: 600 1.45rem/1.45 var(--display); color: var(--ink); text-decoration: none; }
.lead-entry a:hover { color: var(--link); }
.lead-entry p { margin: 0.5rem 0 0; color: var(--ink-2); }

/* author */
.author-card { display: flex; gap: 1rem; align-items: flex-start; padding: 1.4rem 0; }
.author-card img { width: 88px; height: 88px; border-radius: 50%; flex: none; }

/* footer */
.foot {
  margin-top: 4rem;
  background: var(--screen-deep);
  color: var(--screen-dim);
  font-size: 0.9rem;
  line-height: 1.7;
}
.foot-in { max-width: var(--wide); margin: 0 auto; padding: 2.2rem var(--gutter) 2.5rem; display: grid; gap: 1.4rem; }
@media (min-width: 760px) { .foot-in { grid-template-columns: 1.2fr 1fr 1fr; } }
.foot a { color: var(--screen-ink); }
.foot ul { list-style: none; margin: 0; padding: 0; }
.foot li + li { margin-top: 0.3rem; }
.foot .logo { font-size: 1.3rem; }
.foot h2 { font: 600 0.95rem/1.3 var(--display); color: #fff; margin: 0 0 0.5rem; }
.foot p { margin: 0.6rem 0 0; }

/* 404 */
.lost { max-width: var(--column); margin: 0 auto; padding: 2rem var(--gutter); }
.screen-head.narrow { max-width: var(--column); }

/* home: featured summary + numbered latest list on the screen */
.home-head { display: grid; gap: 1.6rem; }
@media (min-width: 900px) { .home-head { grid-template-columns: 1.2fr 1fr; gap: 3.5rem; align-items: start; } }
.home-head .btn-row { margin: 1.4rem 0 0; }
.screen-list-title { font: 600 1rem/1.3 var(--display); color: var(--screen-dim); margin: 0.2rem 0 0.3rem; }
.screen-list .tracks > li { border-bottom-color: var(--screen-line); padding: 0.8rem 0; grid-template-columns: 2.4rem 1fr; }
.screen-list .tracks > li::before { color: var(--screen-dim); grid-row: span 2; }
.screen-list .tracks a { font: 600 1rem/1.45 var(--display); color: #fff; text-decoration: none; }
.screen-list .tracks a:hover { text-decoration: underline; }
.screen-list .tracks span { font-size: 0.82rem; color: var(--screen-dim); }
.lost .section-title { margin-top: 2.2rem; }
