/* Cam design pages (CamMotionLaws.html, CamDiskDesign.html): js/cam-ui.js.
   The frame, panels, results, status, graph tabs and reference cards all come
   from css/kc-calc.css (same look as the spring calculators). This file holds
   only what the cam pages add: the law picker, the segment table and the cam
   drawing. */

/* Input panel: one fixed grid for every row, so boxes and units line up in a column
   (selects and the name box take the same width as the number boxes). */
.kc-calc .cam-props .prop-row { grid-template-columns: minmax(0, 1fr) 112px 30px; }
.kc-calc .cam-props .prop-row input, .kc-calc .cam-props .prop-row select { width: 112px; }
.kc-calc .cam-props .prop-row input[type=text] { text-align: left; }
.kc-calc .cam-props .prop-row .unit { padding-left: 2px; }
/* Between the phone layout (760 px) and full width, three columns leave too little room for labels. */
@media (min-width: 761px) and (max-width: 1000px) { .kc-calc .cam-props .prop-cols { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* inch | mm switch in the toolbar (same look as .sq-seg on the Hertz and keyway pages) */
.kc-calc .sq-seg { display: inline-flex; border: 1px solid #8fa6ae; border-radius: 4px; overflow: hidden; width: fit-content; }
.kc-calc .sq-seg button { appearance: none; border: 0; background: #fff; color: #5a6168; font: 600 12.5px/1 Roboto, Arial, sans-serif;
  padding: 6px 13px; cursor: pointer; border-right: 1px solid #8fa6ae; }
.kc-calc .sq-seg button:last-child { border-right: none; }
.kc-calc .sq-seg button.sq-active { background: #1d3f4b; color: #fff; }

/* Motion-law picker (checkbox tiles, spring-page .it style) */
.kc-calc .cam-lawpick { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 4px; }
.kc-calc .cam-lawpick label { display: flex; align-items: center; gap: 6px; padding: 4px 8px; border: 1.5px solid #434343; border-radius: 6px; background: #e2ecef; font-size: 12px; cursor: pointer; }
.kc-calc .cam-lawpick label:has(input:checked) { background: #fff; border-color: #1a6475; }
.kc-calc .cam-lawpick input { accent-color: #1a6475; width: 13px; height: 13px; margin: 0; }
.kc-calc .cam-lawpick .cam-sw { width: 14px; height: 4px; border-radius: 2px; flex-shrink: 0; }
.kc-calc .cam-lawpick small { color: #5f6b70; }

/* Segment table (spring-page .lt input table look) */
.kc-calc .cam-segs-wrap { overflow-x: auto; background: #fff; border-radius: 6px; }
.kc-calc .cam-segs { width: 100%; border-collapse: collapse; font-size: 12px; min-width: 560px; }
.kc-calc .cam-segs th { font-size: 12px; font-weight: 600; color: #555; text-align: left; padding: 4px 5px; background: #e2ecef; border-bottom: 1.5px solid #434343; }
.kc-calc .cam-segs td { padding: 3px 5px; border-bottom: .5px solid #d0d0d0; vertical-align: middle; }
.kc-calc .cam-segs input, .kc-calc .cam-segs select { font: 12px Roboto, Arial, sans-serif; height: 22px; padding: 1px 4px; border-radius: 5px; border: 1.5px solid #434343; background: #e2ecef; color: #000; }
.kc-calc .cam-segs input:focus, .kc-calc .cam-segs select:focus { outline: none; border-color: #1a6475; background: #e8f0f3; }
.kc-calc .cam-segs input[type=number] { width: 74px; text-align: right; }
.kc-calc .cam-segs select { max-width: 220px; }
.kc-calc .cam-segs input:disabled, .kc-calc .cam-segs select:disabled { background: #f1f1f1; color: #999; border-color: #c0c0c0; }
.kc-calc .cam-segs .cam-start { color: #5f6b70; font-variant-numeric: tabular-nums; }
.kc-calc .cam-segs tr.cam-bad td { background: #fdf0ee; }
.kc-calc .cam-segs .cam-del { border: 1.5px solid #b9c5c8; background: #fff; border-radius: 5px; padding: 0 7px; height: 22px; cursor: pointer; color: #a3312a; }
.kc-calc .cam-row-btns { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }

/* SCCA a, b, c inputs under the law select */
.kc-calc .cam-abc { display: flex; gap: 6px; margin-top: 3px; }
.kc-calc .cam-abc label { display: inline-flex; align-items: center; gap: 2px; font-size: 11.5px; color: #555; }
.kc-calc .cam-segs .cam-abc input[type=number] { width: 54px; }

/* 3D model panel (same size as the spring pages) */
.kc-calc .cam3d-panel { position: relative; height: 420px; background: #fff; }
.kc-calc .cam3d-panel canvas { width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; }
.kc-calc .cam3d-fallback { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; text-align: center; padding: 20px; font-size: 13px; color: #666; background: #f4f4f4; }

/* Cam drawing */
.kc-calc .cam-draw { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; align-items: start; }
@media (max-width: 760px) { .kc-calc .cam-draw { grid-template-columns: 1fr; } }
.kc-calc .cam-canvas-wrap { position: relative; width: 100%; aspect-ratio: 1 / 1; max-width: 460px; margin: 0 auto; background: #fff; border-radius: 6px; border: 1px solid #c9d6da; }
.kc-calc .cam-canvas-wrap canvas { width: 100%; height: 100%; display: block; }
.kc-calc .cam-anim { display: flex; align-items: center; gap: 8px; margin: 6px auto 0; max-width: 460px; }
.kc-calc .cam-anim input[type=range] { flex: 1; min-width: 0; accent-color: #1a6475; }
.kc-calc .cam-anim output { font-size: 12.5px; font-weight: 700; min-width: 42px; text-align: right; font-variant-numeric: tabular-nums; }
.kc-calc .cam-legend { font-size: 11.5px; color: #5f6b70; text-align: center; margin: 4px 0 0; }
.kc-calc .cam-legend i { display: inline-block; width: 14px; height: 3px; vertical-align: middle; margin: 0 4px 0 8px; }
.kc-calc .cam-hide { display: none !important; }
.kc-calc .res-box.bad { border-left-color: #cc2222; background: #fdf3f2; }
.kc-calc .res-box.warn { border-left-color: #cc7700; background: #fffaf0; }
.kc-calc .res-box.good { border-left-color: #2a7a2a; }

/* Static tables in the reference guide */
.cam-table-scroll { overflow-x: auto; }
.cam-table-scroll .ref-table td, .cam-table-scroll .ref-table th { white-space: nowrap; text-align: right; }
.cam-table-scroll .ref-table td:first-child, .cam-table-scroll .ref-table th:first-child { text-align: left; }
.cam-table-scroll .ref-table td.cam-l { text-align: left; white-space: normal; }
.cam-eq { font-family: "Cambria Math", "STIX Two Math", Georgia, serif; font-size: 14px; }

/* "Show the offset as a tilted follower" under the cam drawing */
.kc-calc .cam-tilt { margin: 4px 0 0; flex-wrap: wrap; }
.kc-calc .cam-tilt #cdTiltOut { color: #5d6d72; font-weight: 400; }

/* Cam timing diagram (CamTimingDiagram.html) */
.kc-calc .tm-machine { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin: 2px 0 8px; font-size: 12px; }
.kc-calc .tm-machine input { height: 24px; border: 1.5px solid #434343; border-radius: 4px; padding: 1px 6px; font-size: 12px; }
.kc-calc .tm-machine #cdName { width: 200px; }
.kc-calc .tm-machine #cdRpm { width: 80px; text-align: right; }
.kc-calc .tm-cams td { vertical-align: middle; }
.kc-calc .tm-cams input[type=text] { width: 150px; text-align: left; }
.kc-calc .tm-cams input[type=color] { width: 34px; height: 24px; padding: 0 2px; border: 1px solid #8fa6ae; border-radius: 4px; background: #fff; cursor: pointer; }
.kc-calc .tm-cams .tm-phase { white-space: nowrap; }
.kc-calc .tm-cams .tm-phase input { width: 70px; }
.kc-calc .tm-cams .tm-ratio { white-space: nowrap; }
.kc-calc .tm-cams .tm-ratio input { width: 42px; }
.kc-calc .tm-cams tr.tm-sel { background: #e8f0f3; box-shadow: inset 3px 0 0 #1a6475; }
.kc-calc .tm-cams tbody tr { cursor: pointer; }
.kc-calc .tm-chip { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }
.kc-calc .tm-timeline-wrap { padding: 4px 8px 0; }
.kc-calc .tm-timeline-wrap svg { display: block; width: 100%; font-family: Roboto, Arial, sans-serif; cursor: ew-resize; touch-action: pan-y; user-select: none; }
.kc-calc .tm-timeline-wrap svg.tm-dragging { cursor: grabbing; }
.kc-calc .tm-drag-out:empty { display: none; }
.kc-calc .tm-scrub { padding: 0 8px; }
.kc-calc .tm-state { margin: 4px 8px 0; width: auto; }
.kc-calc .tm-tools { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 24px; font-size: 12px; }
.kc-calc .tm-tools > div { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.kc-calc .tm-tools select, .kc-calc .tm-tools input { height: 24px; border: 1.5px solid #434343; border-radius: 4px; font-size: 12px; max-width: 100%; }
.kc-calc .tm-tools input { width: 70px; text-align: right; padding: 1px 4px; }
.kc-calc .tm-tool-title { width: 100%; font-weight: 700; color: #1d3f4b; }
.kc-calc .tm-tools .grp-note { width: 100%; margin: 2px 0 0; }
.kc-calc .tm-graph-opts { display: flex; align-items: center; gap: 8px; padding: 4px 8px; font-size: 12px; }
@media (max-width: 760px) { .kc-calc .tm-tools { grid-template-columns: 1fr; } }

/* Printable data sheet (js/cam-sheet.js). Built into #camSheet just before printing;
   while body.cam-printing is set, only the sheet prints. */
#camSheet { display: none; }
@media print {
  @page { margin: 0.45in 0.5in; }
  body.cam-printing > *:not(#camSheet) { display: none !important; }
  body.cam-printing { background: #fff !important; }
  body.cam-printing #camSheet { display: block; }
}
#camSheet { font: 9.5pt/1.35 Roboto, Arial, sans-serif; color: #1f2a2e; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
#camSheet .cs-break { break-before: page; page-break-before: always; }
#camSheet .cs-head { display: flex; justify-content: space-between; align-items: flex-end; border-bottom: 2px solid #1d3f4b; padding-bottom: 4px; margin-bottom: 8px; }
#camSheet .cs-brand { font-size: 8.5pt; font-weight: 700; letter-spacing: .08em; color: #1a6475; text-transform: uppercase; }
#camSheet .cs-kind { font-size: 15pt; font-weight: 700; color: #1d3f4b; }
#camSheet .cs-head2 .cs-kind { font-size: 12pt; }
#camSheet .cs-meta { text-align: right; font-size: 8.5pt; color: #5d6d72; }
#camSheet .cs-name { font-size: 11pt; font-weight: 700; color: #1d3f4b; }
#camSheet h3 { font-size: 10pt; margin: 8px 0 3px; color: #1d3f4b; border-bottom: 1px solid #b9c9ce; padding-bottom: 1px; }
#camSheet .cs-top { display: grid; grid-template-columns: 340px 1fr; gap: 12px; align-items: start; }
#camSheet .cs-fig { margin: 0; border: 1px solid #c9d6da; }
#camSheet .cs-fig svg { display: block; width: 100%; height: auto; }
#camSheet .cs-fig figcaption { font-size: 7.5pt; color: #5d6d72; padding: 2px 6px 4px; }
#camSheet .cs-kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }
#camSheet .res-box { border: 1px solid #b9c9ce; border-left: 3px solid #1a6475; padding: 2px 6px; break-inside: avoid; }
#camSheet .res-box.bad { border-left-color: #cc2222; } #camSheet .res-box.warn { border-left-color: #cc7700; } #camSheet .res-box.good { border-left-color: #2a7a2a; }
#camSheet .res-label { display: block; font-size: 7.5pt; color: #5a6168; }
#camSheet .res-val { font-size: 10.5pt; font-weight: 700; font-variant-numeric: tabular-nums; }
#camSheet .res-val small { font-size: 7.5pt; font-weight: 400; color: #5a6168; margin-left: 2px; }
#camSheet .res-sub { display: block; font-size: 7.5pt; color: #5f6b70; }
#camSheet .cs-cols { display: grid; grid-template-columns: 1fr 1.25fr; gap: 12px; align-items: start; }
#camSheet .cs-table { width: 100%; border-collapse: collapse; font-size: 8pt; font-variant-numeric: tabular-nums; }
#camSheet .cs-table th { text-align: left; font-weight: 600; background: #e2ecef; border-bottom: 1px solid #434343; padding: 1px 4px; }
#camSheet .cs-table td { border-bottom: .5px solid #d0d0d0; padding: 1px 4px; }
#camSheet .cs-table tr { break-inside: avoid; }
#camSheet .cs-coord td, #camSheet .cs-coord th { text-align: right; }
#camSheet .cs-coord td:first-child, #camSheet .cs-coord th:first-child { text-align: left; }
#camSheet .cs-status ul { list-style: none; margin: 0; padding: 0; }
#camSheet .cs-status li { font-size: 8pt; padding: 1px 0 1px 12px; position: relative; }
#camSheet .cs-status li::before { content: ''; position: absolute; left: 1px; top: 5px; width: 6px; height: 6px; border-radius: 50%; background: #7f8c8d; }
#camSheet .cs-status li.ok::before { background: #2a7a2a; } #camSheet .cs-status li.warn::before { background: #cc7700; } #camSheet .cs-status li.err::before { background: #cc2222; }
#camSheet .cs-status p, #camSheet .cs-cnote { font-size: 8pt; color: #5d6d72; margin: 3px 0; }
#camSheet .cs-plots { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; }
#camSheet .cs-plots svg { width: 100%; height: auto; display: block; }
#camSheet .cs-foot { margin-top: 8px; padding-top: 3px; border-top: 1px solid #b9c9ce; font-size: 7.5pt; color: #7a8a8f; }
#camSheet svg text { font-family: Roboto, Arial, sans-serif; }
#camSheet .cs-pt { font-size: 10px; font-weight: 700; fill: #1d3f4b; }
#camSheet .cs-tk { font-size: 8px; fill: #4a575b; }
#camSheet .cs-al { font-size: 8.5px; fill: #4a575b; }
#camSheet .cs-grid { stroke: #e3eaec; stroke-width: .6; }
#camSheet .cs-zero { stroke: #9fb0b5; stroke-width: .7; }
#camSheet .cs-frame { fill: none; stroke: #9fb0b5; stroke-width: .7; }
