/* Intercultural 360 - shared reading layout for every guide page (/guides/<slug>.html), mobile first.
   Works with the guides' own markup (Tailwind hero + article.article-body + sidebar) and with pages rendered
   from _template.html (.g-hero / .g-article). Behaviour: /assets/guide.js (sets html.gd-page).
   Layout only: no text is added to or removed from the page's content. */
html.gd-page article h2[id], html.gd-page article h3[id], html.gd-page .g-article section { scroll-margin-top: 76px; }

/* meta line under the title: flag · Updated · reading time */
.gd-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; margin: 0 0 12px; font-size: 13px; font-weight: 600; color: rgba(255,255,255,.92); }
.gd-meta-item { display: inline-flex; align-items: center; gap: 6px; }
.gd-meta-item + .gd-meta-item::before { content: ""; width: 4px; height: 4px; border-radius: 50%; background: currentColor; opacity: .6; margin-right: 8px; }
.gd-flag { width: 20px; height: 15px; border-radius: 3px; object-fit: cover; box-shadow: 0 0 0 1px rgba(255,255,255,.4); flex-shrink: 0; }
.gd-hero:not(.relative):not(.guide-hero):not(.g-hero) .gd-meta { color: #475569; }

/* "On this page" */
.gd-toc { margin: 0 0 20px; border: 1px solid #e2e8f0; border-radius: 16px; background: #f8fafc; }
.gd-toc > summary { display: flex; align-items: center; gap: 10px; min-height: 48px; padding: 0 16px; cursor: pointer; list-style: none; font: 700 14px/1.2 'Inter', system-ui, sans-serif; color: #0f172a; -webkit-tap-highlight-color: transparent; }
.gd-toc > summary::-webkit-details-marker { display: none; }
.gd-toc > summary::after { content: ""; margin-left: auto; width: 9px; height: 9px; border-right: 2px solid #64748b; border-bottom: 2px solid #64748b; transform: rotate(45deg) translateY(-3px); transition: transform .2s ease; }
.gd-toc[open] > summary::after { transform: rotate(225deg) translateY(-2px); }
.gd-toc > summary:focus-visible { outline: 3px solid #5eead4; outline-offset: 2px; border-radius: 16px; }
.gd-toc-count { font-size: 12px; font-weight: 700; color: #0F6E56; background: #e6f4ef; border-radius: 999px; padding: 1px 8px; }
.gd-toc ol { margin: 0; padding: 0 8px 10px; list-style: none; counter-reset: gd; }
.gd-toc li { counter-increment: gd; }
.gd-toc li a { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 6px 8px; border-radius: 10px; color: #334155; font-size: 15px; line-height: 1.35; text-decoration: none; }
.gd-toc li a::before { content: counter(gd); min-width: 24px; height: 24px; border-radius: 50%; background: #0F6E56; color: #fff; font-size: 11px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.gd-toc-plain li a::before { content: none; }
.gd-toc li a:hover, .gd-toc li a:focus-visible { background: #e6f4ef; color: #0F6E56; }
@media (min-width: 1024px) { .gd-toc { display: none; } }   /* desktop keeps the chapter grid + sidebar contents */

/* tables scroll inside their box, never the page */
.gd-table { max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 1rem 0 1.5rem; border: 1px solid #e2e8f0; border-radius: 12px; }
.gd-table > table { margin: 0 !important; min-width: 520px; }
html.gd-page article { overflow-wrap: anywhere; }
html.gd-page article img { max-width: 100%; height: auto; }
html.gd-page article pre { overflow-x: auto; }

/* related guides (only on pages without their own block) */
.gd-related { margin: 2rem 0 0; }
.gd-related ul { list-style: none !important; padding: 0 !important; margin: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; }
@media (min-width: 640px) { .gd-related ul { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.gd-related li { margin: 0 !important; }
.gd-related a { display: flex; align-items: center; gap: 10px; min-height: 56px; padding: 10px 14px; border: 1px solid #e2e8f0; border-radius: 14px; background: #fff; color: #0f172a !important; font-weight: 600; text-decoration: none !important; line-height: 1.35; }
.gd-related a:hover { border-color: #0F6E56; }
.gd-related .gd-flag { box-shadow: 0 0 0 1px #e2e8f0; }

/* reading width and type */
html.gd-page article.article-body, html.gd-page article.prose { max-width: 46rem; }
@media (max-width: 1023.98px) {
  html.gd-page .chapter-nav { display: none !important; }        /* replaced by "On this page" (the links stay in the page) */
  html.gd-page article p, html.gd-page article li, html.gd-page .g-article p, html.gd-page .g-article li { font-size: 16.5px !important; line-height: 1.7 !important; }
  html.gd-page article h2 { font-size: 1.35rem !important; line-height: 1.3 !important; margin-top: 2rem !important; }
  html.gd-page article h3 { font-size: 1.1rem !important; line-height: 1.35 !important; }
  html.gd-page .max-w-7xl.mx-auto.px-4.py-6 { padding-top: 12px !important; }
  html.gd-page .max-w-7xl.mx-auto.px-4.py-6 > nav:first-child { margin-bottom: 12px !important; }
  html.gd-page .max-w-7xl.mx-auto.px-4.py-6 > nav:first-child a { display: inline-flex; align-items: center; min-height: 32px; }
}

/* compact header on phones */
@media (max-width: 767.98px) {
  html.gd-page .gd-hero.relative { height: auto !important; min-height: 180px; display: flex; flex-direction: column; justify-content: flex-end; }
  html.gd-page .gd-hero.relative > img { position: absolute; inset: 0; }
  html.gd-page .gd-hero.relative > .absolute.inset-0.flex { position: relative !important; inset: auto !important; padding: 36px 16px 14px !important; }
  html.gd-page .gd-hero h1 { font-size: 1.4rem !important; line-height: 1.22 !important; margin-bottom: 8px !important; }
  html.gd-page .gd-hero .flex.flex-wrap.gap-3 { flex-wrap: nowrap !important; overflow-x: auto; gap: 6px !important; margin: 0 -16px; padding: 0 16px 2px; scrollbar-width: none; }
  html.gd-page .gd-hero .flex.flex-wrap.gap-3::-webkit-scrollbar { display: none; }
  html.gd-page .gd-hero .flex.flex-wrap.gap-3 > * { flex-shrink: 0; white-space: nowrap; }
  html.gd-page .gd-hero .flex.items-center.gap-2.mb-3 { margin-bottom: 8px !important; flex-wrap: wrap; }
  html.gd-page .gd-hero.guide-hero { padding-top: 24px !important; padding-bottom: 20px !important; }
  html.gd-page .gd-hero.guide-hero h1 + .gd-meta + p { font-size: 15px !important; line-height: 1.5 !important; margin-bottom: 14px !important; }
  html.gd-page .gd-hero.guide-hero nav { margin-bottom: 12px !important; }
  html.gd-page .gd-hero.guide-hero .grid.grid-cols-2 { display: flex !important; overflow-x: auto; gap: 8px !important; margin: 0 -24px; padding: 0 24px 2px; scrollbar-width: none; }
  html.gd-page .gd-hero.guide-hero .grid.grid-cols-2::-webkit-scrollbar { display: none; }
  html.gd-page .gd-hero.guide-hero .grid.grid-cols-2 > * { flex: 0 0 auto; min-width: 136px; }
  html.gd-page .gd-hero.g-hero { padding: 24px 0 20px; }
  html.gd-page .gd-hero.g-hero .g-badge { margin-bottom: 10px; }
  html.gd-page #pdf-btn { min-height: 44px; }
}
/* colour contrast (4.5:1): breadcrumb, grey notes and the green call-to-action buttons of the guides */
html.gd-page .max-w-7xl > nav.text-xs { color: #64748b; }
html.gd-page article .text-slate-400 { color: #64748b; }
html.gd-page a.bg-emerald-500.text-white, html.gd-page .bg-emerald-500.text-white { background-color: #047857; }
html.gd-page a.bg-emerald-500.text-white:hover { background-color: #065f46; }
@media print { .gd-toc, .gd-related, .gd-meta { display: none !important; } .gd-table { overflow: visible; border: 0; } }
