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

:root {
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --primary-light: rgba(59, 130, 246, 0.1);
  --bg: #ffffff;
  --fg: #161718;
  --muted: #6b7280;
  --muted-bg: #f9fafb;
  --border: #e5e7eb;
  --card-bg: #ffffff;
  --max-width: 1100px;
  --radius-outer: 16px;
  --radius-card: 12px;
  --radius-inner: 8px;
  --radius-sm: 6px;
  --radius-xs: 3px;
}

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

body {
  font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  color: var(--fg);
  background: var(--bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  line-height: 1.5;
  font-size: 16px;
}

a { color: inherit; }

/* --- Nav --- */
nav {
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 100;
}
.nav-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 1.5rem;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.nav-logo {
  font-weight: 700;
  font-size: 1.05rem;
  text-decoration: none;
  color: var(--fg);
}
.nav-links {
  display: flex;
  list-style: none;
  align-items: center;
  gap: 0;
}
.nav-links > li {
  display: flex;
  align-items: center;
}
.nav-links > li > a {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.9rem;
  padding: 0.3rem 0.75rem;
  border-radius: var(--radius-sm);
  transition: color 0.15s, background 0.15s;
  font-weight: 400;
  white-space: nowrap;
}
.nav-links > li > a:hover {
  color: var(--primary);
  background: var(--primary-light);
}
.nav-links > li > a[aria-current="page"] {
  color: var(--primary);
  background: var(--primary-light);
}
/* Hamburger dropdown */
.nav-hamburger { position: relative; }
.nav-hamburger::before { display: none; }
.hamburger-btn {
  background: none;
  border: 1px solid var(--border);
  cursor: pointer;
  font-size: 1.1rem;
  color: var(--muted);
  padding: 0.3rem 0.75rem;
  border-radius: var(--radius-xs);
  transition: color 0.15s, background 0.15s, border-color 0.15s;
  line-height: 1;
  display: flex;
  align-items: center;
  font-family: inherit;
}
.hamburger-btn:hover,
.hamburger-btn[aria-expanded="true"] {
  color: var(--primary);
  background: var(--primary-light);
  border-color: var(--primary);
}
.nav-hamburger:has(a[aria-current="page"]) .hamburger-btn {
  color: var(--primary);
  background: var(--primary-light);
  border-color: var(--primary);
}
.hamburger-dropdown {
  display: none;
  position: absolute;
  top: 100%;
  right: 0;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-inner);
  box-shadow: 0 4px 16px rgba(0,0,0,0.08);
  list-style: none;
  min-width: 160px;
  padding: 0.4rem 0;
  z-index: 200;
}
.hamburger-dropdown li a {
  display: block;
  padding: 0.5rem 1rem;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.9rem;
  transition: color 0.15s, background 0.15s;
  white-space: nowrap;
}
.hamburger-dropdown li a:hover {
  color: var(--primary);
  background: var(--primary-light);
}
.hamburger-dropdown li a[aria-current="page"] {
  color: var(--primary);
  background: var(--primary-light);
  font-weight: 600;
}
.nav-hamburger:hover .hamburger-dropdown,
.nav-hamburger.open .hamburger-dropdown {
  display: block;
}
/* Mobile nav: tool links hidden on small screens, moved into dropdown */
.mobile-tool { display: none; }
.mobile-divider {
  height: 1px;
  background: var(--border);
  margin: 0.25rem 0;
}

/* --- Container --- */
.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 1.5rem;
  width: 100%;
}

main { flex: 1; }

/* --- Ad placements --- */
.ad-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1.25rem 0;
}
.ad-label {
  font-size: 0.65rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 3px;
}
.ad-placeholder {
  background: #f3f4f6;
  border: 1px dashed var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #9ca3af;
  font-size: 0.75rem;
  max-width: 100%;
}
.ad-leaderboard { width: 728px; height: 90px; }
.ad-rectangle  { width: 300px; height: 250px; }

/* --- Home page layout --- */
.home-wrap { padding: 2.5rem 0 3rem; }

.home-grid {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 3rem;
  align-items: start;
}

/* --- Hero text --- */
.hero-text { margin-bottom: 2.5rem; }
.hero-text h1 {
  font-size: clamp(2.25rem, 5vw, 3.5rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 0.75rem;
  line-height: 1.1;
}
.hero-text p { font-size: 1.1rem; color: var(--muted); max-width: 36rem; }

/* --- Search form --- */
.form-row {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  margin-bottom: 0.75rem;
}
.form-group { display: flex; flex-direction: column; gap: 0.375rem; }
.form-group label { font-size: 0.875rem; font-weight: 500; }
.hint { font-size: 0.75rem; color: var(--muted); min-height: 1rem; }

.input-wrap { position: relative; }
.input-wrap .icon {
  position: absolute;
  right: 0.875rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
}

.input {
  width: 100%;
  height: 56px;
  padding: 0 3rem 0 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 1rem;
  color: var(--fg);
  background: var(--bg);
  transition: border-color 0.15s, box-shadow 0.15s;
  -webkit-appearance: none;
}
.input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}
.input::placeholder { color: #9ca3af; }

.input-num {
  width: 100px;
  height: 56px;
  padding: 0 0.75rem;
  text-align: center;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 1rem;
  color: var(--fg);
  background: var(--bg);
  transition: border-color 0.15s, box-shadow 0.15s;
  -webkit-appearance: none;
}
.input-num:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.gear-btn {
  height: 56px;
  width: 56px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  transition: border-color 0.15s, color 0.15s, background 0.15s;
  flex-shrink: 0;
  margin-top: 27px;
}
.gear-btn:hover { border-color: var(--primary); color: var(--primary); }
.gear-btn.active {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-light);
}

/* Advanced options */
.advanced-opts {
  display: none;
  margin-bottom: 0.75rem;
  padding: 1.25rem;
  background: var(--muted-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-inner);
  gap: 0.75rem;
}
.advanced-opts.open { display: grid; grid-template-columns: 1fr 1fr; }
.advanced-opts .form-group label { font-size: 0.8rem; }
.advanced-opts .input-sm {
  width: 100%;
  height: 42px;
  padding: 0 0.875rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.9rem;
  color: var(--fg);
  background: var(--bg);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.advanced-opts .input-sm:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.btn-find {
  width: 100%;
  height: 56px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 1.1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}
.btn-find:hover { background: var(--primary-hover); }
.btn-find:active { transform: scale(0.98); }
.btn-find:disabled { opacity: 0.6; cursor: not-allowed; }

.btn-row { display: flex; gap: 0.75rem; margin-top: 1rem; }
.btn-row .btn-find { flex: 1; width: auto !important; }
.btn-clear {
  height: 56px;
  padding: 0 1.5rem;
  border: 2px solid var(--primary);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--primary);
  font-family: inherit;
  font-size: 1.1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
  white-space: nowrap;
  flex-shrink: 0;
}
.btn-clear:hover { background: var(--primary-light); }

/* --- Results --- */
#results-section { display: none; margin-top: 2rem; }
.results-header {
  font-size: 1.2rem;
  font-weight: 600;
  margin-bottom: 1rem;
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
}
.results-count { font-size: 0.875rem; color: var(--muted); font-weight: 400; }

.results-group {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 1rem 1.25rem 1.25rem;
  margin-bottom: 1.5rem;
}
.results-group-heading {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--fg);
  padding-bottom: 0.75rem;
  margin-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
}
.results-group-count { font-weight: 400; color: var(--muted); }

.results-grid { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.word-chip {
  position: relative;
  padding: 0.35rem 0.875rem;
  background: var(--muted-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.word-chip:hover { background: var(--primary-light); border-color: var(--primary); color: var(--primary); }
.copy-tooltip {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: #1e293b;
  color: #fff;
  font-size: 0.72rem;
  font-weight: 500;
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-xs);
  white-space: nowrap;
  pointer-events: none;
  z-index: 10;
}
.copy-tooltip::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 4px solid transparent;
  border-top-color: #1e293b;
}
.results-msg { color: var(--muted); font-size: 0.95rem; padding: 0.5rem 0; }
.results-error { color: #ef4444; font-size: 0.95rem; padding: 0.5rem 0; }

/* --- In-results ad --- */
#ad-in-results {
  display: none;
  flex-direction: column;
  align-items: center;
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}
#ad-in-results.show { display: flex; }

/* --- Examples --- */
.examples {
  margin-top: 3rem;
  background: var(--muted-bg);
  border-radius: var(--radius-outer);
  padding: 2rem;
}
.examples h2 { font-size: 1.5rem; font-weight: 600; text-align: center; margin-bottom: 1.5rem; }
.examples-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}
.example-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 1.5rem;
  cursor: pointer;
  transition: box-shadow 0.15s, border-color 0.15s;
}
.example-card:hover {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}
.example-pattern {
  font-family: 'Courier New', Courier, monospace;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 0.375rem;
}
.example-desc { font-size: 0.875rem; color: var(--muted); }

/* --- Sidebar --- */
.sidebar { position: sticky; top: 1.5rem; }

/* --- Bottom ad row --- */
.bottom-ad-row { padding: 1.5rem 0 3rem; }

/* --- Content pages (How It Works, About, etc.) --- */
.content-page { padding: 5rem 0; }
.content-hero { text-align: center; margin-bottom: 4rem; }
.content-hero h1 {
  font-size: clamp(2rem, 4vw, 3rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 1rem;
  line-height: 1.15;
}
.content-hero p {
  font-size: 1.1rem;
  color: var(--muted);
  max-width: 42rem;
  margin: 0 auto;
  line-height: 1.65;
}
.content-body { max-width: 48rem; margin: 0 auto; }
.content-body h2 {
  font-size: 1.5rem;
  font-weight: 600;
  margin: 2.5rem 0 0.875rem;
  line-height: 1.25;
}
.content-body p { color: var(--muted); line-height: 1.7; margin-bottom: 1rem; font-size: 1rem; }
.content-body ul { margin: 0.5rem 0 1rem 1.25rem; }
.content-body li { color: var(--muted); line-height: 1.7; margin-bottom: 0.5rem; font-size: 1rem; }
.content-body strong { color: var(--fg); font-weight: 600; }
.content-body a { color: var(--primary); text-decoration: underline; }

/* Pattern examples box */
.pattern-box {
  background: var(--muted-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-outer);
  padding: 1.5rem;
  margin: 0.75rem 0 1.5rem;
}
.pattern-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 1rem; }
.pattern-item { display: flex; align-items: flex-start; gap: 1rem; }
.pattern-code {
  font-family: 'Courier New', Courier, monospace;
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--primary);
  background: var(--primary-light);
  padding: 0.25rem 0.625rem;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  flex-shrink: 0;
  margin-top: 2px;
}
.pattern-desc { font-size: 0.875rem; color: var(--muted); line-height: 1.55; padding-top: 2px; }

/* --- FAQ --- */
.faq-section {
  max-width: 48rem;
  margin: 5rem auto 0;
  padding-top: 4rem;
  border-top: 1px solid var(--border);
}
.faq-section h2 {
  font-size: 2rem;
  font-weight: 700;
  text-align: center;
  letter-spacing: -0.02em;
  margin-bottom: 2rem;
}
.faq-item { border-bottom: 1px solid var(--border); }
.faq-question {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.25rem 0;
  cursor: pointer;
  font-size: 1.05rem;
  font-weight: 500;
  gap: 1rem;
  background: none;
  border: none;
  width: 100%;
  text-align: left;
  font-family: inherit;
  color: var(--fg);
}
.faq-question svg { flex-shrink: 0; color: var(--muted); transition: transform 0.2s; }
.faq-item.open .faq-question svg { transform: rotate(180deg); }
.faq-answer {
  overflow: hidden;
  max-height: 0;
  transition: max-height 0.25s ease, padding 0.2s ease;
  font-size: 0.95rem;
  color: var(--muted);
  line-height: 1.7;
}
.faq-item.open .faq-answer { max-height: 500px; padding-bottom: 1.25rem; }

/* --- Contact page --- */
.contact-features {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.5rem;
  margin-bottom: 3rem;
  max-width: 48rem;
  margin-left: auto;
  margin-right: auto;
}
.contact-feature {
  background: var(--muted-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 1.5rem;
}
.contact-feature h3 { font-size: 1rem; font-weight: 600; margin-bottom: 0.5rem; }
.contact-feature p { font-size: 0.875rem; color: var(--muted); }

.email-block {
  max-width: 48rem;
  margin: 0 auto;
  text-align: center;
}
.email-block h2 { font-size: 1.5rem; font-weight: 600; margin-bottom: 1rem; }
.email-block p { color: var(--muted); margin-bottom: 1.5rem; }

.btn-email {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.875rem 2rem;
  background: var(--primary);
  color: white;
  border-radius: var(--radius-inner);
  text-decoration: none;
  font-weight: 600;
  font-size: 1rem;
  transition: background 0.15s;
}
.btn-email:hover { background: var(--primary-hover); color: white; }

.email-fallback { margin-top: 1.25rem; font-size: 0.9rem; color: var(--muted); }
.email-address { color: var(--fg); font-weight: 500; }
.antispam { display: none; }

/* --- Policy pages --- */
.policy-page { padding: 4rem 0; }
.policy-date { color: var(--muted); font-size: 0.9rem; text-align: center; margin-bottom: 3rem; }

/* --- Footer --- */
footer {
  border-top: 1px solid var(--border);
  padding: 2rem 0;
  margin-top: auto;
}
.footer-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}
.footer-brand { font-weight: 600; font-size: 0.9rem; text-decoration: none; color: var(--fg); }
.footer-links { display: flex; gap: 1.5rem; list-style: none; flex-wrap: wrap; }
.footer-links a { font-size: 0.8rem; color: var(--muted); text-decoration: none; transition: color 0.15s; }
.footer-links a:hover { color: var(--fg); }
.footer-copy { font-size: 0.8rem; color: var(--muted); }

/* --- Wordle Solver --- */
.pos-row {
  display: flex;
  gap: 0.625rem;
  margin-top: 0.375rem;
}
.pos-box {
  width: 56px;
  height: 56px;
  text-align: center;
  font-size: 1.35rem;
  font-weight: 700;
  text-transform: uppercase;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  color: var(--fg);
  background: var(--bg);
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
  -webkit-appearance: none;
}
.pos-box:focus {
  outline: none;
  border-color: #16a34a;
  box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.15);
}
.pos-box:not(:placeholder-shown) {
  background: #f0fdf4;
  border-color: #16a34a;
  color: #15803d;
}
.wordle-input-yellow:focus {
  border-color: #ca8a04;
  box-shadow: 0 0 0 3px rgba(202, 138, 4, 0.15);
}
.wordle-input-gray:focus {
  border-color: #6b7280;
  box-shadow: 0 0 0 3px rgba(107, 114, 128, 0.15);
}
.hint-inline {
  font-size: 0.8rem;
  font-weight: 400;
  color: var(--muted);
  margin-left: 0.25rem;
}
.wordle-example-chips {
  display: flex;
  gap: 0.35rem;
  margin-bottom: 0.5rem;
}
.wordle-chip-green,
.wordle-chip-yellow,
.wordle-chip-gray {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  border-radius: var(--radius-xs);
  color: white;
}
.wordle-chip-green  { background: #16a34a; }
.wordle-chip-yellow { background: #ca8a04; }
.wordle-chip-gray   { background: #6b7280; }

/* --- Responsive --- */
@media (max-width: 1024px) {
  .home-grid { grid-template-columns: 1fr; }
  .sidebar { display: none; }
}

@media (max-width: 768px) {
  /* Collapse 3 tool nav links into hamburger dropdown on phones/small tablets */
  /* Use .nav-links > li.nav-tool to beat .nav-links > li { display:flex } specificity */
  .nav-links > li.nav-tool { display: none; }
  .mobile-tool { display: block; }
  .form-row { flex-wrap: wrap; }
  .advanced-opts.open { grid-template-columns: 1fr; }
  .examples-grid { grid-template-columns: 1fr; }
  .contact-features { grid-template-columns: 1fr; }
  /* Make leaderboard fluid so it never causes horizontal scroll */
  .ad-leaderboard { width: 100%; height: auto; min-height: 50px; }
}

@media (max-width: 480px) {
  .footer-inner { flex-direction: column; text-align: center; }
  .footer-links { justify-content: center; }
  /* Scale Wordle pos-boxes down for narrow phones (375px has only ~7px margin at 56px) */
  .pos-box { width: 48px; height: 48px; font-size: 1.15rem; }
  .pos-row { gap: 0.5rem; }
  /* Stack Wordle yellow/gray fields vertically — labels are too long for side-by-side at 375px */
  #wordle-form .form-row .form-group { flex: 1 1 100%; }
}
