/* ==========================================================================
   Article Template — MyRoomTool Blog
   Page shell only. Slots filled later from article data.
   Container, type, spacing, divider → Foundation.

   Hero v2 (standard): desktop — H1+TOC overlay on cover; mobile ≤768 — H1 above cover, TOC on image.
   Theme via article.mrt hero.theme → .hero--light | .hero--dark (manual; no auto-detect).
   ========================================================================== */

.article-template {
  width: 100%;
  padding-block: var(--space-s) 0;
}

/* Compact vertical rhythm for the upper article shell */
.article-template__shell {
  display: flex;
  flex-direction: column;
  gap: var(--space-s);
  /* Small gap before the full-bleed afterword rule */
  padding-bottom: var(--space-m);
}

/* Permanent afterword: Share → divider → Recommendations (inside .container) */
.article-template__afterword {
  display: flex;
  flex-direction: column;
  width: 100%;
  padding-block: 0 var(--space-xxl);
}

/* Container rule under Share: tight above (panel air from Share), normal below → recommendations */
.article-template__afterword > .divider {
  margin-top: 0;
  margin-bottom: var(--space-l);
}

.article-template__back {
  margin: 0;
}

.article-template__back-link {
  color: var(--color-text);
  transition: color var(--duration-normal) var(--ease-standard);
}

.article-template__back-link:hover {
  color: var(--color-accent);
  opacity: 1;
}

/* --------------------------------------------------------------------------
   Hero v2 — desktop overlay; mobile: H1 above cover, TOC on image only
   -------------------------------------------------------------------------- */

.article-template__categories {
  margin: 0 0 var(--space-s);
}

.article-template__categories .category-badge {
  pointer-events: auto;
}

.article-template__categories[hidden],
.article-template__categories:empty {
  display: none !important;
}

.article-template__hero-region {
  position: relative;
  width: 100%;
  margin-top: 0;
}

.article-template__hero-media {
  position: relative;
  width: 100%;
}

.article-template__hero-cover {
  display: block;
  width: 100%;
  aspect-ratio: 21 / 9;
  object-fit: cover;
  border-radius: var(--radius-md);
}

.article-template__hero-cover--placeholder,
.hero--no-cover .article-template__hero-cover--placeholder {
  background-color: #223245;
}

/* Desktop: H1 overlays the cover. */
.article-template__hero-title {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 2;
  box-sizing: border-box;
  width: 100%;
  max-width: min(66.666%, 38rem);
  margin: 0;
  padding: var(--space-xl) var(--space-l) var(--space-l) var(--space-xl);
  pointer-events: none;
}

/* Light (default) — white title for dark covers */
.hero--light .article-template__hero-title,
.article-template__hero-region:not(.hero--dark) .article-template__hero-title {
  color: #ffffff;
  text-shadow:
    0 1px 2px rgba(34, 50, 69, 0.4),
    0 6px 20px rgba(34, 50, 69, 0.45);
}

/* Dark — brand text for light covers */
.hero--dark .article-template__hero-title {
  color: var(--color-text);
  text-shadow: none;
}

/* Publication meta: reading time + date — immediately below Hero */
.article-template__publication {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-s);
  margin: 0;
  color: var(--color-text-muted, var(--color-text));
}

.article-template__meta-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.article-template__meta-icon {
  display: block;
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  object-fit: contain;
}

.article-template__meta-divider {
  display: inline-block;
  width: 1px;
  height: 0.9em;
  background: var(--color-divider);
  flex-shrink: 0;
}

/*
  TOC — text-only on cover; pinned to bottom of hero-media.
  No card / background. Arrow markers. Max 6 items (Builder).
*/
.article-template__toc {
  position: absolute;
  left: 0;
  bottom: 0;
  z-index: 2;
  box-sizing: border-box;
  margin: 0;
  padding: 0 var(--space-l) var(--space-l) var(--space-xl);
  width: auto;
  max-width: min(66.666%, 38rem);
  max-height: 100%;
  overflow-x: hidden;
  overflow-y: auto;
  background: transparent;
  border: none;
  border-radius: 0;
  box-shadow: none;
  pointer-events: auto;
}

.article-template__toc.editorial-accent-bar {
  border-left: none !important;
}

.article-template__toc-list {
  margin: 0;
  padding: 0;
  display: grid;
  gap: var(--space-xs);
  list-style: none;
}

.article-template__toc-list > li {
  display: flex;
  align-items: flex-start;
  gap: 0.5em;
}

.article-template__toc-list > li::before {
  content: "";
  flex-shrink: 0;
  box-sizing: border-box;
  width: 0;
  height: 0;
  margin-top: 0.45em;
  border-style: solid;
  border-width: 0.22em 0 0.22em 0.38em;
  border-color: transparent transparent transparent var(--color-accent);
}

.article-template__toc-list a {
  text-decoration: none;
}

.article-template__toc-list a:hover {
  color: var(--color-accent);
}

.hero--light .article-template__toc-list,
.hero--light .article-template__toc-list a,
.article-template__hero-region:not(.hero--dark) .article-template__toc-list,
.article-template__hero-region:not(.hero--dark) .article-template__toc-list a {
  color: #ffffff;
  text-shadow:
    0 1px 2px rgba(34, 50, 69, 0.35),
    0 4px 12px rgba(34, 50, 69, 0.35);
}

.hero--dark .article-template__toc-list,
.hero--dark .article-template__toc-list a {
  color: var(--color-text);
  text-shadow: none;
}

.hero--light .article-template__toc-list a:hover,
.article-template__hero-region:not(.hero--dark) .article-template__toc-list a:hover,
.hero--dark .article-template__toc-list a:hover {
  color: var(--color-accent);
}

.article-template__intro {
  width: 100%;
  margin-top: 0;
}

.article-template__body,
.article-template__share,
.article-template__recommendations {
  width: 100%;
}

/* Empty slots collapse until content is injected */
.article-template__hero-title:empty,
.article-template__publication:empty,
.article-template__toc:empty,
.article-template__intro:empty,
.article-template__body:empty,
.article-template__share:empty,
.article-template__recommendations:empty {
  display: none;
}

@media (max-width: 768px) {
  /*
    Mobile Hero: H1 above cover; only TOC overlays the image.
    hero-media is the positioning context so TOC cannot escape the cover plane.
  */
  .article-template__hero-region {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: var(--space-s);
  }

  .article-template__hero-title {
    position: static;
    z-index: auto;
    width: 100%;
    max-width: none;
    padding: 0;
    color: var(--color-text);
    text-shadow: none;
    pointer-events: auto;
  }

  .hero--light .article-template__hero-title,
  .article-template__hero-region:not(.hero--dark) .article-template__hero-title,
  .hero--dark .article-template__hero-title {
    color: var(--color-text);
    text-shadow: none;
  }

  .article-template__hero-media {
    position: relative;
    width: 100%;
  }

  .article-template__hero-cover {
    width: 100%;
    aspect-ratio: 21 / 9;
    object-fit: cover;
  }

  .article-template__toc {
    left: 0;
    right: auto;
    bottom: 0;
    width: auto;
    max-width: calc(100% - var(--space-m) * 2);
    max-height: 100%;
    padding: var(--space-m) var(--space-m) var(--space-m) var(--space-s);
    overflow-y: auto;
  }
}
