/*
Theme Name: Daniel Millán
Theme URI: https://dbmillan.com
Author: Daniel Millán
Description: A minimal photography / projects portfolio theme. Static homepage with image grid, "Makings" blog list, single posts with prev/next, and an About/Contact template.
Version: 1.5
License: GPL v2 or later
Text Domain: daniel-millan
*/

/* ========== BASE ========== */
*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
    margin: 0;
    padding: 0;
    background-color: var(--dm-bg, #ebe2d0);          /* cream */
    color: #1a1a1a;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: 16px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
a:hover { text-decoration: underline; }

img { max-width: 100%; height: auto; display: block; }

p { margin: 0 0 1em; }

/* ========== LAYOUT WRAPPER ========== */
.site-container {
    max-width: 1680px;
    margin: 0 auto;
    padding: 0 var(--dm-pad-container, 40px);
}

.site-main {
    min-height: 60vh;
    padding-bottom: 80px;
}

/* ========== HEADER ========== */
.site-header { padding: 36px 0 var(--dm-pad-header, 60px); }

.site-header-inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
}

.site-title {
    font-size: 18px;
    font-weight: 700;
    margin: 0;
    letter-spacing: 0.01em;
}
.site-title a:hover { text-decoration: none; }

.header-right {
    display: flex;
    align-items: center;
    gap: 40px;
}

.main-nav ul {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    align-items: center;
    gap: 40px;
}
.main-nav a { font-size: 16px; }
.main-nav .current-menu-item > a,
.main-nav .current_page_item > a,
.main-nav .current-page-ancestor > a {
    text-decoration: underline;
    text-underline-offset: 4px;
}

.instagram-link { display: inline-flex; }
.instagram-icon { width: 22px; height: 22px; display: block; }

/* ========== HOME GRID ========== */
.home-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--dm-grid-gap, 40px);
}

.home-image {
    background: #ffffff;
    aspect-ratio: 1 / 1;
    overflow: hidden;
    width: 100%;
    position: relative;
}
.home-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.home-image-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    color: #c4bba6;
    font-size: 14px;
}

/* When a home image has a link (rendered as <a>), give a subtle hover hint
   and make sure no underline leaks onto the overlay text inside the wide cell. */
a.home-image {
    transition: opacity 0.2s ease;
    text-decoration: none;
}
a.home-image:hover {
    opacity: 0.85;
    text-decoration: none;
}
a.home-image:hover .home-overlay-title,
a.home-image:hover .home-overlay-sub,
a.home-image:hover .home-overlay-loc { text-decoration: none; }

.home-image-wide {
    grid-column: 1 / -1;
    aspect-ratio: 2 / 1;
    position: relative;
    background: #1a1a1a;
    margin-top: var(--dm-wide-gap, 0px);
}
.home-image-wide img { width: 100%; height: 100%; object-fit: cover; }

.home-overlay {
    position: absolute;
    max-width: 80%;
    top:    var(--ov-top,    auto);
    right:  var(--ov-right,  auto);
    bottom: var(--ov-bottom, auto);
    left:   var(--ov-left,   auto);
    color:  var(--ov-color,  #1a1a1a);
    text-align: var(--ov-align, left);
}

/* Position modifiers — each maps its corner anchors and per-position vars
   into the generic overlay vars used by .home-overlay above. */
.home-overlay.position-tl {
    --resolved-pad: var(--ov-tl-pad, 40px);
    --ov-top:  var(--resolved-pad);
    --ov-left: var(--resolved-pad);
    --ov-color:      var(--ov-tl-color, #1a1a1a);
    --ov-size-title: var(--ov-tl-size-title, 28px);
    --ov-size-sub:   var(--ov-tl-size-sub, 28px);
    --ov-size-loc:   var(--ov-tl-size-loc, 14px);
}
.home-overlay.position-tr {
    --resolved-pad: var(--ov-tr-pad, 40px);
    --ov-top:   var(--resolved-pad);
    --ov-right: var(--resolved-pad);
    --ov-align: right;
    --ov-color:      var(--ov-tr-color, #1a1a1a);
    --ov-size-title: var(--ov-tr-size-title, 28px);
    --ov-size-sub:   var(--ov-tr-size-sub, 28px);
    --ov-size-loc:   var(--ov-tr-size-loc, 14px);
}
.home-overlay.position-bl {
    --resolved-pad: var(--ov-bl-pad, 40px);
    --ov-bottom: var(--resolved-pad);
    --ov-left:   var(--resolved-pad);
    --ov-color:      var(--ov-bl-color, #ffffff);
    --ov-size-title: var(--ov-bl-size-title, 28px);
    --ov-size-sub:   var(--ov-bl-size-sub, 28px);
    --ov-size-loc:   var(--ov-bl-size-loc, 14px);
}
.home-overlay.position-br {
    --resolved-pad: var(--ov-br-pad, 40px);
    --ov-bottom: var(--resolved-pad);
    --ov-right:  var(--resolved-pad);
    --ov-align:  right;
    --ov-color:      var(--ov-br-color, #ffffff);
    --ov-size-title: var(--ov-br-size-title, 28px);
    --ov-size-sub:   var(--ov-br-size-sub, 28px);
    --ov-size-loc:   var(--ov-br-size-loc, 14px);
}

.home-overlay-title {
    font-size: var(--ov-size-title, 28px);
    font-weight: 700;
    margin: 0;
    line-height: 1.15;
}
.home-overlay-sub {
    font-size: var(--ov-size-sub, 28px);
    font-weight: 700;
    margin: 0 0 10px;
    line-height: 1.15;
}
.home-overlay-loc { font-size: var(--ov-size-loc, 14px); margin: 0; }

/* ========== PAGE / BLOG LIST ========== */
.page-title {
    font-size: 32px;
    font-weight: 700;
    margin: 0 0 18px;
    line-height: 1.2;
}

.page-intro {
    max-width: 1200px;
    margin: 0 0 60px;
}

.posts-list {
    display: flex;
    flex-direction: column;
    gap: 60px;
}

.post-item {
    display: grid;
    grid-template-columns: 600px 1fr;
    gap: 60px;
    align-items: start;
}

.post-thumb-link { display: block; }
.post-thumb {
    width: 600px;
    height: 300px;
    overflow: hidden;
    background: #1a1a1a;
}
.post-thumb img { width: 100%; height: 100%; object-fit: cover; }

.post-thumb-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    opacity: 0.85;
}
.post-thumb-placeholder svg { width: 60px; height: 60px; }

.post-content-preview { padding-top: 10px; }
.post-content-preview .post-title {
    font-size: 26px;
    font-weight: 400;
    margin: 0 0 24px;
    line-height: 1.2;
}
.post-content-preview .post-title a:hover { text-decoration: underline; }

.post-excerpt { margin: 0 0 24px; }
.continue-reading { font-size: 15px; }

/* ========== PAGINATION ========== */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 16px;
    margin: 80px 0 40px;
    font-size: 16px;
}
.pagination .page-numbers {
    padding: 6px 10px;
    color: #1a1a1a;
    text-decoration: none;
}
.pagination .page-numbers:hover { text-decoration: underline; }
.pagination .current {
    font-weight: 700;
    text-decoration: underline;
    text-underline-offset: 4px;
}
.pagination .dots { padding: 6px 4px; }

/* ========== SINGLE POST ========== */
.single-post {
    max-width: 1440px;
    margin: 0 auto;
}

.featured-image {
    width: 100%;
    aspect-ratio: 2 / 1;
    overflow: hidden;
    margin-bottom: 12px;
    background: #1a1a1a;
}
.featured-image img { width: 100%; height: 100%; object-fit: cover; }

.featured-caption {
    text-align: right;
    font-size: 13px;
    font-style: italic;
    color: #555;
    margin: 0 0 30px;
}

.post-header {
    text-align: center;
    margin-bottom: 40px;
}
.single-post .post-header .post-title {
    font-size: 30px;
    font-weight: 400;
    margin: 0 0 10px;
    line-height: 1.25;
}
.post-meta { font-size: 14px; color: #555; }

.post-content {
    line-height: 1.65;
    font-size: 15px;
}
.post-content p { margin: 0 0 1.2em; }
.post-content img { margin: 1em 0; }
.post-content h2 { font-size: 22px; margin-top: 1.5em; }
.post-content h3 { font-size: 18px; margin-top: 1.5em; }
.post-content a { text-decoration: underline; }

/* ========== POST CONTENT ENHANCEMENTS ==========
   WP alignment standards, responsive images, and caption styling
   (covers both classic [caption] shortcodes and Gutenberg <figcaption>). */

/* Responsive images — never wider than their container, height auto so aspect ratio is kept */
.post-content img {
    max-width: 100%;
    height: auto;
}
.post-content .wp-caption,
.post-content figure {
    max-width: 100% !important;
}

/* WordPress alignment classes */
.alignleft {
    float: left;
    margin: 0.5em 1.5em 1em 0;
    max-width: 50%;
}
.alignright {
    float: right;
    margin: 0.5em 0 1em 1.5em;
    max-width: 50%;
}
.aligncenter {
    display: block;
    margin: 1.5em auto;
    clear: both;
}
.alignnone {
    display: block;
    margin: 1em 0;
}
.wp-caption.aligncenter {
    margin-left: auto;
    margin-right: auto;
}

/* Caption text — matches the featured-caption look for visual consistency */
.post-content figure { margin: 1.5em 0; }
.post-content .wp-caption-text,
.post-content figcaption {
    text-align: right;
    font-size: 13px;
    font-style: italic;
    color: #555;
    margin-top: 6px;
    line-height: 1.4;
}

/* Clear floats so the next block isn't dragged up alongside a floated image */
.post-content::after {
    content: "";
    display: table;
    clear: both;
}

.post-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 80px 0 40px;
    font-size: 15px;
}
.post-nav a:hover { text-decoration: underline; }
.post-nav .post-nav-prev,
.post-nav .post-nav-next { min-width: 100px; }
.post-nav .post-nav-next { text-align: right; }

/* ========== ABOUT PAGE TEMPLATE ========== */
.about-wrapper {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 60px;
    align-items: start;
}

.about-text { padding-top: 0; }
.about-title {
    font-size: 36px;
    font-weight: 700;
    margin: 0 0 30px;
    line-height: 1.15;
}
.about-content { margin-bottom: 30px; }

.about-images {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    margin: 40px 0;
}
.about-images img {
    width: 160px;
    height: 160px;
    object-fit: cover;
}

.about-contact { margin-top: 30px; }
.about-contact-email { margin: 0 0 12px; font-size: 16px; }
.about-contact .instagram-icon { width: 22px; height: 22px; }

.about-feature {
    background: #ffffff;
    padding: 50px;
}
.about-feature img { width: 100%; height: auto; display: block; }

/* ========== FOOTER ========== */
.site-footer {
    background: var(--dm-footer-bg, #3b3937);
    color: var(--dm-footer-fg, #ebe2d0);
    padding: 28px 20px;
    text-align: center;
    font-size: 14px;
}
.site-footer a { color: inherit; }

.site-footer-menu {
    list-style: none;
    margin: 0 0 10px;
    padding: 0;
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 6px 24px;
    font-size: 13px;
}
.site-footer-menu a {
    text-decoration: underline;
    text-underline-offset: 3px;
}
.site-footer-menu a:hover { opacity: 0.75; }
.site-footer-copyright { margin: 0; }

/* ========== BACK TO TOP ========== */
.back-to-top {
    position: fixed;
    bottom: 100px;
    right: 40px;
    width: 48px;
    height: 48px;
    background: #2a2a2a;
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    z-index: 100;
    text-decoration: none;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}
.back-to-top.is-visible { opacity: 1; pointer-events: auto; }
.back-to-top:hover { text-decoration: none; background: #000; }

/* ========== RESPONSIVE ==========
   Where a value is also controlled in the Customizer, use min(var, cap)
   so the user's setting carries through with a sensible upper bound on
   smaller screens. Where a value is hard-coded, it's a layout choice
   (stacking columns, etc.) that isn't user-controllable. */

/* Tablet / small desktop */
@media (max-width: 1100px) {
    .site-container { padding: 0 min(var(--dm-pad-container, 40px), 30px); }
    .post-item { grid-template-columns: 1fr; gap: 24px; }
    .post-thumb { width: 100%; height: auto; aspect-ratio: 2 / 1; }
    .about-wrapper { grid-template-columns: 1fr; gap: 40px; }
    .about-feature { padding: 30px; }
    .home-overlay.position-tl { --resolved-pad: min(var(--ov-tl-pad, 40px), 30px); }
    .home-overlay.position-tr { --resolved-pad: min(var(--ov-tr-pad, 40px), 30px); }
    .home-overlay.position-bl { --resolved-pad: min(var(--ov-bl-pad, 40px), 30px); }
    .home-overlay.position-br { --resolved-pad: min(var(--ov-br-pad, 40px), 30px); }
    .home-overlay-title { font-size: min(var(--ov-size-title, 28px), 24px); }
    .home-overlay-sub   { font-size: min(var(--ov-size-sub, 28px), 24px); }
    .post-content-preview .post-title { font-size: 24px; }
}

/* Tablet portrait */
@media (max-width: 800px) {
    .site-header { padding: 28px 0 min(var(--dm-pad-header, 60px), 40px); }
    .site-header-inner { flex-wrap: wrap; row-gap: 16px; column-gap: 16px; }
    .site-title { font-size: 16px; }
    .header-right { gap: 24px; }
    .main-nav ul { gap: 24px; }
    .main-nav a { font-size: 15px; }
    .page-title { font-size: 26px; }
    .about-title { font-size: 30px; }
    .home-overlay { max-width: 80%; }
    .home-overlay-title { font-size: min(var(--ov-size-title, 28px), 20px); }
    .home-overlay-sub   { font-size: min(var(--ov-size-sub, 28px), 20px); }
    .home-overlay-loc   { font-size: min(var(--ov-size-loc, 14px), 13px); }
    .single-post .post-header .post-title { font-size: 24px; }
    .post-content { font-size: 16px; } /* slightly larger for readability on smaller screens */
}

/* Phone */
@media (max-width: 600px) {
    body { font-size: 15px; }
    .site-container { padding: 0 min(var(--dm-pad-container, 40px), 18px); }

    /* Stacked header: title on top, nav + IG centered below */
    .site-header { padding: 22px 0 min(var(--dm-pad-header, 60px), 32px); }
    .site-header-inner {
        flex-direction: column;
        align-items: flex-start;
        row-gap: 14px;
    }
    .header-right {
        width: 100%;
        justify-content: flex-start;
        gap: 22px;
    }
    .main-nav ul { gap: 18px; flex-wrap: wrap; }

    /* Home grid stacks to one column — gap inherits from --dm-grid-gap (no override) */
    .home-grid { grid-template-columns: 1fr; }
    .home-image-wide { aspect-ratio: 4 / 3; }
    .home-overlay { max-width: 90%; }
    .home-overlay.position-tl { --resolved-pad: min(var(--ov-tl-pad, 40px), 18px); }
    .home-overlay.position-tr { --resolved-pad: min(var(--ov-tr-pad, 40px), 18px); }
    .home-overlay.position-bl { --resolved-pad: min(var(--ov-bl-pad, 40px), 18px); }
    .home-overlay.position-br { --resolved-pad: min(var(--ov-br-pad, 40px), 18px); }
    .home-overlay-title { font-size: min(var(--ov-size-title, 28px), 18px); }
    .home-overlay-sub   { font-size: min(var(--ov-size-sub, 28px), 18px); }
    .home-overlay-loc   { font-size: min(var(--ov-size-loc, 14px), 12px); }

    /* Page titles */
    .page-title { font-size: 22px; margin-bottom: 14px; }
    .page-intro { margin-bottom: 36px; }

    /* Blog list */
    .posts-list { gap: 40px; }
    .post-content-preview { padding-top: 0; }
    .post-content-preview .post-title { font-size: 22px; margin-bottom: 16px; }
    .post-excerpt { margin-bottom: 16px; }

    /* About */
    .about-wrapper { gap: 30px; }
    .about-title { font-size: 26px; margin-bottom: 20px; }
    .about-images { gap: 12px; margin: 28px 0; }
    .about-images img { width: calc(33.33% - 8px); height: auto; aspect-ratio: 1 / 1; }
    .about-feature { padding: 18px; }

    /* Single post */
    .featured-image { aspect-ratio: 4 / 3; }
    .single-post .post-header .post-title { font-size: 22px; }
    .post-header { margin-bottom: 30px; }
    .post-nav { margin: 50px 0 30px; font-size: 14px; }

    /* Pagination */
    .pagination { gap: 8px; margin: 50px 0 30px; }
    .pagination .page-numbers { padding: 4px 6px; font-size: 15px; }

    /* Back to top */
    .back-to-top {
        bottom: 80px;
        right: 16px;
        width: 42px;
        height: 42px;
        font-size: 18px;
    }

    /* Footer */
    .site-footer { padding: 22px 16px; font-size: 13px; }

    /* Post content alignment becomes block on small screens to avoid awkward wraps */
    .post-content .alignleft,
    .post-content .alignright {
        float: none;
        display: block;
        margin: 1.5em auto;
        max-width: 100%;
    }
}

/* Extra small phones */
@media (max-width: 360px) {
    .main-nav ul { gap: 14px; }
    .header-right { gap: 16px; }
    .main-nav a { font-size: 14px; }
}
