/* clean-cities — see design/look-and-feel.md */

:root {
  --color-primary: #6364ff;
  --color-primary-soft: #8f90ff;
  --color-primary-dark: #4a4bd6;
  --color-bg: #fff6ea;
  --color-surface: #ffffff;
  --color-text: #3d2f2f;
  --color-muted: #9a8579;
  --color-border: #f2e3cf;
  --color-gold: #f2b33d;
  --color-gold-dark: #d1942a;
  --color-success: #3fa46a;
  --color-error: #d64545;

  --radius-card: 20px;
  --shadow-card: 0 6px 24px rgba(61, 47, 47, 0.10);
  --font: "Baloo 2", "Quicksand", ui-rounded, "Hiragino Maru Gothic ProN", "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }

/* author display rules must not defeat the hidden attribute */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font);
  font-size: 16px;
  font-weight: 500;
  line-height: 1.45;
}

/* faint paw-print pattern on wide screens */
@media (min-width: 700px) {
  body {
    background-image: radial-gradient(rgba(99, 100, 255, 0.07) 2.5px, transparent 3px);
    background-size: 56px 56px;
  }
}

#app {
  max-width: 480px;
  margin: 0 auto;
  padding: 16px 16px 32px;
  min-height: calc(100vh - 64px);
}

.screen { animation: screen-in 220ms ease-out; }
@keyframes screen-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

/* ---------- top bar ---------- */

#topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 480px;
  margin: 0 auto;
  padding: 12px 16px;
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-border);
}
#topbar .logo { color: var(--color-primary); display: inline-flex; }
#topbar .app-name { font-weight: 800; font-size: 20px; }
#topbar .spacer { flex: 1; }
#topbar .handle { color: var(--color-muted); font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- cards & forms ---------- */

.card {
  background: var(--color-surface);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  padding: 24px 20px;
  margin-top: 16px;
}

.login-card { text-align: center; }
.login-card .logo.big { color: var(--color-primary); display: inline-flex; }
.login-card h1 { margin: 8px 0 0; font-size: 28px; font-weight: 800; line-height: 1.15; }
.tagline { color: var(--color-muted); margin: 4px 0 20px; }
.footnote { color: var(--color-muted); font-size: 13px; margin: 16px 0 0; }

h2 { font-size: 22px; font-weight: 800; margin: 0 0 12px; }
h3 { font-size: 18px; }

label { display: block; margin: 14px 0 6px; font-weight: 700; }
.muted { color: var(--color-muted); font-weight: 500; }

input {
  width: 100%;
  font: inherit;
  color: var(--color-text);
  background: var(--color-surface);
  border: 2px solid var(--color-border);
  border-radius: 999px;
  padding: 12px 18px;
  min-height: 48px;
}
input:focus {
  outline: 3px solid var(--color-primary-soft);
  outline-offset: 2px;
  border-color: var(--color-primary);
}

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

button { font: inherit; cursor: pointer; }

.primary-btn {
  display: block;
  width: 100%;
  min-height: 48px;
  margin-top: 18px;
  padding: 12px 24px;
  border: none;
  border-radius: 999px;
  background: var(--color-primary);
  color: #fff;
  font-weight: 800;
  font-size: 17px;
  box-shadow: 0 3px 0 var(--color-primary-dark);
  transition: transform 120ms ease-out, box-shadow 120ms ease-out, background 160ms;
}
.primary-btn:hover { background: var(--color-primary-soft); }
.primary-btn:active { transform: translateY(3px); box-shadow: 0 0 0 var(--color-primary-dark); }
.primary-btn:disabled { opacity: 0.6; cursor: default; }

.secondary-btn {
  min-height: 48px;
  padding: 10px 22px;
  border-radius: 999px;
  border: 2px solid var(--color-primary);
  background: var(--color-surface);
  color: var(--color-primary);
  font-weight: 700;
}

.ghost-btn {
  min-height: 44px;
  padding: 8px 16px;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--color-muted);
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.ghost-btn:hover { color: var(--color-primary); }

:focus-visible { outline: 3px solid var(--color-primary-soft); outline-offset: 2px; }

/* ---------- jar screen ---------- */

#screen-jar { text-align: center; }

.balance {
  font-size: 30px;
  font-weight: 800;
  color: var(--color-gold-dark);
  font-variant-numeric: tabular-nums;
  margin: 18px 0 10px;
}
.balance.empty { color: var(--color-muted); font-size: 20px; }

.jar {
  position: relative;
  width: 240px;
  height: 300px;
  margin: 0 auto;
  background: var(--color-surface);
  border: 3px solid var(--color-border);
  border-top-width: 10px;
  border-radius: 28px 28px 34px 34px;
  box-shadow: var(--shadow-card);
  overflow: hidden;
}
#jar-canvas { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 1; }
.jar-fediverse {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 62%;
  transform: translate(-50%, -50%);
  color: var(--color-primary);
  opacity: 0.09;
  z-index: 0;
}
.jar::after { /* glass shine */
  content: '';
  position: absolute;
  top: 10px;
  bottom: 10px;
  left: 12px;
  width: 18px;
  border-radius: 12px;
  background: linear-gradient(rgba(255, 255, 255, 0.8), rgba(255, 255, 255, 0.05));
  pointer-events: none;
  z-index: 2;
}
.jar-mascot {
  position: absolute;
  top: -16px;
  right: 18px;
  transform: rotate(12deg);
  pointer-events: none;
}

.fab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 72px;
  height: 72px;
  margin-top: 22px;
  border: none;
  border-radius: 50%;
  background: var(--color-primary);
  color: #fff;
  box-shadow: 0 4px 0 var(--color-primary-dark), var(--shadow-card);
  transition: transform 120ms ease-out, box-shadow 120ms ease-out;
}
.fab:hover { background: var(--color-primary-soft); }
.fab:active { transform: translateY(4px); box-shadow: 0 0 0 var(--color-primary-dark); }

.jar-actions { margin-top: 18px; display: grid; gap: 4px; }
.jar-actions .primary-btn { margin-top: 0; }

/* ---------- transfer ---------- */

.post-list { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 10px; max-height: 260px; overflow-y: auto; }
.post-list li button {
  width: 100%;
  text-align: left;
  font: inherit;
  background: var(--color-bg);
  border: 2px solid var(--color-border);
  border-radius: 14px;
  padding: 10px 14px;
  min-height: 44px;
  transition: border-color 160ms, background 160ms;
}
.post-list li button:hover, .post-list li button.selected { border-color: var(--color-primary); background: #eef0ff; }
.post-list .who { font-weight: 800; color: var(--color-primary); }
.post-list .what { display: block; color: var(--color-text); font-size: 14px; }
.post-list .when { color: var(--color-muted); font-size: 12px; }
.empty { color: var(--color-muted); }

.result {
  margin-top: 18px;
  background: var(--color-bg);
  border: 2px dashed var(--color-gold-dark);
  border-radius: 14px;
  padding: 14px;
  font-size: 14px;
  text-align: left;
}
.result code {
  display: block;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 6px 10px;
  margin: 6px 0;
  word-break: break-all;
}
.copy-btn {
  border: none;
  background: transparent;
  color: var(--color-primary);
  font-weight: 700;
  text-decoration: underline;
  padding: 4px 0;
  min-height: 44px;
}
.back-btn { margin-top: 14px; }

/* ---------- badges ---------- */

.badge-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 12px; }
.badge {
  background: var(--color-bg);
  border: 2px solid var(--color-border);
  border-radius: 14px;
  padding: 14px 10px;
  text-align: center;
}
.badge.pop { animation: badge-pop 480ms cubic-bezier(0.34, 1.56, 0.64, 1); }
@keyframes badge-pop {
  0% { transform: scale(0.6); }
  60% { transform: scale(1.12); }
  100% { transform: scale(1); }
}
.badge .label { font-weight: 800; font-size: 14px; margin-top: 6px; }
.badge .date { color: var(--color-muted); font-size: 12px; }

/* ---------- camera overlay ---------- */

#camera-overlay {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: #1c1512;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 24px;
}
#camera-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.9;
}
.viewfinder {
  position: relative;
  width: min(320px, 80vw);
  height: 200px;
  border-radius: 18px;
}
.viewfinder span {
  position: absolute;
  width: 34px;
  height: 34px;
  border: 4px solid var(--color-gold);
}
.viewfinder span:nth-child(1) { top: 0; left: 0; border-right: none; border-bottom: none; border-radius: 14px 0 0 0; }
.viewfinder span:nth-child(2) { top: 0; right: 0; border-left: none; border-bottom: none; border-radius: 0 14px 0 0; }
.viewfinder span:nth-child(3) { bottom: 0; left: 0; border-right: none; border-top: none; border-radius: 0 0 0 14px; }
.viewfinder span:nth-child(4) { bottom: 0; right: 0; border-left: none; border-top: none; border-radius: 0 0 14px 0; }
.camera-note { color: #fff; background: rgba(0,0,0,0.55); padding: 6px 14px; border-radius: 999px; z-index: 1; }
.camera-controls { position: relative; z-index: 1; display: grid; gap: 10px; width: min(320px, 80vw); }
.camera-controls input { text-align: center; }
.camera-controls .primary-btn, .camera-controls .secondary-btn { margin-top: 0; }
.ghost-btn.light { color: #fff; }

/* ---------- coin spinner ---------- */

#spinner-overlay {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: var(--color-bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 24px;
}
.spinner-hint { color: var(--color-muted); text-align: center; max-width: 320px; margin: 0; }
#spinner-dial {
  position: relative;
  width: min(280px, 72vw);
  aspect-ratio: 1;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
#spinner-ticks { position: absolute; inset: 0; width: 100%; height: 100%; }
#spinner-coin {
  position: absolute;
  inset: 11%;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ffd873, var(--color-gold) 55%, var(--color-gold-dark));
  border: 4px solid var(--color-gold-dark);
  box-shadow: 0 6px 0 var(--color-gold-dark), var(--shadow-card);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: grab;
  touch-action: none;
}
#spinner-coin:active { cursor: grabbing; }
#spinner-dial.dragging #spinner-coin { box-shadow: 0 10px 22px rgba(209, 148, 42, 0.55); }
#spinner-coin svg { width: 44%; height: 44%; color: #8a5f14; pointer-events: none; }
#spinner-amount {
  margin: 0;
  font-size: 36px;
  font-weight: 800;
  color: var(--color-gold-dark);
  font-variant-numeric: tabular-nums;
}
.spinner-controls { display: grid; gap: 10px; width: min(320px, 80vw); }
.spinner-controls .primary-btn, .spinner-controls .secondary-btn { margin-top: 0; }

/* ---------- confirm screen ---------- */

#confirm-card { text-align: center; }
#confirm-card .big-check { color: var(--color-success); display: inline-flex; }
#confirm-card.error .big-check { color: var(--color-error); }

/* ---------- toast & confetti ---------- */

#toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  z-index: 40;
  background: var(--color-text);
  color: #fff;
  border-radius: 999px;
  padding: 12px 22px;
  font-weight: 700;
  box-shadow: var(--shadow-card);
  animation: toast-in 200ms ease-out;
  max-width: 90vw;
  text-align: center;
}
#toast.success { background: var(--color-success); }
#toast.error { background: var(--color-error); }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 10px); } to { opacity: 1; transform: translate(-50%, 0); } }

#confetti {
  position: fixed;
  inset: 0;
  z-index: 35;
  pointer-events: none;
  display: none;
}

/* ---------- reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
  .screen, #toast { animation: none; }
  .badge.pop { animation: none; }
  .primary-btn, .fab, .post-list li button { transition: none; }
}
