/* Global Design System & Variables */
:root {
    --bg-color: #f8fafc;
    --text-color: #0f172a;
    --text-muted: #475569;
    --primary: #d22630; /* Polish Red */
    --primary-hover: #a61b22;
    --accent: #0f766e; /* Deep Teal */
    --card-bg-front: #ffffff;
    --card-bg-back: #fff5f5; /* Soft reddish tint */
    --card-border: rgba(210, 38, 48, 0.15);
    --btn-secondary-bg: #f1f5f9;
    --btn-secondary-text: #334155;
    --progress-bg: #e2e8f0;
    --shadow: 0 10px 25px -5px rgba(210, 38, 48, 0.08), 0 8px 10px -6px rgba(0, 0, 0, 0.05);
    --border-radius: 16px;
    --font-sans: 'Outfit', sans-serif;
    --font-serif: 'Playfair Display', serif;
}

[data-theme="dark"] {
    --bg-color: #0f0f15;
    --text-color: #f1f5f9;
    --text-muted: #94a3b8;
    --primary: #ff4d5a; /* Vibrant Red */
    --primary-hover: #ff707b;
    --accent: #2dd4bf;
    --card-bg-front: #1e1e24;
    --card-bg-back: #2b1b1e; /* Deep dark reddish tone */
    --card-border: rgba(255, 77, 90, 0.2);
    --btn-secondary-bg: #27272a;
    --btn-secondary-text: #f4f4f5;
    --progress-bg: #27272a;
    --shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.4), 0 8px 10px -6px rgba(0, 0, 0, 0.3);
}

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

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: var(--font-sans);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: background-color 0.3s ease, color 0.3s ease;
    line-height: 1.5;
}

/* App Header */
.app-header {
    text-align: center;
    padding: 2rem 1rem 1rem;
    max-width: 600px;
    margin: 0 auto;
    width: 100%;
}

.top-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.nav-brand {
    font-weight: 800;
    font-size: 1.25rem;
    color: var(--primary);
    letter-spacing: 0.5px;
}

.theme-toggle {
    background: none;
    border: 2px solid var(--card-border);
    color: var(--text-color);
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.theme-toggle:hover {
    background-color: var(--btn-secondary-bg);
    transform: scale(1.05);
}

.theme-toggle .icon {
    width: 1.25rem;
    height: 1.25rem;
}

.theme-toggle .sun-icon { display: none; }
[data-theme="dark"] .theme-toggle .moon-icon { display: none; }
[data-theme="dark"] .theme-toggle .sun-icon { display: block; }

.main-title {
    font-family: var(--font-serif);
    font-size: 2.5rem;
    font-weight: 800;
    margin-bottom: 0.25rem;
}

.subtitle {
    font-size: 0.9rem;
    color: var(--text-muted);
}

.edward-link {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
    border-bottom: 1px dashed var(--primary);
    transition: color 0.2s;
}

.edward-link:hover {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

/* Main Container */
.app-main {
    flex: 1;
    max-width: 600px;
    width: 100%;
    margin: 0 auto;
    padding: 0 1rem 3rem;
}

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

/* Progress Indicator */
.progress-container {
    margin-bottom: 1.5rem;
}

.progress-bar {
    height: 6px;
    background-color: var(--progress-bg);
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 0.5rem;
}

.progress-fill {
    height: 100%;
    background-color: var(--primary);
    border-radius: 3px;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.progress-text {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 600;
}

/* Flashcard Layout */
.flashcard-wrapper {
    perspective: 1000px;
    width: 100%;
    aspect-ratio: 16 / 10;
    min-height: 260px;
    margin-bottom: 1.5rem;
}

.flashcard {
    position: relative;
    width: 100%;
    height: 100%;
    transform-style: preserve-3d;
    transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.3s ease;
    cursor: pointer;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
}

.flashcard:focus-visible {
    outline: 3px solid var(--primary);
    outline-offset: 4px;
}

.flashcard.is-flipped {
    transform: rotateY(180deg);
}

.card-face {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    border-radius: var(--border-radius);
    border: 2px solid var(--card-border);
    padding: 2rem;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    text-align: center;
    overflow: hidden;
}

.card-front {
    background-color: var(--card-bg-front);
}

.card-reverse {
    background-color: var(--card-bg-back);
    transform: rotateY(180deg);
}

.known-toggle {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: none;
    border: 2px solid var(--card-border);
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: transparent;
    transition: all 0.2s ease;
}

.known-toggle svg {
    width: 16px;
    height: 16px;
}

.known-toggle:hover {
    transform: scale(1.1);
    border-color: #10b981;
    color: #10b981;
}

.flashcard.is-known {
    border: 2px solid #10b981;
}

.flashcard.is-known .known-toggle {
    background-color: #10b981;
    border-color: #10b981;
    color: white;
}

.card-side-label {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: var(--text-muted);
}

.card-content {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    flex: 1;
    width: 100%;
}

#card-front-text {
    font-size: 1.5rem;
    font-weight: 600;
    max-width: 90%;
}

.polish-text {
    font-family: var(--font-serif);
    font-size: 2rem;
    font-weight: 800;
    color: var(--primary);
    margin-bottom: 0.5rem;
    line-height: 1.3;
}

.polish-pronunciation {
    font-size: 1rem;
    color: var(--text-muted);
    font-style: italic;
}

.tap-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
    letter-spacing: 0.5px;
}

.audio-action-container {
    margin-top: 0.5rem;
}

.audio-link {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--primary);
    text-decoration: none;
    padding: 6px 12px;
    border-radius: 20px;
    background-color: rgba(210, 38, 48, 0.08);
    transition: all 0.2s ease;
}

.audio-link:hover {
    background-color: var(--primary);
    color: white;
}

.speaker-icon {
    width: 16px;
    height: 16px;
}

/* Controls */
.controls {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
}

.btn {
    font-family: var(--font-sans);
    font-weight: 600;
    font-size: 0.95rem;
    padding: 0.75rem 1.5rem;
    border-radius: var(--border-radius);
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-primary {
    background-color: var(--primary);
    color: white;
    flex: 1.5;
}

.btn-primary:hover {
    background-color: var(--primary-hover);
    transform: translateY(-1px);
}

.btn-secondary {
    background-color: var(--btn-secondary-bg);
    color: var(--btn-secondary-text);
    flex: 1;
}

.btn-secondary:hover {
    opacity: 0.9;
}

.utility-controls {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    margin-top: 1rem;
}

.btn-utility {
    background: none;
    border: 1px solid var(--card-border);
    border-radius: var(--border-radius);
    color: var(--text-color);
    font-size: 0.85rem;
    padding: 0.5rem 1rem;
    flex: 1;
}

.btn-utility:hover {
    background-color: var(--btn-secondary-bg);
}

.btn-utility svg {
    width: 14px;
    height: 14px;
    vertical-align: middle;
    margin-right: 4px;
}

/* Resources Section */
.resources-section {
    margin-top: 3.5rem;
    border-top: 1px solid var(--card-border);
    padding-top: 2.5rem;
}

.resources-section h2 {
    font-family: var(--font-serif);
    font-size: 1.75rem;
    margin-bottom: 1.5rem;
}

.resource-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
}

@media (min-width: 600px) {
    .resource-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

.resource-card {
    background-color: var(--card-bg-front);
    border: 1px solid var(--card-border);
    border-radius: var(--border-radius);
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
}

.resource-card h3 {
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
    color: var(--primary);
}

.resource-card p {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
    flex: 1;
}

.resource-link {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--primary);
    text-decoration: none;
    margin-top: 0.25rem;
    display: inline-block;
}

.resource-link:hover {
    text-decoration: underline;
}

/* App Footer */
.app-footer {
    text-align: center;
    padding: 2rem 1rem;
    font-size: 0.8rem;
    color: var(--text-muted);
    border-top: 1px solid var(--card-border);
    margin-top: auto;
}

/* Media Queries */
@media (max-width: 480px) {
    .main-title {
        font-size: 2rem;
    }
    
    .flashcard-wrapper {
        aspect-ratio: auto;
        height: 280px;
    }
    
    #card-front-text {
        font-size: 1.25rem;
    }
    
    .polish-text {
        font-size: 1.65rem;
    }
}
