/* Logical properties (inline-start/end) are used throughout so that an
   Arabic version only needs dir="rtl" on <html>. */

:root {
  --cream: #f7f1e8;
  --ink: #2b2420;
  --muted: #7a6d63;
  --accent: #b5835a;
  --accent-ink: #ffffff;
  --warn-bg: #fdecc8;
  --warn-ink: #6b4a00;
  --serif: Georgia, "Times New Roman", serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--cream);
  color: var(--ink);
  font-family: var(--sans);
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

[hidden] { display: none !important; }

.screen {
  min-height: 100vh;
  min-height: 100dvh;
}

/* ---------- Buttons & fields ---------- */

.btn {
  display: inline-block;
  inline-size: 100%;
  padding: 16px 20px;
  border: 0;
  border-radius: 999px;
  font: 600 1.05rem var(--sans);
  background: #ffffff;
  color: var(--ink);
  cursor: pointer;
}

.btn--primary {
  background: var(--accent);
  color: var(--accent-ink);
}

.btn:active { transform: scale(0.98); }

.field-label {
  display: block;
  margin-block-end: 8px;
  font-weight: 600;
}

.field-input {
  inline-size: 100%;
  padding: 14px 16px;
  border: 1px solid #d9cdbf;
  border-radius: 12px;
  background: #ffffff;
  font-size: 1.1rem; /* 16px+ stops iOS from zooming on focus */
  color: var(--ink);
}

.field-input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

/* ---------- Welcome ---------- */

.screen--welcome {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(24px + var(--safe-top)) 24px calc(24px + var(--safe-bottom));
}

.welcome {
  inline-size: 100%;
  max-inline-size: 420px;
  text-align: center;
}

.welcome__brand {
  margin: 0;
  font-size: 0.8rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
}

.welcome__title {
  margin: 8px 0 12px;
  font: 400 2.4rem var(--serif);
}

.welcome__text {
  margin: 0 0 24px;
  line-height: 1.5;
}

.welcome__form {
  text-align: start;
}

.hint {
  margin: 12px 0 20px;
  font-size: 0.9rem;
  line-height: 1.4;
  color: var(--muted);
}

.notice {
  margin: 0 0 20px;
  padding: 12px 14px;
  border-radius: 12px;
  font-size: 0.9rem;
  line-height: 1.4;
  text-align: start;
}

.notice--warn {
  background: var(--warn-bg);
  color: var(--warn-ink);
}

.privacy {
  margin: 28px 0 0;
  font-size: 0.75rem;
  line-height: 1.4;
  color: var(--muted);
}

/* ---------- Camera ---------- */

.screen--camera {
  position: fixed;
  inset: 0;
  background: #000000;
  color: #ffffff;
  overflow: hidden;
  touch-action: manipulation; /* no double-tap zoom on the shutter */
  user-select: none;
  -webkit-user-select: none;
}

.viewfinder {
  position: absolute;
  inset: 0;
  inline-size: 100%;
  block-size: 100%;
  object-fit: cover;
}

/* Preview only. The saved photo is never mirrored. */
.viewfinder.is-front { transform: scaleX(-1); }

.flash {
  position: absolute;
  inset: 0;
  background: #ffffff;
  opacity: 0;
  pointer-events: none;
}

.flash.is-firing { animation: flash 280ms ease-out; }

@keyframes flash {
  from { opacity: 0.9; }
  to { opacity: 0; }
}

.camera-status {
  position: absolute;
  inset-inline: 0;
  inset-block-start: 45%;
  margin: 0;
  text-align: center;
  color: rgba(255, 255, 255, 0.8);
}

.camera-top {
  position: absolute;
  inset-inline: 0;
  inset-block-start: 0;
  padding: calc(14px + var(--safe-top)) 16px 14px;
  display: flex;
  justify-content: center;
  background: linear-gradient(rgba(0, 0, 0, 0.55), transparent);
}

.counter {
  padding: 6px 14px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.45);
  font-weight: 600;
  font-size: 0.95rem;
}

.camera-bar {
  position: absolute;
  inset-inline: 0;
  inset-block-end: 0;
  padding: 24px 28px calc(28px + var(--safe-bottom));
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.6));
}

.camera-bar__slot { display: flex; }
.camera-bar__slot--start { justify-content: flex-start; }
.camera-bar__slot--end { justify-content: flex-end; }

.shutter {
  inline-size: 78px;
  block-size: 78px;
  border-radius: 50%;
  border: 5px solid #ffffff;
  background: #ffffff;
  box-shadow: inset 0 0 0 3px #000000;
  cursor: pointer;
  transition: transform 80ms;
}

.shutter:active { transform: scale(0.9); }
.shutter:disabled { opacity: 0.6; }

.round-btn {
  inline-size: 52px;
  block-size: 52px;
  border-radius: 50%;
  border: 0;
  background: rgba(255, 255, 255, 0.2);
  color: #ffffff;
  display: grid;
  place-items: center;
  cursor: pointer;
}

.round-btn:disabled { opacity: 0.4; }

.last-shot {
  inline-size: 52px;
  block-size: 52px;
  padding: 0;
  border: 2px solid #ffffff;
  border-radius: 10px;
  overflow: hidden;
  background: #222222;
  cursor: pointer;
}

.last-shot img {
  inline-size: 100%;
  block-size: 100%;
  object-fit: cover;
  display: block;
}

/* ---------- Error / thanks ---------- */

.screen--message {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(24px + var(--safe-top)) 28px calc(24px + var(--safe-bottom));
  text-align: center;
}

.message { max-inline-size: 420px; }

.message__icon {
  margin: 0;
  font-size: 3rem;
}

.message__title {
  margin: 12px 0;
  font: 400 2.2rem var(--serif);
}

.message__text {
  margin: 0 0 28px;
  line-height: 1.5;
}

/* ---------- Debug viewer (prototype only) ---------- */

.debug-viewer {
  position: fixed;
  inset: 0;
  z-index: 10;
  padding: calc(16px + var(--safe-top)) 16px calc(16px + var(--safe-bottom));
  background: rgba(0, 0, 0, 0.92);
  color: #ffffff;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.debug-viewer img {
  flex: 1;
  min-block-size: 0;
  inline-size: 100%;
  object-fit: contain;
}

.debug-viewer__info {
  margin: 0;
  text-align: center;
  font-family: ui-monospace, monospace;
  font-size: 0.85rem;
}
