/* UniGreen design system — Sage & Terracotta. Linked first on every page; page
   stylesheets only add layout specific to that page and never define colours. */

:root {
  --bg: #F3EFE7;
  --surface: #FFFDF9;
  --surface-2: #F8F4EC;
  --line: #E4DDD0;
  --track: #ECE6DA;

  --ink: #24231F;
  --ink-2: #716A5D;   /* secondary text — 4.5:1 on --bg */
  --ink-3: #857E70;   /* icons and inactive tabs only, too light for small text */
  --ink-4: #B3AC9F;   /* placeholders, dashed outlines */

  --primary: #5B7F5E;
  --primary-dark: #3E5A41;
  --primary-tint: #E5ECE0;
  --primary-soft: #A9BCA9;

  --accent: #C96B4B;      /* icons and large numbers only */
  --accent-ink: #A4512F;  /* terracotta for text */
  --accent-tint: #F6E5DC;

  --danger: #A33A2A;
  --danger-tint: #F6E1DC;

  --strava: #FC4C02;

  /* Canopy: the deep green of the tab bar, hero and feature cards. */
  --canopy: #1F3B2C;
  --canopy-2: #284535;
  --canopy-ink: #F3EFE7;
  --canopy-ink-2: rgba(243, 239, 231, 0.75);
  --sage-glow: #A9BCA9;
  --peach: #E9A27F;

  --r-xl: 22px;
  --r-lg: 20px;
  --r-md: 14px;
  --r-sm: 8px;
  --shadow: 0 1px 2px rgba(36, 35, 31, 0.04), 0 4px 14px rgba(36, 35, 31, 0.04);
  --shadow-lift: 0 10px 26px rgba(31, 59, 44, 0.12);
  --shadow-canopy: 0 14px 34px rgba(31, 59, 44, 0.28);
  --focus-ring: 0 0 0 3px rgba(91, 127, 94, 0.22);

  /* Motion language: Sprout (earned things), Settle (cards arriving), Draw (strokes). */
  --ease-sprout: cubic-bezier(.34, 1.56, .64, 1);
  --ease-settle: cubic-bezier(.2, .8, .2, 1);
  --ease-draw: cubic-bezier(.45, 0, .2, 1);

  --font-display: 'Bricolage Grotesque', 'Inter', -apple-system, sans-serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.45;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--primary-dark); }

/* ── Icons (ug-icons.js) ──────────────────────────────────────────── */
ug-icon { display: inline-flex; width: 1em; height: 1em; flex-shrink: 0; vertical-align: -0.125em; }
ug-icon svg { width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; overflow: visible; }
.ug-wheel { transform-box: fill-box; transform-origin: center; }

/* ── Motion ───────────────────────────────────────────────────────── */
@keyframes ugRise { from { opacity: 0; transform: translateY(22px); } to { opacity: 1; transform: none; } }
@keyframes ugSprout { 0% { transform: scale(.3); opacity: 0; } 60% { transform: scale(1.14); opacity: 1; } 100% { transform: scale(1); } }
@keyframes ugGrow { from { transform: scaleY(0); } to { transform: scaleY(1); } }
@keyframes ugFillX { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@keyframes ugPulse { 0% { box-shadow: 0 0 0 0 rgba(201, 107, 75, .5); } 100% { box-shadow: 0 0 0 12px rgba(201, 107, 75, 0); } }
@keyframes ugBob { 0%, 100% { transform: translateY(0) rotate(-6deg); } 50% { transform: translateY(-7px) rotate(5deg); } }
@keyframes ugShine { 0%, 70% { transform: translateX(-160%) skewX(-18deg); } 100% { transform: translateX(560%) skewX(-18deg); } }
@keyframes ugDraw { from { stroke-dashoffset: 1; } to { stroke-dashoffset: 0; } }
@keyframes ugBlink { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }
/* Cards settle into place top to bottom; pages set --i on each for the stagger. */
.rise { animation: ugRise .8s var(--ease-settle) both; animation-delay: calc(var(--i, 0) * 70ms); }
.sprout { animation: ugSprout .55s var(--ease-sprout) both; }
.lift { transition: transform .25s var(--ease-settle), box-shadow .25s; }
.lift:hover { transform: translateY(-3px); box-shadow: var(--shadow-lift); }
.sub2 { font-family: var(--font-body); font-weight: 600; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; animation-delay: 0ms !important; transition-duration: 0.01ms !important; }
}

/* Tabbed pages: room for the bottom bar plus the iPhone home indicator. */
body.app-page {
  max-width: 520px; margin: 0 auto;
  padding: calc(28px + env(safe-area-inset-top)) max(20px, env(safe-area-inset-right)) calc(112px + env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left));
}
/* Single-card pages (sign in, PIN, support, …). */
body.center-page {
  min-height: 100vh; min-height: 100dvh;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: calc(32px + env(safe-area-inset-top)) max(20px, env(safe-area-inset-right)) calc(32px + env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left));
}

/* Edge-to-edge iOS app only (see app-env.js): a frosted band behind the status bar.
   env() is 0 everywhere else, so on the website it has no height. */
.status-scrim {
  position: fixed; top: 0; left: 0; right: 0; z-index: 900; height: env(safe-area-inset-top);
  background: rgba(243, 239, 231, .86); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  pointer-events: none; transition: opacity .2s;
}
.status-scrim.over-dark { opacity: 0; }

.page-header { margin-bottom: 24px; }
.page-header h1 { font-family: var(--font-display); font-size: 34px; font-weight: 650; letter-spacing: -0.025em; line-height: 1.05; color: var(--ink); }
.page-header p { font-size: 15px; color: var(--ink-2); margin-top: 6px; }

.section-label {
  display: flex; align-items: baseline; flex-wrap: wrap; gap: 6px;
  font-size: 12px; font-weight: 600; color: var(--ink-2);
  text-transform: uppercase; letter-spacing: 0.08em;
  margin: 28px 0 12px;
}
.section-label .hint { text-transform: none; letter-spacing: 0; font-weight: 400; color: var(--ink-2); }

/* ── Buttons ──────────────────────────────────────────────────────── */
.btn-primary, .btn-login, .btn-register, .confirm-tap-btn, .about-btn-primary, .add-btn {
  width: 100%;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 15px 18px;
  background: var(--primary); color: #fff;
  border: none; border-radius: var(--r-md);
  font-size: 16px; font-weight: 600; text-decoration: none;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}
.btn-primary:hover, .btn-login:hover, .btn-register:hover, .confirm-tap-btn:hover, .about-btn-primary:hover, .add-btn:hover { background: var(--primary-dark); }
.btn-primary:active, .btn-login:active, .btn-register:active, .confirm-tap-btn:active, .about-btn-primary:active, .add-btn:active { transform: scale(0.985); }
.btn-primary:disabled, .add-btn:disabled { background: var(--primary-soft); cursor: not-allowed; transform: none; }
.btn-primary ug-icon, .btn-login ug-icon, .btn-register ug-icon, .about-btn-primary ug-icon { font-size: 18px; }

.btn-secondary, .about-btn-secondary, .about-btn, .signout-btn {
  width: 100%;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: 15px 18px;
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--line); border-radius: var(--r-md);
  box-shadow: var(--shadow);
  font-size: 15px; font-weight: 500; text-decoration: none;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-secondary:hover, .about-btn-secondary:hover, .about-btn:hover, .signout-btn:hover { background: var(--surface-2); }
.btn-secondary ug-icon, .about-btn-secondary ug-icon, .about-btn ug-icon, .signout-btn ug-icon { font-size: 19px; color: var(--ink-3); }

.btn-ghost, .confirm-cancel-btn, .modal-cancel-btn {
  width: 100%; padding: 12px;
  background: none; border: none;
  color: var(--ink-2); font-size: 14px; font-weight: 500;
  cursor: pointer;
}
.btn-ghost:hover, .confirm-cancel-btn:hover, .modal-cancel-btn:hover { color: var(--ink); }

/* Loading state for buttons that contain .btn-text + .spinner */
.spinner { display: none; width: 18px; height: 18px; border: 2px solid rgba(255, 255, 255, 0.35); border-top-color: #fff; border-radius: 50%; animation: spin 0.65s linear infinite; }
.loading { opacity: 0.8; pointer-events: none; }
.loading .spinner { display: block; }
.loading .btn-text, .loading > ug-icon { display: none; }
.mini-spinner { width: 16px; height: 16px; border: 2px solid var(--track); border-top-color: var(--primary); border-radius: 50%; animation: spin 0.7s linear infinite; flex-shrink: 0; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Messages ─────────────────────────────────────────────────────── */
.error-msg, .success-msg { display: none; font-size: 14px; font-weight: 500; line-height: 1.4; border-radius: var(--r-md); padding: 11px 14px; margin-bottom: 16px; text-align: center; }
.error-msg { background: var(--danger-tint); color: var(--danger); }
.success-msg { background: var(--primary-tint); color: var(--primary-dark); }
.error-msg.visible, .success-msg.visible { display: block; }

.toast {
  position: fixed; left: 20px; right: 20px; bottom: calc(96px + env(safe-area-inset-bottom));
  max-width: 440px; margin: 0 auto;
  background: var(--ink); color: #fff;
  font-size: 14px; font-weight: 500; text-align: center;
  padding: 12px 18px; border-radius: var(--r-md); box-shadow: var(--shadow-lift);
  opacity: 0; transform: translateY(8px); transition: opacity 0.2s, transform 0.2s; pointer-events: none;
}
.toast.show { opacity: 1; transform: translateY(0); }

.empty-note {
  font-size: 14px; color: var(--ink-2); text-align: center;
  padding: 22px 20px;
  background: var(--surface); border: 1px dashed var(--line); border-radius: var(--r-lg);
}

/* ── Weekly progress (Home + Rewards) ─────────────────────────────── */
.progress-bar-bg { height: 6px; background: var(--track); border-radius: 99px; overflow: hidden; }
.progress-bar-fill { height: 100%; background: var(--primary); border-radius: 99px; transition: width 0.6s ease; }

.circle, .prog-circle {
  width: 100%; max-width: 40px; aspect-ratio: 1;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 600;
}
.circle.done, .prog-circle.done { background: var(--primary); color: #fff; }
.circle.fail, .prog-circle.fail { background: var(--danger-tint); color: var(--danger); }
.circle.empty, .prog-circle.empty { background: transparent; border: 1.5px dashed var(--ink-4); }

/* ── Bottom tab bar ───────────────────────────────────────────────── */
/* A floating canopy-green pill; the student Log tab (.nav-fab) sits beside it as a
   terracotta button. Labels stay for screen readers, a dot marks the active tab. */
.bottom-nav {
  position: fixed; z-index: 100;
  left: max(16px, calc(50% - 244px)); right: max(16px, calc(50% - 244px));
  bottom: calc(14px + env(safe-area-inset-bottom));
  height: 64px;
  display: flex; align-items: center; justify-content: space-around;
  background: var(--canopy);
  border-radius: 24px;
  box-shadow: var(--shadow-canopy);
  animation: ugRise .6s var(--ease-settle) both;
}
.bottom-nav:has(.nav-fab:not([hidden])) { right: calc(max(16px, calc(50% - 244px)) + 74px); }
.nav-item {
  position: relative;
  flex: 1; max-width: 88px; height: 100%;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px;
  color: rgba(243, 239, 231, 0.62); text-decoration: none;
  transition: color 0.2s;
}
.nav-item[hidden] { display: none; }
.nav-item ug-icon { font-size: 24px; transition: transform .3s var(--ease-sprout); }
.nav-item > span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.nav-item::after { content: ''; width: 5px; height: 5px; border-radius: 50%; background: transparent; transition: background .2s, transform .3s var(--ease-sprout); transform: scale(0); }
.nav-item:hover { color: var(--canopy-ink); }
.nav-item:active ug-icon { transform: scale(.88); }
.nav-item.active { color: var(--canopy-ink); }
.nav-item.active::after { background: var(--accent); transform: scale(1); }

.nav-item.nav-fab {
  position: absolute; right: -74px; top: 0;
  width: 64px; max-width: none; height: 64px;
  border-radius: 22px;
  background: var(--accent); color: #FFFDF9;
  box-shadow: 0 14px 30px rgba(164, 81, 47, .35);
  transition: transform .2s var(--ease-sprout), background .2s;
}
.nav-item.nav-fab::after { display: none; }
.nav-item.nav-fab ug-icon { font-size: 28px; }
.nav-item.nav-fab ug-icon svg { stroke-width: 2.2; }
.nav-item.nav-fab:hover { transform: scale(1.06); color: #FFFDF9; }
.nav-item.nav-fab:hover ug-icon { transform: rotate(90deg); }
.nav-item.nav-fab.active { background: var(--surface); color: var(--accent); box-shadow: inset 0 0 0 2px var(--accent); }
