/* ============================================================
   Caribou Health — Mobile Loading (Splash) + Sign In
   Implemented from the "Mobile UX" Claude Design project
   (Loading + Sign In.html · Splash.jsx "draw" variant · SignIn.jsx).
   Tokens are namespaced --cbm-* to avoid clashing with app styles.
   ============================================================ */

:root {
  --cbm-primary-500: #3d9b94;
  --cbm-primary-600: #328580;
  --cbm-primary-700: #296d69;
  --cbm-primary-800: #215654;
  --cbm-gray-50:  #f9fafb;
  --cbm-gray-200: #e5e7eb;
  --cbm-gray-300: #d1d5db;
  --cbm-gray-400: #9ca3af;
  --cbm-gray-600: #4b5563;
  --cbm-gray-700: #374151;
  --cbm-gray-800: #1f2937;
  --cbm-gray-900: #111827;
  --cbm-radius: 0.5rem;
  --cbm-font-display: 'DM Serif Display', Georgia, 'Times New Roman', serif;
  --cbm-font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --cbm-gradient-hero: linear-gradient(135deg, #fef7f4 0%, #fdeee8 30%, #d1eae8 70%, #e8f4f3 100%);
  --cbm-gradient-button: linear-gradient(135deg, var(--cbm-primary-500) 0%, var(--cbm-primary-600) 100%);
}

/* ── Splash / loading screen ─────────────────────────────── */
.cbm-splash {
  position: fixed; inset: 0; z-index: 990;
  background: var(--cbm-gradient-hero);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-family: var(--cbm-font-sans);
  opacity: 1; transition: opacity .42s ease;
  /* respect the iOS notch inside the Capacitor shell */
  padding: env(safe-area-inset-top, 0) env(safe-area-inset-right, 0)
           env(safe-area-inset-bottom, 0) env(safe-area-inset-left, 0);
}
.cbm-splash.cbm-out { opacity: 0; pointer-events: none; }

.cbm-splash-center { text-align: center; margin-top: -16px; }

.cbm-splash-disc {
  width: 132px; height: 132px; border-radius: 50%;
  background: #fff; margin: 0 auto 22px;
  display: grid; place-items: center;
  box-shadow: 0 12px 32px rgba(33, 86, 84, .20), 0 3px 8px rgba(0, 0, 0, .06);
  animation: cbmFloat 5s ease-in-out infinite;
}
.cbm-splash-loader { position: relative; width: 92px; height: 92px; }
.cbm-draw-svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.cbm-draw-svg path {
  stroke: var(--cbm-primary-600);
  stroke-linecap: round; stroke-linejoin: round; fill: none;
  stroke-dasharray: 1; stroke-dashoffset: 1;
  /* stroke-width and draw timing are set inline per segment */
}
.cbm-draw-svg circle {
  stroke: var(--cbm-primary-600); stroke-width: 20; fill: none;
  opacity: 0; transform-box: fill-box; transform-origin: center;
  animation: cbmPop .5s cubic-bezier(.25, .6, .3, 1) forwards;
}
.cbm-draw-png {
  position: absolute; inset: 0; width: 100%; height: 100%; display: block;
  opacity: 0; animation: cbmInk .55s ease forwards;
}

.cbm-splash-wordmark {
  font-family: var(--cbm-font-display); font-size: 40px; font-weight: 400;
  color: var(--cbm-primary-800); margin: 0;
  animation: cbmRise .7s ease .2s both;
}
.cbm-splash-slogan {
  font-family: var(--cbm-font-display); font-style: italic; font-size: 16px;
  color: var(--cbm-primary-700); margin: 6px 0 0; opacity: .92;
  animation: cbmRise .7s ease .4s both;
}

/* ── Sign In screen ──────────────────────────────────────── */
.cbm-signin {
  position: fixed; inset: 0; z-index: 950;
  background: #fff; overflow-y: auto; -webkit-overflow-scrolling: touch;
  font-family: var(--cbm-font-sans); color: var(--cbm-gray-800);
  display: flex; flex-direction: column;
  opacity: 1; transition: opacity .42s ease, transform .42s ease;
}
.cbm-signin.cbm-in { opacity: 0; transform: translateY(8px); }
.cbm-signin.cbm-out { opacity: 0; transform: translateY(8px); pointer-events: none; }

.cbm-signin-header {
  background: var(--cbm-gradient-hero);
  padding: calc(58px + env(safe-area-inset-top, 20px)) 24px 30px;
  text-align: center;
  border-bottom-left-radius: 28px; border-bottom-right-radius: 28px;
  flex-shrink: 0;
}
.cbm-signin-logo {
  width: 68px; height: 68px; margin: 0 auto 8px; display: block;
  filter: drop-shadow(0 4px 12px rgba(0, 0, 0, .12));
}
.cbm-signin-wordmark {
  font-family: var(--cbm-font-display); font-size: 32px; font-weight: 400;
  color: var(--cbm-primary-800); margin: 0; line-height: 1.1;
}
.cbm-signin-slogan {
  font-family: var(--cbm-font-display); font-style: italic; font-size: 15px;
  color: var(--cbm-primary-700); margin: 4px 0 0; opacity: .9;
}

.cbm-signin-body { padding: 26px 24px calc(40px + env(safe-area-inset-bottom, 0)); flex: 1; max-width: 440px; margin: 0 auto; width: 100%; box-sizing: border-box; }
.cbm-signin-welcome { font-family: var(--cbm-font-display); font-size: 26px; font-weight: 400; color: var(--cbm-gray-900); margin: 0 0 4px; }
.cbm-signin-sub { font-size: 15px; color: var(--cbm-gray-600); margin: 0 0 22px; }

/* Segmented sign-in / create-account switch */
.cbm-seg {
  display: flex; gap: 4px; background: #f3f4f6; padding: 4px;
  border-radius: 9999px; margin-bottom: 20px;
}
.cbm-seg button {
  flex: 1; padding: 10px 0; border-radius: 9999px; border: none;
  background: transparent; font-family: var(--cbm-font-sans);
  font-size: 14px; font-weight: 600; color: #6b7280;
  cursor: pointer; transition: all .18s ease;
}
.cbm-seg button[aria-selected="true"] {
  background: #fff; color: var(--cbm-primary-700);
  box-shadow: 0 1px 2px 0 rgba(0, 0, 0, .05);
}

.cbm-form { display: flex; flex-direction: column; gap: 16px; }
.cbm-field label {
  display: block; font-size: 14px; font-weight: 600;
  color: var(--cbm-gray-700); margin-bottom: 6px;
}
.cbm-field input {
  width: 100%; box-sizing: border-box;
  padding: 13px 14px; font-size: 16px; /* 16px stops iOS zoom-on-focus */
  font-family: var(--cbm-font-sans); color: var(--cbm-gray-900);
  border: 1px solid var(--cbm-gray-300); border-radius: var(--cbm-radius);
  background: #fff; outline: none; transition: border-color .15s ease, box-shadow .15s ease;
}
.cbm-field input:focus {
  border-color: var(--cbm-primary-500);
  box-shadow: 0 0 0 3px rgba(61, 155, 148, .18);
}
.cbm-pw-wrap { position: relative; }
.cbm-eye {
  position: absolute; right: 12px; top: 34px;
  border: none; background: transparent; color: var(--cbm-gray-400);
  cursor: pointer; padding: 4px; display: grid; place-items: center;
}
.cbm-forgot {
  align-self: flex-end; margin-top: -6px;
  font-size: 14px; font-weight: 600; color: var(--cbm-primary-600);
  cursor: pointer; text-decoration: none; background: none; border: none; padding: 0;
  font-family: var(--cbm-font-sans);
}

.cbm-btn-primary {
  width: 100%; box-sizing: border-box;
  display: flex; align-items: center; justify-content: center; gap: 9px;
  padding: 15px 0; border: none; border-radius: var(--cbm-radius);
  background: var(--cbm-gradient-button); color: #fff;
  font-family: var(--cbm-font-sans); font-size: 16px; font-weight: 600;
  cursor: pointer; box-shadow: 0 2px 8px rgba(61, 155, 148, .25);
  transition: filter .15s ease;
}
.cbm-btn-primary:hover { filter: brightness(1.05); }
.cbm-btn-primary:disabled { opacity: .75; cursor: default; }
.cbm-spin { animation: cbmSpin .7s linear infinite; }

.cbm-error {
  display: none; padding: 11px 14px; border-radius: var(--cbm-radius);
  background: #fee2e2; color: #b91c1c; font-size: 14px; line-height: 1.4;
}
.cbm-error.cbm-show { display: block; animation: cbmShake .4s ease-out; }

.cbm-divider { display: flex; align-items: center; gap: 12px; margin: 24px 0 18px; }
.cbm-divider span:nth-child(2) { font-size: 13px; color: var(--cbm-gray-400); white-space: nowrap; }
.cbm-divider-line { flex: 1; height: 1px; background: var(--cbm-gray-200); }

.cbm-btn-social {
  width: 100%; box-sizing: border-box;
  display: flex; align-items: center; justify-content: center; gap: 9px;
  padding: 13px 0; border: 1px solid var(--cbm-gray-200); border-radius: var(--cbm-radius);
  background: #fff; font-family: var(--cbm-font-sans);
  font-size: 15px; font-weight: 600; color: var(--cbm-gray-700);
  cursor: pointer; transition: background .15s ease;
}
.cbm-btn-social:hover { background: var(--cbm-gray-50); }
.cbm-btn-social:disabled { opacity: .75; cursor: default; }

/* Apple Sign-In: black per Apple HIG; shown only in the native iOS shell */
.cbm-btn-apple {
  background: #000; color: #fff; border-color: #000;
  margin-bottom: 10px;
}
.cbm-btn-apple:hover { background: #1a1a1a; }

.cbm-signup-row { text-align: center; font-size: 14px; color: var(--cbm-gray-600); margin: 26px 0 0; }
.cbm-signup-row button {
  color: var(--cbm-primary-600); font-weight: 600; cursor: pointer;
  background: none; border: none; padding: 0; font-size: 14px; font-family: var(--cbm-font-sans);
}

/* Create-account extras */
.cbm-field-hint { font-size: 12px; color: var(--cbm-gray-400); margin: 6px 0 0; line-height: 1.4; }
.cbm-check {
  display: flex; align-items: flex-start; gap: 10px; cursor: pointer;
  font-size: 13.5px; color: var(--cbm-gray-600); line-height: 1.45;
}
.cbm-check input { margin-top: 2px; flex-shrink: 0; accent-color: var(--cbm-primary-600); width: 17px; height: 17px; }
.cbm-check a { color: var(--cbm-primary-600); font-weight: 600; text-decoration: none; }

/* ── Keyframes (from Splash.jsx) ─────────────────────────── */
@keyframes cbmBob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-7px); } }
@keyframes cbmFloat { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-2px); } }
@keyframes cbmRise { 0% { opacity: 0; transform: translateY(12px); } 100% { opacity: 1; transform: translateY(0); } }
@keyframes cbmDraw { to { stroke-dashoffset: 0; } }
@keyframes cbmFadeOut { to { opacity: 0; } }
@keyframes cbmPop { 0% { opacity: 0; transform: scale(.86); } 100% { opacity: 1; transform: scale(1); } }
@keyframes cbmInk { to { opacity: 1; } }
@keyframes cbmSpin { to { transform: rotate(360deg); } }
@keyframes cbmShake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); } 75% { transform: translateX(6px); }
}

@media (prefers-reduced-motion: reduce) {
  .cbm-splash, .cbm-splash * { animation: none !important; }
  .cbm-draw-svg { opacity: 0 !important; }
  .cbm-draw-png { opacity: 1 !important; }
  .cbm-splash-wordmark, .cbm-splash-slogan { opacity: 1 !important; transform: none !important; }
}
