/* Article pages (guides). Loaded after styles.css; uses its tokens. Roles and reasons: DESIGN.md */

.art { padding: clamp(1.5rem, 5vw, 3.5rem) 0 var(--section); }
.art__grid { display: grid; grid-template-columns: minmax(0, 1fr); row-gap: var(--s6); }
.art__grid > * { min-width: 0; }

/* ---------- head ---------- */
.art__kicker { font-size: 0.875rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--cinnabar); font-weight: 500; }
.art__kicker a { color: var(--indigo); text-decoration: none; display: inline-flex; align-items: center; min-height: 44px; margin: -0.6rem 0; }
.art__kicker a:hover { text-decoration: underline; }
.art h1 { margin-top: var(--s3); font-size: clamp(2rem, 1.45rem + 2.6vw, 3.15rem); line-height: 1.1; letter-spacing: -0.012em; font-variation-settings: "opsz" 72; max-width: 22em; }
.art__byline { margin-top: var(--s5); padding-top: var(--s3); border-top: 1px solid var(--ink); font-size: 0.875rem; color: var(--ink-2); }
.art__byline a { color: var(--indigo); }

/* ---------- contents ---------- */
.toc { border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); }
.toc summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: var(--s3); min-height: 3rem; font-weight: 500; }
.toc summary::-webkit-details-marker { display: none; }
.toc summary::after { content: "+"; margin-left: auto; color: var(--indigo); font-size: 1.5rem; line-height: 1; transition: transform var(--dur-fast) var(--ease-out); }
.toc[open] summary::after { transform: rotate(45deg); }
.toc__n { font-size: 0.875rem; color: var(--ink-2); font-weight: 400; }
.toc ol { list-style: none; counter-reset: toc; padding-bottom: var(--s3); columns: 2 16rem; column-gap: var(--s6); }
.toc li { counter-increment: toc; position: relative; padding-left: 2rem; break-inside: avoid; }
.toc li::before { content: counter(toc, decimal-leading-zero); position: absolute; left: 0; top: 0.7rem; color: var(--cinnabar); font-size: 0.8125rem; font-variant-numeric: tabular-nums; }
.toc a { color: var(--indigo); display: block; padding: 0.55rem 0; font-size: 0.9375rem; line-height: 1.35; text-decoration: none; }
.toc a:hover { text-decoration: underline; }

/* ---------- prose ---------- */
.prose { max-width: 42rem; }
.prose > * + * { margin-top: var(--s4); }
.prose .lede { font-size: clamp(1.125rem, 1.05rem + 0.35vw, 1.3125rem); line-height: 1.5; }
.prose h2 {
  margin-top: var(--s7); padding-top: var(--s4); border-top: 1px solid var(--ink);
  font-size: clamp(1.45rem, 1.2rem + 1vw, 1.875rem); line-height: 1.2; letter-spacing: -0.006em; font-variation-settings: "opsz" 48;
}
.prose h3 { margin-top: var(--s6); font-size: 1.1875rem; line-height: 1.3; font-weight: 600; }
.prose h2 + *, .prose h3 + * { margin-top: var(--s3); }
.prose a { color: var(--indigo); }
.prose strong { font-weight: 600; }
.prose ul, .prose ol { padding-left: 0; list-style: none; display: grid; gap: var(--s3); }
.prose ul > li { position: relative; padding-left: 1.25rem; }
.prose ul > li::before { content: ""; position: absolute; left: 0.1rem; top: 0.68em; width: 0.4em; height: 0.4em; background: var(--cinnabar); }
.prose ol { counter-reset: item; }
.prose ol > li { counter-increment: item; position: relative; padding-left: 1.75rem; }
.prose ol > li::before { content: counter(item); position: absolute; left: 0; color: var(--cinnabar); font-variant-numeric: lining-nums; }
.prose .tagline { font-size: 0.9375rem; color: var(--ink-2); }
.prose .tagline strong { font-weight: 500; }
.prose .tlabel { margin-top: var(--s5); font-size: 0.8125rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-2); }
.prose .tlabel strong { font-weight: 500; }
.prose .tlabel + .tbl { margin-top: var(--s2); }
.qa .q { display: block; font-weight: 600; margin-bottom: var(--s1); }
.prose h2 + .qa, .prose .qa + .qa { margin-top: var(--s5); }

code { font-family: inherit; font-size: 0.9375em; background: var(--paper-sunk); padding: 0.05em 0.3em; overflow-wrap: anywhere; }
.formula { font-family: var(--font); margin: var(--s4) 0 0; background: var(--paper-sunk); border-left: 2px solid var(--ink); padding: var(--s4); white-space: pre-wrap; overflow-wrap: anywhere; font-size: 0.9375rem; line-height: 1.5; font-variant-numeric: tabular-nums; }
.formula code { background: none; padding: 0; font-size: inherit; }

/* ---------- tables: the almanac frame (ink outer rule, hairline inner rule) ---------- */
.tbl, .pillars { margin-top: var(--s5); border: 1px solid var(--ink); padding: 3px; overflow-x: auto; overscroll-behavior-x: contain; container: tbl / inline-size; }
/* scroll shadows: a soft edge appears only on the side that has more table to scroll to */
.tbl, .pillars {
  background:
    linear-gradient(to right, var(--paper) 40%, transparent) left / 1.5rem 100% no-repeat local,
    linear-gradient(to left, var(--paper) 40%, transparent) right / 1.5rem 100% no-repeat local,
    linear-gradient(to right, rgb(31 27 23 / 0.16), transparent) left / 0.6rem 100% no-repeat scroll,
    linear-gradient(to left, rgb(31 27 23 / 0.16), transparent) right / 0.6rem 100% no-repeat scroll,
    var(--paper);
}
.tbl table, .pillars table { width: 100%; border-collapse: collapse; border: 1px solid var(--rule); font-size: 0.9375rem; line-height: 1.4; font-variant-numeric: lining-nums; }
.tbl th, .tbl td { text-align: left; vertical-align: top; padding: 0.55rem 0.7rem; border-top: 1px solid var(--rule); }
.tbl th + th, .tbl th + td, .tbl td + td, .tbl td + th { border-left: 1px solid var(--rule); }
.tbl thead th { border-top: 0; border-bottom: 1px solid var(--ink); font-size: 0.8125rem; font-weight: 500; letter-spacing: 0.04em; color: var(--ink-2); vertical-align: bottom; }
.tbl thead tr + tr th, .tbl tbody tr:first-child > * { border-top: 0; }
.tbl tbody th { font-weight: 600; }
.tbl .num { white-space: nowrap; }
.tbl a { color: var(--indigo); }
.tbl td :lang(zh-Hans), .tbl th :lang(zh-Hans) { white-space: nowrap; }
.tbl--c2 { max-width: 34rem; }
.tbl--kv tbody th { width: 38%; color: var(--ink-2); font-weight: 400; }
.tbl--kv tbody td { font-weight: 500; }
.tbl:focus-visible, .pillars:focus-visible { outline-offset: 2px; }

@container tbl (max-width: 30rem) {
  .tbl table { font-size: 0.875rem; }
  .tbl th, .tbl td { padding: 0.5rem 0.45rem; }
  .tbl thead th { font-size: 0.75rem; letter-spacing: 0.02em; }
}

.tnote { font-size: 0.875rem; color: var(--ink-2); line-height: 1.5; }
.prose .tbl + .tnote, .prose .pillars + .tnote, .prose .formula + .tnote { margin-top: var(--s3); }

/* two half-tables printed side by side */
.tbl-pair { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--s4); margin-top: var(--s5); }
.tbl-pair .tbl { margin-top: 0; }
@media (min-width: 40rem) { .tbl-pair { grid-template-columns: 1fr 1fr; } }

/* rows that carry sentences: a table when wide, labelled blocks when narrow */
@container tbl (max-width: 34rem) {
  .tbl--stack table, .tbl--stack tbody, .tbl--stack tr, .tbl--stack th, .tbl--stack td { display: block; }
  .tbl--stack thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .tbl--stack tr { padding: var(--s3) 0.7rem; }
  .tbl--stack tr + tr { border-top: 1px solid var(--rule); }
  .tbl--stack th, .tbl--stack td { border: 0 !important; padding: 0; }
  .tbl--stack th { font-size: 1rem; }
  .tbl--stack td { margin-top: var(--s2); }
  .tbl--stack td[data-label]::before { content: attr(data-label); display: block; font-size: 0.75rem; letter-spacing: 0.04em; color: var(--ink-2); }
}

/* the years chart: one compact block per year on narrow screens */
.tbl--years tbody td:first-child { font-weight: 600; }
.tbl--years table { font-size: 0.875rem; }
.tbl--years th, .tbl--years td { white-space: nowrap; padding-left: 0.55rem; padding-right: 0.55rem; }
.tbl--years thead th { white-space: normal; }
@media (min-width: 64rem) {
  /* wide enough to show whole rows: let the header stick under the masthead while reading down 108 years */
  .tbl--years { overflow: visible; }
  .tbl--years thead th { position: sticky; top: calc(3.5rem + 1px); z-index: 1; background: var(--paper); box-shadow: 0 1px 0 var(--ink); }
}
@container tbl (max-width: 38rem) {
  .tbl--years table, .tbl--years tbody { display: block; }
  .tbl--years thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .tbl--years tr { display: grid; grid-template-columns: 3.4rem minmax(0, 1fr) minmax(0, 1fr); column-gap: var(--s3); row-gap: var(--s1); padding: var(--s3) 0.7rem; }
  .tbl--years tr + tr { border-top: 1px solid var(--rule); }
  .tbl--years td { border: 0 !important; padding: 0; white-space: normal; }
  .tbl--years td:nth-child(1) { grid-row: 1 / span 3; font-size: 1.125rem; line-height: 1.3; }
  .tbl--years td:nth-child(2) { grid-column: 2; }
  .tbl--years td:nth-child(3) { grid-column: 3; }
  .tbl--years td:nth-child(n+4)::before { content: attr(data-label); display: block; font-size: 0.75rem; color: var(--ink-2); }
  .tbl--years td:nth-child(4) { grid-column: 2; }
  .tbl--years td:nth-child(5) { grid-column: 3; }
  .tbl--years td:nth-child(6) { grid-column: 2 / span 2; }
}

@container tbl (max-width: 15em) {
  .tbl--years tr { grid-template-columns: minmax(0, 1fr); }
  .tbl--years td:nth-child(n) { grid-column: 1; grid-row: auto; }
}

/* ---------- sample chart: the four pillars ---------- */
.pillars table { table-layout: fixed; text-align: center; }
.pillars thead th { font-size: 0.8125rem; font-weight: 500; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-2); padding: var(--s3) 0.2rem var(--s2); border-bottom: 1px solid var(--ink); }
.pillars thead td { width: 4.6rem; border-bottom: 1px solid var(--ink); }
.pillars tbody th { font-size: 0.75rem; font-weight: 500; letter-spacing: 0.03em; text-transform: uppercase; color: var(--ink-2); text-align: left; vertical-align: middle; padding: 0 0.45rem; overflow-wrap: normal; hyphens: none; }
.pillars td { vertical-align: top; padding: var(--s4) 0.2rem var(--s3); }
.pillars tr + tr > * { border-top: 1px solid var(--rule); }
.pillars th + td, .pillars td + td, .pillars thead th + th, .pillars thead td + th { border-left: 1px solid var(--rule); }
.pillars .pz { display: block; font-size: clamp(2.25rem, 1.8rem + 2vw, 3rem); line-height: 1.1; font-weight: 600; }
.pillars .pl { display: block; margin-top: var(--s1); font-size: 0.8125rem; line-height: 1.3; color: var(--ink-2); }
.pillars .is-dm { position: relative; }
/* very large text on a narrow screen: columns take the width they need and the chart scrolls sideways */
@container tbl (max-width: 14em) {
  .pillars table { table-layout: auto; width: max-content; min-width: 100%; }
  .pillars td { min-width: 4.5em; }
}
.pillars .is-dm::after { content: ""; position: absolute; inset: 6px; border: 1.5px solid var(--cinnabar); pointer-events: none; }

/* ---------- the way to your own chart ---------- */
.next { border-top: 1px solid var(--ink); padding-top: var(--s3); }
.next__label { font-size: 0.8125rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-2); font-weight: 500; }
.next ul { list-style: none; }
.next__item { padding: var(--s2) 0 var(--s4); border-bottom: 1px solid var(--rule); }
.next__title { color: var(--indigo); font-weight: 600; font-size: 1.0625rem; line-height: 1.35; display: block; padding: 0.6rem 0 0.35rem; }
.next__title::after { content: "→"; display: inline-block; margin-left: 0.3em; }
.next__meta { font-size: 0.8125rem; color: var(--ink-2); font-variant-numeric: lining-nums; }
.next__item p:last-child { margin-top: var(--s1); font-size: 0.9375rem; color: var(--ink-2); }
.next__item .next__meta + p { margin-top: var(--s1); }

/* ---------- how this page was made + sources ---------- */
.colophon { max-width: 42rem; border-top: 1px solid var(--ink); padding-top: var(--s4); font-size: 0.875rem; color: var(--ink-2); line-height: 1.55; }
.colophon__label { font-size: 0.8125rem; letter-spacing: 0.08em; text-transform: uppercase; font-weight: 500; color: var(--ink); }
h2.colophon__label { margin-top: var(--s5); }
.colophon a { color: var(--indigo); overflow-wrap: anywhere; }
.sources { list-style: none; margin-top: var(--s2); display: grid; gap: var(--s2); }
.sources li { padding-left: 1rem; position: relative; }
.sources li::before { content: ""; position: absolute; left: 0; top: 0.62em; width: 0.35em; height: 0.35em; background: var(--rule-strong); }

/* ---------- free calculator (/free-chinese-birth-chart/) ---------- */
.tool-form { max-width: 42rem; }
.tool-result:focus-within h2:focus { outline: none; }
.tool-result .tool-animals { margin-top: var(--s4); }
.tool-result .animals__row { gap: 0; }
.tool-result .animals__cell { padding-left: 0.15rem; }
.tool-result .animals__cell::before { content: none; }
.tool-result .animals .el { font-size: 0.8125rem; color: var(--ink-2); }
.tool-result .animals .el span[lang] { font-size: 1rem; }
.tool-result .animals .tool-stem { margin-top: var(--s1); font-size: 0.75rem; }
.tool-notes li strong { font-weight: 600; }
.tool-steps { border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); padding: var(--s2) 0; }
.tool-steps summary { cursor: pointer; min-height: 44px; display: flex; align-items: center; gap: 0.3em; flex-wrap: wrap; }
.tool-steps ol, .tool-steps p { margin-top: var(--s3); }
.tool-steps[open] { padding-bottom: var(--s4); }
.tool-share { display: flex; flex-wrap: wrap; gap: var(--s3); }
.tool-result #t-name-field { max-width: 20rem; }
.share-status:empty { display: none; }
.share-status { font-size: 0.875rem; color: var(--ink-2); }

/* ---------- wide screens: sticky side column for the way to your own chart ---------- */
@media (min-width: 64rem) {
  .art__grid { grid-template-columns: minmax(0, 44rem) 15.5rem; justify-content: space-between; column-gap: var(--s7); }
  .art__grid > * { grid-column: 1; }
  .art__grid > .next { grid-column: 2; grid-row: 1 / span 5; align-self: start; position: sticky; top: 5rem; }
}
