/* ═══════════════════════════════════════════════════════════════════════════
 * DevProp Academy — agency docs styles
 * Same brand as devprop.io main site (sky #38bdf8, ink #0a0a0f, DM Sans)
 * but optimized for long-form reading (760-840px column, generous line-height).
 * ═══════════════════════════════════════════════════════════════════════════ */

:root {
  --sky:        #38bdf8;
  --sky-2:      #0ea5e9;
  --sky-glow:   rgba(56,189,248,.08);
  --ink:        #0a0a0f;
  --text:       #0f172a;
  --muted:      #64748b;
  --dim:        #94a3b8;
  /* Aligned with devprop.io light theme (--bg: #eef3fa) so guide.devprop.io
     shares the same subtle sky-tinted background — no jarring white screens
     between domains. */
  --bg:         #eef3fa;
  --surface:    #ffffff;
  --card:       #ffffff;
  --border:     #e2e8f0;
  --border-2:   #f1f5f9;
  --code-bg:    #f1f5f9;
  --hl:         rgba(255,221,87,0.4);
  --r-sm: 6px; --r-md: 10px; --r-lg: 16px; --r-xl: 24px;
  --font:    'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
  --font-th: 'Anuphan', 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Monaco, Consolas, monospace;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; font-size: 16px; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-size-adjust: 100%;
  position: relative; /* needed for ::before / ::after backgrounds */
}

/* ── GEOMETRIC BACKGROUND (mirrors devprop.io: subtle sky-tinted grid
      + radial glows for visual continuity across both sites) ─────────── */
body::before {
  content:'';
  position:fixed; inset:0; z-index:0; pointer-events:none;
  background-image:
    linear-gradient(rgba(56,189,248,0.028) 1px, transparent 1px),
    linear-gradient(90deg, rgba(56,189,248,0.028) 1px, transparent 1px);
  background-size: 56px 56px;
  mask-image: radial-gradient(ellipse 90% 80% at 50% 0%, black 20%, transparent 100%);
  -webkit-mask-image: radial-gradient(ellipse 90% 80% at 50% 0%, black 20%, transparent 100%);
}
body::after {
  content:'';
  position:fixed; inset:0; z-index:0; pointer-events:none;
  background:
    radial-gradient(ellipse 60% 40% at 15% 20%, rgba(56,189,248,0.05) 0%, transparent 60%),
    radial-gradient(ellipse 50% 35% at 90% 70%, rgba(56,189,248,0.03) 0%, transparent 60%);
}
/* Make sure all in-flow content sits above the decorative backgrounds. */
body > * { position: relative; z-index: 1; }
[data-lang="th"] body { font-family: var(--font-th); }
[lang="th"] body { font-family: var(--font-th); }

img, svg { max-width: 100%; height: auto; }

/* ── PARENT-SITE CHROME COMPATIBILITY ────────────────────────────────────
 * The Academy uses devprop.io's announce-bar + nav + footer (extracted at
 * build time). The parent CSS sets --announce-h: 38px / --nav-h: 70px so
 * --header-h = 108px on desktop. We use explicit gap (not --page-top-gap)
 * because the parent only defines that variable inside a mobile media
 * query — depending on it on desktop yields invalid calc().
 *
 * !important to defeat any inline padding on academy sections.
 * ──────────────────────────────────────────────────────────────────── */
.hub-hero,
.layout,
.doc-shell {
  padding-top: calc(var(--header-h, 108px) + 30px) !important;
}
@media (max-width: 720px) {
  .hub-hero, .layout, .doc-shell {
    padding-top: calc(var(--header-h, 90px) + 14px) !important;
  }
}

/* The Academy article uses .layout (sidebar + main). Override the sticky
   sidebar offset so it lives below the fixed parent nav, not the legacy
   60px topbar offset. */
.layout > .sidebar { top: calc(var(--header-h, 108px) + 12px) !important; }

/* ── LAYOUT: hub & docs ─────────────────────────────────────────────── */
.layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  min-height: calc(100vh - 60px);
  max-width: 1280px;
  margin: 0 auto;
}
.layout.no-sidebar { grid-template-columns: 1fr; }

.sidebar {
  /* Frosted-glass sky tint instead of pure white. Picks up the page bg
     (#eef3fa) underneath so the rail feels integrated with the global
     style, while a 1px sky-tinted border on the right + the slight
     opacity contrast keep it visually distinct from the article column. */
  background: rgba(255,255,255,.45);
  backdrop-filter: blur(14px) saturate(150%);
  -webkit-backdrop-filter: blur(14px) saturate(150%);
  border-right: 1px solid rgba(56,189,248,.18);
  padding: 28px 18px 24px;
  position: sticky; top: 60px;
  height: calc(100vh - 60px);
  overflow-y: auto;
  /* Flex column so .sidebar-foot can be pushed to the bottom via margin-top:auto */
  display: flex; flex-direction: column;
}
.sidebar-foot {
  margin-top: auto;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}
.sidebar-line-cta {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: var(--r-sm);
  font-size: 14px; font-weight: 600;
  color: #475569; text-decoration: none;
  background: transparent;
  transition: background .15s, color .15s, transform .15s;
}
.sidebar-line-cta:hover {
  background: rgba(6,199,85,.08);
  color: #06c755;
  transform: translateX(2px);
}
.sidebar-line-cta svg { color: #06c755; flex-shrink: 0; }

/* ── BACK-TO-TOP (LINE widget is now provided by extracted parent CSS) ── */

/* Parent-site .back-to-top rules copied verbatim from devprop.io (NOT in
   my extracted chrome slice because they live in the buttons section).
   Same sky-grad circle + Material Symbols arrow used on the main site. */
.back-to-top {
  position:fixed; bottom:30px; left:24px; z-index:1000;
  width:48px; height:48px; border-radius:50%; border:none;
  background:var(--sky-grad, linear-gradient(135deg,#67e8f9 0%,#38bdf8 55%,#818cf8 100%));
  color:#050d1a; cursor:pointer;
  display:none; align-items:center; justify-content:center;
  box-shadow:0 8px 28px rgba(56,189,248,.42);
  opacity:0; transform:translateY(8px);
  transition:transform .25s cubic-bezier(.16,1,.3,1), box-shadow .25s ease, opacity .35s ease;
}
.back-to-top.visible { display:inline-flex; opacity:1; transform:translateY(0); }
.back-to-top:hover { transform:translateY(-3px); box-shadow:0 14px 36px rgba(56,189,248,.6); }
.back-to-top:active { transform:scale(.96); }
.back-to-top:focus-visible { outline:2px solid var(--sky); outline-offset:3px; }
.back-to-top .material-symbols-outlined { font-size:22px; font-variation-settings:'FILL' 1,'wght' 700; }

@media (max-width: 720px) {
  .back-to-top { width: 44px; height: 44px; bottom: 20px; left: 16px; }
}
.sidebar h3 {
  font-size: 11px; font-weight: 800; letter-spacing: .12em;
  text-transform: uppercase; color: var(--muted);
  margin: 18px 8px 8px;
}
.sidebar h3:first-child { margin-top: 0; }
.sidebar-nav { display: flex; flex-direction: column; gap: 2px; }
.sidebar-nav a {
  /* align-items:flex-start + padding-top on the num itself keeps the chip
     pinned to the first line of multi-line titles (Connect LINE Official,
     One-click publish to DDproperty…) so every numbered chip sits in a
     perfectly aligned vertical column down the rail. */
  display: flex; align-items: flex-start; gap: 10px;
  padding: 9px 10px; border-radius: var(--r-sm);
  font-size: 14px; line-height: 1.4;
  color: var(--text); text-decoration: none;
  transition: background .15s, color .15s;
}
.sidebar-nav a:hover { background: var(--sky-glow); color: var(--sky-2); }
.sidebar-nav a.active {
  background: var(--sky-glow); color: var(--sky-2); font-weight: 600;
}
.sidebar-nav a .num {
  /* Fixed-size square chip — flex-shrink:0 stops collapse, min-width handles
     2-digit (10). border + visible bg ensures every chip reads as a chip,
     not a faint label. margin-top nudges to align with first text line. */
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  width: 24px; height: 24px; min-width: 24px;
  border-radius: 6px;
  background: #eaeef5; color: var(--muted);
  border: 1px solid #dbe2ec;
  font-size: 12px; font-weight: 700;
  margin-top: 1px;
}
.sidebar-nav a:hover .num { background: #d9ecfb; color: var(--sky-2); border-color: rgba(56,189,248,.35); }
.sidebar-nav a.active .num {
  background: var(--sky); color: #fff; border-color: var(--sky);
}

@media (max-width: 880px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar {
    position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--border);
    padding: 18px;
  }
}

/* ── MAIN content area ───────────────────────────────────────────────── */
.main {
  padding: 48px 56px;
  max-width: 880px;
  width: 100%;
}
@media (max-width: 880px) { .main { padding: 32px 22px; } }
@media (max-width: 480px) { .main { padding: 24px 16px; } }

/* ── HERO (used on landing page) ────────────────────────────────────── */
.hub-hero {
  padding: 80px 24px 40px;
  text-align: center;
  background: radial-gradient(ellipse 70% 50% at 50% 0%, var(--sky-glow) 0%, transparent 70%);
}
.hub-hero h1 {
  font-size: clamp(32px, 4.5vw, 48px);
  font-weight: 900; letter-spacing: -.03em; line-height: 1.1;
  margin: 18px 0 14px; max-width: 900px; margin-inline: auto;
  text-wrap: balance;
}
.hub-hero h1 em { font-style: normal; color: var(--sky-2); }
.hub-hero .eyebrow {
  display: inline-block; font-size: 11.5px; font-weight: 800;
  text-transform: uppercase; letter-spacing: .14em;
  color: var(--sky-2); background: var(--sky-glow);
  border: 1px solid rgba(56,189,248,.22);
  padding: 6px 14px; border-radius: 999px;
}
.hub-hero .lede {
  font-size: clamp(16px, 1.7vw, 19px); color: var(--muted);
  max-width: 700px; margin: 18px auto 28px; line-height: 1.65;
}
.hub-hero .cta-row {
  display: inline-flex; gap: 12px; flex-wrap: wrap; justify-content: center;
}
.btn-primary, .btn-ghost {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 12px 22px; border-radius: var(--r-sm);
  font-weight: 700; font-size: 14.5px; text-decoration: none;
  transition: all .15s;
}
/* !important defeats parent-site CSS (color:#050d1a on .btn-primary) that
   would otherwise win when the academy ships the same class name. */
.btn-primary {
  background: var(--sky) !important;
  color: #fff !important;
  box-shadow: 0 2px 14px rgba(56,189,248,.32);
}
.btn-primary:hover { background: var(--sky-2) !important; transform: translateY(-1px); }
.btn-ghost { background: #fff; color: var(--ink); border: 1px solid var(--border); }
.btn-ghost:hover { border-color: var(--sky); color: var(--sky-2); }

/* ── HUB grid ────────────────────────────────────────────────────────── */
.hub-section { max-width: 1080px; margin: 0 auto; padding: 32px 24px; }
.hub-section h2 {
  font-size: clamp(22px, 2.6vw, 28px); font-weight: 800;
  letter-spacing: -.02em; margin: 0 0 8px;
}
.hub-section .section-lede { color: var(--muted); margin: 0 0 24px; font-size: 16px; }
.hub-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 14px;
}
.hub-card {
  display: flex; flex-direction: column; gap: 10px;
  padding: 22px;
  background: var(--card); border: 1px solid var(--border); border-radius: var(--r-md);
  text-decoration: none; color: var(--text);
  transition: all .15s;
  position: relative; overflow: hidden;
}
.hub-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: var(--sky); transform: scaleX(0); transform-origin: left;
  transition: transform .25s ease;
}
.hub-card:hover { border-color: var(--sky); transform: translateY(-2px); box-shadow: 0 8px 24px rgba(56,189,248,.10); }
.hub-card:hover::before { transform: scaleX(1); }
.hub-card-eyebrow {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .08em; color: var(--sky-2);
}
.hub-card-title { font-size: 17px; font-weight: 700; color: var(--ink); margin: 0; line-height: 1.3; }
.hub-card-desc { font-size: 14px; color: var(--muted); margin: 0; line-height: 1.55; }
.hub-card-meta {
  margin-top: auto; display: flex; gap: 12px; align-items: center;
  padding-top: 12px; font-size: 12.5px; color: var(--dim);
}

/* ── BREADCRUMB ──────────────────────────────────────────────────────── */
.crumbs {
  margin-bottom: 16px;
  font-size: 13px; color: var(--muted);
  display: flex; gap: 6px; align-items: center; flex-wrap: wrap;
}
.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs a:hover { color: var(--sky-2); }
.crumbs .sep { color: var(--dim); margin: 0 2px; }
.crumbs [aria-current] { color: var(--ink); font-weight: 600; }

/* ── ARTICLE (doc page) — long-form reading ─────────────────────────── */
.doc { max-width: 760px; }
.doc h1 {
  font-size: clamp(28px, 3.6vw, 38px);
  font-weight: 900; letter-spacing: -.024em; line-height: 1.18;
  margin: 4px 0 14px; text-wrap: balance;
}
.doc .doc-meta {
  display: flex; gap: 14px; flex-wrap: wrap; align-items: center;
  color: var(--muted); font-size: 13px;
  margin-bottom: 28px; padding-bottom: 18px;
  border-bottom: 1px solid var(--border);
}
.doc .doc-meta .pill {
  background: var(--sky-glow); color: var(--sky-2); border: 1px solid rgba(56,189,248,.22);
  font-weight: 700; text-transform: uppercase; font-size: 11px; letter-spacing: .08em;
  padding: 3px 10px; border-radius: 999px;
}

.doc h2 {
  font-size: clamp(22px, 2.4vw, 26px);
  font-weight: 800; letter-spacing: -.018em;
  margin: 44px 0 12px; line-height: 1.25;
}
.doc h3 {
  font-size: 18px; font-weight: 700; margin: 30px 0 10px;
}
.doc p { margin: 0 0 16px; font-size: 16.5px; line-height: 1.75; color: var(--text); }
.doc p strong { color: var(--ink); }
.doc ul, .doc ol { margin: 0 0 20px 24px; padding: 0; }
.doc li { margin: 6px 0; line-height: 1.7; font-size: 16px; }
.doc li::marker { color: var(--sky); }

.doc a { color: var(--sky-2); text-decoration: underline; text-decoration-color: rgba(56,189,248,.4); text-underline-offset: 3px; }
.doc a:hover { text-decoration-color: var(--sky-2); }

.doc code {
  font-family: var(--font-mono); font-size: .92em;
  padding: 2px 6px; background: var(--code-bg); border-radius: 4px;
  color: var(--sky-2);
}
.doc pre {
  margin: 18px 0; padding: 18px 20px;
  background: var(--code-bg); border-radius: var(--r-md);
  overflow-x: auto; font-size: 13.5px; line-height: 1.6;
}
.doc pre code { background: transparent; padding: 0; color: var(--text); }

.doc blockquote {
  margin: 22px 0; padding: 16px 22px;
  border-left: 3px solid var(--sky);
  background: var(--sky-glow); border-radius: 0 var(--r-md) var(--r-md) 0;
  color: var(--text); font-size: 15.5px;
}
.doc blockquote p:last-child { margin-bottom: 0; }

.callout {
  margin: 22px 0; padding: 18px 22px;
  background: var(--sky-glow); border: 1px solid rgba(56,189,248,.18);
  border-left: 3px solid var(--sky); border-radius: var(--r-md);
}
.callout strong { color: var(--sky-2); }
.callout.warn { background: rgba(245,158,11,.06); border-color: rgba(245,158,11,.28); border-left-color: #f59e0b; }
.callout.warn strong { color: #b45309; }
.callout.success { background: rgba(34,197,94,.06); border-color: rgba(34,197,94,.28); border-left-color: #22c55e; }
.callout.success strong { color: #15803d; }

.doc table {
  width: 100%; border-collapse: collapse;
  margin: 20px 0; font-size: 14.5px;
}
.doc th, .doc td {
  padding: 10px 14px; text-align: left;
  border-bottom: 1px solid var(--border);
}
.doc th { font-weight: 700; color: var(--ink); background: var(--border-2); font-size: 12px; text-transform: uppercase; letter-spacing: .06em; }
.doc tr:hover td { background: var(--sky-glow); }

.doc img {
  border-radius: var(--r-md); border: 1px solid var(--border);
  margin: 18px 0;
}

.steps { counter-reset: step; margin: 24px 0; padding: 0; list-style: none; }
.steps li {
  counter-increment: step;
  position: relative;
  padding: 16px 0 16px 44px;
  border-bottom: 1px solid var(--border-2);
  line-height: 1.65;
}
/* Counter absolutely positioned so any mix of children (link + text node +
   inline-code, etc.) inside the li flows naturally on one line/wrap as
   normal block text. The previous grid layout (28px 1fr) pushed any 3rd
   child onto a new row in the 28px column, breaking text word-by-word. */
.steps li::before {
  content: counter(step);
  position: absolute; left: 0; top: 14px;
  display: flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: 999px;
  background: var(--sky); color: #fff;
  font-weight: 800; font-size: 13px;
}
.steps li:last-child { border-bottom: 0; }

/* ── ARTICLE NAV (prev/next) ────────────────────────────────────────── */
.doc-nav {
  display: grid; grid-template-columns: 1fr 1fr; gap: 14px;
  margin: 56px 0 0; padding-top: 24px;
  border-top: 1px solid var(--border);
}
@media (max-width: 600px) { .doc-nav { grid-template-columns: 1fr; } }
.doc-nav a {
  display: flex; flex-direction: column; gap: 4px;
  padding: 16px 18px; border: 1px solid var(--border); border-radius: var(--r-md);
  text-decoration: none; color: var(--text);
  transition: all .15s;
}
.doc-nav a:hover { border-color: var(--sky); transform: translateY(-1px); }
.doc-nav .dir { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.doc-nav .title { font-weight: 700; font-size: 15px; color: var(--ink); }
.doc-nav .right { text-align: right; }

/* ── FOOTER ──────────────────────────────────────────────────────────── */
.foot {
  border-top: 1px solid var(--border); padding: 32px 24px; margin-top: 60px;
  background: var(--surface);
}
.foot-inner { max-width: 1200px; margin: 0 auto; display: flex; gap: 24px; justify-content: space-between; align-items: center; flex-wrap: wrap; }
.foot-brand { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13.5px; }
.foot-nav { display: flex; gap: 18px; flex-wrap: wrap; }
.foot-nav a { color: var(--muted); text-decoration: none; font-size: 13.5px; }
.foot-nav a:hover { color: var(--sky-2); }

/* ── A11y ────────────────────────────────────────────────────────────── */
:focus-visible { outline: 2px solid var(--sky); outline-offset: 2px; border-radius: 4px; }
.sr-only {
  position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden;
}

/* ── Install PWA banner (auto-shown on supported browsers) ──────────── */
.pwa-banner {
  position: fixed; bottom: 20px; right: 20px;
  background: var(--ink); color: #fff;
  padding: 14px 20px; border-radius: var(--r-md);
  display: flex; align-items: center; gap: 14px;
  box-shadow: 0 12px 36px rgba(0,0,0,.18);
  z-index: 100;
  font-size: 14px;
  max-width: 360px;
  animation: pwa-slide-in .35s ease-out;
}
.pwa-banner button {
  font-family: inherit; font-weight: 700; font-size: 13px;
  background: var(--sky); color: #fff; border: 0; cursor: pointer;
  padding: 7px 14px; border-radius: var(--r-sm);
  transition: background .15s;
}
.pwa-banner button:hover { background: var(--sky-2); }
.pwa-banner .dismiss { background: transparent; color: var(--dim); padding: 4px 8px; }
.pwa-banner .dismiss:hover { color: #fff; background: transparent; }
@keyframes pwa-slide-in { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* ── Bilingual block toggle (block-level sections) ───────────────────── */
[data-lang="en"] [data-lang-section="th"] { display: none !important; }
[data-lang="th"] [data-lang-section="en"] { display: none !important; }
/* When the active language matches, force the section visible
   even if it had the `hidden` attribute set in the HTML (default state) */
[data-lang="en"] [data-lang-section="en"][hidden] { display: revert !important; }
[data-lang="th"] [data-lang-section="th"][hidden] { display: revert !important; }

/* ── Inline data-en / data-th visibility toggle ──────────────────────── */
/* For inline elements where text swaps via attribute. JS swaps textContent;
   we only hide if both attributes are present and lang doesn't match. */
[data-lang="th"] [data-en][data-th]:empty::after { content: attr(data-th); }
[data-lang="en"] [data-en][data-th]:empty::after { content: attr(data-en); }
