@charset "utf-8";

/* ===========================================================================
   Print queue — mistermills.tech/print

   Same cream / umber / burnt-orange palette as make.mistermills.tech, so a
   student moving between the two does not feel handed off to a stranger. Laid
   out as one narrow column, because this is a form to be filled in on a phone
   in a workshop, not a page to be read.
   ======================================================================== */

:root {
  --bg:          #F4EBDC;
  --bg-sunk:     #EAE0CD;
  --surface:     #FBF6EC;
  --surface-2:   #EFE4D0;

  --ink:         #2E2018;
  --ink-2:       #6A5641;
  --ink-3:       #927C63;

  --umber:       #8C6642;
  --accent:      #D4632C;
  --link:        #A8481C;

  --rule:        rgba(52, 36, 26, 0.14);
  --rule-strong: rgba(52, 36, 26, 0.28);
  --shadow:      0 1px 2px rgba(52, 36, 26, .05), 0 8px 24px -12px rgba(52, 36, 26, .18);

  --ok:      #4F6B3A;
  --warning: #B07A16;
  --danger:  #B2361C;

  --display: 'Familjen Grotesk', 'Space Grotesk', system-ui, sans-serif;
  --body:    'Space Grotesk', system-ui, -apple-system, sans-serif;
  --mono:    ui-monospace, 'SF Mono', Menlo, Consolas, monospace;

  --radius:   14px;
  --topbar-h: 60px;
}

:root[data-theme="dark"] {
  --bg:          #191310;
  --bg-sunk:     #120E0B;
  --surface:     #221A14;
  --surface-2:   #2B211A;

  --ink:         #EFE4D4;
  --ink-2:       #B9A38C;
  --ink-3:       #8D7862;

  --umber:       #C08D5E;
  --accent:      #E8873F;
  --link:        #F0A45E;

  --rule:        rgba(241, 231, 214, 0.13);
  --rule-strong: rgba(241, 231, 214, 0.26);
  --shadow:      0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px -12px rgba(0, 0, 0, .6);

  --ok:      #9BBF7C;
  --warning: #E0B24B;
  --danger:  #E4785C;
}

/* ---- Reset & base ------------------------------------------------------ */

*, *::before, *::after { box-sizing: border-box; }

/* The `hidden` attribute is only a UA rule of `display: none`, so ANY display
   declaration on the element beats it — and a `.error { display: flex }` will
   happily show a `<p hidden>`. Every panel, error and spinner on this page is
   toggled by that attribute, so it is restated here at a weight nothing else
   in the file can accidentally outrank. */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--body);
  font-size: 1rem;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, legend { font-family: var(--display); line-height: 1.2; letter-spacing: -0.01em; }
h1 { font-size: clamp(1.6rem, 1.2rem + 1.6vw, 2.2rem); margin: 0 0 .5rem; }
h2 { font-size: clamp(1.35rem, 1.1rem + 1vw, 1.7rem); margin: 0 0 .5rem; }

p { margin: 0 0 1rem; }
code, .mono { font-family: var(--mono); font-size: .92em; }

a { color: var(--link); }

svg { fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

.skip {
  position: absolute; left: -9999px; top: 0; z-index: 99;
  background: var(--accent); color: #fff; padding: .6rem 1rem; border-radius: 0 0 8px 0;
}
.skip:focus { left: 0; }

:where(a, button, input, [tabindex]):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ---- Top bar ----------------------------------------------------------- */

.topbar {
  height: var(--topbar-h);
  border-bottom: 1px solid var(--rule);
  background: var(--surface);
  position: sticky; top: 0; z-index: 10;
}
.topbar-in {
  max-width: 760px; margin: 0 auto; height: 100%;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 1rem;
}
.wordmark { display: flex; align-items: baseline; gap: .45rem; text-decoration: none; color: var(--ink); }
.wm-name { font-family: var(--display); font-weight: 700; letter-spacing: .02em; }
.wm-sep  { color: var(--ink-3); }
.wm-host { color: var(--ink-2); font-size: .9rem; }

.theme-toggle {
  background: none; border: 1px solid var(--rule); border-radius: 8px;
  color: var(--ink-2); width: 34px; height: 34px; cursor: pointer;
  display: grid; place-items: center; padding: 0;
}
.theme-toggle:hover { color: var(--ink); border-color: var(--rule-strong); }
.theme-toggle svg { width: 18px; height: 18px; }
.i-moon { display: none; }
:root[data-theme="dark"] .i-sun  { display: none; }
:root[data-theme="dark"] .i-moon { display: block; }

/* ---- Shell ------------------------------------------------------------- */

.shell { max-width: 760px; margin: 0 auto; padding: 2rem 1rem 4rem; }

.panel {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: clamp(1.25rem, 1rem + 2vw, 2rem);
}

.eyebrow {
  font-size: .75rem; text-transform: uppercase; letter-spacing: .1em;
  color: var(--ink-3); font-weight: 600; margin: 0 0 .35rem;
}
.lede  { color: var(--ink-2); }
.muted { color: var(--ink-3); font-size: .9rem; }

.back-link { font-weight: 600; }

/* ---- Fields ------------------------------------------------------------ */

.field { display: block; margin: 0 0 1.25rem; border: 0; padding: 0; }
.field-label { display: block; font-weight: 600; margin-bottom: .2rem; }
.field-hint  { display: block; color: var(--ink-3); font-size: .875rem; margin-bottom: .5rem; }

input[type="text"] {
  width: 100%; padding: .7rem .8rem; font: inherit; color: var(--ink);
  background: var(--bg); border: 1px solid var(--rule-strong); border-radius: 10px;
}
input[type="text"]:focus { border-color: var(--accent); }

.passcode-input {
  font-family: var(--mono);
  font-size: 1.8rem; letter-spacing: .6em; text-align: center;
  text-indent: .6em;                 /* re-centres text that letter-spacing pushed left */
  max-width: 11rem;
}

/* ---- Buttons ----------------------------------------------------------- */

.button {
  font: inherit; font-weight: 600; cursor: pointer;
  padding: .7rem 1.2rem; border-radius: 10px; border: 1px solid transparent;
  display: inline-flex; align-items: center; gap: .5rem; text-decoration: none;
}
.button.primary { background: var(--accent); color: #fff; }
.button.primary:hover:not(:disabled) { filter: brightness(1.07); }
.button.ghost { background: none; border-color: var(--rule-strong); color: var(--ink-2); }
.button.ghost:hover { color: var(--ink); border-color: var(--ink-3); }
.button:disabled { opacity: .5; cursor: not-allowed; }

.actions { display: flex; flex-wrap: wrap; gap: .6rem; margin-top: 1.5rem; }
.actions .primary { margin-left: auto; }

/* ---- Messages ---------------------------------------------------------- */

.error {
  color: var(--danger); font-weight: 500; font-size: .92rem;
  margin: -.5rem 0 1rem; display: flex; gap: .4rem;
}
.error::before { content: "!"; font-weight: 700; }

.warn {
  background: color-mix(in srgb, var(--warning) 12%, transparent);
  border-left: 3px solid var(--warning);
  padding: .7rem .9rem; border-radius: 0 8px 8px 0; font-size: .92rem;
}

.callout {
  border-left: 3px solid var(--umber);
  background: var(--surface-2);
  padding: .8rem 1rem; border-radius: 0 8px 8px 0; margin: 0 0 1rem;
}
.callout p:last-child { margin-bottom: 0; }
.callout-warning { border-left-color: var(--warning); }

/* ---- Dropzone ---------------------------------------------------------- */

.dropzone {
  border: 2px dashed var(--rule-strong);
  border-radius: var(--radius);
  background: var(--bg);
  padding: 2.5rem 1rem; text-align: center; cursor: pointer;
  transition: border-color .15s, background .15s;
}
.dropzone:hover, .dropzone:focus-visible { border-color: var(--accent); }
.dropzone.is-over { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, var(--bg)); }
.dz-icon { width: 44px; height: 44px; color: var(--ink-3); margin-bottom: .5rem; }
.dz-main { font-weight: 600; margin: 0 0 .25rem; }
.dz-browse { color: var(--link); text-decoration: underline; }
.dz-sub { color: var(--ink-3); font-size: .875rem; margin: 0; }

.reading { display: flex; align-items: center; gap: .6rem; color: var(--ink-2); }

.spinner {
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid var(--rule-strong); border-top-color: var(--accent);
  animation: spin .7s linear infinite; flex: none;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2s; } }

/* ---- Review ------------------------------------------------------------ */

.review { display: grid; gap: 1.25rem; margin-bottom: 1.25rem; }
@media (min-width: 620px) { .review { grid-template-columns: 1fr 1fr; align-items: start; } }

.viewer {
  position: relative; aspect-ratio: 1 / 1; width: 100%;
  background: var(--bg-sunk); border: 1px solid var(--rule);
  border-radius: 10px; overflow: hidden;
  display: grid; place-items: center;
}
.viewer img { width: 100%; height: 100%; object-fit: contain; display: block; }
.viewer-empty { color: var(--ink-3); font-size: .875rem; margin: 0; padding: 1rem; text-align: center; }

/* The first layer, drawn from the G-code. The canvas fills the square viewer
   exactly; portal.js sizes its backing store to match in device pixels. */
.first-layer { border-top: 1px solid var(--rule); padding-top: 1.25rem; margin-bottom: 1.25rem; }
.first-layer h3 { font-size: 1.15rem; margin: 0 0 .4rem; }
.first-layer .callout { margin-bottom: 0; font-size: .92rem; }
.layer-viewer canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

.legend { list-style: none; margin: 1rem 0 .6rem; padding: 0; display: grid; gap: .35rem; font-size: .9rem; }
.legend li { display: flex; align-items: center; gap: .5rem; }
.legend .key { width: 22px; height: 6px; border-radius: 3px; background: var(--key); flex: none; }

.stats { margin: 0; display: grid; gap: .85rem; }
.stats > div { display: grid; gap: .1rem; }
.stats dt { color: var(--ink-3); font-size: .78rem; text-transform: uppercase; letter-spacing: .07em; font-weight: 600; }
.stats dd { margin: 0; font-weight: 500; overflow-wrap: anywhere; }
.stats dd.big { font-family: var(--display); font-size: 1.5rem; font-weight: 600; line-height: 1.15; }

/* ---- Colour swatches --------------------------------------------------- */

.colours { margin-bottom: 1rem; }

.swatches {
  display: grid; gap: .5rem;
  grid-template-columns: repeat(auto-fill, minmax(108px, 1fr));
}

.swatch {
  display: flex; align-items: center; gap: .5rem; cursor: pointer;
  padding: .45rem .55rem; border: 1px solid var(--rule); border-radius: 9px;
  background: var(--bg); font-size: .875rem;
}
.swatch:hover { border-color: var(--rule-strong); }
.swatch input { position: absolute; opacity: 0; width: 0; height: 0; }
.swatch:has(input:checked) {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
  background: color-mix(in srgb, var(--accent) 7%, var(--bg));
}
.swatch:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }

.chip {
  width: 20px; height: 20px; border-radius: 50%; flex: none;
  background: var(--chip, #ccc);
  border: 1px solid var(--rule-strong);
  box-shadow: inset 0 -2px 4px rgba(0, 0, 0, .18);
}
.swatch-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.filename-preview {
  background: var(--surface-2); border-radius: 8px; padding: .6rem .8rem;
  font-size: .9rem; overflow-wrap: anywhere;
}
.filename-preview strong { font-family: var(--mono); font-weight: 600; }

/* ---- Confirm ----------------------------------------------------------- */

.confirm-list { margin: 0 0 1.25rem; display: grid; gap: .7rem; }
.confirm-list > div {
  display: grid; grid-template-columns: 9rem 1fr; gap: .5rem;
  padding-bottom: .7rem; border-bottom: 1px solid var(--rule);
}
.confirm-list > div:last-child { border-bottom: 0; padding-bottom: 0; }
.confirm-list dt { color: var(--ink-3); font-size: .85rem; }
.confirm-list dd { margin: 0; font-weight: 500; overflow-wrap: anywhere; }
.confirm-list dd#c-colour { display: flex; align-items: center; gap: .5rem; }
@media (max-width: 460px) {
  .confirm-list > div { grid-template-columns: 1fr; gap: .1rem; }
}

.tickbox {
  display: flex; gap: .7rem; align-items: flex-start; cursor: pointer;
  background: var(--surface-2); border-radius: 10px; padding: .85rem 1rem;
  border: 1px solid var(--rule); margin-bottom: 1rem;
}
.tickbox input { margin-top: .25rem; width: 18px; height: 18px; flex: none; accent-color: var(--accent); }
.tickbox:has(input:checked) { border-color: var(--ok); }

/* ---- Progress ---------------------------------------------------------- */

.progress { margin-bottom: 1rem; }
.bar { height: 8px; background: var(--bg-sunk); border-radius: 99px; overflow: hidden; }
.bar span { display: block; height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.progress-text { font-size: .875rem; color: var(--ink-2); margin: .4rem 0 0; }

/* ---- Done -------------------------------------------------------------- */

.done { text-align: center; }
.done .actions { justify-content: center; }
.done .actions .primary { margin-left: 0; }
.tick {
  width: 56px; height: 56px; margin: 0 auto 1rem; border-radius: 50%;
  background: color-mix(in srgb, var(--ok) 18%, transparent);
  display: grid; place-items: center; color: var(--ok);
}
.tick svg { width: 30px; height: 30px; stroke-width: 3.5; }

.closed { text-align: center; }

/* ---- Footer ------------------------------------------------------------ */

.foot {
  border-top: 1px solid var(--rule); padding: 1.5rem 1rem;
  text-align: center; color: var(--ink-3); font-size: .85rem;
}
.foot p { margin: 0; }
