/* ivobachmann.ch – public site
   Motif: the 5 x 20 cm mesh of a gabion; the red logo slab is the one loud element. */

:root {
    --red: #e2001a;
    --red-dark: #b80015;
    --granite: #3d3f3c;
    --gneiss: #6f716b;
    --limestone: #ecebe6;
    --wire: #9ea3a0;
    --white: #ffffff;

    --font: "Helvetica Neue", Helvetica, Arial, "Nimbus Sans", "Liberation Sans", sans-serif;
    --step--1: 0.875rem;
    --step-0: 1.0625rem;
    --step-1: 1.25rem;
    --step-2: 1.5625rem;
    --step-3: 2rem;
    --step-4: clamp(2.125rem, 1.4rem + 3vw, 3.5rem);
    --step-5: clamp(2.5rem, 1.5rem + 4.5vw, 4.75rem);
    --line: #dcdcd6;
    --night: rgb(24 25 23);

    --gutter: clamp(1rem, 0.5rem + 2.5vw, 2.5rem);
    --max: 76rem;
    --header-h: 4.75rem;

    /* Gabion mesh: thin wires every 20px across, 80px along (ratio 5:20) */
    --mesh: repeating-linear-gradient(90deg, rgb(158 163 160 / 0.22) 0 1px, transparent 1px 20px),
            repeating-linear-gradient(0deg, rgb(158 163 160 / 0.22) 0 1px, transparent 1px 80px);
}

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

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

body {
    margin: 0;
    background: var(--white);
    color: var(--granite);
    font-family: var(--font);
    font-size: var(--step-0);
    line-height: 1.55;
}

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

a { color: var(--red-dark); text-underline-offset: 0.18em; }
a:hover { color: var(--red); }

:focus-visible { outline: 3px solid var(--red); outline-offset: 2px; }

.visually-hidden {
    position: absolute; width: 1px; height: 1px; overflow: hidden;
    clip: rect(0 0 0 0); white-space: nowrap;
}

.skip-link {
    position: absolute; left: 1rem; top: -4rem; z-index: 100;
    background: var(--granite); color: var(--white); padding: 0.5rem 1rem;
}
.skip-link:focus { top: 1rem; }

/* ---- Header ---------------------------------------------------------- */

.site-header {
    position: sticky; top: 0; z-index: 50;
    background: var(--white);
    border-bottom: 1px solid var(--limestone);
}

.site-header__inner {
    display: flex; align-items: stretch; justify-content: space-between;
    max-width: var(--max); margin: 0 auto -1px; padding: 0 var(--gutter);
    min-height: var(--header-h);
    /* overlap the header's bottom border so logo and active marker sit flush on the photo */
    position: relative;
}

.logo {
    display: flex; align-items: center; gap: 1rem;
    text-decoration: none; color: var(--granite);
}

.logo__mark {
    display: flex; align-items: center; align-self: stretch;
    background: var(--red); color: var(--white);
    padding: 0 1.25rem;
    font-size: 1.375rem; font-weight: 400; letter-spacing: 0.08em; white-space: nowrap;
}

.logo__mark--small {
    display: inline-block; padding: 0.5rem 0.875rem; font-size: 1rem;
}

.logo__claim {
    font-size: var(--step--1); line-height: 1.25; color: var(--gneiss); max-width: 14rem;
}

.nav-toggle { display: none; }

.header-call {
    display: none; align-items: center; gap: 0.4rem; align-self: center; margin-left: auto;
    padding: 0.55rem 0.9rem; border: 2px solid var(--granite);
    color: var(--granite); font-weight: 700; font-size: 0.9375rem; text-decoration: none; white-space: nowrap;
}
.header-call:hover { background: var(--red); border-color: var(--red); color: var(--white); }
.header-call__number { display: none; }

.main-nav { margin-left: auto; }

.main-nav__list {
    display: flex; height: 100%; margin: 0; padding: 0; list-style: none;
}

.main-nav__item { position: relative; display: flex; }

.main-nav__item > a {
    display: flex; align-items: center; padding: 0 0.75rem;
    color: var(--granite); text-decoration: none; font-weight: 700; font-size: 0.9375rem; white-space: nowrap;
    border-bottom: 4px solid transparent; border-top: 4px solid transparent;
}

.main-nav__item > a:hover,
.main-nav__item > a.is-active { border-bottom-color: var(--red); color: var(--granite); }

.main-nav__sub {
    position: absolute; top: 100%; left: 0; min-width: 16rem;
    margin: 0; padding: 0.5rem 0; list-style: none;
    background: var(--granite);
    visibility: hidden; opacity: 0; transform: translateY(-4px);
    transition: opacity 0.15s, transform 0.15s, visibility 0.15s;
}

.main-nav__item:hover .main-nav__sub,
.main-nav__item:focus-within .main-nav__sub { visibility: visible; opacity: 1; transform: none; }

.main-nav__sub a {
    display: block; padding: 0.5rem 1rem; color: var(--white); text-decoration: none; font-size: 0.9375rem;
}
.main-nav__sub a:hover, .main-nav__sub a[aria-current] { background: var(--red); color: var(--white); }

/* The red slab carries the brand; the claim is the home page title */
.logo__claim { display: none; }

@media (max-width: 1280px) {
    .header-call { display: flex; }
    :root { --header-h: 4rem; }

    .nav-toggle {
        display: block; position: relative; width: 3rem; margin-left: 0.5rem;
        background: none; border: 0; cursor: pointer;
    }
    .nav-toggle__bar,
    .nav-toggle__bar::before,
    .nav-toggle__bar::after {
        position: absolute; left: 50%; width: 1.5rem; height: 2px; margin-left: -0.75rem;
        background: var(--granite); content: ""; transition: transform 0.2s;
    }
    .nav-toggle__bar { top: 50%; }
    .nav-toggle__bar::before { top: -7px; }
    .nav-toggle__bar::after { top: 7px; }
    .nav-toggle[aria-expanded="true"] .nav-toggle__bar { background: transparent; }
    .nav-toggle[aria-expanded="true"] .nav-toggle__bar::before { transform: translateY(7px) rotate(45deg); }
    .nav-toggle[aria-expanded="true"] .nav-toggle__bar::after { transform: translateY(-7px) rotate(-45deg); }

    .main-nav {
        display: none; position: absolute; top: 100%; left: 0; right: 0;
        max-height: calc(100vh - var(--header-h)); overflow-y: auto;
        background: var(--granite);
    }
    .main-nav.is-open { display: block; }
    .main-nav__list { display: block; padding: 0.5rem 0 1rem; }
    .main-nav__item { display: block; }
    .main-nav__item > a {
        padding: 0.75rem var(--gutter); color: var(--white); border: 0;
    }
    .main-nav__item > a.is-active { color: var(--white); box-shadow: inset 4px 0 0 var(--red); }
    .main-nav__sub {
        position: static; visibility: visible; opacity: 1; transform: none;
        padding: 0 0 0.5rem; background: none;
    }
    .main-nav__sub a { padding: 0.4rem var(--gutter) 0.4rem calc(var(--gutter) + 1rem); color: #d9dbd8; }
}

@media (max-width: 560px) {
    .logo__mark { padding: 0 0.875rem; font-size: 1.125rem; }
    .header-call { padding: 0.45rem 0.65rem; }
}

/* ---- Hero ------------------------------------------------------------ */

.hero {
    position: relative; display: flex; align-items: flex-end;
    min-height: clamp(16rem, 42vh, 28rem);
    background: var(--granite); overflow: hidden;
}
/* Darkens the lower part of the photo so the white title stays readable */
.hero:not(.hero--plain)::after {
    content: ""; position: absolute; inset: 0; pointer-events: none;
    background: linear-gradient(180deg, rgb(24 25 23 / 0) 30%, rgb(24 25 23 / 0.72) 100%),
                linear-gradient(90deg, rgb(24 25 23 / 0.35), rgb(24 25 23 / 0) 60%);
}

.hero--home { min-height: clamp(24rem, 72vh, 44rem); }

.hero--plain {
    min-height: 0; padding-top: clamp(2.5rem, 6vw, 4.5rem);
    background-color: var(--limestone);
    background-image: var(--mesh);
}

.hero__slides { position: absolute; inset: 0; }

.hero__img {
    position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover;
    opacity: 0; transition: opacity 1.2s ease;
}
.hero__img.is-active { opacity: 1; }

.hero__content {
    position: relative; z-index: 1; width: 100%; max-width: var(--max); margin: 0 auto;
    padding: 0 var(--gutter) clamp(1.75rem, 4vw, 3.25rem);
}

.hero__title {
    max-width: 22ch; margin: 0;
    color: var(--white); text-shadow: 0 2px 24px rgb(0 0 0 / 0.35);
    font-size: var(--step-4); line-height: 1.05; font-weight: 700; letter-spacing: -0.025em;
    overflow-wrap: anywhere; hyphens: auto;
}
.hero__title::before {
    content: ""; display: block; width: 4.5rem; height: 6px; margin-bottom: 1rem; background: var(--red);
}

.hero--plain { padding-top: clamp(2.5rem, 6vw, 4.5rem); }
.hero--plain .hero__title { color: var(--granite); text-shadow: none; }

.hero--home .hero__title { max-width: 16ch; font-size: var(--step-5); }

.hero__actions { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-top: 1.75rem; }

.button {
    display: inline-flex; align-items: center; padding: 0.85rem 1.35rem;
    font-weight: 700; text-decoration: none; border: 2px solid transparent;
}
.button--red { background: var(--red); color: var(--white); }
.button--red:hover { background: var(--red-dark); color: var(--white); }
.button--light { border-color: var(--white); color: var(--white); }
.button--light:hover { background: var(--white); color: var(--granite); }

.breadcrumb ol {
    display: flex; flex-wrap: wrap; gap: 0.25rem 0.5rem; margin: 0 0 0.5rem; padding: 0; list-style: none;
    font-size: var(--step--1);
}
.breadcrumb li + li::before { content: "/"; margin-right: 0.5rem; color: var(--wire); }
.breadcrumb ol { margin-bottom: 1rem; }
.breadcrumb li + li::before { color: rgb(255 255 255 / 0.6); }
.breadcrumb a { color: var(--white); text-decoration: none; font-weight: 700; text-shadow: 0 1px 8px rgb(0 0 0 / 0.5); }
.hero--plain .breadcrumb a { color: var(--gneiss); text-shadow: none; }
.breadcrumb a:hover { text-decoration: underline; }

/* ---- Layout ---------------------------------------------------------- */

.container {
    max-width: var(--max); margin: 0 auto;
    padding: clamp(2rem, 4vw, 3.5rem) var(--gutter) clamp(3rem, 6vw, 5rem);
}

.container--sidebar {
    display: grid; gap: clamp(2rem, 4vw, 4rem);
    grid-template-columns: minmax(0, 1fr) 18.5rem;
    align-items: start;
}

@media (max-width: 960px) {
    .container--sidebar { grid-template-columns: minmax(0, 1fr); }
}

.content > .section + .section { margin-top: 2rem; }

.sidebar { display: grid; gap: 1.25rem; font-size: 0.9375rem; }
.sidebar .section {
    padding: 1.25rem 1.25rem 1rem; background: var(--limestone);
    border-top: 4px solid var(--red);
}
.sidebar .section + .section { margin-top: -1.25rem; border-top: 0; padding-top: 0; }

/* ---- Prose ----------------------------------------------------------- */

.prose { max-width: 70ch; }
.prose > :first-child { margin-top: 0; }
.prose > :last-child { margin-bottom: 0; }
.prose p, .prose ul, .prose ol, .prose blockquote, .prose table { margin: 0 0 1em; }
.prose h2, .prose h3, .prose h4 { line-height: 1.2; margin: 1.6em 0 0.5em; color: var(--granite); }
.prose h2 { font-size: var(--step-3); letter-spacing: -0.01em; }
.prose h3 { font-size: var(--step-2); }
.prose h4 { font-size: var(--step-1); }
.prose ul { padding-left: 0; list-style: none; }
.prose ul > li { position: relative; padding-left: 1.25rem; margin-bottom: 0.3em; }
.prose ul > li::before {
    content: ""; position: absolute; left: 0; top: 0.6em;
    width: 0.5rem; height: 0.5rem; border: 2px solid var(--red);
}
.prose ol { padding-left: 1.4rem; }
.prose blockquote {
    margin-left: 0; padding: 0.25rem 0 0.25rem 1.25rem;
    border-left: 4px solid var(--red); font-size: var(--step-1); color: var(--gneiss);
}
.prose img { margin: 0 0 1rem; }
.prose p > img:first-child:not(:only-child) { float: right; max-width: 45%; margin: 0.25rem 0 1rem 1.25rem; }
.prose a[href^="/download/"]::before {
    content: "PDF"; display: inline-block; margin-right: 0.4em; padding: 0.05em 0.3em;
    font-size: 0.7em; font-weight: 700; letter-spacing: 0.04em; vertical-align: 0.15em;
    color: var(--white); background: var(--red); text-decoration: none;
}

.prose table {
    display: block; max-width: 100%; overflow-x: auto;
    border-collapse: collapse; font-size: 0.9375rem;
}
.prose td, .prose th {
    padding: 0.5rem 0.75rem; text-align: left; vertical-align: top;
    border-bottom: 1px solid var(--limestone);
}
.prose tr:first-child td { font-weight: 700; border-bottom: 2px solid var(--wire); }
.prose td p { margin: 0; }
.prose td img { margin: 0; }

/* ---- Figures, grids -------------------------------------------------- */

.figure { margin: 0; }
.figure img { width: auto; max-width: 100%; }
.figure a { display: inline-block; }

.grid { display: grid; gap: 2rem 1.5rem; }
.grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid__column > * + * { margin-top: 0.75rem; }

/* Line up headings, images and texts across columns */
@supports (grid-template-rows: subgrid) {
    .grid { row-gap: 0.75rem; }
    .grid__column { display: grid; grid-template-rows: subgrid; align-content: start; }
    .grid__column > * + * { margin-top: 0; }
    .grid--rows-1 > .grid__column { grid-row: span 1; }
    .grid--rows-2 > .grid__column { grid-row: span 2; }
    .grid--rows-3 > .grid__column { grid-row: span 3; }
    .grid--rows-4 > .grid__column { grid-row: span 4; }
    .grid--rows-5 > .grid__column { grid-row: span 5; }
    .grid--rows-6 > .grid__column { grid-row: span 6; }
    .grid--rows-7 > .grid__column { grid-row: span 7; }
    .grid--rows-8 > .grid__column { grid-row: span 8; }
    .grid__column .prose h2, .grid__column .prose h3, .grid__column .prose h4 { margin-bottom: 0; }
    .grid__column { margin-bottom: 1.75rem; }
}
.grid__column .prose h4 { font-size: var(--step-1); }
.grid__column .prose { font-size: 0.9375rem; }
.grid__column .prose p { margin-bottom: 0.25em; }
.grid__column .figure img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; }

@media (max-width: 960px) {
    .grid--3, .grid--4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 560px) {
    .grid--2, .grid--3, .grid--4 { grid-template-columns: minmax(0, 1fr); }
}

/* ---- Gallery --------------------------------------------------------- */

.gallery { display: grid; gap: 4px; }
.gallery--cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.gallery--cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.gallery--cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

@media (max-width: 720px) {
    .gallery--cols-3, .gallery--cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.gallery__item { position: relative; margin: 0; }
.gallery.is-collapsed .gallery__item:nth-child(n + 10) { display: none; }
.gallery__more {
    grid-column: 1 / -1; justify-self: start; margin-top: 0.75rem; padding: 0.625rem 1.125rem;
    border: 2px solid var(--granite); background: var(--white); color: var(--granite);
    font: inherit; font-weight: 700; cursor: pointer;
}
.gallery__more:hover { background: var(--granite); color: var(--white); }

.gallery__open {
    display: block; width: 100%; padding: 0; border: 0; cursor: zoom-in; background: var(--limestone);
}

.gallery__img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; transition: filter 0.2s; }
.gallery__open:hover .gallery__img { filter: brightness(1.08); }

.gallery--grid .gallery__caption {
    position: absolute; left: 0; right: 0; bottom: 0; pointer-events: none;
    padding: 1.5rem 0.625rem 0.5rem; font-size: var(--step--1); line-height: 1.3; color: var(--white);
    background: linear-gradient(transparent, rgb(30 31 29 / 0.8));
}

.gallery--team { gap: 2rem 1.5rem; }
.gallery--team .gallery__img { aspect-ratio: 3 / 4; }
.gallery--team .gallery__caption { padding-top: 0.625rem; font-size: 0.9375rem; font-weight: 700; }

/* ---- Accordion (former tabs) ----------------------------------------- */

.accordion { border-top: 2px solid var(--granite); }

.accordion__item { border-bottom: 1px solid var(--wire); }

.accordion__title {
    display: flex; justify-content: space-between; align-items: center; gap: 1rem;
    padding: 1rem 0; cursor: pointer; list-style: none;
    font-size: var(--step-1); font-weight: 700;
}
.accordion__title::-webkit-details-marker { display: none; }
.accordion__title::after {
    content: ""; flex: none; width: 0.875rem; height: 0.875rem;
    background: linear-gradient(var(--red), var(--red)) center / 100% 2px no-repeat,
                linear-gradient(var(--red), var(--red)) center / 2px 100% no-repeat;
    transition: transform 0.2s;
}
.accordion__item[open] > .accordion__title::after { transform: rotate(45deg); }
.accordion__title:hover { color: var(--red-dark); }

.accordion__body { padding: 0 0 1.75rem; }
.accordion__body > * + * { margin-top: 1.25rem; }

/* ---- Subpages, home teasers ------------------------------------------ */

.subpages {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr)); gap: 4px;
    margin-top: 3rem;
}
.subpages { gap: 0.75rem; }
.subpages__link {
    position: relative; display: flex; align-items: flex-end; min-height: 6.5rem; padding: 1.125rem 3rem 1.125rem 1.25rem;
    background: var(--white); border: 1px solid var(--line); border-top: 4px solid var(--red);
    color: var(--granite); font-weight: 700; line-height: 1.3; text-decoration: none;
}
.subpages__link::after {
    content: ""; position: absolute; right: 1.25rem; bottom: 1.4rem; width: 0.6rem; height: 0.6rem;
    border-top: 2px solid var(--red); border-right: 2px solid var(--red); transform: rotate(45deg);
}
.subpages__link:hover { background: var(--granite); border-color: var(--granite); border-top-color: var(--red); color: var(--white); }

.teasers { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: clamp(0.75rem, 2vw, 1.5rem); }
@media (max-width: 720px) { .teasers { grid-template-columns: minmax(0, 1fr); } }

.teaser { position: relative; overflow: hidden; background: var(--granite); }
.teaser .prose { max-width: none; }
.teaser .prose p { margin: 0; }
.teaser img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; margin: 0; transition: transform 0.4s ease; }
.teaser:hover img { transform: scale(1.03); }
.teaser a { display: block; text-decoration: none; color: var(--white); font-size: var(--step-3); font-weight: 700; line-height: 1.1; }
/* Title lies on the photo; the whole card is clickable through the stretched link */
.teaser p:last-child { position: absolute; left: 0; right: 0; bottom: 0; }
.teaser p:last-child a {
    padding: 4rem 1.5rem 1.4rem; background: linear-gradient(transparent, rgb(24 25 23 / 0.8));
    text-shadow: 0 1px 12px rgb(0 0 0 / 0.4);
}
.teaser p:last-child a::before {
    content: ""; display: block; width: 3rem; height: 5px; margin-bottom: 0.75rem; background: var(--red);
}
.teaser:hover p:last-child a { color: var(--white); }

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

.site-footer { background: var(--granite); color: #d9dbd8; font-size: 0.9375rem; }
.site-footer { border-top: 6px solid var(--red); }
.site-footer__inner {
    display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) minmax(0, 0.8fr); gap: 2.5rem;
    max-width: var(--max); margin: 0 auto; padding: 3.5rem var(--gutter) 2.5rem;
}
@media (max-width: 860px) { .site-footer__inner { grid-template-columns: minmax(0, 1fr); gap: 2rem; } }
.site-footer__title { margin: 0 0 0.875rem; color: var(--white); font-size: 1rem; }
.site-footer__contact ul { margin: 0.75rem 0 0; padding: 0; list-style: none; }
.site-footer__contact li { margin-bottom: 0.4rem; }
.site-footer__contact p { margin: 0; }
.site-footer__phone { font-size: var(--step-1); font-weight: 700; text-decoration: none; }
.site-footer__address { margin-top: 1rem; }
.site-footer a { color: var(--white); }
.site-footer__nav ul { margin: 0; padding: 0; list-style: none; }
.site-footer__nav li { margin-bottom: 0.4rem; }
.site-footer__nav a { text-decoration: none; }
.site-footer__nav a:hover { text-decoration: underline; }
.site-footer__copy {
    max-width: var(--max); margin: 0 auto; padding: 1rem var(--gutter) 2rem;
    border-top: 1px solid rgb(255 255 255 / 0.12); font-size: var(--step--1);
}

/* ---- Lightbox -------------------------------------------------------- */

.lightbox {
    width: 100vw; height: 100vh; max-width: none; max-height: none; margin: 0; padding: 0;
    border: 0; background: rgb(24 25 23 / 0.96); color: var(--white);
}
.lightbox::backdrop { background: transparent; }

.lightbox__frame {
    display: flex; gap: 2rem; align-items: center; justify-content: center;
    height: 100%; padding: 4rem 5rem;
}
.lightbox__img { max-height: 100%; max-width: 100%; width: auto; object-fit: contain; min-width: 0; }
.lightbox__text:empty, .lightbox__text.is-empty { display: none; }
.lightbox__text { flex: 0 1 26rem; max-height: 100%; overflow-y: auto; }
.lightbox__caption { margin: 0 0 1rem; font-weight: 700; font-size: var(--step-1); }
.lightbox__caption:empty { display: none; }
.lightbox__description { color: #e4e5e2; font-size: 0.9375rem; }
.lightbox__description h2, .lightbox__description h3, .lightbox__description h4 { color: var(--white); }
.lightbox__description h2:first-child { display: none; }

.lightbox__btn {
    position: absolute; width: 3rem; height: 3rem; border: 0; cursor: pointer;
    background: rgb(255 255 255 / 0.1); color: var(--white); font-size: 2rem; line-height: 1;
}
.lightbox__btn:hover { background: var(--red); }
.lightbox__close { top: 1rem; right: 1rem; }
.lightbox__prev { left: 1rem; top: 50%; transform: translateY(-50%); }
.lightbox__next { right: 1rem; top: 50%; transform: translateY(-50%); }

@media (max-width: 720px) {
    .lightbox__frame { flex-direction: column; padding: 4rem 1rem 1rem; gap: 1rem; overflow-y: auto; justify-content: flex-start; }
    .lightbox__img { max-height: 60vh; }
    .lightbox__text { flex: none; max-height: none; }
    .lightbox__prev, .lightbox__next { top: auto; bottom: 1rem; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { transition-duration: 0.01ms !important; }
}

@media print {
    .site-header, .site-footer__nav, .hero__slides, .lightbox { display: none !important; }
    .hero { min-height: 0; background: none; }
}
