*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --cream: #f5f0e8;
  --parchment: #ede5d5;
  --warm-grey: #b8ad9e;
  --dust: #9e9185;
  --terracotta: #c4765a;
  --terracotta-light: #d4937a;
  --ink: #2e2820;
  --ink-light: #4a4035;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
}

html, body { min-height: 100%; }

body {
  background-color: var(--cream);
  color: var(--ink);
  font-family: 'Jost', sans-serif;
  font-weight: 400;
  -webkit-tap-highlight-color: transparent;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 999;
  opacity: 0.6;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.04'/%3E%3C/svg%3E");
}

/* ── top bar ───────────────────────────────────────────────────────────── */
.top {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 100;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 22px 26px;
}

.monogram {
  font-family: 'Cormorant', serif;
  font-size: 1.15rem;
  letter-spacing: 0.18em;
  color: var(--ink-light);
  text-decoration: none;
  transition: color 0.3s ease, letter-spacing 0.45s var(--ease-out);
}

.monogram:hover { color: var(--terracotta); letter-spacing: 0.24em; }

.top-links {
  display: flex;
  align-items: center;
  gap: 10px;
}

.guestbook-link,
.lang-toggle {
  font-family: 'Jost', sans-serif;
  font-size: 0.66rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--dust);
  background: none;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 7px 15px;
  cursor: pointer;
  text-decoration: none;
  transition: color 0.3s ease, border-color 0.3s ease, background 0.3s ease;
}

.guestbook-link { border-color: rgba(46, 40, 32, 0.16); }

.guestbook-link:hover,
.lang-toggle:hover {
  color: var(--terracotta);
  border-color: rgba(196, 118, 90, 0.42);
  background: rgba(196, 118, 90, 0.06);
}

/* ── stage ─────────────────────────────────────────────────────────────── */
.stage {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 34px;
  padding: 104px 24px 56px;
  text-align: center;
}

/* Load-in, driven by CSS alone: the `js` flag is set by an inline script in the
   document head, so this can never leave the page stuck at opacity 0. */
html.js:not(.reduce-motion) [data-reveal] {
  opacity: 0;
  transform: translateY(14px);
  animation: revealUp 0.9s var(--ease-out) forwards;
}

html.js:not(.reduce-motion) [data-reveal]:nth-child(2) { animation-delay: 0.12s; }
html.js:not(.reduce-motion) [data-reveal]:nth-child(3) { animation-delay: 0.24s; }

@keyframes revealUp {
  to { opacity: 1; transform: none; }
}

.name-field { width: min(100%, 19rem); }

.name-field input {
  width: 100%;
  border: 1px solid rgba(46, 40, 32, 0.16);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.42);
  padding: 13px 22px;
  font-family: 'Cormorant Garamond', serif;
  font-size: 1.08rem;
  color: var(--ink);
  text-align: center;
  outline: none;
  transition: border-color 0.3s ease, background 0.3s ease, box-shadow 0.4s ease;
}

.name-field input::placeholder { color: var(--warm-grey); }

.name-field input:focus {
  border-color: rgba(196, 118, 90, 0.55);
  background: rgba(255, 255, 255, 0.72);
  box-shadow: 0 0 0 4px rgba(196, 118, 90, 0.08);
}

/* ── round primary ─────────────────────────────────────────────────────── */
.btn-capture {
  position: relative;
  width: clamp(13.5rem, 52vw, 15.5rem);
  aspect-ratio: 1;
  border-radius: 50%;
  border: none;
  padding: 0;
  background: var(--ink);
  color: var(--cream);
  font-family: 'Jost', sans-serif;
  cursor: pointer;
  overflow: hidden;
  box-shadow: 0 18px 40px -22px rgba(46, 40, 32, 0.6);
  transition: transform 0.45s var(--ease-out), background 0.35s ease,
              box-shadow 0.45s var(--ease-out);
}

.btn-face {
  position: relative;
  z-index: 2;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
}

/* thin ring just outside the button */
.btn-capture::after {
  content: '';
  position: absolute;
  inset: -13px;
  border-radius: 50%;
  border: 1px solid rgba(196, 118, 90, 0.34);
  transition: transform 0.5s var(--ease-out), opacity 0.5s ease;
}

.btn-capture .lens {
  width: 40px;
  height: 40px;
  color: var(--terracotta-light);
  transition: transform 0.5s var(--ease-out);
}

.btn-capture span[data-i18n] {
  font-size: 0.82rem;
  letter-spacing: 0.24em;
  text-transform: uppercase;
}

.btn-capture:hover {
  background: #241f19;
  transform: translateY(-3px);
  box-shadow: 0 26px 50px -24px rgba(46, 40, 32, 0.66);
}

.btn-capture:hover .lens { transform: scale(1.08) rotate(-4deg); }
.btn-capture:hover::after { transform: scale(1.04); }
.btn-capture:active { transform: scale(0.975); }

.btn-capture:disabled { cursor: wait; }
.btn-capture:disabled:hover { transform: none; }

/* ripple from the tap point */
.ripple {
  position: absolute;
  z-index: 1;
  width: 12px;
  height: 12px;
  margin: -6px 0 0 -6px;
  border-radius: 50%;
  background: rgba(212, 147, 122, 0.5);
  pointer-events: none;
  animation: rippleOut 0.75s var(--ease-out) forwards;
}

@keyframes rippleOut {
  from { transform: scale(1); opacity: 0.65; }
  to { transform: scale(34); opacity: 0; }
}

/* breathing while the queue is moving */
html:not(.reduce-motion) .btn-capture.is-busy::after {
  animation: breathe 1.9s ease-in-out infinite;
}

@keyframes breathe {
  0%, 100% { transform: scale(1); opacity: 0.5; }
  50% { transform: scale(1.07); opacity: 1; }
}

/* one soft bloom when the whole queue lands */
.btn-capture.is-bloom::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 1px solid var(--terracotta-light);
  animation: bloom 1s var(--ease-out) forwards;
  pointer-events: none;
}

@keyframes bloom {
  from { transform: scale(1); opacity: 0.85; }
  to { transform: scale(1.55); opacity: 0; }
}

.btn-upload {
  font-family: 'Jost', sans-serif;
  font-size: 0.7rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ink-light);
  background: none;
  border: 1px solid rgba(46, 40, 32, 0.18);
  border-radius: 999px;
  padding: 12px 26px;
  cursor: pointer;
  transition: color 0.3s ease, border-color 0.3s ease, background 0.3s ease,
              transform 0.4s var(--ease-out);
}

.btn-upload:hover {
  color: var(--terracotta);
  border-color: rgba(196, 118, 90, 0.5);
  background: rgba(196, 118, 90, 0.06);
  transform: translateY(-2px);
}

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

/* ── camera shutter flash ──────────────────────────────────────────────── */
.shutter {
  position: fixed;
  inset: 0;
  z-index: 900;
  background: var(--cream);
  opacity: 0;
  pointer-events: none;
}

html:not(.reduce-motion) .shutter.is-firing {
  animation: shutterFlash 0.5s ease-out forwards;
}

@keyframes shutterFlash {
  0% { opacity: 0.85; }
  100% { opacity: 0; }
}

/* ── queue ─────────────────────────────────────────────────────────────── */
.queue {
  list-style: none;
  width: min(100%, 21rem);
  display: flex;
  flex-direction: column;
  gap: 10px;
  text-align: left;
}

.queue-item {
  display: grid;
  grid-template-columns: 44px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 8px 14px 8px 8px;
  background: rgba(255, 255, 255, 0.5);
  border: 1px solid rgba(46, 40, 32, 0.08);
  border-radius: 999px;
  transition: background 0.5s ease, border-color 0.5s ease;
}

html.js:not(.reduce-motion) .queue-item {
  animation: itemIn 0.6s var(--ease-out) both;
}

@keyframes itemIn {
  from { opacity: 0; transform: translateY(10px) scale(0.97); }
  to { opacity: 1; transform: none; }
}

.thumb {
  position: relative;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  overflow: hidden;
  background: var(--parchment);
}

.thumb img,
.thumb-fallback {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: filter 0.6s ease, transform 0.6s var(--ease-out);
}

.is-sending .thumb img { filter: saturate(0.65) brightness(1.03); }

.tick {
  position: absolute;
  inset: 0;
  margin: auto;
  width: 22px;
  height: 22px;
  color: var(--cream);
  opacity: 0;
}

.is-ok .thumb::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(138, 158, 137, 0.72);
}

.is-ok .tick {
  opacity: 1;
  z-index: 2;
}

html.js:not(.reduce-motion) .is-ok .tick path {
  stroke-dasharray: 26;
  stroke-dashoffset: 26;
  animation: drawTick 0.5s var(--ease-out) 0.05s forwards;
}

@keyframes drawTick {
  to { stroke-dashoffset: 0; }
}

.meta {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.name {
  font-size: 0.8rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* per-file progress bar */
.bar {
  position: relative;
  height: 3px;
  border-radius: 999px;
  background: rgba(46, 40, 32, 0.1);
  overflow: hidden;
  opacity: 0;
  transition: opacity 0.4s ease;
}

.is-sending .bar,
.is-ok .bar { opacity: 1; }

.bar-fill {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--terracotta), var(--terracotta-light));
  transition: width 0.3s var(--ease-out);
}

.is-ok .bar-fill { background: #8a9e89; }

/* sheen travelling along the bar while bytes move */
html:not(.reduce-motion) .is-sending .bar::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.55), transparent);
  animation: sheen 1.4s linear infinite;
}

@keyframes sheen {
  from { transform: translateX(-100%); }
  to { transform: translateX(100%); }
}

.state {
  font-size: 0.62rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--dust);
  transition: color 0.4s ease;
}

.detail {
  font-size: 0.58rem;
  letter-spacing: 0.06em;
  color: var(--warm-grey);
  word-break: break-word;
}

.queue-item.is-ok { background: rgba(138, 158, 137, 0.1); border-color: rgba(138, 158, 137, 0.28); }
.queue-item.is-ok .state { color: var(--ink-light); }

.queue-item.is-err { background: rgba(196, 118, 90, 0.08); border-color: rgba(196, 118, 90, 0.32); }
.queue-item.is-err .state { color: var(--terracotta); }

html.js:not(.reduce-motion) .queue-item.is-err { animation: nudge 0.45s ease; }

@keyframes nudge {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

.retry {
  font-family: 'Jost', sans-serif;
  font-size: 0.6rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  border: none;
  background: none;
  color: var(--terracotta);
  cursor: pointer;
  transition: opacity 0.3s ease;
}

.retry:hover { opacity: 0.7; }

.status {
  min-height: 1.3em;
  font-size: 0.85rem;
  color: var(--ink-light);
}

html.js:not(.reduce-motion) .status.is-fresh {
  animation: statusIn 0.5s var(--ease-out);
}

@keyframes statusIn {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: none; }
}

/* ── custom cursor (fine pointers only) ────────────────────────────────── */
.cursor { display: none; }

@media (hover: hover) and (pointer: fine) {
  html.has-cursor,
  html.has-cursor a,
  html.has-cursor button,
  html.has-cursor label { cursor: none; }

  html.has-cursor input { cursor: auto; }

  .cursor {
    display: block;
    position: fixed;
    top: 0; left: 0;
    z-index: 10000;
    border-radius: 50%;
    pointer-events: none;
    opacity: 0;
    transform: translate(-50%, -50%);
    transition: opacity 0.3s ease;
  }

  html.has-cursor .cursor.is-active { opacity: 1; }

  .cursor-dot {
    width: 6px; height: 6px;
    background: var(--terracotta);
  }

  .cursor-ring {
    width: 38px; height: 38px;
    border: 1px solid rgba(196, 118, 90, 0.55);
    transition: width 0.35s var(--ease-out), height 0.35s var(--ease-out),
                background 0.35s ease, border-color 0.35s ease, opacity 0.3s ease;
  }

  .cursor-ring.is-hover {
    width: 66px; height: 66px;
    background: rgba(196, 118, 90, 0.1);
    border-color: var(--terracotta);
  }

  .cursor.is-suppressed { opacity: 0 !important; }
}

/* ── reduced motion: keep the layout, drop the movement ────────────────── */
html.reduce-motion *,
html.reduce-motion *::before,
html.reduce-motion *::after {
  animation-duration: 0.001ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.001ms !important;
}

@media (min-width: 720px) {
  .top { padding: 26px 46px; }
}
