/* ============================
   Buddhadham.net  Base Styles
   v1.0 (generic, no framework)
   ============================ */

/* ----- CSS Variables (Light/Dark) ----- */
:root{
  --bg: #ffffff;
  --text: #1f2937;           /* slate-800 */
  --muted: #6b7280;          /* slate-500 */
  --link: #0f766e;           /* teal-700 */
  --link-hover: #115e59;     /* teal-800 */
  --border: #e5e7eb;         /* slate-200 */
  --card: #ffffff;
  --shadow: rgba(0,0,0,.06);
  --code-bg: #f8fafc;        /* slate-50 */
  --mark: #fff3b0;
  --radius: 12px;
  --container: 900px;
  --lead: 1.8;
  --space: 20px;
}

@media (prefers-color-scheme: dark){
  :root{
    --bg: #0b0c0d;
    --text: #e5e7eb;
    --muted: #9ca3af;
    --link: #7dd3fc;         /* sky-300 */
    --link-hover: #bae6fd;   /* sky-200 */
    --border: #1f2937;       /* slate-800 */
    --card: #0f1113;
    --shadow: rgba(0,0,0,.25);
    --code-bg: #111827;      /* slate-900 */
    --mark: #3b82f6;
  }
}

/* ----- Reset & Base ----- */
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
html, body { height: 100%; }


/* ----- Container & Prose ----- */
.prose{
  max-width: var(--container);
  margin: 0 auto;
  padding: var(--space);
}
@media (max-width: 600px){
  .prose{ padding: 14px; }
}

/* Site header (top navigation) - keep left/right layout, not centered */
.site-header {
    /* counteract body align-items: center */
    align-self: stretch;
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    box-sizing: border-box;
}

.site-header .inline-flex {
    display: flex;
    gap: 8px;
    align-items: center;
}

.site-header .lang-switch {
    /* prefer flex alignment instead of float so it works reliably */
    float: none !important;
    margin-left: auto;
}

.page-header {
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
    padding: 40px 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.page-title {
    font-size: clamp(1.5rem,3vw,2rem);
    margin: 0 0 20px 0;
    text-align: center;
    width: 100%;
}

.subtitle {
    text-align: center;
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
}

/* ----- Headings & Text ----- */
h1,h2,h3,h4{
  line-height: 1.35;
  margin: 1.2em 0 .4em;
}
h2{ font-size: clamp(1.2rem, 1.2vw + 1rem, 1.4rem); }
h3{ font-size: clamp(1.05rem, 1vw + .9rem, 1.2rem); }
p{ margin: .7em 0; }
small, .muted{ color: var(--muted); }

a{
  color: var(--link);
  text-decoration: none;
}
a:hover{ color: var(--bg); background: var(--link); transition: .18s ease; }

/* ----- Cards ----- */
.card{
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.2rem;
  margin: 1.1rem 0;
  box-shadow: 0 2px 8px var(--shadow);
}

/* ----- TOC (สารบัญลัด) ----- */
.toc{
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: .5rem 1rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  margin: 1.2rem auto 1.6rem;
  box-shadow: 0 2px 8px var(--shadow);
}
.toc a{
  padding: 4px 10px;
  border-radius: 8px;
  color: var(--link);
  font-weight: 500;
  font-size: .95rem;
}
.toc a:hover{
  background: var(--link);
  color: var(--bg);
}

.prose img,
.card img,
article img {
  display: block;
  margin-left: auto;
  margin-right: auto;
  height: auto;
  max-width: 100%;
}

/* ----- Media: Images, Figure, Audio, Video ----- */
figure{ text-align: center; margin: 1.5rem auto; }
figure img{
  display: block;
  margin: 0 auto .6rem;
  max-width: 100%;
  height: auto;
  border-radius: var(--radius);
}

figcaption {
    margin-top: 10px;
    text-align: left;
    width: 100%;
    max-width: 600px;
    color: var(--muted);
    font-size: 0.9rem;
}

img, video{ max-width: 100%; height: auto; }
audio, video{
  display: block;
  margin: .75rem auto;
  width: min(100%, 680px);
  outline: none;
}

/* ----- Tables ----- */
table{
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0;
  overflow: hidden;
  border-radius: 10px;
  border: 1px solid var(--border);
}
th, td{
  padding: .6rem .8rem;
  border-bottom: 1px solid var(--border);
}
thead th{
  background: color-mix(in srgb, var(--card) 85%, var(--border));
  text-align: left;
  font-weight: 700;
}

/* ----- Code & Quotes ----- */
pre, code, kbd, samp{
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
pre{
  background: var(--code-bg);
  padding: .9rem 1rem;
  border-radius: 10px;
  overflow: auto;
  border: 1px solid var(--border);
}
code{ background: var(--code-bg); padding: .15em .35em; border-radius: 6px; }
blockquote{
  margin: 1rem 0;
  padding: .5rem 1rem;
  border-left: 4px solid var(--link);
  background: color-mix(in srgb, var(--card) 88%, var(--border));
  border-radius: 8px;
}

/* ----- Utilities ----- */
.center{ text-align: center; }
.right{ text-align: right; }
.indent{ text-indent: 1.4em; }
.m-0{ margin:0!important; } .mt-0{ margin-top:0!important; } .mb-0{ margin-bottom:0!important; }
.mt-1{ margin-top:.25rem!important; } .mb-1{ margin-bottom:.25rem!important; }
.mt-2{ margin-top:.5rem!important; } .mb-2{ margin-bottom:.5rem!important; }
.p-0{ padding:0!important; } .p-1{ padding:.5rem!important; } .p-2{ padding:1rem!important; }

/* ----- Simple Header (optional) ----- */
.site-header{
  display: flex;
  align-items: center;
  justify-content: flex-start; /* ปุ่มหน้าแรกชิดซ้าย */
  gap: .75rem;
  padding: .6rem var(--space);
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}
.home-btn{
  text-decoration: none;
  color: var(--link);
  font-weight: 600;
  font-size: 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 14px;
}
.home-btn:hover{ background: var(--link); color: var(--bg); }

/* ----- Footer ----- */
.page-end{
  margin: 2rem 0 1rem;
  text-align: center;
  opacity: .75;
  font-size: .95rem;
}

/* ----- Print (สะดวกพิมพ์/บันทึก PDF) ----- */
@media print{
  a{ color: inherit; background: transparent !important; }
  .toc{ break-inside: avoid; box-shadow: none; }
  .card{ box-shadow: none; border-color: #ccc; }
  .site-header{ display:none; } /* พิมพ์เฉพาะเนื้อหา */
}


.hero-img {
  width: min(100%, 420px);
  display: block;
  margin: 0 auto;
  height: auto;
  border-radius: var(--radius);
}

figure {
  text-align: center;
  margin: 1.5rem auto;
}

figure figcaption {
  text-align: center;
  color: var(--muted);
  font-size: .95rem;
  font-style: italic;
  margin-top: .4rem;
}

.footer {
  border-top: 1px solid var(--border);
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center; /* center ไม่ใช่ flex-center */
}

.footer-inner {
  padding: 24px 16px;
  display: flex;          /* เลือกอันเดียวพอ: grid หรือ flex */
  gap: 6px;               /* ลืม ; */
  align-items: center;
  justify-content: center; /* center ไม่ใช่ flex-center */
}

#toTop {
  position: fixed;
  right: 16px;
  bottom: 16px;
  /*display: none;
  display: flex;
  align-items: center;
  z-index: 99; /* ลืม ; */
}
