/* PhotoApp — shared styles (user pages + base for admin). Mobile-first. */

:root {
  --accent: #2563eb;
  --accent-contrast: #ffffff;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #eef0f3;
  --text: #15181d;
  --muted: #5b6370;
  --border: #d5d9e0;
  --danger: #b42318;
  --danger-bg: #fdecea;
  --success: #1a7f37;
  --success-bg: #e8f5ec;
  --warning: #8a5a00;
  --warning-bg: #fff4dc;
  --info-bg: #eaf1fd;
  --info: #1e3a8a;
  --focus: #1d4ed8;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgb(0 0 0 / .06), 0 2px 8px rgb(0 0 0 / .05);
  --tap: 48px;
  --gutter: 16px;
  --maxw: 960px;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --surface: #181b21;
    --surface-2: #22262e;
    --text: #e8eaee;
    --muted: #a0a8b5;
    --border: #343a45;
    --danger: #ff8a80;
    --danger-bg: #3a1714;
    --success: #6fd38a;
    --success-bg: #12301b;
    --warning: #ffcc66;
    --warning-bg: #3a2c0c;
    --info-bg: #172440;
    --info: #b9cdf7;
    --focus: #8ab4ff;
    --shadow: 0 1px 2px rgb(0 0 0 / .4);
  }
}

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

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  min-height: 100vh;
  min-height: 100dvh;
  padding-bottom: env(safe-area-inset-bottom);
}

[hidden] { display: none !important; }

a { color: var(--accent); text-underline-offset: 2px; }
@media (prefers-color-scheme: dark) { a { color: color-mix(in srgb, var(--accent) 55%, white); } }

h1, h2, h3 { line-height: 1.25; margin: 0 0 .5em; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 .75em; }
hr { border: 0; border-top: 1px solid var(--border); margin: 1.25rem 0; }
img { max-width: 100%; }

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

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

.skip-link {
  position: absolute; left: 8px; top: -60px; z-index: 100;
  background: var(--surface); color: var(--text);
  padding: 10px 14px; border-radius: var(--radius-sm); box-shadow: var(--shadow);
}
.skip-link:focus { top: 8px; }

.muted { color: var(--muted); }
.small { font-size: .875rem; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: calc(8px + env(safe-area-inset-top)) var(--gutter) 8px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.brand {
  display: inline-flex; align-items: center; gap: 10px;
  color: var(--text); text-decoration: none; font-weight: 700; font-size: 1.1rem;
  min-height: var(--tap);
}
.brand-logo { height: 32px; width: auto; max-width: 120px; object-fit: contain; }
.topbar nav ul { list-style: none; margin: 0; padding: 0; display: flex; gap: 4px; flex-wrap: wrap; }
.topbar nav a {
  display: inline-flex; align-items: center; min-height: 40px; padding: 0 12px;
  border-radius: 999px; color: var(--text); text-decoration: none; font-size: .95rem;
}
.topbar nav a:hover { background: var(--surface-2); }
.topbar nav a[aria-current="page"] { background: var(--accent); color: var(--accent-contrast); }

main {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: var(--gutter);
}
main:focus { outline: none; }

.loading { color: var(--muted); padding: 2rem 0; text-align: center; }

/* ---------- cards, alerts ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}
.card.narrow { max-width: 480px; margin-left: auto; margin-right: auto; }
.page-message { max-width: 560px; margin: 2rem auto; text-align: center; }
.page-message h1:focus { outline: none; }
body.page-message-mode main > :not(.page-message) { display: none !important; }

.alert {
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin: 0 0 16px;
  border: 1px solid transparent;
}
.alert p:last-child { margin-bottom: 0; }
.alert-title { font-size: 1.05rem; margin-bottom: .25em; }
.alert-error { background: var(--danger-bg); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 30%, transparent); }
.alert-success { background: var(--success-bg); color: var(--success); border-color: color-mix(in srgb, var(--success) 30%, transparent); }
.alert-warning { background: var(--warning-bg); color: var(--warning); border-color: color-mix(in srgb, var(--warning) 30%, transparent); }
.alert-info { background: var(--info-bg); color: var(--info); border-color: color-mix(in srgb, var(--info) 25%, transparent); }
.alert .btn { margin-top: 8px; }
.banner { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
.banner p { margin: 0; }
.banner .btn { margin-top: 0; }

.error-text { color: var(--danger); font-size: .9rem; margin: 0; }

/* ---------- forms ---------- */
.stack > * + * { margin-top: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.stack .field { margin-bottom: 0; }
.field-compact { margin-bottom: 8px; }
label { font-weight: 600; font-size: .95rem; }
.help { color: var(--muted); font-size: .875rem; margin: 0; }
input[type="text"], input[type="email"], input[type="password"], input[type="number"], input[type="search"],
input[type="date"], input[type="url"], select, textarea {
  width: 100%;
  min-height: var(--tap);
  padding: 10px 12px;
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
textarea { min-height: 80px; resize: vertical; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid var(--focus); outline-offset: 0; border-color: var(--focus); }
input[aria-invalid="true"] { border-color: var(--danger); }
input[type="checkbox"], input[type="radio"] { width: 22px; height: 22px; accent-color: var(--accent); margin: 0; flex: none; }
input[type="color"] { width: 56px; height: var(--tap); padding: 2px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); }
.checkbox-field { flex-direction: row; align-items: flex-start; gap: 10px; }
.checkbox-field label { font-weight: 500; padding-top: 1px; }
.form-status { min-height: 1.5em; color: var(--muted); margin: 0; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--tap); padding: 0 18px;
  font: inherit; font-weight: 600; text-decoration: none; line-height: 1.2;
  border-radius: var(--radius-sm); border: 1px solid transparent;
  cursor: pointer; user-select: none; -webkit-tap-highlight-color: transparent;
  transition: filter .15s, background .15s;
}
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: var(--accent-contrast); }
.btn-primary:not(:disabled):hover { filter: brightness(1.08); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-secondary:not(:disabled):hover { background: var(--surface-2); }
.btn-danger { background: var(--danger); color: #fff; }
@media (prefers-color-scheme: dark) { .btn-danger { color: #1a0000; } }
.btn-danger-text { color: var(--danger); }
.btn-block { width: 100%; }
.btn-small { min-height: 40px; padding: 0 12px; font-size: .9rem; }
.btn-large { min-height: 56px; padding: 0 24px; font-size: 1.05rem; }
.btn-google { gap: 10px; }
.icon { width: 22px; height: 22px; flex: none; }
.badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 24px; height: 24px; padding: 0 6px; border-radius: 999px;
  background: var(--accent-contrast); color: var(--accent); font-size: .85rem;
}
.file-btn { position: relative; }
.file-btn:focus-within { outline: 3px solid var(--focus); outline-offset: 2px; }

.actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.divider { display: flex; align-items: center; gap: 10px; color: var(--muted); margin: 18px 0; }
.divider::before, .divider::after { content: ""; flex: 1; border-top: 1px solid var(--border); }

.altcha-slot { min-height: 60px; }
altcha-widget { display: block; --altcha-max-width: 100%; --altcha-color-base: var(--surface); --altcha-color-text: var(--text); --altcha-color-border: var(--border); --altcha-border-radius: 8px; }

/* ---------- camera step ---------- */
.camera-box {
  position: relative;
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
  aspect-ratio: 3 / 4;
  max-height: 62vh;
  max-height: 62dvh;
  width: 100%;
  margin: 0 auto;
}
@media (min-width: 700px) { .camera-box { aspect-ratio: 4 / 3; } }
.camera-video { width: 100%; height: 100%; object-fit: cover; display: block; background: #000; }
.camera-box:not(.live) .camera-video { visibility: hidden; }
.camera-overlay {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  padding: 24px; text-align: center; color: #fff;
  background: linear-gradient(180deg, #1c2029, #0d0f13);
}
.camera-message { max-width: 34ch; margin: 0; }
.camera-flash { position: absolute; inset: 0; background: #fff; opacity: 0; pointer-events: none; }
.camera-flash.flash { animation: flash .25s ease-out; }
@keyframes flash { from { opacity: .7; } to { opacity: 0; } }

.camera-controls {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 10px;
  padding: 14px 0;
}
.camera-side { display: flex; }
.camera-side-end { justify-content: flex-end; }
.camera-side .btn { padding: 0 12px; }
@media (max-width: 380px) { .camera-side .btn span:not(.badge) { display: none; } #gallery-btn::after { content: "Galerij"; } }
.shutter {
  width: 76px; height: 76px; border-radius: 50%;
  border: 5px solid var(--accent); background: var(--surface);
  box-shadow: inset 0 0 0 4px var(--surface), inset 0 0 0 40px var(--accent);
  cursor: pointer; transition: transform .08s;
  -webkit-tap-highlight-color: transparent;
}
.shutter:active:not(:disabled) { transform: scale(.92); }
.shutter:disabled { opacity: .4; cursor: not-allowed; }

.strip-wrap { margin-top: 4px; }
.draft-count { margin: 0 0 8px; font-weight: 600; }
.thumb-strip {
  list-style: none; margin: 0; padding: 0 0 6px;
  display: flex; gap: 8px; overflow-x: auto; scroll-snap-type: x proximity;
}
.thumb-strip li { flex: none; scroll-snap-align: end; }
.thumb { width: 64px; height: 64px; object-fit: cover; border-radius: var(--radius-sm); display: block; background: var(--surface-2); }
.img-placeholder {
  display: flex; align-items: center; justify-content: center; text-align: center;
  background: var(--surface-2); color: var(--muted); font-size: .75rem; padding: 4px; overflow: hidden; word-break: break-all;
}

/* ---------- review step ---------- */
.step-header { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.step-header h1 { margin: 0; }
.step-header p { margin: 0; }
.review-grid {
  list-style: none; margin: 0 0 16px; padding: 0;
  display: grid; grid-template-columns: 1fr; gap: 12px;
}
@media (min-width: 600px) { .review-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 900px) { .review-grid { grid-template-columns: repeat(3, 1fr); } }
.review-item {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; display: flex; flex-direction: column;
}
.review-item.invalid { border-color: var(--danger); }
.review-img { background: var(--surface-2); aspect-ratio: 4 / 3; }
.review-thumb { width: 100%; height: 100%; object-fit: cover; display: block; }
.review-body { padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.review-meta { margin: 0; font-weight: 600; }
.review-body .btn { align-self: flex-start; }
.review-grid .empty { color: var(--muted); padding: 24px 0; text-align: center; }
.sticky-actions {
  position: sticky; bottom: 0; z-index: 10;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(6px);
  padding: 12px 0 calc(12px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
}
.sticky-actions #send { margin-left: auto; }

/* ---------- upload step ---------- */
progress {
  width: 100%; height: 12px; border-radius: 999px; overflow: hidden;
  appearance: none; -webkit-appearance: none; border: 0; background: var(--surface-2); accent-color: var(--accent);
}
progress::-webkit-progress-bar { background: var(--surface-2); border-radius: 999px; }
progress::-webkit-progress-value { background: var(--accent); border-radius: 999px; transition: width .2s; }
progress::-moz-progress-bar { background: var(--accent); border-radius: 999px; }
.progress-label { display: block; margin-bottom: 8px; }
.upload-status { margin: 8px 0 0; font-weight: 600; }
.upload-list { list-style: none; margin: 0 0 16px; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.upload-item {
  display: flex; gap: 12px; align-items: center;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 8px;
}
.upload-thumb { width: 56px; height: 56px; object-fit: cover; border-radius: 6px; flex: none; }
.upload-info { flex: 1; display: grid; grid-template-columns: 1fr auto; gap: 4px 8px; align-items: center; min-width: 0; }
.upload-info progress { grid-column: 1 / -1; height: 6px; }
.upload-name { font-weight: 600; }
.upload-state { font-size: .9rem; color: var(--muted); text-align: right; }
.upload-error { grid-column: 1 / -1; }
.state-done .upload-state, .state-duplicate .upload-state { color: var(--success); font-weight: 600; }
.state-failed, .state-skipped { border-color: var(--danger); }
.state-failed .upload-state, .state-skipped .upload-state { color: var(--danger); font-weight: 600; }
.state-retrying .upload-state { color: var(--warning); }

/* ---------- my photos ---------- */
.photo-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; grid-template-columns: 1fr; }
@media (min-width: 700px) { .photo-list { grid-template-columns: repeat(2, 1fr); } }
.photo-item { display: flex; gap: 14px; padding: 12px; margin: 0; align-items: flex-start; }
.photo-thumb { width: 104px; height: 104px; object-fit: cover; border-radius: var(--radius-sm); flex: none; background: var(--surface-2); }
.photo-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.photo-body p { margin: 0; }
.photo-top { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; }
.caption { overflow-wrap: anywhere; white-space: pre-wrap; }
.reject-reason { color: var(--danger); font-size: .95rem; }
.photo-body .btn { align-self: flex-start; margin-top: 4px; }
.photo-list .empty { grid-column: 1 / -1; text-align: center; }

.status {
  display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: .85rem; font-weight: 600;
  background: var(--surface-2); color: var(--text);
}
.status-processed { background: var(--success-bg); color: var(--success); }
.status-rejected { background: var(--danger-bg); color: var(--danger); }
.status-review { background: var(--warning-bg); color: var(--warning); }
.status-uploaded, .status-processing { background: var(--info-bg); color: var(--info); }
.status-deleted { background: var(--surface-2); color: var(--muted); }

/* ---------- profile / prose ---------- */
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0 0 16px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.prose { overflow-wrap: anywhere; }
.prose h1 { font-size: 1.6rem; }
.prose ul, .prose ol { padding-left: 1.4em; margin: 0 0 .75em; }
.prose blockquote { margin: 0 0 .75em; padding: .25em 1em; border-left: 4px solid var(--border); color: var(--muted); }
.prose pre { background: var(--surface-2); padding: 12px; border-radius: var(--radius-sm); overflow-x: auto; }
.prose code { background: var(--surface-2); padding: 0 4px; border-radius: 4px; font-size: .92em; }
.prose pre code { background: none; padding: 0; }
.privacy-details { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 0 12px; }
.privacy-details summary { min-height: var(--tap); display: flex; align-items: center; cursor: pointer; font-weight: 600; }
.privacy-details .prose { max-height: 40vh; overflow: auto; padding-bottom: 12px; }

/* ---------- dialog & toast ---------- */
.dialog {
  border: 0; border-radius: var(--radius); padding: 0; max-width: min(480px, calc(100vw - 32px)); width: 100%;
  background: var(--surface); color: var(--text); box-shadow: 0 10px 40px rgb(0 0 0 / .3);
}
.dialog::backdrop { background: rgb(0 0 0 / .45); }
.dialog-body { padding: 20px; }
.dialog-title { font-size: 1.2rem; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; margin-top: 16px; }

.toast-region {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(16px + env(safe-area-inset-bottom)); z-index: 1000;
  display: flex; flex-direction: column; gap: 8px; width: min(480px, calc(100vw - 32px)); pointer-events: none;
}
.toast {
  pointer-events: auto; padding: 12px 16px; border-radius: var(--radius-sm);
  background: #1f2430; color: #fff; box-shadow: 0 6px 20px rgb(0 0 0 / .25);
  transition: opacity .3s, transform .3s;
}
.toast-success { background: #14532d; }
.toast-error { background: #7f1d1d; }
.toast-leave { opacity: 0; transform: translateY(8px); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
