/* =====================================================================
   Picrezo - extra styles for the Tolerance Stack-Up Calculator only.
   Uses the colors from style.css, so dark mode works automatically.
   ===================================================================== */

/* ---- BLOCK T1: A wider page than the image tools (the tables need room) ---- */
.wrap.wide { max-width: 980px; }

/* ---- BLOCK T2: Top buttons and general settings ---- */
.ttoolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 1rem 0; }
.ttoolbar .spacer { flex: 1; }
.ttoolbar label { display: inline-flex; gap: 6px; align-items: center; color: var(--muted); font-size: 0.95rem; }
.ttoolbar select { font: inherit; padding: 0.3rem 0.4rem; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--text); }

/* ---- BLOCK T3: One card per line ---- */
.tcard { border: 1px solid var(--line); border-radius: var(--radius); padding: 0.7rem 1rem 0.5rem; margin: 0 0 12px; background: var(--bg-soft); }
.tcard.tclosing { border: 2px solid var(--brand); }
.tcard-top { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; margin-bottom: 4px; }
.tcard-top .row-tools { margin-left: auto; }
/* Line number: large and bold. Line name: bold. */
.tnum { font-weight: 800; font-size: 1.6rem; line-height: 1; color: var(--text); min-width: 2rem; }
.tfield.tname input { font-weight: 700; }
.tbadge { font-size: 0.8rem; font-weight: 600; background: var(--brand); color: var(--on-brand); border-radius: 999px; padding: 0.05rem 0.6rem; }

/* The boxes inside a card wrap onto a new row when there is not enough room (phones). */
.tfields { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: flex-end; margin: 6px 0; }
.tfield { display: flex; flex-direction: column; gap: 2px; min-width: 105px; flex: 1 1 105px; }
.tfield.twide { flex: 2 1 190px; }
.tfield.tsign { flex: 0 0 70px; min-width: 70px; }
.tfield.tsmall { flex: 0 1 120px; min-width: 100px; }
.tfield.tdist { flex: 0 0 150px; }
.tlabel { font-size: 0.8rem; color: var(--muted); }
.tfield input, .tfield select {
  font: inherit; padding: 0.4rem 0.5rem; border: 1px solid var(--line); border-radius: 8px;
  background: var(--bg); color: var(--text); width: 100%; min-width: 0;
}
.tfield input:focus, .tfield select:focus { outline: 2px solid var(--brand); outline-offset: 1px; }
.tparams { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: flex-end; flex: 1 1 260px; }
/* The calculated values of the closing dimension (not editable). */
.tvalue { padding: 0.4rem 0.5rem; border: 1px dashed var(--line); border-radius: 8px; background: var(--bg); font-variant-numeric: tabular-nums; min-height: 2.35rem; }
.thint { min-height: 0; margin: 0.2rem 0 0.3rem; }
.thint:empty { display: none; }
.thint-bad { color: var(--error); }

/* ---- BLOCK T4: Required limits box ---- */
.treq { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: flex-end; }

/* ---- BLOCK T5: Results ---- */
.resgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(270px, 1fr)); gap: 12px; margin: 1rem 0; }
.resbox { border: 1px solid var(--line); border-radius: var(--radius); padding: 0.8rem 1rem; background: var(--bg-soft); }
.resbox h3 { margin: 0 0 0.5rem; font-size: 1.05rem; }
.resrow { display: flex; justify-content: space-between; gap: 12px; padding: 0.2rem 0; border-bottom: 1px solid var(--line); }
.resrow:last-of-type { border-bottom: 0; }
.reslabel { color: var(--muted); }
.resvalue { font-variant-numeric: tabular-nums; text-align: right; }
.resrow-strong .resvalue { font-weight: 700; font-size: 1.1rem; }
.verdict-ok { color: #1a7f3c; font-weight: 700; }
.verdict-bad { color: var(--error); font-weight: 700; }
@media (prefers-color-scheme: dark) { .verdict-ok { color: #5fd18a; } }
.ctable { width: 100%; border-collapse: collapse; margin: 0.4rem 0 1rem; font-size: 0.95rem; }
.ctable th, .ctable td { text-align: left; padding: 0.35rem 0.6rem; border-bottom: 1px solid var(--line); }
.ctable td:nth-child(n+3), .ctable th:nth-child(n+3) { text-align: right; font-variant-numeric: tabular-nums; }

/* ---- BLOCK T6: Tick box in the requirement title, and the sigma level bar ---- */
.treq-toggle { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; cursor: pointer; }
.treq-toggle input { width: 1.1rem; height: 1.1rem; accent-color: var(--brand); cursor: pointer; }
.sigmabar { margin: 0.4rem 0; }
.sigmabar input[type=text] { font: inherit; padding: 0.3rem 0.5rem; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--text); width: 5rem; }

/* ---- BLOCK T7: Table of results at the three temperatures ---- */
.ttable-wrap { overflow-x: auto; }   /* on a phone the table scrolls sideways inside its box */
.ttable { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
.ttable th, .ttable td { padding: 0.4rem 0.6rem; border-bottom: 1px solid var(--line); text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ttable th:first-child, .ttable td:first-child { text-align: left; }
.ttable th { color: var(--muted); font-weight: 600; font-size: 0.85rem; }

/* ---- BLOCK T8 (stage 2): the five result blocks ---- */
.wrap.wide { max-width: 1100px; }
.unitbox { font: inherit; padding: 0.3rem 0.4rem; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--text); width: 5rem; }
/* Two columns on a wide screen, one column on a phone. */
.rgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin: 1rem 0; }
.rb { border-radius: var(--radius); padding: 0.7rem 0.9rem 0.4rem; min-width: 0; }
.rb h3 { margin: 0 0 0.4rem; font-size: 1.15rem; }
.rsubtitle { font-weight: 400; font-size: 0.8rem; color: var(--muted); }
/* Same colors as the tool cards on the home page. */
.rb.wc   { background: rgba(245,140,20,0.25);  border: 2px solid #f58c14; grid-area: 1 / 1; }
.rb.mc   { background: rgba(139,92,246,0.25);  border: 2px solid #8b5cf6; grid-area: 1 / 2; }
.rb.rss  { background: rgba(45,156,240,0.25);  border: 2px solid #2d9cf0; grid-area: 2 / 1; }
.rb.cv   { background: rgba(13,170,160,0.25);  border: 2px solid #0daaa0; grid-area: 2 / 2; }
.rb.rsss { background: rgba(99,102,241,0.25);  border: 2px solid #6366f1; grid-area: 3 / 1; }
@media (prefers-color-scheme: dark) {
  .rb.wc   { background: rgba(255,165,60,0.22);  border-color: #ffa53c; }
  .rb.mc   { background: rgba(170,135,255,0.22); border-color: #aa87ff; }
  .rb.rss  { background: rgba(90,180,255,0.22);  border-color: #5ab4ff; }
  .rb.cv   { background: rgba(45,205,195,0.22);  border-color: #2dcdc3; }
  .rb.rsss { background: rgba(140,143,255,0.22); border-color: #8c8fff; }
}
/* One row per temperature: label, CD, variation, extreme values. */
.rrow { display: grid; grid-template-columns: 4.6rem 1.25fr 1fr 1fr; gap: 4px 8px; padding: 0.5rem 0; border-top: 1px solid rgba(128,128,128,0.35); align-items: start; font-size: 0.95rem; }
.rcell { display: flex; flex-direction: column; min-width: 0; font-variant-numeric: tabular-nums; }
.rlab { font-size: 0.78rem; color: var(--muted); }
.rval { font-size: 1.05rem; }
.rsub { font-size: 0.8rem; color: var(--muted); }
.rline { white-space: nowrap; }
.rextra { grid-column: 1 / -1; margin: 0; font-size: 0.85rem; color: var(--muted); }
.rreq { color: var(--text); }
.rnote, .rwait { margin: 0.3rem 0; font-size: 0.85rem; color: var(--muted); }
/* Temperature label: blue = cold, grey = reference, yellow = hot. */
.tchip { display: inline-block; font-weight: 700; font-size: 0.8rem; border-radius: 999px; padding: 0.1rem 0.5rem; text-align: center; height: fit-content; white-space: nowrap; }
.tchip.cold { background: #bfdcff; color: #0b3a73; }
.tchip.ref  { background: #e6e8ee; color: #3a4150; }
.tchip.hot  { background: #ffe9a0; color: #6b4e00; }
@media (prefers-color-scheme: dark) {
  .tchip.cold { background: #1d3f6e; color: #cfe5ff; }
  .tchip.ref  { background: #343b50; color: #e0e4ef; }
  .tchip.hot  { background: #6b5710; color: #fff0b8; }
}
@media (max-width: 820px) {
  .rgrid { grid-template-columns: 1fr; }
  .rb.wc, .rb.mc, .rb.rss, .rb.cv, .rb.rsss { grid-area: auto; }
}
@media (max-width: 560px) {
  .rrow { grid-template-columns: 1fr 1fr; }
  .rrow .tchip { grid-column: 1 / -1; justify-self: start; }
  .rrow .rcd { grid-column: 1 / -1; }
}

/* ---- BLOCK T9 (stage 2): graphs and "Moments of the result" ---- */
.chartbar { gap: 8px 18px; }
.tchart { border: 1px solid var(--line); border-radius: var(--radius); padding: 0.6rem 0.9rem 0.8rem; margin: 0 0 14px; background: var(--bg-soft); }
.tchart-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.tchart-head h3 { margin: 0; font-size: 1.05rem; flex: 1; }
.tchart-body { display: flex; gap: 14px; align-items: flex-start; margin-top: 8px; }
.tchart-canvas { flex: 1 1 auto; min-width: 0; }
.tcanvas { display: block; width: 100%; height: 360px; border-radius: 8px; background: var(--bg); touch-action: pan-y; }
.tmoments { flex: 0 0 210px; border: 1px solid var(--line); border-radius: 10px; padding: 0.5rem 0.7rem; background: var(--bg); }
.tmoments h4 { margin: 0 0 0.3rem; font-size: 0.95rem; }
.mtable { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.mtable td { padding: 0.2rem 0; border-bottom: 1px solid var(--line); }
.mtable td:last-child { text-align: right; font-variant-numeric: tabular-nums; }
@media (max-width: 820px) {
  .tchart-body { flex-direction: column; }
  .tmoments { flex: 1 1 auto; width: 100%; box-sizing: border-box; }
  .tcanvas { height: 300px; }
}

/* ---- BLOCK T10: keeps the page from "jumping" while the line cards are being built ----
   Before the script has built the cards, the list reserves about the height it will have.
   The script adds the class "ready" when it is done. */
#lines:not(.ready) { min-height: 980px; }
@media (max-width: 820px) { #lines:not(.ready) { min-height: 1040px; } }
@media (max-width: 600px) { #lines:not(.ready) { min-height: 1370px; } }
@media (max-width: 480px) { #lines:not(.ready) { min-height: 1600px; } }
@media (max-width: 430px) { #lines:not(.ready) { min-height: 1950px; } }

/* ---- BLOCK T11: warning note when the RSS limits go beyond the worst case ---- */
.rwarn { margin: 0.3rem 0 0.4rem; padding: 0.35rem 0.6rem; font-size: 0.85rem; color: var(--text); background: rgba(255,200,0,0.22); border-left: 4px solid #e0a800; border-radius: 6px; }

/* ---- BLOCK T12: theoretical dimension tick box, study bar ---- */
.ttheo { display: inline-flex; gap: 6px; align-items: center; font-size: 0.85rem; color: var(--muted); cursor: pointer; }
.ttheo input { accent-color: var(--brand); width: 1rem; height: 1rem; cursor: pointer; }
.tfield.tdisabled { opacity: 0.45; }
.studybar { gap: 8px 10px; }
.studybox { font: inherit; padding: 0.3rem 0.5rem; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--text); width: 14rem; max-width: 100%; }
.studybar .hint { margin: 0; }

/* ---- BLOCK T13: "restore last session" bar ---- */
.restorebar { display: flex; flex-wrap: wrap; gap: 8px 10px; align-items: center; margin: 0.5rem 0; padding: 0.5rem 0.75rem; border: 2px solid #2d9cf0; border-radius: 10px; font-size: 0.92rem; }
.restorebar[hidden] { display: none; }

/* ---- BLOCK T14: Mean / sigma / skewness / kurtosis boxes at the right of a line ---- */
.tstats { display: flex; flex-wrap: wrap; gap: 8px 10px; align-items: flex-end; margin-left: auto; }
.tstats .tfield.tsmall { flex: 0 1 104px; min-width: 92px; }
.tstats .tfield.tdisabled input { background: transparent; border-style: dashed; }

/* ---- BLOCK T15: chain sketch ---- */
.tsketch { display: block; width: 100%; margin-top: 8px; }
/* the vertical sketch can be wider than the screen: it scrolls sideways inside this wrapper */
.tsketch-wrap { overflow-x: auto; max-width: 100%; }

/* ---- BLOCK T16: choice "Thermal expansion acts on" ---- */
.tmode { display: grid; gap: 6px; margin-top: 10px; }
.tmode .tlabel { font-weight: 600; font-size: 0.9rem; }
.tmode-opt { display: flex; gap: 8px; align-items: flex-start; font-size: 0.9rem; cursor: pointer; }
.tmode-opt input { margin-top: 3px; accent-color: var(--brand); }

/* the note under the sketch: "(CL)" in the red of the closing dimension */
.tcl { color: #e5484d; font-weight: 600; }

/* Second "Add line" button under the list of lines */
.tadd-bottom { margin: 10px 0 16px; }
