/* ===========================
   ClueDepot — styles.css
   Mobile-first design system
   =========================== */

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

:root {
  --primary: #4f46e5;
  --primary-dark: #3730a3;
  --primary-light: #eef2ff;
  --accent: #06b6d4;
  --text: #1e293b;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --bg: #ffffff;
  --bg-alt: #f8fafc;
  --bg-card: #ffffff;
  --success: #059669;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
  --shadow-lg: 0 10px 15px rgba(0,0,0,.07), 0 4px 6px rgba(0,0,0,.05);
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --mono: 'Menlo', 'Consolas', monospace;
  --max-w: 1100px;
  --transition: 0.18s ease;
}

html { scroll-behavior: smooth; }
body {
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
  font-size: 16px;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; height: auto; display: block; }
button { cursor: pointer; font-family: var(--font); }

/* --- Layout --- */
.container { max-width: var(--max-w); margin: 0 auto; padding: 0 16px; }
.section { padding: 48px 0; }
.section-alt { background: var(--bg-alt); }

/* --- Header / Nav --- */
.site-header {
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow);
}
.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
}
.site-logo {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: -0.5px;
  text-decoration: none;
}
.site-logo:hover { text-decoration: none; color: var(--primary-dark); }
.site-logo span { color: var(--accent); }

.nav-links {
  display: none;
  gap: 24px;
  list-style: none;
}
.nav-links a { color: var(--text-muted); font-size: 0.9rem; font-weight: 500; }
.nav-links a:hover { color: var(--primary); text-decoration: none; }

.nav-toggle {
  background: none;
  border: none;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.nav-toggle span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
  transition: var(--transition);
}

.mobile-nav {
  display: none;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding: 16px;
}
.mobile-nav.open { display: block; }
.mobile-nav a {
  display: block;
  padding: 10px 0;
  color: var(--text);
  border-bottom: 1px solid var(--border);
  font-weight: 500;
}
.mobile-nav a:last-child { border-bottom: none; }

@media (min-width: 768px) {
  .nav-links { display: flex; }
  .nav-toggle { display: none; }
}

/* --- Hero --- */
.hero {
  background: linear-gradient(135deg, #4f46e5 0%, #3730a3 50%, #1e1b4b 100%);
  color: white;
  padding: 64px 0 48px;
  text-align: center;
}
.hero h1 {
  font-size: clamp(1.75rem, 5vw, 2.75rem);
  font-weight: 800;
  line-height: 1.15;
  margin-bottom: 16px;
}
.hero p {
  font-size: clamp(1rem, 2.5vw, 1.2rem);
  opacity: 0.88;
  max-width: 600px;
  margin: 0 auto 32px;
}

/* Hero search */
.hero-search {
  max-width: 520px;
  margin: 0 auto;
  display: flex;
  gap: 0;
  background: white;
  border-radius: 100px;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
}
.hero-search input {
  flex: 1;
  border: none;
  padding: 14px 20px;
  font-size: 1rem;
  outline: none;
  color: var(--text);
  background: transparent;
}
.hero-search button {
  background: var(--primary);
  color: white;
  border: none;
  padding: 14px 24px;
  font-size: 0.95rem;
  font-weight: 600;
}

/* --- Cards --- */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow);
  transition: box-shadow var(--transition), transform var(--transition);
}
.card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}
.card-icon { font-size: 2rem; margin-bottom: 12px; }
.card-title { font-size: 1.05rem; font-weight: 700; margin-bottom: 6px; }
.card-desc { font-size: 0.9rem; color: var(--text-muted); line-height: 1.5; }
.card-link {
  display: inline-block;
  margin-top: 14px;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--primary);
}
.card-link:hover { text-decoration: underline; }

/* Tool card grid */
.tools-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 20px;
  margin-top: 24px;
}

/* --- Section headings --- */
.section-heading {
  font-size: clamp(1.25rem, 3vw, 1.6rem);
  font-weight: 800;
  margin-bottom: 8px;
}
.section-sub {
  color: var(--text-muted);
  margin-bottom: 8px;
  font-size: 0.95rem;
}

/* --- Tool Page Layout --- */
.tool-hero {
  background: var(--primary-light);
  border-bottom: 1px solid var(--border);
  padding: 32px 0 24px;
}
.tool-hero h1 {
  font-size: clamp(1.4rem, 4vw, 2rem);
  font-weight: 800;
  color: var(--primary);
  margin-bottom: 8px;
}
.tool-hero p {
  color: var(--text-muted);
  max-width: 640px;
  font-size: 0.95rem;
}

/* Tool UI box */
.tool-box {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  box-shadow: var(--shadow-md);
  margin: 28px 0;
}

/* Form elements */
.form-group { margin-bottom: 18px; }
.form-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}
.form-input, .form-select {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: 1rem;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  transition: border-color var(--transition);
  outline: none;
}
.form-input:focus, .form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79,70,229,.12);
}
.form-input.mono { font-family: var(--mono); letter-spacing: 1px; font-size: 1.1rem; }
.form-hint { font-size: 0.8rem; color: var(--text-muted); margin-top: 4px; }

/* Filters row */
.filters-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 11px 20px;
  border: none;
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-weight: 600;
  transition: background var(--transition), opacity var(--transition);
  text-decoration: none;
}
.btn:hover { text-decoration: none; opacity: 0.92; }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); opacity: 1; }
.btn-secondary { background: var(--bg-alt); color: var(--text); border: 1.5px solid var(--border); }
.btn-sm { padding: 7px 14px; font-size: 0.85rem; }

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 8px;
}

/* Results */
.results-area {
  margin-top: 24px;
}
.results-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}
.results-count {
  font-size: 0.9rem;
  color: var(--text-muted);
}
.results-count strong { color: var(--text); }

.results-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.word-pill {
  display: inline-block;
  background: var(--primary-light);
  color: var(--primary-dark);
  padding: 5px 12px;
  border-radius: 100px;
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: 0.5px;
  transition: background var(--transition);
}
.word-pill:hover { background: #e0e7ff; }

.results-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
.results-table th {
  text-align: left;
  padding: 10px 14px;
  background: var(--bg-alt);
  border-bottom: 2px solid var(--border);
  font-weight: 700;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
}
.results-table td {
  padding: 9px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}
.results-table tr:hover td { background: var(--bg-alt); }

/* Empty / loading states */
.state-msg {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
}
.state-msg .icon { font-size: 2.5rem; margin-bottom: 10px; }

.loading-bar {
  height: 3px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 16px;
  display: none;
}
.loading-bar.active { display: block; }
.loading-bar::after {
  content: '';
  display: block;
  height: 100%;
  width: 40%;
  background: var(--primary);
  border-radius: 3px;
  animation: slide 1s ease-in-out infinite;
}
@keyframes slide {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(300%); }
}

/* Length groups */
.length-group { margin-bottom: 28px; }
.length-group-title {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}

/* --- Breadcrumb --- */
.breadcrumb {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--text-muted);
  padding: 14px 0 0;
}
.breadcrumb a { color: var(--text-muted); }
.breadcrumb a:hover { color: var(--primary); }
.breadcrumb .sep { margin: 0 2px; }

/* --- How-to section --- */
.howto { margin: 32px 0; }
.howto h2 {
  font-size: 1.2rem;
  font-weight: 800;
  margin-bottom: 14px;
}
.howto ol, .howto ul {
  padding-left: 20px;
  color: var(--text-muted);
  line-height: 1.8;
}
.howto li { margin-bottom: 4px; }
.howto strong { color: var(--text); }

/* --- FAQ --- */
.faq { margin: 32px 0; }
.faq h2 {
  font-size: 1.2rem;
  font-weight: 800;
  margin-bottom: 16px;
}
.faq-item {
  border-bottom: 1px solid var(--border);
  padding: 14px 0;
}
.faq-item:last-child { border-bottom: none; }
.faq-question {
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  background: none;
  border: none;
  width: 100%;
  text-align: left;
  color: var(--text);
  padding: 0;
}
.faq-question::after {
  content: '+';
  font-size: 1.25rem;
  color: var(--primary);
  flex-shrink: 0;
  transition: transform var(--transition);
}
.faq-item.open .faq-question::after { content: '−'; }
.faq-answer {
  display: none;
  padding-top: 10px;
  color: var(--text-muted);
  font-size: 0.9rem;
  line-height: 1.7;
}
.faq-item.open .faq-answer { display: block; }

/* --- Related tools --- */
.related-tools { margin: 28px 0; }
.related-tools h2 { font-size: 1.1rem; font-weight: 800; margin-bottom: 14px; }
.related-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}
.related-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 500;
  transition: all var(--transition);
}
.related-link:hover {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary);
  text-decoration: none;
}
.related-link .emoji { font-size: 1.2rem; flex-shrink: 0; }

/* --- Ad slots --- */
.ad-slot {
  width: 100%;
  background: transparent;
  text-align: center;
  margin: 16px 0;
  border-radius: var(--radius);
  overflow: hidden;
}
.ad-slot:empty { display: none; }

/* --- Word list pages --- */
.word-list-hero {
  background: var(--primary-light);
  padding: 32px 0 20px;
  border-bottom: 1px solid var(--border);
}
.word-list-hero h1 {
  font-size: clamp(1.4rem, 4vw, 1.9rem);
  font-weight: 800;
  color: var(--primary);
  margin-bottom: 8px;
}
.word-list-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  margin-top: 18px;
}
.stat-box {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 20px;
  text-align: center;
}
.stat-box .num {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--primary);
}
.stat-box .lbl {
  font-size: 0.78rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.word-columns {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 6px;
  margin: 16px 0;
}
.word-columns span {
  font-size: 0.9rem;
  padding: 4px 8px;
  color: var(--text);
  border-radius: 4px;
}
.word-columns span:hover { background: var(--primary-light); color: var(--primary); }

/* --- Category pages --- */
.category-hero {
  background: linear-gradient(135deg, #4f46e5 0%, #2563eb 100%);
  color: white;
  padding: 40px 0 32px;
}
.category-hero h1 {
  font-size: clamp(1.5rem, 4vw, 2.2rem);
  font-weight: 800;
  margin-bottom: 10px;
}
.category-hero p { opacity: 0.9; max-width: 540px; }

/* --- Footer --- */
.site-footer {
  background: #1e293b;
  color: #94a3b8;
  padding: 48px 0 24px;
  margin-top: 64px;
}
.footer-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 32px;
  margin-bottom: 40px;
}
@media (min-width: 640px) {
  .footer-grid { grid-template-columns: 2fr 1fr 1fr; }
}
.footer-brand .logo {
  font-size: 1.2rem;
  font-weight: 800;
  color: white;
  margin-bottom: 10px;
}
.footer-brand .logo span { color: #06b6d4; }
.footer-brand p { font-size: 0.875rem; line-height: 1.6; }
.footer-col h4 {
  color: white;
  font-size: 0.875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 14px;
}
.footer-col ul { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.footer-col a {
  color: #94a3b8;
  font-size: 0.875rem;
  text-decoration: none;
  transition: color var(--transition);
}
.footer-col a:hover { color: white; }
.footer-bottom {
  border-top: 1px solid #334155;
  padding-top: 20px;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 10px;
  font-size: 0.8rem;
}
.footer-bottom a { color: #94a3b8; }
.footer-bottom a:hover { color: white; }

/* --- Homepage Why section --- */
.why-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 20px;
  margin-top: 24px;
}
.why-item {
  padding: 20px;
  background: var(--bg);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}
.why-icon { font-size: 1.8rem; margin-bottom: 10px; }
.why-title { font-weight: 700; margin-bottom: 6px; }
.why-desc { font-size: 0.875rem; color: var(--text-muted); }

/* --- Alphabet filter --- */
.alpha-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 16px 0;
}
.alpha-btn {
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition);
}
.alpha-btn:hover, .alpha-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}

/* --- Clipboard toast --- */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: #1e293b;
  color: white;
  padding: 10px 20px;
  border-radius: 100px;
  font-size: 0.875rem;
  font-weight: 600;
  z-index: 999;
  transition: transform 0.25s ease;
  pointer-events: none;
}
.toast.show { transform: translateX(-50%) translateY(0); }

/* --- Responsive tweaks --- */
@media (max-width: 480px) {
  .tool-box { padding: 18px; }
  .hero { padding: 40px 0 32px; }
  .btn-row { flex-direction: column; }
  .btn-row .btn { justify-content: center; }
}

/* --- Search results dropdown --- */
.search-results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: white;
  border: 1px solid var(--border);
  border-radius: 0 0 12px 12px;
  box-shadow: var(--shadow-lg);
  max-height: 280px;
  overflow-y: auto;
  z-index: 50;
  display: none;
}
.search-results.open { display: block; }
.search-result-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  color: var(--text);
  text-decoration: none;
  font-size: 0.9rem;
  border-bottom: 1px solid var(--border);
}
.search-result-item:last-child { border-bottom: none; }
.search-result-item:hover { background: var(--primary-light); color: var(--primary); }
.hero-search-wrap { position: relative; max-width: 520px; margin: 0 auto; }
.hero-search-wrap .hero-search { border-radius: 100px; }
.hero-search-wrap.focused .hero-search { border-radius: 20px 20px 0 0; }

/* Utility */
.text-center { text-align: center; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 16px; }
.hidden { display: none !important; }
.tag {
  display: inline-block;
  background: var(--primary-light);
  color: var(--primary);
  font-size: 0.75rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 100px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Scrabble helper colors */
.score-badge {
  display: inline-block;
  background: #fbbf24;
  color: #78350f;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 4px;
  margin-left: 6px;
}

/* Team picker */
.team-display {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-top: 20px;
}
.team-card {
  background: var(--bg-alt);
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
}
.team-card h3 {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.team-member {
  padding: 5px 0;
  font-size: 0.9rem;
  color: var(--text);
}

/* Word search grid */
.ws-grid {
  font-family: var(--mono);
  font-size: clamp(0.75rem, 2vw, 1rem);
  letter-spacing: 2px;
  line-height: 1.8;
  background: var(--bg-alt);
  padding: 20px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow-x: auto;
  white-space: pre;
}

/* Crossword grid */
.cw-grid { border-collapse: collapse; margin: 16px auto; }
.cw-grid td {
  width: 34px;
  height: 34px;
  border: 1.5px solid #334155;
  text-align: center;
  vertical-align: middle;
  font-size: 0.9rem;
  font-weight: 700;
  font-family: var(--mono);
  position: relative;
}
.cw-grid td.black { background: #1e293b; border-color: #1e293b; }
.cw-num {
  position: absolute;
  top: 1px;
  left: 2px;
  font-size: 0.55rem;
  font-weight: 600;
  color: var(--text-muted);
  font-family: var(--font);
}
