/* ==================================================
   LATHE SETUP LIST
   ================================================== */

#lathe-setup-modal {
  overflow: hidden;
}

#lathe-setup-modal .lathe-setup-panel {
  min-width: 0;
  max-width: 100%;
  overflow-x: hidden;
}

#lathe-setup-modal .lathe-setup-body {
  width: 100%;
  min-width: 0;
}

.lathe-setup-sections {
  display: grid;
  gap: 1rem;
}

.lathe-setup-section {
  overflow: hidden;
  background: #151a22;
  border: 1px solid var(--cnc-line);
  border-radius: .9rem;
}

.lathe-setup-section h3 {
  margin: 0;
  padding: .8rem 1rem;
  color: var(--cnc-accent);
  background: rgba(34, 42, 53, .72);
  border-bottom: 1px solid var(--cnc-line);
  font-size: 1rem;
  letter-spacing: .04em;
  text-transform: uppercase;
}


/* Training / reference addressing: section letter + numbered step bubble. */
.lathe-setup-section h3 {
  display: flex;
  align-items: center;
  gap: .5rem;
}

.lathe-setup-section__code {
  flex: 0 0 auto;
  font-weight: 950;
}

.lathe-setup-section__code::after {
  content: " —";
}

.lathe-setup-step-badge {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  width: 2.05rem;
  height: 2.05rem;
  border-radius: 50%;
  color: #111;
  background: var(--cnc-accent);
  border: 1px solid var(--cnc-accent-dark);
  font-size: .88rem;
  font-weight: 950;
  line-height: 1;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .22);
}

.lathe-setup-list {
  display: grid;
}

.lathe-setup-row {
  display: flex;
  align-items: center;
  gap: .85rem;
  min-height: 3.35rem;
  padding: .7rem .9rem;
  cursor: pointer;
  border-bottom: 1px solid rgba(56, 68, 84, .72);
  transition:
    background-color .12s ease,
    color .12s ease;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.lathe-setup-row:last-child {
  border-bottom: 0;
}

.lathe-setup-row:hover,
.lathe-setup-row:focus-within {
  background: rgba(255, 212, 0, .07);
}

.lathe-setup-row.is-complete {
  background: rgba(157, 255, 87, .08);
}

.lathe-setup-checkbox {
  flex: 0 0 auto;
  width: 1.45rem;
  height: 1.45rem;
  margin: 0;
  accent-color: var(--cnc-good);
  cursor: pointer;
}

.lathe-setup-row__text {
  min-width: 0;
  color: var(--cnc-text);
  font-size: 1rem;
  font-weight: 750;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.lathe-setup-row.is-complete .lathe-setup-row__text {
  color: var(--cnc-muted);
  text-decoration: line-through;
  text-decoration-thickness: 2px;
}

.lathe-setup-controls {
  display: grid;
  gap: .7rem;
  padding: .85rem;
  background: #151a22;
  border: 1px solid var(--cnc-line);
  border-radius: .9rem;
}

.lathe-setup-progress {
  display: grid;
  place-items: center;
  min-height: 2.8rem;
  padding: .45rem .75rem;
  color: #111;
  background: var(--cnc-good);
  border: 1px solid var(--cnc-good-dark);
  border-radius: .65rem;
}

.lathe-setup-progress strong {
  font-size: 1rem;
  text-align: center;
}

.lathe-setup-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .65rem;
}

.lathe-setup-action {
  min-height: 3rem;
  padding: .65rem .75rem;
  color: var(--cnc-text);
  background: #303a49;
  border: 1px solid var(--cnc-line);
  border-radius: .65rem;
  cursor: pointer;
  font-weight: 850;
}

.lathe-setup-action:hover,
.lathe-setup-action:focus-visible {
  color: #111;
  background: var(--cnc-accent);
  border-color: var(--cnc-accent-dark);
  outline: none;
}

.lathe-setup-action--reset:hover,
.lathe-setup-action--reset:focus-visible {
  color: #111;
  background: var(--cnc-danger);
  border-color: var(--cnc-danger);
}

@media (min-width: 801px) {
  #lathe-setup-modal .lathe-setup-panel {
    width: min(900px, calc(100vw - 2rem));
  }

  .lathe-setup-controls {
    grid-template-columns: minmax(12rem, 1fr) minmax(20rem, auto);
    align-items: center;
  }

  .lathe-setup-actions {
    min-width: 22rem;
  }

  .lathe-setup-row {
    min-height: 3.1rem;
    padding: .65rem 1rem;
  }
}

@media (max-width: 800px) {
  #lathe-setup-modal {
    width: 100dvw;
    height: 100dvh;
    padding: 0;
    align-items: stretch;
    justify-items: stretch;
  }

  #lathe-setup-modal .lathe-setup-panel {
    width: 100%;
    height: 100dvh;
    max-width: none;
    max-height: none;
    margin: 0;
    border-left: 0;
    border-right: 0;
    border-radius: 0;
    overflow-y: auto;
    overflow-x: hidden;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }

  #lathe-setup-modal .tool-modal__header {
    width: 100%;
  }

  #lathe-setup-modal .lathe-setup-body {
    width: 100%;
    padding: .75rem;
  }

  .lathe-setup-row {
    min-height: 3.75rem;
    padding: .8rem .8rem;
  }

  .lathe-setup-checkbox {
    width: 1.65rem;
    height: 1.65rem;
  }

  .lathe-setup-step-badge {
    width: 2.15rem;
    height: 2.15rem;
    font-size: .92rem;
  }

  .lathe-setup-row__text {
    font-size: 1.03rem;
  }

  .lathe-setup-action {
    min-height: 3.35rem;
  }
}


/* ==================================================
   LATHE SETUP LIST — PRINT
   ================================================== */

@media print {
  @page {
    size: letter portrait;
    margin: .32in;
  }

  body.lathe-setup-printing {
    color: #000;
    background: #fff !important;
  }

  body.lathe-setup-printing > * {
    display: none !important;
  }

  body.lathe-setup-printing > #lathe-setup-modal {
    display: block !important;
    position: static !important;
    inset: auto !important;
    width: auto !important;
    height: auto !important;
    padding: 0 !important;
    overflow: visible !important;
  }

  body.lathe-setup-printing #lathe-setup-modal .lathe-setup-panel {
    display: block !important;
    width: 100% !important;
    height: auto !important;
    max-width: none !important;
    max-height: none !important;
    overflow: visible !important;
    color: #000 !important;
    background: #fff !important;
    border: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
  }

  body.lathe-setup-printing #lathe-setup-modal .tool-modal__header {
    position: static !important;
    padding: 0 0 .12in !important;
    margin: 0 0 .12in !important;
    color: #000 !important;
    background: #fff !important;
    border-bottom: 2px solid #000 !important;
  }

  body.lathe-setup-printing #lathe-setup-modal .tool-modal__header .cnc-kicker,
  body.lathe-setup-printing #lathe-setup-modal .modal-close,
  body.lathe-setup-printing #lathe-setup-modal .lathe-setup-controls {
    display: none !important;
  }

  body.lathe-setup-printing #lathe-setup-modal h2 {
    color: #000 !important;
    font-size: 17pt !important;
    line-height: 1 !important;
  }

  body.lathe-setup-printing #lathe-setup-modal .lathe-setup-body {
    display: block !important;
    padding: 0 !important;
  }

  /*
   * Two print columns.
   * Inserts is explicitly marked in lathe-setup.js as the start
   * of column two, so the layout stays intentional rather than
   * letting the browser choose the split point.
   */
  body.lathe-setup-printing #lathe-setup-modal .lathe-setup-sections {
    display: block !important;
    column-count: 2;
    column-gap: .32in;
    column-fill: auto;
  }

  body.lathe-setup-printing #lathe-setup-modal .lathe-setup-section {
    display: inline-block;
    width: 100%;
    margin: 0 0 .11in !important;
    break-inside: avoid;
    page-break-inside: avoid;
    color: #000 !important;
    background: #fff !important;
    border: 1px solid #555 !important;
    border-radius: 0 !important;
  }

  body.lathe-setup-printing #lathe-setup-modal .lathe-setup-section--print-column-break {
    break-before: column;
    -webkit-column-break-before: always;
  }

  body.lathe-setup-printing #lathe-setup-modal .lathe-setup-section h3 {
    padding: .08in .10in !important;
    color: #000 !important;
    background: #eee !important;
    border-bottom: 1px solid #555 !important;
    font-size: 8.5pt !important;
    line-height: 1.05 !important;
  }

  body.lathe-setup-printing #lathe-setup-modal .lathe-setup-row {
    min-height: 0 !important;
    gap: .08in !important;
    padding: .055in .09in !important;
    color: #000 !important;
    background: #fff !important;
    border-bottom: 1px solid #bbb !important;
    line-height: 1.05 !important;
  }

  body.lathe-setup-printing #lathe-setup-modal .lathe-setup-checkbox {
    width: .13in !important;
    height: .13in !important;
  }

  body.lathe-setup-printing #lathe-setup-modal .lathe-setup-step-badge {
    width: .20in !important;
    height: .20in !important;
    color: #000 !important;
    background: #fff !important;
    border: 1px solid #333 !important;
    border-radius: 50% !important;
    box-shadow: none !important;
    font-size: 7.5pt !important;
    font-weight: 900 !important;
    line-height: 1 !important;
  }

  body.lathe-setup-printing #lathe-setup-modal .lathe-setup-section__code {
    color: #000 !important;
    font-weight: 900 !important;
  }

  body.lathe-setup-printing #lathe-setup-modal .lathe-setup-row__text,
  body.lathe-setup-printing #lathe-setup-modal .lathe-setup-row.is-complete .lathe-setup-row__text {
    color: #000 !important;
    font-size: 8.25pt !important;
    line-height: 1.05 !important;
  }
}

/* --------------------------------------------------
   Reference / information notes
   These are read-only shop references, not checklist items.
   -------------------------------------------------- */

.lathe-setup-reference {
  margin: .75rem .9rem .75rem 3.15rem;
  padding: .8rem .9rem;
  color: #1a1a12;
  background: #ffe66a;
  border: 1px solid #d6b900;
  border-radius: .35rem;
  box-shadow:
    0 3px 0 rgba(120, 95, 0, .18),
    0 8px 18px rgba(0, 0, 0, .18);
  transform: rotate(-.18deg);
}

.lathe-setup-reference__label {
  margin: 0 0 .5rem;
  padding-bottom: .35rem;
  border-bottom: 1px solid rgba(75, 62, 0, .28);
  font-size: .78rem;
  font-weight: 900;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.lathe-setup-reference__lines {
  display: grid;
  gap: .42rem;
}

.lathe-setup-reference__line {
  font-size: 1rem;
  font-weight: 850;
  line-height: 1.25;
}

@media (max-width: 800px) {
  .lathe-setup-reference {
    margin: .8rem .8rem .8rem 3.3rem;
    padding: .85rem .9rem;
  }

  .lathe-setup-reference__line {
    font-size: 1.03rem;
  }
}

@media print {
  body.lathe-setup-printing #lathe-setup-modal .lathe-setup-reference {
    margin: .055in .09in .08in .30in !important;
    padding: .07in .09in !important;
    color: #000 !important;
    background: #fff6b8 !important;
    border: 1px solid #777 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    transform: none !important;
    break-inside: avoid;
    page-break-inside: avoid;
  }

  body.lathe-setup-printing #lathe-setup-modal .lathe-setup-reference__label {
    margin: 0 0 .04in !important;
    padding-bottom: .03in !important;
    border-bottom: 1px solid #999 !important;
    font-size: 7.75pt !important;
    line-height: 1 !important;
  }

  body.lathe-setup-printing #lathe-setup-modal .lathe-setup-reference__lines {
    gap: .025in !important;
  }

  body.lathe-setup-printing #lathe-setup-modal .lathe-setup-reference__line {
    font-size: 8.25pt !important;
    line-height: 1.05 !important;
  }
}
