/* Shared look for all Jingle Tumble pages: fonts, colours, chunky buttons, avatars, toasts, cropper. */

@font-face {
  font-family: 'Fredoka One';
  src: local('Fredoka One'), local('FredokaOne-Regular'), url('/fonts/FredokaOne-Regular.ttf') format('truetype');
  font-display: swap;
}
@font-face {
  font-family: 'Cabin';
  font-weight: 700;
  src: local('Cabin Bold'), local('Cabin-Bold'), url('/fonts/Cabin-Bold.ttf') format('truetype');
  font-display: swap;
}

:root {
  --red: #d42a3c;
  --red-dk: #95162a;
  --red-lt: #ff6676;
  --green: #1f7a46;
  --green-dk: #13552f;
  --green-deep: #0b3a22;
  --green-night: #072617;
  --green-lt: #43b26f;
  --gold: #f7c340;
  --gold-dk: #c98b12;
  --gold-lt: #ffe28a;
  --snow: #fffaf2;
  --snow-dk: #eee4d3;
  --ink: #2a1c14;
  --ink-soft: #6e5c4f;
  --font-title: 'Fredoka One', 'Fredoka', ui-rounded, 'SF Pro Rounded', 'Arial Rounded MT Bold', 'Nunito', 'Trebuchet MS', system-ui, sans-serif;
  --font-body: 'Cabin', system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --shadow: 0 8px 22px rgba(20, 8, 4, 0.28);
  --shadow-sm: 0 3px 8px rgba(20, 8, 4, 0.22);
  --radius: 24px;
}

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

button, input, select, textarea { font: inherit; color: inherit; }
button { -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

.title-font { font-family: var(--font-title); font-weight: 400; letter-spacing: 0.01em; }

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45em;
  min-height: 48px;
  padding: 0.55em 1.25em;
  border: 0;
  border-radius: 999px;
  font-family: var(--font-title);
  font-size: 1.1rem;
  line-height: 1.1;
  color: var(--ink);
  background: var(--gold);
  box-shadow: 0 5px 0 var(--gold-dk), 0 9px 16px rgba(0, 0, 0, 0.22);
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  text-decoration: none;
  transition: transform 0.07s ease, box-shadow 0.07s ease, filter 0.15s;
  touch-action: manipulation;
}
.btn:active:not(:disabled), .btn.down { transform: translateY(4px); box-shadow: 0 1px 0 var(--gold-dk), 0 3px 8px rgba(0, 0, 0, 0.22); }
.btn:disabled { filter: grayscale(0.7) brightness(0.92); opacity: 0.6; cursor: default; }
.btn svg { width: 1.25em; height: 1.25em; flex: none; }
.btn.red { background: var(--red); color: #fff; box-shadow: 0 5px 0 var(--red-dk), 0 9px 16px rgba(0, 0, 0, 0.22); }
.btn.red:active:not(:disabled) { box-shadow: 0 1px 0 var(--red-dk), 0 3px 8px rgba(0, 0, 0, 0.22); }
.btn.green { background: var(--green-lt); color: #fff; box-shadow: 0 5px 0 var(--green-dk), 0 9px 16px rgba(0, 0, 0, 0.22); }
.btn.green:active:not(:disabled) { box-shadow: 0 1px 0 var(--green-dk), 0 3px 8px rgba(0, 0, 0, 0.22); }
.btn.snow { background: var(--snow); color: var(--ink); box-shadow: 0 5px 0 var(--snow-dk), 0 9px 16px rgba(0, 0, 0, 0.18); }
.btn.snow:active:not(:disabled) { box-shadow: 0 1px 0 var(--snow-dk), 0 3px 8px rgba(0, 0, 0, 0.18); }
.btn.ghost { background: transparent; color: inherit; box-shadow: none; text-decoration: underline; text-underline-offset: 3px; }
.btn.ghost:active { transform: none; box-shadow: none; opacity: 0.7; }
.btn.small { min-height: 36px; font-size: 0.95rem; padding: 0.4em 0.95em; box-shadow: 0 3px 0 var(--gold-dk), 0 5px 10px rgba(0, 0, 0, 0.18); }
.btn.small.red { box-shadow: 0 3px 0 var(--red-dk), 0 5px 10px rgba(0, 0, 0, 0.18); }
.btn.small.green { box-shadow: 0 3px 0 var(--green-dk), 0 5px 10px rgba(0, 0, 0, 0.18); }
.btn.small.snow { box-shadow: 0 3px 0 var(--snow-dk), 0 5px 10px rgba(0, 0, 0, 0.14); }
.btn.big { min-height: 60px; font-size: 1.35rem; padding: 0.6em 1.6em; }

/* A label that wraps a file input and looks like a button. The input stays in the layout
   (not display:none) because some mobile browsers refuse to open hidden file inputs. */
.file-btn { position: relative; overflow: hidden; }
.file-btn input[type='file'] { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; font-size: 0; }

/* ------------------------------------------------------------ avatars and beans */

.avatar {
  --s: 44px;
  position: relative;
  display: inline-grid;
  place-items: end center;
  flex: none;
  width: var(--s);
  height: var(--s);
  border-radius: 50%;
  overflow: hidden;
  background: radial-gradient(circle at 50% 30%, #ffffff, #dfe8f1);
  box-shadow: 0 0 0 calc(var(--s) * 0.07) var(--ring, #ccc), var(--shadow-sm);
  isolation: isolate;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; -webkit-touch-callout: none; pointer-events: none; }
.avatar .bean { width: 92%; height: 92%; display: block; }

.figure { position: relative; width: 120px; aspect-ratio: 120 / 160; flex: none; }
.figure .fig-body { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.figure .fig-face {
  position: absolute;
  left: 24.17%;
  top: 20.6%;
  width: 51.67%;
  height: 38.75%;
  border-radius: 50%;
  object-fit: cover;
  pointer-events: none;
  -webkit-touch-callout: none;
}
.figure .fig-hat { position: absolute; left: 16%; top: -17%; width: 68%; aspect-ratio: 1; pointer-events: none; }
.figure .fig-hat svg { width: 100%; height: 100%; display: block; overflow: visible; }

.hat-icon svg { width: 100%; height: 100%; display: block; }

/* ------------------------------------------------------------ toasts */

#toasts {
  position: fixed;
  z-index: 60;
  left: 50%;
  top: calc(env(safe-area-inset-top, 0px) + 74px);
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
  width: max-content;
  max-width: calc(100vw - 32px);
}
.toast {
  font-family: var(--font-title);
  font-size: 1.05rem;
  color: var(--ink);
  background: var(--gold-lt);
  border: 3px solid #fff;
  border-radius: 999px;
  padding: 0.45em 1.1em;
  box-shadow: var(--shadow);
  text-align: center;
  animation: toast-in 0.28s cubic-bezier(0.2, 1.4, 0.4, 1);
  transition: opacity 0.35s, transform 0.35s;
}
.toast.error { background: var(--red); color: #fff; }
.toast.good { background: var(--green-lt); color: #fff; }
.toast.out { opacity: 0; transform: translateY(-10px) scale(0.96); }
@keyframes toast-in { from { opacity: 0; transform: translateY(-14px) scale(0.85); } }

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

.spinner {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 5px solid rgba(255, 255, 255, 0.25);
  border-top-color: var(--gold);
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ------------------------------------------------------------ photo cropper (cropper.js) */

.fc-crop {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(env(safe-area-inset-top, 0px) + 12px) calc(env(safe-area-inset-right, 0px) + 12px)
    calc(env(safe-area-inset-bottom, 0px) + 12px) calc(env(safe-area-inset-left, 0px) + 12px);
  background: rgba(7, 26, 16, 0.9);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  color: var(--snow);
  font-family: var(--font-body);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
.fc-crop-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  width: min(100%, 460px);
  max-height: 100%;
}
.fc-crop h2 { margin: 0; font-family: var(--font-title); font-weight: 400; font-size: 1.45rem; text-align: center; }
.fc-crop-hint { margin: -6px 0 0; font-size: 0.92rem; opacity: 0.8; text-align: center; }
.fc-crop-stage {
  position: relative;
  width: var(--stage, 300px);
  height: var(--stage, 300px);
  border-radius: 20px;
  overflow: hidden;
  background: #142a1e;
  box-shadow: var(--shadow);
  touch-action: none;
  cursor: grab;
}
.fc-crop-stage:active { cursor: grabbing; }
.fc-crop-stage canvas { display: block; width: 100%; height: 100%; }
.fc-crop-status {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 20px;
  text-align: center;
  font-family: var(--font-title);
  font-size: 1.1rem;
  background: rgba(7, 26, 16, 0.72);
}
.fc-crop-row { display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; }
.fc-crop-zoom { flex: 1; display: flex; align-items: center; gap: 8px; max-width: 320px; }
.fc-crop-zoom svg { width: 22px; height: 22px; flex: none; opacity: 0.85; }
.fc-crop-zoom input { flex: 1; accent-color: var(--gold); height: 32px; }
.fc-crop-progress { width: min(260px, 80%); height: 12px; border-radius: 99px; background: rgba(255, 255, 255, 0.2); overflow: hidden; }
.fc-crop-progress > div { height: 100%; width: 0; background: var(--gold); transition: width 0.15s; }
.fc-crop-error { color: #ffd0d4; font-family: var(--font-body); font-size: 1rem; }
.fc-icon-btn {
  width: 48px;
  height: 48px;
  flex: none;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  cursor: pointer;
}
.fc-icon-btn svg { width: 26px; height: 26px; }
.fc-icon-btn:active { background: rgba(255, 255, 255, 0.3); }

@media (prefers-reduced-motion: reduce) {
  .toast, .btn { animation: none; transition: none; }
}
