/* Free templates (/site-diary/templates/): the hub and one page per printable form.
   Loaded after /assets/site.css and /site-diary/sd.css, on these pages only, so it uses their tokens
   (warm concrete board, paper cards, the safety-orange piece with a dark label, hi-vis tape) and
   their shared pieces (.btn, .card, .ticks, .faq, .soon-badge, .crumbs, .updated). Every class
   defined here starts with tpl- so it can never collide with the shared stylesheet.
   Static CSS only: the site's CSP allows no inline styles, no scripts and nothing from other hosts.
   The template previews stay white paper in both themes, like the PDFs on the product page. */

/* ---- Hero: the name, the downloads and the big preview --------------------------------------- */

.tpl-hero { padding-block: clamp(24px, 4vw, 44px) clamp(36px, 6vw, 64px); }
.tpl-hero-grid { display: grid; gap: 36px; align-items: start; }
.tpl-hero h1 { max-width: 17ch; }
.tpl-hero .lead { max-width: 38rem; }
.tpl-hero .eyebrow { margin-bottom: 12px; }
.tpl-regions { max-width: 38rem; color: var(--text-2); font-size: 1.125rem; }
.tpl-dl { display: grid; gap: 14px; margin: 26px 0 18px; }
.tpl-dl-buttons { display: flex; flex-wrap: wrap; align-items: center; gap: 14px 16px; }
.tpl-dl-buttons .btn svg { width: 24px; height: 24px; }
.tpl-dl-meta { margin: 0; color: var(--text-2); font-size: 1.125rem; }

/* A sheet of paper: white in both themes, with the paper shadow from the product page. */
.tpl-paper { margin: 0; }
.tpl-paper img { display: block; width: 100%; height: auto; background: #FFFFFF; border-radius: 3px; box-shadow: var(--shadow-paper); }
.tpl-paper figcaption { margin-top: 12px; color: var(--text-2); font-size: 1.0625rem; line-height: 1.35; }
.tpl-hero .tpl-paper { width: 100%; max-width: 480px; justify-self: center; }

@media (min-width: 960px) {
  .tpl-hero-grid { grid-template-columns: minmax(0, 1.08fr) minmax(0, 0.92fr); gap: 56px; }
  .tpl-hero .tpl-paper { justify-self: end; margin-top: 8px; }
}

/* ---- What's on the template ------------------------------------------------------------------ */

.tpl-contents { display: grid; gap: 28px; }
.tpl-contents h3 { margin-bottom: 14px; font-size: 1.35rem; }
.tpl-contents .ticks { gap: 10px; margin: 0; }
.tpl-contents .ticks li { font-size: 1.125rem; }
/* The page 2 preview comes first in the markup (it sits left on wide screens) but after the lists
   on narrow ones, so "Page 1" is always read before a picture of page 2. */
.tpl-contents .tpl-paper { order: 3; max-width: 320px; }
@media (min-width: 820px) {
  .tpl-contents { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); column-gap: 40px; }
  .tpl-contents .tpl-paper { grid-column: 1 / -1; }
}
@media (min-width: 1100px) {
  .tpl-contents { grid-template-columns: 280px minmax(0, 1fr) minmax(0, 1fr); }
  .tpl-contents .tpl-paper { order: 0; grid-column: 1; grid-row: 1; }
}

/* ---- The guide ------------------------------------------------------------------------------- */

.tpl-guide-grid { display: grid; gap: 40px; }
.tpl-guide h2 { margin-top: 1.8em; scroll-margin-top: 16px; }
.tpl-guide ul:not([class]), .tpl-guide ol:not([class]) { padding-left: 1.3em; }
.tpl-guide li { margin-bottom: 0.55em; }
.tpl-guide li::marker { color: var(--text-3); }

/* "On this page": a quiet card of jump links. */
.tpl-toc { margin: 0 0 8px; padding: 16px 20px 6px; border-radius: 18px; background: var(--surface-hero); box-shadow: inset 0 0 0 1px var(--surface-line); }
.tpl-toc p { margin: 0 0 6px; font-weight: 800; }
.tpl-toc ol { margin: 0; padding-left: 1.4em; font-size: 1.125rem; }
.tpl-toc li { margin-bottom: 0; }
.tpl-toc a { display: inline-flex; align-items: center; min-height: 40px; }

/* Field by field: the name in bold, then what to write. */
.tpl-fields { margin: 0 0 1em; }
.tpl-fields dt { margin-top: 18px; font-weight: 800; }
.tpl-fields dt:first-child { margin-top: 0; }
.tpl-fields dd { margin: 4px 0 0; }

/* One small card per region. */
.tpl-region-notes { display: grid; gap: 12px; list-style: none; padding: 0; margin: 0 0 1em; }
.tpl-region-notes li { margin: 0; padding: 16px 18px; border-radius: 18px; background: var(--surface-hero); box-shadow: inset 0 0 0 1px var(--surface-line); font-size: 1.125rem; }
.tpl-region-notes li > b { display: block; margin-bottom: 4px; font-size: 1.1875rem; }

/* "General guidance, not legal advice. Check your contract." */
.tpl-legal { margin: 22px 0 0; padding: 14px 18px; border-radius: 16px; background: var(--sunken); font-weight: 700; }

/* Topic ideas (toolbox talk): two columns of short items on wide screens. */
.tpl-topics { columns: 2 14rem; column-gap: 32px; margin: 0 0 1em; padding-left: 1.2em; }
.tpl-topics li { break-inside: avoid; }

/* The download box beside the guide on wide screens: it stays in view while you read. */
.tpl-side { display: none; }
@media (min-width: 1100px) {
  .tpl-guide-grid { grid-template-columns: minmax(0, 40rem) 280px; justify-content: space-between; gap: 64px; }
  .tpl-side { display: block; }
  .tpl-side .card { position: sticky; top: 24px; display: grid; gap: 14px; padding: 20px; }
  .tpl-side .tpl-paper { max-width: 200px; }
  .tpl-side p { margin: 0; }
  .tpl-side .btn { width: 100%; }
  .tpl-side-note { color: var(--text-2); font-size: 1.0625rem; }
}

/* ---- "Or do it in 60 seconds with the app" ---------------------------------------------------- */

.tpl-app { position: relative; display: grid; gap: 26px; align-items: center; padding-left: calc(clamp(20px, 4vw, 32px) + 12px); }
/* The hi-vis tape down the left edge, as on the product page's free-start card. */
.tpl-app::before { content: ''; position: absolute; left: 14px; top: 22px; bottom: 22px; width: 8px; border-radius: 3px; background: var(--tape-v); box-shadow: 1px 0 0 var(--hivis-edge); }
.tpl-app h2 { margin-top: 0; }
.tpl-app .ticks { gap: 10px; margin: 0 0 6px; }
.tpl-app .ticks li { font-size: 1.125rem; }
.tpl-app .get { margin-top: 18px; }
.tpl-app-more { margin: 16px 0 0; }
.tpl-app-shot { margin: 0; justify-self: center; width: min(62%, 230px); }
.tpl-app-shot picture { display: block; }
.tpl-app-shot img { width: 100%; border-radius: 22px; box-shadow: var(--shadow-shot); background: var(--bg-deep); aspect-ratio: 300 / 649; }
.tpl-app-shot figcaption { margin-top: 10px; color: var(--text-2); font-size: 1rem; line-height: 1.35; text-align: center; }
@media (min-width: 820px) {
  .tpl-app { grid-template-columns: minmax(0, 1fr) 230px; gap: 44px; }
  .tpl-app-shot { width: 100%; }
}

/* ---- Template cards (the hub, and "More free templates") -------------------------------------- */

.tpl-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 250px), 1fr)); gap: 20px; list-style: none; padding: 0; margin: 0; }
.tpl-cards > li { margin: 0; }
.tpl-card { position: relative; display: grid; grid-template-rows: auto 1fr; height: 100%; overflow: hidden; border-radius: var(--r-card); background: var(--surface-hero); box-shadow: var(--shadow-card), inset 0 0 0 1px var(--surface-line); }
/* The top of the form on a board-coloured mat: the title block is what people recognise. */
.tpl-thumb { height: 200px; overflow: hidden; padding: 20px 22px 0; background: var(--bg-deep); }
.tpl-thumb img { display: block; width: 100%; height: auto; background: #FFFFFF; border-radius: 3px 3px 0 0; box-shadow: 0 0 0 1px #D9CFBF, 0 10px 24px -14px rgba(74, 50, 20, 0.5); }
.tpl-card-body { display: grid; gap: 8px; align-content: start; padding: 18px 20px 22px; }
.tpl-card-title { margin: 0; font-size: 1.35rem; line-height: 1.2; }
.tpl-card-title a { color: var(--text); text-decoration: none; }
/* The whole card opens the template's page. */
.tpl-card-title a::after { content: ''; position: absolute; inset: 0; border-radius: inherit; }
.tpl-card:hover .tpl-card-title a { text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 0.18em; }
.tpl-card-title a:focus-visible { outline: none; }
.tpl-card:has(.tpl-card-title a:focus-visible) { outline: 3px solid var(--focus); outline-offset: 3px; }
.tpl-where { margin: 0; color: var(--text-2); font-size: 1rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; }
.tpl-card p { margin: 0; color: var(--text-2); font-size: 1.125rem; }
/* Direct downloads sit above the card-wide link, so they stay clickable. */
.tpl-direct { position: relative; z-index: 1; margin-top: 4px; font-size: 1.0625rem; }
.tpl-direct a { display: inline-flex; align-items: center; min-height: 44px; }
.tpl-cards-compact .tpl-thumb { height: 150px; }
/* The hub: three to a row, one row per region. */
.tpl-cards-3 { grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr)); }
.tpl-group { margin: 36px 0 16px; font-size: 1.35rem; }
.section-head + .tpl-group { margin-top: 8px; }

/* ---- Hub ------------------------------------------------------------------------------------- */

.tpl-hub-hero { padding-block: clamp(24px, 4vw, 44px) clamp(28px, 5vw, 48px); }
.tpl-hub-hero h1 { max-width: 16ch; }
.tpl-hub-hero .lead { max-width: 42rem; }
.tpl-hub-grid { display: grid; gap: 32px; align-items: center; }
/* Three forms fanned out like a stack on the site desk. Wide screens only: on a phone the cards
   below show the same forms straight away. */
.tpl-fan { display: none; }
@media (min-width: 960px) {
  .tpl-hub-grid { grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr); gap: 48px; }
  .tpl-fan { display: block; position: relative; width: 100%; max-width: 500px; justify-self: end; aspect-ratio: 4 / 3; }
  .tpl-fan img { position: absolute; width: 46%; height: auto; background: #FFFFFF; border-radius: 3px; box-shadow: var(--shadow-paper); }
  /* Left on top, so each sheet's title (top right) stays in view. */
  .tpl-fan img:nth-child(1) { left: 0; top: 7%; transform: rotate(-7deg); z-index: 3; }
  .tpl-fan img:nth-child(2) { left: 27%; top: 0; transform: rotate(-1deg); z-index: 2; }
  .tpl-fan img:nth-child(3) { right: 0; top: 6%; transform: rotate(6deg); z-index: 1; }
}
.tpl-steps { counter-reset: tpl-step; display: grid; gap: 14px; list-style: none; padding: 0; margin: 0; }
.tpl-steps li { position: relative; margin: 0; padding-left: 52px; min-height: 36px; font-size: 1.125rem; }
.tpl-steps li::before { counter-increment: tpl-step; content: counter(tpl-step); position: absolute; left: 0; top: -2px; display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; background: var(--sunken); color: var(--text); font-weight: 800; }
.tpl-see-also { display: flex; flex-wrap: wrap; gap: 10px; list-style: none; padding: 0; margin: 24px 0 0; }
.tpl-see-also li { margin: 0; }
.tpl-see-also a { display: inline-flex; align-items: center; min-height: 48px; padding: 0 18px; border-radius: 999px; background: var(--raised); color: var(--text); font-weight: 700; text-decoration: none; box-shadow: inset 0 0 0 1.5px var(--piece-line), 0 4px 0 var(--raised-edge); }
.tpl-see-also a:hover { background: var(--raised-hi); }
.tpl-see-also a:active { transform: translateY(3px); box-shadow: inset 0 0 0 1.5px var(--piece-line), 0 1px 0 var(--raised-edge); }
@media (prefers-reduced-motion: reduce) { .tpl-see-also a:active { transform: none; } }

/* Long words in narrow cards never push the page sideways. */
.tpl-card-title, .tpl-hero h1, .tpl-hub-hero h1 { overflow-wrap: break-word; }
