/* Professional article header card (see _includes/article-header-card.html).
   Token mapping (spec "Map to" column), all existing site values:
     accent bar / focus ring  var(--accent-primary)       Key Takeaways border colour
     accent text (light)      #1A6B5A                     /blog/'s --lib-accent; --accent-primary
                                                          is ~3:1 on white, below AA for small text
     accent text (dark)       var(--accent-primary)       ~6.7:1 on the dark page
     surface                  var(--bg-primary)           page background
     ink / ink-2 / muted      --text-primary / -secondary / -tertiary
     border                   var(--bg-tertiary)          FAQ item border
     hover                    var(--bg-secondary)         back-link background
     radius-card / menu       var(--radius-md)            hero image radius
     shadow-menu              var(--shadow-medium)
     record-line label        uppercase 0.8rem / 600 / 0.04em, as .share-label
     fonts                    inherited (Inter body)      no new font */

.ahc {
  --ahc-accent-text: #1A6B5A;
  --ahc-border: var(--bg-tertiary);
  position: relative;
  margin: 1.5rem 0 0;
  padding: 0; /* styles.css gives every <section> 8rem vertical padding */
  background: var(--bg-primary);
  border: 1px solid var(--ahc-border);
  border-radius: var(--radius-md);
  /* Accent bar drawn as an inset shadow so it follows the corner radius. */
  box-shadow: inset 3px 0 0 var(--accent-primary);
}
[data-theme="dark"] .ahc { --ahc-accent-text: var(--accent-primary); }

/* With the card, the header's own divider would sit directly under a bordered
   box; the card takes over that separation. */
.blog-article-header.blog-article-header--card {
  border-bottom: 0;
  padding-bottom: 0;
  margin-bottom: 2rem;
}

/* ---- Row 1: record line ---- */
.ahc-record {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.35rem 1.5rem;
  padding: 0.85rem 1.5rem;
  border-bottom: 1px solid var(--ahc-border);
  font-size: 0.8rem;
  font-weight: 600;
  line-height: 1.5;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.ahc-record-group {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0 0.5rem;
  margin: 0;
}
/* Two classes: outranks styles.css's [data-theme="dark"] p { color } rule. */
.ahc .ahc-record-lead { color: var(--ahc-accent-text); }
.ahc .ahc-record-meta { color: var(--text-tertiary); }
.ahc-sep { opacity: 0.8; }
.ahc-record a {
  color: inherit;
  text-decoration: none;
  border-radius: 2px;
}
.ahc-record a:hover { text-decoration: underline; text-underline-offset: 3px; }

/* ---- Row 2: actions ---- */
.ahc-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem;
  padding: 0.5rem 1rem 0.5rem 1.1rem;
}
.ahc-menu-wrap { position: relative; }
.ahc-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: 44px;
  padding: 0.5rem 0.85rem;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  font: inherit;
  font-size: 0.95rem;
  font-weight: 500;
  line-height: 1.2;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}
.ahc-action:hover { background: var(--bg-secondary); color: var(--text-primary); }
.ahc-cally {
  margin-left: auto;
  color: var(--ahc-accent-text);
  font-weight: 600;
}
.ahc-cally:hover { color: var(--ahc-accent-text); }
.ahc-chevron { transition: transform 0.12s ease; }
.ahc-action[aria-expanded="true"] .ahc-chevron { transform: rotate(180deg); }
.ahc-action[aria-expanded="true"] { background: var(--bg-secondary); color: var(--text-primary); }
.ahc-action[disabled] { cursor: progress; opacity: 0.7; }

/* Focus: visible 2px ring, never removed. */
.ahc a:focus-visible,
.ahc button:focus-visible,
.ahc textarea:focus-visible {
  outline: 2px solid var(--accent-primary);
  outline-offset: 2px;
}

/* ---- Menus ---- */
.ahc-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 60;
  width: 310px;
  max-width: calc(100vw - 32px);
  padding: 0.4rem;
  background: var(--bg-primary);
  border: 1px solid var(--ahc-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-medium);
  animation: ahc-fade 0.12s ease-out;
}
.ahc-menu[hidden] { display: none; }
@keyframes ahc-fade { from { opacity: 0; } to { opacity: 1; } }
.ahc-item {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0 0.3rem;
  width: 100%;
  min-height: 44px;
  padding: 0.55rem 0.8rem;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-primary);
  font: inherit;
  font-size: 0.95rem;
  line-height: 1.35;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}
.ahc-item:hover,
.ahc-item:focus { background: var(--bg-secondary); color: var(--text-primary); }
.ahc-item[disabled] { cursor: progress; opacity: 0.7; }
.ahc-menu-sep { height: 1px; margin: 0.35rem 0.4rem; background: var(--ahc-border); }
.ahc-menu-foot { color: var(--text-tertiary); font-size: 0.9rem; }
.ahc-menu-foot:hover, .ahc-menu-foot:focus { color: var(--text-tertiary); }
.ahc-accent { color: var(--ahc-accent-text); font-weight: 600; }

.ahc-scrim {
  position: fixed;
  inset: 0;
  z-index: 2147483001; /* above the Cally launcher (2147483000) while a sheet is open */
  background: rgba(2, 6, 23, 0.5); /* --bg-primary (dark) at 50% */
  animation: ahc-fade 0.12s ease-out;
}
.ahc-scrim[hidden] { display: none; }

/* ---- Clipboard fallback ---- */
.ahc-fallback {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
  padding: 0.75rem 1.5rem 1rem;
  border-top: 1px solid var(--ahc-border);
}
.ahc-fallback[hidden] { display: none; }
.ahc-fallback-label { flex: 1 0 100%; font-size: 0.85rem; color: var(--text-tertiary); }
.ahc-fallback-text {
  flex: 1 1 12rem;
  min-width: 0;
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--ahc-border);
  border-radius: var(--radius-sm);
  background: var(--bg-secondary);
  color: var(--text-primary);
  font: inherit;
  font-size: 0.85rem;
  resize: vertical;
}
.ahc-fallback-done {
  min-height: 44px;
  padding: 0.5rem 1rem;
  border: 1px solid var(--ahc-border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  font: inherit;
  font-size: 0.9rem;
  cursor: pointer;
}
.ahc-fallback-done:hover { background: var(--bg-secondary); }

/* ---- No JS: menus become plain link lists; JS-only controls hidden ---- */
.ahc:not(.ahc--js) [data-ahc-js] { display: none; }
.ahc:not(.ahc--js) .ahc-menu-wrap { flex: 1 1 100%; }
.ahc:not(.ahc--js) .ahc-menu {
  position: static;
  width: auto;
  max-width: none;
  border: 0;
  box-shadow: none;
  padding: 0;
  animation: none;
  display: flex;
  flex-wrap: wrap;
}
.ahc:not(.ahc--js) .ahc-item { width: auto; }
.ahc:not(.ahc--js) .ahc-menu::before {
  content: attr(aria-label);
  flex: 1 0 100%;
  padding: 0.25rem 0.8rem 0;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-tertiary);
}

/* ---- 640–899px: record line may wrap; actions wrap only if needed ---- */
@media (max-width: 899px) {
  .ahc-record { justify-content: flex-start; }
}

/* ---- < 640px: stacked record line, 2×2 action grid, bottom sheets ---- */
@media (max-width: 639px) {
  .ahc-record {
    flex-direction: column;
    align-items: flex-start;
    padding: 0.8rem 1rem 0.8rem 1.15rem;
  }
  .ahc-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1px;
    padding: 0;
    margin-left: 3px; /* keep the accent bar visible */
    background: var(--ahc-border); /* shows through the 1px gaps as dividers */
    border-bottom-right-radius: calc(var(--radius-md) - 1px);
    overflow: hidden;
  }
  .ahc:not(.ahc--js) .ahc-actions { display: block; background: none; }
  .ahc-menu-wrap { display: flex; }
  .ahc-action {
    width: 100%;
    min-height: 48px;
    margin: 0;
    border-radius: 0;
    background: var(--bg-primary);
  }
  .ahc-cally { margin-left: 0; }
  .ahc-item { min-height: 48px; }
  .ahc--js .ahc-menu {
    position: fixed;
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 2147483002;
    width: auto;
    max-width: none;
    max-height: 80vh;
    overflow-y: auto;
    padding: 0.6rem 0.6rem calc(0.6rem + env(safe-area-inset-bottom, 0px));
    border-width: 1px 0 0;
    border-radius: var(--radius-md) var(--radius-md) 0 0;
    transform: none !important;
  }
  .ahc-fallback { padding: 0.75rem 1rem 1rem 1.15rem; }
}

@media (prefers-reduced-motion: reduce) {
  .ahc-menu, .ahc-scrim { animation: none; }
  .ahc-chevron, .ahc-action { transition: none; }
  .ahc-action[aria-expanded="true"] .ahc-chevron { transform: none; }
}
