/* ====================================================================
   Design tokens — dark is the default palette; [data-theme="light"]
   on <html> overrides it. Keep this file framework-free (no build step).
   ==================================================================== */
:root {
    --accent: #1d4e89;
    --accent-ink: color-mix(in srgb, var(--accent) 65%, white 35%);
    --bg: #0f1216;
    --surface: #161a20;
    --surface-raised: #1d222a;
    --ink: #e9ebef;
    --ink-soft: #a7adb8;
    --border: #2b313c;
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
    --radius: 10px;
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --max-width: 1200px;
    color-scheme: dark;
}

:root[data-theme="light"] {
    --accent-ink: var(--accent);
    --bg: #f6f7f9;
    --surface: #ffffff;
    --surface-raised: #ffffff;
    --ink: #1c2127;
    --ink-soft: #4a4f57;
    --border: #dde1e6;
    --shadow: 0 10px 30px rgba(20, 24, 30, 0.08);
    color-scheme: light;
}

* {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    font-family: var(--font);
    color: var(--ink);
    background: var(--bg);
    line-height: 1.5;
    transition: background-color 0.15s ease, color 0.15s ease;
    overflow-x: hidden;
}

a {
    color: var(--accent-ink);
    text-decoration: none;
}

a:hover,
a:focus-visible {
    text-decoration: underline;
}

img {
    max-width: 100%;
}

#skipnav {
    position: absolute;
    left: -999px;
    top: auto;
}

#skipnav:focus {
    left: 1rem;
    top: 1rem;
    z-index: 1000;
    background: var(--surface-raised);
    color: var(--ink);
    padding: 0.5rem 1rem;
    border-radius: 6px;
    box-shadow: var(--shadow);
}

/* ---- Header ----
   Only the bar (title, nav, search, theme toggle) stays sticky -- the
   banner lives outside <header> in the markup now (see layout.phtml) so
   it's a normal-flow hero image that scrolls away with the rest of the
   page, instead of staying pinned at a fixed height forever. */
.site-header {
    background: var(--surface-raised);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.site-header-bar {
    max-width: var(--max-width);
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 1.25rem;
    padding: 0.85rem 1.25rem;
}

.site-brand {
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.site-brand-text {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--ink);
}

.site-brand img {
    max-height: 48px;
}

.site-nav {
    flex: 1;
    position: relative;
}

.site-nav ul {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    gap: 0.25rem;
    flex-wrap: wrap;
}

.site-nav li a,
.site-nav li .parent-link > a {
    display: inline-block;
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    color: var(--ink);
    font-weight: 600;
    font-size: 0.95rem;
}

.site-nav li a:hover,
.site-nav li a:focus-visible {
    background: var(--bg);
    color: var(--accent-ink);
    text-decoration: none;
}

.site-nav .parent {
    position: relative;
}

.site-nav .parent-link {
    display: flex;
    align-items: center;
}

.site-nav .child-toggle {
    border: none;
    background: transparent;
    cursor: pointer;
    padding: 0.25rem 0.4rem;
    color: var(--ink);
}

.site-nav .child-toggle::after {
    content: "\25BE";
}

.site-nav .parent > ul {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    background: var(--surface-raised);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.4rem;
    min-width: 12rem;
    box-shadow: var(--shadow);
    flex-direction: column;
}

.site-nav .parent > ul.open {
    display: flex;
}

#mobile-nav-toggle {
    display: none;
    border: 1px solid var(--border);
    background: var(--surface-raised);
    border-radius: 6px;
    width: 2.25rem;
    height: 2.25rem;
    cursor: pointer;
}

.site-search {
    flex-shrink: 0;
}

.site-search input[type="search"],
.site-search input[type="text"] {
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--ink);
    border-radius: 6px;
    padding: 0.45rem 0.7rem;
    font-size: 0.9rem;
}

/* The container itself had no rules at all before -- theme-config.phtml's
   dynamic "height"/"align-items" styles had nothing to act on (no display:
   flex) and nothing clipped the image to that height, so a tall banner
   image just overflowed its box and spilled over the content below it,
   blocking clicks on whatever was underneath. */
.banner {
    position: relative;
    display: flex;
    overflow: hidden;
    /* A safety ceiling independent of whatever height setting is
       configured, so a banner can never dominate or block the page. */
    max-height: min(480px, 60vh);
}

.banner img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
}

/* Darken the banner so it reads as a quiet backdrop rather than a loud,
   attention-grabbing block competing with the archive below it. */
.banner::after {
    content: "";
    position: absolute;
    inset: 0;
    background: rgba(6, 8, 12, 0.45);
    pointer-events: none;
}

/* ---- Theme (dark/light) toggle ---- */
.theme-toggle {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.25rem;
    height: 2.25rem;
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--ink);
    border-radius: 999px;
    cursor: pointer;
    font-size: 1.05rem;
    line-height: 1;
}

.theme-toggle:hover,
.theme-toggle:focus-visible {
    border-color: var(--accent-ink);
    color: var(--accent-ink);
}

.theme-toggle .icon-dark { display: none; }
.theme-toggle .icon-light { display: inline; }
:root[data-theme="light"] .theme-toggle .icon-dark { display: inline; }
:root[data-theme="light"] .theme-toggle .icon-light { display: none; }

/* ---- Content ---- */
#content {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 1.5rem 1.25rem 3rem;
}

#content > h2,
#content > h3 {
    color: var(--ink);
}

.site-footer {
    text-align: center;
    padding: 1.5rem;
    color: var(--ink-soft);
    font-size: 0.9rem;
    border-top: 1px solid var(--border);
}

/* ====================================================================
   Item single-page layout — 30% complementary info / 70% reader, inside
   the shared 1200px container. Info is placed first (left) visually via
   "order" while staying second in the markup, so a narrow/mobile stack
   still shows the document before the metadata (see the 900px breakpoint).
   ==================================================================== */
.item-single-page {
    display: grid;
    grid-template-columns: 3fr 7fr;
    gap: 1.75rem;
    align-items: start;
    margin-top: 1rem;
}

.item-single-page-info {
    order: 1;
}

.item-single-page-reader {
    order: 2;
}

/* Grid items default to min-width:auto, which lets a wide PDF canvas or
   image force the whole row (and page) wider than the viewport. Let the
   columns shrink and leave overflow handling to their own scroll areas. */
.item-single-page-reader,
.item-single-page-info {
    min-width: 0;
}

.item-single-page-reader .media-embeds {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    min-width: 0;
}

.item-single-page-info {
    position: sticky;
    top: 5rem;
    background: var(--surface-raised);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem 1.5rem;
    max-height: calc(100vh - 7rem);
    overflow-y: auto;
}

.item-single-page-info dl .property {
    padding: 0.6rem 0;
    border-bottom: 1px solid var(--border);
}

.item-single-page-info dl .property:last-child {
    border-bottom: none;
}

.item-single-page-info dt {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--ink-soft);
    margin-bottom: 0.2rem;
}

.item-single-page-info dd.value {
    margin: 0 0 0.3rem;
    word-break: break-word;
}

/* Mobile/narrow tablet: stack reader above info (document first, metadata
   below -- the markup's own order), drop the sticky sidebar. */
@media (max-width: 900px) {
    .item-single-page {
        grid-template-columns: 1fr;
    }

    .item-single-page-reader {
        order: 1;
    }

    .item-single-page-info {
        order: 2;
        position: static;
        max-height: none;
    }
}

/* ====================================================================
   "Portada" — modern cover-card grid for item/item-set listings
   ==================================================================== */
ul.resource-list {
    list-style: none;
    margin: 1.5rem 0 0;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
    gap: 1.5rem;
}

ul.resource-list li.resource {
    background: var(--surface-raised);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

ul.resource-list li.resource:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow);
    border-color: var(--accent-ink);
}

ul.resource-list li.resource > .resource-link {
    display: flex;
    flex-direction: column;
    color: inherit;
}

ul.resource-list li.resource > .resource-link:hover {
    text-decoration: none;
}

ul.resource-list li.resource img {
    width: 100%;
    aspect-ratio: 3 / 4;
    object-fit: cover;
    background: var(--bg);
    display: block;
}

ul.resource-list li.resource .resource-name {
    display: block;
    padding: 0.9rem 1rem 0.25rem;
    font-weight: 600;
    color: var(--ink);
    line-height: 1.3;
}

ul.resource-list li.resource .description {
    padding: 0 1rem 1rem;
    color: var(--ink-soft);
    font-size: 0.875rem;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.browse-controls {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    color: var(--ink-soft);
}

/* ---- Mobile nav ---- */
@media (max-width: 760px) {
    .site-header-bar {
        flex-wrap: wrap;
    }

    #mobile-nav-toggle {
        display: block;
        order: 2;
        margin-left: 0.5rem;
    }

    .theme-toggle {
        order: 4;
    }

    .site-nav {
        order: 5;
        width: 100%;
        flex-basis: 100%;
        display: none;
    }

    .site-nav.open {
        display: block;
    }

    .site-nav ul {
        flex-direction: column;
    }

    .site-nav .parent > ul {
        position: static;
        box-shadow: none;
        border: none;
        padding-left: 1rem;
    }

    .site-search {
        order: 3;
        flex: 1;
        min-width: 0;
    }
}
