/* ---------------------------------------------------------------------------
   Passport Photo — "data page"
   Visual direction borrowed from the thing itself: a US passport data page.
   Cool security-paper neutrals, deep navy ink, one gold foil accent, and a
   machine-readable-zone strip as the signature element.

   Sizing is in rem throughout so the whole UI scales with the user's browser
   font size. The deliberate exceptions:
     - hairline borders stay at 1px (a hairline should stay a hairline)
     - SVG geometry stays in the viewBox coordinate space (unitless)
     - the offscreen #file-input box, which is a 1px rendering trick
--------------------------------------------------------------------------- */

:root {
  /* palette */
  --paper: #eceef3;
  --surface: #ffffff;
  --surface-2: #f5f6f9;
  --ink: #101728;
  --ink-2: #545f78;
  --ink-3: #8c94a7;
  --line: #d8dce6;
  --accent: #1d3f9e;
  --accent-ink: #ffffff;
  --accent-soft: #e9eeff;
  --foil: #b3892f;
  --danger: #a4133c;
  --shadow-sm: 0 0.0625rem 0.125rem rgb(16 23 40 / 0.06);
  --shadow-md: 0 0.125rem 0.5rem rgb(16 23 40 / 0.06), 0 0.0625rem 0.125rem rgb(16 23 40 / 0.05);
  --shadow-lg: 0 1rem 2.5rem rgb(16 23 40 / 0.1), 0 0.125rem 0.5rem rgb(16 23 40 / 0.06);

  /* spacing scale */
  --s1: 0.25rem;
  --s2: 0.5rem;
  --s3: 0.75rem;
  --s4: 1rem;
  --s5: 1.5rem;
  --s6: 2rem;
  --s7: 3rem;

  --radius: 0.75rem;
  --radius-lg: 1.125rem;

  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #0b0e16;
    --surface: #141926;
    --surface-2: #1a2030;
    --ink: #e7ecf6;
    --ink-2: #a3adc2;
    --ink-3: #737e94;
    --line: #262d3f;
    --accent: #7f9dff;
    --accent-ink: #0b0e16;
    --accent-soft: #1a2136;
    --foil: #d8b566;
    --danger: #ff8ba7;
    --shadow-sm: 0 0.0625rem 0.125rem rgb(0 0 0 / 0.4);
    --shadow-md: 0 0.125rem 0.5rem rgb(0 0 0 / 0.35);
    --shadow-lg: 0 1rem 2.5rem rgb(0 0 0 / 0.5), 0 0.125rem 0.5rem rgb(0 0 0 / 0.4);
  }
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.55;
  color: var(--ink);
  background: var(--paper);
  /* faint security-paper wash: two very wide, very low-opacity accent pools */
  background-image:
    radial-gradient(70rem 40rem at 15% -10%, color-mix(in srgb, var(--accent)
    7%, transparent), transparent 60%),
    radial-gradient(50rem 34rem at 95% 8%, color-mix(in srgb, var(--foil) 8%,
    transparent), transparent 60%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}

main {
  max-width: 40rem;
  margin: 0 auto;
  padding: var(--s6) var(--s4) var(--s7);
}

[hidden] {
  display: none !important;
}

:focus-visible {
  outline: 0.1875rem solid var(--accent);
  outline-offset: 0.125rem;
  border-radius: 0.25rem;
}

/* --- masthead ------------------------------------------------------------ */

.masthead {
  margin-bottom: var(--s6);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s3);
}

.gh {
  color: var(--ink-2);
  display: flex;
}
.gh:hover {
  color: var(--ink);
}

h1 {
  margin: 0;
  font-size: clamp(2.125rem, 8vw, 2.75rem);
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1.05;
}
h1 .thin {
  font-weight: 300;
  color: var(--ink-2);
}

.tagline {
  margin: var(--s3) 0 0;
  font-size: 1.0625rem;
  color: var(--ink-2);
  max-width: 64rem;
}

.privacy {
  display: inline-flex;
  align-items: flex-start;
  gap: var(--s2);
  margin: var(--s4) 0 0;
  padding: var(--s2) var(--s3);
  border: 1px solid var(--line);
  border-radius: 999rem;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  font-size: 0.8125rem;
  color: var(--ink-2);
}
.privacy::before {
  content: "";
  margin-top: 0.5em;
  width: 0.375rem;
  height: 0.375rem;
  border-radius: 50%;
  background: var(--foil);
  flex: none;
}

/* --- typography in flow -------------------------------------------------- */

.lede {
  margin: 0 0 var(--s2);
  font-size: 1.0625rem;
  color: var(--ink);
}

.hint {
  margin: 0;
  font-size: 0.8125rem;
  color: var(--ink-3);
}

.error {
  margin: var(--s4) 0 0;
  padding: var(--s3) var(--s4);
  border: 1px solid color-mix(in srgb, var(--danger) 35%, transparent);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--danger) 8%, var(--surface));
  color: var(--danger);
  font-size: 0.9375rem;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* --- buttons ------------------------------------------------------------- */

button,
.button-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s2);
  min-height: 2.75rem;
  padding: 0.625rem 1.125rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  color: var(--ink);
  font: inherit;
  font-size: 0.9375rem;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: transform 120ms ease, box-shadow 120ms ease, background-color
    120ms ease,
    border-color 120ms ease;
}

button:hover,
.button-link:hover {
  border-color: var(--ink-3);
  box-shadow: var(--shadow-md);
  transform: translateY(-0.0625rem);
}

button:active,
.button-link:active {
  transform: translateY(0);
  box-shadow: none;
  background: var(--surface-2);
}

button.primary,
.button-link.primary {
  border-color: transparent;
  background: var(--accent);
  color: var(--accent-ink);
  box-shadow: var(--shadow-md);
}
button.primary:hover,
.button-link.primary:hover {
  border-color: transparent;
  background: color-mix(in srgb, var(--accent) 88%, var(--ink));
}
button.primary:active,
.button-link.primary:active {
  background: color-mix(in srgb, var(--accent) 80%, var(--ink));
}

.button-link.disabled {
  opacity: 0.45;
  pointer-events: none;
  box-shadow: none;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s3);
  justify-content: center;
  margin-top: var(--s5);
}

/* --- step bar ------------------------------------------------------------
   1 —— 2 —— 3. Steps you've already finished are clickable; the current and
   upcoming ones are disabled. Must come after the generic `button` rules —
   `.steps button` and `button:hover` have equal specificity, so source order
   is what makes the reset win.
------------------------------------------------------------------------- */

.steps {
  margin-bottom: var(--s6);
}
.steps ol {
  display: flex;
  align-items: center;
  margin: 0;
  padding: 0;
  list-style: none;
}
.steps li {
  display: flex;
  align-items: center;
  min-width: 0;
}
/* every step but the first is preceded by the rule that connects it back */
.steps li + li {
  flex: 1;
}
.steps li + li::before {
  content: "";
  flex: 1;
  min-width: var(--s4);
  height: 1px;
  margin: 0 var(--s3);
  background: var(--line);
  transition: background-color 200ms ease;
}
.steps li[data-state="done"]::before,
.steps li[data-state="current"]::before {
  background: var(--accent);
}

.steps button,
.steps button:hover,
.steps button:active {
  display: inline-flex;
  align-items: center;
  gap: var(--s2);
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 999rem;
  background: none;
  box-shadow: none;
  transform: none;
  font-family: var(--mono);
  font-size: 0.6875rem;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.steps button:disabled {
  cursor: default;
}

.steps .num {
  display: grid;
  place-items: center;
  flex: none;
  width: 1.75rem;
  height: 1.75rem;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0;
  transition: background-color 200ms ease, border-color 200ms ease, color 200ms
    ease;
}
/* Any step you can click gets the accent outline — including ones ahead of
   you, like stepping back to 1 and then returning to your photo via 2. */
.steps button:not(:disabled) .num {
  border-color: var(--accent);
  color: var(--accent);
}
.steps button:not(:disabled) .label {
  color: var(--ink-2);
}
.steps [data-state="current"] .num {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-ink);
}
.steps [data-state="current"] .label {
  color: var(--ink);
  font-weight: 600;
}

.steps button:not(:disabled):hover .num {
  border-color: var(--accent);
  box-shadow: var(--shadow-md);
}
.steps button:not(:disabled):hover .label {
  color: var(--ink);
}

@media (max-width: 26rem) {
  .steps .label {
    font-size: 0.625rem;
    letter-spacing: 0.06em;
  }
  .steps li + li::before {
    margin: 0 var(--s2);
  }
}

/* --- pick screen --------------------------------------------------------- */

.resume {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s3);
  margin-top: var(--s5);
  padding: var(--s3) var(--s3) var(--s3) var(--s4);
  border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
  border-radius: var(--radius);
  background: var(--accent-soft);
  font-size: 0.9375rem;
}
.resume span {
  flex: 1;
  min-width: 11rem;
}

#drop-zone {
  display: block;
  position: relative;
  margin-top: var(--s5);
  padding: var(--s7) var(--s4);
  border: 0.125rem dashed var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-md);
  text-align: center;
  color: var(--ink-2);
  cursor: pointer;
  transition: border-color 140ms ease, background-color 140ms ease, box-shadow
    140ms ease;
}
#drop-zone strong {
  display: block;
  margin-bottom: var(--s1);
  font-size: 1.125rem;
  font-weight: 650;
  letter-spacing: -0.015em;
  color: var(--ink);
}
#drop-zone:hover,
#drop-zone.dragover {
  border-color: var(--accent);
  border-style: solid;
  background: var(--accent-soft);
  box-shadow: var(--shadow-lg);
}
#drop-zone:focus-within {
  outline: 0.1875rem solid var(--accent);
  outline-offset: 0.1875rem;
}

/* Visually hidden but still focusable/tabbable, unlike display:none. */
#file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

#pick-busy {
  margin: var(--s4) 0 0;
  font-family: var(--mono);
  font-size: 0.8125rem;
  letter-spacing: 0.08em;
  color: var(--ink-2);
}

/* --- info panels --------------------------------------------------------- */

.panel {
  margin-top: var(--s6);
  padding: var(--s5);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  font-size: 0.9375rem;
  color: var(--ink-2);
}
.panel h2 {
  margin: 0 0 var(--s3);
  font-family: var(--mono);
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink);
}
.panel p {
  margin: 0 0 var(--s3);
}
.panel ul {
  margin: 0;
  padding: 0;
  list-style: none;
}
.panel li {
  position: relative;
  padding-left: var(--s5);
  margin-bottom: var(--s2);
}
.panel li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.6875rem;
  width: 0.625rem;
  height: 1px;
  background: var(--foil);
}
.panel li:last-child {
  margin-bottom: 0;
}
.panel strong {
  color: var(--ink);
  font-weight: 600;
}

.disclaimer {
  margin: var(--s4) 0 0;
  padding-top: var(--s4);
  border-top: 1px solid var(--line);
  font-size: 0.875rem;
  color: var(--ink-3);
}
.panel a {
  color: var(--accent);
  text-underline-offset: 0.125rem;
}

/* --- crop screen --------------------------------------------------------- */

#crop-area {
  display: flex;
  justify-content: center;
  margin-top: var(--s5);
  padding: var(--s5) 0;
  border-radius: var(--radius-lg);
  /* clips the dimming shadow below into a viewer panel */
  overflow: hidden;
  touch-action: none; /* we handle pan/pinch ourselves */
  user-select: none;
  -webkit-user-select: none;
}
#crop-stage {
  position: relative;
  width: min(80vw, 22.5rem);
  aspect-ratio: 1;
  border-radius: var(--radius);
}
#crop-img {
  position: absolute;
  top: 0;
  left: 0;
  max-width: none;
  transform-origin: 0 0;
  cursor: grab;
  -webkit-user-drag: none;
}
#crop-guides {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: visible;
  border-radius: inherit;
  /* dims the photo outside the frame; must sit ABOVE the image, which
     spills outside #crop-stage — a shadow on the stage itself would be
     painted underneath the image and dim nothing */
  box-shadow: 0 0 0 100rem rgb(6 9 16 / 0.66);
}
.head-oval {
  fill: none;
  stroke: rgb(255 255 255 / 0.85);
  stroke-width: 1;
  stroke-dasharray: 3 3;
}
.eye-band {
  fill: rgb(255 255 255 / 0.1);
  stroke: rgb(255 255 255 / 0.55);
  stroke-width: 0.4;
}
.guide-label {
  fill: rgb(255 255 255 / 0.92);
  font-family: ui-monospace, monospace;
  font-size: 7px;
  letter-spacing: 1px;
  text-anchor: middle;
  text-transform: uppercase;
  paint-order: stroke;
  stroke: rgb(0 0 0 / 0.45);
  stroke-width: 2px;
}

/* --- preview screen ------------------------------------------------------ */

#sheet {
  display: block;
  width: 100%;
  height: auto;
  margin-top: var(--s5);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: var(--shadow-lg);
}

.cutlines {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--s2);
  width: fit-content;
  margin: var(--s4) auto 0;
  padding: var(--s2) var(--s4);
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  color: var(--ink-2);
  cursor: pointer;
  user-select: none;
}

.cutlines:has(:checked) {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--ink);
}

.cutlines input {
  width: 1.1em;
  height: 1.1em;
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
}

.cutlines:focus-within {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

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