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

:root {
    --blue: #2563eb;
    --blue-light: #3b82f6;
    --blue-dark: #1d4ed8;
    --bg: #f8fafc;
    --white: #ffffff;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-500: #6b7280;
    --gray-700: #374151;
    --gray-900: #111827;
    --amber: #f59e0b;
    --amber-light: #fef3c7;
    --green: #10b981;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06);
}

body {
    font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--gray-900);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

a { color: var(--blue); text-decoration: none; }
a:hover { color: var(--blue-dark); text-decoration: underline; }

.container { max-width: 1100px; margin: 0 auto; padding: 0 16px; }

/* === Header === */
.site-header {
    background: var(--white);
    border-bottom: 2px solid var(--blue);
    padding: 12px 0;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow);
}
.header-inner { display: flex; align-items: center; justify-content: space-between; }
.site-logo { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--gray-900); }
.logo-icon { font-size: 1.5rem; }
.logo-text { font-size: 1.25rem; font-weight: 400; }
.logo-text strong { color: var(--blue); font-weight: 700; }
.main-nav { display: flex; gap: 20px; }
.main-nav a { color: var(--gray-700); font-size: 0.9rem; font-weight: 500; }
.main-nav a:hover { color: var(--blue); text-decoration: none; }

/* === Breadcrumbs === */
.breadcrumbs {
    background: var(--white);
    padding: 10px 0;
    border-bottom: 1px solid var(--gray-200);
    font-size: 0.85rem;
    color: var(--gray-500);
}
.breadcrumbs a { color: var(--gray-500); }
.breadcrumbs a:hover { color: var(--blue); }
.breadcrumbs span { margin: 0 4px; }

/* === Main Content === */
main { flex: 1; padding: 24px 0 48px; }

h1 { font-size: 1.8rem; font-weight: 700; color: var(--gray-900); margin-bottom: 8px; }
h2 { font-size: 1.3rem; font-weight: 600; color: var(--gray-900); margin: 24px 0 12px; }
h3 { font-size: 1.1rem; font-weight: 600; margin: 16px 0 8px; }

.subtitle { color: var(--gray-500); font-size: 1rem; margin-bottom: 24px; }

/* === Cards === */
.card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
    margin-bottom: 20px;
}

/* === Letter Grid (A-Z pills) === */
.letter-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 16px 0 24px;
}
.letter-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    border-radius: 999px;
    background: var(--blue);
    color: var(--white);
    font-weight: 700;
    font-size: 0.95rem;
    text-decoration: none;
    transition: background 0.15s, transform 0.1s;
}
.letter-pill:hover { background: var(--blue-dark); color: var(--white); text-decoration: none; transform: scale(1.08); }
.letter-pill.active { background: var(--blue-dark); box-shadow: 0 0 0 3px rgba(37,99,235,0.3); }

/* === Length Cards (homepage) === */
.length-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
    margin: 16px 0 24px;
}
.length-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 16px 12px;
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    text-decoration: none;
    color: var(--gray-900);
    transition: box-shadow 0.15s, transform 0.1s;
}
.length-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); text-decoration: none; color: var(--gray-900); }
.length-card .num { font-size: 1.6rem; font-weight: 700; color: var(--blue); }
.length-card .label { font-size: 0.85rem; color: var(--gray-500); }

/* === Word Grid === */
.word-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin: 16px 0;
}
.word-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: 6px;
    text-decoration: none;
    color: var(--gray-900);
    font-size: 0.9rem;
    font-weight: 500;
    transition: border-color 0.15s, background 0.15s;
}
.word-item:hover { border-color: var(--blue); background: #eff6ff; text-decoration: none; color: var(--gray-900); }
.word-item .len-badge {
    font-size: 0.7rem;
    font-weight: 600;
    background: var(--gray-100);
    color: var(--gray-500);
    padding: 2px 6px;
    border-radius: 999px;
    min-width: 20px;
    text-align: center;
}

/* === Stats grid === */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
    margin: 16px 0;
}
.stat-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: 6px;
    text-decoration: none;
    color: var(--gray-900);
}
.stat-item:hover { border-color: var(--blue); text-decoration: none; }
.stat-item .count { font-weight: 700; color: var(--blue); }

/* === Definition page === */
.def-header { margin-bottom: 24px; }
.def-word { font-size: 2.2rem; font-weight: 800; color: var(--blue); text-transform: uppercase; letter-spacing: 2px; }
.def-meta { display: flex; gap: 16px; margin-top: 8px; flex-wrap: wrap; }
.def-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 12px;
    border-radius: 999px;
    font-size: 0.85rem;
    font-weight: 600;
}
.def-badge.length { background: #dbeafe; color: #1e40af; }

.def-section { margin: 24px 0; }
.def-text { font-size: 1.05rem; line-height: 1.7; color: var(--gray-700); }

.letter-breakdown {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin: 12px 0;
}
.letter-tile {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 36px;
    height: 44px;
    background: #dbeafe;
    border: 2px solid var(--blue);
    border-radius: 4px;
    font-weight: 700;
    font-size: 1.1rem;
    text-transform: uppercase;
    line-height: 1;
    padding-top: 4px;
}
.letter-tile .tile-pts { font-size: 0.55rem; color: var(--blue-dark); }

.related-links { display: flex; gap: 12px; flex-wrap: wrap; margin: 12px 0; }
.related-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: var(--blue);
    color: var(--white);
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-weight: 500;
    text-decoration: none;
}
.related-link:hover { background: var(--blue-dark); color: var(--white); text-decoration: none; }

/* === SEO text === */
.seo-text { color: var(--gray-500); font-size: 0.95rem; line-height: 1.7; margin: 24px 0; }
.seo-text p { margin-bottom: 12px; }

/* === Search === */
.search-box {
    display: flex;
    gap: 8px;
    max-width: 500px;
    margin: 20px 0;
}
.search-box input {
    flex: 1;
    padding: 10px 16px;
    border: 2px solid var(--gray-200);
    border-radius: var(--radius);
    font-size: 1rem;
    outline: none;
    transition: border-color 0.15s;
}
.search-box input:focus { border-color: var(--blue); }
.search-box button {
    padding: 10px 20px;
    background: var(--blue);
    color: var(--white);
    border: none;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
}
.search-box button:hover { background: var(--blue-dark); }

/* === Hero === */
.hero {
    text-align: center;
    padding: 40px 0 32px;
}
.hero h1 { font-size: 2.2rem; margin-bottom: 12px; }
.hero .subtitle { font-size: 1.1rem; }
.hero .search-box { margin: 20px auto; }

/* === Footer === */
.site-footer {
    background: var(--gray-900);
    color: var(--gray-300);
    padding: 40px 0 20px;
    margin-top: auto;
}
.footer-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 24px; }
.footer-col h4 { color: var(--white); font-size: 0.95rem; margin-bottom: 12px; }
.footer-links { display: flex; flex-direction: column; gap: 6px; }
.footer-links a { color: var(--gray-300); font-size: 0.85rem; }
.footer-links a:hover { color: var(--white); }
.footer-text { font-size: 0.85rem; line-height: 1.6; margin-bottom: 8px; }
.footer-bottom { margin-top: 24px; padding-top: 16px; border-top: 1px solid var(--gray-700); text-align: center; font-size: 0.8rem; }

/* === 404 === */
.page-404 { text-align: center; padding: 80px 0; }
.page-404 .icon { font-size: 4rem; margin-bottom: 16px; }

/* === Responsive === */
@media (max-width: 768px) {
    .main-nav { display: none; }
    h1 { font-size: 1.4rem; }
    .hero h1 { font-size: 1.6rem; }
    .word-grid { grid-template-columns: repeat(2, 1fr); }
    .footer-grid { grid-template-columns: repeat(2, 1fr); }
    .length-cards { grid-template-columns: repeat(3, 1fr); }
    .letter-pill { width: 36px; height: 36px; font-size: 0.85rem; }
    .def-word { font-size: 1.6rem; }
}

@media (max-width: 480px) {
    .footer-grid { grid-template-columns: 1fr; }
    .length-cards { grid-template-columns: repeat(2, 1fr); }
}
