/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #f8f9fa;
  --surface: #ffffff;
  --text: #212529;
  --text-muted: #6c757d;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --accent: #10b981;
  --border: #dee2e6;
  --radius: 10px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.08);
  --shadow-md: 0 4px 12px rgba(0,0,0,.1);
  --max-width: 960px;
}

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ===== NAV ===== */
.site-nav {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 1rem;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}

.site-nav__inner {
  max-width: var(--max-width);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.site-nav__brand {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text);
}

.site-nav__links {
  display: flex;
  gap: 0.25rem;
  list-style: none;
  flex-wrap: wrap;
}

.site-nav__links a {
  padding: 0.4rem 0.65rem;
  border-radius: 6px;
  font-size: 0.875rem;
  color: var(--text-muted);
  transition: background .15s, color .15s;
}

.site-nav__links a:hover,
.site-nav__links a.active {
  background: #eef2ff;
  color: var(--primary);
  text-decoration: none;
}

/* ===== MAIN LAYOUT ===== */
.main-content {
  flex: 1;
  max-width: var(--max-width);
  width: 100%;
  margin: 0 auto;
  padding: 2rem 1rem 3rem;
}

/* ===== HERO (homepage) ===== */
.hero {
  text-align: center;
  padding: 2.5rem 1rem 1.5rem;
}

.hero h1 { font-size: 1.85rem; font-weight: 700; margin-bottom: 0.5rem; }
.hero p { color: var(--text-muted); font-size: 1.05rem; max-width: 540px; margin: 0 auto; }

/* ===== CATEGORY SECTION ===== */
.category-section { margin-bottom: 2.5rem; }
.category-section h2 {
  font-size: 1.2rem;
  font-weight: 600;
  margin-bottom: 1rem;
  padding-bottom: 0.4rem;
  border-bottom: 2px solid var(--primary);
  display: inline-block;
}

/* ===== TOOL GRID ===== */
.tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
}

.tool-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  transition: box-shadow .2s, transform .2s;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.tool-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
  text-decoration: none;
}

.tool-card__icon { font-size: 1.5rem; margin-bottom: 0.25rem; }
.tool-card__title { font-weight: 600; color: var(--text); font-size: 1rem; }
.tool-card__desc { font-size: 0.82rem; color: var(--text-muted); line-height: 1.45; }

/* ===== TOOL PAGE ===== */
.tool-page-header { margin-bottom: 1.75rem; }
.tool-page-header h1 { font-size: 1.6rem; font-weight: 700; margin-bottom: 0.35rem; }

.tool-container {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.75rem;
  box-shadow: var(--shadow-sm);
  margin-bottom: 2rem;
}

.form-group { margin-bottom: 1.25rem; }
.form-group label {
  display: block;
  font-weight: 600;
  font-size: 0.875rem;
  margin-bottom: 0.3rem;
}

.form-group input,
.form-group select {
  width: 100%;
  padding: 0.7rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 1rem;
  transition: border-color .15s;
}

.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 0.8rem 1.75rem;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
  min-height: 48px; /* touch-friendly */
}

.btn-primary:hover { background: var(--primary-hover); }

.result-box {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 8px;
  padding: 1.25rem;
  margin-top: 1.5rem;
  display: none;
}

.result-box.visible { display: block; }
.result-box h3 { font-size: 0.9rem; color: var(--text-muted); margin-bottom: 0.75rem; text-transform: uppercase; letter-spacing: .04em; }
.result-value { font-size: 1.75rem; font-weight: 700; color: #15803d; }
.result-details { margin-top: 0.75rem; font-size: 0.9rem; color: var(--text-muted); }
.result-details dt { font-weight: 600; color: var(--text); float: left; clear: left; margin-right: 0.35rem; }
.result-details dd { margin-bottom: 0.3rem; }

/* ===== SEO TEXT ===== */
.seo-text {
  max-width: 700px;
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.7;
}
.seo-text h2 { font-size: 1.1rem; color: var(--text); margin: 1.5rem 0 0.5rem; }
.seo-text p { margin-bottom: 0.75rem; }

/* ===== AD PLACEHOLDERS ===== */
.ad-slot {
  background: #f1f3f5;
  border: 1px dashed #ced4da;
  border-radius: 8px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.75rem;
  padding: 1.5rem;
  margin: 1.5rem 0;
}

/* ===== FOOTER ===== */
.site-footer {
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 1.5rem 1rem;
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: auto;
}

.site-footer a { color: var(--text-muted); }
.site-footer a:hover { color: var(--primary); }

/* ===== WORD SCRAMBLE SPECIFIC ===== */
.scramble-word {
  font-size: 2.5rem;
  font-weight: 700;
  letter-spacing: 0.35rem;
  text-align: center;
  margin: 1rem 0;
  color: var(--primary);
  user-select: none;
}

.scramble-input {
  width: 100%;
  padding: 0.8rem;
  font-size: 1.2rem;
  text-align: center;
  border: 2px solid var(--border);
  border-radius: 8px;
  transition: border-color .15s;
}

.scramble-input:focus {
  outline: none;
  border-color: var(--primary);
}

.scramble-feedback {
  text-align: center;
  font-weight: 600;
  min-height: 1.5rem;
  margin: 0.75rem 0;
}

.scramble-score {
  display: flex;
  justify-content: center;
  gap: 2rem;
  font-size: 0.95rem;
  margin-bottom: 1rem;
}

.scramble-btns {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 1rem;
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  color: var(--primary);
  border: 1px solid var(--primary);
  border-radius: 8px;
  padding: 0.7rem 1.4rem;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
  min-height: 48px;
}

.btn-secondary:hover { background: #eef2ff; }

/* ===== RESPONSIVE ===== */
@media (max-width: 600px) {
  .site-nav__links { font-size: 0.8rem; }
  .site-nav__links a { padding: 0.3rem 0.45rem; }
  .hero h1 { font-size: 1.45rem; }
  .tool-grid { grid-template-columns: 1fr 1fr; }
  .tool-container { padding: 1.25rem; }
  .scramble-word { font-size: 2rem; }
}

@media (max-width: 380px) {
  .tool-grid { grid-template-columns: 1fr; }
}