/**
 * This Day Posts – front-end styles.
 * Designed to inherit from Foxiz's color/spacing CSS variables so the look
 * matches the rest of the site and adapts to dark mode automatically.
 */

/* -------------------------------------------------------------------------- */
/*  Layout wrappers                                                           */
/* -------------------------------------------------------------------------- */
.thdp-wrap {
    display: block;
    width: 100%;
}
.thdp-wrap > * + * {
    margin-top: 32px;
}

/* -------------------------------------------------------------------------- */
/*  Header (mirrors Foxiz Category Header layout 1)                           */
/* -------------------------------------------------------------------------- */
.thdp-header .thdp-title {
    margin-bottom: 14px;
}
.thdp-header .thdp-intro {
    margin-bottom: 12px;
    font-size: 1.05rem;
    line-height: 1.6;
}
.thdp-header .thdp-intro p {
    margin: 0 0 4px;
}
.thdp-header .thdp-subtitle {
    font-size: 0.95rem;
    line-height: 1.55;
    opacity: 0.85;
}

/* -------------------------------------------------------------------------- */
/*  Picker / quick-nav                                                        */
/* -------------------------------------------------------------------------- */
.thdp-picker {
    margin-top: 28px;
}
.thdp-picker-inner {
    background: var(--rb-block-bg, #f5f7fb);
    border: 1px solid var(--rb-border-color, rgba(0, 0, 0, 0.08));
    border-radius: 10px;
    padding: 18px 22px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

@media (min-width: 768px) {
    .thdp-picker-inner {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        gap: 18px;
    }
}

.thdp-picker-form {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
}
.thdp-picker-label {
    font-weight: 600;
    margin-inline-end: 4px;
}
.thdp-picker-form input[type="date"] {
    padding: 8px 12px;
    border: 1px solid var(--rb-border-color, rgba(0, 0, 0, 0.15));
    border-radius: 6px;
    background: var(--rb-bg, #fff);
    color: var(--rb-text-color, inherit);
    font-size: 1rem;
    min-height: 42px;
    line-height: 1.2;
}

.thdp-quicknav {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.thdp-posts {
    margin-top: 36px;
}

/* -------------------------------------------------------------------------- */
/*  Buttons                                                                   */
/* -------------------------------------------------------------------------- */
/* Underline reset only – do NOT touch `border-bottom`, that's the button's
   own bottom edge and removing it leaves the buttons looking open at the
   bottom. The button's own `border: 1px solid …` (declared below) wins
   against any theme `a { border-bottom: 1px dotted } ` style by specificity. */
.thdp-btn,
.thdp-btn:link,
.thdp-btn:visited,
.thdp-btn:hover,
.thdp-btn:active,
.thdp-btn:focus,
.thdp-btn:focus-visible {
    text-decoration: none !important;
}
.thdp-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: 6px;
    font-size: 0.95rem;
    line-height: 1.2;
    font-weight: 600;
    border: 1px solid transparent;
    cursor: pointer;
    transition: background-color .15s ease, color .15s ease, border-color .15s ease, transform .05s ease;
    min-height: 40px;
    font-family: inherit;
}
.thdp-btn:active {
    transform: translateY(1px);
}
.thdp-btn-primary,
.thdp-btn-primary:link,
.thdp-btn-primary:visited {
    background: var(--g-color, #01adfe);
    color: #fff;
}
.thdp-btn-primary:hover,
.thdp-btn-primary:focus-visible {
    filter: brightness(0.92);
    color: #fff;
}
.thdp-btn-ghost,
.thdp-btn-ghost:link,
.thdp-btn-ghost:visited {
    background: transparent;
    color: var(--rb-text-color, inherit);
    border-color: var(--rb-border-color, rgba(0, 0, 0, 0.15));
}
.thdp-btn-ghost:hover,
.thdp-btn-ghost:focus-visible {
    background: var(--rb-block-bg, rgba(0, 0, 0, 0.04));
    color: var(--rb-text-color, inherit);
}
.thdp-btn-random::before {
    content: "🎲";
    font-size: 1.05em;
    margin-inline-end: 4px;
    text-decoration: none;
}

/* -------------------------------------------------------------------------- */
/*  Year groups (each renders a Foxiz list_1 block)                           */
/* -------------------------------------------------------------------------- */
.thdp-posts-inner {
    width: 100%;
}
.thdp-year-group + .thdp-year-group {
    margin-top: 36px;
}
.thdp-year-group .block-h {
    margin-bottom: 18px;
}
/* Smooth-scroll target offset so the heading isn't hidden behind sticky bars */
.thdp-year-group {
    scroll-margin-top: 80px;
}

/* Fallback heading (when foxiz_get_heading is not available) */
.thdp-year-heading {
    margin: 18px 0;
    text-align: center;
    border-bottom: 1px solid var(--rb-border-color, rgba(0, 0, 0, 0.15));
    line-height: 0.1em;
}
.thdp-year-heading h2 span {
    background: var(--rb-bg, #fff);
    padding: 0 14px;
    font-size: 1.25rem;
}

/* -------------------------------------------------------------------------- */
/*  Year skiplinks                                                            */
/*                                                                            */
/*  Layout:                                                                   */
/*    Mobile / narrow desktop: horizontal sticky bar above the post list.    */
/*    Wide desktop (≥1200px) : grid sidebar that lives next to the content,  */
/*                              sticky-positioned in its own column so it    */
/*                              hugs the right edge of the content area      */
/*                              (not the viewport edge).                     */
/* -------------------------------------------------------------------------- */

/* Color tokens shared across breakpoints. */
.thdp-skiplinks {
    --thdp-skip-bg: var(--rb-bg, #fff);
    --thdp-skip-fg: var(--rb-text-color, inherit);
    --thdp-skip-border: var(--rb-border-color, rgba(0, 0, 0, 0.12));
    --thdp-skip-active: var(--g-color, #01adfe);
    /* No `contain` here – it creates a new containing block that breaks
       `position: sticky` on descendants. */
}

/* Layout: mobile-first, vertical column with skiplinks first then posts. */
.thdp-posts-grid {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.thdp-skiplinks-label {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    opacity: 0.55;
}
.thdp-skiplinks-list {
    display: flex;
    gap: 6px;
}
.thdp-skiplink,
.thdp-skiplink:link,
.thdp-skiplink:visited,
.thdp-skiplink:hover,
.thdp-skiplink:focus,
.thdp-skiplink:active {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 6px 10px;
    border-radius: 999px;
    text-decoration: none !important;
    font-size: 0.9rem;
    line-height: 1;
    color: var(--thdp-skip-fg);
    background: transparent;
    border: 1px solid var(--thdp-skip-border);
    transition: background-color .15s ease, color .15s ease, border-color .15s ease;
    min-width: 44px;
    list-style: none;
}
.thdp-skiplink::before,
.thdp-skiplink::after,
.thdp-skiplink::marker {
    content: none !important;
    display: none !important;
}
/* Higher specificity (.thdp-skiplinks ancestor) + !important on color so we
   win against any global theme rule like `nav a:hover { color: blue }`. */
.thdp-skiplinks .thdp-skiplink:hover,
.thdp-skiplinks .thdp-skiplink:focus-visible,
.thdp-skiplinks .thdp-skiplink.is-active {
    background: var(--thdp-skip-active);
    color: #fff !important;
    border-color: var(--thdp-skip-active);
}

/* Post image size: Foxiz gives the list_1 image 40% of the column. Category
   pages have a sidebar from 992px and this page doesn't, so the same 40%
   came out ~1.4x bigger. These widths match the category item's image. */
@media (min-width: 992px) {
    .thdp-posts .p-list-1 .list-feat-holder {
        width: 27%;
        max-width: 27%;
    }
}
@media (min-width: 1200px) {
    .thdp-posts .p-list-1 .list-feat-holder {
        width: 30%;
        max-width: 30%;
    }
}

/* Mobile / narrow desktop: horizontal sticky bar at the top. */
@media (max-width: 1199px) {
    .thdp-skiplinks {
        position: sticky;
        top: 0;
        z-index: 5;
        background: var(--thdp-skip-bg);
        padding: 8px 12px;
        margin: 0 -12px;
        border-bottom: 1px solid var(--thdp-skip-border);
    }
    .thdp-skiplinks-sticky {
        display: flex;
        align-items: center;
        gap: 10px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    .thdp-skiplinks-label {
        flex: 0 0 auto;
    }
    .thdp-skiplinks-list {
        flex-wrap: nowrap;
    }
    .thdp-skiplink {
        flex: 0 0 auto;
    }
}

/* Wide desktop: grid sidebar inside the content container.                  */
/* In RTL, grid column 1 visually appears on the RIGHT, so listing the       */
/* skiplinks column first puts them on the right edge of the post area.      */
/*                                                                           */
/* Sticky pattern: the grid item (`.thdp-skiplinks`) MUST stretch to the     */
/* full height of the grid row so the inner sticky element has somewhere to  */
/* "stick" through the entire scroll. We rely on the grid's default          */
/* `align-items: stretch` (do NOT add `align-items: start` here).            */
@media (min-width: 1200px) {
    .thdp-posts-grid {
        display: grid;
        grid-template-columns: 96px minmax(0, 1fr);
        gap: 28px;
    }
    .thdp-skiplinks {
        /* Stretches by default. No height/min-height needed. */
        height: 100%;
    }
    .thdp-skiplinks-sticky {
        position: sticky;
        top: 90px;
        max-height: calc(100vh - 120px);
        overflow-y: auto;
        background: var(--thdp-skip-bg);
        border: 1px solid var(--thdp-skip-border);
        border-radius: 12px;
        padding: 12px 10px;
        box-shadow: 0 1px 6px rgba(0, 0, 0, 0.04);
        display: flex;
        flex-direction: column;
        gap: 10px;
    }
    .thdp-skiplinks-label {
        text-align: center;
        margin-bottom: 0;
    }
    .thdp-skiplinks-list {
        flex-direction: column;
        gap: 6px;
    }
}

/* -------------------------------------------------------------------------- */
/*  Empty state                                                               */
/* -------------------------------------------------------------------------- */
.thdp-empty-inner {
    text-align: center;
    padding: 36px 16px;
    border: 1px dashed var(--rb-border-color, rgba(0, 0, 0, 0.15));
    border-radius: 10px;
}
.thdp-empty-text {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 6px;
}
.thdp-empty-suggest {
    margin-bottom: 14px;
    opacity: 0.85;
}
.thdp-empty-actions {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 8px;
}

/* -------------------------------------------------------------------------- */
/*  Fallback list (no Foxiz)                                                  */
/* -------------------------------------------------------------------------- */
.thdp-fallback-list {
    list-style: none;
    margin: 0;
    padding: 0;
}
.thdp-fallback-item {
    display: flex;
    gap: 16px;
    padding: 16px 0;
    border-bottom: 1px solid var(--rb-border-color, rgba(0, 0, 0, 0.08));
}
.thdp-fallback-thumb img {
    width: 220px;
    height: auto;
    border-radius: 6px;
    object-fit: cover;
}
.thdp-fallback-body {
    flex: 1 1 auto;
}
.thdp-fallback-title {
    margin: 0 0 6px;
    font-size: 1.25rem;
}
.thdp-fallback-meta {
    font-size: 0.85rem;
    opacity: 0.7;
    margin-bottom: 8px;
}

/* -------------------------------------------------------------------------- */
/*  Dark mode                                                                 */
/* -------------------------------------------------------------------------- */
body[data-theme="dark"] .thdp-picker-inner {
    background: rgba(255, 255, 255, 0.04);
    border-color: rgba(255, 255, 255, 0.08);
}
body[data-theme="dark"] .thdp-picker-form input[type="date"] {
    background: rgba(255, 255, 255, 0.06);
    color: #fff;
    border-color: rgba(255, 255, 255, 0.12);
    color-scheme: dark;
}
body[data-theme="dark"] .thdp-year-heading h2 span {
    background: var(--rb-bg, #111);
}
body[data-theme="dark"] .thdp-skiplinks {
    --thdp-skip-bg: rgba(20, 20, 20, 0.95);
    --thdp-skip-border: rgba(255, 255, 255, 0.12);
    --thdp-skip-fg: #eee;
}
