/* ============================================================
   Homepage — sister page of communitas-project.eu
   ============================================================ */

/* ---------- HERO ---------- */
.hero {
    position: relative;
    padding: clamp(1.5rem, 3vw, 2.5rem) 0;
    overflow: hidden;
    isolation: isolate;
    color: #ffffff;
    /* Force exactly viewport-minus-header so the bottom of the bg image
       lines up with the bottom of the screen on first paint. svh accounts
       for mobile browser chrome; vh is the fallback for older engines. */
    height: calc(100vh - var(--header-h));
    height: calc(100svh - var(--header-h));
    min-height: 480px;
    display: flex;
    align-items: center;
    /* Local image is the fallback shown until JS swaps in the rotating
       remote images (and if JS fails or the remote ones don't load). */
    background:
        linear-gradient(120deg, rgba(20, 22, 24, 0.45) 0%, rgba(20, 22, 24, 0.30) 55%, rgba(236, 100, 76, 0.25) 100%),
        url("../icons/pexels-pixabay-356049.jpg") center/cover no-repeat;
}

/* Rotating background layers (injected by JS in base.html). Two layers
   crossfade every ~10s; each layer carries its own gradient overlay so
   the dark+coral tinting applies to every image, not just the fallback. */
.hero__bg {
    position: absolute;
    inset: 0;
    z-index: -1;
    opacity: 0;
    transition: opacity 1.4s ease-in-out;
    pointer-events: none;
    background:
        linear-gradient(120deg, rgba(20, 22, 24, 0.45) 0%, rgba(20, 22, 24, 0.30) 55%, rgba(236, 100, 76, 0.25) 100%),
        var(--hero-bg-url, none) center/cover no-repeat;
}
.hero__bg.is-active { opacity: 1; }
@media (prefers-reduced-motion: reduce) {
    .hero__bg { transition: none; }
}
.hero__inner {
    width: var(--container-w);
    margin-inline: auto;
    position: relative;
    z-index: 1;
}
.hero__copy {
    position: relative;
    z-index: 2;
    background: rgba(33, 37, 41, 0.72);
    backdrop-filter: blur(10px) saturate(140%);
    -webkit-backdrop-filter: blur(10px) saturate(140%);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--radius-lg);
    /* Vertical padding scales with viewport height so the card never exceeds
       the (height-locked) hero on short screens. Horizontal padding stays
       width-driven. */
    padding: clamp(1.2rem, min(3.5vh, 3vw), 2.8rem) clamp(1.5rem, 3vw, 3rem);
    max-width: 64ch;
    /* Nudge the card toward the centre on wider viewports without fully
       centring it — the rotating logo on the right still gets to breathe. */
    margin-left: clamp(0px, 6vw, 6rem);
    box-shadow: 0 18px 48px rgba(0, 0, 0, 0.28);
}

.hero__eyebrow {
    margin-bottom: clamp(0.6rem, 1.6vh, 1.4rem);
    color: #ffffff;
}
.hero__eyebrow.eyebrow--accent { color: var(--accent); }

/* Visual: large spinning logo, anchored to .hero so it centers on the bg image */
.hero__visual {
    position: absolute;

    right: -15vw;
    transform: translateY(-50%);
    display: grid;
    place-items: center;
    aspect-ratio: 1 / 1;
    /* The square is constrained by BOTH the design's preferred width AND the
       hero's available height (minus a small inset). The min() keeps the
       spinning logo slightly smaller than the rotating background image so
       it never gets clipped at top/bottom by the hero's overflow:hidden. */
    width: min(clamp(420px, 60vw, 880px), calc(100svh - var(--header-h) - 2.5rem));
    z-index: 0;
    pointer-events: none;
}
.hero__visual::before {
    content: "";
    position: absolute;
    inset: 6%;
    border-radius: 999px;
    background: radial-gradient(closest-side, rgba(236, 100, 76, 0.32), transparent 72%);
    z-index: 0;
}
.hero__core {
    position: relative;
    z-index: 1;
    /* Lock both dimensions so the rendered logo is always a fixed-ratio square,
       independent of the source PNG's aspect ratio. object-fit:contain keeps
       the artwork centred within the box if the image is ever non-square. */
    width: 92%;
    height: 92%;
    object-fit: contain;
    animation: spin-slow 28s linear infinite;
    filter: drop-shadow(0 10px 28px rgba(0, 0, 0, 0.45));
}

.hero__title {
    font-family: var(--font-display);
    font-weight: 700;
    /* Take the smaller of the viewport-width and viewport-height target so
       the title shrinks on short screens (1366×768 with bookmarks bar etc.)
       instead of pushing the card past the hero box. */
    font-size: clamp(1.9rem, min(7vh, 1.5rem + 3.6vw), 4.5rem);
    line-height: 1.08;
    letter-spacing: -0.015em;
    margin: 0 0 clamp(0.7rem, 1.8vh, 1.4rem);
    color: #ffffff;
    max-width: 22ch;
}

.hero__lede {
    font-size: clamp(0.95rem, min(2.4vh, 1rem + 0.45vw), 1.4rem);
    line-height: 1.5;
    color: rgba(255, 255, 255, 0.88);
    max-width: 52ch;
    margin: 0 0 clamp(1rem, 2.6vh, 2rem);
    font-weight: 300;
}

.hero__actions {
    display: flex;
    gap: 0.8rem;
    flex-wrap: wrap;
}
.hero .btn--ghost {
    --btn-fg: #ffffff;
    --btn-bd: rgba(255, 255, 255, 0.5);
}
.hero .btn--ghost:hover {
    --btn-bg: #ffffff;
    --btn-fg: var(--ink);
    --btn-bd: #ffffff;
}

/* ---------- ABOUT / PRINCIPLES ---------- */
.about {
    padding: clamp(3.5rem, 6vw, 6rem) 0;
    scroll-margin-top: var(--header-h);
    background: var(--paper);
}
.about__inner {
    width: var(--container);
    margin-inline: auto;
}
.principles {
    list-style: none;
    margin: 0;
    padding: 0;
    position: relative;
    height: clamp(480px, 56vw, 580px);
    perspective: 1400px;
    margin-block: clamp(2rem, 4vw, 3.5rem);
}
.principle {
    position: absolute;
    top: 50%;
    left: 50%;
    width: clamp(260px, 32vw, 360px);
    min-height: clamp(360px, 42vw, 460px);
    margin: 0;
    padding: clamp(1.8rem, 2.4vw, 2.4rem);
    border-radius: var(--radius-lg);
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 0.85rem;
    box-shadow: 0 14px 40px rgba(0, 0, 0, 0.16);
    animation: carousel-shift 30s ease-in-out infinite reverse;
    transition: translate 0.35s var(--ease), box-shadow 0.35s var(--ease);
    will-change: transform, opacity;
}
/* Phase offsets place card 1 at front, with 2/3/4 lined up so each takes the
   front slot in turn (1 → 2 → 3 → 4 → 1). The forward keyframe rotates
   front → right → back → left, so the card currently at "left" is the next to
   reach front; that card is card 2, hence its larger negative delay. */
.principle:nth-child(1) { animation-delay: 0s; }
.principle:nth-child(2) { animation-delay: -22.5s; }
.principle:nth-child(3) { animation-delay: -15s; }
.principle:nth-child(4) { animation-delay: -7.5s; }

/* Alternating: orange + light, like the parent site */
.principle:nth-child(odd) {
    background: linear-gradient(160deg, #fd867f 0%, #ec644c 100%);
    border: 1px solid rgba(255, 255, 255, 0.18);
    color: #ffffff;
}
.principle:nth-child(odd) .principle__num { color: rgba(255, 255, 255, 0.85); }
.principle:nth-child(odd) .principle__title { color: #ffffff; }
.principle:nth-child(odd) .principle__text { color: rgba(255, 255, 255, 0.92); }

.principle:nth-child(even) {
    background: var(--paper);
    border: 1px solid var(--paper-line);
    color: var(--ink);
}

.principles:has(.principle:hover) .principle { animation-play-state: paused; }

/* When paused on hover, lift the hovered card. `translate` composes with
   `transform`, so the lift adds without overriding carousel position
   (CSS-driven mode) or the JS-set position. */
.principle:hover {
    translate: 0 -10px;
    box-shadow: 0 22px 48px rgba(0, 0, 0, 0.22);
}

/* JS-driven mode: a tiny script (see base.html) takes over positioning so the
   user can grab any card and drag the carousel around. The CSS keyframe
   animation is disabled while still letting `translate` (hover lift) compose. */
.principles--js .principle {
    animation: none;
}
.principles--js .principle,
.principles--js .principle:hover {
    cursor: grab;
    user-select: none;
}
.principles--js.is-dragging,
.principles--js.is-dragging .principle,
.principles--js.is-dragging .principle:hover {
    cursor: grabbing;
}
.principles--js {
    /* Allow native vertical scroll, intercept horizontal for the drag handler. */
    touch-action: pan-y;
}

.principle__num {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 0.78rem;
    letter-spacing: 0.18em;
    color: var(--accent);
    text-transform: uppercase;
}
.principle__title {
    margin: 0;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: var(--t-h3);
    line-height: 1.2;
    color: var(--ink);
}
.principle__text {
    margin: 0;
    font-size: var(--t-body);
    line-height: 1.65;
    color: var(--ink-soft);
    font-weight: 300;
}

/*
   Carousel timing — 30s loop, four cards offset by 25% (-0, -7.5s, -15s, -22.5s).
   Each position dwells for ~15% of the cycle (4.5s) so the user has time to read,
   then transitions to the next slot over ~10% (3s). Adjacent dwell ranges line up
   exactly with the 25% phase offset, so all four cards transition simultaneously.
*/
@keyframes carousel-shift {
    /* Front: closest, full size, fully opaque — 4.5s dwell */
    0%, 15% {
        transform: translate(-50%, -50%) translateX(0) translateZ(80px) scale(1);
        opacity: 1;
        z-index: 4;
    }
    /* Right: slightly behind, smaller — 4.5s dwell */
    25%, 40% {
        transform: translate(-50%, -50%) translateX(85%) translateZ(-30px) scale(0.82);
        opacity: 0.78;
        z-index: 3;
    }
    /* Back: completely behind, smallest, faded — 4.5s dwell */
    50%, 65% {
        transform: translate(-50%, -50%) translateX(0) translateZ(-180px) scale(0.66);
        opacity: 0.32;
        z-index: 1;
    }
    /* Left: slightly behind, smaller — 4.5s dwell */
    75%, 90% {
        transform: translate(-50%, -50%) translateX(-85%) translateZ(-30px) scale(0.82);
        opacity: 0.78;
        z-index: 3;
    }
    /* Returning to front to close the loop */
    100% {
        transform: translate(-50%, -50%) translateX(0) translateZ(80px) scale(1);
        opacity: 1;
        z-index: 4;
    }
}

/* Mobile: fall back to vertical stack — carousel is too cramped */
@media (max-width: 720px) {
    .principles {
        height: auto;
        perspective: none;
        display: grid;
        gap: 1.2rem;
    }
    .principle {
        position: static;
        width: 100%;
        min-height: 0;
        animation: none;
        transform: none;
        opacity: 1;
    }
}

@media (prefers-reduced-motion: reduce) {
    .principles {
        height: auto;
        perspective: none;
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 1.2rem;
    }
    .principle {
        position: static;
        width: auto;
        animation: none;
        transform: none;
        opacity: 1;
    }
}

/* ---------- CONTACT ---------- */
.contact {
    background: var(--paper-2);
    padding: clamp(3.5rem, 6vw, 6rem) 0;
    border-block: 1px solid var(--paper-line);
    scroll-margin-top: var(--header-h);
}
.contact__inner {
    width: var(--container);
    margin-inline: auto;
    display: grid;
    grid-template-columns: 1fr 1.6fr;
    gap: clamp(2rem, 4vw, 4rem);
    align-items: start;
}
.contact__lede {
    margin-top: 0.6rem;
    font-size: var(--t-body);
    color: var(--ink-muted);
    max-width: 32ch;
    font-weight: 300;
    line-height: 1.55;
}
.contact-form__grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: clamp(1.4rem, 2vw, 2rem) clamp(1rem, 2vw, 1.6rem);
}
.field {
    position: relative;
}
.field--full { grid-column: 1 / -1; }

.field input,
.field textarea {
    width: 100%;
    padding: 1.4rem 0 0.6rem;
    font-size: var(--t-body);
    background: transparent;
    border: 0;
    border-bottom: 1px solid var(--paper-rule);
    outline: none;
    color: var(--ink);
    font-family: var(--font-body);
    font-weight: 400;
    transition: border-color 0.25s;
}
.field textarea {
    min-height: 6rem;
    max-height: 18rem;
    /* Disable the manual resize handle — the textarea grows automatically with
       content (see the input handler in base.html). When the message exceeds
       max-height, an internal scrollbar takes over. */
    resize: none;
    overflow-y: auto;
}
.field label {
    position: absolute;
    top: 0.85rem;
    left: 0;
    color: var(--ink-muted);
    font-size: var(--t-body);
    pointer-events: none;
    transition: top 0.3s var(--ease), font-size 0.3s var(--ease), color 0.25s, letter-spacing 0.3s var(--ease);
    font-family: var(--font-body);
}
.field input:focus,
.field textarea:focus {
    border-bottom-color: var(--accent);
}
.field input:focus ~ label,
.field input:not(:placeholder-shown) ~ label,
.field textarea:focus ~ label,
.field textarea:not(:placeholder-shown) ~ label {
    top: -0.2rem;
    font-size: 0.72rem;
    color: var(--accent);
    letter-spacing: 0.12em;
    text-transform: uppercase;
    font-weight: 500;
}
.field__star {
    color: var(--accent);
    margin-left: 0.15em;
}

/* Phone field with country dial-code selector ----------------------------- */
.field--phone .field__phone-row {
    display: flex;
    align-items: stretch;
    margin-top: 1.4rem;
    border-bottom: 1px solid var(--paper-rule);
    transition: border-color 0.25s;
}
.field--phone .field__phone-row:focus-within {
    border-bottom-color: var(--accent);
}
.field--phone .field__phone-row input,
.field--phone .field__phone-row select {
    border-bottom: 0;
    padding-top: 0;
    padding-bottom: 0.6rem;
}
.field--phone .field__dial {
    flex: 0 0 auto;
    max-width: 13rem;
    width: auto;
    font-family: var(--font-body);
    font-size: var(--t-body);
    font-weight: 400;
    color: var(--ink);
    background-color: transparent;
    border: 0;
    border-right: 1px solid var(--paper-rule);
    margin-right: 0.9rem;
    padding-right: 1.6rem;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    text-overflow: ellipsis;
    overflow: hidden;
    white-space: nowrap;
    background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%23495057' stroke-width='1.4' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.5rem center;
    background-size: 0.6rem auto;
    transition: color 0.25s;
}
.field--phone .field__dial:focus {
    outline: none;
    color: var(--accent);
    background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%23ec644c' stroke-width='1.4' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}
.field--phone .field__dial option {
    color: var(--ink);
    background: var(--paper);
    font-weight: 400;
}
.field--phone .field__phone-row input {
    flex: 1 1 0;
    min-width: 0;
}
/* Phone field's label sits above the row, always floated since the dial is
   visible from the start (no empty placeholder state). */
.field--phone > label {
    top: -0.2rem;
    font-size: 0.72rem;
    color: var(--ink-muted);
    letter-spacing: 0.12em;
    text-transform: uppercase;
    font-weight: 500;
}
.field--phone:focus-within > label {
    color: var(--accent);
}

@media (max-width: 540px) {
    .field--phone .field__dial {
        max-width: 8.5rem;
        margin-right: 0.6rem;
        padding-right: 1.3rem;
    }
}

.contact-form__foot {
    margin-top: 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1.5rem;
    flex-wrap: wrap;
}

.consent {
    display: inline-flex;
    align-items: flex-start;
    gap: 0.7rem;
    font-size: var(--t-small);
    color: var(--ink-soft);
    cursor: pointer;
    max-width: 32rem;
    line-height: 1.5;
    font-weight: 300;
}
.consent input[type="checkbox"] {
    appearance: none;
    width: 1.1rem;
    height: 1.1rem;
    border: 1px solid var(--ink-muted);
    border-radius: 3px;
    flex-shrink: 0;
    margin-top: 0.15rem;
    display: grid;
    place-content: center;
    transition: border-color 0.25s, background 0.25s;
    cursor: pointer;
}
.consent input[type="checkbox"]::before {
    content: "";
    width: 0.55rem;
    height: 0.55rem;
    background: var(--accent);
    transform: scale(0);
    transition: transform 0.2s var(--ease);
    border-radius: 1px;
}
.consent input[type="checkbox"]:checked {
    border-color: var(--accent);
}
.consent input[type="checkbox"]:checked::before {
    transform: scale(1);
}
.consent a {
    color: var(--accent);
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 3px;
}
.consent a:hover { color: var(--accent-deep); }

@media (max-width: 860px) {
    .contact__inner { grid-template-columns: 1fr; }
    .contact-form__grid { grid-template-columns: 1fr; }
}

/* Submit button — disabled state ----------------------------------------- */
.contact-form__foot .btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    transform: none;
}
.contact-form__foot .btn:disabled:hover {
    transform: none;
}
.contact-form__foot .btn:disabled .arrow {
    transform: none;
}

/* ---------- TOAST ---------- */
.toast {
    position: fixed;
    bottom: clamp(1rem, 3vw, 1.75rem);
    right: clamp(1rem, 3vw, 1.75rem);
    z-index: 1000;
    display: flex;
    align-items: flex-start;
    gap: 0.85rem;
    max-width: min(24rem, calc(100vw - 2rem));
    padding: 1rem 1.1rem 1rem 1rem;
    background: var(--paper);
    border: 1px solid var(--paper-rule);
    border-left: 3px solid var(--accent);
    box-shadow:
        0 1px 0 var(--paper-line),
        0 18px 48px -18px rgba(33, 37, 41, 0.28),
        0 6px 18px -10px rgba(33, 37, 41, 0.16);
    font-family: var(--font-body);
    color: var(--ink);
    transform: translate(0, calc(100% + 2rem));
    opacity: 0;
    pointer-events: none;
    transition:
        transform 0.5s var(--ease, cubic-bezier(.2,.8,.2,1)),
        opacity 0.35s ease;
}
.toast.is-active {
    transform: translate(0, 0);
    opacity: 1;
    pointer-events: auto;
}

.toast__mark {
    flex: 0 0 auto;
    width: 2rem;
    height: 2rem;
    display: grid;
    place-items: center;
    border-radius: 999px;
    background: var(--accent-soft);
    color: var(--accent);
    margin-top: 0.05rem;
}
.toast__mark .toast__cross { display: none; }

.toast--error {
    border-left-color: #b54330;
}
.toast--error .toast__mark {
    background: rgba(181, 67, 48, 0.10);
    color: #b54330;
}
.toast--error .toast__check { display: none; }
.toast--error .toast__cross { display: initial; }

.toast__body {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    min-width: 0;
    padding-right: 0.4rem;
}
.toast__title {
    font-family: var(--font-display);
    font-size: 0.95rem;
    font-weight: 500;
    letter-spacing: 0.005em;
    color: var(--ink);
}
.toast__msg {
    font-size: 0.82rem;
    line-height: 1.45;
    color: var(--ink-soft);
    font-weight: 300;
}

.toast__close {
    flex: 0 0 auto;
    appearance: none;
    background: transparent;
    border: 0;
    color: var(--ink-muted);
    font-size: 1.4rem;
    line-height: 1;
    width: 1.6rem;
    height: 1.6rem;
    cursor: pointer;
    display: grid;
    place-items: center;
    transition: color 0.2s;
    padding: 0;
}
.toast__close:hover { color: var(--ink); }

@media (prefers-reduced-motion: reduce) {
    .toast {
        transition: opacity 0.2s ease;
        transform: none;
    }
}

/* ---------- PARTNERS ---------- */
.partners {
    padding: clamp(3.5rem, 6vw, 6rem) 0;
    scroll-margin-top: var(--header-h);
    background: var(--paper);
}
.partners__inner {
    width: var(--container);
    margin-inline: auto;
}
.partner-grid {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    grid-auto-rows: clamp(110px, 12vw, 160px);
    gap: 1px;
    background: var(--paper-line);
    border: 1px solid var(--paper-line);
    border-radius: var(--radius);
    overflow: hidden;
}
.partner-grid li {
    background: var(--paper);
    display: grid;
    place-items: center;
    padding: clamp(0.9rem, 1.8vw, 1.5rem);
    transition: background 0.3s var(--ease);
    min-width: 0;
}
.partner-grid li:hover {
    background: var(--paper-2);
}
.partner-grid img {
    max-width: 82%;
    max-height: 68%;
    width: auto;
    height: auto;
    object-fit: contain;
    transition: transform 0.3s var(--ease);
}
.partner-grid li:hover img {
    transform: scale(1.06);
}

/* Last grid cell: CTA instead of a logo (kept dark for visual punch) */
.partner-grid__cta {
    background: var(--ink) !important;
}
.partner-grid__cta a {
    display: inline-flex;
    align-items: center;
    gap: 0.5em;
    color: #ffffff;
    font-family: var(--font-body);
    font-weight: 500;
    font-size: var(--t-small);
    letter-spacing: 0.02em;
    text-align: center;
    line-height: 1.3;
    transition: color 0.25s;
}
.partner-grid__cta a .arrow {
    display: inline-block;
    transition: transform 0.25s var(--ease);
}
.partner-grid__cta:hover a {
    color: var(--accent);
}
.partner-grid__cta:hover a .arrow {
    transform: translateX(3px);
}

@media (max-width: 1024px) {
    .partner-grid { grid-template-columns: repeat(4, 1fr); }
}
@media (max-width: 720px) {
    .partner-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 480px) {
    .partner-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ---------- RESPONSIVE: hero ---------- */
@media (max-width: 900px) {
    .hero__visual {
        right: -18vw;
        width: min(clamp(420px, 75vw, 640px), calc(100svh - var(--header-h) - 2rem));
        opacity: 0.55;
    }
}
@media (max-width: 640px) {
    .hero {
        padding: clamp(3rem, 10vw, 4.5rem) 0;
    }
    .hero__visual {
        right: -25vw;
        width: min(clamp(360px, 90vw, 560px), calc(100svh - var(--header-h) - 2rem));
        opacity: 0.4;
    }
}

/* ---------- ANIMATIONS ---------- */
@keyframes spin-slow {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}
