/* ============================================================
   KARTUL — global styles
   Design tokens aligned to Figma (Kommuna, 32px nav, 53/18px inset).
   Home: sticky logo peek at viewport bottom; footer lifts the band on scroll.
   ============================================================ */

@font-face {
    font-family: "Kommuna";
    src: url("../fonts/Kommuna-Normal.ttf") format("truetype");
    font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
    font-family: "Kommuna";
    src: url("../fonts/Kommuna-NormalBold.ttf") format("truetype");
    font-weight: 700; font-style: normal; font-display: swap;
}
@font-face {
    font-family: "Kommuna";
    src: url("../fonts/Kommuna-NormalBlack.ttf") format("truetype");
    font-weight: 900; font-style: normal; font-display: swap;
}

:root {
    /* ========== TUNE HERE — design tokens ============================= */
    --paper: #ffffff;
    --ink: #000000;
    --forest: #339966;
    --lime: #00ff00;

    --measure: 14.5px;
    --nav-size: 32px;
    --mobile-menu-size: 41px;

    --header-height: 97px;
    --header-clearance: 97px;
    --nav-fade: 97px;
    --nav-gap: 75px;

    --side-inset: 53px;
    --side-inset-mobile: 18px;
    --col-gap: 32px;

    --step-1: 0px;
    --step-2: 0px;
    --step-3: 0px;
    --step-4: 0px;
    --step-5: 0px;
    --step-6: 0px;

    --img-height: clamp(88px, 22vw, 168px);
    --img-tilt: 0deg;

    --logo-width-desktop: min(56.6vw, 978px);
    --logo-width-mobile: min(63vw, 246px);
    --logo-aspect: 0.2638;
    --logo-height: calc(var(--logo-width-desktop) * var(--logo-aspect));
    --logo-peek-offset: 7rem; /* sticky tuck — viewport hides bottom of logo at rest */
    --stage-top: 7rem; /* clearance below header gradient (content starts here) */
    --stage-top-mobile: 24px;
    --chrome-fade: 97px;
    --chrome-fade-mobile: 48px;
    --chrome-band-min: calc(var(--logo-height) + var(--chrome-band-pad-top) + var(--chrome-fade) + var(--chrome-band-pad-bottom));

    --chrome-band-pad-top: 24px;
    --chrome-band-pad-top-mobile: 12px;
    --chrome-band-pad-bottom: 18px;
    --chrome-nav-width: 65px;
    --chrome-nav-gap: 12px;

    --bp-mobile: 780px;
    --paper-fade: 1s;
    /* ================================================================== */
}

/* ---------- page transition ---------- */
@view-transition { navigation: auto; }

::view-transition-old(root) {
    animation: paperOut var(--paper-fade) ease-in both;
}
::view-transition-new(root) {
    animation: paperIn var(--paper-fade) ease-out both;
}

@keyframes paperIn {
    0%   { opacity: 0; }
    35%  { opacity: .35; }
    100% { opacity: 1; }
}
@keyframes paperOut {
    0%   { opacity: 1; }
    60%  { opacity: .45; }
    100% { opacity: 0; }
}

.page-chrome {
    view-transition-name: site-chrome;
    position: sticky;
    bottom: 0;
    z-index: 5;
    margin-inline: calc(-1 * var(--chrome-outset, 0px));
    padding-inline: var(--side-inset);
    box-sizing: border-box;
    margin-top: auto;
    padding-top: calc(var(--chrome-band-pad-top) + var(--chrome-fade));
    padding-bottom: var(--chrome-band-pad-bottom);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0) 0%, var(--paper) 55%);
    pointer-events: none;
    flex-shrink: 0;
}
::view-transition-old(site-chrome),
::view-transition-new(site-chrome) {
    animation: none;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--paper); }

body {
    color: var(--ink);
    font-family: "Kommuna", "Courier New", monospace;
    font-size: var(--measure);
    line-height: 1.2;
    -webkit-font-smoothing: antialiased;
}

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

/* ---------- language switch (shared) ---------- */
.lang-switch {
    display: flex;
    gap: 6px;
    align-items: baseline;
}
.lang-switch a {
    font: inherit;
    background: none;
    border: 0;
    padding: 0;
    cursor: pointer;
    color: var(--ink);
    opacity: 0.5;
    text-decoration: none;
}
.lang-switch a:hover { opacity: 0.8; }
.lang-switch a[aria-current="true"] { opacity: 1; font-weight: 700; }
.lang-switch span { opacity: 0.4; }

/* ---------- desktop header (Home · Events · Menu) ---------- */
.site-header {
    position: relative;
    z-index: 30;
    pointer-events: none;
    margin-bottom: calc(-1 * var(--nav-fade));
}

.topnav {
    pointer-events: auto;
    position: relative;
    background: linear-gradient(180deg, var(--paper) 0%, rgba(255, 255, 255, 0) 100%);
}

.topnav-row {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: var(--nav-gap);
    min-height: var(--header-height);
    padding: 32px var(--side-inset) 28px;
}

.topnav-links {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    align-items: center;
    gap: var(--nav-gap);
    font-size: var(--nav-size);
    font-weight: 400;
}

.topnav-links a:hover { font-weight: 700; }
.topnav-links a[aria-current="page"] {
    font-weight: 700;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.topnav-lang {
    display: inline-flex;
    align-items: center;
    margin-left: auto;
    flex-shrink: 0;
    font-size: var(--nav-size);
    line-height: 1;
    mix-blend-mode: multiply;
}

/* ---------- page chrome (logo + nav + footer) — home is the reference ---------- */
.home-stage,
.menu-stage,
.page-stage,
.simple-stage,
.events-page,
.event-stage {
    --chrome-outset: var(--side-inset);
    display: flex;
    flex-direction: column;
    min-height: calc(100vh - var(--header-height));
    padding-top: var(--stage-top);
}

.home-stage > .home-content,
.menu-stage > .menu-body,
.page-stage > .manifesto-body,
.page-stage > :not(.page-chrome):not(.site-footer):not(.manifesto-body),
.simple-stage > .simple-body,
.events-page > .events-stage,
.event-stage > .home-content {
    flex: 1 1 auto;
    min-height: calc(100vh - var(--header-height) - var(--chrome-band-min));
}

.simple-stage,
.events-page {
    --chrome-outset: 0;
}

/* ---------- sticky bottom band (logo + mobile nav) ---------- */
.sticky-bottom {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: var(--chrome-nav-gap);
    pointer-events: none;
}

.sticky-bottom-nav {
    position: relative;
    flex-shrink: 0;
    pointer-events: auto;
}

@media (min-width: 781px) {
    .sticky-bottom-nav {
        display: none;
    }
}

/* ---------- mobile hamburger + menu (no overlay) ---------- */
.nav-toggle {
    display: none;
    position: static;
    width: var(--chrome-nav-width);
    height: 55px;
    margin: 0;
    padding: 0;
    border: 0;
    background: none;
    cursor: pointer;
    color: var(--ink);
}

.nav-toggle-icon {
    display: block;
    width: 100%;
    height: auto;
}

.nav-toggle-icon--close {
    display: none;
}

body.is-nav-open .nav-toggle-icon--open {
    display: none;
}

body.is-nav-open .nav-toggle-icon--close {
    display: block;
}

.mobile-menu {
    position: absolute;
    right: 0;
    bottom: calc(100% + 12px);
    z-index: 1;
    background: none;
    padding: 0;
    pointer-events: none;
}

.mobile-menu:not([hidden]) {
    pointer-events: auto;
}

.mobile-menu nav {
    pointer-events: auto;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.mobile-menu-links {
    list-style: none;
    margin: 0 0 1.5rem;
    padding: 0;
    text-align: right;
    font-size: var(--mobile-menu-size);
    font-weight: 700;
    line-height: 1.35;
}

.mobile-menu-links li + li { margin-top: 0.15em; }

.mobile-menu-links a[aria-current="page"] {
    text-decoration: underline;
    text-underline-offset: 4px;
}

.mobile-menu-lang {
    font-size: var(--mobile-menu-size);
    font-weight: 700;
}

.mobile-menu-lang a[aria-current="true"] {
    text-decoration: underline;
    text-underline-offset: 4px;
}

/* ---------- layout grid (home + multi-column pages) ---------- */
.manifesto-body {
    display: flex;
    flex-direction: column;
    gap: var(--row-gap, 0px);
}

.layout-row {
    display: grid;
    grid-template-columns: repeat(12, minmax(0, 1fr));
    gap: 0 var(--col-gap);
    align-items: start;
}

.col {
    grid-column: span var(--span, 4);
    min-width: 0;
}

.col:nth-child(1) { padding-top: var(--step-1); }
.col:nth-child(2) { padding-top: var(--step-2); }
.col:nth-child(3) { padding-top: var(--step-3); }
.col:nth-child(4) { padding-top: var(--step-4); }
.col:nth-child(5) { padding-top: var(--step-5); }
.col:nth-child(6) { padding-top: var(--step-6); }

.manifesto-body p { margin: 0 0 1.1em; }
.manifesto-body p:first-child { margin-top: 0; }
.manifesto-body a { text-decoration: underline; text-underline-offset: 2px; }
.manifesto-body a:hover { font-weight: 700; }
.manifesto-body h3 { font-size: inherit; font-weight: 700; margin: 1.2em 0 .4em; }
.manifesto-body ul { margin: 0 0 1.1em; padding-left: 1.1em; }
.manifesto-body .loading { opacity: .4; }

/* ---------- home + single event page (shared stage chrome) ---------- */
.home-stage,
.event-stage {
    position: relative;
    z-index: 1;
    padding-inline: var(--side-inset);
}

.home-content {
    padding-bottom: 2rem;
}

.site-logo {
    flex: 1 1 auto;
    min-width: 0;
    margin: 0;
    padding: 0;
    background: none;
    pointer-events: auto;
    color: inherit;
}

.site-logo img {
    display: block;
    width: var(--logo-width-desktop);
    height: auto;
}

@media (min-width: 781px) {
    .page-chrome {
        bottom: calc(-1 * var(--logo-peek-offset));
        padding-bottom: 0;
    }
}

.site-logo:hover img,
.site-logo:focus-visible img {
    opacity: 0.75;
}

.site-footer {
    position: relative;
    z-index: 1;
    flex-shrink: 0;
    background: var(--paper);
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(10.5rem, 1fr));
    gap: 32px 48px;
    padding: 32px 0 56px;
    font-weight: 700;
}

.site-footer-links {
    font-weight: 700;
}

.site-footer-links p {
    margin: 0;
}

.simple-stage .site-footer,
.events-page .site-footer {
    padding-inline: var(--side-inset);
}

.site-footer p {
    margin: 0 0 0.35em;
}

.site-footer a {
    text-decoration: underline;
    text-underline-offset: 2px;
}

.site-footer-hours p:first-child {
    margin-bottom: 0.5em;
}

/* ---------- inline images ---------- */
.inline-img {
    margin: 0 0 1.1em;
    transform: rotate(var(--img-tilt));
}
.inline-img a {
    display: block;
    color: inherit;
    cursor: pointer;
}
.inline-img a img {
    transition: filter 0.25s ease;
}
.inline-img a:hover img,
.inline-img a:focus-visible img {
    filter: brightness(0.82) contrast(1.08) saturate(1.15);
}
.inline-img img {
    display: block;
    width: min(100%, calc(var(--img-height) * var(--img-scale, 1)));
    height: auto;
    object-fit: cover;
}
.inline-img figcaption {
    margin-top: 4px;
    opacity: .75;
    font-size: .95em;
}

/* ---------- multi-column pages (default template) ---------- */
.page-stage {
    position: relative;
    z-index: 1;
    min-height: calc(100vh - var(--header-height));
    padding-inline: var(--side-inset);
}

/* ------------------------------------------------------------
   MOBILE
   ------------------------------------------------------------ */
@media (max-width: 780px) {
    :root {
        --stage-top: var(--stage-top-mobile);
        --chrome-fade: var(--chrome-fade-mobile);
        --chrome-band-pad-top: var(--chrome-band-pad-top-mobile);
    }

    .home-stage,
    .menu-stage,
    .page-stage,
    .event-stage {
        --chrome-outset: var(--side-inset-mobile);
    }

    .page-chrome {
        padding-inline: var(--side-inset-mobile);
    }

    .events-page .site-footer,
    .simple-stage .site-footer {
        padding-inline: var(--side-inset-mobile);
    }

    .home-stage,
    .event-stage {
        padding-inline: var(--side-inset-mobile);
    }

    .site-header {
        display: none;
    }

    .nav-toggle {
        display: block;
    }

    .site-logo img {
        width: var(--logo-width-mobile);
    }

    .site-footer {
        grid-template-columns: 1fr;
        gap: 28px;
        padding: 28px 0 48px;
    }

    .layout-row {
        grid-template-columns: 1fr;
    }
    .col { grid-column: span 1; }
    .col:nth-child(n) { padding-top: 0; }

    .page-home .manifesto-body {
        gap: 2rem;
    }
    .page-home .layout-row {
        row-gap: 2rem;
    }
    .page-home .col {
        display: flex;
        flex-direction: column;
        gap: 1.5rem;
    }
    .page-home .col > .inline-img,
    .page-home .col > figure.inline-img {
        margin-bottom: 0;
    }

    .page-stage {
        padding-inline: var(--side-inset-mobile);
    }
}