/* ==========================================================================
   CardToCAD -- look & feel
   Palette lifted straight from the wordmark: dark blueprint navy, cardboard
   tan, cream linework, and the fiducial-marker orange dot. Corner brackets
   throughout echo the mat's own ArUco corner markers.
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;700&display=swap');

:root {
  --navy-900: #0a1628;
  --navy-800: #0d1f2e;
  --navy-700: #132a3d;
  --navy-600: #16324a;
  --navy-500: #1c3e5c;

  --cream: #f4f1ea;
  --cream-dim: #c9d1d9;

  --tan: #c89b6c;
  --tan-dim: #a67f52;

  --orange: #ff6a39;

  --border: rgba(244, 241, 234, 0.14);
  --border-strong: rgba(200, 155, 108, 0.55);

  --mono: 'JetBrains Mono', 'Courier New', Courier, monospace;
  --serif: Georgia, 'Times New Roman', serif;

  --radius: 2px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--navy-900);
  background-image:
    linear-gradient(180deg, var(--navy-800) 0%, var(--navy-900) 320px),
    repeating-linear-gradient(0deg, rgba(244,241,234,0.025) 0px, rgba(244,241,234,0.025) 1px, transparent 1px, transparent 32px),
    repeating-linear-gradient(90deg, rgba(244,241,234,0.025) 0px, rgba(244,241,234,0.025) 1px, transparent 1px, transparent 32px);
  color: var(--cream);
  font-family: var(--mono);
  font-size: 15px;
  line-height: 1.55;
}

.wrap {
  max-width: 880px;
  margin: 0 auto;
  padding: 0 24px 64px;
}

/* ---------- header ---------- */

.site-header {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 36px 0 28px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 40px;
}

.site-header img.logo {
  height: 92px;
  width: auto;
  flex-shrink: 0;
}

.site-header .headline {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding-bottom: 4px;
}

.site-header .headline .tagline {
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--cream-dim);
}

/* ---------- corner-bracket panel (fiducial-marker motif) ---------- */

.bracket-panel {
  position: relative;
  padding: 28px;
  margin-bottom: 24px;
  background: rgba(244, 241, 234, 0.03);
  border: 1px solid var(--border);
}

.corner {
  position: absolute;
  width: 16px;
  height: 16px;
  pointer-events: none;
}
.corner.tl { top: -1px; left: -1px; border-top: 2px solid var(--tan); border-left: 2px solid var(--tan); }
.corner.tr { top: -1px; right: -1px; border-top: 2px solid var(--tan); border-right: 2px solid var(--tan); }
.corner.bl { bottom: -1px; left: -1px; border-bottom: 2px solid var(--tan); border-left: 2px solid var(--tan); }
.corner.br { bottom: -1px; right: -1px; border-bottom: 2px solid var(--tan); border-right: 2px solid var(--tan); }

.bracket-panel.active .corner { border-color: var(--orange); }

/* ---------- section labels ---------- */

.eyebrow {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--tan);
  margin: 0 0 16px;
}
.eyebrow .dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--orange);
  flex-shrink: 0;
}

h1, h2, h3 {
  font-family: var(--serif);
  color: var(--cream);
  margin: 0 0 12px;
  font-weight: 700;
}
h2 { font-size: 20px; }

p { color: var(--cream-dim); }

/* ---------- upload dropzone ---------- */

.dropzone {
  display: block;
  position: relative;
  border: 2px dashed var(--border-strong);
  padding: 56px 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
  background: rgba(244, 241, 234, 0.02);
}
.dropzone:hover,
.dropzone.dragover {
  border-color: var(--orange);
  background: rgba(255, 106, 57, 0.05);
}
.dropzone input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}
.dropzone .dz-icon {
  font-size: 28px;
  color: var(--tan);
  margin-bottom: 10px;
}
.dropzone .dz-label {
  font-size: 14px;
  color: var(--cream);
}
.dropzone .dz-sub {
  font-size: 12px;
  color: var(--cream-dim);
  margin-top: 6px;
}
.dropzone .dz-filename {
  margin-top: 14px;
  font-size: 13px;
  color: var(--orange);
  display: none;
}

/* ---------- form controls ---------- */

label.field-label {
  display: block;
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--cream-dim);
  margin-bottom: 8px;
}

input[type="number"], input[type="text"] {
  width: 100%;
  background: var(--navy-800);
  border: 1px solid var(--border);
  color: var(--cream);
  font-family: var(--mono);
  font-size: 14px;
  padding: 10px 12px;
}
input[type="number"]:focus, input[type="text"]:focus {
  outline: none;
  border-color: var(--tan);
}

.field-row { margin: 22px 0; max-width: 220px; }
.field-hint { font-size: 11px; color: var(--cream-dim); margin-top: 6px; }

/* ---------- buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--mono);
  font-size: 13px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 13px 22px;
  border: 1px solid var(--tan);
  background: transparent;
  color: var(--cream);
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.btn:hover { background: var(--tan); color: var(--navy-900); }

.btn-primary {
  background: var(--orange);
  border-color: var(--orange);
  color: var(--navy-900);
  font-weight: 700;
}
.btn-primary:hover { background: #ff8259; border-color: #ff8259; color: var(--navy-900); }

.btn-row { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 8px; }

/* ---------- stats grid (results page) ---------- */

.stats-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  margin: 20px 0 28px;
}
.stat-cell {
  flex: 1 1 150px;
  background: var(--navy-800);
  padding: 16px 18px;
}
.stat-cell .stat-label {
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--tan);
  margin-bottom: 6px;
}
.stat-cell .stat-value {
  font-size: 22px;
  color: var(--cream);
  font-weight: 500;
}
.stat-cell .stat-unit {
  font-size: 12px;
  color: var(--cream-dim);
  margin-left: 3px;
}

/* ---------- preview image ---------- */

.preview-frame {
  position: relative;
  border: 1px solid var(--border);
  background: var(--navy-800);
  padding: 8px;
  margin-bottom: 28px;
}
.preview-frame img {
  display: block;
  width: 100%;
  height: auto;
}

/* ---------- alerts / warnings ---------- */

.alert {
  border: 1px solid var(--border-strong);
  border-left: 3px solid var(--orange);
  background: rgba(255, 106, 57, 0.06);
  padding: 12px 16px;
  font-size: 13px;
  color: var(--cream);
  margin-bottom: 10px;
}
.alert.error {
  border-left-color: #ff4d4d;
  background: rgba(255, 77, 77, 0.07);
}

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

.site-footer {
  margin-top: 56px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--cream-dim);
  letter-spacing: 0.04em;
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}
.site-footer .marker-dot {
  display: inline-block;
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--orange);
  margin-right: 6px;
  vertical-align: middle;
}

a { color: var(--tan); }
a:hover { color: var(--orange); }


/* ---------- snap slider ---------- */

.snap-row { margin: 26px 0 24px; }
.snap-track {
  display: flex;
  align-items: center;
  gap: 14px;
}
.snap-end {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--cream-dim);
  white-space: nowrap;
}
.snap-out {
  min-width: 34px;
  text-align: right;
  font-size: 16px;
  color: var(--orange);
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  flex: 1;
  height: 22px;
  background: transparent;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 2px;
  background: var(--border-strong);
}
input[type="range"]::-moz-range-track {
  height: 2px;
  background: var(--border-strong);
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px; height: 16px;
  margin-top: -7px;
  background: var(--orange);
  border: 2px solid var(--navy-900);
  border-radius: 50%;
}
input[type="range"]::-moz-range-thumb {
  width: 12px; height: 12px;
  background: var(--orange);
  border: 2px solid var(--navy-900);
  border-radius: 50%;
}
input[type="range"]:disabled { opacity: 0.5; cursor: progress; }
input[type="range"]:focus { outline: none; }
input[type="range"]:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 2px var(--tan); }

.snap-status { min-height: 18px; margin-top: 12px; font-size: 12px; color: var(--cream-dim); }
.snap-status.busy { color: var(--tan); }
.snap-status.ok { color: var(--cream-dim); }
.snap-status.err { color: #ff6b6b; }

.stat-cell .stat-value.stat-text { font-size: 15px; line-height: 1.35; padding-top: 4px; }

/* ---------- outside / inside edge controls ---------- */

.edge-grid {
  display: flex;
  flex-wrap: wrap;
  margin: 18px -8px 12px;
}
.edge-ctl {
  flex: 1 1 320px;
  margin: 8px;
  border: 1px solid var(--border);
  background: rgba(244, 241, 234, 0.02);
  padding: 16px 18px 14px;
  transition: opacity 0.15s ease;
}
.edge-ctl.off .snap-track,
.edge-ctl.off .field-hint,
.edge-ctl.off .edge-blurb { opacity: 0.38; }
.edge-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.edge-title {
  font-family: var(--serif);
  font-weight: 700;
  font-size: 17px;
  color: var(--cream);
}
.edge-blurb {
  font-size: 12px;
  color: var(--cream-dim);
  margin: 4px 0 14px;
}
.edge-ctl .snap-track { gap: 10px; }
.edge-ctl .field-hint { margin-top: 8px; }

/* on/off switch */
.switch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
}
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch-ui {
  position: relative;
  width: 36px; height: 20px;
  border: 1px solid var(--border-strong);
  background: var(--navy-800);
  transition: background 0.15s ease, border-color 0.15s ease;
}
.switch-ui::after {
  content: "";
  position: absolute;
  top: 2px; left: 2px;
  width: 14px; height: 14px;
  background: var(--cream-dim);
  transition: transform 0.15s ease, background 0.15s ease;
}
.switch input:checked + .switch-ui { border-color: var(--orange); background: rgba(255, 106, 57, 0.18); }
.switch input:checked + .switch-ui::after { transform: translateX(16px); background: var(--orange); }
.switch input:focus-visible + .switch-ui { box-shadow: 0 0 0 2px var(--tan); }
.switch input:disabled + .switch-ui { opacity: 0.5; cursor: progress; }
.switch-text {
  min-width: 22px;
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--cream-dim);
}

/* results page extras */
.stat-sub { font-size: 11px; color: var(--cream-dim); margin-top: 2px; min-height: 14px; }
.btn.disabled {
  opacity: 0.35;
  cursor: not-allowed;
  pointer-events: none;
}
.stl-note { margin-top: 12px; font-size: 12px; color: var(--cream-dim); }
.stl-note[hidden] { display: none; }


/* ==========================================================================
   Browser version additions
   ========================================================================== */

[hidden] { display: none !important; }

/* engine (processing) status line under the upload form */
.engine-status {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 18px;
  font-size: 12px;
  color: var(--cream-dim);
}
.engine-status .pip {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--tan);
  flex-shrink: 0;
  animation: pip 1.1s ease-in-out infinite;
}
.engine-status.ready .pip { background: var(--orange); animation: none; }
.engine-status.err { color: #ff6b6b; }
.engine-status.err .pip { background: #ff4d4d; animation: none; }
@keyframes pip { 50% { opacity: 0.25; } }

.btn[disabled], .btn.busy { opacity: 0.6; cursor: progress; }

.mat-links { font-size: 13px; margin: -4px 0 20px; color: var(--cream-dim); }
.mat-links .mat-row { margin-top: 4px; }
.mat-links .mat-region {
  display: inline-block; min-width: 110px;
  font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--tan);
}
.mat-links .field-hint { display: block; margin-top: 8px; max-width: 60em; }

/* small screens */
@media (max-width: 560px) {
  .wrap { padding: 0 16px 48px; }
  .site-header { padding: 24px 0 20px; margin-bottom: 28px; }
  .site-header img.logo { height: 64px; }
  .bracket-panel { padding: 20px 16px; }
  .dropzone { padding: 40px 16px; }
  .edge-grid { margin: 18px 0 12px; }
  .edge-ctl { flex: 1 1 100%; margin: 8px 0; min-width: 0; }
  .snap-end { font-size: 10px; }
}
