:root {
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-focus: rgba(37, 99, 235, 0.2);
    --pico-primary: #2563eb;
    --pico-primary-hover: #1d4ed8;
    --pico-primary-focus: rgba(37, 99, 235, 0.25);
    --pico-primary-inverse: #ffffff;
}

html,
body {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
}

.container,
.container-fluid {
    width: 100%;
    max-width: none !important;
    margin-left: 0;
    margin-right: 0;
    padding-left: 0.75rem;
    padding-right: 0.75rem;
    box-sizing: border-box;
}

.container > article,
.container-fluid > article,
.container > section,
.container-fluid > section {
    width: 100%;
    max-width: none;
}

.logo-img {
    height: 200px;
    width: auto;
    vertical-align: middle;
}

.flag {
    font-family:
        "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol",
        "Noto Color Emoji", "Android Emoji", "EmojiOne Mozilla", sans-serif;
    font-style: normal;
    font-weight: normal;
    line-height: 1;
    display: inline-block;
    margin-inline-end: 0.25em;
}

html[dir="rtl"] body {
    direction: rtl;
    text-align: right;
}

.help-text {
    font-size: 0.875rem;
    color: var(--muted-color);
}

label {
    font-weight: 600;
}

.results-table {
    margin-top: 2rem;
}

.results-table th {
    background: var(--primary);
    color: white;
}

.results-table td {
    font-family: monospace;
    font-size: 1.1rem;
}

.points {
    font-weight: bold;
    color: var(--primary);
}

.count-badge {
    background: var(--primary);
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 1rem;
    font-size: 0.875rem;
}

.error {
    background: #fee2e2;
    border: 1px solid #ef4444;
    color: #991b1b;
    padding: 1rem;
    border-radius: 0.5rem;
    margin: 1rem 0;
}

.tool-form:has(.pattern-input:not(:placeholder-shown)) .validation-error,
.tool-form:has(.letters-input:not(:placeholder-shown)) .validation-error {
    display: none;
}

.empty {
    text-align: center;
    padding: 3rem;
    color: var(--muted-color);
}

.language-list {
    list-style: none;
    padding: 0;
    margin: 1rem 0;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid var(--muted-border-color);
    border-radius: 0.5rem;
    padding: 0.5rem;
    background: var(--card-background-color);
}

.language-list li {
    margin: 0;
}

.language-list a {
    display: flex;
    align-items: center;
    padding: 0.5rem 0.75rem;
    text-decoration: none;
    border-radius: 0.25rem;
    transition: background-color 0.2s;
    width: 100%;
    box-sizing: border-box;
}

.language-list a:hover {
    background: var(--primary-focus);
}

.language-list a.primary {
    background: var(--primary);
    color: white;
}

.language-list a.primary:hover {
    background: var(--primary-hover);
}

.language-list .flag {
    margin-inline-end: 0.75rem;
    font-size: 1.25rem;
    flex-shrink: 0;
}

.pattern-input {
    font-family: monospace;
    font-size: 1.5rem;
    letter-spacing: 0.5rem;
    text-transform: uppercase;
}

.letters-input {
    font-family: monospace;
    font-size: 1.5rem;
    letter-spacing: 0.25rem;
    text-transform: uppercase;
}

/* Homepage specific styles */
.hero {
    text-align: center;
    padding: 0.65rem 1rem;
    background: linear-gradient(135deg, #2563eb 0%, #0ea5e9 100%);
    color: white;
    border-radius: 0.65rem;
    border: 1px solid rgba(14, 165, 233, 0.35);
    box-shadow: 0 10px 28px rgba(2, 132, 199, 0.2);
    margin: 0.35rem 0.35rem 2rem;
}

.hero-compact {
    padding: 0.25rem 1rem;
    margin-bottom: 0.5rem;
}

.hero-compact p {
    margin: 0.1rem 0;
    font-size: 0.85rem;
}

.hero h1 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
}

.hero p {
    font-size: 1.1rem;
    opacity: 0.9;
    margin: 0.5rem 0;
}

.tool-card {
    padding: 1.5rem;
    border-radius: 0.5rem;
    background: var(--card-background-color);
    border: 1px solid var(--muted-border-color);
    transition:
        transform 0.2s,
        box-shadow 0.2s;
    cursor: pointer;
    text-decoration: none;
    color: inherit;
    display: block;
}

.tool-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    color: inherit;
}

.tool-card:hover [role="button"] {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.tool-card h3 {
    margin-bottom: 0.5rem;
    color: var(--primary);
}

.tool-card {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.tool-card p {
    flex-grow: 1;
}

.language-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 0.6rem;
    margin-top: 1rem;
}

.language-card {
    padding: 0.5rem 0.6rem;
    border-radius: 0.5rem;
    background: var(--card-background-color);
    border: 1px solid var(--muted-border-color);
    text-decoration: none !important;
    color: inherit;
    display: block;
    transition: transform 0.2s, box-shadow 0.2s;
    cursor: pointer;
}

.language-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    color: inherit;
}

.language-card:hover h4,
.language-card:hover .word-count {
    text-decoration: none;
}

.language-card h4 {
    margin: 0;
    line-height: 1.2;
    color: var(--primary);
    display: flex;
    align-items: center;
}

.word-count {
    font-size: 0.875rem;
    color: var(--muted-color);
    margin: 0.25rem 0 0;
}

.language-card.selected {
    border: 2px solid var(--primary);
    background: var(--primary-focus);
}

.hero-logo {
    display: block;
    max-width: min(96vw, 1520px);
    width: 100%;
    max-height: 560px;
    height: auto;
    object-fit: contain;
    margin: 0.4rem auto;
}

/* Results grouping by word length */
.results-container {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.length-group {
    margin-top: 1rem;
}

.length-header {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    background: var(--primary);
    color: white;
    font-weight: 600;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    margin-bottom: 1rem;
}

.length-title {
    font-size: 1.1rem;
}

.length-count {
    font-size: 0.875rem;
    opacity: 0.8;
    font-weight: normal;
}

.length-group .results-table {
    margin: 0;
    border: none;
}

.length-group .results-table th {
    background: transparent;
    color: var(--color);
    padding: 0.25rem 1rem;
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: bold;
    border: none;
}

.length-group .results-table td {
    padding: 0.5rem 1rem;
}

.length-group .results-table tbody tr:last-child td {
    border-bottom: none;
}

.site-nav {
    text-align: center;
    padding: 0.35rem 1rem;
    background: linear-gradient(135deg, #2563eb 0%, #0ea5e9 100%);
    color: white;
    border-radius: 0.65rem;
    border: 1px solid rgba(14, 165, 233, 0.35);
    box-shadow: 0 10px 28px rgba(2, 132, 199, 0.2);
    margin: 0.3rem 0 0.65rem;
}

.site-nav-tile {
    text-align: center;
    padding: 0.35rem 1rem;
    background: linear-gradient(135deg, #2563eb 0%, #0ea5e9 100%);
    color: white;
    border-radius: 0.65rem;
    border: 1px solid rgba(14, 165, 233, 0.35);
    box-shadow: 0 10px 28px rgba(2, 132, 199, 0.2);
    margin: 0.3rem 0 0.65rem;
}

.site-nav-brand {
    text-decoration: none;
    display: block;
    color: white;
}

.site-nav-tile .site-nav-brand {
    color: white;
}

.site-nav-brand-text {
    font-size: clamp(1.3rem, 2.7vw, 1.85rem);
    font-weight: 700;
    letter-spacing: 0.02em;
    color: white;
    margin-inline-start: 2px;
}

.site-nav-tile .site-nav-brand-text {
    color: white;
    font-size: clamp(1.3rem, 2.7vw, 1.85rem);
}

.site-nav-logo {
    display: block;
    height: clamp(112px, 16vw, 176px);
    width: auto;
    max-width: min(92vw, 840px);
}

.full-width-shell {
    width: 100%;
    max-width: none;
    margin-left: 0;
    margin-right: 0;
    padding-left: 0.75rem;
    padding-right: 0.75rem;
    box-sizing: border-box;
}

.breadcrumb-nav ul {
    flex-wrap: wrap;
    row-gap: 0.25rem;
}

.breadcrumb-nav li,
.breadcrumb-nav a {
    white-space: normal;
    overflow-wrap: anywhere;
}

.site-footer {
    text-align: center;
}

.compact-footer {
    margin-top: 2rem;
}

.home-footer {
    margin-top: 4rem;
    padding: 2rem;
    border-top: 1px solid var(--muted-border-color);
}

.footer-link-plain {
    text-decoration: none;
}

.hero-title {
    margin: 0;
    color: white;
    font-size: clamp(2.4rem, 7vw, 3.6rem);
}

.hero-compact .hero-title {
    margin-top: 0.5rem;
}

.languages-heading {
    margin-top: 2rem;
}

.results-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.col-word {
    width: 70%;
}

.col-points {
    width: 30%;
}

.results-note {
    text-align: center;
    margin-top: 1rem;
}

.results-footer-actions {
    margin-top: 2rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.results-footer-actions a[role="button"] {
    transition:
        transform 0.2s,
        box-shadow 0.2s,
        background-color 0.2s,
        color 0.2s,
        border-color 0.2s;
}

.results-footer-actions a[role="button"]:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.stats-page {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.stats-section {
    padding: 1rem;
}

.stats-kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.stats-kpi {
    border: 1px solid var(--muted-border-color);
    border-radius: 0.5rem;
    padding: 0.65rem 0.75rem;
    background: var(--card-background-color);
}

.stats-kpi span {
    display: block;
    font-size: 0.75rem;
    color: var(--muted-color);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.stats-kpi strong {
    display: block;
    margin-top: 0.15rem;
    font-size: 1.2rem;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

.stats-distribution-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 0.9rem;
}

.stats-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.stats-table {
    margin: 0;
    width: 100%;
    font-size: 0.92rem;
}

.stats-table th {
    white-space: nowrap;
}

.stats-table.compact td,
.stats-table.compact th {
    padding: 0.45rem 0.6rem;
}

.stats-all-table td:first-child,
.stats-all-table th:first-child {
    min-width: 180px;
}

@media (max-width: 768px) {
    .hero {
        padding: 0.55rem 0.75rem;
        margin: 0.3rem 0.3rem 1rem;
    }

    .hero-compact {
        padding: 0.25rem 0.75rem;
    }

    .hero-compact p {
        font-size: 0.8rem;
    }

    .site-nav-logo {
        height: clamp(100px, 22vw, 144px);
        max-width: min(92vw, 680px);
    }

    .site-nav {
        padding: 0.3rem 0.75rem;
        margin: 0.25rem 0 0.55rem;
    }

    .site-nav-tile {
        padding: 0.3rem 0.75rem;
        margin: 0.25rem 0 0.55rem;
    }

    .pattern-input,
    .letters-input {
        font-size: clamp(1rem, 4.8vw, 1.2rem);
        letter-spacing: 0.12rem;
    }

    .tool-card {
        padding: 1rem;
    }

    .language-grid {
        grid-template-columns: 1fr;
        gap: 0.75rem;
        margin-top: 1rem;
    }

    .results-table td {
        font-size: 1rem;
    }

    .stats-section {
        padding: 0.75rem;
    }

    .stats-kpi-grid {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 480px) {
    .site-nav {
        padding: 0.3rem 0.75rem;
    }

    .site-nav-logo {
        height: clamp(92px, 28vw, 128px);
        max-width: min(92vw, 600px);
    }

    .hero-logo {
        max-height: 340px;
    }

    .hero p {
        font-size: 0.95rem;
    }

    .results-footer-actions {
        flex-direction: column;
    }

    .results-footer-actions a[role="button"] {
        width: 100%;
        margin: 0;
    }

    .stats-kpi-grid {
        grid-template-columns: 1fr;
    }
}

@media (prefers-color-scheme: dark) {
    .tool-card h3 {
        color: white;
    }

    .tool-card p {
        color: white;
    }

    .hero {
        background: linear-gradient(135deg, #1d4ed8 0%, #0369a1 100%);
        border-color: rgba(56, 189, 248, 0.45);
        box-shadow: 0 10px 28px rgba(2, 132, 199, 0.35);
    }

    .site-nav-tile {
        background: linear-gradient(135deg, #1d4ed8 0%, #0369a1 100%);
        border-color: rgba(56, 189, 248, 0.45);
        box-shadow: 0 10px 28px rgba(2, 132, 199, 0.35);
    }

    .site-nav {
        background: linear-gradient(135deg, #1d4ed8 0%, #0369a1 100%);
        border-color: rgba(56, 189, 248, 0.45);
        box-shadow: 0 10px 28px rgba(2, 132, 199, 0.35);
    }
}
