/* House theme of the vincentrozenberg.com tools: Tailwind slate neutrals
   written as literal hex, slate-700 as the main colour, rose-600 as the only
   complement, failures in red. Nothing is fetched: no webfont, no CDN. */

:root {
  --brand-main: #334155; /* slate-700 */
  --brand-comp: #e11d48; /* rose-600 */

  --slate-50: #f8fafc;
  --slate-100: #f1f5f9;
  --slate-200: #e2e8f0;
  --slate-300: #cbd5e1;
  --slate-400: #94a3b8;
  --slate-500: #64748b;
  --slate-700: #334155;
  --slate-800: #1e293b;
  --slate-900: #0f172a;
  --slate-950: #020617;
  --red-500: #ef4444;
  --red-600: #dc2626;
  --white: #ffffff;

  --fg: var(--slate-700);
  --fg-muted: var(--slate-500);
  --fg-strong: var(--slate-900);
  --fg-on-accent: var(--white);
  --fg-failure: var(--red-600);
  --accent: var(--brand-main);
  --accent-strong: color-mix(in srgb, var(--brand-main) 80%, var(--slate-950));
  --comp: var(--brand-comp);
  --comp-soft: color-mix(in srgb, var(--brand-comp) 10%, var(--white));
  --failure-soft: color-mix(in srgb, var(--red-500) 10%, var(--white));

  --bg: var(--slate-100);
  --bg-panel: var(--white);
  --bg-sunken: var(--slate-50);
  --bg-highlight: var(--slate-100);
  --line: var(--slate-200);
  --line-strong: var(--slate-300);
  --viewer-top: #f8fafc;
  --viewer-bottom: #e2e8f0;
  --shadow-panel: 0 1px 2px 0 rgba(15, 23, 42, 0.06);
  --focus: var(--brand-comp);

  --font: "Roboto", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --radius: 8px;

  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --fg: var(--slate-50);
    --fg-muted: var(--slate-400);
    --fg-strong: var(--white);
    --fg-on-accent: var(--slate-950);
    --fg-failure: var(--red-500);
    --accent: color-mix(in srgb, var(--brand-main) 78%, var(--white));
    --accent-strong: var(--slate-300);
    --comp: color-mix(in srgb, var(--brand-comp) 78%, var(--white));
    --comp-soft: color-mix(in srgb, var(--brand-comp) 18%, var(--slate-900));
    --failure-soft: color-mix(in srgb, var(--red-500) 16%, var(--slate-900));

    --bg: var(--slate-900);
    --bg-panel: var(--slate-800);
    --bg-sunken: color-mix(in srgb, var(--slate-900) 60%, var(--slate-800));
    --bg-highlight: var(--slate-700);
    --line: rgba(148, 163, 184, 0.24);
    --line-strong: rgba(148, 163, 184, 0.4);
    --viewer-top: #475569;
    --viewer-bottom: #1e293b;
    --shadow-panel: 0 1px 3px 0 rgba(2, 6, 23, 0.5), 0 1px 2px -1px rgba(2, 6, 23, 0.5);
  }
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  font-weight: 400;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-synthesis: none;
}

button, input, select, textarea { font: inherit; color: inherit; }

h1, h2, h3 { margin: 0; color: var(--fg-strong); letter-spacing: -0.01em; }
h1 { font-size: 1.45rem; font-weight: 600; line-height: 1.3; }
h2 { font-size: 1.15rem; font-weight: 600; line-height: 1.4; }
h3 { font-size: 1rem; font-weight: 600; }
p { margin: 0; }
a { color: var(--accent); text-underline-offset: 2px; }
a:hover { color: var(--comp); }

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: 4px;
}

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.wrap {
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 16px;
}

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

.site-header { padding: 28px 0 18px; }
.site-header .wrap { display: flex; flex-wrap: wrap; gap: 8px 20px; align-items: end; justify-content: space-between; }
.brand { display: flex; align-items: center; gap: 10px; }
.brand svg { flex: none; }
.tagline { color: var(--fg-muted); margin-top: 2px; }

.privacy {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg-panel);
  color: var(--fg-muted);
  font-size: 0.92rem;
}
.privacy svg { color: var(--comp); flex: none; }

main { flex: 1; padding-bottom: 32px; }

/* ---------- panels ---------- */

.panel {
  background: var(--bg-panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-panel);
}

/* ---------- drop zone ---------- */

.drop {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 48px 20px;
  text-align: center;
  border: 1.5px dashed var(--line-strong);
  background: var(--bg-panel);
  transition: border-color 120ms, background-color 120ms;
}
.drop.compact { flex-direction: row; flex-wrap: wrap; padding: 14px 16px; gap: 8px 14px; }
.drop.compact .drop-icon, .drop.compact .drop-hint { display: none; }
.drop-icon { color: var(--fg-muted); }
.drop-title { font-size: 1.1rem; font-weight: 600; color: var(--fg-strong); }
.drop-hint { color: var(--fg-muted); max-width: 46ch; }
body.dragging .drop {
  border-color: var(--comp);
  background: var(--comp-soft);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 34px;
  padding: 6px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--line-strong);
  background: var(--bg-panel);
  color: var(--fg);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}
.btn:hover { background: var(--bg-highlight); color: var(--fg); }
.btn.primary {
  background: var(--brand-main);
  border-color: var(--brand-main);
  color: var(--white);
}
.btn.primary:hover { background: color-mix(in srgb, var(--brand-main) 85%, var(--slate-950)); color: var(--white); }
@media (prefers-color-scheme: dark) {
  .btn.primary { background: var(--slate-50); border-color: var(--slate-50); color: var(--slate-900); }
  .btn.primary:hover { background: var(--slate-200); color: var(--slate-900); }
}
.btn.small { min-height: 28px; padding: 3px 10px; font-size: 0.9rem; }
.btn[disabled] { opacity: 0.5; cursor: default; }

/* ---------- progress ---------- */

.progress { margin-top: 16px; padding: 18px 20px; }
.progress-head { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; flex-wrap: wrap; }
.progress-file { color: var(--fg-muted); overflow-wrap: anywhere; }
.stages { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 6px; }
.stage { display: flex; align-items: center; gap: 10px; color: var(--fg-muted); }
.stage .dot {
  width: 14px; height: 14px; flex: none;
  border-radius: 50%;
  border: 1.5px solid var(--line-strong);
}
.stage.active { color: var(--fg-strong); }
.stage.active .dot { border-color: var(--comp); border-top-color: transparent; animation: spin 0.8s linear infinite; }
.stage.done { color: var(--fg); }
.stage.done .dot { border-color: var(--accent); background: var(--accent); box-shadow: inset 0 0 0 2px var(--bg-panel); }
.stage .detail { margin-left: auto; font-variant-numeric: tabular-nums; color: var(--fg-muted); }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .stage.active .dot { animation: none; border-top-color: var(--comp); } }

.bar {
  margin-top: 14px;
  height: 4px;
  border-radius: 2px;
  background: var(--line);
  overflow: hidden;
}
.bar > span { display: block; height: 100%; width: 0; background: var(--comp); transition: width 150ms; }
.bar.indeterminate > span { width: 30%; animation: slide 1.2s ease-in-out infinite; }
@keyframes slide { from { transform: translateX(-100%); } to { transform: translateX(340%); } }
@media (prefers-reduced-motion: reduce) { .bar.indeterminate > span { animation: none; width: 100%; opacity: 0.4; } }

/* ---------- error ---------- */

.error {
  margin-top: 16px;
  padding: 16px 20px;
  border-color: color-mix(in srgb, var(--fg-failure) 40%, transparent);
  background: var(--failure-soft);
}
.error h2 { color: var(--fg-failure); font-size: 1rem; }
.error p { margin-top: 4px; }
.error details { margin-top: 8px; color: var(--fg-muted); }
.error pre { white-space: pre-wrap; overflow-wrap: anywhere; font-family: var(--mono); font-size: 0.9rem; margin: 6px 0 0; }

/* ---------- result ---------- */

.result {
  margin-top: 16px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 16px;
  align-items: start;
}
@media (max-width: 860px) {
  .result { grid-template-columns: minmax(0, 1fr); }
}

.viewer {
  position: relative;
  overflow: hidden;
  aspect-ratio: 4 / 3;
  max-height: 72vh;
  width: 100%;
  background: linear-gradient(180deg, var(--viewer-top), var(--viewer-bottom));
}
@media (max-width: 860px) { .viewer { aspect-ratio: 1 / 1; max-height: 70vh; } }
.viewer canvas { display: block; width: 100%; height: 100%; touch-action: none; }
.viewer canvas:focus-visible { outline-offset: -3px; border-radius: var(--radius); }
.viewer-tools {
  position: absolute;
  top: 10px;
  right: 10px;
  display: flex;
  gap: 6px;
}
.viewer-tools .btn { background: color-mix(in srgb, var(--bg-panel) 85%, transparent); backdrop-filter: blur(6px); }
.viewer-hint {
  position: absolute;
  left: 12px;
  bottom: 10px;
  right: 12px;
  color: var(--fg-muted);
  font-size: 0.88rem;
  pointer-events: none;
}
.viewer-fallback {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  text-align: center;
  color: var(--fg-muted);
}

.side { display: grid; gap: 16px; min-width: 0; }
.side > .panel { padding: 16px; }

.file-name { overflow-wrap: anywhere; }
.file-meta { color: var(--fg-muted); margin-top: 2px; }

.stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 14px 0;
}
.stat {
  padding: 8px 10px;
  border-radius: var(--radius);
  background: var(--bg-sunken);
  border: 1px solid var(--line);
  min-width: 0;
}
.stat b {
  display: block;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--fg-strong);
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}
.stat span { color: var(--fg-muted); font-size: 0.9rem; }

.download { width: 100%; min-height: 40px; font-size: 1rem; }
.howto { margin-top: 10px; color: var(--fg-muted); }
.howto kbd {
  font-family: inherit;
  font-weight: 600;
  color: var(--fg);
}

.warnings h3 { color: var(--fg-strong); display: flex; align-items: center; gap: 6px; }
.warnings h3::before {
  content: "";
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--comp);
  flex: none;
}
.warnings ul { margin: 8px 0 0; padding-left: 18px; display: grid; gap: 4px; }
.warnings li { overflow-wrap: anywhere; }

/* ---------- part list ---------- */

.parts-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.parts-head span { color: var(--fg-muted); }
.parts-filter {
  width: 100%;
  margin-top: 10px;
  padding: 6px 10px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--bg-panel);
}
.tree {
  margin: 10px -6px 0;
  max-height: 420px;
  overflow: auto;
  overscroll-behavior: contain;
}
.tree ul { list-style: none; margin: 0; padding: 0 0 0 14px; }
.tree > ul { padding-left: 0; }
.tree summary, .tree .leaf {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 6px;
  border-radius: 6px;
  cursor: default;
  min-width: 0;
}
.tree summary { cursor: pointer; list-style: none; font-weight: 600; color: var(--fg-strong); }
.tree summary::-webkit-details-marker { display: none; }
.tree summary::before {
  content: "";
  width: 0; height: 0; flex: none;
  border-left: 5px solid var(--fg-muted);
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  transition: transform 100ms;
}
.tree details[open] > summary::before { transform: rotate(90deg); }
.tree .leaf:hover, .tree summary:hover, .tree .leaf.hot { background: var(--bg-highlight); }
.tree .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree .count { color: var(--fg-muted); font-weight: 400; font-variant-numeric: tabular-nums; flex: none; }
.swatch {
  width: 12px; height: 12px; flex: none;
  border-radius: 3px;
  border: 1px solid var(--line-strong);
}
.tree .more { color: var(--fg-muted); padding: 3px 6px; }

/* ---------- about ---------- */

.about {
  margin-top: 24px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  color: var(--fg-muted);
}
.about h2 { font-size: 1rem; margin-bottom: 4px; }
@media (max-width: 760px) { .about { grid-template-columns: minmax(0, 1fr); } }

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

.site-footer {
  border-top: 1px solid var(--line);
  padding: 16px 0 24px;
  color: var(--fg-muted);
  font-size: 0.92rem;
}
.site-footer .wrap { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px 20px; }

[hidden] { display: none !important; }

/* The tree scrolls, so an outside outline would be clipped. */
.tree summary:focus-visible { outline-offset: -2px; }
