/* PT Timeline — client milestone story
   ธีมมืด media-forward + timeline rail/node · on-brand Obsidian/Brass/Ivory · mobile-first */

:root {
  --obsidian: #16171a;
  --obsidian-2: #1f2124;
  --card: #26282c;
  --ivory: #fbfaf2;
  --ivory-dim: #d3d1c6;      /* body รอง — contrast สูงพอบนพื้นมืด */
  --ivory-mute: #9d9c93;     /* label เล็ก */
  --brass: #dcc563;
  --brass-deep: #b79a34;
  --brass-glow: rgba(220, 197, 99, 0.35);
  --rail-line: rgba(220, 197, 99, 0.22);
  --line: rgba(251, 250, 242, 0.10);
  --radius: 22px;
  --maxw: 600px;
  --rail-x: 24px;            /* ตำแหน่งเส้น rail จากขอบซ้าย */
  --pad-x: 48px;             /* padding ซ้ายของ slide (node = pad-x - 24 = rail-x) */
  --ff-sans: "Noto Sans Thai", system-ui, -apple-system, "Segoe UI", sans-serif;
  --ff-serif: "Trirong", "Noto Serif Thai", Georgia, serif;
  --ease: cubic-bezier(0.16, 1, 0.3, 1); /* ease-out-expo */
  --z-dots: 30; --z-bar: 50; --z-state: 60;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  background: var(--obsidian);
  color: var(--ivory);
  font-family: var(--ff-sans);
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
  overscroll-behavior: none;
}
img { max-width: 100%; display: block; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--brass); outline-offset: 3px; border-radius: 4px; }

/* ── progress bar ─────────────────────────────────────────── */
.progressbar { position: fixed; top: 0; left: 0; right: 0; height: 3px; background: var(--line); z-index: var(--z-bar); }
.progressbar span {
  display: block; height: 100%; width: 100%; transform: scaleX(0); transform-origin: left center;
  background: linear-gradient(90deg, var(--brass-deep), var(--brass));
  transition: transform .35s var(--ease);
}

/* ── state screen ─────────────────────────────────────────── */
.state { position: fixed; inset: 0; display: grid; place-items: center; background: var(--obsidian); z-index: var(--z-state); padding: 28px; }
.state-inner { text-align: center; max-width: 340px; }
.spinner { width: 40px; height: 40px; margin: 0 auto 22px; border: 3px solid var(--line); border-top-color: var(--brass); border-radius: 50%; animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.state-msg { color: var(--ivory-dim); font-size: 15.5px; line-height: 1.7; margin: 0; }
.retry { margin-top: 20px; background: var(--brass); color: #1a1a1a; border: 0; border-radius: 999px; padding: 12px 28px; font-family: var(--ff-sans); font-weight: 600; font-size: 15px; cursor: pointer; transition: transform .15s var(--ease), filter .15s; }
.retry:hover { filter: brightness(1.06); } .retry:active { transform: scale(.97); }

/* ── deck / slides ────────────────────────────────────────── */
.deck { height: 100vh; height: 100dvh; overflow-y: scroll; scroll-snap-type: y mandatory; scroll-behavior: smooth; -webkit-overflow-scrolling: touch; }
.slide {
  position: relative; min-height: 100vh; min-height: 100dvh;
  scroll-snap-align: start; scroll-snap-stop: always;
  display: flex; flex-direction: column; justify-content: center;
  padding: calc(env(safe-area-inset-top) + 56px) 24px calc(env(safe-area-inset-bottom) + 88px) var(--pad-x); /* ล่างเผื่อป้าย Netlify */
  overflow: hidden;
}
.slide-body { width: 100%; max-width: var(--maxw); }

/* rail: เส้น timeline แนวตั้งเต็มความสูง slide (ต่อเนื่องข้าม slide) */
.slide--ms::before {
  content: ""; position: absolute; left: var(--rail-x); top: 0; bottom: 0; width: 2px;
  background: var(--rail-line);
  transform: scaleY(0); transform-origin: top center;
}
.has-js .slide--ms.in::before { transform: scaleY(1); transition: transform 1s var(--ease); }
:root .slide--ms::before { transform: scaleY(1); } /* fallback ถ้าไม่มี js/บล็อก in */
.has-js .slide--ms::before { transform: scaleY(0); }

/* ── milestone content ────────────────────────────────────── */
.ms-kicker {
  position: relative; display: inline-flex; align-items: center; gap: 12px;
  color: var(--brass); font-weight: 600; font-size: 14px; letter-spacing: 0; /* ห้าม track ภาษาไทย: วรรณยุกต์หลุดบน iOS */
  margin-bottom: 18px;
}
.ms-kicker::before { /* node บน rail */
  content: ""; position: absolute; left: -24px; top: 50%; transform: translate(-50%, -50%);
  width: 13px; height: 13px; border-radius: 50%;
  background: var(--obsidian); border: 2px solid var(--brass);
  box-shadow: 0 0 0 5px var(--obsidian), 0 0 18px var(--brass-glow);
}
.ms-step { font-variant-numeric: tabular-nums; }
.ms-dot { width: 3px; height: 3px; border-radius: 50%; background: var(--brass); opacity: .6; }
.ms-date { color: var(--ivory-mute); letter-spacing: 0; font-weight: 500; }
.ms-title {
  font-family: var(--ff-serif); font-weight: 600;
  font-size: clamp(28px, 7.6vw, 42px); line-height: 1.25; margin: 0; letter-spacing: -0.005em;
  text-wrap: balance;
}
.ms-detail { color: var(--ivory-dim); font-size: 16.5px; line-height: 1.78; margin: 16px 0 0; max-width: 42ch; white-space: pre-wrap; text-wrap: pretty; }

/* media */
.ms-media { margin-top: 24px; }
.media-single, .media-item {
  position: relative; border-radius: var(--radius); overflow: hidden;
  background: var(--obsidian-2); box-shadow: 0 20px 46px rgba(0,0,0,.45);
}
.media-single::after, .media-item::after { /* scrim ล่างบางๆ ให้ภาพจม */
  content: ""; position: absolute; inset: auto 0 0 0; height: 34%;
  background: linear-gradient(to top, rgba(0,0,0,.32), transparent); pointer-events: none;
}
.media-single img, .media-item img { width: 100%; max-height: 54vh; object-fit: cover; }
.media-strip { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 8px; scroll-snap-type: x mandatory; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
.media-strip::-webkit-scrollbar { display: none; }
.media-strip .media-item { flex: 0 0 80%; scroll-snap-align: center; }
.media-strip .media-item img { max-height: 46vh; }
.media-video { position: relative; width: 100%; aspect-ratio: 16 / 9; border-radius: var(--radius); overflow: hidden; background: #000; box-shadow: 0 20px 46px rgba(0,0,0,.45); }
.media-video iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.media-count { margin-top: 11px; color: var(--ivory-mute); font-size: 12.5px; letter-spacing: 0; display: flex; align-items: center; gap: 7px; }
.media-count::before { content: ""; width: 16px; height: 1px; background: var(--ivory-mute); opacity: .5; }

/* ── intro ────────────────────────────────────────────────── */
.slide--intro { justify-content: center; text-align: center; align-items: center; padding-left: 24px; }
.slide--intro .slide-body { max-width: 34ch; }
.intro-mark { color: var(--brass); font-size: 14px; letter-spacing: 0; margin-bottom: 30px; font-weight: 600; }
.intro-hi { color: var(--ivory-dim); font-size: 17px; margin: 0 0 10px; }
.intro-name { font-family: var(--ff-serif); font-weight: 700; font-size: clamp(40px, 13vw, 68px); line-height: 1.06; margin: 0; color: var(--ivory); letter-spacing: -0.02em; text-wrap: balance; }
.intro-sub { color: var(--ivory-dim); font-size: 16px; line-height: 1.75; margin: 22px auto 0; }
.intro-chip { display: inline-flex; align-items: baseline; gap: 8px; margin-top: 30px; padding: 10px 20px; border: 1px solid var(--brass); border-radius: 999px; color: var(--brass); }
.intro-chip b { font-size: 21px; font-weight: 700; font-variant-numeric: tabular-nums; }
.intro-chip span { font-size: 13px; }
.scroll-hint { position: absolute; left: 0; right: 0; bottom: calc(env(safe-area-inset-bottom) + 96px); text-align: center; color: var(--ivory-mute); font-size: 13px; letter-spacing: 0; } /* ยกพ้นป้าย Netlify มุมล่าง */
.scroll-hint .chev { display: block; margin: 10px auto 0; width: 11px; height: 11px; border-right: 2px solid var(--brass); border-bottom: 2px solid var(--brass); transform: rotate(45deg); animation: bob 1.6s ease-in-out infinite; }
@keyframes bob { 0%,100% { transform: translateY(0) rotate(45deg); } 50% { transform: translateY(7px) rotate(45deg); } }

/* ── outro ────────────────────────────────────────────────── */
.slide--outro { justify-content: center; text-align: center; align-items: center; padding-left: 24px; }
.slide--outro .slide-body { max-width: 32ch; }
.outro-badge { width: 84px; height: 84px; margin: 0 auto 22px; }
.outro-badge svg { width: 100%; height: 100%; overflow: visible; }
.ob-track { fill: rgba(220, 197, 99, .06); stroke: var(--line); stroke-width: 2; }
.ob-ring { fill: none; stroke: var(--brass); stroke-width: 2.5; stroke-linecap: round; transform: rotate(-90deg); transform-origin: 38px 38px; filter: drop-shadow(0 0 8px var(--brass-glow)); }
.ob-cup path { fill: none; stroke: var(--brass); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
/* วงแหวนวาดรอบตัวเอง แล้วเรืองหนึ่งจังหวะ */
.has-js .slide--outro .ob-ring { stroke-dasharray: 1; stroke-dashoffset: 1; }
.has-js .slide--outro.in .ob-ring { stroke-dashoffset: 0; transition: stroke-dashoffset 1.2s var(--ease) .2s; }
.has-js .slide--outro.in .outro-badge svg { animation: badge-glow 1.6s var(--ease) 1.2s 1 both; }
@keyframes badge-glow { 0% { filter: none; } 40% { filter: drop-shadow(0 0 22px var(--brass-glow)); } 100% { filter: drop-shadow(0 0 6px rgba(220,197,99,.15)); } }
.outro-recap { list-style: none; margin: 26px auto 0; padding: 16px 0; display: flex; justify-content: center; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.outro-recap li { flex: 1 1 0; min-width: 0; padding: 0 10px; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.outro-recap li + li { border-left: 1px solid var(--line); }
.outro-recap b { font-family: var(--ff-serif); font-weight: 600; font-size: clamp(26px, 7.4vw, 36px); line-height: 1; color: var(--brass); font-variant-numeric: tabular-nums; }
.outro-recap li > span { color: var(--ivory-mute); font-size: 12.5px; line-height: 1.4; }
.outro-title { font-family: var(--ff-serif); font-weight: 700; font-size: clamp(30px, 9vw, 46px); margin: 0; line-height: 1.2; text-wrap: balance; }
.outro-sub { color: var(--ivory-dim); font-size: 16.5px; line-height: 1.75; margin: 18px auto 0; }
.outro-brand { margin-top: 42px; padding-top: 22px; border-top: 1px solid var(--line); color: var(--ivory-mute); font-size: 13px; letter-spacing: 0; }
.outro-brand b { color: var(--brass); font-weight: 600; }

/* ── dots ─────────────────────────────────────────────────── */
.dots { position: fixed; right: 6px; top: 50%; transform: translateY(-50%); display: flex; flex-direction: column; gap: 2px; z-index: var(--z-dots); }
.dots button { width: 24px; height: 24px; padding: 0; border: 0; background: none; cursor: pointer; display: grid; place-items: center; }
.dots button::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--line); transition: all .25s var(--ease); }
.dots button:hover::before { background: var(--ivory-mute); }
.dots button.active::before { background: var(--brass); box-shadow: 0 0 10px var(--brass-glow); transform: scale(1.5); }

/* ── entrance motion ──────────────────────────────────────── */
.has-js .anim { opacity: 0; transform: translateY(20px); }
.has-js .slide.in .anim { opacity: 1; transform: none; transition: opacity .7s var(--ease), transform .7s var(--ease); }
.has-js .slide.in .anim:nth-child(1) { transition-delay: .08s; }
.has-js .slide.in .anim:nth-child(2) { transition-delay: .16s; }
.has-js .slide.in .anim:nth-child(3) { transition-delay: .26s; }
.has-js .slide.in .anim:nth-child(4) { transition-delay: .36s; }

/* ── heatmap ความสม่ำเสมอ ─────────────────────────────────── */
.slide--heat { --cell: 16px; --gap: 4px; }
.heat-kicker { color: var(--brass); font-weight: 600; font-size: 14px; letter-spacing: 0; margin-bottom: 18px; }
.nw { white-space: nowrap; }
/* ตัวเลขสรุป: เรียงในบรรทัดเดียว คั่นเส้นบาง (ไม่ใช้การ์ด 3 ใบ) */
.heat-stats { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); margin: 30px 0 0; padding: 18px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.heat-stats div { min-width: 0; padding: 0 14px; display: flex; flex-direction: column-reverse; justify-content: flex-end; }
.heat-stats div:first-child { padding-left: 0; }
.heat-stats div + div { border-left: 1px solid var(--line); }
.heat-stats dt { color: var(--ivory-mute); font-size: 12.5px; line-height: 1.4; }
.heat-stats dd { margin: 0 0 8px; font-family: var(--ff-serif); font-weight: 600; font-size: clamp(30px, 8.4vw, 42px); line-height: 1; color: var(--brass); font-variant-numeric: tabular-nums; }
.heat { margin-top: 26px; }
.heat-body { display: flex; gap: 8px; }
.heat-days { display: grid; grid-template-rows: repeat(7, var(--cell)); gap: var(--gap); padding-top: 21px; flex: none; min-width: 18px; }
.heat-days span { color: var(--ivory-mute); font-size: 10.5px; line-height: var(--cell); }
.heat-scroll { min-width: 0; overflow-x: auto; scrollbar-width: none; padding: 0 5px 4px 0; } /* เผื่อ outline ช่องวันนี้ ไม่ให้โดนตัด */
.heat-scroll::-webkit-scrollbar { display: none; }
.heat-months, .heat-grid { display: grid; grid-auto-flow: column; grid-auto-columns: var(--cell); gap: var(--gap); width: max-content; }
.heat-months { margin-bottom: 7px; height: 14px; }
.heat-months span { color: var(--ivory-mute); font-size: 11px; white-space: nowrap; overflow: visible; }
.heat-col { display: grid; grid-template-rows: repeat(7, var(--cell)); gap: var(--gap); }
.hc { display: block; width: var(--cell); height: var(--cell); border-radius: 4px; background: rgba(251, 250, 242, 0.07); }
.hc--pt { background: var(--brass); box-shadow: 0 0 10px rgba(220, 197, 99, .25); }
.hc--cardio { background: rgba(220, 197, 99, .38); }
.hc--both { background: var(--brass); box-shadow: 0 0 0 2px rgba(220, 197, 99, .45), 0 0 12px var(--brass-glow); }
.hc--out { background: transparent; box-shadow: inset 0 0 0 1px var(--line); }
.hc--today { outline: 1.5px solid var(--ivory); outline-offset: 2px; }
/* แถบ streak ใต้กริด: สัปดาห์ที่ต่อเนื่องอยู่ตอนนี้ */
.heat-band { display: grid; grid-auto-flow: column; grid-auto-columns: var(--cell); gap: var(--gap); width: max-content; margin-top: 10px; }
.heat-band i { height: 3px; border-radius: 3px; }
.heat-band i.on { background: var(--brass); box-shadow: 0 0 8px var(--brass-glow); }
.heat-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 18px; margin-top: 16px; }
.heat-range { color: var(--ivory-dim); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.heat-legend { display: flex; flex-wrap: wrap; gap: 8px 16px; color: var(--ivory-mute); font-size: 12.5px; }
.heat-legend span { display: inline-flex; align-items: center; gap: 7px; }
.heat-legend .hc { --cell: 12px; border-radius: 3px; }
.has-js .slide.in .heat-stats.anim { transition-delay: .36s; }
.has-js .slide.in .heat.anim { transition-delay: .46s; }
/* wave reveal ทีละคอลัมน์ (สัปดาห์) ซ้าย→ขวา แล้ว streak band ลากตาม */
.has-js .slide--heat .heat-col .hc { opacity: 0; transform: scale(.5); }
.has-js .slide--heat.in .heat-col .hc {
  opacity: 1; transform: none;
  transition: opacity .5s var(--ease), transform .6s var(--ease);
  transition-delay: calc(.55s + min(var(--i) * 32ms, 900ms));
}
.has-js .slide--heat .heat-band { transform: scaleX(0); transform-origin: left center; }
.has-js .slide--heat.in .heat-band { transform: none; transition: transform 1.1s var(--ease) 1.1s; }

/* ── น้ำหนัก ──────────────────────────────────────────────── */
.wchart-wrap { margin-top: 26px; }
.wchart { display: block; width: 100%; height: auto; overflow: visible; }
.wc-base { stroke: var(--line); stroke-width: 1; }
.wc-area { fill: rgba(220, 197, 99, 0.10); }
.wc-line { fill: none; stroke: var(--brass); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.wc-dot { fill: var(--obsidian); stroke: var(--brass); stroke-width: 2; }
.wc-dot--now { fill: var(--brass); filter: drop-shadow(0 0 6px var(--brass-glow)); }
.wc-x { fill: var(--ivory-mute); font-family: var(--ff-sans); font-size: 11px; }
/* เส้นลากจากซ้ายไปขวาตอนเข้า slide (pathLength=1) */
.has-js .slide--weight .wc-line { stroke-dasharray: 1; stroke-dashoffset: 1; }
.has-js .slide--weight.in .wc-line { stroke-dashoffset: 0; transition: stroke-dashoffset 1.4s var(--ease) .5s; }
.has-js .slide--weight .wc-area, .has-js .slide--weight .wc-dot { opacity: 0; }
.has-js .slide--weight.in .wc-area, .has-js .slide--weight.in .wc-dot { opacity: 1; transition: opacity .6s var(--ease) 1.3s; }

/* ── ก้าวต่อไป ─────────────────────────────────────────────── */
.next-goals { list-style: none; counter-reset: g; margin: 28px 0 0; padding: 0; display: grid; gap: 14px; }
.next-goals li {
  counter-increment: g; position: relative; padding: 0 0 14px 44px;
  color: var(--ivory); font-size: 17px; line-height: 1.6; border-bottom: 1px solid var(--line);
}
.next-goals li::before {
  content: counter(g); position: absolute; left: 0; top: 0;
  width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center;
  border: 1.5px solid var(--brass); color: var(--brass); font-family: var(--ff-serif); font-weight: 600; font-size: 14px;
}
.next-cta { margin-top: 32px; }
.next-btn {
  display: inline-flex; align-items: center; justify-content: center; min-height: 52px; padding: 0 28px;
  border-radius: 999px; background: var(--brass); color: #1a1a1a; font-weight: 700; font-size: 16px; text-decoration: none;
  box-shadow: 0 10px 30px rgba(220, 197, 99, .22);
  transition: transform .2s var(--ease), box-shadow .2s var(--ease), filter .2s;
}
.next-btn:hover { transform: translateY(-2px); box-shadow: 0 14px 36px rgba(220, 197, 99, .32); filter: brightness(1.05); }
.next-btn:active { transform: scale(.98); }
.slide--next .outro-brand { text-align: left; }

@media (min-width: 760px) {
  .slide--heat { --cell: 22px; --gap: 6px; }
  :root { --pad-x: 88px; --rail-x: 64px; --maxw: 620px; }
  .slide { padding-right: 48px; }
  .slide--intro, .slide--outro { padding-left: 48px; }
  .dots { right: 20px; gap: 4px; }
  .ms-detail, .intro-sub, .outro-sub { font-size: 17px; }
}

/* ══ Photo-immersive style (?style=photo) ══════════════════ */
[data-style="photo"] .progressbar { display: none; }
.storybar { position: fixed; top: 0; left: 0; right: 0; display: flex; gap: 4px; padding: calc(env(safe-area-inset-top) + 11px) 13px 0; z-index: var(--z-bar); }
.storybar i { flex: 1; height: 3px; border-radius: 3px; background: rgba(255,255,255,.28); }
.storybar i.on { background: rgba(255,255,255,.95); }
[data-style="photo"] .dots { display: none; }

[data-style="photo"] .slide--ms { justify-content: flex-end; padding: 0; overflow: hidden; }
[data-style="photo"] .slide--ms::before { display: none; }               /* ไม่มี rail ในโหมด immersive */
.photo-bg { position: absolute; inset: 0; background-size: cover; background-position: center; transform: scale(1.06); }
.has-js .slide--ms.in .photo-bg { transform: scale(1); transition: transform 6s ease-out; } /* ken-burns เบาๆ */
.photo-bg--none { background: radial-gradient(130% 100% at 50% 0%, #2c2f34, var(--obsidian)); }
.photo-bg--video { transform: none; }
.photo-bg--video .media-video { position: absolute; inset: 0; aspect-ratio: auto; border-radius: 0; box-shadow: none; }
.photo-scrim { position: absolute; inset: 0; background: linear-gradient(to top, rgba(0,0,0,.86) 0%, rgba(0,0,0,.42) 34%, rgba(0,0,0,.08) 62%, rgba(0,0,0,.34) 100%); pointer-events: none; }
[data-style="photo"] .photo-body { position: relative; z-index: 2; width: 100%; max-width: 640px; margin: 0; padding: 0 26px calc(env(safe-area-inset-bottom) + 100px); }
[data-style="photo"] .ms-kicker { color: #f4e39a; }
[data-style="photo"] .ms-kicker::before { display: none; }
[data-style="photo"] .ms-date { color: rgba(255,255,255,.72); }
[data-style="photo"] .ms-title { color: #fff; text-shadow: 0 2px 20px rgba(0,0,0,.55); }
[data-style="photo"] .ms-detail { color: rgba(255,255,255,.9); max-width: 46ch; text-shadow: 0 1px 12px rgba(0,0,0,.5); }
[data-style="photo"] .intro-name { text-shadow: 0 2px 24px rgba(0,0,0,.5); }
@media (min-width: 760px) {
  [data-style="photo"] .photo-body { padding-left: 56px; padding-right: 56px; padding-bottom: calc(env(safe-area-inset-bottom) + 76px); }
}
@media (prefers-reduced-motion: reduce) {
  .has-js .slide--ms.in .photo-bg { transform: none !important; transition: none !important; }
}

@media (prefers-reduced-motion: reduce) {
  .has-js .slide--outro .ob-ring { stroke-dasharray: none !important; stroke-dashoffset: 0 !important; transition: none !important; }
  .has-js .slide--outro.in .outro-badge svg { animation: none !important; }
  .has-js .slide--weight .wc-line { stroke-dasharray: none !important; stroke-dashoffset: 0 !important; transition: none !important; }
  .has-js .slide--weight .wc-area, .has-js .slide--weight .wc-dot { opacity: 1 !important; transition: none !important; }
  .has-js .slide--heat .heat-col .hc, .has-js .slide--heat .heat-band { opacity: 1 !important; transform: none !important; transition: none !important; }
  .has-js .anim { opacity: 1 !important; transform: none !important; transition: none !important; }
  .has-js .slide--ms::before, .has-js .slide--ms.in::before { transform: scaleY(1) !important; transition: none !important; }
  .deck { scroll-behavior: auto; }
  .scroll-hint .chev, .spinner { animation: none; }
  .progressbar span { transition: none; }
}
