/*
 * Contao 5.7 additions for the Cords theme – replaces the CSS that came with the
 * removed PCT modules (AutoGrid, Revolution Slider, Supersized).
 */

/* --- Grid (replaces PCT AutoGrid) -------------------------------------------
   Element group with CSS class "grid grid--2|3|4"; nested elements become columns.
   Same gutter (1% each side) and breakpoints as AutoGrid. */
.grid {margin-left: -1%; margin-right: -1%; display: flex; flex-wrap: wrap; align-items: flex-start;}
.grid > * {box-sizing: border-box; padding-left: 1%; padding-right: 1%; flex: 0 0 100%; max-width: 100%;}
.grid--2 > * {flex-basis: 50%; max-width: 50%;}
.grid--3 > * {flex-basis: 33.3333%; max-width: 33.3333%;}
.grid--4 > * {flex-basis: 25%; max-width: 25%;}
/* Teaser boxes (home) sit edge to edge, like before */
.grid:has(> .ce_imagebox) {margin-left: 0; margin-right: 0;}
.grid > .ce_imagebox {padding-left: 0; padding-right: 0;}

/* Columns from former AutoGrid wrappers: their inner ".inside" div picked up the theme's
   "#main .inside" padding (20px 50px 50px) – keep that look */
#main .grid > .grid__col {padding: 20px calc(1% + 50px) 50px;}
@media only screen and (max-width: 768px) {
	#main .grid > .grid__col {padding: 20px calc(1% + 20px) 50px;} /* theme: body.padding #main .inside on mobile */
}

/* Like AutoGrid "adjust_mobile": only the team grid switches to two columns on tablets
   (the teaser boxes on the home page stay in one row) */
@media only screen and (min-width: 768px) and (max-width: 990px) {
	.grid--4 > * {flex-basis: 50%; max-width: 50%;}
}
@media only screen and (max-width: 767px) {
	.grid > * {flex-basis: 100% !important; max-width: 100% !important;}
}

/* --- Without jQuery (theme.js) ------------------------------------------------ */
/* Sidebar: like slimScroll – native scrollbar hidden (keeps the full 300px width), a slim bar is laid
   over the content while hovering/scrolling (theme.js); wheel, touch and keyboard scrolling stay native */
#header {scrollbar-width: none;}
#header::-webkit-scrollbar {display: none;}
.sidebar-scrollbar {position: fixed; top: 0; left: 293px; width: 7px; border-radius: 7px; background: rgba(0,0,0,0.4); opacity: 0; transition: opacity 0.4s; z-index: 5001; pointer-events: none;}
.sidebar-scrollbar.is-visible {opacity: 1;}
/* Sidebar fits the screen: the theme reserved 260px at the bottom for language switcher + social icons
   (both hidden in customize.css already) – keep only the space the copyright line needs */
#header .inside {padding-bottom: 90px; display: flow-root;} /* flow-root: logo margin stays inside (no overflow) */
@media only screen and (max-width: 767px), screen and (min-device-width : 768px) and (max-device-width : 1024px) and (orientation : portrait) {
	#header .inside {padding-bottom: 110px;} /* copyright sits at bottom: 65px in the mobile menu */
	#header.mobopen {height: calc(100% - 50px);} /* menu panel starts below the 50px bar – don't run off screen */
	#header .logo {display: none;} /* logo + name are in the top bar already – no second logo in the menu panel */
	#header nav.mainmenu {margin-top: 10px;}
	#header form input[type="image"] {max-width: 240px;} /* donation button: same size as in the desktop sidebar */
}
/* Lower desktop screens (e.g. laptops with 768px height): a bit tighter, so everything incl. copyright fits */
/* Sub menu arrow: the theme centres it with a fixed line-height of 42px (52px link − 2 × 5px inset of the
   divider line). Centre it with flex instead, so it also fits the smaller menu items below. */
nav.mainmenu a.submenu:after {display: flex; align-items: center; line-height: 1;}

/* The logo graphic is 485×343 with transparent margins (horse y 81–185, text y 193–242). The smaller logo
   boxes scale the graphic so horse + text fit completely (instead of cropping it). */
@media only screen and (min-width: 991px) and (max-height: 860px) {
	#header .logo {height: 100px; margin-top: 20px; background-size: 283px auto !important; background-position: center -44px !important;}
	nav.mainmenu a {padding-top: 10px; padding-bottom: 10px;}
	#header form input[type="image"] {width: 65% !important;}
}
@media only screen and (min-width: 991px) and (max-height: 700px) {
	#header .logo {height: 80px; margin-top: 15px; background-size: 223px auto !important; background-position: center -34px !important;}
	nav.mainmenu a {padding-top: 7px; padding-bottom: 7px;}
	#header form input[type="image"] {width: 50% !important;}
}

/* Mobile top bar: small logo (horse head cut from the logo graphic) + name, links to the home page */
.mobheader__brand {position: absolute; left: 15px; top: 6px; height: 38px; display: flex; align-items: center; gap: 10px; color: rgba(255,255,255,0.9); text-decoration: none; max-width: calc(100% - 80px);}
.mobheader .mobheader__icon {display: block; flex: 0 0 auto; width: 54px; height: 38px; margin: 0; background-size: 177px auto !important; background-position: -64px -30px !important; transition: none;}
.mobheader__name {font-family: 'Raleway', Georgia, serif; font-weight: 400; font-size: 11px; line-height: 15px; letter-spacing: 0.08em; text-transform: uppercase; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;}
.mobheader__brand:focus-visible {outline: 2px solid #fff; outline-offset: 2px;}
@media only screen and (max-width: 330px) {
	.mobheader__name {display: none;} /* very narrow phones: horse only */
}

/* "To top" link fades in/out (was jQuery fadeIn/fadeOut) */
#linktotop {display: block; opacity: 0; visibility: hidden; transition: opacity 0.6s, visibility 0.6s;}
#linktotop.is-visible {opacity: 1; visibility: visible;}
@media only screen and (max-width: 767px) {
	#linktotop, #linktotop.is-visible {display: none;} /* theme: hidden on mobile */
}
.open_subnav:focus-visible, .menu-btn:focus-visible, #linktotop:focus-visible {outline: 2px solid #fff; outline-offset: -2px;}

/* Lightbox (replaces Colorbox) */
dialog.lightbox {border: 0; padding: 0; background: transparent; max-width: 100vw; max-height: 100vh; width: 100vw; height: 100vh; overflow: hidden;}
dialog.lightbox::backdrop {background: rgba(0,0,0,0.85);}
.lightbox__figure {margin: 0; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; pointer-events: none;}
.lightbox__img {max-width: 95vw; max-height: 88vh; width: auto; height: auto; box-shadow: 0 0 25px rgba(0,0,0,0.6); pointer-events: auto;}
.lightbox__caption {color: #fff; margin-top: 10px; font-size: 15px; pointer-events: auto;}
.lightbox__btn {position: absolute; border: 0; background: rgba(0,0,0,0.4); color: #fff; width: 50px; height: 50px; cursor: pointer; font-size: 28px; line-height: 50px; padding: 0;}
.lightbox__btn:hover, .lightbox__btn:focus-visible {background: rgba(0,0,0,0.7);}
.lightbox__close {top: 15px; right: 15px;}
.lightbox__close:before {content: "\00d7"; font-size: 36px;}
.lightbox__prev, .lightbox__next {top: 50%; margin-top: -25px;}
.lightbox__prev {left: 15px;}
.lightbox__next {right: 15px;}
.lightbox__prev:before {font-family: "icons"; content: "\ea07";}
.lightbox__next:before {font-family: "icons"; content: "\ea08";}
.lightbox--single .lightbox__prev, .lightbox--single .lightbox__next {display: none;}

/* --- Image margins (Contao 5 dropped the "imagemargin" field) ---------------- */
.img-ml-20pct figure {margin-left: 20%;}

/* --- Home header image (replaces Revolution Slider) --------------------------
   Like the old slider ("fullScreenOffsetContainer: #wrapper"): the image fills the
   viewport minus the content below it, so the teaser boxes stay visible. Mobile: 100vh. */
#header_after .hero {margin: 0;}
#header_after .hero__figure {margin: 0; height: 100vh; overflow: hidden;}
#header_after .hero__figure img {display: block; width: 100%; height: 100%; object-fit: cover; object-position: center center;}

@media only screen and (min-width: 768px) {
	#contentwrapper:has(.hero) {display: flex; flex-direction: column; height: 100vh;}
	#contentwrapper:has(.hero) > #wrapper {flex: 0 0 auto;}
	#contentwrapper:has(.hero) > #header_after,
	#contentwrapper:has(.hero) > #header_after > .inside,
	#contentwrapper:has(.hero) > #header_after .mod_article,
	#contentwrapper:has(.hero) > #header_after .hero {display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0;}
	#contentwrapper:has(.hero) .hero__figure {flex: 1 1 auto; height: auto; min-height: 300px;}
}

/* --- Photo gallery (replaces Supersized) -------------------------------------
   Full-screen slideshow next to the 300px sidebar, like before. */
.gallery-slider {position: fixed; top: 0; right: 0; bottom: 0; left: 300px; margin: 0; background: #111; z-index: 1;}
.gallery-slider .swiper {width: 100%; height: 100%;}
.gallery-slider .swiper-slide {background: #111;}
.gallery-slider .swiper-slide .ce_image, .gallery-slider .swiper-slide figure {margin: 0; height: 100%;}
.gallery-slider .swiper-slide img {display: block; width: 100%; height: 100%; object-fit: cover;}
.gallery-slider figcaption.caption {position: absolute; left: 50px; bottom: 50px; color: #393939; background: rgba(255,255,255,0.9); display: inline-block; padding: 15px 25px; font-family: 'Raleway', Georgia, serif; font-weight: 300; font-size: 26px; line-height: 1.3; max-width: calc(100% - 250px);}

/* Controls like Supersized: progress bar at the very top, column bottom right */
.gallery-progress {position: fixed; top: 0; left: 0; width: 100%; height: 8px; overflow: hidden; z-index: 5; background: url('../scripts/supersized/img/progress-back.png') repeat-x;}
.gallery-progress__bar {height: 8px; width: 100%; transform: translateX(-100%); background: url('../scripts/supersized/img/progress-bar.png') repeat-x;}
.gallery-navi {position: fixed; right: 50px; bottom: 50px; width: 100px; z-index: 5;}
.gallery-counter {color: #fff; font-family: 'Raleway', Georgia, serif; font-weight: 300; font-size: 30px; line-height: 42px; text-align: center; text-shadow: 0 1px 3px rgba(0,0,0,0.5);}
.gallery-controls {border-top: 1px solid rgba(255,255,255,0.4); border-bottom: 1px solid rgba(255,255,255,0.4); margin-bottom: 10px;}
.gallery-pauseplay {display: inline-block; padding: 10px; border: 0; background: transparent; cursor: pointer; text-shadow: #000 0 -1px 0;}
.gallery-pauseplay:before {font-family: "icons"; content: "\eb63"; display: inline-block; position: relative; color: #fff; font-size: 18px; line-height: 1;}
.gallery-pauseplay.is-playing:before {content: "\2389";}
.gallery-pauseplay:hover:before {color: rgba(255,255,255,0.9);}
.gallery-thumb {display: block; position: relative; width: 100px; height: 75px; padding: 0; overflow: hidden; background: #ddd; border: 1px solid #fff; box-shadow: 0 0 5px #000; cursor: pointer;}
.gallery-thumb--prev {margin-bottom: 10px;}
.gallery-thumb img {width: 150px; max-width: none; height: auto; display: block;}
.gallery-thumb:before {font-family: "icons"; content: "\ea07"; position: absolute; left: 50%; top: 0; margin-left: -6px; z-index: 1; line-height: 75px; font-size: 25px; color: #fff; text-shadow: 0 2px 2px rgba(0,0,0,0.3); transition: all 0.3s ease;}
.gallery-thumb--next:before {content: "\ea08";}
.gallery-thumb--prev:hover:before {left: 20px;}
.gallery-thumb--next:hover:before {left: 80px;}

/* Mobile layout of the theme (no sidebar, 50px header bar): full screen below the bar, like Supersized */
@media only screen and (max-width: 767px), screen and (min-device-width : 768px) and (max-device-width : 1024px) and (orientation : portrait) {
	.gallery-slider {top: 50px; left: 0;}
	.gallery-progress {position: absolute;}
	.gallery-navi {right: 20px; bottom: 20px;}
}
@media only screen and (max-width: 767px) {
	.gallery-slider figcaption.caption {left: 15px; bottom: 20px; font-size: 15px; padding: 5px 10px; max-width: calc(100% - 150px);}
}
