/* ===================================================================
   CHINESE TEXT TO SPEECH WITH HANYU PINYIN - STYLES
   
   This stylesheet defines the visual design for the educational
   interactive about Chinese pronunciation and Hanyu Pinyin.
   
   Design Principles:
   - Clean, organized layout optimized for iframe and full-screen
   - Visual hierarchy guides user attention
   - Sufficient contrast for readability
   - Touch-friendly button sizes
   - Responsive to both desktop and mobile interactions
   =================================================================== */

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

html, body {
    width: 100%;
    height: 100%;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    overflow: hidden;
}

/* Container - Adapts to iframe (450px) or full screen (90vh) */
.container {
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 8px;
}

/* Main Panel - Central content area */
.main-panel {
    width: 100%;
    max-width: 600px;
    height: 100%;
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 16px;
    gap: 12px;
}

/* Header Tooltip - No visible header text, shows on hover */
.header-tooltip {
    font-size: 14px;
    font-weight: 600;
    color: #667eea;
    text-align: center;
    padding: 8px;
    cursor: help;
    opacity: 0.7;
    transition: opacity 0.3s ease;
}

.header-tooltip:hover {
    opacity: 1;
}

/* Input Section */
.input-section {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.label-text {
    font-size: 13px;
    font-weight: 600;
    color: #333;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.text-input {
    width: 100%;
    padding: 10px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 14px;
    font-family: 'Segoe UI', sans-serif;
    resize: vertical;
    min-height: 60px;
    max-height: 80px;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.text-input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.char-count {
    font-size: 12px;
    color: #999;
    text-align: right;
}

/* Button Section */
.button-section {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 8px;
}

.btn {
    padding: 10px 12px;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
    height: auto;
    min-height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.btn-primary:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
}

.btn-secondary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(245, 87, 108, 0.4);
}

.btn-secondary:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(245, 87, 108, 0.4);
}

.btn-tertiary {
    background: #f0f0f0;
    color: #333;
    border: 2px solid #ddd;
}

.btn-tertiary:hover {
    background: #e8e8e8;
    border-color: #999;
}

.btn-tertiary:active {
    background: #ddd;
}

/* Section Titles */
.section-title {
    font-size: 12px;
    font-weight: 700;
    color: #667eea;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}

/* Pinyin Display Section */
.pinyin-section {
    background: #f8f9ff;
    padding: 10px;
    border-radius: 8px;
    border-left: 4px solid #667eea;
}

.pinyin-display {
    font-size: 16px;
    line-height: 1.6;
    color: #333;
    word-wrap: break-word;
    min-height: 40px;
    display: flex;
    align-items: center;
}

.placeholder-text {
    color: #ccc;
    font-style: italic;
    font-size: 13px;
}

/* Character Analysis Section */
.analysis-section {
    background: #fff5f7;
    padding: 10px;
    border-radius: 8px;
    border-left: 4px solid #f5576c;
}

.analysis-display {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 8px;
    min-height: 50px;
}

.analysis-placeholder {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 50px;
}

.char-card {
    background: white;
    border: 2px solid #f5576c;
    border-radius: 6px;
    padding: 8px;
    text-align: center;
    box-shadow: 0 2px 6px rgba(245, 87, 108, 0.1);
    transition: all 0.3s ease;
}

.char-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(245, 87, 108, 0.2);
}

.char-large {
    font-size: 24px;
    font-weight: bold;
    color: #333;
    margin-bottom: 4px;
}

.char-pinyin {
    font-size: 11px;
    color: #667eea;
    font-weight: 600;
}

/* Tone Reference Section */
.tone-reference {
    background: #f0fff4;
    padding: 10px;
    border-radius: 8px;
    border-left: 4px solid #4caf50;
}

.tone-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(70px, 1fr));
    gap: 8px;
}

.tone-item {
    background: white;
    border: 2px solid #4caf50;
    border-radius: 6px;
    padding: 8px;
    text-align: center;
    box-shadow: 0 2px 6px rgba(76, 175, 80, 0.1);
    transition: all 0.3s ease;
}

.tone-item:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 10px rgba(76, 175, 80, 0.2);
}

.tone-number {
    font-size: 10px;
    font-weight: 700;
    color: #666;
    text-transform: uppercase;
    margin-bottom: 4px;
}

.tone-mark {
    font-size: 28px;
    font-weight: bold;
    color: #4caf50;
    margin: 4px 0;
}

.tone-description {
    font-size: 10px;
    color: #999;
    line-height: 1.3;
}

/* Examples Section */
.examples-section {
    background: #fffbf0;
    padding: 10px;
    border-radius: 8px;
    border-left: 4px solid #ff9800;
}

.examples-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}

.example-btn {
    padding: 8px;
    background: white;
    border: 2px solid #ff9800;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    color: #ff9800;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 6px rgba(255, 152, 0, 0.1);
}

.example-btn:hover {
    background: #ff9800;
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(255, 152, 0, 0.3);
}

.example-btn:active {
    transform: translateY(0);
}

/* Information Panel */
.info-panel {
    background: #e3f2fd;
    padding: 10px;
    border-radius: 8px;
    border-left: 4px solid #2196f3;
    margin-top: 4px;
}

.info-title {
    font-size: 12px;
    font-weight: 700;
    color: #2196f3;
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.info-content {
    font-size: 12px;
    color: #555;
    line-height: 1.5;
    text-align: justify;
}

/* Scrollbar Styling */
.main-panel::-webkit-scrollbar {
    width: 6px;
}

.main-panel::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

.main-panel::-webkit-scrollbar-thumb {
    background: #667eea;
    border-radius: 10px;
}

.main-panel::-webkit-scrollbar-thumb:hover {
    background: #764ba2;
}

/* Responsive Design for Different Screen Sizes */
@media (max-height: 600px) {
    .main-panel {
        padding: 12px;
        gap: 8px;
    }

    .btn {
        min-height: 36px;
        font-size: 12px;
    }

    .text-input {
        min-height: 50px;
        max-height: 70px;
    }
}

/* Animation for feedback */
@keyframes pulse {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
    100% {
        transform: scale(1);
    }
}

.btn:active {
    animation: pulse 0.3s ease;
}