/* public/styles/article.css: article pictures and the article sidebar (ArticleLayout links this file itself).
   Not bundled on purpose: [...slug].astro imports ArticleLayout, so bundled CSS would also ship on every tutorial
   page. The base article styles (toc, tables, STEPS strip) live in src/styles/global.css; the sticky toc bar and
   the back-to-top button live at the end of this file. */

/* featured picture: a tutorial's finished drawing (square, unlike the 3:2 hub photos) */
.art-hero { margin: 0; justify-self: center; max-width: 360px; width: 100%; }
.art-hero img { display: block; width: 100%; height: auto; aspect-ratio: 1; border-radius: var(--radius-lg); border: 6px solid #fff; box-shadow: 0 6px 0 var(--accent-sun); background: #fff; }
.art-hero figcaption { margin-top: var(--space-3); font-size: .9375rem; color: var(--color-text-2); text-align: center; }
@media (max-width: 899px) { .art-hero { max-width: 300px; } }

/* sidebar layout: the reading column keeps its width, tables stop breaking out under the sidebar */
.post-side .with-side-main { min-width: 0; container-type: inline-size; }
.post-side .with-side-aside { margin-block: var(--space-5) var(--space-6); }
@media (min-width: 1100px) {
  /* tables use the whole main column (wider than the reading width), never run under the sidebar */
  .post-side .post-body .table-wrap { width: 100cqw; max-width: none; }
  .post-side .table-wrap thead th { white-space: normal; }
  .post .side-post { max-height: calc(100vh - 112px); overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; padding: 2px 6px 6px 2px; }
}
.post-body > h2, .post-body > h3, .post-body .table-wrap, .post-body .step-strip, .post-body .guide-figure { clear: both; }

/* listicle item picture: floats beside the item text; the caption link covers the picture */
.item-thumb { position: relative; float: right; width: 112px; margin: var(--space-1) 0 var(--space-3) var(--space-4); text-align: center; }
.item-thumb img { display: block; width: 100%; height: auto; aspect-ratio: 1; border: 1px solid var(--color-line); border-radius: var(--radius-md); background: #fff; box-shadow: 0 3px 0 var(--art-green); }
.item-thumb figcaption { margin-top: var(--space-2); font-size: .8125rem; line-height: 1.3; font-weight: 700; }
.item-thumb a::after, .guide-figure a::after { content: ""; position: absolute; inset: 0; }
.item-thumb:hover img, .guide-figure:hover img { box-shadow: 0 0 0 3px var(--color-primary); }
@media (min-width: 600px) { .item-thumb { width: 150px; } }

/* guide picture between sections */
.guide-figure { position: relative; display: grid; gap: var(--space-3); align-items: center; margin: var(--space-5) 0 var(--space-6); padding: var(--space-4); background: var(--color-surface); border: 1px solid var(--color-line); border-top: 6px solid var(--art-orange); border-radius: var(--radius-md); }
.guide-figure img { display: block; width: 100%; max-width: 260px; height: auto; aspect-ratio: 1; margin-inline: auto; border-radius: var(--radius-sm); background: #fff; border: 1px solid var(--color-line); }
.guide-figure figcaption { display: grid; gap: var(--space-1); text-align: center; }
.guide-figure a { font: 600 1.125rem/1.3 var(--font-display); }
.guide-figure-k { font-size: .8125rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--color-text-2); }
.guide-figure-n { font-size: .9375rem; color: var(--color-text-2); }
@media (min-width: 600px) {
  .guide-figure { grid-template-columns: 200px 1fr; }
  .guide-figure img { max-width: none; }
  .guide-figure figcaption { text-align: left; }
}

/* sidebar boxes */
.side-box { padding: var(--space-4) var(--space-3); background: #fff; border: 2px solid var(--color-line); border-radius: var(--radius-lg); }
.side-box-h { margin: 0 0 var(--space-3); font-size: 1.1rem; }
.side-list { display: grid; gap: var(--space-2); list-style: none; margin: 0; padding: 0; }
.side-list a { display: grid; grid-template-columns: 48px 1fr; gap: var(--space-3); align-items: center; padding: 4px; border-radius: var(--radius-md); font-weight: 700; line-height: 1.3; }
.side-list a:hover { background: var(--color-surface); }
.side-list img { width: 48px; height: 48px; object-fit: cover; border-radius: var(--radius-sm); }
.side-dot { width: 48px; height: 48px; border-radius: var(--radius-sm); background: var(--band-sky); }
.side-thumbs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-2); list-style: none; margin: 0; padding: 0; }
.side-thumbs a { display: grid; gap: 4px; justify-items: center; font-size: .8125rem; font-weight: 700; line-height: 1.2; text-align: center; }
.side-thumbs img { width: 100%; height: auto; aspect-ratio: 1; border: 1px solid var(--color-line); border-radius: var(--radius-sm); background: #fff; }
.side-thumbs a:hover img { box-shadow: 0 0 0 2px var(--color-primary); }

/* phones and tablets: the sidebar follows the body; shop picks show here, the book card is the opt-in below */
@media (max-width: 1099px) {
  .post-side .side-post { display: grid; gap: var(--space-4); }
  .post-side .with-side-aside .shop-side { display: block; }
  .post-side .with-side-aside .book-card { display: none; }
  .side-thumbs { grid-template-columns: repeat(3, minmax(0, 120px)); }
}
@media print { .item-thumb, .guide-figure, .post-side .with-side-aside { display: none; } }

/* "On this page" sticky bar (ArticleToc + src/scripts/article-toc.ts). JS removes [hidden]; .is-on shows it once
   the in-flow list has scrolled away. Phones/tablets: full width under the sticky site header (--toc-y, 0 while
   the header hides). >=1100px: over the article column only (--toc-l/--toc-w), so it never covers the sidebar. */
.post-body h2[id], .post-body h3[id], .post #faq { scroll-margin-top: var(--toc-offset, 7.5rem); }
.toc-bar { position: fixed; z-index: 45; top: 0; left: 0; right: 0; transform: translateY(var(--toc-y, 0px)); visibility: hidden; opacity: 0; transition: transform 220ms var(--ease), opacity 160ms var(--ease), visibility 0s linear 160ms; }
.toc-bar.is-on { visibility: visible; opacity: 1; transition: transform 220ms var(--ease), opacity 160ms var(--ease), visibility 0s; }
.toc-bar-in { background: #fff; border-bottom: 2px solid var(--color-line); border-left: 6px solid var(--art-sky); box-shadow: 0 6px 16px rgb(38 15 9 / .10); padding-left: env(safe-area-inset-left); padding-right: env(safe-area-inset-right); }
.toc-bar-btn { display: flex; align-items: center; gap: var(--space-3); width: 100%; min-height: 48px; margin: 0; padding: var(--space-2) var(--gutter); background: transparent; border: 0; color: var(--color-text); font: inherit; text-align: left; cursor: pointer; }
.toc-bar-btn:focus-visible { outline: 3px solid var(--color-primary); outline-offset: -3px; border-radius: var(--radius-sm); }
.toc-bar-k { flex: none; font: 600 .8125rem/1.2 var(--font-display); text-transform: uppercase; letter-spacing: .04em; color: var(--color-text-2); }
.toc-bar-cur { flex: 1 1 auto; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-weight: 700; line-height: 1.3; }
.toc-bar-chev { flex: none; margin-left: auto; transition: transform 160ms var(--ease); }
.toc-bar.is-open .toc-bar-chev { transform: rotate(180deg); }
.toc-bar-panel { position: relative; max-height: 60vh; max-height: 60dvh; overflow-y: auto; overscroll-behavior: contain; border-top: 1px solid var(--color-line); padding: var(--space-2) var(--gutter) var(--space-3); }
.toc-bar-panel[hidden] { display: none; }
.toc-bar-panel ol { margin: 0; padding: 0 0 0 1.6em; }
.toc-bar-panel li { line-height: 1.35; }
.toc-bar-panel a { display: block; padding: 10px var(--space-2); border-radius: var(--radius-sm); color: var(--color-text); text-decoration: none; font-weight: 700; }
.toc-bar-panel a:hover { background: var(--color-surface); text-decoration: underline; }
.toc-bar-panel a[aria-current] { background: var(--band-sky); box-shadow: inset 4px 0 0 var(--color-primary); }
.toc-bar-panel li:has(a[aria-current])::marker { color: var(--color-primary); }
.post-body [tabindex="-1"]:focus:not(:focus-visible) { outline: none; }
@media (min-width: 1100px) {
  .toc-bar { left: var(--toc-l, 0px); right: auto; width: var(--toc-w, 100%); padding-top: var(--space-2); }
  .toc-bar-in { border: 2px solid var(--color-line); border-left: 6px solid var(--art-sky); border-radius: var(--radius-md); overflow: hidden; }
  .toc-bar-btn { padding-inline: var(--space-4); }
  .toc-bar-panel { padding-inline: var(--space-4); }
}

/* Back to top (BackToTop + src/scripts/back-to-top.ts): appears after about one screen, clear of the safe area */
.to-top { position: fixed; z-index: 44; right: max(var(--space-4), env(safe-area-inset-right)); bottom: max(var(--space-4), calc(env(safe-area-inset-bottom) + var(--space-3))); display: grid; place-items: center; width: 48px; height: 48px; padding: 0; background: #fff; color: var(--color-text); border: 2px solid var(--color-text); border-radius: 50%; box-shadow: 0 3px 0 var(--color-text); cursor: pointer; visibility: hidden; opacity: 0; transform: translateY(8px); transition: opacity 160ms var(--ease), transform 160ms var(--ease), visibility 0s linear 160ms; }
.to-top.is-on { visibility: visible; opacity: 1; transform: none; transition: opacity 160ms var(--ease), transform 160ms var(--ease), visibility 0s; }
.to-top:hover { background: var(--band-sky); }
.to-top:focus-visible { outline: 3px solid var(--color-primary); outline-offset: 3px; }
/* >=1100px: right edge of the article column (--tt-x from the script), clear of the sticky sidebar */
@media (min-width: 1100px) { .to-top { bottom: var(--space-6); } .to-top--col { right: auto; left: calc(var(--tt-x) - 48px); } }
@media (prefers-reduced-motion: reduce) { .toc-bar, .toc-bar.is-on, .toc-bar-chev, .to-top, .to-top.is-on { transition: none; } .to-top { transform: none; } }
@media print { .toc-bar, .to-top { display: none !important; } }
