/* AI writing tool pages (ai-writing-tools-template.html). The backend fills the [data-microapp-template] spans from
   Airtable (usually as <p> text) and mounts the tool widget into #widget-wrapper-for-<slug>. Everything here styles
   around those bindings; it never relies on the markup inside them beyond plain rich text. */

/* ---------- Hero with the tool in the first screen ---------- */
.tp-hero{position:relative;overflow:clip;padding:calc(var(--hdr) + var(--rb-offset,0px) + clamp(24px,5svh,52px)) 16px clamp(48px,7vw,80px)}
.tp-hero::before{content:"";position:absolute;left:50%;top:calc(var(--hdr) + 30px);width:min(1100px,120vw);height:560px;transform:translateX(-50%);
  background:radial-gradient(40% 50% at 28% 55%,color-mix(in srgb,var(--brand) 15%,transparent),transparent 70%),radial-gradient(35% 45% at 74% 40%,rgba(236,72,153,.11),transparent 70%),radial-gradient(30% 40% at 55% 85%,rgba(13,148,136,.09),transparent 70%);
  filter:blur(10px);pointer-events:none}
.tp-in{position:relative;display:flex;flex-direction:column;align-items:center;max-width:960px;margin:0 auto;text-align:center}

.tp-crumb{display:flex;flex-wrap:wrap;justify-content:center;align-items:center;gap:6px;margin:0 0 16px;font-size:14px;color:var(--muted)}
.tp-crumb a{color:var(--muted);text-decoration:none;transition:color .2s}
.tp-crumb a:hover{color:var(--ink)}
.tp-sep{color:var(--line-3)}
.tp-crumb [data-microapp-template],.tp-crumb [data-microapp-template] *{display:inline;margin:0;font:inherit;color:var(--ink-2)}

/* The H1 wraps the bound title span; whatever the backend puts inside it reads as one heading */
.cd-tool-h1,.cd-tool-h2{margin:0;padding:0;font:inherit;color:inherit;letter-spacing:inherit}
.cd-tool-h1>[data-microapp-template]{display:block;max-width:16em;margin:0 auto;font:600 calc(clamp(34px,4.6vw,60px) * min(var(--u),1.15))/1.05 var(--display);letter-spacing:-.04em;color:var(--ink);text-wrap:balance}
.cd-tool-h1>[data-microapp-template] *{margin:0;font:inherit;letter-spacing:inherit;color:inherit}
.tp-in>[data-microapp-template="description"]{display:block;max-width:40em;margin:16px auto 0;font-size:calc(clamp(15px,1.25vw,18px) * min(var(--u),1.15));line-height:1.55;color:var(--muted);text-wrap:pretty}
.tp-in>[data-microapp-template="description"] *{margin:0;font:inherit;color:inherit}

/* The tool: always a light card, because the widget draws its own light form */
.tp-tool{width:min(640px,100%);margin-top:clamp(22px,3.5svh,32px);padding:6px 0 2px;border-radius:22px;background:#fff;color:#16141f;color-scheme:light;text-align:left;
  box-shadow:0 1px 2px rgba(20,16,40,.06),0 24px 60px -24px rgba(40,20,90,.28),inset 0 0 0 1px rgba(20,16,40,.07)}
.tp-tool{position:relative}
/* Loading: our skeleton shows; the widget keeps mounting underneath, out of sight */
.tp-tool[data-state="loading"] #widget-container,.tp-tool[data-state="fail"] #widget-container{position:absolute;inset:0;height:0;overflow:hidden;opacity:0;pointer-events:none}
.tp-skel{display:grid;gap:10px;width:min(540px,calc(100% - 48px));margin:0 auto;padding:22px 0 26px}
.tp-skel[hidden]{display:none}
.tp-skel i{display:block;border-radius:10px;background:linear-gradient(90deg,#ececf1 0%,#f6f6f9 40%,#ececf1 80%);background-size:200% 100%;animation:tp-shimmer 1.3s linear infinite}
.tp-skel .l{width:34%;height:14px;border-radius:6px}
.tp-skel .f{height:46px}
.tp-skel .f.t{height:100px}
.tp-skel .b{height:46px;margin-top:8px;background:linear-gradient(90deg,#dcdbe4 0%,#e9e8ef 40%,#dcdbe4 80%);background-size:200% 100%}
@keyframes tp-shimmer{to{background-position:-200% 0}}
@media (prefers-reduced-motion:reduce){.tp-skel i{animation:none}}
/* Fallback when the library, the API or the network fails */
.tp-fail{display:flex;flex-direction:column;align-items:center;gap:8px;padding:40px 28px 34px;text-align:center}
.tp-fail[hidden]{display:none}
.tp-fail-ic{display:grid;place-items:center;width:48px;height:48px;margin-bottom:6px;border-radius:14px;background:#efeaff;color:#5c33ff}
.tp-fail-ic svg{width:24px;height:24px;fill:currentColor}
.tp-fail b{font:600 20px/1.3 var(--display);letter-spacing:-.02em;color:#16141f}
.tp-fail p{max-width:30em;margin:0;font-size:15px;line-height:1.55;color:#5f5b6e}
.tp-fail-act{display:flex;flex-wrap:wrap;justify-content:center;gap:8px;margin-top:12px}
.tp-fail .d-btn{background:#16141f;color:#fff}
.tp-fail .d-btn.ghost{background:transparent;color:#16141f;box-shadow:inset 0 0 0 1px #d9d7e2}
.tp-fail small{margin-top:10px;font-size:13.5px;color:#6f6b7d}
.tp-fail a{color:#16141f;text-decoration:underline;text-underline-offset:3px}
.tp-fail .d-btn.ghost,.tp-fail .d-btn{text-decoration:none}
.tp-points{display:flex;flex-wrap:wrap;justify-content:center;gap:8px 20px;margin:18px 0 0;padding:0;list-style:none;font-size:14px;color:var(--muted)}
.tp-points li{display:inline-flex;align-items:center;gap:6px}
.tp-points .hi{width:16px;height:16px;color:var(--ok,#16a34a);fill:none;stroke:currentColor;stroke-width:2}

/* The template-pack promo the backend can personalise: kept, but as a quiet link */
.tp-promo{margin-top:16px}
.tp-promo>div{display:block}
.tp-promo span,.tp-promo p{display:inline;margin:0;font-size:14px;line-height:1.5}
.tp-promo a{display:inline-flex;align-items:center;gap:6px;padding:7px 14px;border-radius:999px;background:var(--paper);box-shadow:inset 0 0 0 1px var(--line);color:var(--ink-2);text-decoration:none;transition:box-shadow .2s,color .2s}
.tp-promo a:hover{box-shadow:inset 0 0 0 1px var(--line-3);color:var(--ink)}
.tp-promo span[style]{color:var(--brand-ink)!important;font-weight:600}

/* ---------- How it works ---------- */
.tp-steps{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:14px;margin:0;padding:0;list-style:none}
.tp-steps li{padding:22px;border-radius:18px;background:var(--bg);box-shadow:inset 0 0 0 1px var(--line)}
.tp-steps span{display:grid;place-items:center;width:30px;height:30px;border-radius:9px;background:var(--brand-soft,var(--fill));color:var(--brand-ink);font:700 14px/1 var(--display)}
.tp-steps b{display:block;margin-top:14px;font:600 18px/1.25 var(--display);letter-spacing:-.02em;color:var(--ink)}
.tp-steps p{margin:6px 0 0;font-size:14.5px;line-height:1.55;color:var(--muted)}

/* ---------- About this tool (Airtable rich text) ---------- */
.tp-about-in{max-width:760px}
.cd-tool-h2>[data-microapp-template]{display:block;font:600 calc(clamp(26px,2.8vw,38px) * min(var(--u),1.15))/1.12 var(--display);letter-spacing:-.03em;color:var(--ink);text-wrap:balance}
.cd-tool-h2>[data-microapp-template] *{margin:0;font:inherit;letter-spacing:inherit;color:inherit}
.tp-about-in>[data-microapp-template="midsection-content"]{display:block;margin-top:22px;font-size:16.5px;line-height:1.75;color:var(--ink-2)}
.tp-about-in>[data-microapp-template="midsection-content"] p{margin:0 0 1em}
/* Airtable rich text separates paragraphs with empty <p><br></p>; the margins already do that job */
.tp-about-in>[data-microapp-template="midsection-content"] p:is(:empty,:has(>br:only-child)){display:none}
.tp-about-in>[data-microapp-template="midsection-content"] :is(h2,h3,h4){margin:1.6em 0 .5em;font:600 20px/1.3 var(--display);letter-spacing:-.02em;color:var(--ink)}
.tp-about-in>[data-microapp-template="midsection-content"] :is(ul,ol){margin:0 0 1em;padding-left:1.3em}
.tp-about-in>[data-microapp-template="midsection-content"] li{margin:.3em 0}
.tp-about-in>[data-microapp-template="midsection-content"] a{color:var(--ink);text-decoration:underline;text-decoration-color:var(--line-3);text-underline-offset:3px}
.tp-about-in>[data-microapp-template="midsection-content"] a:hover{text-decoration-color:currentColor}
.tp-about-in>[data-microapp-template="midsection-content"] strong{color:var(--ink)}

/* ---------- More tools ---------- */
.tp-pop{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:10px;margin:0;padding:0;list-style:none}
.tp-pop a{position:relative;display:block;padding:16px 40px 16px 18px;border-radius:14px;background:var(--bg);box-shadow:inset 0 0 0 1px var(--line);font:600 15px/1.35 var(--sans);color:var(--ink);text-decoration:none;transition:box-shadow .2s,background .2s}
.tp-pop a:hover{background:var(--paper);box-shadow:inset 0 0 0 1px var(--line-3),var(--lift)}
.tp-go{position:absolute;right:14px;top:50%;width:16px;height:16px;margin-top:-8px;fill:none;stroke:var(--muted);stroke-width:1.8;transition:transform .25s var(--spring),stroke .2s}
.tp-pop a:hover .tp-go{stroke:var(--ink);transform:translate(2px,-2px)}

@media (max-width:980px){
  .tp-pop{grid-template-columns:repeat(2,minmax(0,1fr))}
  .tp-steps{grid-template-columns:1fr}
}
@media (max-width:560px){
  .tp-pop{grid-template-columns:1fr}
  .tp-tool{border-radius:18px}
  .tp-points{gap:6px 14px;font-size:13px}
}
