/**
 * Word Counter App Styles
 *
 * A production-ready word counter with accessible, responsive design
 */

/* ========================================
   App Page Layout
   ======================================== */

.app-page {
    padding: var(--space-4);
    padding-top: calc(var(--header-height) + var(--space-4));
    min-height: calc(100vh - var(--header-height));
    display: flex;
    flex-direction: column;
    align-items: center;
}

.app-container {
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
}

.app-header {
    text-align: center;
    margin-bottom: var(--space-6);
}

.app-header h1 {
    font-size: var(--font-size-2xl);
    margin-bottom: var(--space-2);
}

.app-description {
    color: var(--color-text-muted);
    font-size: var(--font-size-sm);
    margin-bottom: 0;
}

/* ========================================
   Word Counter
   ======================================== */

.word-counter {
    background: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-lg);
}

/* Text Input Area */
.wc-input-area {
    padding: var(--space-4);
    background: var(--color-bg-card);
}

.wc-textarea {
    width: 100%;
    min-height: 200px;
    padding: var(--space-4);
    font-size: var(--font-size-base);
    font-family: inherit;
    line-height: 1.6;
    color: var(--color-text);
    background: var(--color-bg-alt);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    resize: vertical;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.wc-textarea::placeholder {
    color: var(--color-text-muted);
}

.wc-textarea:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

/* Action Buttons */
.wc-actions {
    display: flex;
    gap: var(--space-3);
    margin-top: var(--space-4);
}

.wc-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-4);
    font-size: var(--font-size-sm);
    font-weight: 500;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: background var(--transition-fast), transform 0.1s ease;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.wc-btn:active {
    transform: scale(0.98);
}

.wc-btn:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
}

.wc-btn-secondary {
    background: var(--color-bg-alt);
    color: var(--color-text);
    border: 1px solid var(--color-border);
}

.wc-btn-secondary:hover {
    background: var(--color-border);
}

.wc-btn-primary {
    background: var(--color-primary);
    color: white;
    border: none;
}

.wc-btn-primary:hover {
    background: var(--color-primary-dark);
}

/* ========================================
   Statistics Section
   ======================================== */

.wc-stats {
    padding: var(--space-4);
    background: var(--color-bg-alt);
    border-top: 1px solid var(--color-border);
}

.wc-stats-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-4);
}

.wc-stats-title {
    font-size: var(--font-size-sm);
    font-weight: 600;
    color: var(--color-text);
    margin: 0;
}

/* Stats Grid */
.wc-stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-3);
}

.wc-stat-card {
    background: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: var(--space-4);
    text-align: center;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.wc-stat-card:hover {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 1px var(--color-primary);
}

.wc-stat-value {
    font-size: var(--font-size-2xl);
    font-weight: 700;
    font-family: var(--font-mono);
    color: var(--color-primary);
    line-height: 1.2;
    margin-bottom: var(--space-1);
}

.wc-stat-label {
    font-size: var(--font-size-xs);
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Reading time special styling */
.wc-stat-card.wc-stat-reading-time .wc-stat-value {
    color: var(--color-success-text, #047857);
}

/* Empty state */
.wc-stats-empty {
    text-align: center;
    padding: var(--space-6);
    color: var(--color-text-muted);
    font-size: var(--font-size-sm);
}

/* ========================================
   Accessibility Announcements
   ======================================== */

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ========================================
   Responsive Design
   ======================================== */

@media (max-width: 600px) {
    .app-page {
        padding: var(--space-2);
        padding-top: calc(var(--header-height) + var(--space-2));
    }

    .app-header {
        margin-bottom: var(--space-4);
    }

    .wc-textarea {
        min-height: 150px;
        font-size: var(--font-size-sm);
    }

    .wc-stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .wc-stat-value {
        font-size: var(--font-size-xl);
    }

    .wc-stat-label {
        font-size: 0.65rem;
    }
}

@media (max-width: 400px) {
    .wc-stats-grid {
        grid-template-columns: 1fr 1fr;
    }

    .wc-actions {
        flex-direction: column;
    }

    .wc-btn {
        width: 100%;
    }
}

/* ========================================
   Reduced Motion
   ======================================== */

@media (prefers-reduced-motion: reduce) {
    .wc-btn,
    .wc-textarea,
    .wc-stat-card {
        transition: none;
    }

    .wc-btn:active {
        transform: none;
    }
}

/* ========================================
   Help Panel (Modal)
   ======================================== */

.help-panel {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-4);
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.help-panel[hidden] {
    display: none;
}

.help-content {
    background: var(--color-bg-card);
    border-radius: var(--radius-lg);
    max-width: 500px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-xl);
}

.help-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-4) var(--space-6);
    border-bottom: 1px solid var(--color-border);
    position: sticky;
    top: 0;
    background: var(--color-bg-card);
}

.help-header h2 {
    font-size: var(--font-size-lg);
    margin: 0;
}

.help-close {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--font-size-xl);
    border-radius: var(--radius-md);
    color: var(--color-text-muted);
}

.help-close:hover {
    background: var(--color-bg-alt);
    color: var(--color-text);
}

.help-close:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
}

.help-body {
    padding: var(--space-6);
}

.help-section {
    margin-bottom: var(--space-6);
}

.help-section:last-child {
    margin-bottom: 0;
}

.help-section h3 {
    font-size: var(--font-size-base);
    margin-bottom: var(--space-4);
    color: var(--color-text);
}

.help-steps {
    margin: 0;
    padding-left: var(--space-5);
}

.help-steps li {
    margin-bottom: var(--space-2);
    color: var(--color-text-muted);
    font-size: var(--font-size-sm);
}

.help-features {
    margin: 0;
    padding-left: var(--space-5);
}

.help-features li {
    margin-bottom: var(--space-2);
    color: var(--color-text-muted);
    font-size: var(--font-size-sm);
}

/* ========================================
   Header Actions
   ======================================== */

.nav-actions {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.btn-icon {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-full);
    font-size: var(--font-size-lg);
    font-weight: 600;
    color: var(--color-text-muted);
    background: var(--color-bg-alt);
    border: 1px solid var(--color-border);
    cursor: pointer;
}

.btn-icon:hover {
    background: var(--color-border);
    color: var(--color-text);
}

.btn-icon:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
}

/* ========================================
   Print Styles
   ======================================== */

@media print {
    .wc-actions,
    .help-panel,
    .nav-actions {
        display: none;
    }

    .word-counter {
        box-shadow: none;
        border: 1px solid #ccc;
    }

    .wc-stats {
        background: white;
    }

    .wc-stat-card {
        border: 1px solid #ccc;
    }
}
