/* ==========================================================================
   Website templates — /templates, /templates/<id>/<slug>, the live demo viewer
   and the "I want this template" modal.

   Loaded only by those pages (registerCssFile in the views), after
   style.css / responsive.css, and built from the same tokens: lime accent,
   dark surfaces, the browser-frame look of the project page's .site-preview.
   ========================================================================== */

/* ---------- Catalogue ---------- */

.templates-list__intro {
    max-width: 720px;
    margin: 0 auto 40px;
    text-align: center;
    color: var(--color-white-1);
    opacity: .75;
    line-height: var(--line-height-body);
}

.templates-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 40px;
    margin-top: 40px;
}

.tpl-card {
    display: flex;
    flex-direction: column;
    height: 100%;
    border: 1px solid var(--color-divider-2);
    border-radius: var(--border-radius-1);
    background: var(--bg-color-1);
    overflow: hidden;
    transition: var(--transition-base);
}

.tpl-card:hover {
    border-color: rgba(207, 248, 94, .45);
    box-shadow: 0 24px 60px -30px rgba(207, 248, 94, .38);
    transform: translateY(-4px);
}

.tpl-card__shot {
    display: block;
    margin: 14px 14px 0;
    border: 1px solid var(--color-divider-2);
    border-radius: var(--border-radius-4);
    overflow: hidden;
    background: var(--bg-color-2);
    text-decoration: none;
}

.tpl-card__chrome {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 9px 12px;
    border-bottom: 1px solid var(--color-divider-2);
    background: var(--bg-color-3);
}

.tpl-card__dot {
    width: 8px;
    height: 8px;
    border-radius: var(--border-radius-2);
    background: var(--color-divider-2);
}

.tpl-card__viewport {
    display: block;
    position: relative;
    aspect-ratio: 16 / 11;
    overflow: hidden;
}

/* A full-page capture is far taller than the viewport: on hover the rest of
   the page travels past, top to bottom. `object-position` animates; a normal
   16:10 capture has nothing to travel and stays put. */
.tpl-card__img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: top center;
    transition: object-position 5s ease-in-out;
}

.tpl-card:hover .tpl-card__img {
    object-position: bottom center;
}

.tpl-card__body {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 10px;
    padding: 22px 26px 26px;
}

.tpl-card__category {
    align-self: flex-start;
    font-size: 12px;
    font-weight: var(--font-weight-semibold);
    color: var(--color-lime-1);
    text-transform: uppercase;
    letter-spacing: .08em;
}

.tpl-card__title {
    margin: 0;
    font-size: var(--font-size-md);
    font-weight: var(--font-weight-bold);
    line-height: 1.35em;
}

.tpl-card__title a {
    color: var(--color-white-1);
    text-decoration: none;
    transition: var(--transition-fast);
}

.tpl-card__title a:hover {
    color: var(--color-lime-1);
}

.tpl-card__text {
    margin: 0;
    color: var(--color-white-1);
    opacity: .7;
    font-size: var(--font-size-sm);
    line-height: var(--line-height-body);
}

/* pushed to the bottom so the buttons line up across a row of cards */
.tpl-card__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: auto;
    padding-top: 10px;
}

.tpl-card__btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 11px 18px;
    border: 1px solid var(--color-divider-2);
    border-radius: var(--border-radius-3);
    color: var(--color-white-1);
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-semibold);
    line-height: 1;
    text-decoration: none;
    transition: var(--transition-fast);
}

.tpl-card__btn:hover {
    border-color: var(--color-lime-1);
    color: var(--color-lime-1);
}

.tpl-card__btn--primary {
    background: var(--color-lime-1);
    border-color: var(--color-lime-1);
    color: var(--color-black-1);
}

.tpl-card__btn--primary:hover {
    background: var(--color-white-1);
    border-color: var(--color-white-1);
    color: var(--color-black-1);
}

.templates-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    max-width: 560px;
    margin: 40px auto 0;
    padding: 50px 30px;
    border: 1px dashed var(--color-divider-2);
    border-radius: var(--border-radius-1);
    text-align: center;
    color: var(--color-white-1);
}

.templates-empty > i {
    font-size: 40px;
    color: var(--color-lime-1);
}

.templates-empty p {
    margin: 0;
    opacity: .75;
    line-height: var(--line-height-body);
}

/* ---------- Template page ---------- */

.template-single__panel {
    position: sticky;
    top: 130px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 30px;
    border: 1px solid var(--color-divider-2);
    border-radius: var(--border-radius-1);
    background: var(--bg-color-1);
    color: var(--color-white-1);
}

.template-single__name {
    margin: 0;
    font-size: clamp(24px, 2vw, 30px);
    font-weight: var(--font-weight-bold);
    line-height: var(--line-height-heading);
}

.template-single__line {
    margin: 0;
    opacity: .75;
    line-height: var(--line-height-body);
}

.template-single__subtitle {
    margin: 10px 0 0;
    font-size: var(--font-size-base);
    font-weight: var(--font-weight-bold);
}

.template-single__features {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.template-single__features li {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    font-size: var(--font-size-sm);
    line-height: 1.5em;
}

.template-single__features i {
    flex: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: var(--border-radius-2);
    background: rgba(207, 248, 94, .12);
    color: var(--color-lime-1);
    font-size: 14px;
}

.template-single__actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 12px;
}

.template-single__actions .special-btn button {
    justify-content: center;
}

.template-single__demo {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 14px 18px;
    border: 1px solid var(--color-divider-2);
    border-radius: 14px;
    color: var(--color-white-1);
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-semibold);
    text-decoration: none;
    transition: var(--transition-fast);
}

.template-single__demo:hover {
    border-color: var(--color-lime-1);
    color: var(--color-lime-1);
}

.template-single__note {
    margin: 4px 0 0;
    font-size: 13px;
    opacity: .55;
    line-height: 1.5em;
}

.template-single__body {
    margin-top: 50px;
    color: var(--color-white-1);
}

/* ---------- "I want this template" modal ---------- */

.template-request-modal .modal-dialog {
    max-width: 620px;
}

.template-request-modal .modal-content {
    min-height: unset;
}

.template-request-modal .modal-body {
    padding: 0 40px 40px;
    display: block;
}

.template-request__head {
    margin-bottom: 26px;
    color: var(--color-white-1);
}

.template-request__chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    border-radius: var(--border-radius-3);
    background: rgba(207, 248, 94, .12);
    color: var(--color-lime-1);
    font-size: 13px;
    font-weight: var(--font-weight-semibold);
}

.template-request__head h2 {
    margin: 14px 0 8px;
    font-size: clamp(24px, 2.2vw, 30px);
    font-weight: var(--font-weight-bold);
    line-height: var(--line-height-heading);
}

.template-request__head p {
    margin: 0;
    opacity: .7;
    line-height: var(--line-height-body);
}

.template-request__form .form-group {
    margin-bottom: 14px;
}

/* the modal rule in style.css gives every textarea 150px; three rows do here */
.template-request-modal textarea {
    min-height: 96px;
}

.template-request__form .special-btn button {
    justify-content: center;
    margin-top: 6px;
}

.template-request__privacy {
    margin: 14px 0 0;
    color: var(--color-white-1);
    font-size: 12px;
    opacity: .55;
    text-align: center;
}

.template-request__privacy a {
    color: inherit;
    text-decoration: underline;
    text-underline-offset: 3px;
}

/* ---------- Full-screen live demo ---------- */

body.tpl-viewer-body {
    height: 100vh;
    height: 100dvh;
    margin: 0;
    overflow: hidden;
    background: var(--bg-color-2);
}

.tpl-viewer {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.tpl-viewer__bar {
    display: flex;
    flex: none;
    align-items: center;
    gap: 16px;
    padding: 10px 16px;
    border-bottom: 1px solid var(--color-divider-2);
    background: var(--bg-color-1);
    color: var(--color-white-1);
}

.tpl-viewer__back {
    display: inline-flex;
    flex: none;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    border: 1px solid var(--color-divider-2);
    border-radius: var(--border-radius-3);
    color: var(--color-white-1);
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-semibold);
    text-decoration: none;
    transition: var(--transition-fast);
}

.tpl-viewer__back:hover {
    border-color: var(--color-lime-1);
    color: var(--color-lime-1);
}

.tpl-viewer__title {
    display: flex;
    flex-direction: column;
    min-width: 0;
    line-height: 1.25;
}

.tpl-viewer__label {
    color: var(--color-lime-1);
    font-size: 11px;
    font-weight: var(--font-weight-semibold);
    text-transform: uppercase;
    letter-spacing: .08em;
}

.tpl-viewer__title strong {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    font-size: var(--font-size-base);
}

.tpl-viewer__devices {
    display: inline-flex;
    gap: 4px;
    margin: 0 auto;
    padding: 4px;
    border: 1px solid var(--color-divider-2);
    border-radius: var(--border-radius-3);
    background: var(--bg-color-2);
}

.tpl-viewer__device {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 34px;
    border: none;
    border-radius: var(--border-radius-3);
    background: transparent;
    color: var(--color-white-1);
    font-size: 16px;
    opacity: .6;
    cursor: pointer;
    transition: var(--transition-fast);
}

.tpl-viewer__device:hover {
    opacity: 1;
}

.tpl-viewer__device.is-active {
    background: var(--color-lime-1);
    color: var(--color-black-1);
    opacity: 1;
}

.tpl-viewer__actions {
    display: flex;
    flex: none;
    align-items: center;
    gap: 10px;
}

.tpl-viewer__open {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border: 1px solid var(--color-divider-2);
    border-radius: 14px;
    color: var(--color-white-1);
    text-decoration: none;
    transition: var(--transition-fast);
}

.tpl-viewer__open:hover {
    border-color: var(--color-lime-1);
    color: var(--color-lime-1);
}

.tpl-viewer__cta-short {
    display: none;
}

/* the stage fills what the bar leaves; the frame inside is what the device
   buttons resize, centred, with the stage colour around a narrow device */
.tpl-viewer__stage {
    --tpl-viewer-width: 100%;
    display: flex;
    flex: 1;
    justify-content: center;
    min-height: 0;
    background: var(--bg-color-2);
}

.tpl-viewer__stage[data-device="tablet"] {
    --tpl-viewer-width: 820px;
    padding: 20px;
}

.tpl-viewer__stage[data-device="mobile"] {
    --tpl-viewer-width: 390px;
    padding: 20px;
}

.tpl-viewer__frame {
    position: relative;
    width: 100%;
    max-width: var(--tpl-viewer-width);
    height: 100%;
    overflow: hidden;
    background: #fff;
}

.tpl-viewer__stage[data-device="tablet"] .tpl-viewer__frame,
.tpl-viewer__stage[data-device="mobile"] .tpl-viewer__frame {
    border: 1px solid var(--color-divider-2);
    border-radius: 22px;
    box-shadow: 0 30px 80px -40px rgba(0, 0, 0, .9);
}

.tpl-viewer__frame iframe {
    display: block;
    width: 100%;
    height: 100%;
    border: 0;
}

.tpl-viewer__loading {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    background: var(--bg-color-2);
    color: var(--color-white-1);
    font-size: var(--font-size-sm);
    z-index: 1;
}

.tpl-viewer__loading[hidden] {
    display: none;
}

.tpl-viewer__spinner {
    width: 36px;
    height: 36px;
    border: 3px solid var(--color-divider-2);
    border-top-color: var(--color-lime-1);
    border-radius: var(--border-radius-2);
    animation: tpl-viewer-spin .8s linear infinite;
}

@keyframes tpl-viewer-spin {
    to {
        transform: rotate(360deg);
    }
}

/* ---------- Responsive ---------- */

@media (max-width: 1199.98px) {
    .templates-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 30px;
    }
}

@media (max-width: 991.98px) {
    .template-single__panel {
        position: static;
    }

    /* a phone or small tablet already is the device: the switcher has nothing to show */
    .tpl-viewer__devices {
        display: none;
    }

    .tpl-viewer__actions {
        margin-left: auto;
    }
}

@media (max-width: 767.98px) {
    .templates-grid {
        grid-template-columns: minmax(0, 1fr);
        gap: 24px;
    }

    .templates-list__intro {
        margin-bottom: 24px;
        font-size: var(--font-size-sm);
    }

    .tpl-card__body {
        padding: 18px 20px 22px;
    }

    .template-single__panel {
        padding: 24px 20px;
    }

    .template-request-modal .modal-dialog {
        max-width: none;
        margin: 12px;
    }

    .template-request-modal .modal-body {
        padding: 0 20px 24px;
    }

    .tpl-viewer__bar {
        gap: 10px;
        padding: 8px 10px;
    }

    .tpl-viewer__back span,
    .tpl-viewer__label,
    .tpl-viewer__open {
        display: none;
    }

    .tpl-viewer__back {
        padding: 10px 12px;
    }

    .tpl-viewer__cta-long {
        display: none;
    }

    .tpl-viewer__cta-short {
        display: inline;
    }

    .tpl-viewer__actions .special-btn button {
        padding: 12px 50px 12px 16px;
        font-size: var(--font-size-sm);
    }

    .tpl-viewer__actions .special-btn button i {
        width: 32px;
        height: 32px;
    }
}
