/**
 * EveryFiveDays — Single Article System
 * efd-single-article.css  —  Milestone 13
 *
 * Reading progress bar, Skip Through rail, the article typography column
 * and the six editorial components (Research Note, Key Finding, Editor's
 * Take, Practical Takeaway, Product Insight, Pull Quote).
 *
 * Colour and type tokens are read from the Elementor Kit (Kit 5) so there
 * is one source of truth sitewide; the literal after each comma is a
 * fallback only, matching 07_BRAND_GUIDELINES.md, so the file still works
 * standalone (and in a static export served without the kit stylesheet).
 *
 * Everything is scoped under an `efd-` class or id. No bare element
 * selectors — nothing here can reach unrelated WordPress content.
 */

/* ------------------------------------------------------------------ */
/* Tokens                                                              */
/* ------------------------------------------------------------------ */

:root {
  --efd-primary:    var(--e-global-color-primary, #0D1B2A);
  --efd-secondary:  var(--e-global-color-secondary, #1B263B);
  --efd-tertiary:   var(--e-global-color-efd-tertiary, #778DA9);
  --efd-accent:     var(--e-global-color-accent, #415A77);
  --efd-background: var(--e-global-color-efd-background, #E0E1DD);
  --efd-surface:    var(--e-global-color-efd-surface, #FFFFFF);
  --efd-border:     var(--e-global-color-efd-border, #DDE3EA);

  --efd-font-display: var(--e-global-typography-primary-font-family, "Archivo Black"), sans-serif;
  --efd-font-text:    var(--e-global-typography-text-font-family, "Roboto"), sans-serif;

  --efd-radius: 12px;

  /* The article measure. Every member of the reading column — dek, meta
     line, Skip Through rail, article body, disclosure — is sized from this
     one token, so they cannot drift apart. */
  --efd-measure: 700px;

  /* Distance from the top of the viewport that a jumped-to heading must
     clear. JS overwrites this with the measured sticky-header height on
     load, resize and header state change; the literal is the desktop
     resting height, used before JS runs and if JS never runs. */
  --efd-header-offset: 96px;

  --efd-cat-current: var(--efd-accent);
}

/* Per-category accent.
   Archives carry the class on <body> (post_class via the archive query);
   single posts carry it on the Elementor template wrapper instead, which
   is why the `body.` form alone silently did nothing on articles. Both
   are declared, and because these are custom properties they inherit
   down to everything inside either wrapper. */
body.category-sleep-recovery,
.elementor.category-sleep-recovery              { --efd-cat-current: var(--e-global-color-efd-cat-sleep, #1B3B5C); }
body.category-cognitive-performance,
.elementor.category-cognitive-performance       { --efd-cat-current: var(--e-global-color-efd-cat-cognitive, #57508A); }
body.category-fitness-technology,
.elementor.category-fitness-technology          { --efd-cat-current: var(--e-global-color-efd-cat-fitness, #C23A22); }
body.category-productive-workspaces,
.elementor.category-productive-workspaces       { --efd-cat-current: var(--e-global-color-efd-cat-workspace, #2E5A46); }
body.category-smart-pet-care,
.elementor.category-smart-pet-care              { --efd-cat-current: var(--e-global-color-efd-cat-petcare, #C08A1E); }

/* ------------------------------------------------------------------ */
/* Reading progress                                                    */
/* ------------------------------------------------------------------ */

#efd-reading-progress {
  position: fixed;
  inset: 0 0 auto 0;
  height: 3px;
  /* Above the sticky header (z-index 999) but below Xpro's mobile nav
     drawer overlay, so it never paints over an open menu. */
  z-index: 1000;
  pointer-events: none;
  background: transparent;
  /* Hidden until JS confirms the article is actually taller than the
     viewport — a progress meter for content already fully on screen is
     noise. visibility (not display) keeps the fixed element out of flow
     either way, so revealing it cannot shift layout. */
  visibility: hidden;
}

#efd-reading-progress.is-active { visibility: visible; }

.efd-reading-progress__fill {
  height: 100%;
  width: 100%;
  transform: scaleX(0);
  transform-origin: left center;
  background: var(--efd-cat-current);
  will-change: transform;
}

@media (prefers-reduced-motion: no-preference) {
  .efd-reading-progress__fill { transition: transform 80ms linear; }
}

/* ------------------------------------------------------------------ */
/* The article column                                                  */
/* ------------------------------------------------------------------ */

/* Every element in the reading column is centred to the same measure.
   Members below must set vertical spacing with `margin-block`, never the
   `margin` shorthand — a shorthand resets the inline margins to 0 and
   silently un-centres the element. */
.efd-article-dek,
.efd-article-meta,
#efd-skip-through,
.efd-article-content,
.efd-disclosure {
  max-width: var(--efd-measure);
  margin-inline: auto;
}

/* Elementor stamps `max-width: 100%` on every widget, and `min(100%,
   var(--width))` on every top-level container, from custom-frontend.min.css
   — which loads after this file and at a higher weight, so a bare class
   cannot hold the measure. These two selectors restate it at matching
   weight for the only two elements that carry an efd- class on an
   Elementor node: the article body (a widget, boxed or full-width) and the
   Disclosure template (a container). No !important, and nothing here
   applies to any element Elementor did not already style. */
.e-con.e-con > .e-con-inner > .elementor-widget.efd-article-content,
.elementor.elementor .e-con > .elementor-widget.efd-article-content,
.e-con.e-con.efd-disclosure {
  max-width: var(--efd-measure);
  margin-inline: auto;
}

/* Muted foreground, not the accent. The dek sat in accent blue directly above
   the meta line's real author link, so it read as a link that would not click. */
.efd-article-dek {
  font-family: var(--efd-font-text);
  font-size: 20px;
  line-height: 1.55;
  color: var(--efd-muted-fg, #5A6B7F);
  margin-block: 0 12px;
}

.efd-article-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px;
  font-family: var(--efd-font-text);
  font-size: 14px;
  color: var(--efd-tertiary);
  margin-block: 0 16px;
}

.efd-article-meta__sep { opacity: 0.55; }
.efd-article-meta__author { color: var(--efd-secondary); font-weight: 500; }
.efd-article-meta__author a { color: inherit; text-decoration: none; }
.efd-article-meta__author a:hover,
.efd-article-meta__author a:focus-visible { text-decoration: underline; }
.efd-article-meta__time[hidden] { display: none; }

/* "Last updated" — rendered only when a post has genuinely been revised
   since publication, so its presence is information rather than furniture. */
.efd-article-meta__updated { color: var(--efd-tertiary); }

/* ------------------------------------------------------------------ */
/* Skip Through                                                        */
/* ------------------------------------------------------------------ */

/* Ships closed. JS adds .is-ready only once it has built two or more real
   items, so an article with too little structure — or a visitor with JS
   off — never sees an empty bordered box. */
#efd-skip-through { display: none; }
#efd-skip-through.is-ready { display: block; }
#efd-skip-through[hidden] { display: none; }

#efd-skip-through {
  border-top: 1px solid var(--efd-border);
  border-bottom: 1px solid var(--efd-border);
  margin-block: 28px 40px;
}

.efd-skip-through__eyebrow {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--efd-font-text);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--efd-tertiary);
  padding: 14px 0 10px;
  margin: 0;
}

.efd-skip-through__arrow { flex: none; }

#efd-skip-through-list {
  list-style: none;
  margin: 0;
  padding: 0 0 16px;
  display: flex;
  gap: 8px;
  /* The rail is the only thing that scrolls sideways. min-width:0 stops a
     very long heading pill from forcing the flex parent — and with it the
     page — wider than the viewport. */
  min-width: 0;
  max-width: 100%;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scroll-snap-type: x proximity;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}

#efd-skip-through-list::-webkit-scrollbar { height: 4px; }
#efd-skip-through-list::-webkit-scrollbar-thumb {
  background: var(--efd-border);
  border-radius: 4px;
}

.efd-skip-through__item { flex: none; scroll-snap-align: start; max-width: 100%; }

.efd-skip-through__link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--efd-border);
  background: var(--efd-surface);
  font-family: var(--efd-font-text);
  font-size: 14px;
  color: var(--efd-secondary);
  text-decoration: none;
  transition: border-color 120ms ease, color 120ms ease, background-color 120ms ease;
}

.efd-skip-through__link:hover { border-color: var(--efd-cat-current); color: var(--efd-primary); }

.efd-skip-through__link:focus-visible {
  outline: 2px solid var(--efd-cat-current);
  outline-offset: 2px;
}

.efd-skip-through__num {
  flex: none;
  font-weight: 700;
  opacity: 0.55;
  font-variant-numeric: tabular-nums;
}

/* Truncated visually only — the full heading text stays in the DOM, so the
   accessible name is never the ellipsised version. Keeps a 90-character H2
   from producing a pill wider than a phone screen. */
.efd-skip-through__label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 28ch;
}

.efd-skip-through__link.is-active {
  background: var(--efd-cat-current);
  border-color: var(--efd-cat-current);
  color: #fff;
  font-weight: 700;
}

.efd-skip-through__link.is-active .efd-skip-through__num { opacity: 0.85; }

/* Active state must not be carried by colour alone (WCAG 1.4.1): the active
   pill is the only one that shows a leading dot. */
.efd-skip-through__link.is-active::before {
  content: "";
  flex: none;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

@media (forced-colors: active) {
  .efd-skip-through__link { border-color: ButtonBorder; }
  .efd-skip-through__link.is-active { border-width: 2px; forced-color-adjust: none; }
  .efd-reading-progress__fill { background: Highlight; forced-color-adjust: none; }
}

/* Anchor landing offset — driven by the measured header height, not a
   guess, and applied through CSS rather than a JS scroll calculation. */
.efd-article-content h2[id],
.efd-article-content h3[id] {
  scroll-margin-top: calc(var(--efd-header-offset, 96px) + 16px);
}

/* ------------------------------------------------------------------ */
/* Article typography column                                           */
/* ------------------------------------------------------------------ */

.efd-article-content {
  font-family: var(--efd-font-text);
  font-size: 18px;
  line-height: 1.75;
  color: var(--efd-secondary);
}

.efd-article-content p { margin: 0 0 18px; }

.efd-article-content h2 {
  font-family: var(--efd-font-display);
  font-size: clamp(22px, 2.2vw, 27px);
  line-height: 1.3;
  color: var(--efd-primary);
  margin: 34px 0 14px;
}

.efd-article-content h3 {
  font-family: var(--efd-font-display);
  font-size: clamp(18px, 1.7vw, 21px);
  line-height: 1.35;
  color: var(--efd-primary);
  margin: 26px 0 12px;
}

.efd-article-content ul,
.efd-article-content ol { margin: 0 0 18px; padding-left: 1.3em; }

.efd-article-content li + li { margin-top: 8px; }

.efd-article-content img {
  border-radius: var(--efd-radius);
  max-width: 100%;
  height: auto;
  margin: 8px 0;
}

.efd-article-content blockquote {
  margin: 32px 0;
  padding: 4px 0 4px 20px;
  border-left: 3px solid var(--efd-cat-current);
  font-style: italic;
  color: var(--efd-primary);
}

/* CYNTH separates sections with `<hr />` — nine of them in a typical
   generated article — and an unstyled browser rule reads as a mistake. A
   short centred mark instead, sized so it paces the article rather than
   cutting it. */
.efd-article-content hr {
  border: 0;
  width: 64px;
  height: 1px;
  background: var(--efd-border);
  margin: 32px auto;
}

.efd-article-content > *:last-child { margin-bottom: 0; }

@media (max-width: 767px) {
  .efd-article-content { font-size: 17px; line-height: 1.7; }
  .efd-article-content h2 { margin: 28px 0 12px; }
  .efd-article-content h3 { margin: 22px 0 10px; }
  .efd-article-content hr { margin: 36px auto; }
  .efd-article-dek { font-size: 18px; }
}

/* ------------------------------------------------------------------ */
/* Hero image                                                          */
/* ------------------------------------------------------------------ */

.efd-article-hero img {
  width: 100%;
  aspect-ratio: 16 / 9;
  max-height: 480px;
  object-fit: cover;
  border-radius: var(--efd-radius);
}

/* ------------------------------------------------------------------ */
/* Editorial components — shared base                                  */
/* ------------------------------------------------------------------ */

.efd-component {
  margin: 40px 0;
  padding: 24px 28px;
  border-radius: var(--efd-radius);
  border: 1px solid var(--efd-border);
  background: var(--efd-surface);
}

.efd-component__label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--efd-font-text);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin: 0 0 12px;
}

.efd-component__body {
  font-family: var(--efd-font-text);
  font-size: 17px;
  line-height: 1.65;
  color: var(--efd-secondary);
}

.efd-component__body > *:last-child { margin-bottom: 0; }

/* A. Research Note — evidence, not an ad: quiet, documentary */
.efd-component--research-note { background: var(--efd-background); }
.efd-component--research-note .efd-component__label { color: var(--efd-accent); }

.efd-component__source {
  margin: 12px 0 0;
  font-size: 14px;
  color: var(--efd-tertiary);
}

/* B. Key Finding — a conclusion worth pausing on */
.efd-component--key-finding { border-left: 4px solid var(--efd-cat-current); }
.efd-component--key-finding .efd-component__label { color: var(--efd-cat-current); }
.efd-component--key-finding .efd-component__body { font-size: 18px; color: var(--efd-primary); }

/* C. Editor's Take — clearly the publication's own voice, not fact */
.efd-component--editors-take { background: var(--efd-primary); border-color: var(--efd-primary); }
.efd-component--editors-take .efd-component__label { color: var(--efd-background); opacity: 0.7; }
.efd-component--editors-take .efd-component__body { color: #fff; }

/* D. Practical Takeaway — do / avoid */
.efd-component--practical-takeaway .efd-component__label { color: var(--efd-accent); }

.efd-takeaway__row { display: flex; flex-wrap: wrap; gap: 4px 10px; margin-top: 10px; }
.efd-takeaway__row:first-of-type { margin-top: 0; }

.efd-takeaway__row-label { flex: none; font-weight: 700; min-width: 84px; }
.efd-takeaway__row-value { flex: 1 1 220px; min-width: 0; }

.efd-takeaway__row--do    .efd-takeaway__row-label { color: var(--e-global-color-efd-cat-workspace, #2E5A46); }
.efd-takeaway__row--avoid .efd-takeaway__row-label { color: #A8452E; }

/* E. Product Insight — editorially selected, not an advertisement.
   Deliberately has no badge, no countdown and no colour-shouting button:
   the CTA is a text link in the category accent, nothing more. */
.efd-component--product-insight .efd-component__label { color: var(--efd-tertiary); }

.efd-product-insight__name {
  font-family: var(--efd-font-display);
  font-size: 19px;
  line-height: 1.35;
  color: var(--efd-primary);
  margin: 4px 0 12px;
}

.efd-product-insight__field-label {
  font-family: var(--efd-font-text);
  font-weight: 700;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--efd-tertiary);
  margin: 14px 0 2px;
}

.efd-product-insight__field-label:first-of-type { margin-top: 0; }
.efd-product-insight__field-value { margin: 0; }

.efd-product-insight__cta {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 16px;
  font-weight: 700;
  color: var(--efd-cat-current);
  text-decoration: none;
}

.efd-product-insight__cta:hover { text-decoration: underline; }
.efd-product-insight__cta:focus-visible { outline: 2px solid var(--efd-cat-current); outline-offset: 2px; }

.efd-product-insight__pending {
  margin-left: 8px;
  font-weight: 400;
  font-size: 13px;
  color: var(--efd-tertiary);
}

.efd-product-insight__disclosure {
  margin: 14px 0 0;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--efd-tertiary);
}

/* F. Pull Quote — occasional, large, editorial */
.efd-component--pull-quote {
  border: none;
  background: none;
  padding: 8px 0;
}

.efd-component--pull-quote blockquote {
  margin: 0;
  padding: 0;
  border: none;
  font-family: var(--efd-font-display);
  font-size: clamp(26px, 3vw, 34px);
  line-height: 1.3;
  font-style: normal;
  color: var(--efd-primary);
}

.efd-component--pull-quote cite {
  display: block;
  margin-top: 14px;
  font-family: var(--efd-font-text);
  font-style: normal;
  font-size: 14px;
  color: var(--efd-tertiary);
}

@media (max-width: 767px) {
  .efd-component { padding: 20px; }
  .efd-takeaway__row-label { min-width: 100%; }
}

/* ------------------------------------------------------------------ */
/* Affiliate disclosure (existing component 97, restyled in context)   */
/* ------------------------------------------------------------------ */

.efd-disclosure {
  margin-block: 20px 0;
  padding: 12px 16px;
  border-radius: var(--efd-radius);
  background: var(--efd-background);
  font-family: var(--efd-font-text);
  font-size: 14px;
  line-height: 1.5;
  color: var(--efd-tertiary);
}
