/* UNDR photo consent, matched to undr.zone: pure black monochrome, the UNDR
   block logo, light 300-weight system type, uppercase headings and buttons
   with wide tracking, 1px rules, square corners. The one exception on purpose
   is the full-bleed green screen, readable from across a dark room. */
:root {
  --undr-bg: #000;
  --undr-surface: #0a0a0a;
  --undr-surface-2: #141414;
  --undr-ink: #fff;
  --undr-ink-mid: #aaa;
  --undr-ink-faint: #888;
  --undr-rule: #1a1a1a;
  --undr-rule-2: #333;
  --undr-error: #ff7a7a;
  --undr-green: #17c964;
  --undr-font: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
  --undr-focus: 0 0 0 2px #000, 0 0 0 4px #fff;
  --undr-ease: cubic-bezier(.2, .8, .2, 1);
  --screen-width: 640px;
  --touch: 56px;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html {
  -webkit-text-size-adjust: 100%;
  background: var(--undr-bg);
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--undr-bg);
  color: var(--undr-ink);
  font-family: var(--undr-font);
  font-size: 1.0625rem;
  font-weight: 300;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

body.large-text { font-size: 1.25rem; }

h1, h2 {
  margin: 0;
  font-weight: 300;
  text-transform: uppercase;
}

h1 {
  font-size: clamp(1.6rem, 5vw, 2.25rem);
  letter-spacing: .12em;
  line-height: 1.2;
}

h2 {
  font-size: .9em;
  letter-spacing: .2em;
}

p { margin: 0; }

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

/* App bar */
.bar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px max(16px, env(safe-area-inset-right)) 10px max(16px, env(safe-area-inset-left));
  padding-top: max(10px, env(safe-area-inset-top));
  background: var(--undr-bg);
  border-bottom: 1px solid var(--undr-rule);
}

.bar-logo {
  height: 32px;
  width: auto;
  flex: none;
}

.bar-party {
  min-width: 0;
  overflow: hidden;
  color: var(--undr-ink-mid);
  font-size: .85rem;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.bar-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  flex: none;
}

.chip {
  min-height: 44px;
  min-width: 44px;
  padding: 0 12px;
  background: transparent;
  border: 1px solid var(--undr-rule-2);
  border-radius: 0;
  color: var(--undr-ink);
  font: inherit;
  font-size: .85rem;
  cursor: pointer;
  touch-action: manipulation;
}

.chip[aria-pressed="true"] {
  background: var(--undr-ink);
  color: var(--undr-bg);
}

.chip-quiet { color: var(--undr-ink-faint); }

.language-toggle { display: flex; }
.language-toggle .chip + .chip { border-left: 0; }

.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--undr-ink-mid);
  font-size: .8rem;
  white-space: nowrap;
}

.status::before {
  content: '';
  width: 8px;
  height: 8px;
  background: var(--undr-green);
}

.status.offline::before { background: var(--undr-ink-faint); }
.status.pending { color: var(--undr-ink); }
.status.pending::before { background: #fff; }

/* Screens */
main {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.screen {
  flex: 1;
  width: 100%;
  max-width: var(--screen-width);
  margin: 0 auto;
  padding: 32px 20px calc(32px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.screen-center { justify-content: center; }

.hero-logo {
  width: 150px;
  height: auto;
  margin-bottom: 20px;
}

.step {
  color: var(--undr-ink-faint);
  font-size: .9rem;
}

.lead { color: var(--undr-ink-mid); }

.note {
  color: var(--undr-ink-faint);
  font-size: .9em;
}

.callout {
  padding: 12px 16px;
  border: 1px solid var(--undr-ink);
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* Buttons: white block, inverted while pressed */
.button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: var(--touch);
  padding: 12px 20px;
  border: 1px solid var(--undr-ink);
  border-radius: 0;
  font: inherit;
  font-weight: 400;
  font-size: .95rem;
  letter-spacing: .2em;
  text-transform: uppercase;
  cursor: pointer;
  touch-action: manipulation;
  transition: background-color 140ms var(--undr-ease), color 140ms var(--undr-ease);
}

.button.primary {
  background: var(--undr-ink);
  color: var(--undr-bg);
}

.button.primary:active:not(:disabled) {
  background: var(--undr-bg);
  color: var(--undr-ink);
}

.button.primary:disabled {
  background: transparent;
  border-color: var(--undr-rule-2);
  color: var(--undr-ink-faint);
  cursor: not-allowed;
}

.button.secondary {
  background: transparent;
  border-color: var(--undr-rule-2);
  color: var(--undr-ink);
}

.button.secondary:active {
  background: var(--undr-ink);
  color: var(--undr-bg);
}

.text-button {
  align-self: flex-start;
  min-height: 44px;
  padding: 0;
  background: none;
  border: 0;
  color: var(--undr-ink);
  font: inherit;
  font-size: .9em;
  text-decoration: underline;
  text-underline-offset: 4px;
  cursor: pointer;
}

button:focus-visible,
input:focus-visible {
  outline: none;
  box-shadow: var(--undr-focus);
}

/* Fields */
input[type="text"],
input[type="email"] {
  width: 100%;
  min-height: var(--touch);
  padding: 12px 14px;
  background: var(--undr-surface);
  border: 1px solid var(--undr-rule-2);
  border-radius: 0;
  color: var(--undr-ink);
  font: inherit;
  font-size: max(1rem, 16px); /* below 16px iOS zooms in on focus */
  -webkit-appearance: none;
}

input::placeholder { color: var(--undr-ink-faint); }

.input-large { font-size: clamp(1.1rem, 3vw, 1.35rem) !important; }

.code-input {
  font-size: 1.75rem !important;
  letter-spacing: .4em;
  text-align: center;
  -webkit-text-security: disc;
}

.field-error { color: var(--undr-error); }

.form-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-field label,
.field-label {
  color: var(--undr-ink-mid);
  font-size: .9em;
}

/* Form */
#consent-form {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.form-email {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--undr-rule);
  overflow-wrap: anywhere;
}

.form-email .text-button { flex: none; align-self: center; }

.welcome-back {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.name-fields {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}

.terms {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px 0;
  border-top: 1px solid var(--undr-rule);
  border-bottom: 1px solid var(--undr-rule);
}

.terms-preview {
  margin: 0;
  padding-left: 1.1em;
  display: flex;
  flex-direction: column;
  gap: 8px;
  color: var(--undr-ink-mid);
}

.terms-full {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  background: var(--undr-surface-2);
  font-size: .95em;
}

.agreement { margin-bottom: 8px; font-weight: 400; }

/* Newsletter box */
.check-field {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 14px;
  min-height: 44px;
  cursor: pointer;
}

.check-field input {
  position: absolute;
  opacity: 0;
  width: 30px;
  height: 30px;
  margin: 0;
}

.check-box {
  flex: none;
  width: 30px;
  height: 30px;
  border: 1px solid var(--undr-ink);
  background: transparent;
}

.check-field input:checked + .check-box {
  background: var(--undr-ink) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='3'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5'/%3E%3C/svg%3E") center/22px no-repeat;
}

.check-field input:focus-visible + .check-box { box-shadow: var(--undr-focus); }

.check-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.check-text small {
  color: var(--undr-ink-faint);
  font-size: .85em;
}

/* Remember me: a button, not a form field, since it changes what is being signed */
.remember-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.remember-field small {
  color: var(--undr-ink-faint);
  font-size: .85em;
}

.remember-toggle {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  min-height: var(--touch);
  padding: 12px 14px;
  background: transparent;
  border: 1px solid var(--undr-rule-2);
  border-radius: 0;
  color: var(--undr-ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
  touch-action: manipulation;
}

.remember-toggle[aria-pressed="true"] { border-color: var(--undr-ink); }

.remember-toggle[aria-pressed="true"] .check-box {
  background: var(--undr-ink) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='3'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5'/%3E%3C/svg%3E") center/22px no-repeat;
}

/* Signature */
.signature-container {
  width: 100%;
  background: #fff;
}

.signature-pad {
  display: block;
  width: 100%;
  touch-action: none;
}

/* Photographer choices */
.choice-list {
  display: flex;
  flex-direction: column;
  border-top: 1px solid var(--undr-rule-2);
}

.choice {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  min-height: 72px;
  padding: 12px 8px;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--undr-rule-2);
  color: var(--undr-ink);
  font: inherit;
  font-size: 1.25em;
  text-align: left;
  cursor: pointer;
  touch-action: manipulation;
}

.choice:active,
.choice[aria-current="true"] {
  background: var(--undr-ink);
  color: var(--undr-bg);
}

/* Review */
.confirm-value {
  font-size: 1.25em;
  overflow-wrap: anywhere;
}

.review {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding-top: 20px;
  border-top: 1px solid var(--undr-rule);
}

.review dl {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 16px;
  margin: 0;
}

.review dt { color: var(--undr-ink-mid); }
.review dd { margin: 0; overflow-wrap: anywhere; }

.signature-image-container { background: #fff; }

.signature-image-container img {
  display: block;
  max-width: 100%;
  max-height: 180px;
  margin: 0 auto;
}

/* The green screen */
body[data-screen="green"] { background: var(--undr-green); }
body[data-screen="green"] .bar { display: none; }

.screen-green {
  max-width: none;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: var(--undr-green);
  color: #000;
  text-align: center;
  animation: green-in 220ms var(--undr-ease);
}

.screen-green h1 {
  font-size: clamp(2rem, 7vw, 3.5rem);
  font-weight: 400;
}

.green-mark {
  width: 96px;
  height: 96px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.5'%3E%3Cpath d='M4 12.5l5 5L20 6.5'/%3E%3C/svg%3E") center/contain no-repeat;
}

.green-initials {
  font-size: clamp(4rem, 18vw, 9rem);
  font-weight: 300;
  line-height: 1.1;
}

.green-detail {
  max-width: 34ch;
  font-size: 1.15em;
  font-weight: 400;
}

.button.on-green {
  max-width: 360px;
  margin-top: 24px;
  background: #000;
  border-color: #000;
  color: #fff;
}

.button.on-green:active {
  background: transparent;
  color: #000;
}

@keyframes green-in {
  from { clip-path: inset(50% 0); }
  to { clip-path: inset(0 0); }
}

/* Notification */
.notification {
  position: fixed;
  left: 50%;
  bottom: calc(16px + env(safe-area-inset-bottom));
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: min(92vw, 560px);
  padding: 12px 16px;
  background: var(--undr-ink);
  color: var(--undr-bg);
  font-weight: 400;
  transform: translate(-50%, 200%);
  visibility: hidden;
  transition: transform 200ms var(--undr-ease), visibility 200ms;
}

.notification.show {
  transform: translate(-50%, 0);
  visibility: visible;
}

.notification.error {
  background: var(--undr-error);
}

#notification-close {
  flex: none;
  width: 36px;
  height: 36px;
  background: none;
  border: 0;
  color: inherit;
  font-size: 1.5rem;
  cursor: pointer;
}

/* Emergency reset, shown by tapping the UNDR logo 3 times */
.rescue-button {
  position: fixed;
  left: 50%;
  bottom: calc(16px + env(safe-area-inset-bottom));
  z-index: 30;
  max-width: 92vw;
  min-height: 44px;
  padding: 8px 20px;
  background: var(--undr-surface-2);
  border: 1px solid var(--undr-rule-2);
  border-radius: 0;
  color: var(--undr-ink-faint);
  font: inherit;
  font-size: .85rem;
  cursor: pointer;
  transform: translateX(-50%);
  touch-action: manipulation;
}

/* Which version this tablet is really running */
.app-version {
  padding: 4px 12px calc(6px + env(safe-area-inset-bottom));
  color: var(--undr-ink-faint);
  font-size: .75rem;
  text-align: right;
}

body[data-screen="green"] .app-version { color: rgba(0, 0, 0, .6); }

/* Small tablets in portrait, and phones as a fallback */
@media (max-width: 620px) {
  .bar { flex-wrap: wrap; }
  .bar-party { flex: 1; }
  .bar-controls { width: 100%; justify-content: flex-end; }
  #photographer-chip { margin-right: auto; }
}

@media (prefers-reduced-motion: reduce) {
  .screen-green { animation: none; }
  .button, .notification { transition: none; }
}
