/* 
    Created by Phuah Jin Wei
    Version 2.01 (improved ui)
    Created Date: 2025/10/15
	Last Updated: 2025/10/17
*/

:root {
  --bg: #0b0c0f;
  --surface: #0f1115;
  --panel: #141820;
  --text: #e7e9ee;
  --muted: #9aa3b2;
  --border: #242a34;
  --accent: #4caf50;
  --accent-press: #3c9441;
  --error: #ef4444;
  --ring: rgba(76, 175, 80, .35);
  --drop-bg: rgba(76, 175, 80, .06);
  --chip: #1b2130;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f6f7f9;
    --surface: #ffffff;
    --panel: #ffffff;
    --text: #101218;
    --muted: #4b5565;
    --border: #e5e7eb;
    --accent: #16a34a;
    --accent-press: #11863d;
    --ring: rgba(22, 163, 74, .25);
    --drop-bg: rgba(22, 163, 74, .08);
    --chip: #f3f4f6;
  }
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial;
  background: var(--bg);
  color: var(--text);
  padding: clamp(16px, 2.5vw, 32px);
  display: flex;
  align-items: center;
  justify-content: center;
}

.container {
  width: min(840px, 100%);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .12);
  padding: clamp(16px, 3vw, 28px);
}

h1 {
  margin: 0 0 16px;
  font-size: clamp(20px, 3.2vw, 28px);
  text-align: center;
}

.lead {
  margin: 0 0 20px;
  color: var(--muted);
  text-align: center;
  font-size: clamp(13px, 1.8vw, 15px);
}

.image-section {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px 28px;
  align-items: center;
  justify-items: center;
  margin-bottom: 16px;
}

@media (min-width: 720px) {
  .image-section {
    grid-template-columns: max-content max-content;
    justify-content: center;
    justify-items: center;
  }

  .radio-group {
    width: auto;
  }
}

.image-section img {
  width: clamp(140px, 22vw, 200px);
  height: auto;
  display: block;
  border-radius: 12px;
  background: var(--surface);
  padding: 8px;
}

.radio-group {
  width: 100%;
}

.radio-group fieldset {
  border: 0;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.radio-group legend {
  font-size: 14px;
  color: var(--muted);
  margin-bottom: 4px;
  text-align: center;
}

@media (min-width: 720px) {
  .radio-group legend {
    text-align: left;
  }
}

.radio-label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 16px;
  user-select: none;
  justify-content: center;
}

@media (min-width: 720px) {
  .radio-label {
    justify-content: flex-start;
  }
}

.radio-label input[type=radio] {
  inline-size: 18px;
  block-size: 18px;
  accent-color: var(--accent);
}

.uploader {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 2px dashed var(--border);
  padding: 20px;
  border-radius: 12px;
  margin-top: 6px;
  transition:
    border-color .2s,
    box-shadow .2s,
    background .2s,
    transform .06s;
  text-align: center;
  cursor: pointer;
}

.uploader:active {
  transform: translateY(1px);
}

.uploader:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--ring) inset;
}

.uploader.is-dragover {
  border-color: var(--accent);
  background: var(--drop-bg);
  box-shadow: 0 0 0 4px var(--ring) inset;
}

.icon {
  font-size: 28px;
  line-height: 1;
}

.drop-hint {
  font-size: 13px;
  color: var(--muted);
}

.file-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--chip);
  border: 1px solid var(--border);
  font-size: 13px;
  max-width: 100%;
}

.chip .name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 44ch;
  display: inline-block;
}

.chip .size {
  opacity: .8;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.chip .remove {
  border: none;
  background: transparent;
  cursor: pointer;
  font-weight: 700;
  padding: 0 4px;
  line-height: 1;
  color: var(--muted);
}

.chip .remove:hover {
  color: var(--text);
}

.chip .remove:focus-visible {
  outline: 2px solid var(--ring);
  border-radius: 6px;
}

#file-uploader {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

#error-message {
  color: var(--error);
  min-height: 1.25rem;
  text-align: center;
  font-weight: 600;
  word-break: break-word;
}

.actions {
  display: flex;
  justify-content: center;
  margin-top: 10px;
}

#convert-btn {
  appearance: none;
  border: none;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  padding: 10px 14px;
  border-radius: 12px;
  cursor: pointer;
  inline-size: fit-content;
  transition:
    transform .04s,
    background .2s;
}

#convert-btn[disabled] {
  opacity: .6;
  cursor: not-allowed;
}

#convert-btn:hover:not([disabled]) {
  background: var(--accent-press);
}

#convert-btn:active:not([disabled]) {
  transform: translateY(1px) scale(.99);
}

#convert-btn:focus-visible {
  outline: 3px solid var(--ring);
  outline-offset: 3px;
}
