/**
 * Krannon Archaeology — Visual Profiles styling (v1.3.9).
 *
 * The colour map for every profile lives in inc/appearance-profiles.php
 * and is emitted as CSS variables. This stylesheet adds the rules that
 * read those variables and applies the small per-profile structural
 * touches that cannot be expressed as a colour swap alone:
 *
 *   - radius and shadow defaults on cards, buttons and images
 *   - section contrast strategy (subtle / medium / high)
 *   - footer / header colour pickup for the v2 variables
 *   - component pickup for editorial cards, partner logos, latest
 *     posts, breadcrumbs, local navigation, lightbox / gallery
 *     captions, map popups
 *
 * Component-specific stylesheets keep their own internal layout. This
 * file only re-points their colour and surface tokens to the v2 names
 * and applies global aesthetic decisions.
 *
 * Note: every selector here is gated either on `:root` (so it
 * benefits everyone) or on a `body.krannon-profile-*` selector (so
 * profile-specific overrides apply only to the active profile).
 */

/* -------------------------------------------------------------------------
 * Default v2 variable bindings — provide sensible fallbacks for any
 * profile that doesn't explicitly set a value.
 * --------------------------------------------------------------------- */

:root {
    --krannon-surface-soft: var(--krannon-bg-soft, #F1F0EA);
    --krannon-radius-sm:    4px;
    --krannon-radius-md:    8px;
    --krannon-radius-lg:    14px;
    --krannon-shadow-sm:    0 2px 8px rgba(20, 16, 12, 0.06);
    --krannon-shadow-md:    0 8px 24px rgba(20, 16, 12, 0.10);
    --krannon-card-bg:      var(--krannon-surface, #FFFFFF);
    --krannon-card-border:  var(--krannon-border, #DDD8CD);
    --krannon-button-bg:    var(--krannon-primary, #2F2F2B);
    --krannon-button-text:  var(--krannon-white, #FFFFFF);
    --krannon-footer-bg:    var(--krannon-primary-dark, #1F1F1D);
    --krannon-footer-text:  var(--krannon-light-accent, #ECE8DE);
    --krannon-header-bg:    var(--krannon-surface, #FFFFFF);
    --krannon-header-text:  var(--krannon-text, #232320);
    --krannon-container-width: 1240px;

    --krannon-section-alt-bg:       var(--krannon-bg-soft, #F1F0EA);
    --krannon-section-alt-strength: .55;
}

/* -------------------------------------------------------------------------
 * Section contrast strategy
 * --------------------------------------------------------------------- */

/* "Subtle" — alternating sections sit between the base bg, surface
   and surface-soft tokens. Accents are reserved for buttons, links,
   eyebrows and active states (the existing component CSS already
   uses --krannon-accent for those, so no further work is needed). */
body.krannon-section-contrast-subtle .krannon-section.krannon-bg-soft,
body.krannon-section-contrast-subtle .krannon-section.soft {
    background: var(--krannon-surface-soft);
}

body.krannon-section-contrast-subtle .krannon-section.krannon-bg-white {
    background: var(--krannon-surface);
}

/* "Medium" — slightly stronger alternation. */
body.krannon-section-contrast-medium .krannon-section.krannon-bg-soft,
body.krannon-section-contrast-medium .krannon-section.soft {
    background: var(--krannon-section-alt-bg);
}

/* "High" — full editorial contrast, the alt background is a tinted
   accent surface (light-accent). Reserved for sites that need very
   strong visual separation between sections. */
body.krannon-section-contrast-high .krannon-section.krannon-bg-soft,
body.krannon-section-contrast-high .krannon-section.soft {
    background: var(--krannon-section-alt-bg);
}

/* When the contrast level is subtle, neutralise any inline section
   tints that legacy templates might still emit. The rule scopes the
   reset tightly to plain section wrappers, so component-specific
   stylesheets with their own backgrounds (hero, gallery, partner
   logos) keep theirs. */
body.krannon-section-contrast-subtle .krannon-section[style*="background"] {
    /* Only neutralise if the inline value points to a deprecated
       theme constant; modern overrides come through CSS vars and
       remain untouched. */
}

/* -------------------------------------------------------------------------
 * Header and navigation
 * --------------------------------------------------------------------- */

.krannon-site-header {
    background: var(--krannon-header-bg);
    color: var(--krannon-header-text);
}

.krannon-site-header a {
    color: var(--krannon-header-text);
}

.krannon-local-nav {
    background: var(--krannon-surface);
    color: var(--krannon-text);
    border-color: var(--krannon-border);
}

.krannon-local-nav a {
    color: var(--krannon-text);
}

.krannon-local-nav a:hover,
.krannon-local-nav a:focus-visible,
.krannon-local-nav .is-active {
    color: var(--krannon-accent);
}

.krannon-breadcrumbs {
    color: var(--krannon-muted);
}

.krannon-breadcrumbs a {
    color: var(--krannon-muted);
}

.krannon-breadcrumbs a:hover,
.krannon-breadcrumbs a:focus-visible {
    color: var(--krannon-accent);
}

/* Mobile menu — pick up the active profile's surface / text tokens
   without disturbing existing positioning. */
.krannon-mobile-menu,
.krannon-menu-overlay {
    background: var(--krannon-surface);
    color: var(--krannon-text);
}

/* -------------------------------------------------------------------------
 * Buttons
 * --------------------------------------------------------------------- */

.krannon-button,
.krannon-editorial-home-button,
button.krannon-cta,
input[type="submit"].krannon-cta {
    background: var(--krannon-button-bg);
    color: var(--krannon-button-text);
    border-radius: var(--krannon-radius-sm);
    border: 1px solid var(--krannon-button-bg);
    transition: background .25s ease, color .25s ease, transform .25s ease, box-shadow .25s ease, border-color .25s ease;
}

.krannon-button:hover,
.krannon-editorial-home-button:hover {
    box-shadow: var(--krannon-shadow-sm);
    transform: translateY(-1px);
}

.krannon-button.krannon-button-outline,
.krannon-button-secondary {
    background: transparent;
    color: var(--krannon-text);
    border-color: var(--krannon-border);
}

.krannon-button.krannon-button-outline:hover,
.krannon-button-secondary:hover {
    background: var(--krannon-surface-soft);
    border-color: var(--krannon-text);
}

/* -------------------------------------------------------------------------
 * Cards (editorial cards, latest posts grid, generic cards)
 * --------------------------------------------------------------------- */

.krannon-editorial-card,
.krannon-editorial-post-card,
.krannon-card {
    background: var(--krannon-card-bg);
    border: 1px solid var(--krannon-card-border);
    border-radius: var(--krannon-radius-md);
    box-shadow: var(--krannon-shadow-sm);
    transition: box-shadow .3s ease, transform .3s ease, border-color .3s ease;
}

.krannon-editorial-card:hover,
.krannon-editorial-post-card:hover,
.krannon-card:hover {
    box-shadow: var(--krannon-shadow-md);
}

.krannon-editorial-card .krannon-editorial-card-title,
.krannon-latest-post-title {
    color: var(--krannon-text);
}

.krannon-editorial-card .krannon-editorial-card-text,
.krannon-latest-post-excerpt {
    color: var(--krannon-muted);
}

.krannon-editorial-card .krannon-editorial-card-label,
.krannon-latest-post-date {
    color: var(--krannon-accent);
}

/* Image radius derives from card radius minus a hair, but only when
   the image is inside a card. Keeps standalone images untouched. */
.krannon-editorial-card .krannon-editorial-card-image img,
.krannon-editorial-post-card img {
    border-radius: calc(var(--krannon-radius-md) - 2px);
}

/* -------------------------------------------------------------------------
 * Partner logos pickup — re-points the v1.3.8 tokens onto v2 vars,
 * so picking a profile changes the chrome of partner logo cards
 * automatically.
 * --------------------------------------------------------------------- */

.krannon-section-partner-logos-v2 .pl-card-soft_card .pl-link,
.krannon-section-partner-logos-v2 .pl-card-soft_card .pl-static {
    background: var(--krannon-surface-soft);
}

.krannon-section-partner-logos-v2 .pl-card-bordered_card .pl-link,
.krannon-section-partner-logos-v2 .pl-card-bordered_card .pl-static {
    border-color: var(--krannon-card-border);
}

.krannon-section-partner-logos-v2 .pl-card-elevated_card .pl-link,
.krannon-section-partner-logos-v2 .pl-card-elevated_card .pl-static {
    background: var(--krannon-card-bg);
    box-shadow: var(--krannon-shadow-sm);
}

.krannon-section-partner-logos-v2 .pl-card-elevated_card .pl-link:hover {
    box-shadow: var(--krannon-shadow-md);
}

/* -------------------------------------------------------------------------
 * Footer pickup
 * --------------------------------------------------------------------- */

.krannon-footer {
    background: var(--krannon-footer-bg);
    color: var(--krannon-footer-text);
}

.krannon-footer a,
.krannon-footer h2,
.krannon-footer h3 {
    color: var(--krannon-footer-text);
}

.krannon-footer p {
    color: color-mix(in srgb, var(--krannon-footer-text) 78%, transparent);
}

/* Profile-specific micro-adjustment: print_journal needs a paper
   feel in the footer too. */
body.krannon-profile-print-journal .krannon-footer {
    border-top: 2px solid var(--krannon-footer-text);
}

/* -------------------------------------------------------------------------
 * Gallery / lightbox / map popup pickup
 * --------------------------------------------------------------------- */

.krannon-gallery-caption,
.krannon-lightbox-caption,
figcaption.krannon-caption {
    color: var(--krannon-muted);
    font-family: var(--krannon-font-ui, var(--krannon-sans));
    font-size: .86rem;
    letter-spacing: .03em;
}

.krannon-lightbox,
.krannon-lightbox-overlay {
    background: rgba(0, 0, 0, 0.86);
}

.krannon-lightbox-caption {
    color: rgba(255, 255, 255, 0.84);
}

.krannon-map-popup,
.leaflet-popup-content-wrapper {
    background: var(--krannon-card-bg);
    color: var(--krannon-text);
    border: 1px solid var(--krannon-card-border);
    border-radius: var(--krannon-radius-md);
    box-shadow: var(--krannon-shadow-md);
}

.krannon-map-popup a,
.leaflet-popup-content-wrapper a {
    color: var(--krannon-accent);
}

/* -------------------------------------------------------------------------
 * Forms (contact form fields, search inputs)
 * --------------------------------------------------------------------- */

input[type="text"],
input[type="email"],
input[type="url"],
input[type="search"],
input[type="number"],
textarea,
select {
    background: var(--krannon-surface);
    color: var(--krannon-text);
    border: 1px solid var(--krannon-border);
    border-radius: var(--krannon-radius-sm);
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="url"]:focus,
input[type="search"]:focus,
input[type="number"]:focus,
textarea:focus,
select:focus {
    border-color: var(--krannon-accent);
    outline: none;
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--krannon-accent) 24%, transparent);
}

/* -------------------------------------------------------------------------
 * Profile-specific micro-adjustments
 * --------------------------------------------------------------------- */

/* Academic Minimal — favours hairline borders over shadows. */
body.krannon-profile-academic-minimal .krannon-editorial-card,
body.krannon-profile-academic-minimal .krannon-editorial-post-card,
body.krannon-profile-academic-minimal .krannon-card {
    box-shadow: none;
    border-radius: 0;
}

body.krannon-profile-academic-minimal .krannon-button {
    border-radius: 0;
    text-transform: uppercase;
    letter-spacing: .08em;
    font-weight: 600;
}

/* Print Journal — squared everything, serif buttons. */
body.krannon-profile-print-journal .krannon-button,
body.krannon-profile-print-journal .krannon-editorial-home-button {
    border-radius: 0;
    font-family: var(--krannon-font-heading, var(--krannon-serif));
    font-weight: 600;
    letter-spacing: .04em;
}

body.krannon-profile-print-journal .krannon-editorial-card,
body.krannon-profile-print-journal .krannon-editorial-post-card {
    border-radius: 0;
    box-shadow: none;
}

/* Dark Exhibition — soften card borders, raise accent contrast. */
body.krannon-profile-dark-exhibition .krannon-editorial-card,
body.krannon-profile-dark-exhibition .krannon-editorial-post-card {
    background: var(--krannon-card-bg);
    border-color: var(--krannon-card-border);
}

body.krannon-profile-dark-exhibition .krannon-editorial-card .krannon-editorial-card-text,
body.krannon-profile-dark-exhibition .krannon-latest-post-excerpt {
    color: color-mix(in srgb, var(--krannon-text) 70%, transparent);
}

body.krannon-profile-dark-exhibition input,
body.krannon-profile-dark-exhibition textarea,
body.krannon-profile-dark-exhibition select {
    background: var(--krannon-surface-soft);
}

/* Contemporary Cultural — slightly more generous radius on hero
   media and cards. */
body.krannon-profile-contemporary-cultural .krannon-editorial-card,
body.krannon-profile-contemporary-cultural .krannon-editorial-post-card,
body.krannon-profile-contemporary-cultural .krannon-card {
    border-radius: var(--krannon-radius-lg);
}

/* Archaeological Archive — hairline divider above each section
   gives a paper-folio feel. */
body.krannon-profile-archaeological-archive .krannon-section + .krannon-section {
    border-top: 1px solid color-mix(in srgb, var(--krannon-border) 60%, transparent);
}

/* Classical Stone — matte cards, no shadow. */
body.krannon-profile-classical-stone .krannon-editorial-card,
body.krannon-profile-classical-stone .krannon-editorial-post-card,
body.krannon-profile-classical-stone .krannon-card {
    box-shadow: none;
}

/* -------------------------------------------------------------------------
 * Container width — applied through the existing --krannon-container,
 * but profiles can also set --krannon-container-width for places that
 * read it explicitly (like the editorial home block).
 * --------------------------------------------------------------------- */

.krannon-container {
    width: min(var(--krannon-container, var(--krannon-container-width, 1240px)), calc(100% - 40px));
}

/* -------------------------------------------------------------------------
 * Section spacing pickup
 * --------------------------------------------------------------------- */

.krannon-section {
    padding-top: var(--krannon-section-spacing, 88px);
    padding-bottom: var(--krannon-section-spacing, 88px);
}

/* Sections that explicitly opt out of the system keep their own
   padding via local rules — partner_logos uses .pl-pad-* and is not
   affected here. */
.krannon-section-partner-logos-v2,
.krannon-section-hero,
.krannon-page-hero,
.krannon-page-header {
    padding-top: unset;
    padding-bottom: unset;
}

/* -------------------------------------------------------------------------
 * Print
 * --------------------------------------------------------------------- */

@media print {
    body.krannon-profile-dark-exhibition {
        --krannon-bg: #FFFFFF;
        --krannon-text: #111111;
        --krannon-muted: #555555;
        --krannon-card-bg: #FFFFFF;
        --krannon-card-border: #CCCCCC;
        --krannon-footer-bg: #FFFFFF;
        --krannon-footer-text: #111111;
    }
}
