/*
 * Blog posts: page layout, article, content typography, sidebar and the Kadence bridge.
 * Loaded on single posts, archives and search (they share the sidebar).
 *
 * How the cascade is arranged
 *  - Element defaults inside the content are written as :where(.entry-content) element. :where() adds no weight, so they
 *    only tie with the theme's own element rules (h2 46px, ul padding 0, span inline-block ...) and win because this
 *    file loads later. Anything with a class (Kadence blocks, Gutenberg blocks, utility classes, inline styles)
 *    always wins over them, so a block can set its own size, margin or colour.
 *  - Colours are WCAG AA on white: navy #1c1c45 text, #575e8d secondary text (6.2:1), #0a58ca links (6.4:1).
 */

:root {
  --cp-navy: #1c1c45;
  --cp-navy-soft: #575e8d;
  --cp-amber: #ffa520;
  --cp-link: #0a58ca;
  --cp-link-hover: #07418f;
  --cp-line: #e6e8ee;
  --cp-soft: #f5f7fa;
  --cp-radius: 12px;
}

/* ---------- Page ---------- */
.single-post main,
.cas-post {
  background: #fff;
}
.cas-post {
  padding: 48px 0;
}
@media (max-width: 767.98px) {
  .cas-post { padding: 32px 0; }
}
/* Breadcrumb: the same compact text trail as the blog page (Home › Blog › title). Grey #6e6c90 is 5.0:1 on white,
   the current page is navy. The separator is drawn in CSS and hidden from screen readers (the "/ ''" alt text). */
.cas-crumbs {
  margin: 0 0 24px;
  font-size: 14px;
  line-height: 1.5;
  color: #6e6c90;
}
.cas-crumbs ol {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.cas-crumbs li { margin: 0; padding: 0; }
.cas-crumbs li + li::before {
  content: "\203A";
  content: "\203A" / "";
  margin-right: 8px;
  color: #6e6c90;
}
.cas-crumbs a {
  display: inline-block;
  padding: 2px 0;
  color: #6e6c90;
  font-size: inherit;
  font-weight: 400;
  text-decoration: none;
}
.cas-crumbs a:hover { color: #1c1c45; text-decoration: underline; text-underline-offset: 3px; }
.cas-crumbs li[aria-current] { color: #1c1c45; font-weight: 500; overflow-wrap: anywhere; }

/* ---------- Article header ---------- */
/* The category is a tag in the byline line: a small uppercase label on a soft amber tint, the same style as the "Featured" pill on
   the blog page (navy on #fff3e0 is 15:1). It fills amber on hover. */
.cas-article__by { margin-bottom: 8px; }
.cas-article__dates { align-items: center; }
.cas-article__cat {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}
.cas-article__cat a {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 10px;
  border-radius: 4px;
  background: #fff3e0;
  color: var(--cp-navy);
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  line-height: 1.3;
  text-transform: uppercase;
  text-decoration: none;
}
.cas-article__cat a:hover {
  background: var(--cp-amber);
}
.cas-article__cat-label {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
/* The tag needs no separator dot after it, and on phones it takes its own line. */
.cas-article__cat + [aria-hidden="true"] { display: none; }
@media (max-width: 575.98px) {
  .cas-article__cat { flex: 0 0 100%; }
}

.cas-article .cas-article__title {
  margin: 0 0 20px;
  font-size: clamp(30px, 3.4vw, 44px);
  line-height: 1.15;
  font-weight: 600;
  letter-spacing: -0.01em;
  overflow-wrap: break-word;
  text-wrap: balance;
}
.cas-article__meta {
  flex-wrap: nowrap;
  align-items: flex-start;
  margin: 0 0 28px;
}
.cas-article__meta .user-image { flex: 0 0 44px; }
.cas-article__meta .user-info { flex: 1 1 auto; min-width: 0; }
.cas-article__by {
  font-size: 15px;
  font-weight: 600;
  line-height: 1.4;
  color: var(--cp-navy);
}
.cas-article__by a {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.cas-article__dates {
  display: flex;
  flex-wrap: wrap;
  gap: 0 8px;
  font-size: 14px;
  line-height: 1.5;
  color: var(--cp-navy-soft);
}
.cas-article__figure {
  margin: 0 0 32px;
  border-radius: var(--cp-radius);
  overflow: hidden;
  background: var(--cp-soft);
}
.cas-article__figure img {
  display: block;
  width: 100%;
  height: auto;
  max-height: 520px;
  object-fit: contain;
}
.cas-article__figure figcaption {
  padding: 8px 14px;
  font-size: 14px;
  line-height: 1.5;
  color: var(--cp-navy-soft);
}

/* ---------- Table of contents ---------- */
.cas-toc__list,
.cas-toc__sub {
  margin: 0;
  padding: 0;
  list-style: none;
}
.cas-toc__list a {
  display: block;
  padding: 7px 0 7px 15px;
  color: var(--cp-navy);
  font-size: 15px;
  line-height: 1.4;
  text-decoration: none;
}
.cas-toc__list a:hover {
  color: var(--cp-link-hover);
  text-decoration: underline;
}
.cas-toc__sub a {
  padding-left: 28px;
  font-size: 14px;
  color: var(--cp-navy-soft);
}
.cas-toc--inline {
  margin: 0 0 28px;
  border: 1px solid var(--cp-line);
  border-radius: var(--cp-radius);
  background: var(--cp-soft);
}
.cas-toc--inline summary {
  padding: 12px 16px;
  min-height: 44px;
  font-weight: 600;
  line-height: 1.5;
  cursor: pointer;
}
.cas-toc--inline nav {
  padding: 0 16px 12px;
}
@media (min-width: 992px) {
  .cas-toc--inline { display: none; }
}
.cas-toc--side { display: none; }
@media (min-width: 992px) {
  .cas-toc--side { display: block; }
}

/* ---------- Content typography ---------- */
.entry-content {
  color: var(--cp-navy);
  font-size: 16px;
  line-height: 1.75;
  overflow-wrap: break-word;
}
.entry-content > :first-child { margin-top: 0; }
.entry-content > :last-child { margin-bottom: 0; }

:where(.entry-content) h2,
:where(.entry-content) h3,
:where(.entry-content) h4,
:where(.entry-content) h5,
:where(.entry-content) h6 {
  margin: 2em 0 0.6em;
  color: var(--cp-navy);
  font-weight: 600;
  line-height: 1.25;
  scroll-margin-top: 120px;
  text-wrap: balance;
}
:where(.entry-content) h2 { font-size: clamp(24px, 2.2vw, 30px); }
:where(.entry-content) h3 { font-size: clamp(20px, 1.8vw, 24px); margin-top: 1.7em; }
:where(.entry-content) h4 { font-size: 20px; margin-top: 1.5em; }
:where(.entry-content) h5 { font-size: 18px; margin-top: 1.4em; }
:where(.entry-content) h6 { font-size: 16px; margin-top: 1.4em; text-transform: uppercase; letter-spacing: 0.04em; }
:where(.entry-content) h2 + h3,
:where(.entry-content) h3 + h4 { margin-top: 1em; }

:where(.entry-content) p { margin: 0 0 1.25em; }
:where(.entry-content) strong,
:where(.entry-content) b { font-weight: 600; }
:where(.entry-content) a {
  color: var(--cp-link);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
}
:where(.entry-content) a:hover {
  color: var(--cp-link-hover);
  text-decoration-thickness: 2px;
}
.entry-content a:focus-visible,
.cas-sidebar a:focus-visible,
.cas-post-nav a:focus-visible,
.cas-article__cat a:focus-visible,
.cas-toc summary:focus-visible,
.cas-table-scroll:focus-visible {
  outline: 3px solid var(--cp-navy);
  outline-offset: 2px;
  border-radius: 2px;
}
/* Kadence and Gutenberg buttons are links too; they keep their own look. */
:where(.entry-content) a[class*="kb-button"],
:where(.entry-content) a[class*="wp-block-button"],
:where(.entry-content) a.wp-element-button { text-decoration: none; }

:where(.entry-content) ul,
:where(.entry-content) ol { margin: 0 0 1.25em; padding-left: 1.5em; }
:where(.entry-content) ul { list-style: disc outside; }
:where(.entry-content) ol { list-style: decimal outside; }
:where(.entry-content) li { margin: 0 0 0.45em; padding-left: 0.2em; }
:where(.entry-content) li > ul,
:where(.entry-content) li > ol { margin: 0.45em 0 0.45em; }
:where(.entry-content) li > p { margin-bottom: 0.6em; }
:where(.entry-content) dl { margin: 0 0 1.25em; }
:where(.entry-content) dt { font-weight: 600; }
:where(.entry-content) dd { margin: 0 0 0.6em; padding-left: 1.5em; }

:where(.entry-content) blockquote {
  margin: 0 0 1.5em;
  padding: 16px 20px;
  border-left: 4px solid var(--cp-amber);
  border-radius: 0 8px 8px 0;
  background: var(--cp-soft);
  font-size: 1.05em;
}
:where(.entry-content) blockquote > :last-child { margin-bottom: 0; }
:where(.entry-content) cite { font-size: 0.9em; font-style: normal; color: var(--cp-navy-soft); }

:where(.entry-content) hr {
  margin: 2em 0;
  border: 0;
  border-top: 1px solid var(--cp-line);
  opacity: 1;
}
:where(.entry-content) pre {
  margin: 0 0 1.5em;
  padding: 16px;
  overflow: auto;
  border-radius: 8px;
  background: var(--cp-navy);
  color: var(--cp-soft);
  font-size: 15px;
  line-height: 1.6;
}
:where(.entry-content) code,
:where(.entry-content) kbd { padding: 0.1em 0.35em; border-radius: 4px; background: var(--cp-soft); font-size: 0.9em; }
:where(.entry-content) pre code { padding: 0; background: none; color: inherit; }
:where(.entry-content) mark { padding: 0 0.2em; background: #fff1cf; color: inherit; }
:where(.entry-content) sup,
:where(.entry-content) sub { line-height: 0; }
:where(.entry-content) details { margin: 0 0 1em; padding: 12px 16px; border: 1px solid var(--cp-line); border-radius: 8px; }
:where(.entry-content) summary { font-weight: 600; cursor: pointer; }

/* Images, figures, captions and alignment */
:where(.entry-content) img { max-width: 100%; height: auto; }
:where(.entry-content) figure { margin: 0 0 1.5em; }
:where(.entry-content) figcaption,
.entry-content .wp-caption-text {
  margin-top: 8px;
  font-size: 14px;
  line-height: 1.5;
  color: var(--cp-navy-soft);
}
.entry-content .aligncenter { display: block; margin-left: auto; margin-right: auto; text-align: center; }
.entry-content .alignleft { float: left; margin: 0.25em 1.5em 1em 0; max-width: 50%; }
.entry-content .alignright { float: right; margin: 0.25em 0 1em 1.5em; max-width: 50%; }
.entry-content .alignwide,
.entry-content .alignfull { width: 100%; max-width: 100%; margin-left: 0; margin-right: 0; }
.entry-content::after { content: ""; display: table; clear: both; }
@media (max-width: 575.98px) {
  .entry-content .alignleft,
  .entry-content .alignright { float: none; max-width: 100%; margin: 0 auto 1em; }
}

/* Tables */
.cas-table-scroll {
  margin: 0 0 1.5em;
  overflow-x: auto;
  border: 1px solid var(--cp-line);
  border-radius: 8px;
}
:where(.entry-content) table {
  width: 100%;
  margin: 0;
  border-collapse: collapse;
  font-size: 16px;
  line-height: 1.5;
}
:where(.entry-content) caption {
  padding: 12px 12px 8px;
  caption-side: top;
  text-align: left;
  font-weight: 600;
  color: var(--cp-navy);
}
:where(.entry-content) th,
:where(.entry-content) td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--cp-line);
  text-align: left;
  vertical-align: top;
}
:where(.entry-content) thead th { background: var(--cp-navy); color: #fff; border-bottom: 0; }
:where(.entry-content) tbody tr:nth-child(even) > * { background: var(--cp-soft); }
:where(.entry-content) tbody th { font-weight: 600; white-space: nowrap; }
.cas-table-scroll table { border: 0; }

/* Embedded video (YouTube handler in inc/post-helpers.php, core embed blocks) */
.cas-embed,
.entry-content .wp-block-embed { margin: 0 0 1.5em; }
.cas-embed__frame,
.entry-content .wp-block-embed__wrapper {
  position: relative;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border-radius: var(--cp-radius);
  background: var(--cp-navy);
}
.cas-embed__frame iframe,
.entry-content .wp-block-embed__wrapper iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

/* Blocks the older posts carry */
.entry-content .cas-guide-links { border-radius: var(--cp-radius); }
.entry-content .cas-country-top > :last-child { margin-bottom: 0; }

/* ---------- End of article ---------- */
.cas-cta {
  margin: 48px 0 0;
  padding: 24px;
  border-radius: var(--cp-radius);
  background: var(--cp-soft);
}
.cas-cta .cas-cta__title {
  margin: 0 0 8px;
  font-size: 22px;
  line-height: 1.25;
  font-weight: 600;
}
.cas-cta p { margin: 0 0 12px; font-size: 16px; line-height: 1.6; color: var(--cp-navy-soft); }
.cas-post-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin: 32px 0 0;
}
@media (max-width: 575.98px) {
  .cas-post-nav { grid-template-columns: 1fr; }
}
.cas-post-nav__link {
  display: block;
  padding: 16px;
  border: 1px solid var(--cp-line);
  border-radius: var(--cp-radius);
  color: var(--cp-navy);
  text-decoration: none;
}
.cas-post-nav__link:hover { border-color: var(--cp-navy); }
.cas-post-nav__link--next { grid-column: 2; text-align: right; }
@media (max-width: 575.98px) {
  .cas-post-nav__link--next { grid-column: 1; }
}
.cas-post-nav__label {
  display: block;
  font-size: 13px;
  line-height: 1.4;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--cp-navy-soft);
}
.cas-post-nav__title {
  display: block;
  margin-top: 4px;
  font-weight: 600;
  line-height: 1.35;
}

/* ---------- Sidebar ---------- */
.cas-sidebar__inner {
  display: flex;
  flex-direction: column;
  gap: 24px;
}
.cas-side-card {
  padding: 20px;
  border-radius: var(--cp-radius);
  background: var(--cp-soft);
}
.cas-side-card .cas-side-title {
  margin: 0 0 12px;
  font-size: 18px;
  line-height: 1.3;
  font-weight: 600;
  color: var(--cp-navy);
}
.cas-side-text {
  margin: 0 0 12px;
  font-size: 14px;
  line-height: 1.5;
  color: var(--cp-navy-soft);
}
.cas-side-list { margin: 0; padding: 0; list-style: none; }
.cas-side-list li + li { border-top: 1px solid var(--cp-line); }
.cas-side-list a {
  display: block;
  padding: 10px 0;
  color: var(--cp-navy);
  font-size: 15px;
  line-height: 1.4;
  text-decoration: none;
}
.cas-side-list a:hover { color: var(--cp-link-hover); text-decoration: underline; }

/* ---------- Check-a-car card ----------
   The one call to action in the sidebar, so it is the dark card (the others are light grey). Its form is the "stacked"
   variant of template-parts/home-search-form.php: visible label, full-width field and button. It does not use the
   homepage stylesheet, so it looks the same on posts, archives and search. Contrast (WCAG AA needs 4.5:1 for text,
   3:1 for focus rings): white on navy 16.1, light text #dcdef0 on navy 12.1, amber on navy 8.2, navy on amber (button)
   8.2, navy on the hover amber 7.2, placeholder #6e6c90 on white 5.0. */
.cas-side-card--cta {
  padding: 24px;
  border: 1px solid transparent;   /* gives the card an edge in forced-colours mode */
  background: var(--cp-navy);
  color: #fff;
  box-shadow: 0 10px 24px rgba(28, 28, 69, 0.16);
}
.cas-side-card--cta .cas-side-eyebrow {
  margin: 0 0 8px;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.4;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--cp-amber);
}
.cas-side-card--cta .cas-side-title {
  margin: 0 0 8px;
  font-size: 22px;
  line-height: 1.25;
  color: #fff;
}
.cas-side-card--cta .cas-side-text {
  max-width: 52ch;
  margin: 0 0 20px;
  font-size: 15px;
  line-height: 1.55;
  color: #dcdef0;
}
.cas-side-form { margin: 0; }
.cas-side-form__label {
  display: block;
  margin: 0 0 6px;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.4;
  color: #fff;
}
.cas-side-form__field {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 48px;
  padding: 0 14px;
  border-radius: 8px;
  background: #fff;
  color: #6e6c90;
}
.cas-side-form__field svg { flex: none; }
.cas-side-form input.cas-side-form__input {
  flex: 1 1 auto;
  width: 100%;
  min-width: 0;
  height: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  outline: 0;
  font: inherit;
  font-size: 16px;                /* 16px stops iOS zooming in on focus */
  line-height: 1.5;
  color: var(--cp-navy);
}
.cas-side-form input.cas-side-form__input::placeholder { color: #6e6c90; opacity: 1; }
.cas-side-form__btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  height: 48px;
  margin: 12px 0 0;
  padding: 0 20px;
  border: 0;
  border-radius: 8px;
  background: var(--cp-amber);
  color: var(--cp-navy);
  font: inherit;
  font-size: 16px;
  font-weight: 600;
  line-height: 1;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: background-color 0.2s;
}
.cas-side-form__btn:hover { background: #f29a12; }
.cas-side-form__check {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--cp-navy);
}
/* Focus rings: white on the navy card (the sidebar's default navy ring would vanish here). */
.cas-side-form__field:focus-within {
  outline: 3px solid #fff;
  outline-offset: 2px;
}
.cas-side-form__btn:focus-visible,
.cas-side-card--cta .cas-side-link:focus-visible {
  outline: 3px solid #fff;
  outline-offset: 2px;
}
.cas-side-card--cta .cas-side-note {
  margin: 14px 0 0;
  font-size: 14px;
  line-height: 1.5;
  color: #dcdef0;
}
.cas-side-card--cta .cas-side-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;               /* comfortable touch target */
  margin-top: 6px;
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
}
.cas-side-card--cta .cas-side-link:hover {
  color: var(--cp-amber);
  text-decoration-thickness: 2px;
}
/* Wide single column (tablet, the sidebar sits under the article): field and button share a row. */
@media (min-width: 576px) and (max-width: 991.98px) {
  .cas-side-card--cta { padding: 28px; }
  .cas-side-form {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    column-gap: 12px;
  }
  .cas-side-form__label { grid-column: 1 / -1; }
  .cas-side-form__btn { width: auto; margin-top: 0; padding: 0 24px; }
}
/* Under 992px the sidebar drops below the article, where the end-of-article card (.cas-cta) has just shown the same form,
   so a second copy is hidden on posts. Archives and search have no end card and keep it. */
@media (max-width: 991.98px) {
  .single-post .cas-side-card--cta { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .cas-side-form__btn { transition: none; }
}
@media (forced-colors: active) {
  .cas-side-form__field { border: 1px solid CanvasText; }
  .cas-side-form__btn { border: 1px solid ButtonText; }
}

/* The sidebar is deliberately not sticky: with the check-a-car card, contents, related posts and guides it is 1,100 to
   1,600px tall, taller than most screens, and a sticky element taller than the screen has its lower cards cut off. */

/* ---------- Kadence Blocks design tokens: brand colours ----------
   Kadence 3.9 reads every default colour from these variables (blue and grey out of the box). html:root is one step
   more specific than the :root rule Kadence prints, so these win whatever the load order. Unused on posts without
   Kadence blocks. Buttons: navy with white text, lighter navy on hover (both pass 4.5:1), outline buttons navy. */
html:root,
html:root:where(.kb-tokens) {
  --kb-token--primitive--color--brand--primary: #1c1c45;
  --kb-token--primitive--color--brand--secondary: #ffa520;
  --kb-token--primitive--color--brand--accent: #ffa520;
  --kb-token--primitive--color--brand--button: #1c1c45;
  --kb-token--primitive--color--brand--button-hover: #3a3a78;
  --kb-token--primitive--color--neutral--900: #1c1c45;
  --kb-token--primitive--color--neutral--700: #34386b;
  --kb-token--primitive--color--neutral--600: #575e8d;
  --kb-token--primitive--color--neutral--500: #6f6c90;
  --kb-token--primitive--color--neutral--300: #c4c6d8;
  --kb-token--primitive--color--neutral--200: #e6e8ee;
  --kb-token--primitive--color--neutral--100: #f5f7fa;
  --kb-token--primitive--color--neutral--50: #fffaf1;
  --kb-token--primitive--color--notice--success: #115b43;
  --kb-token--primitive--color--notice--warning: #b45309;
  --kb-token--primitive--color--notice--error: #bb2020;
  --kb-token--primitive--color--notice--info: #0a58ca;
  --global-palette-btn-bg: #1c1c45;
  --global-palette-btn: #ffffff;
  --global-palette-btn-bg-hover: #3a3a78;
  --global-palette-btn-hover: #ffffff;
}
