/* The analyses built on the price archive (/compare, /analysis, /ratios and
   /tools/periodic-buying). They share the look of the history reports
   (history-report.css, the hr-* classes); this file adds what those do not have:
   tabs without a script, forms, the costs table and the lists of differences.
   Nothing here sets a colour of its own; it uses the tokens of style.css. */

.an-page .hr-note,.an-page .an-p{max-width:75ch}
.an-p{margin:0 0 10px;font-size:14.5px;line-height:2;color:var(--text)}
.an-h3{margin:22px 0 4px;font-size:16px;font-weight:650;color:var(--ink)}
.an-draft{border-style:dashed;border-color:var(--stale);color:var(--stale)}
.an-checked{color:var(--muted);white-space:nowrap}

/* ---- the two sides of a chart: a line and the area under it ---- */
.an-page .hr-lines .area{stroke:none}
.an-page .hr-lines .area.l1{fill:color-mix(in srgb,var(--brand) 14%,transparent)}
.an-page .hr-lines .area.l2{fill:color-mix(in srgb,var(--gold) 16%,transparent)}
.an-page .hr-lines .l4,.an-page .sw.l4{stroke:var(--chg-up);background:var(--chg-up)}
.an-page .hr-lines .ln.l4{stroke-dasharray:2 3}
.an-page .hr-key .sw.l4{height:4px}
.an-page .hr-chart .ptl{pointer-events:none}

/* ---- tabs: radio buttons, so they work without a script ---- */
.an-tabs{margin:6px 0 0}
.an-tab-in{position:absolute;opacity:0;width:1px;height:1px;margin:0;pointer-events:none}
.an-tab-l{display:inline-flex;align-items:center;min-height:38px;margin:0 0 8px 6px;padding:0 14px;border:1px solid var(--line);border-radius:999px;background:var(--surface);color:var(--muted);font-size:13.5px;cursor:pointer;user-select:none}
.an-tab-l:hover{border-color:var(--line-strong);color:var(--ink)}
.an-tab-in:checked+.an-tab-l{border-color:var(--brand);background:var(--brand-soft);color:var(--ink);font-weight:650}
.an-tab-in:focus-visible+.an-tab-l{outline:2px solid var(--brand);outline-offset:2px}
.an-panels{display:block}
.an-panel{display:none}
.an-tabs>.an-tab-in:nth-of-type(1):checked~.an-panels>.an-panel:nth-child(1),
.an-tabs>.an-tab-in:nth-of-type(2):checked~.an-panels>.an-panel:nth-child(2),
.an-tabs>.an-tab-in:nth-of-type(3):checked~.an-panels>.an-panel:nth-child(3),
.an-tabs>.an-tab-in:nth-of-type(4):checked~.an-panels>.an-panel:nth-child(4),
.an-tabs>.an-tab-in:nth-of-type(5):checked~.an-panels>.an-panel:nth-child(5),
.an-tabs>.an-tab-in:nth-of-type(6):checked~.an-panels>.an-panel:nth-child(6),
.an-tabs>.an-tab-in:nth-of-type(7):checked~.an-panels>.an-panel:nth-child(7),
.an-tabs>.an-tab-in:nth-of-type(8):checked~.an-panels>.an-panel:nth-child(8){display:block}

/* ---- the waterfall ---- */
.an-wf .wf-bar.tot{fill:var(--faint);opacity:.7}
.an-wf .wf-bar.up{fill:var(--chg-up)}
.an-wf .wf-bar.down{fill:var(--chg-down)}
.an-wf .wf-bar.flat{fill:var(--faint)}
.an-wf .wf-v{font-size:12.5px;font-weight:650;fill:var(--ink);paint-order:stroke;stroke:var(--bg);stroke-width:4px;stroke-linejoin:round}
.an-wf .wf-n{font-size:12px;fill:var(--muted)}
.an-wf .wf-link{stroke:var(--line-strong);stroke-width:1;stroke-dasharray:3 3}
.an-unit{margin:0 0 4px;font-size:12.5px;color:var(--muted)}

/* ---- drawdown episodes ---- */
.an-eps tr.an-open th,.an-eps tr.an-open td{background:color-mix(in srgb,var(--chg-down) 8%,var(--surface))}
.an-eps td,.an-buys td{vertical-align:top}
.an-bands li{grid-template-columns:minmax(90px,.8fr) minmax(110px,2fr) minmax(80px,auto)}
.an-more{margin-top:10px}
.an-more summary{cursor:pointer;min-height:44px;display:flex;align-items:center;font-weight:600;color:var(--brand)}
.an-more[open] summary{margin-bottom:8px}
.an-count{justify-self:end;font-size:13px;color:var(--muted)}

/* ---- the steps of a worked example ---- */
.an-steps{display:grid;gap:10px;margin:8px 0 0;padding:0;list-style:none;counter-reset:none}
.an-steps li{padding:12px 16px;border:1px solid var(--line);border-radius:12px;background:var(--surface)}
.an-steps h3{margin:0 0 2px;font-size:15px;color:var(--ink)}
.an-steps .f{margin:2px 0;font-size:13.5px;color:var(--muted)}
.an-steps .n{margin:2px 0;font-size:14px;line-height:2;color:var(--text);overflow-wrap:anywhere}
.an-steps .nt{margin:2px 0 0;font-size:12.5px;line-height:1.9;color:var(--muted)}

/* ---- a grid of cases ---- */
.an-grid th,.an-grid td{white-space:nowrap;text-align:center}
.an-grid tbody th{text-align:start}
.an-grid td.is-base{background:var(--brand-soft);font-weight:650}
.an-grid td small{display:block;font-size:11.5px;color:var(--muted)}

/* ---- tables whose cells hold sentences ---- */
.an-costs td,.an-costs th{white-space:normal;vertical-align:top;min-width:200px;line-height:1.9}
.an-costs tbody th{min-width:130px}
.an-ret td,.an-roll td,.an-bud td,.an-sens td{vertical-align:top}
.an-ret .an-dates{white-space:normal;min-width:190px}
.an-ret .an-arrow{color:var(--faint);padding:0 4px}
.an-ret td small.n{display:block;font-size:12px;color:var(--muted);white-space:normal}
.an-ret tr.st-gap th,.an-ret tr.st-gap td{background:var(--surface-2);color:var(--muted);white-space:normal}
.an-bud td small.n{display:block;font-size:12.5px;color:var(--muted);white-space:normal}
.an-bud .an-total th,.an-bud .an-total td{border-top:2px solid var(--line-strong)}
.an-val{display:inline-flex;flex-direction:column;align-items:flex-start;gap:2px}
.an-val>.chg{align-self:flex-start}
.an-ref{display:inline-block;min-width:24px;height:24px;margin:0 2px;padding:0 6px;border:1px solid var(--line-strong);border-radius:12px;font-size:11.5px;line-height:22px;text-align:center;text-decoration:none;vertical-align:text-top;color:var(--brand)}
.an-ref:hover{border-color:var(--brand);background:var(--brand-soft)}
.an-refs{margin:12px 0 0;padding-inline-start:22px;font-size:13px;line-height:1.95;color:var(--muted)}
.an-refs li{margin-bottom:8px;max-width:80ch}
.an-refs a{color:var(--brand);text-decoration:underline;text-underline-offset:3px}
.an-refs li:target{background:color-mix(in srgb,var(--brand) 12%,transparent);border-radius:6px}

/* ---- the differences and who each asset suits ---- */
.an-diffs{display:grid;grid-template-columns:repeat(auto-fit,minmax(260px,1fr));gap:12px;margin:8px 0 0;padding:0;list-style:none}
.an-diffs li{padding:14px 16px;border:1px solid var(--line);border-radius:12px;background:var(--surface)}
.an-diffs h3{margin:0 0 4px;font-size:15px;font-weight:650;color:var(--ink)}
.an-diffs p{margin:0;font-size:13.5px;line-height:1.95;color:var(--text)}
.an-diffs .hr-link{margin-top:6px;font-size:13.5px}
.an-suits{display:grid;grid-template-columns:repeat(auto-fit,minmax(280px,1fr));gap:14px;margin-top:18px}
.an-suit{padding:16px 18px;border:1px solid var(--line);border-top:3px solid var(--brand);border-radius:12px;background:var(--surface)}
.an-suit:nth-child(2){border-top-color:var(--gold)}
.an-suit h3{margin:0 0 6px;font-size:16px;color:var(--ink)}
.an-suit ul{margin:0;padding-inline-start:20px;font-size:14px;line-height:2;color:var(--text)}
.an-limit{margin:8px 0 0;font-size:13.5px;line-height:1.95;color:var(--muted)}
.an-limit b{color:var(--ink)}

/* ---- the form of a calculator ---- */
.an-form{margin:12px 0 18px;padding:16px 18px;border:1px solid var(--line);border-radius:12px;background:var(--surface-2)}
.an-fields{display:grid;grid-template-columns:repeat(auto-fit,minmax(170px,1fr));gap:12px 14px}
.an-form label{display:flex;flex-direction:column;gap:4px;font-size:13px;color:var(--muted)}
.an-form input,.an-form select{width:100%;min-height:44px;padding:0 12px;border:1px solid var(--line-strong);border-radius:10px;background:var(--surface);color:var(--ink);font:inherit;font-size:15px}
.an-form input{direction:ltr;text-align:right}
.an-form input:focus-visible,.an-form select:focus-visible{outline:2px solid var(--brand);outline-offset:1px}
.an-form fieldset{margin:0;padding:0;border:0;min-width:0}
.an-actions{display:flex;flex-wrap:wrap;align-items:center;gap:10px 18px;margin-top:14px}
.an-btn{min-height:44px;padding:0 24px;border-radius:999px;background:var(--ink);color:var(--bg);font:inherit;font-size:14.5px;font-weight:650;cursor:pointer}
.an-btn:hover{opacity:.88}
.an-btn:focus-visible{outline:2px solid var(--brand);outline-offset:2px}
.an-results{display:grid;gap:8px;margin:14px 0 0;padding:0;list-style:none}
.an-results li{display:flex;flex-wrap:wrap;align-items:baseline;gap:4px 14px;padding:12px 16px;border:1px solid var(--line);border-radius:12px;background:var(--surface)}
.an-results .l{flex:1 1 280px;color:var(--text);line-height:1.9}
.an-results b{font-size:19px;color:var(--ink)}
.an-results small{flex:1 1 100%;font-size:12.5px;color:var(--muted)}
.an-form .hint{font-size:11.5px;color:var(--muted)}
.an-facts td,.an-facts th{white-space:normal;vertical-align:top;line-height:1.9}
.an-facts tbody th{min-width:150px}
.an-links{display:flex;flex-wrap:wrap;gap:6px 18px;margin:8px 0 0;padding:0;list-style:none;font-size:14px}
.an-links a{display:inline-flex;align-items:center;min-height:32px;color:var(--brand);text-decoration:underline;text-underline-offset:3px}

/* ---- the periodic-buying tool ---- */
.an-per td,.an-std td,.an-led td,.an-ex td{vertical-align:top}
.an-per td small.n,.an-std td small.n,.an-led td small.n{display:block;font-size:12px;color:var(--muted);white-space:normal}
.an-per .an-total th,.an-per .an-total td{border-top:2px solid var(--line-strong);font-weight:650}
.an-led .an-dates{white-space:normal;min-width:150px}
.an-led th[scope="row"]{text-align:center}
.an-std td.st-gap{background:var(--surface-2);white-space:normal;min-width:140px}
.an-std .an-val{gap:6px}
.an-pair{display:flex;align-items:center;gap:8px}
.an-pair small.n{min-width:44px}

@media (max-width:720px){
  .an-tab-l{min-height:44px}
  /* a table with many short values: two to a line, the name above each value */
  .an-stack.an-cols tr{display:grid;grid-template-columns:1fr 1fr;gap:0 16px}
  .an-stack.an-cols tbody th,.an-stack.an-cols td.an-dates{grid-column:1 / -1}
  .an-stack.an-cols td{flex-direction:column;justify-content:flex-start;gap:2px;border-top:1px dashed var(--line)}
  .an-stack.an-cols td::before{max-width:none}
  /* the episodes: three short numbers to a line, the date of the recovery across */
  .an-stack.an-cols3 tr{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:0 10px}
  .an-stack.an-cols3 tbody th,.an-stack.an-cols3 td.an-dates,.an-stack.an-cols3 td[data-label="جبران در"]{grid-column:1 / -1}
  .an-stack.an-cols3 td{flex-direction:column;justify-content:flex-start;gap:2px;font-size:13.5px}
  .an-stack.an-cols3 td::before{max-width:none;font-size:11.5px}
  .an-stack.an-cols3 td[data-label="جبران در"]{flex-direction:row;justify-content:space-between;align-items:baseline}
  .an-form{padding:14px 12px}
  .an-page .hr-card:nth-child(4){grid-column:auto}
  .an-page .hr-card.is-main{grid-column:1 / -1}
  /* a table of sentences becomes one block per row: the label, then each value under its own name */
  .an-stack{overflow:visible;border:0}
  .an-stack table,.an-stack tbody,.an-stack tr,.an-stack th,.an-stack td{display:block;width:auto;min-width:0}
  .an-stack thead{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap}
  .an-stack tr{margin:0 0 10px;padding:10px 14px;border:1px solid var(--line);border-radius:12px;background:var(--surface)}
  .an-stack tbody th{position:static;padding:0 0 6px;border:0;background:none;white-space:normal;font-size:15px}
  .an-stack td{display:flex;justify-content:space-between;align-items:flex-start;gap:12px;padding:6px 0;border:0;border-top:1px dashed var(--line);white-space:normal}
  .an-stack td::before{content:attr(data-label);flex:none;max-width:42%;font-size:12.5px;font-weight:600;color:var(--muted)}
  .an-stack td[colspan]{display:block}
  .an-stack td[colspan]::before{display:block;margin-bottom:2px}
  .an-stack .an-val{align-items:flex-end;text-align:end}
  .an-stack td.an-dates{display:block}
  .an-stack td.an-dates::before{display:none}
  .an-stack tr.st-gap td{display:block}
  .an-stack tr.st-gap td::before{display:none}
  .an-stack .an-total{border-color:var(--line-strong)}
  .an-stack .an-bud .an-total th,.an-stack .an-bud .an-total td{border-top:0}
  .an-stack .an-per .an-total th,.an-stack .an-per .an-total td{border-top:0}
  .an-stack .an-per .an-total td{font-weight:650}
  .an-std td.st-gap{display:block}
  .an-std td.st-gap::before{display:none}
  .an-pair{justify-content:flex-end}
  /* the form of the periodic tool: short fields side by side */
  .an-fields-12{grid-template-columns:repeat(12,minmax(0,1fr));gap:12px 10px}
  .an-fields-12>label{grid-column:span 4}
  .an-fields-12>label:nth-child(1){grid-column:span 12}
  .an-fields-12>label:nth-child(3){grid-column:span 5}
  .an-fields-12>label:nth-child(4){grid-column:span 3}
  .an-fields-12>label:nth-child(5),.an-fields-12>label:nth-child(6){grid-column:span 6}
  .an-ledger.an-stack tr{padding:8px 12px;margin-bottom:8px}
  .an-ledger.an-stack tbody th{padding:0 0 2px;text-align:start;font-size:13.5px}
  .an-ledger.an-stack td{padding:4px 0}
}
