/* =========================================
   THE LEARNING SHIRE THEME - DAILY SPARK
========================================= */

/* RESET & BASE */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
    /* Smooth scrolling */
}

body {
    background-color: #2e4a33;
    font-family: 'Comic Neue', 'Comic Sans MS', sans-serif;
    color: #4a3b2a;
    height: 100vh;
    overflow-x: hidden;
}

/* =========================================
   HEADER
========================================= */
.app-header {
    background-color: #fdf6e3;
    border-bottom: 4px solid #4a3b2a;
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: fixed;
    top: 0;
    width: 100%;
    z-index: 100;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
    height: 100px;
    /* Fixed height for calculation */
}

.header-center {
    text-align: center;
}

.app-header h1 {
    font-size: 1.8rem;
    color: #2e4a33;
    margin-bottom: 5px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.meta-info {
    font-size: 1rem;
    font-style: italic;
    color: #6b4c35;
    font-weight: bold;
}

.nav-btn {
    background-color: #4a3b2a;
    color: #fdf6e3;
    border: 2px solid #6b4c35;
    padding: 10px 20px;

    /* Ensure this uses the new font too */
    font-family: 'Comic Neue', sans-serif;
    font-weight: bold;

    font-size: 1.1rem;
    /* Increased slightly for readability */
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.2s ease;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
}

.nav-btn:hover {
    background-color: #6b4c35;
    transform: scale(1.05);
}

.nav-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* =========================================
   MAIN LAYOUT (SNAP SCROLL)
========================================= */
.layout-container {
    display: flex;
    max-width: 1800px;
    margin: 100px auto 0;
    /* Push down below header */
    padding: 20px;
    gap: 40px;
}

/* LEFT SIDE: STICKY IMAGE (50%) */
.sticky-sidebar {
    flex: 1;
    position: sticky;
    top: 120px;
    /* Sits just below header */
    height: calc(100vh - 140px);
    /* Full height minus header/padding */
    display: flex;
    align-items: center;
    /* Center image vertically */
    justify-content: center;
}

#main-image {
    width: 100%;
    height: 100%;
    object-fit: contain;
    /* Ensures whole image is seen */
    border: 4px solid #4a3b2a;
    border-radius: 12px;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.5);
    background-color: #000;
}

/* RIGHT SIDE: SCROLLING CONTENT (50%) */
.scrolling-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 100px;
    /* Big gap between sections */
    padding-bottom: 50px;
}

/* =========================================
   CARDS (FULL SCREEN SECTIONS)
========================================= */
.card {
    background-color: #fdf6e3;
    border: 2px solid #4a3b2a;
    border-radius: 12px;
    padding: 40px;
    /* More padding for "poster" look */
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
    position: relative;

    /* THE MAGIC: Full Screen Height Logic */
    min-height: calc(100vh - 140px);
    /* Height of screen minus header */
    display: flex;
    flex-direction: column;
    justify-content: center;
    /* Vertically center the content */

    /* Scroll Snapping offsets */
    scroll-margin-top: 120px;
}

.card::before {
    content: '';
    display: block;
    width: 100%;
    height: 4px;
    background: #6b4c35;
    position: absolute;
    top: 0;
    left: 0;
    border-top-left-radius: 10px;
    border-top-right-radius: 10px;
    opacity: 0.5;
}

.card h2 {
    color: #2e4a33;
    border-bottom: 2px dashed #6b4c35;
    padding-bottom: 10px;
    margin-bottom: 30px;
    font-size: 1.8rem;
    /* Bigger titles */
}

.instruction {
    font-style: italic;
    color: #666;
    margin-bottom: 25px;
    font-size: 1.1rem;
}

/* =========================================
   INTERACTIVE ELEMENTS
========================================= */
input,
textarea,
.writing-area,
.better-sentence {
    width: 100%;
    background: #fff;
    border: 1px solid #c7b299;
    padding: 15px;
    font-family: 'Comic Neue', 'Comic Sans MS', sans-serif;
    /* <--- NEW FONT */
    font-size: 1.2rem;
    border-radius: 4px;
    color: #333;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.05);
}

textarea:focus,
input:focus,
.better-sentence:focus {
    outline: none;
    border-color: #2e4a33;
    background: #fffcf5;
}

/* Section 2 Buttons */
.starter-pill {
    background: #2e4a33;
    color: #fdf6e3;
    border: none;
    padding: 10px 15px;
    margin: 0 8px 10px 0;
    border-radius: 6px;
    cursor: pointer;
    font-family: 'Georgia', serif;
    font-size: 1rem;
    font-family: 'Comic Neue', 'Comic Sans MS', sans-serif; /* Change from Georgia */
    transition: 0.2s;
}

.starter-pill:hover {
    background: #4a3b2a;
    transform: translateY(-2px);
}

/* Section 3 (Sentence Doctor) */
.boring-sentence {
    font-size: 1.5rem;
    color: #6b4c35;
    text-align: center;
    margin-bottom: 20px;
    font-style: italic;
}

.arrow {
    text-align: center;
    font-size: 2rem;
    color: #2e4a33;
    margin: 10px 0;
}

/* =========================================
   SECTION 4: GRAMMAR (UPDATED)
========================================= */
.grammar-list li {
    list-style: none;
    font-size: 1.4rem;
    line-height: 2;
    margin-bottom: 20px;
    padding: 20px;
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sentence-text {
    flex: 1;
}

/* Base Clickable Items */
.conj,
.indep,
.sub,
.sub-conj {
    border-bottom: 2px dotted #ccc;
    cursor: pointer;
    transition: 0.2s;
    border-radius: 4px;
    padding: 2px 4px;
    text-decoration: none;
    margin: 0 2px;
}

/* Independent Clause (RED) */
.active-indep {
    background-color: #ffcdd2;
    color: #b71c1c;
    border-bottom: 2px solid #b71c1c;
    font-weight: bold;
}

/* Subordinate Clause (ORANGE) */
.active-sub {
    background-color: #ffe0b2;
    color: #e65100;
    border-bottom: 2px solid #e65100;
    font-weight: bold;
}

/* Subordinate Conjunction (YELLOW) - Only exists inside Orange */
.active-sub-conj {
    background-color: #fff9c4;
    /* Yellow */
    color: #fbc02d;
    /* Dark Gold text */
    border-bottom: 2px solid #fbc02d;
    font-weight: bold;
    box-shadow: 0 0 5px rgba(0, 0, 0, 0.1);
    /* Pop out slightly */
    position: relative;
    z-index: 5;
    /* Sit on top of orange */
}

/* Conjunction (GREEN) */
.active-conj {
    background-color: #c8e6c9;
    color: #1b5e20;
    border-bottom: 2px solid #1b5e20;
    font-weight: bold;
}

/* Reveal Tag */
.type-tag {
    background: #4a3b2a;
    color: #fdf6e3;
    padding: 8px 15px;
    border-radius: 4px;
    font-size: 1rem;
    font-weight: bold;
    margin-left: 20px;
    opacity: 0;
    transform: translateX(10px);
    transition: all 0.3s ease;
}

.type-tag.visible {
    opacity: 1;
    transform: translateX(0);
}

.reveal-btn {
    background: #6b4c35;
    color: white;
    border: none;
    padding: 15px;
    width: 100%;
    font-family: 'Georgia', serif;
    font-size: 1.2rem;
    cursor: pointer;
    border-radius: 6px;
    margin-top: 10px;
}

.reveal-btn:hover {
    background: #4a3b2a;
}

/* Section 5 (Thinking) */
.thinking-grid {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.think-box label {
    display: block;
    font-weight: bold;
    color: #2e4a33;
    margin-bottom: 8px;
    font-size: 1.2rem;
}

/* RESPONSIVE */
@media (max-width: 900px) {
    .layout-container {
        flex-direction: column;
    }

    .sticky-sidebar {
        position: relative;
        top: 0;
        height: auto;
        max-height: 50vh;
    }

    .card {
        min-height: auto;
    }

    /* Disable snap layout on mobile */
    .app-header h1 {
        font-size: 1.4rem;
    }

    .grammar-list li {
        flex-direction: column;
        align-items: flex-start;
    }

    .type-tag {
        margin-top: 10px;
        margin-left: 0;
    }
}

/* =========================================
   NEW FEATURE 1: FOCUS MODE (Fullscreen)
========================================= */
/* The button sitting on the image */
#focus-btn {
    position: absolute;
    top: 15px;
    right: 15px;
    background: rgba(46, 74, 51, 0.8);
    /* Shire Green semi-transparent */
    color: white;
    border: 2px solid #fdf6e3;
    width: 40px;
    height: 40px;
    font-size: 1.5rem;
    border-radius: 50%;
    cursor: pointer;
    z-index: 20;
    transition: 0.2s;
    display: flex;
    /* Center the icon */
    align-items: center;
    justify-content: center;
}

#focus-btn:hover {
    background: #4a3b2a;
    transform: scale(1.1);
}

/* The Class we toggle to make it Fullscreen */
.fullscreen-mode {
    position: fixed !important;
    /* Force fixed positioning */
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100vw !important;
    height: 100vh !important;
    z-index: 9999;
    background: rgba(0, 0, 0, 0.95);
    /* Dark background */
    padding: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.fullscreen-mode img {
    max-width: 95%;
    max-height: 95%;
    border: none !important;
    /* Remove border in focus mode */
    box-shadow: none !important;
}

/* =========================================
   NEW FEATURE: TEXT TO SPEECH (TTS)
========================================= */
.tts-btn {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    color: #2e4a33;
    /* Shire Green */
    padding: 0 5px;
    margin-left: 10px;
    opacity: 0.6;
    transition: 0.2s;
    vertical-align: middle;
}

.tts-btn:hover {
    opacity: 1;
    transform: scale(1.2);
    color: #e65100;
    /* Orange highlight on hover */
}

/* Ensure speaker buttons don't print! */
@media print {
    .tts-btn {
        display: none !important;
    }
}

/* =========================================
   NEW FEATURE 2: PRINTABLE WORKSHEET
   (Layout V3: Fixed Pixel Heights for Reliability)
========================================= */
/* =========================================
   NEW FEATURE 2: PRINTABLE WORKSHEET
   (Layout V4: Final adjustments)
========================================= */
@media print {

    /* 1. Base Setup */
    body {
        background: white;
        color: black;
        height: auto;
        overflow: visible;
    }

    /* Hide UI Elements */
    .nav-btn,
    #focus-btn,
    #grammar-reveal-btn,
    .starter-pill,
    .arrow,
    .app-header,
    .header-right {
        display: none !important;
    }

    /* Reset Card Styles */
    .card {
        background: white;
        border: none;
        box-shadow: none;
        min-height: auto;
        margin-bottom: 0;
        padding: 0;
    }

    /* Layout Reset */
    .layout-container {
        display: block;
        margin: 0;
        padding: 0;
        max-width: 100%;
    }

    .sticky-sidebar {
        position: relative;
        height: auto;
        width: 100%;
        display: block;
        text-align: center;
    }

    .scrolling-content {
        display: block;
        padding: 0;
    }

    /* Image Sizing */
    #main-image {
        max-height: 350px;
        border: 1px solid #000;
        width: auto;
        max-width: 100%;
        margin-bottom: 20px;
    }

    /* --- PAGE 1: IMAGE + VOCAB --- */
    .scrolling-content .card:nth-of-type(1) {
        page-break-after: always;
        padding-bottom: 20px;
    }

    /* --- PAGE 2: STORY & SENTENCE DOCTOR --- */

    /* SECTION 2 (Story) */
    .scrolling-content .card:nth-of-type(2) {
        display: block;
        margin-top: 20px;
    }

    /* ... existing print styles ... */

    /* --- PAGE 2: STORY & SENTENCE DOCTOR --- */

    /* SECTION 2 (Story) */
    .scrolling-content .card:nth-of-type(2) {
        display: block;
        margin-top: 20px;
    }

    /* NEW CODE START: Reduce font size for Story Starter text */
    #story-starter {
        font-size: 11pt !important;
        /* Overrides the inline 1.2rem */
        line-height: 1.3 !important;
        /* Tightens the spacing slightly */
        margin-bottom: 10px !important;
    }

    /* Optional: Make the "What happens next?" instruction smaller too */
    .scrolling-content .card:nth-of-type(2) .instruction {
        font-size: 10pt !important;
    }

    /* NEW CODE END */

    /* ... continue with existing styles ... */

    /* Height reduced to 250px (50% of previous size) */
    .scrolling-content .card:nth-of-type(2) .writing-area {
        height: 250px !important;
        min-height: 250px !important;
        border: 2px solid #000;
        resize: none;
    }

    /* SECTION 3 (Sentence Doctor) */
    .scrolling-content .card:nth-of-type(3) {
        display: block;
        page-break-after: always;
        margin-top: 40px;
    }

    /* Height reduced to 200px (50% of previous size) */
    .scrolling-content .card:nth-of-type(3) .better-sentence {
        display: block;
        height: 200px !important;
        min-height: 200px !important;
        border: 2px solid #000;
        color: transparent !important;
    }

    /* --- PAGE 3: GRAMMAR & THINKING --- */

    /* SECTION 5 (Thinking): Kept at 210px (Perfect size) */
    .think-box textarea {
        height: 210px !important;
        border: 2px solid #000;
    }

    /* GLOBAL CLEANUP */
    input::placeholder,
    textarea::placeholder {
        color: transparent !important;
    }

    .active-indep,
    .active-sub,
    .active-conj,
    .active-sub-conj {
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
}

/* =========================================
   UPDATED: SENTENCE STARTER GROUPS
========================================= */
.starter-group {
    display: inline-flex;
    align-items: center;
    background: #e0f2f1;
    /* Light background for the whole group */
    border-radius: 15px;
    margin: 0 8px 8px 0;
    padding-right: 5px;
    border: 1px solid #b2dfdb;
}

/* The Insert Button (The Text) */
.starter-pill {
    background: transparent;
    color: #00695c;
    border: none;
    padding: 8px 10px;
    cursor: pointer;
    font-family: 'Georgia', serif;
    font-weight: bold;
    border-right: 1px solid #b2dfdb;
    /* Separator line */
}

.starter-pill:hover {
    background: #b2dfdb;
    border-radius: 15px 0 0 15px;
}

/* The Small Speaker inside the group */
.mini-tts {
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    padding: 0 8px;
    opacity: 0.6;
    transition: 0.2s;
}

.mini-tts:hover {
    opacity: 1;
    transform: scale(1.2);
}

@media print {
    .starter-group {
        display: none !important;
    }
}
/* =========================================
   NEW FEATURE: NAVIGATION DROPDOWN
========================================= */
.nav-select {
    background-color: #fdf6e3;
    border: 2px solid #6b4c35;
    color: #4a3b2a;
    padding: 8px;
    font-family: 'Comic Neue', sans-serif;
    font-weight: bold;
    font-size: 1rem;
    border-radius: 6px;
    cursor: pointer;
    max-width: 200px;
}

/* =========================================
   NEW FEATURE: TEXT BOX EXPANSION
========================================= */

/* The header container inside a card to hold title + button */
.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px dashed #6b4c35;
    margin-bottom: 20px;
    padding-bottom: 10px;
}

.card-header h2 {
    border-bottom: none; /* Remove old border since container has it */
    margin-bottom: 0;
    padding-bottom: 0;
}

/* The Expand Button Style */
.expand-btn {
    background: #2e4a33;
    color: white;
    border: none;
    width: 35px;
    height: 35px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: 0.2s;
}

.expand-btn:hover {
    background: #4a3b2a;
    transform: scale(1.1);
}

/* --- THE EXPANDED MODE --- */
/* This class is added by JS when you click the button */
/* --- THE EXPANDED MODE --- */
.card.expanded-card {
    position: fixed;
    top: 100px;
    right: 0;
    width: 50%;
    height: calc(100vh - 100px);
    z-index: 500;
    border-radius: 0;
    border-left: 4px solid #2e4a33;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    
    /* NEW FIX: Forces content to start at the top so it doesn't get cut off */
    justify-content: flex-start !important; 
    padding-top: 30px; /* Adds a little extra space at the top */
}

/* Make the textarea huge when expanded */
.card.expanded-card .content-wrapper,
.card.expanded-card .writing-area {
    flex: 1; /* Grow to fill the space */
    display: flex;
    flex-direction: column;
}

.card.expanded-card textarea {
    flex: 1; /* Stretch the text box to the bottom */
    min-height: 300px;
}

/* Hide Expand buttons when printing */
@media print {
    .expand-btn, .nav-select {
        display: none !important;
    }
}
/* PASTE THE NEW CODE HERE (AT THE VERY END) */
/* Make the Thinking Routine stack vertically when expanded so text boxes are huge */
.card.expanded-card .thinking-grid {
    display: flex;
    flex-direction: column;
    gap: 20px;
    width: 100%;
}
/* =========================================
   FOOTER
========================================= */
.app-footer {
    background-color: #2e4a33; /* Shire Green */
    color: #fdf6e3; /* Cream Text */
    text-align: center;
    padding: 20px;
    margin-top: 50px; /* Space above footer */
    border-top: 4px solid #4a3b2a;
    font-family: 'Comic Neue', sans-serif;
    font-size: 0.9rem;
}

.separator {
    margin: 0 10px;
    opacity: 0.5;
}

/* Hide footer when printing so it looks like a clean worksheet */
@media print {
    .app-footer {
        display: none !important;
    }
}
/* =========================================
   RESTORED: GRAMMAR QUIZ STYLES
========================================= */

/* The Container for the buttons */
.quiz-options {
    display: flex;
    gap: 10px;
    margin-top: 10px;
    margin-bottom: 10px;
}

/* The Buttons (Simple, Compound, Complex) */
.quiz-btn {
    background-color: #e0f2f1; /* Light Teal */
    border: 1px solid #4db6ac;
    color: #004d40;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-family: inherit;
    font-weight: bold;
    font-size: 1rem;
    transition: all 0.2s ease;
}

.quiz-btn:hover {
    background-color: #b2dfdb;
    transform: translateY(-2px);
}

/* The Feedback Box (Hidden by default) */
.quiz-feedback {
    display: none;
    margin-top: 15px;
    padding: 20px;
    border-radius: 8px;
    font-size: 1rem;
    line-height: 1.6;
    animation: fadeIn 0.3s ease-in-out;
}

/* The "Beautiful" Red Box for errors */
.quiz-feedback.incorrect {
    background-color: #ffcdd2; /* Light Red background */
    border: 2px solid #e57373; /* Darker Red border */
    color: #b71c1c; /* Deep Red text */
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

/* The Green Box for success */
.quiz-feedback.correct {
    background-color: #c8e6c9;
    border: 2px solid #81c784;
    color: #1b5e20;
}

/* Animation for the box appearing */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}