/* ============================================
   GRAMMARLY.SITE — Global Stylesheet
   Mobile-first, SEO-optimised, Ad-ready
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;700;800;900&family=Lora:ital,wght@0,400;0,600;1,400&display=swap');

:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #eff6ff;
  --accent: #f59e0b;
  --accent-light: #fffbeb;
  --success: #10b981;
  --danger: #ef4444;
  --ink: #1e293b;
  --body: #475569;
  --muted: #94a3b8;
  --border: #e2e8f0;
  --bg: #f8fafc;
  --card: #ffffff;
  --nav-h: 64px;
  --radius: 14px;
  --shadow-sm: 0 1px 4px rgba(0,0,0,.06);
  --shadow: 0 4px 20px rgba(0,0,0,.08);
  --shadow-lg: 0 12px 40px rgba(0,0,0,.12);
}

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

html { scroll-behavior: smooth; font-size: 16px; }

body {
  font-family: 'Nunito', sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; display: block; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── NAVBAR ── */
.navbar {
  position: sticky; top: 0; z-index: 200;
  background: #fff;
  border-bottom: 1px solid #ebebeb;
  height: var(--nav-h);
  display: flex; align-items: center;
  padding: 0 24px;
}
.nav-inner {
  max-width: 1100px; width: 100%; margin: 0 auto;
  display: flex; align-items: center; gap: 2px;
}
.nav-logo {
  font-size: 1.05rem; font-weight: 800;
  color: #171717; text-decoration: none;
  display: flex; align-items: center; gap: 8px;
  white-space: nowrap; margin-right: 16px; flex-shrink: 0;
  letter-spacing: -0.3px;
}
.nav-logo span { color: var(--primary); }
.nav-logo-icon { width: 28px; height: 28px; flex-shrink: 0; display: block; }

/* Desktop nav links */
.nav-links {
  display: flex; gap: 2px; align-items: center;
  list-style: none; flex: 1;
}
.nav-links > li { position: relative; }
.nav-links a {
  display: flex; align-items: center; gap: 4px;
  padding: 8px 12px;
  border-radius: 9999px;
  font-size: 14px; font-weight: 500; letter-spacing: -0.2px;
  color: #4d4d4d; white-space: nowrap;
  transition: background .15s, color .15s;
  text-decoration: none;
}
.nav-links a:hover, .nav-links a.active {
  background: #f5f5f5; color: #171717; text-decoration: none;
}

/* Topics dropdown trigger */
.nav-dropdown-btn {
  display: flex; align-items: center; gap: 5px;
  padding: 8px 12px;
  border-radius: 9999px;
  font-size: 14px; font-weight: 500; letter-spacing: -0.2px;
  color: #4d4d4d;
  background: none; border: none; cursor: pointer;
  transition: background .15s, color .15s; white-space: nowrap;
  font-family: inherit;
}
.nav-dropdown-btn:hover, .nav-dropdown-btn.open {
  background: #f5f5f5; color: #171717;
}
.nav-dropdown-btn svg { transition: transform .2s; flex-shrink: 0; }
.nav-dropdown-btn.open svg { transform: rotate(180deg); }

/* Dropdown panel */
.nav-dropdown {
  position: absolute; top: calc(100% + 6px); left: 0;
  min-width: 196px;
  background: #fff;
  border: 1px solid #ebebeb;
  border-radius: 12px;
  box-shadow: 0px 2px 2px rgba(0,0,0,.06), 0px 8px 16px -4px rgba(0,0,0,.08);
  padding: 6px;
  z-index: 300;
  opacity: 0; pointer-events: none;
  transform: translateY(-4px);
  transition: opacity .15s, transform .15s;
}
.nav-dropdown.open {
  opacity: 1; pointer-events: auto; transform: translateY(0);
}
.nav-dropdown a {
  display: block; padding: 8px 12px;
  border-radius: 8px;
  font-size: 14px; font-weight: 400; letter-spacing: -0.2px;
  color: #4d4d4d; white-space: nowrap;
}
.nav-dropdown a:hover { background: #f5f5f5; color: #171717; text-decoration: none; }

/* Hamburger button */
.nav-menu-btn {
  display: none;
  margin-left: auto; flex-shrink: 0;
  background: none; border: 1px solid #ebebeb;
  border-radius: 8px;
  width: 36px; height: 36px;
  cursor: pointer; color: #171717;
  align-items: center; justify-content: center;
}
.nav-menu-btn svg { display: block; }

/* Mobile overlay */
.nav-overlay {
  display: none;
  position: fixed; top: var(--nav-h); left: 0; right: 0; bottom: 0;
  background: #fff; z-index: 190;
  padding: 8px 16px 32px;
  overflow-y: auto;
  border-top: 1px solid #ebebeb;
}
.nav-overlay.open { display: block; }
.nav-overlay-links { list-style: none; display: flex; flex-direction: column; gap: 1px; }
.nav-overlay-section {
  font-size: 11px; font-weight: 500; letter-spacing: 0.07em;
  text-transform: uppercase; color: #888;
  padding: 18px 12px 6px; font-family: ui-monospace, monospace;
}
.nav-overlay-links a {
  display: block; padding: 11px 12px;
  border-radius: 8px; font-size: 15px; font-weight: 500;
  color: #4d4d4d; text-decoration: none;
}
.nav-overlay-links a:hover { background: #f5f5f5; color: #171717; }

@media (max-width: 760px) {
  .nav-links { display: none; }
  .nav-menu-btn { display: flex; }
}

/* ── AD PLACEHOLDER (will become real AdSense later) ── */
.ad-slot {
  background: linear-gradient(135deg, #f1f5f9, #e2e8f0);
  border: 1.5px dashed #cbd5e1;
  border-radius: var(--radius);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 0.3rem;
  color: var(--muted); font-size: 0.72rem; font-weight: 600;
  letter-spacing: 0.06em; text-transform: uppercase;
  min-height: 90px; width: 100%;
  margin: 1.2rem 0;
  position: relative; overflow: hidden;
}
.ad-slot::before {
  content: ''; position: absolute; inset: 0;
  background: repeating-linear-gradient(45deg, transparent, transparent 10px, rgba(0,0,0,.02) 10px, rgba(0,0,0,.02) 11px);
}
.ad-slot-label { font-size: 0.65rem; opacity: .6; }
.ad-banner { min-height: 90px; }
.ad-square { min-height: 250px; max-width: 300px; }
.ad-leaderboard { min-height: 90px; }

/* ── HERO ── */
.hero {
  background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 60%, #0ea5e9 100%);
  color: #fff; text-align: center;
  padding: 3rem 1.2rem 4rem;
  position: relative; overflow: hidden;
}
.hero::after {
  content: '';
  position: absolute; bottom: -2px; left: 0; right: 0; height: 40px;
  background: var(--bg);
  clip-path: ellipse(55% 100% at 50% 100%);
}
.hero-badge {
  display: inline-block;
  background: rgba(255,255,255,.15);
  border: 1px solid rgba(255,255,255,.3);
  border-radius: 99px; padding: 0.3rem 1rem;
  font-size: 0.75rem; font-weight: 700;
  letter-spacing: 0.08em; text-transform: uppercase;
  margin-bottom: 1rem;
}
.hero h1 {
  font-family: 'Lora', serif;
  font-size: clamp(1.8rem, 6vw, 3rem);
  font-weight: 600; line-height: 1.2;
  margin-bottom: 0.9rem;
}
.hero h1 strong { font-weight: 700; color: #fde68a; }
.hero p {
  font-size: clamp(0.95rem, 3vw, 1.1rem);
  opacity: .85; max-width: 540px; margin: 0 auto 1.8rem;
}
.hero-btns { display: flex; gap: 0.8rem; justify-content: center; flex-wrap: wrap; }
.btn {
  display: inline-flex; align-items: center; gap: 0.4rem;
  padding: 0.7rem 1.4rem; border-radius: 99px;
  font-family: 'Nunito', sans-serif; font-size: 0.9rem; font-weight: 800;
  border: none; cursor: pointer; transition: all .2s;
  text-decoration: none;
}
.btn-white { background: #fff; color: var(--primary); }
.btn-white:hover { background: #eff6ff; text-decoration: none; transform: translateY(-1px); }
.btn-outline { background: transparent; color: #fff; border: 2px solid rgba(255,255,255,.5); }
.btn-outline:hover { background: rgba(255,255,255,.1); text-decoration: none; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); text-decoration: none; transform: translateY(-1px); }
.btn-accent { background: var(--accent); color: #fff; }
.btn-accent:hover { background: #d97706; text-decoration: none; transform: translateY(-1px); }

/* ── LAYOUT ── */
.container { max-width: 1100px; margin: 0 auto; padding: 0 1.5rem; }
.page-body { padding: 2rem 0 3rem; }
@media (max-width: 480px) {
  .container { padding: 0 1rem; }
  .hero { padding: 2.5rem 1rem 3.5rem; }
  footer { padding: 2.5rem 1rem 1.5rem; }
  .navbar { padding: 0 1rem; }
}

.content-grid {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 2rem; align-items: start;
}
@media (max-width: 900px) {
  .content-grid { grid-template-columns: 1fr; }
  .sidebar { order: 2; }
}

/* ── CARDS ── */
.card {
  background: var(--card); border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.card-body { padding: 1.3rem; }
.card:hover { box-shadow: var(--shadow); }

/* ── SECTION HEADERS ── */
.section-hd {
  display: flex; align-items: center; gap: 0.6rem;
  font-size: 1.25rem; font-weight: 900;
  color: var(--ink); margin-bottom: 1.1rem;
}
.section-hd .icon {
  width: 36px; height: 36px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem; flex-shrink: 0;
}

/* ── RULE BLOCK ── */
.rule {
  background: var(--primary-light);
  border-left: 4px solid var(--primary);
  border-radius: 0 10px 10px 0;
  padding: 0.85rem 1rem;
  font-size: 0.9rem; line-height: 1.65;
  margin-bottom: 1rem;
}
.rule.amber { background: var(--accent-light); border-left-color: var(--accent); }
.rule.green { background: #ecfdf5; border-left-color: var(--success); }
.rule.red { background: #fef2f2; border-left-color: var(--danger); }
.rule strong { font-weight: 800; color: var(--ink); }

/* ── EXAMPLES ── */
.example-row {
  display: flex; gap: 0.55rem; align-items: flex-start;
  margin: 0.45rem 0; font-size: 0.88rem;
}
.badge {
  display: inline-flex; align-items: center;
  padding: 2px 9px; border-radius: 99px;
  font-size: 0.68rem; font-weight: 800;
  white-space: nowrap; flex-shrink: 0; margin-top: 2px;
}
.badge-right { background: #d1fae5; color: #065f46; }
.badge-wrong { background: #fee2e2; color: #991b1b; }
.badge-eg { background: #dbeafe; color: #1e40af; }
.badge-tip { background: #fef3c7; color: #92400e; }
.badge-daily { background: #f3e8ff; color: #6b21a8; }
.ex-text { line-height: 1.55; color: var(--body); }
.ex-text em { color: var(--muted); font-size: 0.82rem; }
.ex-text strong { color: var(--primary-dark); font-weight: 800; }

/* ── TABLES ── */
.tbl-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); margin: 1rem 0; }
table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
thead th {
  background: var(--ink); color: #fff;
  padding: 0.7rem 1rem; text-align: left;
  font-weight: 800; font-size: 0.8rem; letter-spacing: .04em;
}
tbody td { padding: 0.65rem 1rem; border-bottom: 1px solid var(--border); vertical-align: top; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:nth-child(even) td { background: #f8fafc; }
code { background: #f1f5f9; color: var(--primary-dark); padding: 1px 5px; border-radius: 4px; font-size: .82rem; }

/* ── TOPIC CARDS (index page) ── */
.topics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(155px, 1fr));
  gap: 0.8rem; margin: 1.5rem 0;
}
.topic-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.1rem 1rem;
  text-align: center; transition: all .2s;
  text-decoration: none; color: var(--ink);
  display: flex; flex-direction: column; align-items: center; gap: 0.5rem;
}
.topic-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); text-decoration: none; border-color: var(--primary); }
.topic-card .tc-icon { font-size: 1.8rem; }
.topic-card .tc-title { font-size: 0.88rem; font-weight: 800; color: var(--ink); }
.topic-card .tc-count { font-size: 0.72rem; color: var(--muted); font-weight: 600; }

/* ── QUIZ ── */
.quiz-q {
  background: var(--primary-light);
  border-radius: var(--radius); padding: 1.1rem;
  margin-bottom: 1rem;
}
.quiz-qnum { font-size: 0.72rem; font-weight: 800; color: var(--primary); letter-spacing: .06em; margin-bottom: .3rem; text-transform: uppercase; }
.quiz-qtext { font-size: 1rem; font-weight: 700; color: var(--ink); line-height: 1.5; }
.quiz-opts { display: flex; flex-direction: column; gap: 0.5rem; margin-top: 0.9rem; }
.quiz-opt {
  padding: 0.7rem 1rem;
  background: #fff; border: 1.5px solid var(--border);
  border-radius: 10px; cursor: pointer;
  font-family: 'Nunito', sans-serif; font-size: 0.88rem; font-weight: 600;
  text-align: left; transition: all .18s; color: var(--ink);
}
.quiz-opt:hover { border-color: var(--primary); background: var(--primary-light); }
.quiz-opt.correct { background: #d1fae5; border-color: var(--success); color: #065f46; }
.quiz-opt.wrong { background: #fee2e2; border-color: var(--danger); color: #991b1b; }
.quiz-feedback {
  font-size: 0.84rem; padding: 0.6rem 0.9rem;
  border-radius: 8px; margin-top: 0.6rem; display: none;
}
.quiz-feedback.show { display: block; }
.quiz-feedback.ok { background: #d1fae5; color: #065f46; }
.quiz-feedback.fail { background: #fee2e2; color: #991b1b; }
.quiz-next {
  display: none; margin-top: 0.8rem;
  padding: 0.65rem 1.3rem; background: var(--primary); color: #fff;
  border: none; border-radius: 99px; cursor: pointer;
  font-family: 'Nunito', sans-serif; font-size: 0.88rem; font-weight: 800;
  transition: background .18s;
}
.quiz-next.show { display: inline-block; }
.quiz-next:hover { background: var(--primary-dark); }
.progress-wrap { background: var(--border); border-radius: 99px; height: 6px; margin-bottom: 1rem; }
.progress-fill { background: var(--primary); height: 100%; border-radius: 99px; transition: width .3s; }
.score-pill {
  display: inline-flex; align-items: center; gap: 0.4rem;
  background: var(--primary-light); color: var(--primary);
  border-radius: 99px; padding: 4px 14px;
  font-size: 0.78rem; font-weight: 800; margin-bottom: 0.8rem;
}

/* ── SIDEBAR ── */
.sidebar-widget {
  background: var(--card); border-radius: var(--radius);
  border: 1px solid var(--border); overflow: hidden;
  margin-bottom: 1.2rem;
}
.widget-head {
  background: var(--ink); color: #fff;
  padding: 0.65rem 1rem;
  font-size: 0.78rem; font-weight: 800; letter-spacing: .06em;
  text-transform: uppercase;
}
.widget-body { padding: 1rem; }
.widget-link {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.5rem 0; border-bottom: 1px solid var(--border);
  font-size: 0.84rem; font-weight: 600; color: var(--body);
  text-decoration: none; transition: color .18s;
}
.widget-link:last-child { border-bottom: none; padding-bottom: 0; }
.widget-link:hover { color: var(--primary); text-decoration: none; }
.widget-link .wl-icon { font-size: 1rem; }

/* ── CHIPS ── */
.chips { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.8rem; }
.chip {
  padding: 3px 11px; border-radius: 99px; border: 1.5px solid;
  font-size: 0.72rem; font-weight: 700; letter-spacing: .02em;
}
.chip-blue { color: var(--primary); border-color: #bfdbfe; background: #eff6ff; }
.chip-amber { color: #92400e; border-color: #fcd34d; background: #fffbeb; }
.chip-green { color: #065f46; border-color: #6ee7b7; background: #ecfdf5; }
.chip-red { color: #991b1b; border-color: #fca5a5; background: #fef2f2; }

/* ── BREADCRUMB ── */
.breadcrumb {
  display: flex; align-items: center; gap: 0.4rem;
  font-size: 0.78rem; color: var(--muted); font-weight: 600;
  margin-bottom: 1.2rem; flex-wrap: wrap;
}
.breadcrumb a { color: var(--primary); text-decoration: none; }
.breadcrumb a:hover { text-decoration: underline; }
.breadcrumb-sep { color: var(--border); }

/* ── FOOTER ── */
footer {
  background: var(--ink); color: #94a3b8;
  padding: 2.5rem 1.2rem 1.5rem;
  margin-top: 3rem;
}
.footer-inner {
  max-width: 1100px; margin: 0 auto;
  display: grid; grid-template-columns: 2fr 1fr 1fr;
  gap: 2rem;
}
@media (max-width: 640px) {
  .footer-inner { grid-template-columns: 1fr; gap: 1.5rem; }
}
.footer-brand { font-size: 1.2rem; font-weight: 900; color: #fff; margin-bottom: 0.5rem; }
.footer-brand span { color: var(--accent); }
.footer-desc { font-size: 0.82rem; line-height: 1.7; max-width: 260px; }
.footer-col-title { font-size: 0.75rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: #fff; margin-bottom: 0.8rem; }
.footer-links { list-style: none; display: flex; flex-direction: column; gap: 0.5rem; }
.footer-links a { font-size: 0.83rem; color: #94a3b8; text-decoration: none; transition: color .18s; }
.footer-links a:hover { color: #fff; }
.footer-bottom { max-width: 1100px; margin: 2rem auto 0; padding-top: 1rem; border-top: 1px solid #334155; font-size: 0.75rem; text-align: center; }

/* ── TIP BOX ── */
.tip-box {
  background: #fffbeb; border: 1.5px solid #fcd34d;
  border-radius: var(--radius); padding: 1rem 1.1rem;
  font-size: 0.88rem; line-height: 1.65; margin: 1rem 0;
  display: flex; gap: 0.6rem; align-items: flex-start;
}
.tip-icon { font-size: 1.1rem; flex-shrink: 0; margin-top: 1px; }

/* ── DIVIDER ── */
hr.divider { border: none; border-top: 1px solid var(--border); margin: 1.2rem 0; }

/* ── SEARCH BAR (homepage) ── */
.search-wrap {
  max-width: 480px; margin: 1.5rem auto 0;
  display: flex; gap: 0; background: #fff;
  border-radius: 99px; overflow: hidden;
  box-shadow: 0 4px 24px rgba(0,0,0,.18);
}
.search-wrap input {
  flex: 1; border: none; outline: none;
  padding: 0.85rem 1.2rem; font-size: 0.95rem;
  font-family: 'Nunito', sans-serif;
  background: transparent; color: var(--ink);
}
.search-wrap button {
  background: var(--accent); border: none; cursor: pointer;
  padding: 0 1.3rem; font-size: 1.1rem; color: #fff;
  transition: background .18s;
}
.search-wrap button:hover { background: #d97706; }

/* ── SCROLL TO TOP ── */
#scrollTop {
  position: fixed; bottom: 1.5rem; right: 1.2rem;
  width: 42px; height: 42px; border-radius: 50%;
  background: var(--primary); color: #fff;
  border: none; cursor: pointer; font-size: 1.1rem;
  box-shadow: var(--shadow); display: none;
  align-items: center; justify-content: center;
  z-index: 90; transition: background .18s;
}
#scrollTop:hover { background: var(--primary-dark); }
#scrollTop.show { display: flex; }

/* ── UTILITIES ── */
.text-center { text-align: center; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.mt-2 { margin-top: 1rem; }
.fw-900 { font-weight: 900; }
.text-muted { color: var(--muted); }
.text-primary { color: var(--primary); }
