/* ==========================================================
   CMS additions – only styles for elements that did not exist
   in the static site (form feedback, pagination, honeypot).
   The original design lives untouched in style.css.
   ========================================================== */
.form-alert {
  grid-column: 1 / -1;
  padding: 16px 20px;
  border-left: 4px solid var(--navy);
  background: var(--ice);
  color: var(--navy);
  font-size: var(--fs-sm);
}
.form-alert.error { border-left-color: var(--orange); background: #fdeee9; color: #8a2a0d; }
.field .field-error { display: block; margin-top: 6px; color: #b5370f; font-size: 14px; }
.field .field-error:empty { display: none; }
.field-foot { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.field-foot .field-error { flex: 1; }
.field-count { margin-top: 6px; margin-left: auto; color: var(--gray); font-size: 13px; white-space: nowrap; }
.field-count.near { color: #b5370f; }
.form-submit[disabled] { opacity: .7; cursor: wait; }
.field input[aria-invalid="true"], .field textarea[aria-invalid="true"] { border-color: var(--orange); }
.hp-field { position: absolute !important; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
.cms-pagination { display: flex; gap: 12px; justify-content: center; margin-top: 48px; }

/* ---------- Thank-you popup (contact form) ---------- */
.ty-modal {
  border: 0; padding: 0; background: transparent; max-width: none; max-height: none;
  width: 100%; height: 100%; display: none; place-items: center; overflow: auto;
}
.ty-modal[open] { display: grid; }
.ty-modal::backdrop { background: rgba(6, 57, 112, .55); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); animation: ty-fade .3s ease both; }
.ty-card {
  position: relative; width: min(520px, calc(100% - 32px)); margin: 16px;
  background: var(--white); border-top: 4px solid var(--orange);
  padding: clamp(40px, 4vw, 56px) clamp(24px, 3vw, 48px) clamp(32px, 3vw, 44px);
  text-align: center; box-shadow: 0 30px 80px rgba(4, 30, 60, .35);
  animation: ty-pop .55s cubic-bezier(.2, .9, .3, 1.25) both;
}
.ty-x {
  position: absolute; top: 14px; right: 14px; width: 38px; height: 38px;
  display: grid; place-items: center; border: 0; background: transparent; color: var(--gray); cursor: pointer;
  transition: color .2s, transform .25s;
}
.ty-x svg { width: 14px; height: 14px; }
.ty-x:hover, .ty-x:focus-visible { color: var(--navy); transform: rotate(90deg); }
.ty-icon { position: relative; width: 92px; height: 92px; margin: 0 auto 24px; }
.ty-icon > svg { width: 100%; height: 100%; display: block; }
.ty-circle {
  fill: var(--ice); stroke: var(--navy); stroke-width: 2.5;
  stroke-dasharray: 151; stroke-dashoffset: 151;
  animation: ty-draw .6s .25s ease-out forwards;
}
.ty-check {
  fill: none; stroke: var(--orange); stroke-width: 4; stroke-linecap: round; stroke-linejoin: round;
  stroke-dasharray: 36; stroke-dashoffset: 36;
  animation: ty-draw .35s .8s ease-out forwards;
}
.ty-burst { position: absolute; inset: 0; pointer-events: none; }
.ty-burst i {
  position: absolute; left: 50%; top: 50%; width: 8px; height: 8px; margin: -4px; border-radius: 50%;
  background: var(--sky); opacity: 0;
  transform: rotate(calc(var(--i) * 36deg)) translateY(0) scale(.4);
  animation: ty-burst .7s 1s ease-out forwards;
}
.ty-burst i:nth-child(3n + 1) { background: var(--orange); }
.ty-burst i:nth-child(3n + 2) { background: var(--navy); width: 6px; height: 6px; margin: -3px; }
.ty-title {
  font-family: var(--font-head); font-weight: 500; color: var(--navy);
  font-size: clamp(34px, 1.67vw + 18px, 50px); line-height: 1.1; margin-bottom: 14px;
  animation: ty-up .5s .45s ease both;
}
.ty-text { color: var(--gray); font-size: var(--fs-body); line-height: var(--lh-body); max-width: 400px; margin: 0 auto 28px; animation: ty-up .5s .55s ease both; }
.ty-btn { animation: ty-up .5s .65s ease both; }
.ty-btn:focus-visible { outline: 2px solid var(--sky); outline-offset: 3px; }
.ty-modal.closing .ty-card { animation: ty-out .22s ease-in forwards; }
.ty-modal.closing::backdrop { animation: ty-fade .22s ease-in reverse forwards; }

@keyframes ty-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes ty-pop { from { opacity: 0; transform: translateY(24px) scale(.92); } to { opacity: 1; transform: none; } }
@keyframes ty-out { to { opacity: 0; transform: translateY(12px) scale(.96); } }
@keyframes ty-up { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes ty-draw { to { stroke-dashoffset: 0; } }
@keyframes ty-burst {
  0% { opacity: 0; transform: rotate(calc(var(--i) * 36deg)) translateY(0) scale(.4); }
  30% { opacity: 1; }
  100% { opacity: 0; transform: rotate(calc(var(--i) * 36deg)) translateY(-66px) scale(1); }
}
@media (max-width: 700px) {
  .ty-btn { width: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  .ty-card, .ty-title, .ty-text, .ty-btn, .ty-modal::backdrop { animation: none; }
  .ty-circle, .ty-check { animation: none; stroke-dashoffset: 0; }
  .ty-burst { display: none; }
}

/* ---------- Article: right-side "In this article" tabs ---------- */
.article-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) clamp(250px, 17vw, 330px);
  gap: clamp(40px, 4vw, 80px);
  align-items: start;
}
.article-main { min-width: 0; }
/* headings land a little below the top edge when jumped to */
.article-main h2[id] { scroll-margin-top: 32px; }
/* image sections share the narrower column more evenly */
.article-layout .art-split .img { flex: 0 0 44%; }

.article-toc {
  position: sticky; top: 32px; align-self: start;
  /* gap above the box (a margin, so it is not counted in the box height when stuck) */
  margin-top: clamp(48px, 4.17vw, 80px);
}
.article-toc-mobile { display: none; }
.toc-card { background: var(--white); border: 1px solid var(--sky); border-top: 3px solid var(--navy); }
/* the list always fits the screen: 32px space top + bottom, minus the title row (~56px).
   (set on the list itself – flex sizing does not reach inside <details>) */
.toc-card nav { max-height: calc(100vh - 64px - 56px); overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: var(--sky) transparent; }
.toc-card nav::-webkit-scrollbar { width: 5px; }
.toc-card nav::-webkit-scrollbar-thumb { background: var(--sky); border-radius: 5px; }
.toc-card nav::-webkit-scrollbar-track { background: transparent; }
.toc-title {
  list-style: none; cursor: default;
  padding: 16px 20px 10px;
  font-size: 13px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--navy);
}
.toc-title::-webkit-details-marker { display: none; }
.toc-list { list-style: none; margin: 0; padding: 0 0 12px; counter-reset: toc; }
.toc-list li { counter-increment: toc; }
.toc-list a {
  position: relative; display: flex; gap: 12px;
  padding: 8px 20px 8px 17px;
  border-left: 3px solid transparent;
  color: var(--gray); font-size: clamp(14px, 0.21vw + 11.3px, 16px); line-height: 1.35; text-decoration: none;
  transition: color .2s, background-color .2s, border-color .2s;
}
.toc-list a::before {
  content: counter(toc, decimal-leading-zero);
  flex: none; font-family: var(--font-head); font-size: 17px; line-height: 1.2; color: var(--sky);
  transition: color .2s;
}
.toc-list a:hover { color: var(--navy); background: var(--cream); }
.toc-list a.active { color: var(--navy); font-weight: 600; background: var(--ice); border-left-color: var(--orange); }
.toc-list a.active::before { color: var(--orange); }
.toc-list a:focus-visible { outline: 2px solid var(--sky); outline-offset: -2px; }

/* below 1200px: no side column – the list sits above the article and can be opened/closed */
@media (max-width: 1199px) {
  .article-layout { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .article-toc { position: static; order: -1; margin-top: clamp(32px, 4vw, 48px); }
  .article-intro .article-toc-mobile { display: block; width: 100%; margin-top: 0; }
  .article-layout.has-mobile-toc .article-toc-desktop { display: none; }
  .toc-card nav { max-height: none; overflow: visible; }
  .toc-title { cursor: pointer; display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; }
  .toc-title::after {
    content: ""; width: 9px; height: 9px; margin-right: 4px;
    border-right: 2px solid var(--navy); border-bottom: 2px solid var(--navy);
    transform: rotate(45deg) translateY(-2px); transition: transform .25s;
  }
  .toc-card[open] .toc-title::after { transform: rotate(-135deg) translateY(-2px); }
  .toc-card[open] .toc-title { border-bottom: 1px solid var(--ice); }
  .toc-list { padding-top: 6px; }
  .article-layout .art-split .img { flex: none; }
}
@media (prefers-reduced-motion: reduce) {
  .toc-list a, .toc-list a::before, .toc-title::after { transition: none; }
}

/* ---------- Article FAQs (accordion) ---------- */
.article-faqs .faq-list { border-top: 1px solid var(--sky); }
.faq-item { border-bottom: 1px solid var(--sky); }
.faq-item summary {
  list-style: none; cursor: pointer;
  display: flex; align-items: center; justify-content: space-between; gap: 24px;
  padding: clamp(18px, 1.35vw, 26px) 4px;
  color: var(--navy); font-size: clamp(17px, 0.42vw + 13px, 22px); font-weight: 600; line-height: 1.4;
  transition: color .2s;
}
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary:hover { color: var(--orange); }
.faq-item summary:focus-visible { outline: 2px solid var(--sky); outline-offset: 2px; }
/* plus / minus icon */
.faq-icon { position: relative; flex: none; width: 34px; height: 34px; border: 1px solid var(--navy); border-radius: 50%; transition: background-color .25s, border-color .25s; }
.faq-icon::before, .faq-icon::after {
  content: ""; position: absolute; left: 50%; top: 50%; width: 12px; height: 2px; margin: -1px 0 0 -6px;
  background: var(--navy); transition: transform .3s ease, background-color .25s;
}
.faq-icon::after { transform: rotate(90deg); }
.faq-item[open] .faq-icon { background: var(--orange); border-color: var(--orange); }
.faq-item[open] .faq-icon::before, .faq-item[open] .faq-icon::after { background: var(--white); }
.faq-item[open] .faq-icon::after { transform: rotate(0deg); }
.faq-a { display: flex; flex-direction: column; gap: 16px; padding: 0 58px clamp(20px, 1.56vw, 30px) 4px; }
.faq-item[open] .faq-a { animation: faq-in .3s ease both; }
@keyframes faq-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
@media (max-width: 700px) {
  .faq-a { padding-right: 4px; }
  .faq-icon { width: 30px; height: 30px; }
}
@media (prefers-reduced-motion: reduce) {
  .faq-item[open] .faq-a { animation: none; }
  .faq-icon, .faq-icon::before, .faq-icon::after { transition: none; }
}

/* ---------- Article: byline + "About the author" box ---------- */
.article-head .date .byline { color: var(--gray); }
.article-head .date .byline a { color: var(--navy); font-weight: 600; text-decoration: underline; text-decoration-color: var(--sky); text-underline-offset: 3px; }
.article-head .date .byline a:hover { color: var(--orange); }

.author-box {
  scroll-margin-top: 32px;
  display: flex; gap: clamp(24px, 2.5vw, 44px); align-items: flex-start;
  background: var(--white); border: 1px solid var(--sky); border-left: 6px solid var(--navy);
  padding: clamp(24px, 2.3vw, 44px);
}
.author-photo { flex: none; width: clamp(110px, 8.4vw, 160px); aspect-ratio: 1; border-radius: 50%; overflow: hidden; border: 4px solid var(--ice); }
.author-photo img { width: 100%; height: 100%; object-fit: cover; object-position: center top; display: block; }
.author-body { display: flex; flex-direction: column; gap: 16px; align-items: flex-start; min-width: 0; }
.author-id { display: flex; flex-direction: column; gap: 4px; }
.author-name { font-family: var(--font-head); font-weight: 500; font-size: var(--fs-h4); line-height: 1.2; color: var(--navy); }
.author-role { color: var(--orange); font-size: var(--fs-sm); font-weight: 500; }
.author-bio { display: flex; flex-direction: column; gap: 14px; }
.author-links { display: flex; flex-wrap: wrap; align-items: center; gap: 14px 24px; margin-top: 4px; }
.author-linkedin { display: inline-flex; align-items: center; gap: 10px; color: var(--navy); font-weight: 600; font-size: var(--fs-sm); }
.author-linkedin:hover { color: var(--orange); }
@media (max-width: 700px) {
  .author-box { flex-direction: column; align-items: center; text-align: center; border-left-width: 1px; border-top: 6px solid var(--navy); }
  .author-body, .author-links { align-items: center; justify-content: center; }
}
