/* ============================================================
   MicroHabits — styles.css  v2.0
   18 habits · Categories · iOS native scroll · Glassmorphism
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;1,9..40,300&family=DM+Serif+Display:ital@0;1&display=swap');

/* ─── Variables ──────────────────────────────────────────────── */
:root {
  --accent      : #4F46E5;
  --accent-light: #818CF8;
  --accent-bg   : rgba(79,70,229,0.08);
  --bg          : #F0EEE9;
  --bg2         : #E4E1DB;
  --surface     : rgba(255,255,255,0.70);
  --surface2    : rgba(255,255,255,0.48);
  --border      : rgba(255,255,255,0.92);
  --border2     : rgba(0,0,0,0.07);
  --text        : #1A1814;
  --text2       : #6B6862;
  --text3       : #A0998F;
  --radius      : 20px;
  --radius-sm   : 14px;
  --radius-xs   : 10px;
  --shadow      : 0 4px 20px rgba(0,0,0,0.07), 0 1px 3px rgba(0,0,0,0.04);
  --shadow-lg   : 0 10px 40px rgba(0,0,0,0.11), 0 2px 8px rgba(0,0,0,0.05);
  --safe-top    : env(safe-area-inset-top,   44px);
  --safe-bottom : env(safe-area-inset-bottom, 34px);
}

/* ─── Reset ──────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { height: 100%; -webkit-text-size-adjust: 100%; }

/* iOS native app feel — no bounce on body, scroll on inner container */
body {
  font-family: 'DM Sans', -apple-system, sans-serif;
  background  : var(--bg);
  color       : var(--text);
  height      : 100%;
  overflow    : hidden;                  /* ← prevents body bounce */
  overscroll-behavior-y: contain;
  -webkit-font-smoothing: antialiased;
  position    : relative;
}

/* Noise grain */
body::before {
  content : '';
  position: fixed;
  inset   : 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.03'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index : 0;
  opacity : 0.45;
}

/* Ambient blobs */
.blob { position: fixed; border-radius: 50%; filter: blur(90px); pointer-events: none; z-index: 0; }
.blob-1 { width:340px; height:340px; background: radial-gradient(circle,rgba(79,70,229,.14) 0%,transparent 70%); top:-90px; right:-50px; }
.blob-2 { width:260px; height:260px; background: radial-gradient(circle,rgba(236,72,153,.09) 0%,transparent 70%); bottom:22%; left:-70px; }
.blob-3 { width:200px; height:200px; background: radial-gradient(circle,rgba(16,185,129,.08) 0%,transparent 70%); bottom:5%; right:10%; }

/* ─── App shell ──────────────────────────────────────────────── */
.app-shell {
  position      : relative;
  z-index       : 1;
  max-width     : 430px;
  margin        : 0 auto;
  height        : 100dvh;
  display       : flex;
  flex-direction: column;
  padding-top   : var(--safe-top);
}

/* ─── Fixed header area ──────────────────────────────────────── */
.app-header {
  flex-shrink: 0;
  padding    : 20px 22px 0;
}

.greeting {
  font-family   : 'DM Serif Display', Georgia, serif;
  font-size     : 26px;
  font-weight   : 400;
  color         : var(--text);
  letter-spacing: -0.4px;
  line-height   : 1.15;
}

.date-label {
  font-size : 13px;
  color     : var(--text2);
  margin-top: 2px;
}

/* ─── Ring card ──────────────────────────────────────────────── */
.ring-card {
  flex-shrink    : 0;
  margin         : 16px 14px 0;
  background     : var(--surface);
  backdrop-filter: blur(28px) saturate(1.7);
  -webkit-backdrop-filter: blur(28px) saturate(1.7);
  border         : 1px solid var(--border);
  border-radius  : var(--radius);
  box-shadow     : var(--shadow-lg);
  padding        : 22px 22px 20px;
  display        : flex;
  align-items    : center;
  gap            : 20px;
}

.ring-wrapper { position: relative; width: 110px; height: 110px; flex-shrink: 0; }
.ring-wrapper canvas { display: block; }

.ring-center {
  position       : absolute;
  inset          : 0;
  display        : flex;
  flex-direction : column;
  align-items    : center;
  justify-content: center;
  pointer-events : none;
}

.ring-pct {
  font-family   : 'DM Serif Display', serif;
  font-size     : 28px;
  color         : var(--accent);
  line-height   : 1;
  letter-spacing: -1px;
}

.ring-label { font-size: 9px; color: var(--text3); margin-top: 2px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; }

.ring-meta { flex: 1; }
.ring-title    { font-size: 17px; font-weight: 600; color: var(--text); letter-spacing: -.3px; }
.ring-subtitle { font-size: 12.5px; color: var(--text2); margin-top: 3px; line-height: 1.4; }
.ring-done-text {
  display      : inline-block;
  margin-top   : 10px;
  font-size    : 11.5px;
  font-weight  : 500;
  color        : var(--accent);
  background   : var(--accent-bg);
  padding      : 4px 10px;
  border-radius: 100px;
}

/* ─── Scrollable content area ───────────────────────────────── */
.scroll-container {
  flex                   : 1;
  overflow-y             : auto;
  -webkit-overflow-scrolling: touch;   /* ← momentum scroll on iOS */
  overscroll-behavior-y  : contain;
  padding-bottom         : calc(var(--safe-bottom) + 24px);
}

/* ─── Category header ────────────────────────────────────────── */
.category-header {
  display    : flex;
  align-items: center;
  gap        : 8px;
  padding    : 22px 18px 8px;
}

.cat-icon { font-size: 16px; line-height: 1; }

.cat-name {
  flex       : 1;
  font-size  : 11.5px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color      : var(--text2);
}

.cat-pill {
  font-size    : 11px;
  font-weight  : 600;
  padding      : 3px 9px;
  border-radius: 100px;
}

/* ─── Habit group ────────────────────────────────────────────── */
.habit-group {
  display       : flex;
  flex-direction: column;
  gap           : 7px;
  padding       : 0 14px;
}

/* ─── Habit row ──────────────────────────────────────────────── */
.habit-item {
  display        : flex;
  align-items    : center;
  gap            : 12px;
  background     : var(--surface);
  backdrop-filter: blur(16px) saturate(1.4);
  -webkit-backdrop-filter: blur(16px) saturate(1.4);
  border         : 1px solid var(--border);
  border-radius  : var(--radius-sm);
  padding        : 13px 14px;
  box-shadow     : 0 2px 8px rgba(0,0,0,0.045);
  cursor         : pointer;
  user-select    : none;
  -webkit-tap-highlight-color: transparent;
  transition     : transform .16s ease, background .22s ease, box-shadow .16s ease;
  animation      : slideIn .38s ease both;
}

.habit-item:active { transform: scale(0.972); box-shadow: 0 1px 3px rgba(0,0,0,0.05); }

.habit-item.done {
  background  : rgba(79,70,229,0.06);
  border-color: rgba(79,70,229,0.18);
}
.habit-item.done .habit-label {
  color          : var(--text3);
  text-decoration: line-through;
  text-decoration-color: var(--accent-light);
}

/* Checkbox */
.habit-check {
  width        : 26px;
  height       : 26px;
  border-radius: 7px;
  border       : 1.5px solid var(--border2);
  background   : rgba(255,255,255,0.85);
  display      : flex;
  align-items  : center;
  justify-content: center;
  flex-shrink  : 0;
  cursor       : pointer;
  color        : white;
  transition   : all .22s cubic-bezier(.34,1.56,.64,1);
  -webkit-tap-highlight-color: transparent;
}
.habit-check.checked { transform: scale(1.06); }
.habit-check:active  { transform: scale(0.86); }

.habit-emoji { font-size: 20px; line-height: 1; flex-shrink: 0; }

.habit-label {
  flex      : 1;
  font-size : 14px;
  font-weight: 600;
  color     : var(--text);
  letter-spacing: .02em;
  transition: color .2s ease;
}

.habit-badge {
  font-size    : 11px;
  font-weight  : 600;
  padding      : 3px 8px;
  border-radius: 100px;
  flex-shrink  : 0;
}

/* ─── Weekly chart card ──────────────────────────────────────── */
.chart-card {
  margin         : 6px 14px 0;
  background     : var(--surface);
  backdrop-filter: blur(24px) saturate(1.6);
  -webkit-backdrop-filter: blur(24px) saturate(1.6);
  border         : 1px solid var(--border);
  border-radius  : var(--radius);
  box-shadow     : var(--shadow);
  padding        : 20px 18px 18px;
}

.chart-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 16px; }
.chart-title  { font-size: 15px; font-weight: 600; color: var(--text); }
.chart-sub    { font-size: 11.5px; color: var(--text3); margin-top: 2px; }
.chart-avg    { font-family: 'DM Serif Display', serif; font-size: 22px; color: var(--accent); text-align: right; line-height: 1; }
.chart-avg-label { font-size: 10px; color: var(--text3); text-align: right; margin-top: 2px; }
.chart-wrapper { height: 130px; position: relative; }

/* ─── Complete banner ────────────────────────────────────────── */
.complete-banner {
  position     : fixed;
  top          : calc(var(--safe-top) + 10px);
  left         : 50%;
  transform    : translateX(-50%);
  z-index      : 100;
  background   : #1E1B4B;
  color        : white;
  padding      : 12px 22px;
  border-radius: 100px;
  font-size    : 13.5px;
  font-weight  : 500;
  box-shadow   : 0 8px 32px rgba(79,70,229,.45);
  white-space  : nowrap;
  display      : flex;
  align-items  : center;
  gap          : 8px;
  animation    : bannerIn .4s cubic-bezier(.34,1.56,.64,1) both;
}
.complete-banner.hidden { display: none; }

/* ─── Animations ─────────────────────────────────────────────── */
@keyframes slideIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes bannerIn {
  from { opacity: 0; transform: translateX(-50%) translateY(-14px) scale(.9); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }
}

/* ─── Scrollbar ──────────────────────────────────────────────── */
::-webkit-scrollbar { width: 0; }

/* ─── Utility ────────────────────────────────────────────────── */
.hidden { display: none !important; }

/* ─── Older iOS safe area fallback ──────────────────────────── */
@supports (padding-top: constant(safe-area-inset-top)) {
  .app-shell { padding-top: constant(safe-area-inset-top); }
}
