/* --- Base Styles & Variables /home/master/django/static/css --- */
:root {
    /* Light Mode Colors */
    --bg-color: #ffffff;
    --text-color: #212529;
    --muted-text-color: #6c757d;
    --accent-color: #007bff;
    --accent-hover-color: #0056b3;
    --border-color: #dee2e6;
    --card-bg-color: #f8f9fa;
    --card-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    --tag-bg: #e9ecef;
    --tag-text: #495057;
    --tag-hover-bg: #d6dce1;

    /* Spacing */
    --spacing-xs: 0.25rem;
    --spacing-sm: 0.5rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2.5rem;

    /* Typography */
    --font-family-sans: 'Inter', system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-weight-light: 300;
    --font-weight-normal: 400;
    --font-weight-medium: 500;
    --font-weight-bold: 700;

    /* Borders */
    --border-radius-sm: 0.25rem;
    --border-radius-md: 0.5rem;

    /* Scroller */
    --scroller-item-width: 93px; /* Consistent width for grid column and figure */

    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root {
        /* Dark Mode Colors */
        --bg-color: #1a1a1a;
        --text-color: #e9ecef;
        --muted-text-color: #adb5bd;
        --accent-color: #0d6efd;
        --accent-hover-color: #3b82f6;
        --border-color: #495057;
        --card-bg-color: #2c2c2c;
        --card-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
        --tag-bg: #343a40;
        --tag-text: #ced4da;
        --tag-hover-bg: #495057;

        color-scheme: dark;
    }
}

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-family-sans);
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    font-weight: var(--font-weight-normal);
}

img, picture, svg, video {
    display: block;
    max-width: 100%;
}

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

h1, h2, h3 {
    line-height: 1.3;
    font-weight: var(--font-weight-bold);
    margin-bottom: var(--spacing-md);
}

h1 {
    font-size: clamp(1.8rem, 5vw, 2.5rem);
    margin-top: var(--spacing-lg);
    margin-bottom: var(--spacing-lg);
}

h2 {
    font-size: clamp(1.4rem, 4vw, 1.8rem);
    font-weight: var(--font-weight-medium);
}
h2 a {
    color: inherit; /* Make header link same color as text */
}
h2 a:hover {
     color: var(--accent-color); /* Underline on hover */
}


/* --- Layout: Container --- */
.container {
    width: 100%;
    max-width: 1200px; /* Adjust as needed */
    margin-left: auto;
    margin-right: auto;
    padding-left: var(--spacing-md);
    padding-right: var(--spacing-md);
}

main.container {
    flex-grow: 1; /* Ensure main content pushes footer down */
    padding-top: var(--spacing-lg);
    padding-bottom: var(--spacing-xl);
}

/* --- Site Header / Search --- */
.site-header {
    background-color: var(--card-bg-color);
    padding: var(--spacing-sm) 0;
    border-bottom: 1px solid var(--border-color);
    position: sticky; /* Keep header visible */
    top: 0;
    z-index: 100;
    box-shadow: var(--card-shadow);
}

.site-header .container {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
}

.logo {
    font-size: 1.8rem;
    text-decoration: none;
}

.search-form {
    display: flex;
    align-items: center;
    flex-grow: 1;
    max-width: 400px; /* Limit search width */
}

.search-form input[type="search"] {
    flex-grow: 1;
    padding: 0.6em 1em;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md) 0 0 var(--border-radius-md);
    font-size: 0.9rem;
    background-color: var(--bg-color);
    color: var(--text-color);
    min-width: 100px; /* Ensure it doesn't collapse */
}
.search-form input[type="search"]:focus {
    outline: 2px solid var(--accent-color);
    outline-offset: -1px;
    border-color: var(--accent-color);
    z-index: 1; /* Bring to front on focus */
}

.search-form button {
    padding: 0.6em 1em;
    border: 1px solid var(--accent-color);
    background-color: var(--accent-color);
    color: white;
    border-radius: 0 var(--border-radius-md) var(--border-radius-md) 0;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: var(--font-weight-medium);
    transition: background-color 0.2s ease;
    margin-left: -1px; /* Overlap border */
}
.search-form button:hover,
.search-form button:focus {
    background-color: var(--accent-hover-color);
    border-color: var(--accent-hover-color);
    outline: none;
}


/* --- List Section --- */
.list-section {
    margin-bottom: var(--spacing-xl);
}

.list-header {
    margin-bottom: var(--spacing-md);
}
.list-header h2 {
    margin-bottom: var(--spacing-xs);
}

.tags {
    display: flex;
    flex-wrap: wrap;
    gap: var(--spacing-xs) var(--spacing-sm);
}

.tag {
    display: inline-block;
    background-color: var(--tag-bg);
    color: var(--tag-text);
    padding: 0.2em 0.6em;
    border-radius: var(--border-radius-sm);
    font-size: 0.75rem;
    font-weight: var(--font-weight-medium);
    text-decoration: none;
    transition: background-color 0.2s ease, color 0.2s ease;
}
.tag:hover {
    background-color: var(--tag-hover-bg);
    color: var(--text-color);
    text-decoration: none;
}

/* --- Horizontal Scroller --- */
.horizontal-media-scroller {
    position: relative; /* For fadeout positioning */
}

.media-list {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: var(--scroller-item-width); /* Use variable for grid track size */
    gap: var(--spacing-md);
    list-style: none;
    padding: var(--spacing-sm) 0; /* top/bottom only; first/last covers align with the container content edge */
    margin: 0; /* No negative margin: the scroller must not bleed past its container */

    overflow-x: auto;
    overscroll-behavior-inline: contain; /* Prevent parent scroll */
    scroll-snap-type: inline mandatory; /* Optional: snap scrolling */
    scrollbar-width: thin; /* Firefox */
    scrollbar-color: var(--border-color) transparent; /* Firefox */
}
/* Webkit scrollbar styling */
.media-list::-webkit-scrollbar {
  height: 8px;
}
.media-list::-webkit-scrollbar-track {
  background: transparent;
}
.media-list::-webkit-scrollbar-thumb {
  background-color: var(--border-color);
  border-radius: 10px;
  border: 2px solid transparent; /* Creates padding around thumb */
  background-clip: content-box;
}
.media-list::-webkit-scrollbar-thumb:hover {
  background-color: var(--muted-text-color);
}


.media-element {
    scroll-snap-align: start; /* Optional: snap scrolling */
    display: block; /* Ensure li takes up grid space */
}

.book-link {
    display: block;
    text-decoration: none;
    color: inherit;
    outline-offset: 4px;
    border-radius: var(--border-radius-md);
    transition: transform 0.2s ease-out, box-shadow 0.2s ease-out;
}
.book-link:hover,
.book-link:focus {
    text-decoration: none;
    transform: translateY(-4px); /* Slight lift effect */
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.1);
}
.book-link:focus {
     outline: 2px solid var(--accent-color);
}


/* Optional: Add a fade-out effect at the end of the scroller */
.scroller-fadeout {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 50px; /* Width of the fade */
    background: linear-gradient(to left, var(--bg-color), transparent);
    pointer-events: none; /* Don't interfere with scrolling */
    visibility: hidden; /* Hide by default */
}

/* Show fade only if content overflows */
.horizontal-media-scroller:has(.media-list:scroll) .scroller-fadeout {
    /* This requires browser support for :has() and :scroll, might not work everywhere yet */
    /* visibility: visible; */
     /* Fallback: always show if needed, or use JS */
     visibility: visible; /* Adjust as needed based on testing */
}

/* --- Book Cover Size --- */
.media-list .media-element .book-link figure {
    margin: 0;
     width: 93px;/* Use variable for figure width */
    height: 140px; /* Keep height fixed or make it proportional if desired */
    overflow: hidden;
    display: block;
    background-color: #f0f0f0; /* Placeholder background */
    border-radius: var(--border-radius-sm);
    box-shadow: var(--card-shadow);
}

.media-list .media-element .book-link figure picture,
.media-list .media-element .book-link figure picture img {
    display: block;
    width: 100%;
    height: 100%;
}

.media-list .media-element .book-link figure picture img {
    object-fit: cover; /* Ensure image covers the area */
}

/* --- Book Popup (Desktop) --- */
.book-popup {
    display: none; /* Hidden by default */
    position: absolute; /* Positioned by JS */
    background: var(--card-bg-color);
    border: 1px solid var(--border-color);
    padding: var(--spacing-md);
    border-radius: var(--border-radius-md);
    box-shadow: 0 5px 15px rgba(0,0,0,0.15);
    max-width: 320px;
    z-index: 1001;
    font-size: 0.9rem;
    visibility: hidden; /* Used for smoother positioning */
}
.book-popup.active {
    display: block; /* Show when active class is added */
}
.book-popup h3 {
    font-size: 1.1rem;
    margin-bottom: var(--spacing-sm);
}
.book-popup h3 a {
    color: inherit;
}
.book-popup h3 a:hover {
    color: var(--accent-color);
}
.book-popup .authors {
    font-size: 0.85rem;
    color: var(--muted-text-color);
    margin-bottom: var(--spacing-sm);
    font-style: italic;
}
.book-popup .description {
    font-size: 0.85rem;
    color: var(--text-color);
    line-height: 1.5;
}

/* --- Mobile Modal Styles (Add if needed, or adapt .book-details-mobile) --- */
.book-modal-overlay {
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.6); /* Semi-transparent background */
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1002;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    padding: var(--spacing-md);
}

.book-modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.book-modal-content {
    background-color: var(--card-bg-color);
    padding: var(--spacing-lg);
    border-radius: var(--border-radius-md);
    max-width: 500px;
    width: 100%;
    max-height: 80vh; /* Limit height */
    overflow-y: auto; /* Allow scrolling if content overflows */
    position: relative;
    box-shadow: var(--card-shadow);
    transform: scale(0.95);
    transition: transform 0.3s ease;
}

.book-modal-overlay.active .book-modal-content {
    transform: scale(1);
}

.book-modal-close {
    position: absolute;
    top: var(--spacing-sm);
    right: var(--spacing-sm);
    background: none;
    border: none;
    font-size: 1.8rem;
    line-height: 1;
    color: var(--muted-text-color);
    cursor: pointer;
    padding: var(--spacing-xs);
}
.book-modal-close:hover {
    color: var(--text-color);
}

#bookModalBody h3 { /* Style heading inside modal */
    font-size: 1.3rem;
    margin-top: 0; /* Remove potential top margin */
    margin-bottom: var(--spacing-sm);
}
#bookModalBody h3 a { color: inherit; }
#bookModalBody h3 a:hover { color: var(--accent-color); }

#bookModalBody .authors { /* Style authors inside modal */
    font-size: 0.9rem;
    color: var(--muted-text-color);
    margin-bottom: var(--spacing-md);
    font-style: italic;
}
#bookModalBody .description { /* Style description inside modal */
    font-size: 0.9rem;
    margin-bottom: var(--spacing-md);
    line-height: 1.6;
}
#bookModalBody .cta-link { /* Style the Amazon link */
    display: inline-block;
    margin-top: var(--spacing-sm);
    padding: 0.5em 1em;
    background-color: var(--accent-color);
    color: #ffffff;
    border-radius: var(--border-radius-sm);
    text-decoration: none;
    font-weight: var(--font-weight-medium);
    transition: background-color 0.2s ease;
}
#bookModalBody .cta-link:hover {
    background-color: var(--accent-hover-color);
    color: #ffffff; /* Ensure text remains white on hover */
    text-decoration: none;
}

/* --- Pagination --- */
.pagination-container {
    width: 100%;
    margin: var(--spacing-xl) 0 var(--spacing-md) 0;
    font-family: var(--font-family-sans);
}

.pagination-wrapper {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: var(--spacing-xs);
    padding: var(--spacing-sm);
}

.pagination-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2.2rem;
    height: 2.2rem;
    padding: 0 0.6rem;
    margin: 0 0.1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    background-color: var(--bg-color);
    color: var(--text-color);
    font-size: 0.85rem;
    font-weight: var(--font-weight-medium);
    text-decoration: none;
    transition: all 0.2s ease;
}

.pagination-link:hover {
    background-color: var(--card-bg-color);
    border-color: var(--muted-text-color);
    color: var(--accent-color);
    text-decoration: none;
}

.pagination-link.current {
    background-color: var(--accent-color);
    border-color: var(--accent-color);
    color: #ffffff;
    font-weight: var(--font-weight-bold);
    pointer-events: none;
}

.pagination-numbers {
    display: flex;
    align-items: center;
    gap: 0.1rem;
}

.pagination-ellipsis {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.5rem;
    height: 2.2rem;
    color: var(--muted-text-color);
    padding: 0 var(--spacing-xs);
}

.first-page,
.last-page,
.prev-page,
.next-page {
    display: inline-flex;
    align-items: center;
    gap: var(--spacing-xs);
    padding: 0 0.8rem;
}
.prev-page .pagination-text,
.next-page .pagination-text {
    display: none; /* Hide prev/next text on mobile by default */
}
@media (min-width: 500px) {
    .prev-page .pagination-text,
    .next-page .pagination-text {
        display: inline; /* Show text on larger screens */
    }
}

.pagination-icon {
    font-size: 1.1rem;
    line-height: 1;
}

.pagination-info {
    text-align: center;
    margin-top: var(--spacing-sm);
    color: var(--muted-text-color);
    font-size: 0.8rem;
}


/* --- Footer --- */
.site-footer-bottom {
    background-color: var(--card-bg-color);
    border-top: 1px solid var(--border-color);
    padding: var(--spacing-md) 0;
    margin-top: var(--spacing-xl);
    font-size: 0.85rem;
    color: var(--muted-text-color);
}
.site-footer-bottom .container {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--spacing-sm) var(--spacing-md);
}
.site-footer-bottom a {
    color: var(--muted-text-color);
}
.site-footer-bottom a:hover {
    color: var(--accent-color);
}


/* --- Accessibility & Reduced Motion --- */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto; /* Disable smooth scrolling */
  }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
   .book-link:hover,
    .book-link:focus {
        transform: none; /* Disable lift */
    }
    .book-modal-overlay,
    .book-modal-content {
        transition: none; /* Disable modal transitions */
    }
}

/* High Contrast Mode */
@media (forced-colors: active) {
    .pagination-link, .search-form button, .tag, #bookModalBody .cta-link {
        border: 1px solid;
    }
    .pagination-link.current {
        border-width: 2px;
        font-weight: bold;
        forced-color-adjust: none; /* Allow background/color */
        background-color: Highlight;
        color: HighlightText;
    }
     .book-popup, .book-modal-content {
         border: 2px solid;
     }
     .book-modal-close {
         color: ButtonText; /* Ensure close button is visible */
     }
      #bookModalBody .cta-link {
         forced-color-adjust: none; /* Allow background/color */
         background-color: Highlight;
         color: HighlightText;
     }
}

/* --- END OF modern_style.css --- */