/**
 * This project's own styling, on top of the site's stylesheet and the tools
 * stylesheet from the site's tools/assets/css/style.css.
 *
 * The same shape as laser/assets/css/laser.css -- the option grid, the preset
 * rows, the front-door cards, the preview stage -- under `.cnc-page` instead of
 * `.laser-page`, plus the few things only a router page has: the depth scale
 * under the shaded preview, and the toolpath legend, whose colours have to match
 * what the canvas draws.
 *
 * Nothing here invents a colour. The tools stylesheet has no .btn rule, so
 * buttons are .primary / .secondary inside .actions -- a Bootstrap .btn comes
 * out invisible on the dark card.
 */

.cnc-page .opts .grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 16px 22px;
}

.cnc-page .unit { color: var(--ink-dim); font-weight: 400; font-size: 13px; }

/* A heading inside a card, splitting one long panel of options into parts. */
.cnc-page .subhead {
    margin: 22px 0 12px;
    padding-top: 16px;
    border-top: 1px solid var(--line);
    font-size: 13.5px;
    font-weight: 600;
    color: var(--ink-dim);
    text-transform: none;
}

/* ---- saved machines, cutters and materials -------------------------------- */

.cnc-page .presets {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}
.cnc-page .presets label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13.5px;
    font-weight: 600;
    margin: 0;
}
.cnc-page .presets select {
    background: var(--panel-2);
    color: var(--ink);
    border: 1px solid var(--line);
    border-radius: 7px;
    padding: 6px 9px;
    font-size: 13.5px;
    min-width: 200px;
}
.cnc-page .presets .est { flex: 1 1 100%; }

/* The tools stylesheet sizes .primary and .secondary for a main action; these
   sit in a row of their own above the options and want to be quieter. */
.cnc-page .presets .secondary,
.cnc-page .actions .secondary.sm,
.cnc-page .actions .sm { padding: 6px 12px; font-size: 13px; }
.cnc-page .secondary[disabled] { opacity: .45; cursor: not-allowed; }

/* ---- the front door ------------------------------------------------------- */

.cnc-page .toolcards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 16px;
    margin: 18px 0 24px;
}
.cnc-page .toolcard {
    display: flex;
    gap: 15px;
    align-items: flex-start;
    background: var(--card-bg, var(--panel));
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 18px 20px;
    text-decoration: none;
    color: inherit;
}
.cnc-page .toolcard:hover { border-color: var(--accent); }
/* A card for something not built yet: readable, obviously not a link. */
.cnc-page .toolcard.soon { opacity: .62; cursor: default; }
.cnc-page .toolcard.soon:hover { border-color: var(--line); }
.cnc-page .toolcard-icon {
    flex: 0 0 auto;
    width: 42px; height: 42px;
    display: grid; place-items: center;
    border-radius: 10px;
    background: var(--panel-2);
    color: var(--accent);
    font-size: 18px;
}
.cnc-page .toolcard-body { display: block; }
.cnc-page .toolcard-body strong { display: block; margin-bottom: 5px; font-size: 15px; }
.cnc-page .toolcard-body span { display: block; color: var(--ink-dim); font-size: 13.5px; line-height: 1.55; }
.cnc-page .soontag,
.cnc-page .freetag {
    display: inline-block;
    margin-left: 7px;
    padding: 1px 8px;
    border-radius: 999px;
    background: rgba(var(--primary-rgb, 78, 161, 255), .14);
    color: var(--accent);
    font-style: normal;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
    vertical-align: middle;
}
.cnc-page .soontag { background: rgba(127, 127, 127, .16); color: var(--ink-dim); }

/* ---- the previews --------------------------------------------------------- */

.cnc-page .stage {
    position: relative;
    margin-top: 14px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--panel-2);
    padding: 12px;
    /* A checked ground, so a preview that is mostly pale still reads as a
       picture sitting on something rather than as an empty panel. */
    background-image:
        linear-gradient(45deg, rgba(127,127,127,.07) 25%, transparent 25%, transparent 75%, rgba(127,127,127,.07) 75%),
        linear-gradient(45deg, rgba(127,127,127,.07) 25%, transparent 25%, transparent 75%, rgba(127,127,127,.07) 75%);
    background-size: 18px 18px;
    background-position: 0 0, 9px 9px;
}
.cnc-page .stage canvas {
    display: block;
    max-width: 100%;
    height: auto;
    margin: 0 auto;
    border-radius: 6px;
}
/* The shaded relief is a lit surface, so the browser may smooth it: unlike the
   laser project's dither, where one canvas pixel is one laser dot and smoothing
   would show a softer picture than the machine can burn, here a sample is a
   point on a continuous surface and interpolating between them is honest. */
.cnc-page .stage.shade canvas { image-rendering: auto; }
.cnc-page .stage.path canvas { image-rendering: auto; }

.cnc-page .previewtabs { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.cnc-page .previewtabs button {
    background: transparent;
    border: 1px solid var(--line);
    color: var(--ink-dim);
    border-radius: 999px;
    padding: 5px 13px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}
.cnc-page .previewtabs button.on { border-color: var(--accent); color: var(--ink); }

/* The legend under the toolpath view. The swatches have to match what the
   canvas draws, so both read their colours from the same place. */
.cnc-page .legend { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 10px; }
.cnc-page .legend span { display: inline-flex; align-items: center; gap: 7px; color: var(--ink-dim); font-size: 12.5px; }
.cnc-page .legend i { width: 20px; height: 0; border-top-width: 2px; border-top-style: solid; display: inline-block; }
.cnc-page .legend .finish { border-top-color: var(--accent); }
.cnc-page .legend .rough { border-top-color: #8bd17c; }
.cnc-page .legend .jump { border-top-color: #e2574c; border-top-style: dashed; }

/* The depth scale beside the shaded preview: deep on the left, the top of the
   material on the right, so a glance says how much of the thickness is going. */
.cnc-page .depthscale {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 10px;
    font-size: 12.5px;
    color: var(--ink-dim);
}
.cnc-page .depthscale .bar {
    flex: 1 1 120px;
    height: 9px;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: linear-gradient(90deg, #3b2a1b, #c4a67c);
}

/* ---- the numbers, and what the cutter could not reach --------------------- */

/* A plain statement of what the compensation threw away. It is not a warning
   when it is small -- every cutter rounds something off -- so it only becomes
   one above the threshold the page sets, and reads as information below it. */
.cnc-page .reach {
    display: flex;
    align-items: baseline;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 12px;
    padding: 10px 13px;
    border: 1px solid var(--line);
    border-left: 3px solid var(--accent);
    border-radius: 8px;
    background: var(--panel-2);
    font-size: 13px;
    color: var(--ink-dim);
}
.cnc-page .reach b { color: var(--ink); font-weight: 600; }

/* ---- the G-code, when somebody wants to look before downloading ---------- */

.cnc-page .peek {
    margin-top: 12px;
    max-height: 260px;
    overflow: auto;
    background: var(--panel-2);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 11px 13px;
    font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
    font-size: 12px;
    line-height: 1.55;
    white-space: pre;
    color: var(--ink-dim);
}

/* ---- footer -------------------------------------------------------------- */

.cnc-foot {
    margin-top: 48px;
    padding: 22px 0 30px;
    border-top: 1px solid var(--line);
    color: var(--ink-dim);
    font-size: 13.5px;
    text-align: center;
}
.cnc-foot a { color: var(--accent); text-decoration: none; }
.cnc-foot a:hover { text-decoration: underline; }
.cnc-foot .est { font-size: 12.5px; }

/* ---- the 3D simulator ----------------------------------------------------- */

/* The canvas sizes itself from the stage in sim-main.js's resize(), so it must
   not also be stretched by CSS: a canvas scaled by CSS is a blurry canvas. */
.cnc-page #stage3d canvas { max-width: 100%; height: auto; cursor: grab; }
.cnc-page #stage3d canvas:active { cursor: grabbing; }

.cnc-page .simstate { display: flex; flex-wrap: wrap; gap: 9px; margin-bottom: 4px; }
.cnc-page .simchip {
    display: inline-flex;
    align-items: baseline;
    gap: 7px;
    background: var(--panel-2);
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 6px 13px;
    font-size: 12.5px;
    color: var(--ink-dim);
}
.cnc-page .simchip i { color: var(--ink-dim); font-size: 12px; }
.cnc-page .simchip b { font-weight: 600; color: var(--ink-dim); }
.cnc-page .simchip em { font-style: normal; font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; }

/* The spindle chip lights up while it is turning. */
.cnc-page .simchip.on { border-color: #ffd54a; }
.cnc-page .simchip.on i, .cnc-page .simchip.on em { color: #ffd54a; }

.cnc-page .simbar {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 14px;
}
.cnc-page .simbar input[type=range] { flex: 1 1 220px; accent-color: var(--accent); }
.cnc-page .simclock { font-variant-numeric: tabular-nums; min-width: 110px; }
.cnc-page .simspeed { display: flex; align-items: center; gap: 7px; font-size: 13px; color: var(--ink-dim); }
.cnc-page .simspeed label { margin: 0; font-weight: 600; }
.cnc-page .simspeed select {
    background: var(--panel-2); color: var(--ink);
    border: 1px solid var(--line); border-radius: 7px; padding: 4px 8px; font-size: 13px;
}
.cnc-page .simbar .est { flex: 1 1 100%; }

/* The reader's findings. Faults are a list that has to be readable at a glance,
   so the lines are given room rather than being packed. */
.cnc-page #problems ul, .cnc-page #notes ul { margin: 0 0 4px; padding-left: 20px; }
.cnc-page #problems li, .cnc-page #notes li { margin-bottom: 7px; line-height: 1.55; font-size: 13.5px; }
.cnc-page #notes li { color: var(--ink-dim); }

/* ---- the cutting and V-carving previews ----------------------------------- */

/* The drawing itself, under the toolpath, so an offset reads as an offset. */
.cnc-page .legend .drawn { border-top-color: var(--ink-dim); }

/* A tab is marked with a dot rather than drawn to length: at bed scale a 5 mm
   tab on a 300 mm part is less than a pixel, so drawing it honestly means
   drawing nothing. The laser project marks them the same way. */
.cnc-page .legend .tabdot {
    width: 8px; height: 8px;
    border: 0; border-radius: 50%;
    background: #8bd17c;
}

/* The words to carve: a text box wide enough to see a phrase in. */
.cnc-page input[type=text] {
    width: 100%;
    background: var(--panel-2);
    color: var(--ink);
    border: 1px solid var(--line);
    border-radius: 7px;
    padding: 7px 10px;
    font-size: 14px;
}
