/* Site-specific overrides layered on top of the theme (assets/css/app.min.css). */

/*
 * The theme sizes .app-content to fill the viewport. Making it a flex column lets
 * the body take the slack and parks the footer at the bottom of the first screen,
 * so it is visible without scrolling on short pages and simply follows the content
 * on long ones.
 */
#content.app-content {
    display: flex;
    flex-direction: column;
}

.app-content-body {
    flex: 1 0 auto;
}

/*
 * Opt-in fade for a page arriving from the branded intro. It is deliberately
 * shorter than the intro's fade-out: the user has already waited, so this should
 * read as the page settling rather than as another delay. Only opacity animates,
 * which the compositor can handle without re-laying out the tiles.
 */
.app-content-fade-in .app-content-body {
    animation: app-content-in 400ms ease-out both;
}

@keyframes app-content-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Respect reduced-motion: appear immediately. */
@media (prefers-reduced-motion: reduce) {
    .app-content-fade-in .app-content-body {
        animation: none;
    }
}

/*
 * Application footer: a quiet branding strip under the page content. It is muted
 * and border-separated so it reads as chrome rather than competing with the page.
 */
.app-footer {
    flex-shrink: 0;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .5rem 1rem;
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid rgba(var(--bs-inverse-rgb), .15);
    color: var(--bs-body-color);
    font-size: .8125rem;
}

.app-footer-brand {
    display: flex;
    align-items: center;
    gap: .625rem;
    opacity: .65;
}

/*
 * Reserve the slot even before the logo loads: a fixed height with min-width
 * stops the footer text from jumping sideways once the SVG paints.
 */
.app-footer-logo {
    height: 22px;

    width: auto;
}

/* Pushes the trailing meta to the far edge on wide screens, wraps under on narrow. */
.app-footer-meta {
    margin-left: auto;
    opacity: .45;
}

/*
 * Landing page (/Welcome): a standalone, once-per-session brand intro that
 * redirects to the dashboard. It replaced the old overlay splash, which flickered
 * because the browser painted it before the hide logic could run. A separate page
 * has no such race - there is nothing underneath to reveal.
 */
.app-landing {
    /* Hard-coded rather than var(--bs-body-bg): the page forces dark mode, and this
       also covers the moment before app.min.css has applied its variables. */
    background-color: #1a1d24;
    color: #fff;
}

.landing {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    padding: 2rem;
    text-align: center;

    /*
     * Closing fade. Only the content fades - the dark body stays put - so the screen
     * empties to the same colour the page started on instead of flashing white.
     * `forwards` holds the faded state, so a late redirect never lets the intro
     * flicker back into view.
     */
    animation: landing-out var(--landing-fade-ms, 900ms) ease-in var(--landing-fade-delay-ms, 2100ms) forwards;
}

@keyframes landing-out {
    to {
        opacity: 0;
    }
}

/*
 * Scale with the viewport instead of a fixed height: comfortable on a phone,
 * generous on a desktop, and capped so it never dominates a wide monitor.
 */
.landing-logo {
    width: clamp(180px, 28vw, 360px);
    height: auto;
    animation: landing-in 600ms ease-out both;
}

.landing-version {
    margin: 0;
    color: var(--bs-body-color);
    opacity: .5;
    font-size: .875rem;
}

/* Escape hatch for anyone who does not want to wait out the timer. */
.landing-skip {
    color: var(--bs-body-color);
    opacity: .5;
    font-size: .875rem;
    text-decoration: none;
}

.landing-skip:hover,
.landing-skip:focus {
    opacity: .9;
}

@keyframes landing-in {
    from { opacity: 0; transform: translateY(.5rem); }
    to { opacity: 1; transform: none; }
}

/* Respect reduced-motion: show it immediately and cut rather than fade. */
@media (prefers-reduced-motion: reduce) {
    .landing,
    .landing-logo {
        animation: none;
    }
}

/*
 * Native <select> popups are painted by the OS, not the theme, so the options
 * fall back to a light list on a dark page. Opting the control into the page's
 * colour scheme lets the browser paint a matching dark popup, and the explicit
 * option colours cover engines that ignore color-scheme.
 */
[data-bs-theme="dark"] .form-select,
.dark-mode .form-select {
    color-scheme: dark;
}

[data-bs-theme="dark"] .form-select option,
[data-bs-theme="dark"] .form-select optgroup,
.dark-mode .form-select option,
.dark-mode .form-select optgroup {
    background-color: var(--bs-body-bg);
    color: var(--bs-body-color);
}

/* Templated asset type picker: readable contrast in both light and dark themes. */
.asset-type-picker .dropdown-item {
    color: var(--bs-body-color);
    white-space: normal;
}

.asset-type-picker .dropdown-item:hover,
.asset-type-picker .dropdown-item:focus {
    background-color: rgba(var(--bs-inverse-rgb), .15);
    color: var(--bs-body-color);
}

.asset-type-picker .dropdown-item.active {
    background-color: rgba(var(--bs-theme-rgb), .25);
    color: var(--bs-body-color);
}

.asset-type-picker .dropdown-item.active .text-opacity-50 {
    --bs-text-opacity: .75;
}

/* Card-style asset type chooser: the image is the primary identifier, so it gets a
   fixed hero area to keep the grid aligned regardless of source aspect ratio. */
.asset-type-chooser .asset-type-media .card-img-top {
    width: 100%;
    height: 170px;
    object-fit: cover;
}

.asset-type-chooser .asset-type-choice {
    transition: transform .12s ease-in-out, border-color .12s ease-in-out;
}

.asset-type-chooser .asset-type-choice:hover,
.asset-type-chooser .asset-type-choice:focus-visible {
    border-color: rgba(var(--bs-theme-rgb), .75) !important;
    transform: translateY(-2px);
}

/* Schedule template route builder: a connector line between the step numbers so the
   selected phases read as a sequence rather than an unordered list. */
.route-builder .route-step {
    position: relative;
    padding-left: .25rem;
}

.route-builder .route-step:not(:last-child)::before {
    content: '';
    position: absolute;
    left: 1rem;
    top: 2rem;
    bottom: -.5rem;
    width: 2px;
    background-color: rgba(var(--bs-theme-rgb), .35);
}

.route-builder .route-step-number {
    width: 1.75rem;
    height: 1.75rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    z-index: 1;
}

/* Detail fields line up under the step name rather than the number, so the
   connector running down the left edge stays unobstructed. */
.route-builder .route-step-detail {
    padding-left: 2.25rem;
}

/* Asset type image on the schedule template detail card. Fixed height for the same
   reason as the chooser: source images vary in aspect ratio and an unconstrained
   one would push the template facts below the fold. */
.schedule-template-media {
    width: 100%;
    height: 200px;
    object-fit: cover;
}

/* Small asset type thumbnail in the template list header. Sized to sit level with
   the heading text rather than to be read as an image in its own right. */
.schedule-template-thumb {
    display: inline-block;
    width: 2.5rem;
    height: 2.5rem;
    border-radius: .375rem;
    overflow: hidden;
}

.schedule-template-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
