/*
 * Shared Base CSS for Multi-Language Wordle
 * Common styles used across all language versions
 */

:root {
    /* Colors - Can be overridden by language-specific CSS */
    --bg-color: #121213;
    --tile-bg: #3a3a3c;
    --tile-border: #565758;
    --tile-correct: #538d4e;
    --tile-present: #b59f3b;
    --tile-absent: #3a3a3c;
    --text-color: #ffffff;
    --text-secondary: #818384;
    --card-bg: #1a1a1b;
    --error-color: #e74c3c;
    --success-color: #538d4e;

    /* Sizing */
    --tile-size: 62px;
    --tile-gap: 5px;
    --tile-font-size: 2rem;
    --container-max-width: 540px;
    --spacing-sm: 8px;
    --spacing-md: 16px;
    --spacing-lg: 24px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Clear Sans', 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.container {
    width: 100%;
    max-width: var(--container-max-width);
    padding: 0;
    padding-top: 52px;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 100vh;
}

/* Navbar */
.navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    padding: 0 16px;
    height: 52px;
    border-bottom: 1px solid var(--tile-border);
    background: var(--bg-color);
    z-index: 100;
}

.nav-left,
.nav-right {
    display: flex;
    gap: 8px;
    flex: 1;
}

.nav-right {
    justify-content: flex-end;
}

.nav-center {
    flex: 0 0 auto;
    text-align: center;
}

.navbar h1 {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: 0.05rem;
    margin: 0;
}

.icon-btn {
    background: none;
    border: none;
    color: var(--text-color);
    font-size: 1.25rem;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
}

.icon-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Main Content */
main {
    width: 100%;
    padding: var(--spacing-md);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--spacing-md);
    flex: 1;
}

/* Sentence Card */
.sentence-card {
    background: transparent;
    border-radius: 12px;
    padding: var(--spacing-sm) var(--spacing-md);
    width: 100%;
    text-align: center;
    border: none;
}

.sentence {
    font-size: 1.25rem;
    margin-bottom: 4px;
    /* tightened spacing below sentence */
    line-height: 1.6;
}

.hint {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* If the hint immediately follows the sentence, make their gap small */
.sentence+.hint {
    margin-top: 4px;
    display: block;
}

/* Error Message */
.error-message {
    background: rgba(231, 76, 60, 0.2);
    border: 1px solid var(--error-color);
    color: var(--error-color);
    padding: var(--spacing-sm) var(--spacing-md);
    border-radius: 8px;
    width: 100%;
    text-align: center;
    font-size: 0.9rem;
}

/* Guess Grid */
.guesses-container {
    display: flex;
    flex-direction: column;
    gap: var(--tile-gap);
    width: 100%;
    max-width: calc(var(--tile-size) * 7 + var(--tile-gap) * 6);
}

.guess-row {
    display: flex;
    justify-content: center;
    gap: var(--tile-gap);
}

.tile {
    width: var(--tile-size);
    height: var(--tile-size);
    border: 2px solid var(--tile-border);
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: var(--tile-font-size);
    font-weight: 700;
    text-transform: uppercase;
    border-radius: 4px;
    transition: all 0.1s ease;
}

.tile.empty {
    background: transparent;
}

.tile.correct {
    background: var(--tile-correct);
    border-color: var(--tile-correct);
}

.tile.present {
    background: var(--tile-present);
    border-color: var(--tile-present);
}

.tile.absent {
    background: var(--tile-absent);
    border-color: var(--tile-absent);
}

/* Game Result */
.game-result {
    background: var(--card-bg);
    border-radius: 12px;
    padding: var(--spacing-lg);
    width: 100%;
    text-align: center;
    border: 1px solid var(--tile-border);
}

.game-result.win h2 {
    color: var(--success-color);
}

.game-result.lose h2 {
    color: var(--error-color);
}

.answer-reveal {
    margin-top: var(--spacing-lg);
    padding-top: var(--spacing-lg);
    border-top: 1px solid var(--tile-border);
}

.answer-word {
    font-size: 2.5rem;
    font-weight: 700;
    margin: var(--spacing-md) 0;
}

.pronunciation {
    color: var(--text-secondary);
    font-size: 1rem;
    margin-bottom: var(--spacing-sm);
}

.example {
    font-size: 1.1rem;
    color: var(--text-secondary);
    font-style: italic;
}

/* Input Form */
.guess-form {
    width: 100%;
}

.input-group {
    display: flex;
    gap: var(--spacing-sm);
    width: 100%;
}

.guess-input {
    flex: 1;
    padding: var(--spacing-md);
    font-size: 1.25rem;
    background: var(--card-bg);
    border: 2px solid var(--tile-border);
    border-radius: 8px;
    color: var(--text-color);
    outline: none;
}

.guess-input:focus {
    border-color: var(--text-color);
}

.guess-input::placeholder {
    color: var(--text-secondary);
}

/* Buttons */
.btn {
    padding: var(--spacing-md) var(--spacing-lg);
    font-size: 1rem;
    font-weight: 600;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-submit {
    background: var(--tile-correct);
    color: white;
}

.btn-submit:hover {
    background: #4a7d44;
}

.btn-share {
    background: var(--tile-correct);
    color: white;
    margin-top: var(--spacing-md);
}

.share-section {
    margin-top: var(--spacing-lg);
}

.next-puzzle-info {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-top: var(--spacing-md);
}

/* Keyboard */
.keyboard {
    width: 100%;
    max-width: 500px;
    margin-top: var(--spacing-md);
}

.keyboard-row {
    display: flex;
    justify-content: center;
    gap: 6px;
    margin-bottom: 8px;
}

.keyboard-row-bottom {
    gap: 12px;
}

.key {
    min-width: 30px;
    height: 50px;
    padding: 0 8px;
    font-size: 1.1rem;
    font-weight: 600;
    background: var(--tile-bg);
    border: none;
    border-radius: 4px;
    color: var(--text-color);
    cursor: pointer;
    transition: all 0.1s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.key:active {
    transform: scale(0.95);
}

.key-wide {
    min-width: 65px;
    font-size: 0.75rem;
}

.key.correct {
    background: var(--tile-correct);
}

.key.present {
    background: var(--tile-present);
}

.key.absent {
    background: #1a1a1b;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    z-index: 200;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.modal.show {
    display: flex;
}

.modal-content {
    background: var(--card-bg);
    border-radius: 16px;
    max-width: 480px;
    width: 100%;
    max-height: 85vh;
    overflow-y: auto;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.modal-header h2 {
    margin: 0;
}

.close-btn {
    background: none;
    border: none;
    color: var(--text-color);
    font-size: 1.75rem;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: background 0.2s;
    line-height: 1;
}

.close-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

.modal-body {
    padding: 24px;
}

.modal-section {
    margin-top: 20px;
}

.modal-section h3 {
    margin-bottom: 12px;
    font-size: 1.1rem;
}

.modal-section ul {
    padding-left: 24px;
}

.modal-section li {
    margin-bottom: 10px;
    line-height: 1.5;
}

.modal-description {
    line-height: 1.6;
    margin-bottom: 8px;
}

.example-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 14px;
}

.tile-example {
    width: 42px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    font-weight: 700;
    border-radius: 4px;
    flex-shrink: 0;
    border: 2px solid rgba(255, 255, 255, 0.1);
}

.tile-example.correct {
    background: var(--tile-correct);
}

.tile-example.present {
    background: var(--tile-present);
}

.tile-example.absent {
    background: var(--tile-absent);
}

.example-text {
    flex: 1;
}

.example-text strong {
    display: block;
    margin-bottom: 2px;
}

.example-text p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin: 0;
}

.note-small {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: var(--spacing-sm);
}

/* Footer */
footer {
    padding: var(--spacing-md);
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.75rem;
    /* slightly smaller */
    opacity: 0.95;
}

/* Responsive */
@media (max-width: 480px) {
    :root {
        --tile-size: 48px;
        --tile-font-size: 1.5rem;
        --spacing-md: 12px;
        --spacing-lg: 16px;
    }

    /* Reduce sentence card padding on mobile */
    .sentence-card {
        padding: 4px 0;
        margin-bottom: 8px;
    }

    .sentence {
        font-size: 1.1rem;
    }

    /* Optimize guesses container spacing */
    .guesses-container {
        gap: 4px;
        margin-bottom: 16px;
        /* More space before input */
    }

    .guess-row {
        gap: 4px;
    }

    /* Make input and button stack on very small screens */
    .input-group {
        flex-direction: row;
        gap: 8px;
        margin-bottom: 8px;
        /* Less space before keyboard */
    }

    .guess-input {
        padding: 12px;
        font-size: 1.1rem;
        min-width: 0;
        /* Allow input to shrink */
    }

    .btn-submit {
        padding: 12px 16px;
        font-size: 0.95rem;
        white-space: nowrap;
        flex-shrink: 0;
    }

    /* Keyboard sizing and spacing for mobile */
    .keyboard {
        padding: 0 4px;
        /* Add small horizontal padding */
        margin-top: 0;
        /* Remove extra top margin */
    }

    .key {
        min-width: 30px;
        height: 54px;
        font-size: 1.15rem;
        padding: 0 5px;
    }

    .key-wide {
        min-width: 58px;
        font-size: 0.75rem;
    }

    .keyboard-row {
        gap: 3.5px;
        margin-bottom: 5px;
    }

    .keyboard-row-bottom {
        gap: 7px;
    }

    /* Modal responsive adjustments */
    .modal {
        padding: 12px;
    }

    .modal-content {
        max-height: 90vh;
        border-radius: 12px;
    }

    .modal-header {
        padding: 16px 20px;
    }

    .modal-header h2 {
        font-size: 1.3rem;
    }

    .modal-body {
        padding: 20px;
    }

    .modal-section h3 {
        font-size: 1rem;
    }

    .tile-example {
        width: 38px;
        height: 38px;
        font-size: 1.2rem;
    }

    .example-row {
        gap: 10px;
        margin-bottom: 12px;
    }

    .example-text {
        font-size: 0.95rem;
    }
}

/* Extra small screens - stack input and button */
@media (max-width: 360px) {
    :root {
        --tile-size: 44px;
        --tile-font-size: 1.4rem;
    }

    .sentence-card {
        padding: 2px 0;
    }

    .sentence {
        font-size: 1rem;
    }

    /* Stack input and button vertically on very small screens */
    .input-group {
        flex-direction: column;
        gap: 8px;
        margin-bottom: 8px;
    }

    .btn-submit {
        width: 100%;
        padding: 14px;
    }

    /* Keyboard optimization for very small screens */
    .keyboard {
        padding: 0 2px;
    }

    .key {
        min-width: 27px;
        height: 52px;
        font-size: 1.1rem;
        padding: 0 3px;
    }

    .key-wide {
        min-width: 54px;
        font-size: 0.72rem;
    }

    .keyboard-row {
        gap: 2.5px;
        margin-bottom: 4px;
    }

    .keyboard-row-bottom {
        gap: 5px;
    }

    /* Extra compact modal for very small screens */
    .modal {
        padding: 8px;
    }

    .modal-content {
        border-radius: 10px;
        max-height: 92vh;
    }

    .modal-header {
        padding: 14px 16px;
    }

    .modal-header h2 {
        font-size: 1.2rem;
    }

    .modal-body {
        padding: 16px;
    }

    .modal-section {
        margin-top: 16px;
    }

    .modal-section h3 {
        font-size: 0.95rem;
        margin-bottom: 10px;
    }

    .modal-section li {
        margin-bottom: 8px;
        font-size: 0.9rem;
    }

    .tile-example {
        width: 36px;
        height: 36px;
        font-size: 1.1rem;
    }

    .example-row {
        gap: 8px;
        margin-bottom: 10px;
    }

    .example-text {
        font-size: 0.9rem;
    }

    .example-text strong {
        font-size: 0.9rem;
    }

    .example-text p {
        font-size: 0.85rem;
    }
}

/* Toast notifications */
.toast {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    background: #ffffff;
    color: #121213;
    padding: 16px 28px;
    border-radius: 10px;
    font-weight: 600;
    font-size: 0.95rem;
    z-index: 1000;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
    pointer-events: none;
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

@keyframes toastOut {
    from {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }

    to {
        opacity: 0;
        transform: translateX(-50%) translateY(20px);
    }
}