/*
 Theme Name:   Davis Archive Childv3.1
 Theme URI:    https://arc.amarvyas.in
 Description:  A minimalist, sidebar-enabled archive theme based on Anders Norén's Davis. Synchronized Media & Spacing.
 Author:       Amar Vyas
 Template:     davis
 Version:      3.1
 Requires at least: 6.3
 Requires PHP: 8.3
 Text Domain:  davis-archive-child
*/

/* ==========================================================================
   1. CSS VARIABLES & BASE THEME
   ========================================================================== */
:root {
    --font-stack: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Kohinoor Devanagari", "Kohinoor Gujarati", "Nirmala UI", "Noto Sans Devanagari", "Noto Sans Gujarati", sans-serif;
	   
    /* Color Palette */
    --bg-color: #E0F4F4;
    --text-color: #2b2b2b;
    --heading-color: #111111; /* Extracted for cleaner Dark Mode handling */
    --accent-color: #315C66;
    --border-color: #C9DFE2;
    --meta-color: #555555;
	--header-bg: #C2ECF1;
	
    /* --- THE UNIFORM WIDTH PANEL --- */
    /* All content elements now synchronize to the exact same visual boundary */
    --text-width: 78ch;            
    --inline-image-width: var(--text-width);    
    --featured-image-width: var(--text-width);  
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg-color: #121212;
        --text-color: #e4e4e4;
        --heading-color: #ffffff;
        --accent-color: #66b3ff;
        --border-color: #333333;
        --meta-color: #aaaaaa;
    }
}

html { 
    scroll-behavior: smooth; 
}

body,
#wrapper,
.site-wrapper {
    font-family: var(--font-stack);
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.75;
	font-family: "Source Serif 4", serif;
	font-size: 1.2rem;
}

/* ==========================================================================
   2. TYPOGRAPHY & READABILITY
   ========================================================================== */

/* Monospace: headings, titles and UI */
h1, h2, h3, h4, h5, h6,
.entry-title,
.site-title,
.post-meta,
.category-links,
.site-nav {
    font-family: "IBM Plex Mono", monospace;
    color: var(--heading-color);
    line-height: 1.25;
}

/* Body text */
.entry-content p,
.entry-content ul,
.entry-content ol,
.entry-content blockquote {
    font-family: "Source Serif 4", serif;
}

/* ==========================================================================
   MAIN READING COLUMN
   ========================================================================== */

.entry-header,
.entry-content,
.post-meta,
.post-navigation,
 {
    max-width: 780px;
    margin-left: auto;
    margin-right: auto;
}

/* Keep text comfortably narrow */
.entry-content p,
.entry-content ul,
.entry-content ol,
.entry-content blockquote {
    max-width: 38em;
    width: 100%;
    text-align: left;
}

/* Headings may be slightly wider */
.entry-content h1,
.entry-content h2,
.entry-content h3,
.entry-content h4 {
    max-width: 85ch;
    text-align: left;
}

/* ==========================================================================
   ENTRY TITLE
   ========================================================================== */

.entry-title {
    font-size: clamp(2rem, 2.5vw + 1rem, 3rem);
	font-family: "IBM Plex Mono", monospace;
    line-height: 1.15;
    margin-top: 0;
    text-align: left;
}
/* ==========================================================================
   HEADING SIZES
   ========================================================================== */
.entry-content h2 {
    font-size: clamp(2rem, 4vw, 2.4rem);
    line-height: 1.2;
}

.entry-content h3 {
    font-size: clamp(1.6rem, 3vw, 1.9rem);
    line-height: 1.3;
}

.entry-content h4 {
    font-size: clamp(1.3rem, 2vw, 1.5rem);
    line-height: 1.4;
}

/* ==========================================================================
   VERTICAL RHYTHM
   ========================================================================== */

.entry-content p,
.entry-content ul,
.entry-content ol {
    margin-top: 0;
    margin-bottom: 1.8rem;
}

.entry-content h1 {
    margin-top: 2rem;
    margin-bottom: 1rem;
}

.entry-content h2 {
    margin-top: 4rem;
    margin-bottom: 1rem;
}

.entry-content h3 {
    margin-top: 3rem;
    margin-bottom: .8rem;
}

.entry-content h4 {
    margin-top: 2.5rem;
    margin-bottom: .6rem;
}

/* Tighten first paragraph after heading */
.entry-content h2 + p,
.entry-content h3 + p,
.entry-content h4 + p {
    margin-top: 0;
}

/* Increase spacing before a heading */
.entry-content p + h2 {
    margin-top: 4rem;
}

.entry-content p + h3 {
    margin-top: 3rem;
}

/* ==========================================================================
   IMAGES
   ========================================================================== */

.entry-content img {
    display: block;
    margin: 2rem auto;
}

.entry-content figure {
    max-width: 980px;
    margin: 2rem auto;
}

/* ==========================================================================
   SPECIAL BOXES
   ========================================================================== */

.translation-box,
.book-box,
.podcast-box,
blockquote,
pre {
    max-width: 760px;
    margin: 2rem auto;
}

/* ==========================================================================
   CODE BLOCKS
   ========================================================================== */

pre {
    background: #D7E4D1;
    border: 1px solid #BDD1B5;
    border-radius: 6px;

    padding: 1.5rem;

    font-family: "JetBrains Mono", monospace;
    font-size: .95rem;
    line-height: 1.7;

    overflow-x: auto;
}

code {
    font-family: "JetBrains Mono", monospace;
}

.decorative-divider,
.separator,
.entry-divider {
    margin-top: 1rem;
    margin-bottom: 1.5rem;
}

.post-meta {
    font-size: .9rem;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: #666;
}

/* ==========================================================================
   LINKS & BLOCKQUOTES
   ========================================================================== */

/* Links */
a { 
    color: #7A4A39; 
    text-decoration: none; 
    transition: color 0.2s ease-in-out, text-decoration 0.2s ease-in-out; 
}
a:hover { 
    text-decoration: underline; 
    text-underline-offset: 4px;
	color: #5E3628;
}

/* Blockquotes */
blockquote, .entry-content blockquote {
    margin: 2.5rem 0;
    padding: 0.5rem 0 0.5rem 1.5rem;
    border-left: 4px solid var(--accent-color);
    font-size: 1.15rem;
    font-style: italic;
    color: var(--meta-color);
	background: #EDF5EA;
    border-left: 5px solid #B8CCAF;
    padding: 1.5rem 2rem;
    border-radius: 4px;
   }

blockquote p { margin-bottom: 0; }


/* ==========================================================================
   3. STRUCTURAL LAYOUT & DESKTOP GRID
   ========================================================================== */
.section-inner, 
.section-inner.thin, 
#site-content .section-inner, 
.site-content .section-inner {
    max-width: 1200px;
    width: 100%;
    box-sizing: border-box;
}

#content, .site-content { 
    max-width: 1200px; 
    margin: 0 auto; 
    padding: 0 2rem; 
}

@media (min-width: 1000px) {
    .site-content > .section-inner, 
    main > .section-inner, 
    #content {
        /* Kept !important here to force grid layout over potential parent flex/block constraints */
        display: grid !important;
        grid-template-columns: minmax(0, 820px) 240px !important;
        gap: 5rem;
        margin: 0 auto;
        align-items: start;
    }
    
    .ez-toc-container, 
    .wp-block-table-of-contents, 
    .toc-wrapper, 
    #site-content .widget, 
    .widget-area {
        position: sticky;
        top: 3rem;
        max-height: calc(100vh - 6rem);
        overflow-y: auto;
        padding-left: 2rem;
        border-left: 1px solid var(--border-color);
        font-size: 0.9rem;
        line-height: 1.6;
    }
}

/* ==========================================================================
   4. DECOUPLED MEDIA SYNCHRONIZATION (Strict Left-Edge Lock)
   ========================================================================== */

/* Structural Layout Envelopes (Containers) */
.featured-image,
.archive-image-link,
.wp-block-image,
figure,
.wp-block-embed,
.wp-block-video {
    width: 100%;
    max-width: var(--text-width); /* Strictly locks right edge to match paragraph width */
    margin: 0 auto 2rem 0;        /* Flushes left edge perfectly with text */
    padding: 0;
    clear: both;
}

/* Inner Media Output Tags simply track their parent envelopes */
img,
iframe,
video,
.featured-image img,
.archive-featured-image,
.wp-block-embed-youtube iframe {
    width: 100%;
    max-width: 100%;
    height: auto;
    display: block;
}

iframe, .wp-block-embed-youtube iframe, .wp-block-video video {
    aspect-ratio: 16 / 9;
    border: none;
    border-radius: 6px;
    background-color: var(--border-color);
}

.archive-featured-image, .featured-image img {
    aspect-ratio: 16 / 9;
    object-fit: cover;
    border-radius: 6px;
}

audio, .wp-block-audio, iframe[src*="hubhopper"], iframe[src*="podcast.co"] {
    aspect-ratio: auto;
    min-height: 150px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
    max-width: var(--text-width);
}

/* Alignment Bounds */
img.aligncenter, .wp-block-image .aligncenter { display: block; margin: 1.5rem auto; }
img.alignleft { float: left; margin: 0.5rem 1.5rem 1.5rem 0; }
img.alignright { float: right; margin: 0.5rem 0 1.5rem 1.5rem; }

/* ==========================================================================
   5. WHITESPACE EXTRACTION & MOBILE OPTIMIZATION (No-Overflow Fix)
   ========================================================================== */
hr, hr.separator, .separator, .post-separator, .archive-separator, .hr.mini {
    display: none;
    margin: 0;
    padding: 0;
    height: 0;
}

#site-header { padding: 1.5rem 0; }
main#site-content, #content, .site-content { padding-top: 0.5rem; }

@media (max-width: 800px) {
    #site-header { 
        padding-top: 1.2rem; 
        padding-bottom: 1.2rem; 
    }
    main#site-content, #content, .site-content { 
        padding-top: 0; 
        margin-top: 0; 
    }
    article { margin-top: 0; }
    
    .archive-image-link, .featured-image { 
        margin-top: 0.75rem; 
        margin-bottom: 1.2rem;
    }

    /* Flat structural stacking */
    .section-inner, .site-content, #content, article {
        width: 100%;
        max-width: 100%;
        padding: 0;
        margin: 0;
    }
    
    /* 1. Apply uniform 1rem safety pads ONLY to Layout Block Containers */
    .entry-content p, .entry-content ul, .entry-content ol, .entry-content blockquote,
    .entry-content h1, .entry-content h2, .entry-content h3, .entry-content h4,
    .entry-header, .post-header, .page-header,
    .featured-image, .archive-image-link, .wp-block-image, figure, .wp-block-embed, .wp-block-audio,
    #header .section-inner, #footer .section-inner {
        width: auto;
        max-width: calc(100% - 2rem);
        margin-left: 1rem;
        margin-right: 1rem;
    }

    /* 2. Strip calculations entirely from raw tags to prevent layout blowouts */
    img, figure img, iframe, audio, video, .featured-image img, .archive-featured-image {
        width: 100%;
        max-width: 100%;
        margin-left: 0;
        margin-right: 0;
        border-radius: 0; /* Square alignment edges maximize tiny displays */
    }

    .alignright, .alignleft, .wp-block-image.alignright, .wp-block-image.alignleft {
        float: none;
        clear: both;
        margin: 1.5rem 0;
        max-width: 100%;
    }

    h1.entry-title, .entry-header h1 {
        font-size: clamp(1.5rem, 5vw + 0.5rem, 2.5rem);
    }
    
    h1, h2, h3, h4, h5, h6, p, a, span, code {
        overflow-wrap: break-word;
        word-wrap: break-word;
    }
}

/* ==========================================================================
   6. HEADER, FOOTER & NAVIGATION STRUCTURE
   ========================================================================== */
.main-menu-clean {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    list-style: none;
    margin: 0;
    padding: 0;
}

.main-menu-clean a { 
    font-weight: 600; 
    color: var(--text-color); 
}

#footer {
    margin-top: 3rem;
    padding: 2rem 0;
    border-top: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    text-align: left;
    color: var(--meta-color);
    font-size: 0.9rem;
}

@media (min-width: 600px) {
    #footer { flex-direction: row; justify-content: space-between; align-items: center; }
}

.footer-menu {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 1.5rem;
    list-style: none;
    margin: 0;
    padding: 0;
}

@media (max-width: 600px) {
    .footer-menu { justify-content: flex-start; }
}


/* ==========================================================================
   7. ARCHIVE PARAMETERS & PRINT STYLES
   ========================================================================== */
article { text-align: left; }
.entry-header { 
    text-align: left; 
    margin-bottom: 1rem; 
}
.entry-header  {
    font-size: 0.9rem;
    color: var(--meta-color);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 1.5rem;
}
.entry-meta {
    font-family: "IBM Plex Mono", monospace;
    font-size: .85rem;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: #666;
}
.post-navigation {
    display: flex;
    justify-content: space-between;
    margin-top: 4rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border-color);
    font-weight: 600;
    margin-bottom: 2rem;
}

@media print {
    #header, #footer, .post-navigation, .back-to-top { display: none; }
    body, #wrapper { background: #fff; color: #000; font-size: 13pt; }
    .site-content, #content, article { max-width: 100%; width: 100%; margin: 0; }
    a { text-decoration: underline; color: #000; }
}

/* ==========================================================================
   8. SINGLE POST RE-ARCHITECTURE & WHITESPACE COLLAPSE
   ========================================================================== */

/* 1. Eliminate structural top paddings on single views */
.single-post-main,
#site-content.single-post-main,
.single-post-main .section-inner {
    padding-top: 0;
    margin-top: 0;
}

.single article {
    margin-top: 0;
}

/* 2. Format the new metadata alignment row beneath the title */
.custom-post-meta {
    font-size: 0.9rem;
    color: var(--meta-color);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 1rem;
    margin-bottom: 2.5rem; /* Space between metadata block and content/images */
    text-align: left;
    line-height: 1.5;
}

.custom-post-meta a {
    color: var(--accent-color);
    font-weight: 700;
}

.meta-divider {
    margin: 0 0.5rem;
    color: var(--border-color);
    font-weight: bold;
}

/* 3. Style the "Last Updated" row natively inline */
.meta-last-updated {
    text-transform: none;
    letter-spacing: normal;
    font-style: italic;
    margin-top: 0.5rem;
    color: var(--meta-color);
    padding-left: 0.75rem;
    border-left: 2px solid var(--border-color);
}

/* 4. Ensure mobile views maintain clean margins for the new meta row */
@media (max-width: 800px) {
    .custom-post-meta {
        max-width: calc(100% - 2rem);
        margin-left: 1rem;
        margin-right: 1rem;
    }
}

/* ==========================================================================
   9. CUSTOM COMPONENTS
   ========================================================================== */

/* Hero Image */
.wp-caption, figure {
    margin-top: 4rem;
    margin-bottom: 4rem;
}

.wp-caption img {
    border-radius: 8px;
}

/* Note Box */
.note-box {
    background: #EEF5E9;
    border-left: 4px solid var(--accent-color);
    padding: 1.5rem;
    margin: 2rem 0;
    border-radius: 6px;
}

/* Pull Quote */ 
.pullquote {
    font-size: 1.3rem;
    line-height: 1.6;
    font-style: italic;
    border-left: 4px solid var(--accent-color);
    padding-left: 1.5rem;
    margin: 3rem 0;
}

/* Podcast Block */

.podcast-box {
    background: #E4EFE8;
    padding: 2rem;
    margin: 3rem 0;
    border-radius: 12px;
	border: 1px solid #C2D7CC;
}

.podcast-box h3 {
    margin-top: 0;
    font-family: Georgia, serif;
}

/*Timeline*/
.timeline {
    position: relative;
    margin: 2rem 0;
    padding-left: 2rem;
}

.timeline::before {
    content: "";
    position: absolute;
    left: 0.6rem;
    top: 0;
    bottom: 0;

    width: 2px;

    background: #bdd1b5;
}

.timeline-item {
    position: relative;
    margin-bottom: 2rem;
}

.timeline-item::before {

    content: "";

    position: absolute;

    left: -1.7rem;

    top: 0.4rem;

    width: 10px;
    height: 10px;

    border-radius: 50%;

    background: #9bb88f;

}

.timeline-year {

    font-family: "IBM Plex Mono", monospace;

    font-size: 1rem;

    font-weight: 600;

    color: #315c66;

    margin-bottom: .3rem;

}

.timeline-text {

    font-family: "Source Serif 4", serif;

    line-height: 1.7;

}

/* Book Block Styling */
.book-box {
    background: #EAF1E5;
    border: 1px solid #C7D8BC;
    border-radius: 10px;
    padding: 2rem;
    margin: 3rem 0;
    max-width: 90ch;
}

/* Specificity fix to override standard entry-content p width */
.book-box p {
    max-width: none;
    width: auto;
    margin-bottom: 1.5rem;
}

.book-title {
    margin-top: 0;
    font-family: Georgia, serif;
}

.book-author {
    color: #777;
    font-style: italic;
}

.book-review {
    font-family: Georgia, serif;
    line-height: 1.9;
    font-size: 1.05rem;
}
/* Glassmorphism Floating Back to Top Button */
#scrollTop {
    position: fixed !important;
    bottom: 30px;
    right: 30px;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background-color: var(--text-color);
    color: var(--bg-color) !important;
    font-size: 1.5rem !important;
    font-weight: bold;
    text-decoration: none !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    z-index: 99999;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: all 0.3s ease-in-out;
}

#scrollTop.is-visible {
    opacity: 0.9;
    visibility: visible;
    transform: translateY(0);
}

#scrollTop:hover {
    opacity: 1 !important;
    transform: translateY(-3px);
}

@media (max-width: 600px) {
    #scrollTop {
        width: 42px;
        height: 42px;
        bottom: 20px;
        right: 20px;
        font-size: 1.25rem !important;
    }
}

/*Info Box*/
.info-box{

    background:#eef5ff;

    border-left:4px solid #4a89dc;

    padding:1.5rem;

    margin:2rem 0;

    border-radius:8px;

    font-size:.95rem;

    font-family:var(--font-stack);
}

/*Searech Bar*/
  .search-form {
    max-width: 24rem;
    margin: 1rem auto;
}

.search-field {
    width: 100%;
    padding: .75rem 1rem;
    background: #f8fbfb;
    border: 1px solid #c9dfe2;
    border-radius: 4px;

    font-family: "IBM Plex Mono", monospace;
    font-size: .9rem;
}

/*Reduce Header Space*/
.entry-header {
    padding-top: 1.7rem;
    margin-bottom: 1.7rem;
}
/*Reduce Divider (diamonds) Spacing*/
.separator {
    margin: 1.2rem auto;
}


/*Categories*/
.main-navigation {
    font-family: "IBM Plex Mono", monospace;
    text-transform: uppercase;
    letter-spacing: .08em;
    font-size: .95rem;
}