﻿/*
 CharChem CSS file
*/
/* Periodic system table */
.mentable { border-collapse:collapse; margin-top:5px; line-height:1;}
.mentable td { text-align:center; padding:5px 2px;}
.mentable td.chem-element { width:4em; max-width:4em; border:1px #000 solid; }
.mentable td.chem-row { border-top:1px #000 solid; border-bottom:1px #000 solid;}
.mentable td.chem-cell { border:1px #000 solid; }
.mentable td.chem-cell.noleft {border-left:none;}
.mentable td.chem-cell.noright {border-right:none;}
.mentable td.group-id { vertical-align:bottom;}
.mentable td.period-id { vertical-align:center; border:1px #000 solid;}
.mentable-text {font-size:12px;}
.mentable-subgroup-hd {vertical-align:bottom; height:100%; font-size:12px;}
.mentable-subgroup-hd .left {float:left; margin-left:0.5em;}
.mentable-subgroup-hd .right {float:right; margin-right:0.5em;}
.chem-element .number { float:left; font-size:12px;}
.chem-element.subgr_b .number { float:right;}
.chem-element .id { font-weight:bold; }
.chem-element.subgr_a .id { float:right; margin-right:0.5em;}
.chem-element.subgr_b .id { float:left; margin-left:0.5em;}
.chem-element .name { font-size:10px; color:#555; font-family:Arial; clear:both;}
.chem-element .mass { font-size:12px; color:#777;}


.chem-element.s_block { background-color:#FCF;}
.chem-element.p_block { background-color:#FFC;}
.chem-element.d_block { background-color:#CCF;}
.chem-element.f_block { background-color:#CFC;}

/* colors from wikipedia */
.chem-element.Alkali-metals { background-color:#F66;}
.chem-element.Alkaline-earth-metals { background-color:#FFDEAD;}
.chem-element.Lanthanides {background-color:#FFBFFF;}
.chem-element.Actinides {background-color:#F9C;}
.chem-element.Transition-metals { background-color:#FFC0C0;}
.chem-element.Post-transition-metals {background-color:#CCC;}
.chem-element.Metalloids {background-color:#CC9;}
.chem-element.Other-nonmetals {background-color:#A0FFA0;}
.chem-element.Halogens {background-color:#FF9;}
.chem-element.Noble-gases {background-color:#C0FFFF;}
.chem-element.Unknown-props {background-color:#E8E8E8;}

/* Easy chemistry style https://chemistry-easy.ru/ */
.easy-chem-table { color: #231a1d; }
.easy-chem-table .chem-element.s_block { background-color: #d2748e;}
.easy-chem-table .chem-element.p_block { background-color: #f6dd5f;}
.easy-chem-table .chem-element.d_block { background-color: #7fc1db;}
.easy-chem-table .chem-element.f_block { background-color: #c3d9b3;}
.easy-chem-table .chem-element.f2_block { background-color: #9cbd86;}
.easy-chem-table .chem-element .element-box .id { grid-area: id; font-size: 150%; font-weight: 200; text-align: left; }
.easy-chem-table .element-box .number { grid-area: number; font-size: 105%; text-align: right; }
.easy-chem-table .element-box .name { grid-area: name; font-size: 58%; text-align: left; color: inherit; }
.easy-chem-table .element-box .mass { grid-area: mass; font-size: 85%; text-align: left; color: inherit; padding: 2px 0;}
.easy-chem-table .element-box {
    display: grid;
    grid-template-areas: 
        "id number"
        "mass mass"
        "name name";
    grid-template-columns: 1fr auto;
    grid-template-rows: auto;
}
.easy-chem-table .chem-element.mtbl-note { width: auto; }

/* ======================================================================= */
.echem-formula {font-family: Cambria, Times, Serif}
/* ======================================================================= */

/* -------- deprecated from ver 2.2. used for makeTextFormula ------------------- */
.echem-formula b {font-weight: normal; padding-right: 0.15em;}
.echem-formula i, .echem-formula em {font-style: normal;}
.echem-comment {color:blue;}
.echem-opcomment { font-size:80%; display:block;}
.echem-op {display:inline-block; text-align:center; line-height:0.8; vertical-align: middle;}
/* atom charge. over atom id */
.echem-item-charge { 
    display: inline-block;
    font-size: 0.7em;
    left: -1em;
    position: relative;
    top: -0.5em;
    width: 0.1em;
    white-space: nowrap;
}
/* Atomic mass and number of the left of the element. Example: $nM(16)O*/
.echem-mass-and-num 
{
	display:inline-block;
	margin-bottom:-0.3em;
	vertical-align:-0.4em;
	line-height:1.2em;
	font-size:70%;
	text-align:right;
    letter-spacing: -0.05em;
}
.chem-long-arrow {
    display: inline-block;
    text-align: center;
    width: 3em;
    transform: scaleX(3);
    font-family: Times, serif;
}

/* ---------------------- buildHtmlRich. v2.2 --------------------------- */

.cch-expr {
    --col-height: 0.3em;
    --col-top: calc(-1*(var(--col-height) + 0.4em));
    --op-comm-dy: 0.3em;
    --op-comm2-dy: calc(0.5em - var(--op-comm-dy)); /* for head+footer both */
    --op-comm1-dy: calc(1em - var(--op-comm2-dy));  /* for head only or footer only */
    --arr-begin-pad: 0.2em;  /* begin--------->end */
    --arr-end-pad: 0.4em;
    --arr-both-pad: var(--arr-end-pad); /* For double-headed arrows, the indents are the same. Otherwise, you can see the offset between the top and bottom comments. */
}

span.echem-formula {
    display: inline-block;
}
div.echem-formula {
    display: block;
}
  
.cch-expr { 
    gap: 0.3em;
    flex-wrap: wrap;
    display: inline-flex;
    align-items: baseline;
}
.cch-expr * {
    line-height: 1;
    margin: 0;
    padding: 0;
    box-sizing: content-box;
}
  
.cch-agent  {
    display: inline-flex;
    align-items: baseline;
}
.cch-node-item, .cch-symbols {
    display: inline-flex;
    align-items: baseline;
}
  
/* If the agent contains elements with oxidation states, then a place must be reserved at the top. 
The oxidation states will rise there via the absolute position. */
.cch-has-over {
    padding-top: var(--col-height);
}
.cch-agent-k {
    padding-right: 0.1em;
}
  
.cch-over { 
    display: inline-flex; 
    position: relative;
}
  
.cch-over > *:nth-child(2) {
    position: absolute;
    left: 0;
    width: 100%;
    display: inline-flex;
    justify-content: center;
}
.cch-over > *:nth-child(2) {
    top: var(--col-top);
}
  
.cch-index,
.cch-over > *:nth-child(2), 
.cch-supsub > * {
    font-size: 0.65em;
    white-space: nowrap;
    font-stretch: condensed;
    letter-spacing: -0.05em;

    line-height: 1em;
    min-height: 1em;    
}
  
.cch-supsub {
    display: inline-flex;
    flex-direction: column;
    align-self: center;
    margin-top: -0.25em;
    padding-top: 0.2em;
}
.cch-supsub-left > * {text-align: right;}
  
.cch-charge {
    display: inline-flex;
    align-items: baseline;
}
.cch-minus {
    display: inline-block;
    width: 0.4em;
    transform: scaleX(0.8);
}
.cch-mul {
    display: inline-block;
    padding: 0 0.1em;
}
  
  
/*********************
      Operations
        _____________________________.cch-op-both
       ^   
       |   *    * *****   *   **** .cch-op-comment
    1em|   *    * *      * *  *   *
       |   ****** ****  *   * *   *
       v___*____*_*_____*****_*___*_____________
       ^   *    * ***** *   * ****  ------
       |                               ↨ --op-comm-dy = 0.3em
    1em|------middle line of operation------------ 
       |                   ↨ --op-comm-dy
       v___***___***__*****_________________
       ^   *  * *   *   *
       |   ***  *   *   *
    1em|   *  * *   *   *
       |   ***   ***    * .cch-op-comment
       v_____________________________________
  
*********************/
    
/* Если этого не сделать, то align-items неправильно работает для пустой строки. Как будто не находит базовую линию. */
.cch-op-comment::before,
.cch-arrow-both::before {
    display: inline-block;
    content: ".";
    width: 0;
    visibility: hidden;
}
  
.cch-op-comment {
    min-width: 1.2em;
    display: inline-flex;
    justify-content: center;
}
.cch-op-comment > * {
    font-size: 80%;  
}
.cch-op-comment:has(+ .cch-op[data-op="-->"]), /* above */
.cch-op[data-op="-->"] + .cch-op-comment /* below */
{
    padding-left: var(--arr-begin-pad);
    padding-right: var(--arr-end-pad);
}
.cch-op-comment:has(+ .cch-op[data-op="<--"]), /* above */ 
.cch-op[data-op="<--"] + .cch-op-comment /* below */
{
    padding-right: var(--arr-begin-pad);
    padding-left: var(--arr-end-pad);
}
.cch-op-comment:has(+ .cch-op[data-op="<==>"]) /* above */ ,
.cch-op[data-op="<==>"] + .cch-op-comment /* below */,
.cch-op-comment:has(+ .cch-op[data-op="<-->"]) /* above */,
.cch-op[data-op="<-->"] + .cch-op-comment /* below */
{
    padding-right: var(--arr-both-pad);
    padding-left: var(--arr-both-pad);
}
  
.cch-op {
    position: relative;
    min-width: 0.6em;
    height: 1em;
    display: inline-flex;
    justify-content: center;
}
.cch-op-arrow .cch-op-code {
    opacity: 0;
    width: 1.2em;
}
.cch-op-code {
    text-align: center;
    white-space: nowrap;  
    height: 1em;
    display: inline-flex;
}
  
.cch-op-both {
    align-self: baseline;
    padding-top: 1em;
    margin-bottom: -1em; /* иначе образуется поле снизу */
    transform: translateY(-1em);

    display: inline-flex;
    flex-direction: column;
    align-items: center;
    line-height: 1;
}
.cch-op-both > * {position: relative;}
.cch-op-both > .cch-op {
    width: 100%;
    height: 1em;
}
.cch-op-both > *:nth-child(1) {transform: translateY(var(--op-comm2-dy));}
.cch-op-both > *:nth-child(3) {transform: translateY(calc(-1 * var(--op-comm2-dy)));}
  
.cch-op-head {
    position: relative;
    padding-top: var(--op-comm1-dy);
    display: inline-flex;
}
.cch-op-head > *:first-child {
    transform: translateY(calc(-1 * var(--op-comm1-dy)));
}
.cch-op-head > .cch-op, .cch-op-footer > .cch-op {
    width: 100%;
    position: absolute;
}
.cch-op-footer {
    position: relative;
    padding-bottom: var(--op-comm1-dy);
    display: inline-flex;
}
.cch-op-footer > *:nth-child(2) {
    transform: translateY(var(--op-comm1-dy));
}
.cch-arrow-both, .cch-arrow-bidir {
    display: inline-flex;
    line-height: 1em;
    height: 1em;
}
.cch-arrow-fwd, .cch-arrow-bkwd, .cch-arrow-both-left, .cch-arrow-both-right {
    overflow: hidden; 
    width: 100%; 
    display: inline-flex;
    justify-content: flex-end;
    position: absolute;
    line-height: 1em;
    height: 1em;
    & > svg {position: absolute;}
}
.cch-arrow-both-left {width: 50%; left:0}
.cch-arrow-both-right {width: 50%; right: 0;}
.cch-arrow-fwd svg {right: 0;}
.cch-arrow-bkwd svg {left: 0;}
.cch-arrow-fwd svg, .cch-arrow-bkwd svg {top:0.3em;} 
.cch-arrow-both-left svg {left: 0; top:0;}
.cch-arrow-both-left > svg, .cch-arrow-both-right > svg {top:0.14em;}
.cch-arrow-both .cch-arrow-bkwd, .cch-arrow-bidir .cch-arrow-bkwd  {width: 50%; left:0}
.cch-arrow-both .cch-arrow-fwd, .cch-arrow-bidir .cch-arrow-fwd {width: 50%; right:0}
