html {
  font-size: 14px;
}

@media (min-width: 768px) {
  html {
    font-size: 16px;
  }
}

.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
  box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #258cfb;
}

html {
  position: relative;
  min-height: 100%;
}

body {
  margin-bottom: 60px;
}

/* Shared page layout */
html {
    min-height: 100%;
}

body {
    min-height: 100vh;
    margin: 0;
    display: flex;
    flex-direction: column;
}

.site-main {
    flex: 1;
    width: 100%;
}

.footer {
    position: static;
    width: 100%;
    white-space: normal;
    line-height: normal;
    padding: 1rem;
}

/* Sustainability homepage */
.sustainability-hero {
    min-height: 85vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 5rem 1.5rem;
    color: #ffffff;
    text-align: center;
    background-image: linear-gradient(rgba(4, 30, 23, 0.75), rgba(4, 30, 23, 0.8)), url("../images/sustainability-background.jpg");
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    background-attachment: fixed;
}

.hero-content {
    width: 100%;
    max-width: 1100px;
}

.hero-label {
    margin-bottom: 1.5rem;
    color: #d9efb0;
    font-size: 0.9rem;
    font-weight: 700;
    letter-spacing: 0.18em;
}

.sustainability-hero h1 {
    margin: 0 0 1.5rem;
    font-family: Impact, "Arial Narrow", sans-serif;
    font-size: clamp(3rem, 7vw, 7rem);
    line-height: 1.15;
    background-image: linear-gradient( to right, #c4de85, #ffffff, #f2d675, #ffffff, #c4de85 );
    background-clip: text;
    -webkit-background-clip: text;
    color: transparent;
    -webkit-text-fill-color: transparent;
    -webkit-text-stroke: 1px #c4de85;
}

.hero-description {
    max-width: 850px;
    margin: 0 auto 2rem;
    font-size: clamp(1.05rem, 2vw, 1.5rem);
    line-height: 1.8;
}

.explore-link {
    display: inline-block;
    padding: 0.9rem 1.6rem;
    border: 2px solid #e0efbb;
    border-radius: 0.3rem;
    background-color: #e0efbb;
    color: #082c24;
    font-weight: 700;
    text-decoration: none;
    transition: background-color 0.2s ease, color 0.2s ease;
}

    .explore-link:hover,
    .explore-link:focus-visible {
        background-color: #082c24;
        color: #ffffff;
    }

.topics-introduction {
    padding: 3.5rem 1.5rem;
    background-color: #f1f5e9;
    color: #123c2e;
    text-align: center;
}

    .topics-introduction h2 {
        margin-bottom: 1rem;
        font-size: clamp(1.6rem, 3vw, 2.5rem);
    }

    .topics-introduction p {
        max-width: 750px;
        margin: 0 auto;
        line-height: 1.8;
    }

@media (max-width: 767.98px) {
    .sustainability-hero {
        min-height: 70vh;
        padding: 3rem 1.25rem;
    }

    .hero-label {
        font-size: 0.75rem;
        letter-spacing: 0.1em;
    }
}

@media (max-width: 575.98px) {
    .sustainability-hero h1 {
        font-size: 2.8rem;
    }

    .topics-introduction {
        padding: 2.5rem 1.25rem;
    }
}

/* Use normal background scrolling on smaller screens. */
@media (max-width: 767.98px) {
    .sustainability-hero {
        background-attachment: scroll;
    }
}

/* Respect visitors who prefer reduced motion. */
@media (prefers-reduced-motion: reduce) {
    .sustainability-hero {
        background-attachment: scroll;
    }
}

/* Sustainability topic sections */
.topic-section {
    padding: 4rem 2rem;
    color: #ffffff;
    background-color: #082c24;
    background-image: linear-gradient(rgba(4, 30, 23, 0.85), rgba(4, 30, 23, 0.85)), url("../images/sustainability-background.jpg");
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
}

.topic-row {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr;
    align-items: center;
    gap: 1.5rem;
    max-width: 1400px;
    margin: 0 auto;
}

.topic-description h2 {
    margin-bottom: 1rem;
    color: #f8bd08;
    font-family: Impact, "Arial Narrow", sans-serif;
    font-size: clamp(2rem, 4vw, 4rem);
    text-shadow: 2px 2px 0 navy;
}

.topic-description p {
    max-width: 650px;
    line-height: 1.8;
    font-size: 1.1rem;
}

.topic-description .image-note {
    color: #d9efb0;
    font-size: 0.85rem;
}

.topic-card {
    position: relative;
    display: block;
    aspect-ratio: 1;
    overflow: hidden;
    color: #ffffff;
    background-color: #103c30;
    text-decoration: none;
}

    .topic-card img {
        width: 100%;
        height: 100%;
        display: block;
        object-fit: cover;
    }

.card-title {
    position: absolute;
    right: 0;
    bottom: 0;
    left: 0;
    padding: 1rem;
    background-color: rgba(0, 0, 0, 0.8);
    color: #ffffff;
    font-weight: 700;
    text-align: center;
    transition: opacity 2s ease;
}

.card-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 0.75rem;
    padding: 1.25rem;
    background-color: rgba(8, 44, 36, 0.95);
    color: #ffffff;
    text-align: center;
    opacity: 0;
    transition: opacity 2s ease;
}

    .card-overlay strong {
        color: #f2d675;
        font-size: 1.2rem;
    }

    .card-overlay span {
        font-size: 0.95rem;
        line-height: 1.5;
    }

.card-source {
    text-decoration: underline;
}

.topic-card:hover .card-overlay,
.topic-card:focus-visible .card-overlay {
    opacity: 1;
}

.topic-card:hover .card-title,
.topic-card:focus-visible .card-title {
    opacity: 0;
}

.topic-card:focus-visible {
    outline: 3px solid #f2d675;
    outline-offset: 4px;
}

/* Tablet: description above two image cards */
@media (max-width: 767.98px) {
    .topic-section {
        padding: 2.5rem 1.25rem;
        background-attachment: scroll;
    }

    .topic-row {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .topic-description {
        grid-column: 1 / -1;
    }
}

/* Mobile: stack all content */
@media (max-width: 575.98px) {
    .topic-row {
        grid-template-columns: 1fr;
    }

    .topic-card {
        width: 100%;
        max-width: 360px;
        justify-self: center;
    }
}

/* Show descriptions below images on touch devices */
@media (hover: none) {
    .topic-card {
        aspect-ratio: auto;
    }

        .topic-card img {
            aspect-ratio: 1;
            height: auto;
        }

    .card-title {
        display: none;
    }

    .card-overlay {
        position: static;
        opacity: 1;
    }
}

@media (prefers-reduced-motion: reduce) {
    .topic-section {
        background-attachment: scroll;
    }

    .card-title,
    .card-overlay {
        transition: none;
    }
}

/* Energy section: images on the left, description on the right */
.topic-row-reversed {
    grid-template-columns: 1fr 1fr 2fr;
}

    .topic-row-reversed .topic-description {
        padding-left: 1rem;
    }

/* Tablet: description first, then two image cards */
@media (max-width: 767.98px) {
    .topic-row-reversed {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

        .topic-row-reversed .topic-description {
            grid-column: 1 / -1;
            grid-row: 1;
            padding-left: 0;
        }
}

/* Mobile: description and image cards in one column */
@media (max-width: 575.98px) {
    .topic-row-reversed {
        grid-template-columns: 1fr;
    }
}

/* Image overlays controlled by JavaScript mouse events */
.topic-card.is-hovered .card-overlay {
    opacity: 1;
}

.topic-card.is-hovered .card-title {
    opacity: 0;
}

/* JavaScript-generated instructions */
.topics-introduction .interaction-hint {
    margin-top: 1rem;
    font-size: 0.95rem;
}

/* Animate the children, leaving the measured row position stable. */
.topic-row > .topic-description,
.topic-row > .topic-card {
    opacity: 1;
    transform: translateY(0);
    transition: opacity 1.2s ease, transform 1.4s cubic-bezier(0.22, 1, 0.36, 1);
}

.topic-row > :nth-child(2) {
    transition-delay: 0.12s;
}

.topic-row > :nth-child(3) {
    transition-delay: 0.24s;
}

/* Keep the layout space occupied so scrolling does not jump. */
.topic-row.is-outside-viewport {
    pointer-events: none;
}

.topic-row.is-outside-viewport > .topic-description,
.topic-row.is-outside-viewport > .topic-card {
    opacity: 0;
    transform: translateY(22px);
    transition-duration: 0.3s;
    transition-delay: 0s;
}

/* Reveal focused links immediately for keyboard navigation. */
.topic-row:focus-within {
    pointer-events: auto;
}

.topic-row:focus-within > .topic-description,
.topic-row:focus-within > .topic-card {
    opacity: 1;
    transform: none;
    transition: none;
}

@media (prefers-reduced-motion: reduce) {
    .topic-row > .topic-description,
    .topic-row > .topic-card {
        transition: none;
        transform: none;
    }

    .topic-row.is-outside-viewport > .topic-description,
    .topic-row.is-outside-viewport > .topic-card {
        transform: none;
    }
}

/* Contact and About page */
.contact-page {
    min-height: 85vh;
    padding: 4rem 1.5rem;
    color: #fff4bd;
    background-color: #082c24;
    background-image: linear-gradient(rgba(4, 30, 23, 0.85), rgba(4, 30, 23, 0.9)), url("../images/sustainability-background.jpg");
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
}

.contact-title {
    margin: 0 0 3rem;
    text-align: center;
    font-family: Impact, "Arial Narrow", sans-serif;
    font-size: clamp(2.8rem, 7vw, 7rem);
    background-image: linear-gradient( to right, #c4de85, #ffffff, #f2d675, #ffffff, #c4de85 );
    background-clip: text;
    -webkit-background-clip: text;
    color: transparent;
    -webkit-text-fill-color: transparent;
}

.contact-content {
    max-width: 1500px;
}

.contact-panel {
    height: 100%;
    padding: 1.5rem;
    border: 1px solid #ffffff;
    background-color: rgba(8, 35, 28, 0.92);
    box-shadow: 10px 10px 0 #f8f6b0;
    overflow-wrap: anywhere;
}

    .contact-panel h2 {
        margin-bottom: 1.25rem;
        color: #f2d675;
        font-family: Georgia, serif;
        font-style: italic;
        font-size: 2.5rem;
        text-shadow: 2px 2px 0 navy;
    }

    .contact-panel h3 {
        margin-top: 1.5rem;
        color: #f2d675;
        font-size: 1.25rem;
    }

    .contact-panel p,
    .credit-list {
        font-family: Arial, sans-serif;
        font-size: 1rem;
        line-height: 1.7;
    }

    .contact-panel a {
        color: #fff4bd;
        text-underline-offset: 3px;
    }

        .contact-panel a:hover {
            color: #ffffff;
        }

        .contact-panel a:focus-visible {
            outline: 2px solid #ffffff;
            outline-offset: 3px;
        }

.credit-list {
    padding-left: 1.25rem;
}

    .credit-list li {
        margin-bottom: 0.65rem;
    }

@media (max-width: 767.98px) {
    .contact-page {
        padding: 2.5rem 1rem;
        background-attachment: scroll;
    }

    .contact-title {
        margin-bottom: 2rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    .contact-page {
        background-attachment: scroll;
    }
}

/* Sustainability quiz */
.quiz-container {
    max-width: 850px;
    margin: 0 auto;
}

.quiz-introduction {
    margin-bottom: 2rem;
    color: #ffffff;
    font-size: 1.1rem;
    line-height: 1.7;
    text-align: center;
}

.quiz-question {
    min-width: 0;
    margin-bottom: 1.5rem;
    padding: 1.5rem;
    border: 1px solid #d9efb0;
    background-color: #082c24;
}

    .quiz-question legend {
        float: none;
        width: auto;
        padding: 0 0.5rem;
        color: #f2d675;
        font-size: 1.2rem;
        font-weight: 700;
    }

    .quiz-question label {
        display: flex;
        align-items: flex-start;
        gap: 0.75rem;
        padding: 0.75rem;
        color: #ffffff;
        line-height: 1.5;
        cursor: pointer;
    }

        .quiz-question label:hover,
        .quiz-question label:focus-within {
            background-color: #174c3c;
        }

    .quiz-question input {
        flex-shrink: 0;
        margin-top: 0.3rem;
        accent-color: #f2d675;
    }

        .quiz-question input:focus-visible {
            outline: 2px solid #f2d675;
            outline-offset: 4px;
        }

.quiz-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
}

.quiz-reset {
    padding: 0.9rem 1.6rem;
    border: 2px solid #e0efbb;
    border-radius: 0.3rem;
    background-color: #082c24;
    color: #ffffff;
    font-weight: 700;
}

    .quiz-reset:hover {
        background-color: #174c3c;
    }

    .quiz-reset:focus-visible {
        outline: 3px solid #f2d675;
        outline-offset: 3px;
    }

.quiz-result:not(:empty) {
    margin-top: 2rem;
    padding: 1.5rem;
    border-left: 4px solid #f2d675;
    background-color: #082c24;
    color: #ffffff;
    line-height: 1.7;
}

.quiz-result h2 {
    color: #f2d675;
    font-size: 1.5rem;
}

@media (max-width: 575.98px) {
    .quiz-question {
        padding: 1rem;
    }

    .quiz-actions button {
        width: 100%;
    }
}
/* AI image upload: shared forest palette, scoped to this form. */
.image-upload-page {
    min-height: 82vh;
    padding: clamp(2rem, 5vw, 4rem) 1.25rem;
    color: #fff;
    background: linear-gradient(rgba(4,30,23,.86), rgba(4,30,23,.94)), url('../images/sustainability-background.jpg') center / cover;
}
.image-upload-shell { max-width: 900px; margin: 0 auto; }
.image-upload-page h1 {
    color: #e0efbb;
    font-family: Impact, 'Arial Narrow', sans-serif;
    font-size: clamp(2.5rem, 6vw, 4.5rem);
    margin-bottom: 1rem;
}
.image-upload-shell > p { line-height: 1.7; }
.image-upload-panel {
    margin-top: 2rem;
    padding: clamp(1.25rem, 4vw, 2.5rem);
    border: 1px solid #698564;
    border-top: 4px solid #f2d675;
    border-radius: 16px;
    background: #082c24;
    box-shadow: 0 16px 40px #0003;
}
.image-upload-page .form-label { color: #f2d675; font-weight: 700; }
.image-upload-page .form-control {
    background-color: #f1f5e9;
    color: #123c2e;
    border: 2px solid #c3d4b2;
    border-radius: 8px;
    padding: .8rem 1rem;
}
.image-upload-page .form-control:focus {
    border-color: #f2d675;
    box-shadow: 0 0 0 3px #f2d67544;
}
.image-upload-page input::file-selector-button { background: #d9efb0; color: #082c24; }
.image-upload-page .form-text { color: #d9e6ce; margin-top: .6rem; }
.image-upload-page .text-danger { color: #ffb7b7 !important; }
.image-upload-page .btn { padding: .8rem 1.4rem; font-weight: 700; margin: .4rem .5rem 0 0; }
.image-upload-page .upload-primary { background: #e0efbb; color: #082c24; border: 2px solid #e0efbb; }
.image-upload-page .upload-secondary { color: #e0efbb; border: 2px solid #e0efbb; }
.image-upload-page .btn:hover { background: #f2d675; border-color: #f2d675; color: #082c24; }
.image-upload-page .btn:focus-visible { outline: 3px solid #f2d675; outline-offset: 4px; }
@media (max-width: 480px) {
    .image-upload-page .btn { display: block; width: 100%; margin-right: 0; }
}

/* Sustainability image gallery */
.ai-gallery-page {
    min-height: 85vh;
    padding: clamp(2rem, 4vw, 4rem) clamp(1rem, 3vw, 3rem);
    color: #fff;
    background: linear-gradient(rgba(4,30,23,.87), rgba(4,30,23,.95)), url('../images/sustainability-background.jpg') center / cover;
}
.ai-gallery-heading { margin-bottom: 2.5rem; max-width: 850px; }
.ai-gallery-heading h1 {
    font-family: Impact, 'Arial Narrow', sans-serif;
    font-size: clamp(3rem, 6vw, 5rem);
    color: #e0efbb;
    margin-bottom: 1rem;
}
.ai-gallery-heading > p:not(.hero-label) { line-height: 1.8; margin-bottom: 1.5rem; }
.ai-gallery-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr)); gap: 1.5rem; }
.ai-gallery-grid .col { min-width: 0; }
.ai-gallery-grid .card {
    background: #f1f5e9;
    color: #123c2e;
    border: 1px solid #a8c18b;
    border-radius: 14px;
    overflow: hidden;
    box-shadow: 0 12px 30px #0003;
}
.ai-gallery-grid .card-img-top { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; }
.ai-gallery-grid .card-body { display: flex; flex-direction: column; padding: 1.25rem; }
.ai-gallery-grid h2 { font-weight: 700; }
.ai-gallery-grid .text-break { line-height: 1.65; }
.ai-gallery-grid .small { color: #46614b; }
.ai-gallery-actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: auto; }
.ai-gallery-actions a { padding: .45rem .7rem; border: 1px solid #315b44; border-radius: 6px; color: #123c2e; font-weight: 600; text-decoration: none; }
.ai-gallery-actions a:first-child { background: #123c2e; color: #fff; }
.ai-gallery-actions a:hover { background: #e0efbb; color: #082c24; }
.ai-gallery-actions a:focus-visible { outline: 3px solid #9b7100; outline-offset: 3px; }
@media (min-width: 1800px) { .ai-gallery-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); } }

/* Shared image preview and metadata for Edit and Details. */
.ai-image-preview {
    display: block;
    width: 100%;
    max-height: 480px;
    object-fit: contain;
    background: #041e17;
    border: 1px solid #698564;
    border-radius: 10px;
    margin-bottom: 2rem;
}
.ai-image-details { margin-bottom: 1.5rem; overflow-wrap: anywhere; }
.ai-image-details dt { color: #f2d675; font-weight: 700; margin-bottom: .4rem; }
.ai-image-details dd { margin-bottom: 1.4rem; line-height: 1.75; }
.ai-image-prompt { white-space: pre-wrap; }
.ai-image-metadata { color: #d9e6ce; line-height: 1.7; }

.ai-gallery-heading a:not(.explore-link) { color: #e0efbb; }
.ai-gallery-actions form { margin: 0; }
.ai-gallery-actions button { padding: .45rem .7rem; border: 1px solid #315b44; border-radius: 6px; color: #123c2e; background: #e0efbb; font-weight: 600; }
.ai-gallery-actions button:disabled { opacity: .7; }
.ai-gallery-actions button:focus-visible { outline: 3px solid #9b7100; outline-offset: 3px; }
.ai-gallery-grid article { scroll-margin-top: 1rem; }
.ai-gallery-grid > a.card { text-decoration: none; }
.ai-gallery-grid > a.card:hover img { opacity: .7; }
.ai-gallery-grid > a.card img { transition: opacity 2s; }
@media (prefers-reduced-motion: reduce) { .ai-gallery-grid > a.card img { transition: none; } }

/* Identity Login and Register: keep the built-in forms and validation. */
.account-theme {
    padding: clamp(2rem, 5vw, 4rem) max(1.25rem, calc((100vw - 1100px) / 2));
    background: linear-gradient(rgba(4,30,23,.87), rgba(4,30,23,.95)), url('../images/sustainability-background.jpg') center / cover;
    color: #fff;
    min-height: 80vh;
}
.account-theme > h1 {
    color: #e0efbb;
    font-family: Impact, 'Arial Narrow', sans-serif;
    font-size: clamp(2.8rem, 6vw, 4.5rem);
    margin-bottom: 1.5rem;
}
.account-theme > .row { --bs-gutter-x: 2rem; row-gap: 1.5rem; }
.account-theme form {
    padding: clamp(1.2rem, 3vw, 2rem);
    background: #082c24;
    border: 1px solid #698564;
    border-top: 4px solid #f2d675;
    border-radius: 14px;
    box-shadow: 0 16px 40px #0003;
}
.account-theme h2, .account-theme h3 { color: #f2d675; font-size: clamp(1.25rem, 2.5vw, 1.65rem); }
.account-theme hr { border-color: #c3d4b2; opacity: .5; }
.account-theme .form-control { background-color: #f1f5e9; color: #123c2e; border: 2px solid #c3d4b2; border-radius: 8px; }
.account-theme .form-floating > label { color: #315b44; }
.account-theme .form-control:focus { border-color: #f2d675; box-shadow: 0 0 0 3px #f2d67544; }
.account-theme .btn-primary { background: #e0efbb; color: #082c24; border: 2px solid #e0efbb; font-weight: 700; }
.account-theme .btn-primary:hover { background: #f2d675; border-color: #f2d675; }
.account-theme a { color: #e0efbb; text-underline-offset: .2em; overflow-wrap: anywhere; }
.account-theme a:hover { color: #f2d675; }
.account-theme .text-danger { color: #ffb7b7 !important; }
.account-theme .form-check-input:checked { background-color: #315b44; border-color: #e0efbb; }
.account-theme a:focus-visible, .account-theme button:focus-visible { outline: 3px solid #f2d675; outline-offset: 4px; }
@media (max-width: 767.98px) { .account-theme > .row { margin: 0; } .account-theme > .row > div { padding: 0; } }
.footer-icons { display: flex; flex-wrap: wrap; justify-content: center; gap: 1rem; margin-top: 1rem; } .footer-icons a { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; background: #123c2e; color: #e0efbb; border-radius: 50%; text-decoration: none; } .footer-icons a:hover { background: #e0efbb; color: #123c2e; } .footer-icons a:focus-visible { outline: 3px solid #9b7100; outline-offset: 3px; }
