/* =========================================================
   HD Photo Converter — stylesheet
   Design: darkroom / photo-lab theme. Single accent (safelight
   teal) plus a warm amber reserved for the download action.
   ========================================================= */

:root {
  --ink: #14161A;
  --bg: #191B1F;
  --bg-soft: #212327;
  --surface: #262931;
  --surface-2: #2E323B;
  --border: #383C45;
  --text: #EFEDE7;
  --text-muted: #A6ABB5;
  --text-faint: #6E7380;
  --teal: #5FBDB0;
  --teal-strong: #7BD2C6;
  --amber: #E2A253;
  --amber-strong: #EEB871;
  --danger: #E2705E;

  --serif: Charter, "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: "SF Mono", SFMono-Regular, Consolas, "Liberation Mono", Menlo, monospace;

  --radius-s: 6px;
  --radius-m: 10px;
  --max-w: 1160px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  line-height: 1.55;
  overflow-x: hidden;
}

h1, h2, h3 {
  font-family: var(--serif);
  font-weight: 600;
  line-height: 1.15;
  margin: 0 0 .5em;
  color: var(--text);
}

h1 { font-size: clamp(2rem, 4.4vw, 3.1rem); letter-spacing: -0.01em; }
h2 { font-size: clamp(1.4rem, 2.6vw, 1.9rem); margin-bottom: .8em; }
h3 { font-size: 1.1rem; margin-bottom: .35em; }

p { margin: 0 0 1em; max-width: 62ch; }

a { color: var(--teal-strong); }
a:hover { color: var(--teal); }

code {
  font-family: var(--mono);
  font-size: 0.85em;
  background: var(--surface-2);
  padding: .1em .35em;
  border-radius: 4px;
}

.wrap {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 20px;
}

.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  background: var(--teal);
  color: var(--ink);
  padding: 10px 16px;
  z-index: 100;
  border-radius: 0 0 6px 0;
}
.skip-link:focus {
  left: 0;
}

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

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

/* ---------- header ---------- */
.site-header {
  border-bottom: 1px solid var(--border);
  background: var(--ink);
  position: sticky;
  top: 0;
  z-index: 20;
}
.header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 14px;
  padding-bottom: 14px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}
.brand-mark {
  color: var(--teal);
  display: inline-flex;
}
.brand-name {
  font-family: var(--serif);
  font-size: 1.08rem;
  letter-spacing: -0.01em;
}
.brand-tag {
  margin: 0;
  font-size: .8rem;
  color: var(--text-faint);
  display: none;
}
@media (min-width: 560px) {
  .brand-tag { display: block; }
}

/* ---------- hero ---------- */
.hero {
  padding: 56px 0 48px;
  background:
    radial-gradient(circle at 85% -10%, rgba(95,189,176,0.14), transparent 55%),
    var(--bg);
}
.hero-grid {
  display: grid;
  gap: 40px;
  align-items: center;
}
@media (min-width: 860px) {
  .hero-grid { grid-template-columns: 1.05fr 0.95fr; gap: 56px; }
}
.hero-sub {
  font-size: 1.15rem;
  color: var(--teal-strong);
  font-weight: 600;
  max-width: 46ch;
}
.hero-detail { color: var(--text-muted); }

.hero-art { display: flex; justify-content: center; }
.hero-frame {
  position: relative;
  width: 100%;
  max-width: 420px;
  aspect-ratio: 4 / 3;
  border-radius: var(--radius-m);
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--surface);
  display: flex;
}
.hero-frame-half {
  flex: 1;
  position: relative;
  display: flex;
  align-items: flex-end;
  padding: 14px;
}
.hero-frame-half.left {
  background:
    repeating-linear-gradient(135deg, #23262c 0 10px, #262a31 10px 20px);
  filter: saturate(.6) contrast(.9);
}
.hero-frame-half.right {
  background:
    repeating-linear-gradient(135deg, #23262c 0 10px, #262a31 10px 20px);
  filter: saturate(1.25) contrast(1.12) brightness(1.08);
}
.hero-frame-label {
  font-size: .72rem;
  letter-spacing: .02em;
  color: var(--text-muted);
  background: rgba(20,22,26,0.55);
  padding: 3px 8px;
  border-radius: 4px;
}
.hero-frame-divider {
  position: absolute;
  left: 50%;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--teal);
  box-shadow: 0 0 0 3px rgba(95,189,176,0.18);
}

/* ---------- buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: var(--radius-s);
  padding: 12px 22px;
  font-size: .98rem;
  font-family: var(--sans);
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: transform .08s ease, background-color .15s ease, border-color .15s ease;
  min-height: 44px;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary {
  background: var(--teal);
  color: #0E1513;
}
.btn-primary:hover:not(:disabled) { background: var(--teal-strong); }

.btn-accent {
  background: var(--amber);
  color: #241503;
}
.btn-accent:hover:not(:disabled) { background: var(--amber-strong); }

.btn-ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--text);
}
.btn-ghost:hover:not(:disabled) { border-color: var(--teal); color: var(--teal-strong); }

.btn-large {
  padding: 15px 30px;
  font-size: 1.05rem;
  width: 100%;
  max-width: 360px;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 22px;
}

/* ---------- sections ---------- */
.section {
  padding: 44px 0;
  border-bottom: 1px solid var(--border);
}
.section.alt { background: var(--bg-soft); }
.section-note { color: var(--text-muted); font-size: .92rem; margin-top: -4px; }

/* ---------- dropzone ---------- */
.dropzone {
  border: 1.5px dashed var(--border);
  border-radius: var(--radius-m);
  background: var(--surface);
  padding: 48px 20px;
  text-align: center;
  cursor: pointer;
  color: var(--text-muted);
  transition: border-color .15s ease, background-color .15s ease;
}
.dropzone:hover, .dropzone:focus-visible {
  border-color: var(--teal);
  background: var(--surface-2);
}
.dropzone.dragover {
  border-color: var(--teal);
  background: rgba(95,189,176,0.08);
}
.dropzone-icon { color: var(--teal); margin-bottom: 10px; }
.dropzone-title { font-size: 1.08rem; color: var(--text); margin: 0 0 .3em; font-weight: 600; }
.dropzone-hint { margin: 0; font-size: .88rem; }

.error-msg {
  margin-top: 14px;
  color: var(--danger);
  background: rgba(226,112,94,0.1);
  border: 1px solid rgba(226,112,94,0.35);
  border-radius: var(--radius-s);
  padding: 10px 14px;
  font-size: .92rem;
}

.file-meta {
  margin-top: 22px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-m);
  padding: 16px;
}
.file-meta-thumb {
  width: 72px; height: 72px;
  border-radius: var(--radius-s);
  overflow: hidden;
  background: var(--surface-2);
  flex-shrink: 0;
}
.file-meta-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.file-meta-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 8px 20px;
  margin: 0;
  flex: 1;
  min-width: 200px;
}
.file-meta-list div { display: flex; flex-direction: column; }
.file-meta-list dt { font-size: .72rem; color: var(--text-faint); text-transform: none; }
.file-meta-list dd { margin: 0; font-family: var(--mono); font-size: .88rem; }

/* ---------- controls ---------- */
.controls-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
  margin-bottom: 10px;
}
@media (min-width: 700px) {
  .controls-grid { grid-template-columns: 1fr 1fr; column-gap: 32px; }
}
.control { display: block; }
.control-label {
  display: flex;
  justify-content: space-between;
  font-size: .92rem;
  margin-bottom: 6px;
  color: var(--text-muted);
}
.control-label output { font-family: var(--mono); color: var(--text); }

input[type="range"] {
  -webkit-appearance: none;
  width: 100%;
  height: 44px;
  background: transparent;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 6px;
  background: var(--surface-2);
  border-radius: 3px;
}
input[type="range"]::-moz-range-track {
  height: 6px;
  background: var(--surface-2);
  border-radius: 3px;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  margin-top: -9px;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--teal);
  border: 3px solid var(--ink);
  box-shadow: 0 0 0 1px var(--border);
}
input[type="range"]::-moz-range-thumb {
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--teal);
  border: 3px solid var(--ink);
}

fieldset {
  border: none;
  padding: 0;
  margin: 24px 0 0;
}
legend {
  font-size: .92rem;
  color: var(--text-muted);
  margin-bottom: 8px;
  padding: 0;
}

.segmented {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.seg-btn {
  flex: 1 1 auto;
  min-width: 84px;
  min-height: 44px;
  padding: 10px 14px;
  border-radius: var(--radius-s);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  font-family: var(--sans);
  font-size: .92rem;
  font-weight: 600;
  cursor: pointer;
}
.seg-btn:hover { border-color: var(--teal); }
.seg-btn[aria-pressed="true"] {
  background: var(--teal);
  border-color: var(--teal);
  color: #0E1513;
}

/* ---------- progress ---------- */
.progress-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-m);
  padding: 22px;
}
.progress-title { font-weight: 600; margin-bottom: 14px; }
.progress-track {
  height: 8px;
  border-radius: 4px;
  background: var(--surface-2);
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  width: 0%;
  background: var(--teal);
  transition: width .25s ease;
}
.progress-stage {
  margin: 10px 0 0;
  font-size: .88rem;
  color: var(--text-muted);
}

/* ---------- compare slider ---------- */
.compare-wrap { display: flex; justify-content: center; }
.compare-frame {
  position: relative;
  width: 100%;
  max-width: 720px;
  border-radius: var(--radius-m);
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--ink);
  touch-action: pan-y;
  user-select: none;
}
.compare-frame img {
  display: block;
  width: 100%;
  height: auto;
  pointer-events: none;
}
.compare-clip {
  position: absolute;
  inset: 0;
  width: 50%;
  overflow: hidden;
}
.compare-clip img {
  width: var(--clip-w, 720px);
  max-width: none;
}
.compare-handle {
  position: absolute;
  top: 0; bottom: 0;
  left: 50%;
  width: 3px;
  background: var(--teal);
  cursor: ew-resize;
  transform: translateX(-50%);
}
.compare-handle-grip {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 40px; height: 40px;
  background: var(--teal);
  color: #0E1513;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  box-shadow: 0 2px 10px rgba(0,0,0,.4);
}
.compare-tag {
  position: absolute;
  bottom: 12px;
  font-size: .72rem;
  padding: 4px 10px;
  border-radius: 4px;
  background: rgba(20,22,26,0.65);
  color: var(--text);
}
.compare-tag.left { left: 12px; }
.compare-tag.right { right: 12px; }

/* ---------- resize ---------- */
.resize-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  max-width: 480px;
}
.checkbox-field {
  grid-column: 1 / -1;
  flex-direction: row !important;
  align-items: center;
  gap: 10px;
}
.checkbox-field input { width: 20px; height: 20px; }

.field { display: flex; flex-direction: column; gap: 6px; font-size: .9rem; color: var(--text-muted); }
.field input[type="number"] {
  min-height: 44px;
  padding: 8px 12px;
  border-radius: var(--radius-s);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-family: var(--mono);
  font-size: 1rem;
}
.field input:focus-visible { border-color: var(--teal); }

.preset-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}
.chip {
  min-height: 40px;
  padding: 8px 16px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: .88rem;
}
.chip:hover { border-color: var(--teal); color: var(--text); }
.chip[aria-pressed="true"] { background: var(--surface-2); color: var(--teal-strong); border-color: var(--teal); }

.hint-text {
  margin-top: 12px;
  font-size: .86rem;
  color: var(--amber-strong);
  min-height: 1.2em;
}

/* ---------- size compare ---------- */
.size-compare {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 14px;
  margin-top: 22px;
  max-width: 620px;
}
.size-compare > div {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-s);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.size-label { font-size: .76rem; color: var(--text-faint); }
.size-value { font-family: var(--mono); font-size: 1.05rem; }

/* ---------- download ---------- */
.download-section { text-align: left; }
.download-section .btn-large { display: flex; }

/* ---------- privacy ---------- */
.privacy-section { background: var(--ink); border-bottom: 1px solid var(--border); }
.privacy-row {
  display: flex;
  align-items: flex-start;
  gap: 16px;
}
.privacy-icon { color: var(--teal); flex-shrink: 0; margin-top: 2px; }
.privacy-row p { margin: 0; color: var(--text-muted); }

/* ---------- how it works ---------- */
.how-list { padding-left: 1.2em; max-width: 70ch; }
.how-list li { margin-bottom: .7em; color: var(--text-muted); }
.how-list strong { color: var(--text); }

/* ---------- faq ---------- */
.faq-item { margin-bottom: 22px; max-width: 70ch; }
.faq-item p { color: var(--text-muted); margin: 0; }

/* ---------- footer ---------- */
.site-footer {
  padding: 26px 0 40px;
  color: var(--text-faint);
  font-size: .84rem;
}
.site-footer p { margin: 0; }

/* ---------- sticky download on mobile ---------- */
@media (max-width: 640px) {
  #download.section {
    position: sticky;
    bottom: 0;
    background: var(--bg);
    border-top: 1px solid var(--border);
    box-shadow: 0 -8px 20px rgba(0,0,0,.35);
    padding: 16px 0 calc(16px + env(safe-area-inset-bottom));
    z-index: 15;
  }
  #download.section h2,
  #download.section .section-note { display: none; }
  .btn-large { max-width: none; }
}

/* ---------- reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  * { transition-duration: 0.001ms !important; animation-duration: 0.001ms !important; }
}

/* ---------- small screens: single column everywhere ---------- */
@media (max-width: 480px) {
  .resize-grid { grid-template-columns: 1fr; }
  .file-meta { flex-direction: column; align-items: flex-start; }
}
