/* Forest Friends — green-themed PWA stylesheet */

:root {
  --green-50:  #EAF6EE;
  --green-100: #C4E5CF;
  --green-200: #9CD3AF;
  --green-400: #4DAE6F;
  --green-600: #1D9E75;
  --green-700: #167A5A;
  --green-800: #0E5A42;
  --green-900: #07392A;

  --bg:        #F8FAF7;
  --surface:   #FFFFFF;
  --text:      #1A2A22;
  --text-soft: #5A6A62;
  --text-mute: #8A9A92;
  --border:    rgba(0, 0, 0, 0.08);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.06);

  --teal:   #1D9E75;
  --blue:   #378ADD;
  --amber:  #BA7517;
  --pink:   #D4537E;
  --purple: #7F77DD;
  --coral:  #D85A30;
  --gray:   #6A7570;
  --red:    #E24B4A;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 24px;

  --header-h: 56px;
  --nav-h:    62px;

  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:        #0E1612;
    --surface:   #18241E;
    --text:      #E8F2EC;
    --text-soft: #A8B8B0;
    --text-mute: #6A7A72;
    --border:    rgba(255, 255, 255, 0.08);
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg); color: var(--text);
  font-family: var(--font-sans);
  font-size: 16px; line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

#app-shell {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex; flex-direction: column;
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
}

/* ===== Top bar ===== */
#top-bar {
  height: var(--header-h);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px;
  background: var(--surface);
  border-bottom: 0.5px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.brand-name { font-size: 16px; color: var(--green-700); }
.brand-leaf {
  display: inline-block; width: 20px; height: 20px;
  background: var(--green-600);
  clip-path: polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%);
}
.icon-btn {
  width: 40px; height: 40px;
  border: none; background: transparent;
  border-radius: 50%; color: var(--text-soft);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
}
.icon-btn:active { background: var(--green-50); }

/* ===== Main view ===== */
#view-root {
  flex: 1;
  padding: 16px 16px 24px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* ===== Bottom nav ===== */
#bottom-nav {
  height: var(--nav-h);
  background: var(--surface);
  border-top: 0.5px solid var(--border);
  display: grid; grid-template-columns: 1fr 1fr 1fr;
  position: sticky; bottom: 0;
  padding-bottom: env(safe-area-inset-bottom);
}
.nav-btn {
  border: none; background: transparent;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 2px; font-size: 11px;
  color: var(--text-mute); cursor: pointer;
  transition: color 0.15s;
}
.nav-btn.active { color: var(--green-600); }
.nav-btn svg { stroke-width: 2; }

/* ===== Kid switcher ===== */
.kid-pill {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--green-50); color: var(--green-800);
  border: 1px solid var(--green-200);
  padding: 6px 12px 6px 6px;
  border-radius: 999px; font-size: 14px; font-weight: 500;
  cursor: pointer;
}
.kid-avatar {
  width: 24px; height: 24px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--green-600); color: white;
  font-size: 11px; font-weight: 500;
}
.kid-menu {
  position: absolute; top: var(--header-h); left: 50%;
  transform: translateX(-50%);
  background: var(--surface);
  border: 0.5px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  padding: 8px; z-index: 20;
  min-width: 200px;
}
.kid-menu-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  cursor: pointer; font-size: 14px;
}
.kid-menu-item:active, .kid-menu-item.active { background: var(--green-50); }

/* ===== Today view ===== */
.today-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  margin-bottom: 16px; padding-bottom: 12px;
  border-bottom: 0.5px solid var(--border);
}
.today-title { font-size: 18px; font-weight: 500; margin: 0; }
.today-sub { font-size: 13px; color: var(--text-soft); margin: 2px 0 0; }

.bonus-banner {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; margin-bottom: 16px;
  background: #FAEEDA; border: 1px solid #EF9F27;
  border-radius: var(--radius-md);
}
.bonus-icon {
  width: 38px; height: 38px; border-radius: 50%;
  background: #EF9F27; color: white;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; flex-shrink: 0;
}
.bonus-text { flex: 1; min-width: 0; }
.bonus-title { font-size: 13px; font-weight: 500; color: #412402; margin: 0; }
.bonus-sub { font-size: 11px; color: #633806; margin: 2px 0 0; }
.bonus-num { font-size: 22px; font-weight: 500; color: #412402; }
.bonus-num span { font-size: 11px; font-weight: 400; }

.timeline { display: flex; flex-direction: column; gap: 6px; }
.tl-row {
  display: grid; grid-template-columns: 60px 10px 1fr auto;
  align-items: center; gap: 10px;
  padding: 10px 12px;
  background: var(--surface); border: 0.5px solid var(--border);
  border-radius: var(--radius-md);
}
.tl-time { font-size: 12px; color: var(--text-soft); }
.tl-dot { width: 8px; height: 8px; border-radius: 50%; justify-self: center; }
.tl-mid { display: flex; align-items: center; gap: 10px; min-width: 0; }
.tl-chip {
  width: 28px; height: 28px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 500; flex-shrink: 0;
}
.tl-label { font-size: 14px; margin: 0; }
.tl-sub { font-size: 11px; color: var(--text-soft); margin: 1px 0 0; }
.tl-tag {
  font-size: 10px; padding: 3px 8px; border-radius: 999px;
  font-weight: 500; white-space: nowrap;
}
.tag-done { background: var(--green-50); color: var(--green-800); }
.tag-pend { background: var(--bg); color: var(--text-soft); border: 0.5px solid var(--border); }
.tag-lock { background: #F1EFE8; color: #444441; }
.tag-class { background: #E6F1FB; color: #0C447C; }
.tag-meal { background: #FAECE7; color: #712B13; }

.tl-row.muted .tl-label { color: var(--text-soft); }

.now-line {
  display: grid; grid-template-columns: 60px 1fr 90px;
  align-items: center; gap: 10px; padding: 6px 0;
}
.now-label { font-size: 11px; font-weight: 500; color: #A32D2D; }
.now-stripe {
  height: 1.5px; background: #A32D2D; position: relative;
}
.now-stripe::before {
  content: ""; position: absolute; left: -4px; top: 50%;
  transform: translateY(-50%); width: 9px; height: 9px;
  border-radius: 50%; background: #A32D2D;
}
.now-right { font-size: 11px; font-weight: 500; color: #A32D2D; text-align: right; }

/* ===== Animal forest grid ===== */
.forest-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
}
.animal-card {
  background: var(--surface); border: 0.5px solid var(--border);
  border-radius: var(--radius-md); padding: 12px;
  display: flex; flex-direction: column; gap: 8px;
  cursor: pointer;
}
.animal-card.done { background: var(--green-50); border-color: var(--green-200); }
.animal-card.rest { opacity: 0.55; }
.animal-head { display: flex; align-items: center; gap: 10px; }
.animal-name { font-size: 14px; font-weight: 500; margin: 0; }
.animal-disc { font-size: 11px; color: var(--text-soft); margin: 0; }
.animal-meta { display: flex; align-items: center; justify-content: space-between; font-size: 12px; }
.streak {
  display: inline-flex; align-items: center; gap: 4px;
  color: #854F0B; font-weight: 500;
}
.streak::before { content: '🔥'; font-size: 12px; }
.minutes { color: var(--text-soft); }

/* ===== Auth gate ===== */
.overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(15, 25, 20, 0.6);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  backdrop-filter: blur(4px);
}
.overlay.hidden { display: none; }
.auth-card, .passcode-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 28px 24px;
  max-width: 360px; width: 100%;
  box-shadow: var(--shadow-md);
  text-align: center;
}
.auth-leaf {
  width: 48px; height: 48px;
  margin: 0 auto 16px;
  background: var(--green-600);
  clip-path: polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%);
}
.auth-card h1 { font-size: 22px; margin: 0 0 8px; }
.auth-subtitle { font-size: 14px; color: var(--text-soft); margin: 0 0 20px; }
#auth-form { display: flex; flex-direction: column; gap: 10px; }
.auth-card input, .passcode-card input {
  width: 100%; padding: 12px 14px; font-size: 16px;
  border: 1px solid var(--border); border-radius: var(--radius-md);
  background: var(--bg); color: var(--text);
  text-align: center;
}
.auth-card input:focus, .passcode-card input:focus {
  outline: 2px solid var(--green-400); outline-offset: -1px;
}
button.btn-primary, #auth-submit, #passcode-submit {
  background: var(--green-600); color: white;
  border: none; padding: 12px 14px;
  border-radius: var(--radius-md); font-size: 15px; font-weight: 500;
  cursor: pointer;
}
button.btn-primary:active, #auth-submit:active, #passcode-submit:active {
  background: var(--green-700);
}
button.btn-secondary, #passcode-cancel {
  background: transparent; color: var(--text-soft);
  border: 1px solid var(--border); padding: 12px 14px;
  border-radius: var(--radius-md); font-size: 15px;
  cursor: pointer;
}
.auth-message, .passcode-message {
  margin: 12px 0 0; font-size: 13px;
  min-height: 18px;
}
.auth-message.success, .passcode-message.success { color: var(--green-700); }
.auth-message.error, .passcode-message.error { color: var(--red); }

.passcode-card h2 { font-size: 18px; margin: 0 0 6px; }
#passcode-sub { font-size: 13px; color: var(--text-soft); margin: 0 0 16px; }
#passcode-input {
  letter-spacing: 12px; font-size: 24px; padding: 14px;
  margin-bottom: 16px;
}
.passcode-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* ===== Loading ===== */
.loading {
  display: flex; align-items: center; gap: 10px;
  padding: 20px; color: var(--text-soft);
}
.loading-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--green-400);
  animation: pulse 1.4s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { transform: scale(0.85); opacity: 0.5; }
  50% { transform: scale(1.15); opacity: 1; }
}

.empty {
  padding: 40px 20px; text-align: center;
  color: var(--text-soft);
}
.empty-title { font-size: 16px; font-weight: 500; margin: 0 0 6px; color: var(--text); }
.empty-sub { font-size: 13px; margin: 0; }

/* ===== Color discipline classes ===== */
.c-teal   { background: #E1F5EE; color: #085041; }
.c-blue   { background: #E6F1FB; color: #0C447C; }
.c-amber  { background: #FAEEDA; color: #633806; }
.c-pink   { background: #FBEAF0; color: #72243E; }
.c-green  { background: #EAF6EE; color: var(--green-800); }
.c-purple { background: #EEEDFE; color: #26215C; }
.c-coral  { background: #FAECE7; color: #712B13; }
.c-gray   { background: #F1EFE8; color: #444441; }
.c-red    { background: #FCEBEB; color: #791F1F; }

.dot-teal   { background: #1D9E75; }
.dot-blue   { background: #378ADD; }
.dot-amber  { background: #BA7517; }
.dot-pink   { background: #D4537E; }
.dot-green  { background: var(--green-600); }
.dot-purple { background: #7F77DD; }
.dot-coral  { background: #D85A30; }
.dot-gray   { background: #888780; }
.dot-red    { background: #E24B4A; }
