/* ============================================================
   Aadhaar Card Cutter — premium DARK theme
   Typography: Inter (UI) + Fraunces (display serif)
   Palette: warm charcoal, bone ink, hairline borders, burnt-orange
   ============================================================ */

@font-face {
  font-family: 'Inter';
  src: url('vendor/fonts/inter-var.woff2') format('woff2-variations');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Fraunces';
  src: url('vendor/fonts/fraunces-var.woff2') format('woff2-variations');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  /* Palette — warm dark */
  --bg: #12100e;
  --bg-wash-a: #1c1712;
  --bg-wash-b: #131815;
  --card: #1b1814;
  --card-2: #211d18;
  --raised: #262119;
  --ink: #f1ece2;
  --ink-soft: #b7aea0;
  --ink-faint: #7c7468;
  --line: #2b2620;
  --line-strong: #3a332a;
  --accent: #f2702b;
  --accent-bright: #ff8a45;
  --accent-deep: #d5540f;
  --accent-soft: #3a2416;
  --green: #4ade80;
  --green-soft: #16301f;
  --danger: #f87171;
  --danger-soft: #391d1d;

  --radius: 14px;
  --radius-sm: 9px;
  --shadow-card: 0 1px 0 rgba(0,0,0,.4) inset, 0 10px 30px -14px rgba(0,0,0,.6);
  --shadow-pop: 0 18px 50px -12px rgba(0,0,0,.8);
  --font-ui: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-display: 'Fraunces', Georgia, 'Times New Roman', serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.55;
  color: var(--ink);
  background:
    radial-gradient(1100px 500px at 85% -10%, var(--bg-wash-a) 0%, transparent 55%),
    radial-gradient(900px 460px at -10% 8%, var(--bg-wash-b) 0%, transparent 50%),
    var(--bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
a { color: var(--accent-bright); text-decoration: none; }
a:hover { text-decoration: underline; }
code {
  font-family: ui-monospace, 'Cascadia Code', Consolas, monospace;
  font-size: .92em;
  background: var(--raised);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 1px 6px;
  color: var(--accent-bright);
}
::selection { background: var(--accent-soft); color: var(--ink); }

/* ---------- Header ---------- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(18, 16, 14, .78);
  -webkit-backdrop-filter: blur(14px) saturate(1.3);
  backdrop-filter: blur(14px) saturate(1.3);
  border-bottom: 1px solid var(--line);
}
.header-inner {
  max-width: 960px;
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.logo {
  flex: none;
  width: 42px; height: 42px;
  border-radius: 50%;
  object-fit: cover;
  border: 1.5px solid var(--line-strong);
  box-shadow: 0 4px 14px -6px rgba(0,0,0,.7);
}
.brand-text h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 650;
  letter-spacing: -.01em;
  line-height: 1.15;
}
.tagline {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--ink-faint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------- Stepper ---------- */
.stepper {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: none;
}
.step-indicator {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--ink-faint);
  font-size: 12.5px;
  font-weight: 550;
}
.step-indicator .dot {
  width: 24px; height: 24px;
  display: grid; place-items: center;
  border-radius: 50%;
  font-size: 11px;
  font-weight: 650;
  color: var(--ink-faint);
  background: var(--card-2);
  border: 1.5px solid var(--line-strong);
  transition: all .25s ease;
}
.step-indicator.active { color: var(--accent-bright); }
.step-indicator.active .dot {
  color: #1a0f08;
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 4px 14px -4px rgba(242, 112, 43, .6);
}
.step-indicator.done { color: var(--green); }
.step-indicator.done .dot {
  color: #0c1a10;
  background: var(--green);
  border-color: var(--green);
}
.step-connector {
  width: 26px; height: 1.5px;
  background: var(--line-strong);
  border-radius: 2px;
}
.step-indicator.done + .step-connector { background: var(--green); }

/* ---------- Layout ---------- */
.container {
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
  padding: 32px 24px 64px;
  flex: 1;
}
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 32px;
}
.step { display: none; }
.step.active {
  display: block;
  animation: stepIn .35s cubic-bezier(.2, .7, .2, 1);
}
@keyframes stepIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
.hidden { display: none !important; }

/* ---------- Typography ---------- */
.section-head { margin-bottom: 18px; }
.kicker {
  display: block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--accent-bright);
  margin-bottom: 6px;
}
.section-head h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 620;
  letter-spacing: -.015em;
  line-height: 1.2;
}
.muted { color: var(--ink-soft); }
.lede { margin: 0 0 20px; font-size: 14px; }
.lede strong { font-weight: 650; color: var(--ink); }
.lede em { font-style: italic; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--font-ui);
  font-size: 14px;
  font-weight: 600;
  line-height: 1;
  padding: 11px 18px;
  border-radius: 10px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all .18s ease;
  text-decoration: none;
}
.btn:focus-visible { outline: 2px solid var(--accent-bright); outline-offset: 2px; }
.btn-primary {
  background: var(--accent);
  color: #1a0f08;
  box-shadow: 0 6px 18px -6px rgba(242, 112, 43, .55);
}
.btn-primary:hover { background: var(--accent-bright); color: #1a0f08; box-shadow: 0 8px 22px -6px rgba(255, 138, 69, .6); }
.btn-primary:active { transform: translateY(1px); }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; box-shadow: none; }
.btn-lg { padding: 14px 26px; font-size: 15px; border-radius: 12px; }
.btn-ghost {
  background: var(--card-2);
  color: var(--ink-soft);
  border-color: var(--line-strong);
}
.btn-ghost:hover { color: var(--ink); border-color: #55493a; background: var(--raised); }
.btn-ghost:active { transform: translateY(1px); }

/* ---------- Dropzone ---------- */
.dropzone {
  border: 1.5px dashed var(--line-strong);
  border-radius: var(--radius);
  background: linear-gradient(180deg, var(--card-2) 0%, var(--card) 100%);
  padding: 56px 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color .2s ease, background .2s ease, transform .2s ease;
}
.dropzone:hover, .dropzone.dragover {
  border-color: var(--accent);
  background: linear-gradient(180deg, var(--raised) 0%, var(--accent-soft) 130%);
}
.dropzone:focus-visible { outline: 2px solid var(--accent-bright); outline-offset: 3px; }
.dropzone.dragover { transform: scale(1.005); }
.dz-icon {
  width: 76px; height: 76px;
  margin: 0 auto 18px;
  display: grid; place-items: center;
  border-radius: 50%;
  color: var(--accent-bright);
  background: var(--accent-soft);
  transition: transform .2s ease;
}
.dropzone:hover .dz-icon, .dropzone.dragover .dz-icon { transform: translateY(-3px); }
.dz-title {
  margin: 0 0 4px;
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 620;
  letter-spacing: -.01em;
}
.dz-sub { margin: 0 0 20px; color: var(--ink-soft); font-size: 14px; }
.dz-sub .link { color: var(--accent-bright); font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }
.dz-hint {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin: 0;
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--card-2);
  font-size: 12px;
  color: var(--ink-faint);
}

/* ---------- Forms ---------- */
.field-row {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}
.field { display: block; }
.field span {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-soft);
  margin-bottom: 6px;
}
.field input {
  width: 100%;
  font-family: var(--font-ui);
  font-size: 15px;
  color: var(--ink);
  padding: 11px 13px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--raised);
  transition: border-color .15s ease, box-shadow .15s ease;
}
.field input::placeholder { color: var(--ink-faint); }
.field input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(242, 112, 43, .18);
}
.manual { margin: 0 0 16px; }
.manual summary {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-soft);
  cursor: pointer;
  padding: 6px 0;
  user-select: none;
  width: fit-content;
}
.manual summary:hover { color: var(--accent-bright); }
.manual .field { margin-top: 12px; }

/* ---------- Error / status ---------- */
.error {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  margin-bottom: 16px;
  padding: 11px 14px;
  border-radius: 10px;
  background: var(--danger-soft);
  border: 1px solid #4d2626;
  color: var(--danger);
  font-size: 13.5px;
}
.error::before {
  content: "";
  flex: none;
  width: 16px; height: 16px;
  margin-top: 1px;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='M12 7.5v5.5'/%3E%3Ccircle cx='12' cy='16.5' r='.4' fill='black'/%3E%3C/svg%3E") center / contain no-repeat;
  -webkit-mask-repeat: no-repeat;
}

/* ---------- Preview / crop ---------- */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.toolbar-right { display: flex; gap: 8px; flex-wrap: wrap; }
.page-control { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; }
.page-label { color: var(--ink-soft); font-weight: 600; }
.page-control select {
  font-family: var(--font-ui);
  font-size: 13.5px;
  padding: 7px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--raised);
  color: var(--ink);
  cursor: pointer;
}
.page-control select:focus { outline: none; border-color: var(--accent); }
.canvas-wrap {
  position: relative;
  display: inline-block;
  max-width: 100%;
  border-radius: 12px;
  overflow: hidden;
  background:
    linear-gradient(45deg, #23201b 25%, transparent 25%, transparent 75%, #23201b 75%),
    linear-gradient(45deg, #23201b 25%, #191613 25%, #191613 75%, #23201b 75%);
  background-size: 20px 20px;
  background-position: 0 0, 10px 10px;
  border: 1px solid var(--line);
}
#page-canvas {
  display: block;
  max-width: 100%;
  height: auto;
}
.crop-box {
  position: absolute;
  border: 2px solid var(--accent-bright);
  border-radius: 3px;
  cursor: move;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, .55);
  touch-action: none;
}
.crop-box .grip {
  position: absolute;
  width: 12px; height: 12px;
  background: #fff;
  border: 2px solid var(--accent);
  border-radius: 3px;
}
.crop-box .grip.nw { top: -7px; left: -7px; cursor: nwse-resize; }
.crop-box .grip.ne { top: -7px; right: -7px; cursor: nesw-resize; }
.crop-box .grip.sw { bottom: -7px; left: -7px; cursor: nesw-resize; }
.crop-box .grip.se { bottom: -7px; right: -7px; cursor: nwse-resize; }
.crop-bar {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-top: 14px;
  flex-wrap: wrap;
}
.crop-info {
  margin: 0;
  font-size: 14px;
  font-weight: 650;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.crop-info .pt { color: var(--ink-faint); font-weight: 500; }
.crop-bar .hint { margin: 0; font-size: 12.5px; color: var(--ink-faint); }

/* ---------- Export ---------- */
.export-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 24px;
}
.check {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  cursor: pointer;
  transition: border-color .15s ease, background .15s ease, box-shadow .15s ease;
}
.check:hover { border-color: var(--line-strong); background: var(--card-2); }
.check input { position: absolute; opacity: 0; pointer-events: none; }
.check-box {
  flex: none;
  width: 22px; height: 22px;
  display: grid; place-items: center;
  border: 1.5px solid var(--line-strong);
  border-radius: 7px;
  background: var(--raised);
  color: transparent;
  transition: all .15s ease;
}
.check input:checked + .check-box {
  background: var(--accent);
  border-color: var(--accent);
  color: #1a0f08;
  box-shadow: 0 3px 10px -3px rgba(242, 112, 43, .6);
}
.check input:focus-visible + .check-box { outline: 2px solid var(--accent-bright); outline-offset: 2px; }
.check-text { display: flex; flex-direction: column; gap: 1px; }
.check-text strong { font-size: 14px; font-weight: 650; }
.check-text small { font-size: 12px; color: var(--ink-faint); }
.export-actions { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.export-actions .btn { flex: none; }
#export-status { margin: 0; font-size: 13px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%) translateY(16px);
  background: var(--ink);
  color: #1a160f;
  padding: 11px 20px;
  border-radius: 10px;
  font-size: 13.5px;
  font-weight: 600;
  box-shadow: var(--shadow-pop);
  opacity: 0;
  transition: opacity .25s ease, transform .25s ease;
  z-index: 100;
}
.toast:not(.hidden) { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- Footer ---------- */
.app-footer {
  border-top: 1px solid var(--line);
  padding: 20px 24px 32px;
  text-align: center;
  color: var(--ink-faint);
  font-size: 12.5px;
}
.app-footer p { margin: 2px 0; }
.app-footer a { color: var(--ink-soft); font-weight: 600; }

/* ---------- Stepper state helpers (pure CSS, mirrors app.js flow) ---------- */
/* Export step lights up whenever the export card is shown (app.js adds
   .active to #step-export directly without showStep) */
body:has(#step-export.active) .step-indicator[data-step="export"] { color: var(--accent-bright); }
body:has(#step-export.active) .step-indicator[data-step="export"] .dot {
  color: #1a0f08;
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 4px 14px -4px rgba(242, 112, 43, .6);
}
/* Mark preview done when export card is shown */
body:has(#step-export.active) .step-indicator[data-step="preview"] { color: var(--green); }
body:has(#step-export.active) .step-indicator[data-step="preview"] .dot {
  color: #0c1a10;
  background: var(--green);
  border-color: var(--green);
}
/* When upload step is active again (start over), clear preview/export highlights */
body:has(#step-upload.active) .step-indicator[data-step="preview"],
body:has(#step-upload.active) .step-indicator[data-step="export"] { color: var(--ink-faint); }
body:has(#step-upload.active) .step-indicator[data-step="preview"] .dot,
body:has(#step-upload.active) .step-indicator[data-step="export"] .dot {
  color: var(--ink-faint);
  background: var(--card-2);
  border-color: var(--line-strong);
  box-shadow: none;
}
/* Start-over safety: hide crop overlay whenever upload step is active */
body:has(#step-upload.active) #crop-box { display: none !important; }

/* ---------- Responsive ---------- */
@media (max-width: 720px) {
  .header-inner { flex-direction: column; align-items: flex-start; gap: 10px; padding: 12px 16px; }
  .stepper { width: 100%; justify-content: space-between; }
  .step-label { display: none; }
  .step-connector { flex: 1; }
  .container { padding: 20px 16px 48px; }
  .card { padding: 24px 20px; }
  .field-row { grid-template-columns: 1fr; }
  .export-options { grid-template-columns: 1fr; }
  .dropzone { padding: 40px 16px; }
  .section-head h2 { font-size: 22px; }
}
@media (max-width: 480px) {
  .crop-bar { flex-direction: column; gap: 6px; }
  .dz-icon { width: 60px; height: 60px; }
  .dz-title { font-size: 19px; }
  .brand-text h1 { font-size: 17px; }
  .tagline { display: none; }
}
