/* chem/_engine/chem-trends.css — periodic-trend colouring (pairs with chem-trends.js; loads after chem-ui.css) */
.chem-ptwrap{--tr-navy:#16294a;--tr-navy2:#2c4478;--tr-gold:#F5A623;--tr-mute:#5c6b86;--tr-line:#e8ecf1}

/* ---- tiles ---- */
.chem-ptwrap .chem-el{transition:background-color .22s ease-out,color .22s ease-out,opacity .22s ease-out,transform .08s}
.chem-ptwrap.trend-on .chem-el[data-trend] .sy,
.chem-ptwrap.trend-on .chem-el[data-trend] .z,
.chem-ptwrap.trend-on .chem-el[data-trend] .ar{color:var(--tcol,var(--tr-navy))}
.chem-ptwrap.trend-on .chem-el[data-trend] .z,
.chem-ptwrap.trend-on .chem-el[data-trend] .ar{opacity:.82}
.chem-ptwrap.trend-on .chem-el[data-trend] .ar{font-weight:700;letter-spacing:-.01em}
.chem-ptwrap.trend-on .chem-el.trend-na{background:repeating-linear-gradient(135deg,#eceff4 0 3px,#f7f8fb 3px 6px);--tcol:#8a97ad}
.chem-ptwrap.trend-on .chem-el.trend-dim{opacity:.38;filter:saturate(.2)}
.chem-ptwrap.trend-on .chem-el.trend-dim:hover{opacity:1;filter:none}

/* ---- group / period highlight (ChemTrends.highlight) ---- */
.chem-ptwrap .chem-el.hl-g,.chem-ptwrap .chem-el.hl-p{box-shadow:inset 0 0 0 1.5px rgba(22,41,74,.55);z-index:1}
.chem-ptwrap .chem-el.hl-g.hl-p{box-shadow:inset 0 0 0 2px var(--tr-navy),0 0 0 2px rgba(245,166,35,.6)}
.chem-ptwrap .chem-el.hl-off{opacity:.35;filter:saturate(.4)}
.chem-ptwrap .chem-el.hl-off:hover{opacity:1;filter:none}

/* ---- "Colour by" control ---- */
.chem-trend-ctl{position:relative;display:inline-flex;margin-left:auto}
.chem-trend-btn{display:inline-flex;align-items:center;gap:4px;min-height:30px;white-space:nowrap}
.chem-trend-btn b{font-weight:800}
.chem-trend-btn .car{font-size:9px;opacity:.7;margin-left:1px}
.chem-trend-btn.on{background:var(--tr-navy);color:#fff;border-color:var(--tr-navy)}
.chem-trend-btn:focus-visible,.chem-trend-opt:focus-visible{outline:2px solid var(--tr-gold);outline-offset:2px}

.chem-trend-pop{position:absolute;top:calc(100% + 6px);right:0;z-index:20;width:300px;background:#fff;border:1px solid var(--tr-line);border-radius:14px;padding:10px;box-shadow:0 18px 44px -18px rgba(26,45,74,.45),0 0 0 1px rgba(26,45,74,.03);animation:chemTrendIn .18s ease-out;transform-origin:top right}
.chem-trend-pop[hidden]{display:none}
.chem-trend-title{font-size:10.5px;font-weight:700;letter-spacing:.06em;text-transform:uppercase;color:var(--tr-mute);padding:2px 4px 8px}
.chem-trend-grid{display:grid;grid-template-columns:repeat(4,1fr);gap:6px}
.chem-trend-opt{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:3px;min-height:52px;padding:6px 2px;border:1px solid var(--tr-line);border-radius:10px;background:#fafbfd;color:var(--tr-navy2);font:600 10.5px/1.1 Poppins,system-ui,sans-serif;cursor:pointer;transition:background-color .16s,border-color .16s,transform .16s}
.chem-trend-opt i{display:inline-flex;align-items:center;justify-content:center;min-width:22px;height:22px;padding:0 5px;border-radius:7px;background:#eef2f8;color:var(--tr-navy);font:800 10px/1 Poppins,system-ui,sans-serif;font-style:normal}
.chem-trend-opt span{max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.chem-trend-opt:hover{background:#f1f5fb;border-color:#cfd8e6}
.chem-trend-opt:active{transform:scale(.97)}
.chem-trend-opt.on{background:var(--tr-navy);border-color:var(--tr-navy);color:#fff}
.chem-trend-opt.on i{background:var(--tr-gold);color:var(--tr-navy)}

/* bottom sheet on narrow hosts */
.chem-trend-back{position:fixed;inset:0;z-index:60;background:rgba(22,41,74,.28);animation:chemTrendFade .18s ease-out}
.chem-trend-back[hidden]{display:none}
.chem-trend-pop.sheet{position:fixed;top:auto;right:0;left:0;bottom:0;z-index:61;width:auto;border-radius:18px 18px 0 0;padding:12px 14px calc(14px + env(safe-area-inset-bottom,0px));box-shadow:0 -12px 40px -16px rgba(26,45,74,.5);animation:chemTrendUp .22s ease-out;transform-origin:bottom center}
.chem-trend-pop.sheet::before{content:"";display:block;width:36px;height:4px;border-radius:2px;background:#d7dde8;margin:0 auto 10px}
.chem-trend-pop.sheet .chem-trend-grid{grid-template-columns:repeat(3,1fr);gap:8px}
.chem-trend-pop.sheet .chem-trend-opt{min-height:56px;font-size:12px}

/* ---- legend ---- */
.chem-legend .chem-trend-leg{display:flex;align-items:center;gap:8px;flex-wrap:wrap;width:100%;font-size:10.5px;color:var(--tr-mute)}
.chem-trend-leg .bar{position:relative;display:inline-block;flex:1 1 140px;max-width:260px;height:10px;border-radius:5px;box-shadow:inset 0 0 0 1px rgba(22,41,74,.08)}
.chem-trend-leg .bar em{position:absolute;left:50%;top:-3px;height:16px;border-left:1.5px solid rgba(22,41,74,.55);font:600 9px/1 Poppins,system-ui,sans-serif;font-style:normal;color:var(--tr-mute);padding-left:3px;white-space:nowrap;transform:translateX(-1px)}
.chem-trend-leg .lo,.chem-trend-leg .hi{font-weight:700;color:var(--tr-navy)}
.chem-trend-leg .unit{opacity:.85}
.chem-trend-leg .na i{display:inline-block;width:10px;height:10px;border-radius:3px;margin-right:4px;vertical-align:-1px;background:repeating-linear-gradient(135deg,#dfe4ec 0 2px,#f7f8fb 2px 4px)}
.chem-trend-leg .sw i{display:inline-block;width:10px;height:10px;border-radius:3px;margin-right:4px;vertical-align:-1px;box-shadow:inset 0 0 0 1px rgba(22,41,74,.08)}
.chem-trend-leg .rank{display:inline-flex;align-items:center;flex-wrap:wrap;gap:2px}
.chem-trend-leg .rank b{display:inline-block;min-width:22px;padding:2px 4px;border-radius:6px;text-align:center;font-weight:800;font-size:10px}
.chem-trend-leg .rank b.ref{opacity:.75;border:1px dashed rgba(22,41,74,.4);background:#fff!important;color:var(--tr-navy)!important}
.chem-trend-leg .rank u{text-decoration:none;opacity:.5;font-size:9px}
.chem-trend-leg .mn{flex-basis:100%;font-style:italic;opacity:.8}
.chem-legend .chem-trend-cap{flex-basis:100%;font-size:11px;line-height:1.45;color:#3a4a66;padding-top:2px}
.chem-trend-cap b{color:var(--tr-navy);font-weight:700}
.chem-trend-why{display:inline}
.chem-trend-why summary{display:inline-block;list-style:none;cursor:pointer;font-weight:700;color:#2563eb;padding:2px 6px;border-radius:6px;min-height:24px;line-height:20px}
.chem-trend-why summary::-webkit-details-marker{display:none}
.chem-trend-why summary:hover{background:#eef3ff}
.chem-trend-why[open] summary{color:var(--tr-navy)}
.chem-trend-why p{margin:6px 0 0;padding:8px 10px;background:#fafbfd;border-left:3px solid var(--tr-gold);border-radius:0 8px 8px 0;color:#3a4a66}

/* ---- trend arrows (SVG overlay in the empty block above groups 3–12) ---- */
.chem-trend-arrows{position:absolute;pointer-events:none;color:rgba(22,41,74,.55);overflow:visible;animation:chemTrendFade .3s ease-out;z-index:1}
.chem-trend-arrows line{stroke:currentColor;stroke-width:1.4;stroke-linecap:round}
.chem-trend-arrows text{fill:currentColor;font:600 10px/1 Poppins,system-ui,sans-serif}

/* ---- tooltip ---- */
.chem-trend-tip{position:absolute;z-index:7;transform:translate(-50%,-100%);background:#0f172a;color:#fff;font:500 11px/1.2 Poppins,system-ui,sans-serif;padding:5px 8px;border-radius:8px;white-space:nowrap;pointer-events:none;box-shadow:0 10px 24px -12px rgba(0,0,0,.5);animation:chemTrendFade .14s ease-out}
.chem-trend-tip b{font-weight:700;margin-right:4px}
.chem-trend-tip::after{content:"";position:absolute;left:50%;bottom:-4px;width:8px;height:8px;background:inherit;transform:translateX(-50%) rotate(45deg)}
@media (hover:none){.chem-trend-tip{display:none}}

/* ---- chalk (dark board) parent ---- */
.chem.chalk .chem-trend-pop{background:#1b2740;border-color:#2b3a5e}
.chem.chalk .chem-trend-opt{background:#233252;border-color:#2b3a5e;color:#dbe4f5}
.chem.chalk .chem-trend-opt i{background:#2c4478;color:#fff}
.chem.chalk .chem-trend-title,.chem.chalk .chem-legend .chem-trend-cap,.chem.chalk .chem-trend-why p{color:#c7d2e6;background:transparent}
.chem.chalk .chem-trend-arrows{color:rgba(255,255,255,.55)}

@keyframes chemTrendIn{from{opacity:0;transform:translateY(-4px) scale(.98)}to{opacity:1;transform:none}}
@keyframes chemTrendUp{from{opacity:0;transform:translateY(24px)}to{opacity:1;transform:none}}
@keyframes chemTrendFade{from{opacity:0}to{opacity:1}}
@media (prefers-reduced-motion:reduce){
  .chem-ptwrap .chem-el,.chem-trend-opt{transition:none}
  .chem-trend-pop,.chem-trend-pop.sheet,.chem-trend-back,.chem-trend-arrows,.chem-trend-tip{animation:none}
}
