/* AutoVeil styles.
   Layout and spacing utilities come from Tailwind (CDN) in index.html.
   This file holds the theme tokens and the component classes that app.js also uses.
   Look: warm paper and deep teal by day, ink-green and aqua by night. Frosted panels, pill controls. */

/* ---------- theme tokens ----------
   Light by default. Dark when the system prefers it, unless the user forced light.
   The user can force either theme with data-theme on <html> (see js/theme-init.js).
   --box is also read by the canvas code in js/app.js. */
:root {
  --bg: #f3efe7; --surface: rgba(255, 253, 248, .78); --sunk: #e6e0d3; --ink: #1a2422; --muted: #5b6965; --line: #d6cebe;
  --accent: #0b6e6a; --accent-ink: #ffffff; --box: #e11d48;
  --glow-a: rgba(11, 110, 106, .13); --glow-b: rgba(225, 29, 72, .07);
  --warn: #8a4f00; --warn-bg: #fbefd5; --bad: #b3261e;
  --mono: "IBM Plex Mono", ui-monospace, Menlo, Consolas, monospace;
  --display: Fraunces, Georgia, serif;
  --radius: 16px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0a1110; --surface: rgba(17, 29, 28, .78); --sunk: #060b0b; --ink: #e5efec; --muted: #8ba19b; --line: #25383a;
    --accent: #4fd1c5; --accent-ink: #04211e; --box: #ff5c8a;
    --glow-a: rgba(79, 209, 197, .12); --glow-b: rgba(255, 92, 138, .07);
    --warn: #f0b95a; --warn-bg: #2b2210; --bad: #ff8a80;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0a1110; --surface: rgba(17, 29, 28, .78); --sunk: #060b0b; --ink: #e5efec; --muted: #8ba19b; --line: #25383a;
  --accent: #4fd1c5; --accent-ink: #04211e; --box: #ff5c8a;
  --glow-a: rgba(79, 209, 197, .12); --glow-b: rgba(255, 92, 138, .07);
  --warn: #f0b95a; --warn-bg: #2b2210; --bad: #ff8a80;
  color-scheme: dark;
}

/* ---------- base ---------- */
[hidden] { display: none !important; }
body {
  background:
    radial-gradient(900px 520px at 8% -8%, var(--glow-a), transparent 70%),
    radial-gradient(800px 480px at 100% 0%, var(--glow-b), transparent 70%),
    var(--bg);
  background-attachment: fixed;
  color: var(--ink); font-size: 14px; line-height: 1.5; -webkit-font-smoothing: antialiased; min-height: 100vh;
}
em { font-family: var(--display); font-style: italic; font-weight: 600; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
input[type=range] { width: 100%; min-width: 0; accent-color: var(--accent); }
input[type=checkbox] { accent-color: var(--accent); }
input[type=color] { width: 44px; height: 28px; padding: 0; border: 1px solid var(--line); border-radius: 999px; background: none; overflow: hidden; }
/* .panel prefix beats Tailwind's reset (select { padding: 0 }), which the CDN injects after this file */
.panel select { background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 8px 16px; min-width: 0; max-width: 100%; }

/* ---------- panels ---------- */
.panel {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); min-width: 0;
  -webkit-backdrop-filter: blur(14px) saturate(1.2); backdrop-filter: blur(14px) saturate(1.2);
  box-shadow: 0 1px 0 rgba(255, 255, 255, .25) inset, 0 8px 28px -18px rgba(0, 0, 0, .35);
}

/* ---------- photo list ---------- */
.add { display: block; border: 1.5px dashed var(--line); border-radius: 12px; padding: 12px 10px; text-align: center; color: var(--muted); cursor: pointer; }
.add:hover, .add.over, .drop:hover, .drop.over { border-color: var(--accent); }
.add:hover, .add.over, .drop.over { color: var(--accent); }
.add b { display: block; color: var(--ink); font-weight: 600; }
.thumb { display: flex; align-items: stretch; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--bg); }
.thumb.on { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.tsel { flex: 1; min-width: 0; display: flex; gap: 8px; align-items: center; padding: 4px; border: 0; background: none; text-align: left; }
.tsel img { width: 44px; height: 44px; object-fit: cover; border-radius: 8px; flex: none; background: var(--sunk); }
.tmeta { display: flex; flex-direction: column; min-width: 0; }
.tname { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 12px; }
.tstat { font: 11px var(--mono); color: var(--muted); }
.tstat.zero, .tstat.err { color: var(--warn); }
.tx { border: 0; background: none; color: var(--muted); padding: 0 8px; font-size: 18px; }
.tx:hover { color: var(--bad); }
@media (max-width: 980px) {
  .thumb { flex: none; width: 190px; }
}

/* ---------- editor ---------- */
.btn { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 6px 16px; transition: border-color .15s, background .15s; }
.btn:hover:not(:disabled) { border-color: var(--accent); }
.btn:disabled { opacity: .45; cursor: default; }
.btn[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; padding: 9px 16px; }
.note { font-size: 12.5px; color: var(--muted); }
.note.warn { color: var(--warn); background: var(--warn-bg); border-radius: 12px; padding: 8px 12px; }
.drop {
  display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 6px; min-height: 340px;
  border: 1.5px dashed var(--line); border-radius: 12px; padding: 24px; cursor: pointer; color: var(--muted);
  background: linear-gradient(160deg, transparent 55%, var(--glow-a));
}
.drop h2 { margin: 0; font: 600 36px/1.15 var(--display); letter-spacing: -.02em; text-wrap: balance; color: var(--ink); }
.drop h2 em { color: var(--accent); }
.drop p { margin: 0; max-width: 46ch; }
#cv { max-width: 100%; max-height: 74vh; width: auto; height: auto; touch-action: none; display: block; cursor: crosshair; border-radius: 6px; }

/* ---------- controls ---------- */
.grp { display: flex; flex-direction: column; gap: 8px; min-width: 0; border: 0; padding: 0; margin: 0; }
.grp > legend, .lbl { font: 500 11px var(--mono); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); padding: 0; }
/* fieldset legends ignore flex gap, so give the legend its own space */
.grp > legend { margin-bottom: 8px; }
.row { display: flex; align-items: center; gap: 10px; justify-content: space-between; min-width: 0; }
.row output { font: 12px var(--mono); color: var(--muted); min-width: 7ch; text-align: right; }
.chk { display: flex; gap: 8px; align-items: flex-start; }
.chk input { margin-top: 4px; }

/* segmented radio control (veil scope, cover method, theme): pill track, filled accent thumb */
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 2px; padding: 3px; border: 1px solid var(--line); border-radius: 999px; background: var(--sunk); }
.seg label { position: relative; text-align: center; padding: 5px 6px; cursor: pointer; border-radius: 999px; font-weight: 500; transition: background .15s, color .15s; }
.seg label:hover { color: var(--accent); }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label:has(input:checked) { background: var(--accent); color: var(--accent-ink); box-shadow: 0 1px 4px rgba(0, 0, 0, .25); }
.seg label:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 1px; }

/* ---------- detector status ---------- */
.model[data-s="ready"] .dot { background: var(--accent); box-shadow: 0 0 0 3px var(--glow-a); }
.model[data-s="init"] .dot { background: var(--box); animation: pulse 1s ease-in-out infinite; }
.model[data-s="error"] .dot { background: var(--bad); }
@keyframes pulse { 50% { opacity: .35; } }
@media (prefers-reduced-motion: reduce) { .model[data-s="init"] .dot { animation: none; } }
