/* Otoolia — Tableau périodique (styles limités à .tp / .tp-*) */
.tp {
  --tp-ink: #172033;
  --tp-alkali: #f8d3bf; --tp-alkaline: #f6e7a6; --tp-transition: #f3c3d4; --tp-post: #d6dbe4; --tp-metalloid: #c3e6d6;
  --tp-nonmetal: #d9ecc2; --tp-halogen: #d8cffb; --tp-noble: #c9e3f7; --tp-lanthanoid: #f6d4ea; --tp-actinoid: #f1d6c9;
  --tp-solid: #eadfc4; --tp-liquid: #bfe7d3; --tp-gas: #cfe3f9; --tp-na: repeating-linear-gradient(135deg, #e4e7ec 0 4px, #f3f4f6 4px 8px);
  --tp-good: #15803d; --tp-bad: #c81e1e;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .tp { --tp-good: #4ade80; --tp-bad: #f87171; } }
:root[data-theme="dark"] .tp { --tp-good: #4ade80; --tp-bad: #f87171; }

.tp-head h1 { font-size: clamp(1.6rem, 4vw, 2.3rem); margin-bottom: .2em; }
.tp-sm { min-height: 34px; padding: 5px 14px; font-size: .88rem; }
.tp-alkali { background: var(--tp-alkali); } .tp-alkaline { background: var(--tp-alkaline); } .tp-transition { background: var(--tp-transition); }
.tp-post { background: var(--tp-post); } .tp-metalloid { background: var(--tp-metalloid); } .tp-nonmetal { background: var(--tp-nonmetal); }
.tp-halogen { background: var(--tp-halogen); } .tp-noble { background: var(--tp-noble); } .tp-lanthanoid { background: var(--tp-lanthanoid); } .tp-actinoid { background: var(--tp-actinoid); }

/* Barre d'outils */
.tp-bar { display: grid; gap: 10px; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); margin: 14px 0 10px; align-items: end; }
.tp-f { display: flex; flex-direction: column; gap: 4px; font-size: .82rem; font-weight: 600; min-width: 0; }
.tp .ot-input, .tp .ot-select { padding: 6px 9px; min-height: 38px; font-size: .92rem; width: 100%; }
.tp-search { grid-column: 1 / -1; }
@media (min-width: 900px) { .tp-bar { grid-template-columns: minmax(0, 1.6fr) repeat(4, minmax(0, 1fr)) auto; } .tp-search { grid-column: auto; } }
.tp-legend { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 10px; }
.tp-leg { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--ot-border); border-radius: 999px; padding: 3px 10px; font: inherit; font-size: .78rem; color: var(--ot-text); background: var(--ot-surface); }
button.tp-leg { cursor: pointer; } button.tp-leg:hover { border-color: var(--ot-brand); }
.tp-leg-note { border: 0; color: var(--ot-text-soft); padding-left: 2px; }
.tp-dot { width: 11px; height: 11px; border-radius: 3px; display: inline-block; flex: none; }
.tp-dot-na { background: var(--tp-na); }
.tp-dot-exp { background-image: repeating-linear-gradient(135deg, transparent 0 3px, rgba(0,0,0,.25) 3px 4px); }
.tp-st-solid { background-color: var(--tp-solid); } .tp-st-liquid { background-color: var(--tp-liquid); } .tp-st-gas { background-color: var(--tp-gas); }
.tp-ramp i { width: 90px; height: 10px; border-radius: 3px; background: linear-gradient(90deg, hsl(212 72% 95%), hsl(208 64% 61%)); }

/* Grille */
.tp-wrap { overflow-x: auto; padding: 2px 2px 6px; -webkit-overflow-scrolling: touch; }
.tp-grid { display: grid; grid-template-columns: 18px repeat(18, minmax(42px, 1fr)); grid-template-rows: 16px repeat(7, auto) 12px auto auto; gap: 3px; min-width: 820px; }
.tp-gn, .tp-pn { font-size: .68rem; color: var(--ot-text-soft); display: grid; place-items: center; }
.tp-frow { font-size: .72rem; color: var(--ot-text-soft); display: flex; align-items: center; justify-content: flex-end; padding-right: 6px; text-align: right; }
.tp-ph { border-radius: 6px; display: grid; place-items: center; font-size: .66rem; color: var(--tp-ink); opacity: .75; aspect-ratio: 1 / 1.12; }
.tp-cell { --tp-bg: transparent; position: relative; border: 1px solid rgba(0,0,0,.06); border-radius: 6px; padding: 14px 2px 3px; min-width: 0; aspect-ratio: 1 / 1.12;
  display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--tp-ink); font: inherit; cursor: pointer; line-height: 1.1;
  transition: transform .1s, box-shadow .1s, opacity .15s; }
.tp-cell:hover { transform: translateY(-1px); box-shadow: 0 3px 10px rgba(0,0,0,.18); z-index: 1; }
.tp-cell:focus-visible { outline: 3px solid var(--ot-focus, #2563eb); outline-offset: 1px; z-index: 2; }
.tp-cell .tp-z { position: absolute; top: 3px; left: 4px; font-size: .62rem; opacity: .8; }
.tp-sym { font-weight: 800; font-size: clamp(.95rem, 1.35vw, 1.3rem); letter-spacing: -.02em; }
.tp-name { font-size: .56rem; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 1px; }
.tp-val { font-size: .58rem; opacity: .85; margin-top: 1px; white-space: nowrap; }
.tp-cell.tp-sel { outline: 3px solid var(--ot-text); outline-offset: 0; z-index: 2; }
.tp-cell.tp-cmp::after { content: "✓"; position: absolute; top: 2px; right: 4px; font-size: .62rem; font-weight: 800; }
.tp-cell.tp-dim { opacity: .18; }
.tp-by-state .tp-cell { background: var(--tp-solid); }
.tp-by-state .tp-cell[data-state="liquid"] { background: var(--tp-liquid); }
.tp-by-state .tp-cell[data-state="gas"] { background: var(--tp-gas); }
.tp-by-state .tp-cell.tp-exp { background-image: repeating-linear-gradient(135deg, transparent 0 5px, rgba(0,0,0,.12) 5px 6px); }
.tp-by-num .tp-cell { background: var(--tp-bg); }
.tp-by-num .tp-cell.tp-na { background: var(--tp-na); color: #5b6474; }
.tp-by-num .tp-ph { background: transparent; border: 1px dashed var(--ot-border); color: var(--ot-text-soft); }
.tp-foot { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 6px; font-size: .8rem; color: var(--ot-text-soft); margin: 6px 0 var(--ot-space); }

/* Fiche + comparateur */
.tp-two { display: grid; gap: var(--ot-space); align-items: start; grid-template-columns: minmax(0, 1fr); margin-bottom: calc(var(--ot-space) * 1.5); }
@media (min-width: 1000px) { .tp-two:not(.tp-two--wide) { grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); } }
.tp-two > * { min-width: 0; }
#tp-detail { scroll-margin-top: 80px; }
.tp-dhead { display: flex; gap: 14px; align-items: center; padding-bottom: 12px; border-bottom: 1px solid var(--ot-border); }
.tp-tile { width: 92px; height: 100px; flex: none; border-radius: 12px; display: flex; flex-direction: column; align-items: center; justify-content: center; position: relative; color: var(--tp-ink); }
.tp-tile .tp-z { position: absolute; top: 6px; left: 8px; font-size: .8rem; }
.tp-tile .tp-sym { font-size: 2.4rem; line-height: 1; }
.tp-tile .tp-val { font-size: .75rem; margin-top: 6px; }
.tp-dtitle { min-width: 0; }
.tp-dtitle h2 { margin: 0; font-size: 1.5rem; }
.tp-dtitle p { margin: 2px 0 8px; font-size: .88rem; }
.tp-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.tp-props { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 150px), 1fr)); gap: 8px; margin: 12px 0 0; }
.tp-prop { background: var(--ot-surface-2); border-radius: var(--ot-radius-s); padding: 7px 10px; margin: 0; min-width: 0; }
.tp-prop dt { font-size: .74rem; color: var(--ot-text-soft); }
.tp-prop dd { margin: 2px 0 0; font-weight: 600; font-size: .92rem; overflow-wrap: anywhere; }
.tp-wide { grid-column: 1 / -1; }
.tp-cfg { font-family: var(--ot-mono, ui-monospace, Menlo, Consolas, monospace); font-weight: 600; }
.tp-cfg sup { font-size: .7em; }
.tp-nd { color: var(--ot-text-soft); font-weight: 400; font-style: italic; }
.tp-notes { font-size: .82rem; color: var(--ot-text-soft); margin: 10px 0 0; padding-left: 1.2em; }
.tp-h2 { font-size: 1.05rem; margin: 0 0 10px; display: flex; align-items: center; gap: 8px; }
.tp-h2 small { margin-left: auto; font-weight: 500; color: var(--ot-text-soft); }
.tp-scroll { overflow-x: auto; }
.tp-table { border-collapse: collapse; width: 100%; font-size: .84rem; }
.tp-table th, .tp-table td { border-bottom: 1px solid var(--ot-border); padding: 6px 8px; text-align: left; vertical-align: top; }
.tp-table thead th { white-space: nowrap; }
.tp-table tbody th { font-weight: 500; color: var(--ot-text-soft); min-width: 130px; }
.tp-table td.tp-best { font-weight: 700; }
.tp-chip { display: inline-grid; place-items: center; min-width: 26px; height: 24px; padding: 0 3px; border-radius: 5px; color: var(--tp-ink); font-weight: 800; font-size: .8rem; }
.tp-x { border: 0; background: none; color: var(--ot-text-soft); font-size: 1.1rem; cursor: pointer; padding: 0 4px; }
.tp-x:hover { color: var(--tp-bad); }

/* Quiz */
.tp-qgrid { display: grid; gap: var(--ot-space); grid-template-columns: minmax(0, 1fr); }
@media (min-width: 800px) { .tp-qgrid { grid-template-columns: 260px minmax(0, 1fr); } }
.tp-qopts { display: flex; flex-direction: column; gap: 8px; }
.tp-check { display: flex; align-items: center; gap: 8px; font-size: .88rem; }
.tp-quiz { border: 1px solid var(--ot-border); border-radius: var(--ot-radius); padding: 18px; min-height: 220px; display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center; }
.tp-qlab { font-size: .75rem; letter-spacing: .08em; text-transform: uppercase; color: var(--ot-text-soft); margin: 0; }
.tp-qtxt { font-size: 1.3rem; font-weight: 700; margin: 6px 0 14px; }
.tp-opts { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; max-width: 640px; }
.tp-opt { min-width: 110px; }
.tp-opt.tp-ok { border-color: var(--tp-good); color: var(--tp-good); font-weight: 700; }
.tp-opt.tp-ko { border-color: var(--tp-bad); color: var(--tp-bad); text-decoration: line-through; }
.tp-opt:disabled { opacity: 1; cursor: default; }
.tp-fb { margin: 14px 0 0; font-size: .92rem; max-width: 640px; }
.tp-fb .ot-btn { margin-top: 10px; }
.tp-good { color: var(--tp-good); } .tp-bad { color: var(--tp-bad); }
.tp-score { font-size: .85rem; color: var(--ot-text-soft); margin: 4px 0 0; }

/* Fiches à imprimer (réglages) */
.tp-pfields { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 200px), 1fr)); margin-bottom: 10px; }
.tp-pchecks { display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 4px 0 12px; }
.tp-pbtns { display: flex; flex-wrap: wrap; gap: 8px; }
.tp-section { margin-bottom: calc(var(--ot-space) * 1.5); }
.tp-toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); background: var(--ot-text); color: var(--ot-bg); padding: 8px 16px; border-radius: 10px; font-size: .88rem; z-index: 50; }
.tp-print { display: none; }

@media (max-width: 600px) {
  .tp-grid { min-width: 700px; gap: 2px; }
  .tp-cell { padding-top: 12px; }
  .tp-name { display: none; }
  .tp-tile { width: 76px; height: 84px; }
  .tp-tile .tp-sym { font-size: 2rem; }
}

/* ---------- Impression : seule la fiche générée est imprimée ---------- */
@page tp-paysage { size: A4 landscape; margin: 8mm; }
@page tp-portrait { size: A4 portrait; margin: 8mm; }
@media print {
  body.tp-printing #ot-header, body.tp-printing #ot-footer, body.tp-printing .ot-skip, body.tp-printing .ot-consent,
  body.tp-printing .tp > :not(#tp-print) { display: none !important; }
  body.tp-printing main { padding: 0 !important; margin: 0 !important; max-width: none !important; }
  body.tp-printing { background: #fff !important; color: #000 !important; }
  .tp-print { display: block !important; color: #000; }
  body.tp-print-landscape .tp-print { page: tp-paysage; }
  body.tp-print-portrait .tp-print { page: tp-portrait; }
  .tp-phead { display: flex; justify-content: space-between; align-items: baseline; gap: 10mm; margin-bottom: 3mm; font-size: 11pt; }
  .tp-phead span { font-size: 10pt; }
  .tp-pgrid { display: grid; grid-template-columns: 4mm repeat(18, 1fr); grid-template-rows: 4mm repeat(7, 15.5mm) 3mm 15.5mm 15.5mm; gap: .6mm; }
  body.tp-print-portrait .tp-pgrid { grid-template-rows: 4mm repeat(7, 11.6mm) 3mm 11.6mm 11.6mm; }
  .tp-pgrid .tp-gn, .tp-pgrid .tp-pn { font-size: 6.5pt; color: #444; }
  .tp-pc { position: relative; border: .25mm solid #555; border-radius: 1mm; display: flex; flex-direction: column; align-items: center; justify-content: center;
    padding-top: 2mm; overflow: hidden; color: #000; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .tp-pc .tp-z { position: absolute; top: .6mm; left: 1mm; font-size: 5.5pt; }
  .tp-pc .tp-sym { font-size: 11pt; }
  .tp-pc .tp-name { font-size: 4.6pt; display: block; white-space: nowrap; }
  .tp-pc .tp-val { font-size: 4.6pt; }
  body.tp-print-portrait .tp-pc .tp-sym { font-size: 8.5pt; }
  body.tp-print-portrait .tp-pc .tp-name, body.tp-print-portrait .tp-pc .tp-val { font-size: 3.6pt; }
  .tp-pc.tp-pph { border-style: dashed; color: #555; font-size: 6pt; padding-top: 0; }
  .tp-pc.tp-out { border-color: #ccc; background: none !important; }
  .tp-nocol .tp-pc { background: #fff !important; }
  .tp-plegend { display: flex; flex-wrap: wrap; gap: 1mm 4mm; font-size: 7pt; margin-top: 3mm; }
  .tp-plegend span { display: inline-flex; align-items: center; gap: 1.5mm; }
  .tp-plegend .tp-dot { width: 3mm; height: 3mm; border: .2mm solid #555; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .tp-psrc { font-size: 6.5pt; color: #555; margin: 2mm 0 0; }
}
