/* HEIC to JPG: WBJ Solutions */

/* Colours follow the WBJ Solutions site (Palette.php):
   light = "Violet and orange", dark = "Darker". Violet carries the
   structure, buttons and links; orange is the highlight, never text on white. */
:root {
  --bg: #F6F4FA;
  --surface: #FFFFFF;
  --surface-2: #FAF9FC;
  --ink: #16131C;
  --heading: #17121F;
  --ink-2: #3D3846;
  --muted: #5F5B69;
  --line: #E6E2EE;
  --line-2: #EEEBF4;
  --field: #D3CDDD;
  --accent: #6D0AB6;
  --accent-strong: #6D0AB6;
  --accent-hover: #5A0896;
  --accent-ink: #FFFFFF;
  --accent-tint: #F1E8FB;
  --accent-track: #E2D2F5;
  --bar: #EE811B;
  --link: #5A0896;
  --success: #2F7D4F;
  --success-tint: #E3F1E8;
  --danger: #B4332A;
  --danger-ink: #6B3A35;
  --danger-tint: #FDF3F2;
  --danger-line: #E9B8B2;
  --tile: #ECE8F2;
  --shadow: 0 1px 2px rgba(22, 19, 28, 0.04);
  --radius: 16px;
  --font: 'Plus Jakarta Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, 'Cascadia Mono', Consolas, monospace;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #120E18;
  --surface: #1C1724;
  --surface-2: #221C2B;
  --ink: #F4F1F8;
  --heading: #FFFFFF;
  --ink-2: #CFC9D8;
  --muted: #A39DB0;
  --line: #2F2839;
  --line-2: #27212F;
  --field: #463E52;
  --accent: #F3A35A;
  --accent-strong: #F3A35A;
  --accent-hover: #F7BC84;
  --accent-ink: #120E18;
  --accent-tint: #241A30;
  --accent-track: #3B2D4B;
  --bar: #F3A35A;
  --link: #CBA8F2;
  --success: #6CC08E;
  --success-tint: #1B2E24;
  --danger: #F08377;
  --danger-ink: #F3C3BD;
  --danger-tint: #2E1A1E;
  --danger-line: #6A3530;
  --tile: #2A2333;
  color-scheme: dark;
}

/* Darker scheme: two faint glows, one from each end of the logo */
:root[data-theme="dark"] body {
  background:
    radial-gradient(1100px 620px at 82% -10%, rgba(109, 10, 182, .32), transparent 62%),
    radial-gradient(900px 520px at 0% 110%, rgba(238, 129, 27, .10), transparent 62%),
    #120E18;
  background-attachment: fixed;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
}

a { color: var(--link); }
a:hover { color: var(--ink); }
h1, h2, .brand-name { color: var(--heading); }

[hidden] { display: none !important; }

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

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

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

.mono { font-family: var(--mono); }

/* ---------- Layout ---------- */

.page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 0 24px;
}

.wrap { width: 100%; max-width: 1200px; margin: 0 auto; }

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  padding: 22px 0;
}

.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: var(--ink); }
.brand img { width: 44px; height: 44px; display: block; }
.brand-name { font-weight: 800; font-size: 18px; letter-spacing: -0.01em; line-height: 1.2; }
.brand-by { font-size: 13px; color: var(--muted); }

.header-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.chip {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 14px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--line);
  font-size: 13px; color: var(--ink-2);
}

.icon-btn {
  width: 44px; height: 44px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer;
}
.icon-btn:hover { border-color: var(--field); }
.icon-btn .sun { display: none; }
:root[data-theme="dark"] .icon-btn .sun { display: block; }
:root[data-theme="dark"] .icon-btn .moon { display: none; }

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

.site-footer {
  display: flex; justify-content: space-between; flex-wrap: wrap; gap: 12px;
  padding: 20px 0 28px; font-size: 13px; color: var(--muted);
}
.site-footer a { color: var(--muted); }

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

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

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 44px; padding: 0 18px; border-radius: 12px;
  border: 1px solid var(--field); background: var(--surface); color: var(--ink);
  font-weight: 700; font-size: 14px; text-decoration: none; cursor: pointer;
  transition: background-color .15s, border-color .15s, color .15s;
}
.btn:hover { border-color: var(--muted); color: var(--ink); }
.btn:disabled { cursor: not-allowed; opacity: .55; }

.btn-primary { background: var(--accent-strong); border-color: var(--accent-strong); color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--accent-ink); }
.btn-primary:disabled:hover { background: var(--accent-strong); border-color: var(--accent-strong); color: var(--accent-ink); }

.btn-lg { min-height: 56px; border-radius: 14px; font-size: 16px; width: 100%; }

.btn-danger { background: var(--danger); border-color: var(--danger); color: #FFFFFF; }
:root[data-theme="dark"] .btn-danger { color: #1F1D1B; }
.btn-danger:hover { filter: brightness(.92); color: #FFFFFF; border-color: var(--danger); }
:root[data-theme="dark"] .btn-danger:hover { color: #1F1D1B; }
.btn-danger.confirming { box-shadow: 0 0 0 3px var(--danger-line); }

.btn-danger-outline { border-color: var(--danger-line); color: var(--danger); }
.btn-danger-outline:hover { border-color: var(--danger); color: var(--danger); }

.btn-quiet { min-height: 40px; padding: 0 14px; font-weight: 600; color: var(--ink-2); border-color: var(--line); }

/* ---------- Upload workspace ---------- */

.workspace {
  display: grid;
  grid-template-columns: minmax(300px, 400px) minmax(0, 1fr);
  grid-template-areas:
    "drop photos"
    "options photos"
    "action photos";
  grid-template-rows: auto auto 1fr;
  gap: 16px 24px;
  align-items: start;
}

.dropzone {
  grid-area: drop;
  width: 100%;
  border: 2px dashed var(--accent);
  background: var(--accent-tint);
  border-radius: var(--radius);
  padding: 36px 24px;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  text-align: center; cursor: pointer; color: var(--ink);
  transition: background-color .15s, border-color .15s, transform .15s;
}
.dropzone:hover { border-color: var(--accent-strong); }
.dropzone.dragover { border-style: solid; border-color: var(--accent-strong); transform: scale(1.01); }
.dropzone-icon {
  width: 56px; height: 56px; border-radius: 14px;
  background: var(--surface); color: var(--accent-strong);
  display: flex; align-items: center; justify-content: center;
}
.dropzone-title { font-weight: 700; font-size: 17px; }
.dropzone-sub { font-size: 14px; color: var(--muted); }
.only-touch { display: none; }

/* Options */
.options { grid-area: options; padding: 0; }
.options > summary {
  list-style: none; cursor: pointer;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  min-height: 56px; padding: 0 20px; font-weight: 700;
}
.options > summary::-webkit-details-marker { display: none; }
.summary-hint { font-weight: 400; color: var(--muted); font-size: 14px; }
.options .chev { transition: transform .2s; flex: none; }
.options[open] .chev { transform: rotate(180deg); }
.options-body { padding: 0 20px 20px; display: flex; flex-direction: column; gap: 16px; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.field .opt { font-weight: 400; color: var(--muted); }
.field input {
  height: 44px; padding: 0 14px; border-radius: 10px;
  border: 1px solid var(--field); background: var(--surface); font-size: 15px;
}
.field input::placeholder { color: var(--muted); opacity: .8; }
.hint { font-size: 12px; color: var(--muted); margin: 0; }

.check {
  display: flex; gap: 12px; align-items: flex-start;
  padding-top: 14px; border-top: 1px solid var(--line-2);
}
.check input { width: 20px; height: 20px; margin: 2px 0 0; accent-color: var(--accent-strong); flex: none; }
.check label { font-size: 14px; cursor: pointer; }
.check .hint { display: block; margin-top: 2px; }

/* Action bar */
.action-bar { grid-area: action; display: flex; flex-direction: column; gap: 10px; }
.action-meta { font-size: 13px; color: var(--muted); text-align: center; margin: 0; }

.progress-box {
  border-radius: 14px; background: var(--accent-tint);
  padding: 16px 18px; display: flex; flex-direction: column; gap: 10px;
}
.progress-head { display: flex; justify-content: space-between; gap: 12px; font-weight: 700; }
.bar { height: 10px; border-radius: 99px; background: var(--accent-track); overflow: hidden; }
.bar > span { display: block; height: 100%; width: 0; background: var(--bar); border-radius: 99px; transition: width .25s ease; }
.progress-note { font-size: 13px; color: var(--ink-2); margin: 0; }

/* Photos panel */
.photos { grid-area: photos; padding: 20px; min-height: 420px; }
.photos-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap; margin-bottom: 16px;
}
.photos-title { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.photos-title h2 { margin: 0; font-size: 18px; font-weight: 800; }
.count { font-size: 13px; color: var(--muted); }

.empty {
  border: 1px dashed var(--line); border-radius: 12px;
  min-height: 320px; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 8px;
  color: var(--muted); text-align: center; padding: 24px;
}
.empty svg { color: var(--field); }
.empty strong { color: var(--ink-2); }

.photo-grid {
  list-style: none; margin: 0; padding: 0;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px;
}

.tile {
  position: relative; border: 1px solid var(--line); border-radius: 12px;
  overflow: hidden; background: var(--surface);
}
.tile.is-error { border-color: var(--danger-line); }
.tile-thumb {
  position: relative; aspect-ratio: 4 / 3; background: var(--tile);
  display: flex; align-items: center; justify-content: center; color: var(--muted);
}
.tile-thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.tile.is-error .tile-thumb { background: var(--danger-tint); color: var(--danger); }
.tile-remove {
  position: absolute; top: 6px; right: 6px; width: 32px; height: 32px; border-radius: 999px;
  border: 0; background: rgba(255, 255, 255, .92); color: #1F1D1B;
  display: flex; align-items: center; justify-content: center; cursor: pointer; z-index: 1;
}
.tile-remove:hover { background: #FFFFFF; }
.tile-badge {
  position: absolute; top: 6px; left: 6px; width: 26px; height: 26px; border-radius: 999px;
  background: var(--success); color: #FFFFFF; display: flex; align-items: center; justify-content: center; z-index: 1;
}
.tile-body { padding: 8px 10px 10px; min-width: 0; }
.tile-name { font-family: var(--mono); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile-meta { font-size: 12px; color: var(--muted); }
.tile.is-error .tile-meta { color: var(--danger); }
.tile.is-done .tile-meta { color: var(--success); }
.tile-bar { height: 4px; background: var(--line-2); border-radius: 99px; overflow: hidden; margin-top: 6px; }
.tile-bar > span { display: block; height: 100%; width: 0; background: var(--bar); transition: width .2s; }
.tile.is-done .tile-bar > span { background: var(--success); }

/* ---------- Result ---------- */

.result {
  display: grid;
  grid-template-columns: minmax(320px, 440px) minmax(0, 1fr);
  gap: 24px; align-items: start;
}
.summary { padding: 28px; display: flex; flex-direction: column; gap: 18px; }
.done-badge {
  width: 56px; height: 56px; border-radius: 999px;
  background: var(--success-tint); color: var(--success);
  display: flex; align-items: center; justify-content: center;
}
.summary h1 { margin: 0 0 4px; font-size: 28px; font-weight: 800; letter-spacing: -0.02em; line-height: 1.2; }
.summary p { margin: 0; color: var(--muted); }

.info {
  display: flex; flex-direction: column; gap: 10px;
  padding: 14px 16px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line-2);
  font-size: 14px;
}
.info-row { display: flex; align-items: center; gap: 10px; color: var(--ink-2); }
.info-row svg { color: var(--muted); flex: none; }
.timer-bar { height: 6px; border-radius: 99px; background: var(--line-2); overflow: hidden; }
.timer-bar > span { display: block; height: 100%; background: var(--muted); border-radius: 99px; transition: width 1s linear; }

.destroy-panel {
  border: 1px solid var(--danger-line); background: var(--danger-tint);
  border-radius: 12px; padding: 16px; display: flex; flex-direction: column; gap: 12px;
}
.destroy-head { display: flex; gap: 12px; align-items: flex-start; }
.destroy-head svg { color: var(--danger); flex: none; margin-top: 1px; }
.destroy-head strong { display: block; }
.destroy-head span { font-size: 13px; color: var(--danger-ink); }

.files { padding: 22px; }
.files-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.files-head h2 { margin: 0; font-size: 18px; font-weight: 800; }
.file-grid {
  list-style: none; margin: 0; padding: 0;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 12px;
}
.file-grid a {
  display: block; text-decoration: none; color: var(--ink);
  border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--surface);
}
.file-grid a:hover { border-color: var(--accent); }
.file-grid .thumb { aspect-ratio: 1 / 1; background: var(--tile); }
.file-grid img { width: 100%; height: 100%; object-fit: cover; display: block; }
.file-grid .name { padding: 6px 8px; font-family: var(--mono); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- Destroyed / notice ---------- */

.notice {
  max-width: 560px; margin: 32px auto 0; padding: 40px 32px; text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 14px;
}
.notice h1 { margin: 0; font-size: 28px; font-weight: 800; letter-spacing: -0.02em; }
.notice p { margin: 0; color: var(--muted); }
.notice .done-badge { background: var(--surface-2); color: var(--ink-2); }

.notice-page {
  max-width: 520px; margin: 12vh auto; padding: 0 24px; text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 14px;
}
.notice-page h1 { margin: 0; font-size: 26px; }
.notice-page p { margin: 0; color: var(--muted); }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px);
  background: var(--ink); color: var(--bg); padding: 12px 18px; border-radius: 12px;
  font-size: 14px; font-weight: 600; opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s; z-index: 20; max-width: calc(100vw - 32px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Phone ---------- */

@media (max-width: 860px) {
  .page { padding: 0 16px; }
  .site-header { padding: 16px 0 10px; }
  .brand img { width: 40px; height: 40px; }
  .brand-by { display: none; }
  .header-actions .chip { display: none; }

  .workspace {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "drop" "photos" "options" "action";
    grid-template-rows: none;
    gap: 14px;
  }

  .dropzone { flex-direction: row; justify-content: center; padding: 18px; min-height: 64px; }
  .dropzone-icon { width: 36px; height: 36px; border-radius: 10px; }
  .dropzone-icon svg { width: 20px; height: 20px; }
  .dropzone-sub { display: none; }
  .only-pointer { display: none; }
  .only-touch { display: inline; }

  .photos { padding: 14px; min-height: 0; }
  .photos-head { flex-wrap: nowrap; align-items: flex-start; }
  .photos-title { flex-direction: column; gap: 0; min-width: 0; }
  .empty { min-height: 140px; }
  .photo-grid { grid-template-columns: minmax(0, 1fr); gap: 0; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
  .tile { display: flex; align-items: center; gap: 12px; border: 0; border-bottom: 1px solid var(--line-2); border-radius: 0; padding: 8px 4px 8px 10px; }
  .tile:last-child { border-bottom: 0; }
  .tile.is-error { background: var(--danger-tint); }
  .tile-thumb { width: 48px; height: 48px; flex: none; aspect-ratio: auto; border-radius: 8px; overflow: hidden; }
  .tile-thumb svg { width: 20px; height: 20px; }
  .tile-body { flex: 1; padding: 0; }
  .tile-remove { position: static; order: 3; width: 44px; height: 44px; background: transparent; color: var(--muted); flex: none; }
  .tile-badge { position: static; order: 2; flex: none; }

  .action-bar {
    position: sticky; bottom: 0; z-index: 5;
    margin: 0 -16px; padding: 12px 16px calc(14px + env(safe-area-inset-bottom));
    background: var(--surface); border-top: 1px solid var(--line);
  }

  main { padding-bottom: 0; }
  .site-footer { padding-bottom: 20px; }

  .result { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .summary { padding: 20px; }
  .summary h1 { font-size: 24px; }
  .files { padding: 16px; }
  .file-grid { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
  .notice { padding: 28px 20px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
