/* Global Design System & Variables */
:root {
    --bg-color: #f5f8fa;
    --text-color: #1e293b;
    --text-muted: #64748b;
    --primary: #005a9c; /* Aegean Blue */
    --primary-hover: #004475;
    --accent: #d4af37; /* Hellenic Gold */
    --card-bg-front: #ffffff;
    --card-bg-back: #e0f2fe;
    --card-border: rgba(0, 90, 156, 0.15);
    --btn-secondary-bg: #e2e8f0;
    --btn-secondary-text: #334155;
    --progress-bg: #e2e8f0;
    --shadow: 0 10px 30px -10px rgba(0, 90, 156, 0.15);
    --border-radius: 16px;
    --font-sans: 'Outfit', sans-serif;
    --font-serif: 'Playfair Display', serif;
}

[data-theme="dark"] {
    --bg-color: #0b1329;
    --text-color: #f8fafc;
    --text-muted: #94a3b8;
    --primary: #38bdf8; /* Lighter Cyan/Blue for dark theme readability */
    --primary-hover: #7dd3fc;
    --accent: #fbbf24;
    --card-bg-front: #1e293b;
    --card-bg-back: #0f172a;
    --card-border: rgba(56, 189, 248, 0.2);
    --btn-secondary-bg: #334155;
    --btn-secondary-text: #f1f5f9;
    --progress-bg: #334155;
    --shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.5);
}

/* 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: 2.5rem 1rem 1.5rem;
    max-width: 800px;
    margin: 0 auto;
    width: 100%;
}

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

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

.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 Icons Toggle Visibility */
.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.5rem;
}

.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);
}

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

/* Hidden Class for Screen Readers */
.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;
}

/* Progress Container */
.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 Styles */
.flashcard-wrapper {
    perspective: 1000px;
    width: 100%;
    aspect-ratio: 16 / 10;
    min-height: 260px;
    margin-bottom: 2rem;
}

.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);
}

/* Keep Known Indicator Styling */
.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;
}

/* If Card is Marked as Known */
.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;
}

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

.greek-text {
    font-family: var(--font-serif);
    font-size: 2.25rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 0.5rem;
}

.greek-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 Section */
.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(0, 90, 156, 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: 1.5rem;
}

.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 {
    background-color: rgba(0, 0, 0, 0.05);
}

[data-theme="dark"] .btn-secondary:hover {
    background-color: rgba(255, 255, 255, 0.05);
}

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

.btn-text {
    background: none;
    border: none;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.btn-text:hover {
    color: var(--primary);
    background-color: rgba(0, 90, 156, 0.05);
}

/* 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: 0.5rem;
}

.resources-intro {
    font-size: 0.95rem;
    color: var(--text-muted);
    margin-bottom: 1.5rem;
}

.resources-grid {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.resource-card {
    display: block;
    background-color: var(--card-bg-front);
    border: 1px solid var(--card-border);
    border-radius: var(--border-radius);
    padding: 1.25rem;
    text-decoration: none;
    color: inherit;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.02);
}

.resource-card:hover {
    transform: translateY(-2px);
    border-color: var(--primary);
    box-shadow: var(--shadow);
}

.resource-title {
    font-weight: 700;
    font-size: 1.05rem;
    color: var(--primary);
    margin-bottom: 0.25rem;
}

.resource-desc {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
}

.resource-action {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--accent);
}

/* 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;
    }
    
    .greek-text {
        font-size: 1.75rem;
    }
}
