/* Family Hub - Shared Styles */
@import url('https://fonts.googleapis.com/css2?family=DM+Serif+Display:ital@0;1&family=DM+Sans:wght@300;400;500;600&display=swap');

:root {
  --bg: #0f0f14;
  --surface: #17171f;
  --surface2: #1f1f2a;
  --surface3: #262633;
  --border: rgba(255,255,255,0.07);
  --primary: #7c6af7;
  --primary-glow: rgba(124,106,247,0.2);
  --accent: #f7c06a;
  --accent2: #6af7c4;
  --danger: #f76a6a;
  --text: #e8e8f0;
  --text-muted: rgba(232,232,240,0.45);
  --text-dim: rgba(232,232,240,0.25);
  --radius: 14px;
  --radius-sm: 8px;
  --shadow: 0 4px 24px rgba(0,0,0,0.4);
  --transition: 0.2s ease;
  --nav-height: 64px;
}

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

html { font-size: 16px; -webkit-text-size-adjust: 100%; }

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
  overflow-x: hidden;
}

/* Noise texture overlay */
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='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.04'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 0;
  opacity: 0.6;
}

/* ─── TYPOGRAPHY ─────────────────────────────── */
h1, h2, h3 { font-family: 'DM Serif Display', serif; line-height: 1.2; }
h1 { font-size: clamp(1.8rem, 5vw, 2.8rem); }
h2 { font-size: clamp(1.3rem, 3vw, 1.8rem); }
h3 { font-size: 1.1rem; }
p { color: var(--text-muted); line-height: 1.65; }
a { color: var(--primary); text-decoration: none; }

/* ─── LAYOUT ─────────────────────────────────── */
.app-container {
  position: relative;
  z-index: 1;
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 20px;
}

.page-header {
  padding: calc(var(--nav-height) + 32px) 0 24px;
}

/* ─── NAV ────────────────────────────────────── */
.nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--nav-height);
  background: rgba(15,15,20,0.85);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  z-index: 100;
  display: flex;
  align-items: center;
  padding: 0 20px;
}

.nav-inner {
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.nav-brand {
  font-family: 'DM Serif Display', serif;
  font-size: 1.25rem;
  color: var(--text);
  text-decoration: none;
  margin-right: auto;
}

.nav-brand span { color: var(--primary); }

.nav-link {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 0.88rem;
  font-weight: 500;
  transition: var(--transition);
  cursor: pointer;
  border: none;
  background: none;
  font-family: 'DM Sans', sans-serif;
}

.nav-link:hover, .nav-link.active {
  color: var(--text);
  background: var(--surface2);
}

.nav-link.active { color: var(--primary); }

.nav-user {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: 8px;
  padding-left: 12px;
  border-left: 1px solid var(--border);
}

.nav-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--primary-glow);
  border: 2px solid var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--primary);
  flex-shrink: 0;
}

.nav-name {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
  display: none;
}

@media (min-width: 600px) { .nav-name { display: block; } }

/* ─── CARDS ──────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.card-sm { padding: 14px 16px; }

/* ─── BUTTONS ────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.9rem;
  font-weight: 500;
  border: none;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}

.btn-primary {
  background: var(--primary);
  color: white;
}
.btn-primary:hover { background: #6b59e8; box-shadow: 0 0 20px var(--primary-glow); }

.btn-secondary {
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--surface3); }

.btn-danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid rgba(247,106,106,0.3);
}
.btn-danger:hover { background: rgba(247,106,106,0.1); }

.btn-accent {
  background: var(--accent);
  color: #1a1008;
  font-weight: 600;
}
.btn-accent:hover { background: #e8ae55; }

.btn-sm { padding: 6px 12px; font-size: 0.82rem; }
.btn-lg { padding: 13px 28px; font-size: 1rem; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ─── FORMS ──────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-label { font-size: 0.82rem; font-weight: 500; color: var(--text-muted); letter-spacing: 0.03em; text-transform: uppercase; }

.form-control {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 10px 14px;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.95rem;
  transition: var(--transition);
  width: 100%;
}
.form-control:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-glow); }
.form-control::placeholder { color: var(--text-dim); }

select.form-control { cursor: pointer; }

/* ─── BADGES ─────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.badge-daily { background: rgba(106,247,196,0.15); color: var(--accent2); }
.badge-weekly { background: rgba(124,106,247,0.15); color: var(--primary); }
.badge-monthly { background: rgba(247,192,106,0.15); color: var(--accent); }
.badge-oneoff { background: rgba(247,106,106,0.15); color: var(--danger); }
.badge-admin { background: rgba(247,192,106,0.15); color: var(--accent); }

/* ─── GRID LAYOUTS ───────────────────────────── */
.grid-2 { display: grid; grid-template-columns: 1fr; gap: 16px; }
@media (min-width: 640px) { .grid-2 { grid-template-columns: 1fr 1fr; } }

.grid-3 { display: grid; grid-template-columns: 1fr; gap: 16px; }
@media (min-width: 640px) { .grid-3 { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 900px) { .grid-3 { grid-template-columns: repeat(3, 1fr); } }

/* ─── SECTION ────────────────────────────────── */
.section { margin-bottom: 32px; }
.section-title {
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.section-title::after { content: ''; flex: 1; height: 1px; background: var(--border); }

/* ─── MODAL ──────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  visibility: hidden;
  transition: var(--transition);
}
.modal-overlay.open { opacity: 1; visibility: visible; }

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  transform: translateY(10px);
  transition: var(--transition);
}
.modal-overlay.open .modal { transform: translateY(0); }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 22px;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.4rem;
  cursor: pointer;
  line-height: 1;
  padding: 4px;
}
.modal-close:hover { color: var(--text); }

.modal-body { display: flex; flex-direction: column; gap: 16px; }

/* ─── TOAST ──────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 18px;
  font-size: 0.88rem;
  color: var(--text);
  box-shadow: var(--shadow);
  animation: toastIn 0.3s ease forwards;
  pointer-events: all;
  max-width: 300px;
}
.toast.success { border-color: var(--accent2); }
.toast.error { border-color: var(--danger); }

@keyframes toastIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ─── EMPTY STATE ────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-muted);
}
.empty-icon { font-size: 2.5rem; margin-bottom: 12px; opacity: 0.5; }

/* ─── SCOREBOARD ─────────────────────────────── */
.score-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--surface2);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}
.score-rank {
  font-family: 'DM Serif Display', serif;
  font-size: 1.1rem;
  color: var(--text-dim);
  width: 24px;
  text-align: center;
  flex-shrink: 0;
}
.score-rank.gold { color: #ffd700; }
.score-rank.silver { color: #c0c0c0; }
.score-rank.bronze { color: #cd7f32; }

.score-bar-wrap { flex: 1; }
.score-label { font-size: 0.85rem; font-weight: 500; margin-bottom: 4px; }
.score-bar-bg { background: var(--surface3); border-radius: 999px; height: 6px; overflow: hidden; }
.score-bar-fill { height: 100%; border-radius: 999px; background: var(--primary); transition: width 1s ease; }
.score-pct { font-size: 0.85rem; font-weight: 600; color: var(--accent); flex-shrink: 0; }

/* ─── PAGE FADE ──────────────────────────────── */
.page-fade { animation: fadeIn 0.35s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

/* ─── UTILS ──────────────────────────────────── */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.gap-6 { gap: 24px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.w-full { width: 100%; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-sm { font-size: 0.85rem; }
.text-muted { color: var(--text-muted); }
.font-serif { font-family: 'DM Serif Display', serif; }
.hidden { display: none !important; }

/* ─── LIGHT MODE ────────────────────────────── */
body.light-mode {
  --bg: #f5f5f8;
  --surface: #ffffff;
  --surface2: #f0f0f5;
  --surface3: #e5e5ee;
  --border: rgba(0,0,0,0.08);
  --primary-glow: rgba(124,106,247,0.12);
  --text: #1a1a2e;
  --text-muted: rgba(26,26,46,0.55);
  --text-dim: rgba(26,26,46,0.3);
  --shadow: 0 4px 24px rgba(0,0,0,0.06);
}

body.light-mode::before { opacity: 0; }
body.light-mode .nav { background: rgba(245,245,248,0.85); }
body.light-mode .kb-key.absent { background: #d3d6da !important; color: #787c7e; }
body.light-mode .guess-mini-cell.absent { background: #787c7e; }

/* Nav links wrapper (desktop) */
.nav-links {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Burger button - hidden on desktop */
.nav-burger {
  display: none;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: var(--text);
  cursor: pointer;
  padding: 8px;
  margin-left: auto;
  -webkit-tap-highlight-color: transparent;
}

/* ─── MOBILE DRAWER ─────────────────────────── */
.mobile-drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
  z-index: 150;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}
.mobile-drawer-overlay.open { opacity: 1; visibility: visible; }

.mobile-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 280px;
  max-width: 80vw;
  background: var(--surface);
  border-left: 1px solid var(--border);
  z-index: 151;
  transform: translateX(100%);
  transition: transform 0.3s ease;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}
.mobile-drawer.open { transform: translateX(0); }

.mobile-drawer-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px;
  border-bottom: 1px solid var(--border);
}

.mobile-drawer-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  margin-left: auto;
  display: flex;
  align-items: center;
}
.mobile-drawer-close:hover { color: var(--text); }

.mobile-drawer-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--primary-glow);
  border: 2px solid var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--primary);
  flex-shrink: 0;
}

.mobile-drawer-name { font-weight: 500; font-size: 0.95rem; }
.mobile-drawer-role { font-size: 0.75rem; color: var(--text-muted); }

.mobile-drawer-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  color: var(--text-muted);
  font-size: 0.95rem;
  font-weight: 500;
  text-decoration: none;
  transition: var(--transition);
  border: none;
  background: none;
  width: 100%;
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
  text-align: left;
}
.mobile-drawer-link:hover { background: var(--surface2); color: var(--text); }
.mobile-drawer-link.active { color: var(--primary); background: var(--primary-glow); }

.mobile-drawer-divider {
  height: 1px;
  background: var(--border);
  margin: 8px 0;
}

.mobile-drawer-footer {
  margin-top: auto;
  padding: 16px 20px;
  border-top: 1px solid var(--border);
}

/* ─── MOBILE NAV ────────────────────────────── */
@media (max-width: 600px) {
  .nav-burger { display: flex; }
  .nav-links { display: none; }
  .nav-brand { font-size: 1.1rem; }
}
