/* ============================================
   Little Lake Forest Tales - Custom Styling
   Τυπογραφική Βελτίωση για Online Ανάγνωση
   Mobile-First, Touch-Optimized Design
   ============================================ */

/* Global mobile optimizations - Based on 2024/2025 Best Practices */
* {
    -webkit-tap-highlight-color: rgba(45, 106, 79, 0.2);
    -webkit-touch-callout: none;
}

html {
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
    /* Prevent horizontal scrolling */
    overflow-x: hidden;
}

body {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    /* Prevent layout shift */
    overflow-x: hidden;
}

/* Performance optimization for mobile */
.story-card,
.md-content article img {
    will-change: transform;
    transform: translateZ(0);
    backface-visibility: hidden;
}

/* ==========================================
   1. TYPOGRAPHY - Book Reading Experience
   ========================================== */

/* Import serif font for story content */
@import url('https://fonts.googleapis.com/css2?family=Merriweather:ital,wght@0,400;0,700;1,400&family=Lora:ital,wght@0,400;0,600;1,400&display=swap');

/* Main content typography */
.md-content article {
    font-family: 'Merriweather', Georgia, serif;
    font-size: 18px;
    line-height: 1.9;
    color: #2c2c2c;
}

/* Limit content width for book-like reading */
.md-content__inner {
    max-width: 700px;
    margin-left: auto;
    margin-right: auto;
    padding: 2rem 1.5rem;
}

/* Story paragraphs - more breathing room */
.md-content article p {
    margin-bottom: 1.4em;
    text-align: justify;
}

/* Headers keep sans-serif but styled */
.md-content h1,
.md-content h2,
.md-content h3 {
    font-family: 'Roboto', sans-serif;
    color: #2d6a4f;
    font-weight: 600;
    margin-top: 2em;
    margin-bottom: 1em;
}

.md-content h1 {
    font-size: 2.2em;
    line-height: 1.3;
    border-bottom: 3px solid #2d6a4f;
    padding-bottom: 0.5em;
}

/* First h1 on page - align with sidebar */
.md-content article > h1:first-child {
    margin-top: 0;
}

.md-content h2 {
    font-size: 1.6em;
    color: #52b788;
}

/* ==========================================
   2. COLORS - Forest Theme
   ========================================== */

/* Soft cream background */
[data-md-color-scheme="default"] {
    --md-default-bg-color: #faf8f5;
    --md-default-fg-color: #2c2c2c;
}

/* Primary forest green */
[data-md-color-scheme="default"] .md-header {
    background-color: #2d6a4f;
}

/* Links - water blue */
.md-content a {
    color: #1e88e5;
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: all 0.2s ease;
}

.md-content a:hover {
    color: #1565c0;
    border-bottom-color: #1e88e5;
}

/* ==========================================
   3. IMAGES - Enhanced Presentation
   ========================================== */

/* Story images */
.md-content article img {
    border-radius: 12px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
    margin: 0.5em auto 1.5em auto;
    display: block;
    max-width: 100%;
    height: auto;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.md-content article img:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

/* Image captions */
.md-content article img + em,
.md-content article p:has(img) + p em {
    display: block;
    text-align: center;
    color: #6c757d;
    font-size: 0.9em;
    margin-top: -1.5em;
    margin-bottom: 2em;
    font-style: italic;
}

/* ==========================================
   4. STORY SPECIFIC STYLING
   ========================================== */

/* Drop cap - first letter of story */
.md-content article > p:first-of-type::first-letter {
    font-size: 3.5em;
    line-height: 0.9;
    float: left;
    margin: 0.1em 0.1em 0 0;
    color: #2d6a4f;
    font-weight: 700;
    font-family: 'Lora', Georgia, serif;
}

/* Dialogue styling - Greek quotes */
.md-content article p:has(> :is(«, »)) {
    padding-left: 1.5em;
    border-left: 3px solid #d4edda;
    background: linear-gradient(to right, #f1f9f4 0%, transparent 100%);
    padding-top: 0.5em;
    padding-bottom: 0.5em;
    margin: 1em 0;
    border-radius: 0 8px 8px 0;
}

/* Bold character names */
.md-content article strong {
    color: #2d6a4f;
    font-weight: 600;
}

/* Section breaks */
.md-content article hr {
    border: none;
    text-align: center;
    margin: 3em auto;
    position: relative;
    height: 2em;
}

.md-content article hr::after {
    content: "🌿 ✨ 🌿";
    font-size: 1.5em;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    background: var(--md-default-bg-color);
    padding: 0 1em;
}

/* ==========================================
   5. STORY CARDS - Homepage & Index
   ========================================== */

/* Hero section on homepage */
.hero-section {
    margin-top: 0;
    margin-bottom: 1.5rem;
}

.hero-section h2 {
    margin-top: 0.5em !important;
    margin-bottom: 0.3em;
}

.hero-section p {
    margin-bottom: 0.8em;
}

.hero-section em {
    display: block;
    margin-bottom: 0.5em;
}

/* Story cards container */
.story-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 2rem;
    margin: 2rem 0;
}

/* Individual story card */
.story-card {
    background: white;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
    border: 2px solid transparent;
    position: relative;
}

.story-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 12px 32px rgba(45, 106, 79, 0.2);
    border-color: #52b788;
}

/* Story card image */
.story-card-image {
    width: 100%;
    height: 200px;
    object-fit: cover;
    display: block;
    margin-bottom: 0 !important;
}

/* Story card content */
.story-card-content {
    padding: 0 1.5rem 1.5rem 1.5rem !important;
}

.story-card-title {
    font-family: 'Roboto', sans-serif;
    font-size: 1.3em;
    font-weight: 600;
    color: #2d6a4f;
    margin: 0.5em 0 0.5em 0 !important;
    line-height: 1.3;
}

.story-card-excerpt {
    font-family: 'Merriweather', Georgia, serif;
    font-size: 0.95em;
    color: #555;
    line-height: 1.6;
    margin-bottom: 1em;
}

.story-card-link {
    display: inline-block;
    color: #1e88e5;
    font-weight: 600;
    text-decoration: none;
    font-size: 0.9em;
    transition: color 0.2s ease;
}

.story-card-link:hover {
    color: #1565c0;
}

.story-card-link::after {
    content: " →";
    transition: transform 0.2s ease;
    display: inline-block;
}

.story-card-link:hover::after {
    transform: translateX(4px);
}

/* Story number badge */
.story-number {
    position: absolute;
    top: 12px;
    right: 12px;
    background: rgba(45, 106, 79, 0.9);
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.2em;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    z-index: 10;
}

/* ==========================================
   6. NAVIGATION ENHANCEMENTS
   ========================================== */

/* Next/Previous story navigation */
.story-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 3rem 0 2rem 0;
    padding: 2rem;
    background: linear-gradient(135deg, #d4edda 0%, #c3e6cb 100%);
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.story-nav-button {
    display: inline-flex;
    align-items: center;
    padding: 0.8rem 1.5rem;
    background: white;
    color: #2d6a4f;
    text-decoration: none;
    border-radius: 8px;
    font-weight: 600;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.story-nav-button:hover {
    background: #2d6a4f;
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(45, 106, 79, 0.3);
}

/* Breadcrumbs enhancement */
.md-breadcrumbs {
    font-size: 0.9em;
}

/* ==========================================
   7. SPECIAL ELEMENTS
   ========================================== */

/* Admonition boxes styling */
.md-typeset .admonition {
    border-radius: 12px;
    border-left: 4px solid #2d6a4f;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

/* Task lists */
.md-typeset .task-list-item {
    list-style: none;
}

.md-typeset .task-list-control .task-list-indicator::before {
    background-color: #52b788;
}

/* ==========================================
   8. HOMEPAGE HERO SECTION
   ========================================== */

.hero-section {
    text-align: center;
    padding: 3rem 1rem;
    background: linear-gradient(135deg, #d4edda 0%, #f1f9f4 100%);
    border-radius: 16px;
    margin-bottom: 3rem;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
}

.hero-title {
    font-size: 2.5em;
    color: #2d6a4f;
    margin-bottom: 0.5em;
    font-family: 'Lora', Georgia, serif;
}

.hero-subtitle {
    font-size: 1.2em;
    color: #52b788;
    font-style: italic;
    margin-bottom: 1em;
}

.hero-description {
    font-size: 1.1em;
    color: #555;
    max-width: 600px;
    margin: 0 auto 2em auto;
    line-height: 1.7;
}

/* ==========================================
   9. RESPONSIVE DESIGN - Mobile Optimized
   ========================================== */

/* Tablets (768px and below) */
@media screen and (max-width: 768px) {
    /* Typography adjustments */
    .md-content article {
        font-size: 17px;
        line-height: 1.8;
    }

    .md-content__inner {
        padding: 1.5rem 1rem;
        max-width: 100%;
    }

    /* Story cards - single column */
    .story-cards {
        grid-template-columns: 1fr;
        gap: 2rem;
    }

    /* Hero section */
    .hero-title {
        font-size: 2em;
    }

    .hero-description {
        font-size: 1em;
    }

    /* Story navigation */
    .story-nav {
        flex-direction: column;
        gap: 1rem;
        padding: 1.5rem;
    }

    .story-nav-button {
        width: 100%;
        justify-content: center;
    }

    /* Headers */
    .md-content h1 {
        font-size: 1.8em;
    }

    .md-content h2 {
        font-size: 1.4em;
    }
}

/* Mobile phones (480px and below) - Touch Optimized */
@media screen and (max-width: 480px) {
    /* Enhanced mobile typography */
    .md-content article {
        font-size: 16px;
        line-height: 1.75;
    }

    .md-content article p {
        margin-bottom: 1.2em;
    }

    /* Remove drop cap on very small screens */
    .md-content article > p:first-of-type::first-letter {
        font-size: 2.5em;
        margin: 0.05em 0.08em 0 0;
    }

    /* Mobile-friendly content width */
    .md-content__inner {
        padding: 1rem 0.75rem;
    }

    /* Touch-friendly story cards */
    .story-card {
        border-radius: 12px;
        margin-bottom: 0.5rem;
    }

    .story-card-image {
        height: 180px;
    }

    .story-card-content {
        padding: 1.25rem;
    }

    .story-card-title {
        font-size: 1.2em;
        margin-bottom: 0.75em;
    }

    .story-card-excerpt {
        font-size: 0.9em;
        line-height: 1.5;
    }

    /* Larger tap targets for links */
    .story-card-link {
        display: inline-block;
        padding: 0.5rem 0;
        font-size: 1em;
    }

    /* Story number badge - slightly smaller */
    .story-number {
        width: 36px;
        height: 36px;
        font-size: 1.1em;
        top: 10px;
        right: 10px;
    }

    /* Hero section mobile */
    .hero-section {
        padding: 2rem 1rem;
        margin-bottom: 2rem;
    }

    .hero-title {
        font-size: 1.6em;
        line-height: 1.3;
    }

    .hero-subtitle {
        font-size: 1em;
    }

    .hero-description {
        font-size: 0.95em;
        line-height: 1.6;
    }

    /* Mobile headers */
    .md-content h1 {
        font-size: 1.6em;
        margin-top: 1.5em;
        padding-bottom: 0.3em;
    }

    .md-content h2 {
        font-size: 1.3em;
        margin-top: 1.5em;
    }

    /* Images - full width on mobile */
    .md-content article img {
        margin: 1.5em 0;
        border-radius: 10px;
        width: 100%;
    }

    /* Dialogue styling - less padding on mobile */
    .md-content article p:has(> :is(«, »)) {
        padding-left: 1em;
        padding-right: 0.5em;
        border-left-width: 2px;
    }

    /* Section breaks - smaller on mobile */
    .md-content article hr::after {
        font-size: 1.2em;
        padding: 0 0.5em;
    }

    /* Links - larger tap targets */
    .md-content a {
        padding: 0.2em 0;
        display: inline-block;
    }

    /* Story cards gap */
    .story-cards {
        gap: 1.75rem;
    }
}

/* Large phones (iPhone 14 Pro Max, etc - 430px) */
@media screen and (min-width: 390px) and (max-width: 480px) {
    .md-content article {
        font-size: 16.5px;
    }

    .story-card-image {
        height: 200px;
    }
}

/* Small phones (iPhone SE, older Androids - 375px and below) */
@media screen and (max-width: 375px) {
    .md-content article {
        font-size: 15px;
        line-height: 1.7;
    }

    .hero-title {
        font-size: 1.4em;
    }

    .story-card-image {
        height: 160px;
    }

    .story-card-content {
        padding: 1rem;
    }

    .story-number {
        width: 32px;
        height: 32px;
        font-size: 1em;
    }
}

/* Touch device optimizations - Best Practices 2024/2025 */
@media (hover: none) and (pointer: coarse) {
    /* Minimum 44x44px tap targets (Apple/Google guidelines) */
    .story-card-link,
    .story-nav-button,
    .md-content a {
        min-height: 44px;
        min-width: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    /* Remove hover effects on touch devices */
    .story-card:hover {
        transform: none;
    }

    /* Add active state instead - Visual feedback for touches */
    .story-card:active {
        transform: scale(0.98);
        transition: transform 0.1s ease;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    }

    .story-card-link:active,
    .story-nav-button:active {
        opacity: 0.8;
        background-color: rgba(45, 106, 79, 0.1);
    }

    /* Touch-friendly spacing - 8px minimum between tap targets */
    .story-cards {
        gap: 2rem;
    }

    /* Prevent text selection on tap (children's book UX) */
    .story-card-title,
    .story-card-excerpt {
        -webkit-user-select: none;
        user-select: none;
    }

    /* Enable smooth kinetic scrolling on iOS */
    .md-content,
    .story-cards {
        -webkit-overflow-scrolling: touch;
    }
}

/* Landscape mode on phones */
@media screen and (max-height: 500px) and (orientation: landscape) {
    .hero-section {
        padding: 1.5rem 1rem;
    }

    .md-content article {
        font-size: 15px;
    }

    .story-card-image {
        height: 140px;
    }
}

/* ==========================================
   10. PRINT STYLES - Book Format
   ========================================== */

@media print {
    .md-header,
    .md-sidebar,
    .md-footer,
    .md-nav,
    .story-nav {
        display: none !important;
    }

    .md-content article {
        font-size: 12pt;
        line-height: 1.6;
        max-width: 100%;
    }

    .md-content article img {
        page-break-inside: avoid;
        max-width: 80%;
        margin: 1cm auto;
    }

    .md-content h1 {
        page-break-after: avoid;
    }
}

/* ==========================================
   11. DARK MODE ADJUSTMENTS
   ========================================== */

[data-md-color-scheme="slate"] .md-content article {
    color: #e0e0e0;
}

[data-md-color-scheme="slate"] .story-card {
    background: #2d3748;
    border-color: #4a5568;
}

[data-md-color-scheme="slate"] .story-card-title {
    color: #52b788;
}

[data-md-color-scheme="slate"] .story-card-excerpt {
    color: #cbd5e0;
}

[data-md-color-scheme="slate"] .hero-section {
    background: linear-gradient(135deg, #2d3748 0%, #1a202c 100%);
}

/* ==========================================
   12. ACCESSIBILITY IMPROVEMENTS
   ========================================== */

/* Focus states */
a:focus,
button:focus {
    outline: 3px solid #f4a261;
    outline-offset: 2px;
}

/* High contrast for readability */
.md-content article strong {
    font-weight: 700;
}

/* Selection styling */
::selection {
    background: #f4a261;
    color: white;
}
