/* ============================================
   ViolinFree.com - Shared Styles
   Hand-drawn sketchbook aesthetic
   ============================================ */

/* ---------- CSS Variables ---------- */
:root {
    /* Paper & Background */
    --paper-bg: #fdfcf9;
    --paper-secondary: #f5f3f0;
    --staff-lines: #d4c5b0;
    
    /* Text Colors - Improved Contrast */
    --text-primary: #1a1a1a;
    --text-body: #2d2d2d;
    --text-secondary: #4a4a4a;
    --text-muted: #6a6a6a;
    
    /* Legacy pencil variables (for compatibility) */
    --pencil-dark: #1a1a1a;
    --pencil-medium: #2d2d2d;
    --pencil-light: #4a4a4a;
    --pencil-faint: #c0c0c0;
    
    /* Accent Colors - Deep Navy */
    --accent: #1e3a5f;
    --accent-light: #2d5a8a;
    --accent-hover: #15294a;
    
    /* Highlights - Muted, sophisticated */
    --highlight-primary: #d4e5f7;
    --highlight-secondary: #e8e4df;
    
    /* Legacy highlight names */
    --highlight-yellow: #e8e4df;
    --highlight-blue: #d4e5f7;
    
    /* Shadows */
    --shadow-color: rgba(0, 0, 0, 0.1);
    --shadow-dark: rgba(0, 0, 0, 0.15);
    
    /* Body background */
    --body-bg-start: #f0ebe4;
    --body-bg-end: #e8e2d9;
    
    /* Tip note - muted warm gray instead of yellow */
    --tip-bg: #f5f3f0;
    
    /* Card colors */
    --card-back-bg: #1e3a5f;
    --card-back-text: #ffffff;
    
    /* Doodle/decoration opacity */
    --doodle-opacity: 0.3;
    --smudge-opacity: 0.02;
}

/* ---------- Dark Mode Variables ---------- */
[data-theme="dark"] {
    --paper-bg: #1a1a1a;
    --paper-secondary: #242424;
    --staff-lines: #333333;
    
    /* Text Colors - Improved Contrast */
    --text-primary: #f5f5f5;
    --text-body: #e0e0e0;
    --text-secondary: #b0b0b0;
    --text-muted: #808080;
    
    /* Legacy pencil variables (for compatibility) */
    --pencil-dark: #f5f5f5;
    --pencil-medium: #e0e0e0;
    --pencil-light: #b0b0b0;
    --pencil-faint: #404040;
    
    /* Accent - Lighter navy for dark mode */
    --accent: #5a8fc9;
    --accent-light: #7aaad9;
    --accent-hover: #4a7fb9;
    
    /* Highlights - Subtle in dark mode */
    --highlight-primary: #1e3a5f;
    --highlight-secondary: #2a2a2a;
    
    --highlight-yellow: #2a2a2a;
    --highlight-blue: #1e3a5f;
    
    --shadow-color: rgba(0, 0, 0, 0.3);
    --shadow-dark: rgba(0, 0, 0, 0.4);
    
    --body-bg-start: #0d0d0d;
    --body-bg-end: #141414;
    
    --tip-bg: #242424;
    
    --card-back-bg: #5a8fc9;
    --card-back-text: #ffffff;
    
    --doodle-opacity: 0.2;
    --smudge-opacity: 0.02;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 18px;
    line-height: 1.9;
    background: linear-gradient(180deg, var(--body-bg-start) 0%, var(--body-bg-end) 100%);
    min-height: 100vh;
    color: var(--text-body);
    transition: background 0.3s ease, color 0.3s ease;
}

/* ---------- Typography ---------- */
h1, h2, h3, h4 {
    font-family: 'Caveat', cursive;
    color: var(--text-primary);
    line-height: 1.3;
}

.subtitle-font {
    font-family: 'Architects Daughter', cursive;
}

/* Hand-drawn accent text */
.handwritten {
    font-family: 'Patrick Hand', cursive;
}

a {
    color: var(--accent);
    text-decoration: none;
    transition: color 0.2s ease;
}

a:hover {
    color: var(--accent-hover);
    text-decoration: underline;
}

/* Improved paragraph spacing */
p {
    margin-bottom: 1rem;
    color: var(--text-body);
}

p:last-child {
    margin-bottom: 0;
}

strong {
    color: var(--text-primary);
    font-weight: 600;
}

em {
    font-style: italic;
}

/* ---------- Paper Container ---------- */
.music-paper {
    background: var(--paper-bg);
    position: relative;
    box-shadow: 
        0 4px 20px var(--shadow-color),
        0 0 0 1px rgba(0,0,0,0.05);
    transition: background 0.3s ease, box-shadow 0.3s ease;
}

/* Staff lines background */
.staff-lines {
    background-image: 
        repeating-linear-gradient(
            transparent,
            transparent 23px,
            var(--staff-lines) 23px,
            var(--staff-lines) 24px,
            transparent 24px,
            transparent 29px,
            var(--staff-lines) 29px,
            var(--staff-lines) 30px,
            transparent 30px,
            transparent 35px,
            var(--staff-lines) 35px,
            var(--staff-lines) 36px,
            transparent 36px,
            transparent 41px,
            var(--staff-lines) 41px,
            var(--staff-lines) 42px,
            transparent 42px,
            transparent 47px,
            var(--staff-lines) 47px,
            var(--staff-lines) 48px,
            transparent 48px,
            transparent 80px
        );
    background-size: 100% 80px;
    opacity: 0.2;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
}

[data-theme="dark"] .staff-lines {
    opacity: 0.1;
}

/* ---------- Sketchy Underline ---------- */
.sketchy-underline {
    position: relative;
    display: inline-block;
}

.sketchy-underline::after {
    content: '';
    position: absolute;
    bottom: -4px;
    left: -5px;
    right: -5px;
    height: 8px;
    background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 10"><path d="M0 8 Q 10 2, 20 7 T 40 6 T 60 8 T 80 5 T 100 7" stroke="%231e3a5f" stroke-width="2.5" fill="none"/></svg>') repeat-x;
    background-size: contain;
}

[data-theme="dark"] .sketchy-underline::after {
    background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 10"><path d="M0 8 Q 10 2, 20 7 T 40 6 T 60 8 T 80 5 T 100 7" stroke="%235a8fc9" stroke-width="2.5" fill="none"/></svg>') repeat-x;
    background-size: contain;
}

/* ---------- Highlight Effects ---------- */
.highlight-yellow {
    background: linear-gradient(180deg, transparent 50%, var(--highlight-yellow) 50%);
    padding: 0 4px;
    margin: 0 -4px;
}

.highlight-blue {
    background: linear-gradient(180deg, transparent 50%, var(--highlight-blue) 50%);
    padding: 0 4px;
    margin: 0 -4px;
}

/* ---------- Circled Text ---------- */
.circled {
    position: relative;
    white-space: nowrap;
}

.circled::before {
    content: '';
    position: absolute;
    top: -8px;
    left: -12px;
    right: -12px;
    bottom: -8px;
    border: 2px solid var(--accent);
    border-radius: 50% 45% 50% 48%;
    transform: rotate(-2deg);
    opacity: 0.7;
}

/* ---------- Crossed Out Text ---------- */
.crossed-out {
    position: relative;
    color: var(--pencil-faint);
}

.crossed-out::after {
    content: '';
    position: absolute;
    left: -2px;
    right: -2px;
    top: 50%;
    height: 2px;
    background: var(--pencil-medium);
    transform: rotate(-3deg);
}

/* ---------- Sketch Box ---------- */
.sketch-box {
    border: 2.5px solid var(--pencil-medium);
    border-radius: 3px 8px 5px 10px;
    position: relative;
    background: var(--paper-bg);
    transition: background 0.3s ease, border-color 0.3s ease;
}

.sketch-box::before {
    content: '';
    position: absolute;
    top: 4px;
    left: 4px;
    right: -4px;
    bottom: -4px;
    background: var(--pencil-faint);
    border-radius: 3px 8px 5px 10px;
    z-index: -1;
    opacity: 0.3;
}

/* ---------- Tip Note ---------- */
.tip-note {
    background: var(--tip-bg);
    border-left: 4px solid var(--accent);
    box-shadow: 2px 2px 0 var(--shadow-color);
    position: relative;
    transition: background 0.3s ease;
    border-radius: 0 8px 8px 0;
}

.tip-note::before {
    content: 'TIP';
    position: absolute;
    top: -10px;
    left: 12px;
    font-family: 'Caveat', cursive;
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--accent);
    background: var(--tip-bg);
    padding: 0 6px;
    transition: background 0.3s ease, color 0.3s ease;
}

/* ---------- Sketch Button ---------- */
.sketch-button {
    font-family: 'Caveat', cursive;
    font-size: 1.4rem;
    font-weight: 600;
    background: var(--accent);
    color: white;
    border: 2px solid var(--pencil-dark);
    border-radius: 4px 10px 6px 12px;
    padding: 0.75rem 2rem;
    transform: rotate(-1deg);
    transition: all 0.2s ease;
    box-shadow: 3px 4px 0 var(--pencil-dark);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
}

.sketch-button:hover {
    transform: rotate(0deg) translateY(-2px);
    box-shadow: 5px 6px 0 var(--pencil-dark);
    text-decoration: none;
    color: white;
}

.sketch-button:active {
    transform: rotate(0deg) translateY(2px);
    box-shadow: 1px 2px 0 var(--pencil-dark);
}

.sketch-button-outline {
    background: var(--paper-bg);
    color: var(--pencil-dark);
    border: 2px solid var(--pencil-medium);
}

.sketch-button-outline:hover {
    background: var(--pencil-dark);
    color: var(--paper-bg);
}

.sketch-button-small {
    font-size: 1.2rem;
    padding: 0.5rem 1.2rem;
}

/* ---------- Lesson Card ---------- */
.lesson-card {
    background: var(--paper-bg);
    border: 2px solid var(--pencil-light);
    border-radius: 4px 12px 8px 16px;
    position: relative;
    transition: all 0.3s ease;
}

/* ---------- Lesson Bubble ---------- */
.lesson-bubble {
    background: var(--accent);
    color: white;
    font-family: 'Caveat', cursive;
    font-size: 1.3rem;
    font-weight: 700;
    min-width: 55px;
    height: 50px;
    padding: 0 10px;
    border-radius: 50% 45% 55% 48%;
    display: flex;
    align-items: center;
    justify-content: center;
    transform: rotate(-5deg);
    box-shadow: 2px 3px 0 var(--shadow-dark);
    flex-shrink: 0;
}

/* ---------- Check List ---------- */
.check-list {
    list-style: none;
    padding-left: 0;
}

.check-list li {
    position: relative;
    padding-left: 2rem;
    margin-bottom: 0.75rem;
}

.check-list li::before {
    content: '';
    position: absolute;
    left: 0;
    top: 2px;
    width: 20px;
    height: 20px;
    background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M4 12 L9 17 L20 6" stroke="%231e3a5f" stroke-width="3" fill="none" stroke-linecap="round" stroke-linejoin="round"/></svg>') no-repeat;
    background-size: contain;
}

[data-theme="dark"] .check-list li::before {
    background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M4 12 L9 17 L20 6" stroke="%235a8fc9" stroke-width="3" fill="none" stroke-linecap="round" stroke-linejoin="round"/></svg>') no-repeat;
    background-size: contain;
}

/* ---------- Video Frame ---------- */
.video-frame {
    border: 3px solid var(--pencil-light);
    border-radius: 8px;
    padding: 4px;
    background: var(--pencil-faint);
    transition: border-color 0.3s ease, background 0.3s ease;
}

.video-frame video {
    border-radius: 4px;
    width: 100%;
    display: block;
}

/* ---------- Image Frame ---------- */
.image-frame {
    border: 3px solid var(--pencil-light);
    border-radius: 8px;
    background: white;
    padding: 8px;
    box-shadow: 3px 4px 0 var(--pencil-faint);
    transition: all 0.3s ease;
}

[data-theme="dark"] .image-frame {
    background: var(--paper-secondary);
}

.image-frame img {
    border-radius: 4px;
    width: 100%;
}

/* ---------- Section Header ---------- */
.section-header {
    position: relative;
    display: inline-block;
    padding-bottom: 8px;
}

.section-header::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 6"><path d="M0 3 Q 25 0, 50 3 T 100 3" stroke="%23c0c0c0" stroke-width="2" fill="none"/></svg>') repeat-x;
}

/* ---------- Stage Groupings ---------- */
.stage-group {
    margin-bottom: 2.5rem;
}

.stage-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 2px dashed var(--pencil-faint);
}

.stage-number {
    font-family: 'Caveat', cursive;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--paper-bg);
    background: var(--accent);
    padding: 0.25rem 0.75rem;
    border-radius: 4px;
    white-space: nowrap;
}

.stage-title {
    font-family: 'Caveat', cursive;
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--text-primary);
}

.stage-description {
    font-size: 0.95rem;
    color: var(--text-secondary);
    margin-left: auto;
    font-style: italic;
}

@media (max-width: 640px) {
    .stage-header {
        flex-wrap: wrap;
    }
    
    .stage-description {
        width: 100%;
        margin-left: 0;
        margin-top: 0.5rem;
    }
}

/* ---------- Accordion Styles ---------- */
.accordion-item {
    background: var(--paper-bg);
    border: 2px solid var(--pencil-light);
    border-radius: 4px 12px 8px 16px;
    margin-bottom: 1rem;
    overflow: hidden;
    transition: all 0.3s ease;
}

.accordion-header {
    padding: 1rem 1.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: background 0.2s ease;
    user-select: none;
}

.accordion-header:hover {
    background: var(--paper-secondary);
}

.accordion-title {
    flex: 1;
}

.accordion-title h2 {
    font-size: 1.8rem;
    margin-bottom: 0.2rem;
}

.accordion-title p {
    font-family: 'Architects Daughter', cursive;
    color: var(--pencil-light);
    font-size: 1.1rem;
}

.accordion-icon {
    width: 24px;
    height: 24px;
    transition: transform 0.3s ease;
    color: var(--pencil-medium);
}

.accordion-item.is-open .accordion-icon {
    transform: rotate(180deg);
}

.accordion-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s ease;
}

.accordion-content-inner {
    padding: 0 1.5rem 1.5rem 1.5rem;
    border-top: 1px dashed var(--pencil-faint);
}

.accordion-item.is-open .accordion-content {
    max-height: 3000px; /* Large enough for any content */
}

/* ---------- Theme Toggle ---------- */
.theme-toggle {
    position: fixed;
    top: 1.5rem;
    right: 1.5rem;
    background: var(--paper-bg);
    border: 2px solid var(--pencil-medium);
    border-radius: 50%;
    width: 50px;
    height: 50px;
    font-size: 1.5rem;
    cursor: pointer;
    transform: rotate(5deg);
    transition: all 0.3s ease;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 2px 3px 0 var(--shadow-color);
}

.theme-toggle:hover {
    transform: rotate(-5deg) scale(1.1);
    border-color: var(--accent);
}

.theme-toggle .icon-sun,
.theme-toggle .icon-moon {
    position: absolute;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.theme-toggle .icon-moon {
    opacity: 0;
    transform: rotate(-90deg);
}

[data-theme="dark"] .theme-toggle .icon-sun {
    opacity: 0;
    transform: rotate(90deg);
}

[data-theme="dark"] .theme-toggle .icon-moon {
    opacity: 1;
    transform: rotate(0deg);
}

/* ---------- Doodles ---------- */
.doodle {
    position: absolute;
    opacity: var(--doodle-opacity);
    pointer-events: none;
    z-index: 10;
    transition: opacity 0.3s ease;
}

.doodle-interactive {
    pointer-events: auto;
    cursor: pointer;
    transition: transform 0.2s ease, opacity 0.2s ease;
}

.doodle-interactive:hover {
    opacity: 0.6;
    transform: scale(1.1) rotate(3deg);
}

/* ---------- Smudge Marks ---------- */
.smudge {
    position: absolute;
    border-radius: 50%;
    background: rgba(100, 100, 100, var(--smudge-opacity));
    filter: blur(10px);
    pointer-events: none;
}

[data-theme="dark"] .smudge {
    background: rgba(200, 200, 200, var(--smudge-opacity));
}

/* ---------- Footer ---------- */
.site-footer {
    text-align: center;
    padding: 2rem 1rem;
    margin-top: 3rem;
    border-top: 3px solid transparent;
    border-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 6"><path d="M0 3 Q 10 0, 20 4 T 40 2 T 60 4 T 80 2 T 100 3" stroke="%23c0c0c0" stroke-width="2" fill="none"/></svg>') 1 repeat;
}

.site-footer p {
    color: var(--pencil-light);
}

.site-footer a {
    color: var(--accent);
    font-weight: 600;
}

/* ---------- Quiz Card Styles ---------- */
.quiz-card {
    perspective: 1000px;
    cursor: pointer;
    transition: transform 0.2s ease;
}

.quiz-card:hover {
    transform: scale(1.03) rotate(-1deg);
}

.quiz-card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transition: transform 0.6s;
    transform-style: preserve-3d;
}

.quiz-card.is-flipped .quiz-card-inner {
    transform: rotateY(180deg);
}

.quiz-card-front,
.quiz-card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 1rem;
    border-radius: 8px;
}

.quiz-card-front {
    background-color: var(--paper-bg);
    border: 2px solid var(--pencil-light);
    box-shadow: 2px 3px 0 var(--pencil-faint);
}

.quiz-card-back {
    background-color: var(--card-back-bg);
    color: var(--card-back-text);
    border: 2px solid var(--card-back-bg);
    transform: rotateY(180deg);
    box-shadow: 2px 3px 0 rgba(0,0,0,0.2);
    font-weight: 500;
}

/* Quiz card rotation variations */
.quiz-card:nth-child(odd) { transform: rotate(0.5deg); }
.quiz-card:nth-child(even) { transform: rotate(-0.5deg); }
.quiz-card:nth-child(3n) { transform: rotate(1deg); }
.quiz-card:nth-child(4n) { transform: rotate(-1deg); }

.quiz-card:nth-child(odd):hover { transform: scale(1.03) rotate(-0.5deg); }
.quiz-card:nth-child(even):hover { transform: scale(1.03) rotate(0.5deg); }

/* ---------- Image Hidden State (for quiz) ---------- */
.image-hidden {
    opacity: 0;
    transform: scale(0.95) rotate(-0.5deg);
    max-height: 0;
    overflow: hidden;
    padding: 0 !important;
    border: none !important;
    margin-bottom: 0 !important;
    box-shadow: none !important;
}

/* ---------- Completion Box ---------- */
.completion-box {
    border: 3px dashed var(--pencil-medium);
    border-radius: 8px 15px 10px 20px;
    background: linear-gradient(135deg, var(--tip-bg) 0%, var(--paper-bg) 100%);
    position: relative;
    transition: background 0.3s ease, border-color 0.3s ease;
}

/* ---------- Utility Classes ---------- */
.text-accent { color: var(--accent); }
.font-bold { font-weight: 700; }
.text-center { text-align: center; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-4 { margin-bottom: 1rem; }
.mb-6 { margin-bottom: 1.5rem; }
.mb-8 { margin-bottom: 2rem; }
.mt-4 { margin-top: 1rem; }
.mt-8 { margin-top: 2rem; }
.p-6 { padding: 1.5rem; }
.p-8 { padding: 2rem; }
.rounded-lg { border-radius: 0.5rem; }

/* ---------- Responsive ---------- */
@media (max-width: 768px) {
    .theme-toggle {
        top: 1rem;
        right: 1rem;
        width: 44px;
        height: 44px;
    }
    
    .lesson-bubble {
        width: 40px;
        height: 40px;
        font-size: 1.2rem;
    }
    
    .accordion-header {
        padding: 0.75rem 1rem;
    }
    
    .accordion-title h2 {
        font-size: 1.5rem;
    }
    
    .accordion-content-inner {
        padding: 0 1rem 1rem 1rem;
    }
    
    .doodle {
        display: none;
    }
}
