/**
 * App content template — one stylesheet for every app in the Apps sheet.
 *
 * Markup lives inside #appSheetDetail (dedicated detail view; #/apps is the selection grid). Each .app-item supplies:
 *   data-detail-slug (URL segment, e.g. perfect-scorm → #/apps/perfect-scorm),
 *   data-detail-title, data-detail-body (||| paragraphs), data-detail-video,
 *   data-detail-image (optional poster when video is set), data-detail-image-alt,
 *   data-detail-buy-url (https only; used when JSON is missing)
 *   data-detail-embed-url — same; when set (with no JSON), body + media are replaced by an iframe
 * Buy Now: always shown in #appSheetDetailBuyWrap — link when buyNowUrl is set, else .app-page__buy-now--inactive
 * embedUrl in JSON: optional https URL in #appSheetDetailEmbed (body + media hidden). Adds .app-sheet-detail--embed:
 *   toolbar and Buy Now are hidden — app name appears in the top nav; external page supplies other chrome.
 *
 * Shareable routes (hash): #/home | #/apps | #/apps/<slug> | #/apps/<slug>/support | #/apps/<slug>/privacy (opens matching <details>, scrolls into view)
 * Wiring: website_assets/js/App.js (hashchange → applyRouteFromHash, showAppDetail).
 *
 * Visual content editor (text + layout modifiers): content-editor.html
 * Static layout reference (same classes): design-preview.html
 * Per-app copy and media paths: website_assets/app-content/<slug>.json (see README.txt there).
 */

/* --- App detail view (full panel; selection grid is separate) --- */
.app-sheet-detail {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-top: 0;
    padding-top: 0;
    border-top: none;
    width: 100%;
    align-self: stretch;
    text-align: left;
}

.app-sheet-detail[hidden] {
    display: none !important;
}

.app-sheet-detail.app-sheet-detail--embed {
    gap: 8px;
    min-height: 0;
}

.app-sheet-detail--embed .app-sheet-detail__toolbar,
.app-sheet-detail--embed .app-sheet-detail__buy-wrap,
.app-sheet-detail--embed .app-sheet-detail__privacy-wrap,
.app-sheet-detail--embed .app-sheet-detail__support-wrap {
    display: none !important;
}

/* Shared column — matches banner / detail grid (1280px max, centred in the panel). */
.apps-content-rail {
    width: min(100%, 1280px);
    max-width: 100%;
    margin-inline: auto;
    align-self: center;
    box-sizing: border-box;
}

/* Apps list — top inset matches tab-panel side/bottom padding (no in-page Apps lozenge) */
.tab-panel[data-panel="app"].apps-panel--list {
    padding-top: 28px;
}

/* Full-height white panel behind the apps grid — matches app detail content rail */
.apps-panel__content-panel {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    align-self: center;
    width: min(100%, 1280px);
    max-width: 100%;
    flex: 1 1 auto;
    min-height: 0;
    margin-inline: auto;
    padding: 20px 24px 28px;
    border-radius: 12px;
    background: #fff;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.12);
    box-sizing: border-box;
}

.tab-panel[data-panel="app"] .apps-panel__icons-slot {
    flex: 1 1 auto;
    min-height: 0;
    align-self: stretch;
}

/* App detail — same top inset as the apps list (breadcrumb is in the fixed nav) */
.tab-panel[data-panel="app"].apps-panel--detail {
    padding-top: 28px;
}

@media (max-width: 768px), ((max-height: 480px) and (orientation: landscape)) {
    .tab-panel[data-panel="app"].apps-panel--list {
        padding-top: 12px;
    }

    .tab-panel[data-panel="app"].apps-panel--detail {
        padding-top: 12px;
    }

    .apps-panel__content-panel {
        width: 100%;
        padding: 14px 10px 18px;
        border-radius: 10px;
    }
}

.app-sheet-detail__toolbar {
    position: relative;
    z-index: 0;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-shrink: 0;
}

.app-sheet-detail__title {
    margin: 0;
    text-align: left;
}

.app-sheet-detail__banner {
    display: block;
    width: min(100%, 1280px);
    max-width: 100%;
    height: auto;
    aspect-ratio: 1280 / 452;
    object-fit: contain;
    border-radius: 12px;
}

/* Sheet detail heading: fixed default size (overrides .app-page__title clamp in this context) */
.app-sheet-detail .app-page__title.app-sheet-detail__title {
    font-size: 35px;
    line-height: 1.15;
}

.app-sheet-detail__grid {
    width: 100%;
}

/* When a toolbar banner or Gumroad embed is used, keep content aligned to the same max width. */
.app-sheet-detail.app-sheet-detail--has-banner .app-sheet-detail__grid,
.app-sheet-detail.app-sheet-detail--embed .app-sheet-detail__grid {
    width: min(100%, 1280px);
    margin-left: auto;
    margin-right: auto;
    align-self: center;
}

.app-sheet-detail.app-sheet-detail--has-banner .app-sheet-detail__toolbar {
    position: relative;
    justify-content: center;
}

.app-sheet-detail.app-sheet-detail--has-banner .app-sheet-detail__banner {
    margin-left: auto;
    margin-right: auto;
}


.app-sheet-detail .app-page__figure {
    min-height: 160px;
}

.app-sheet-detail .app-page__video,
.app-sheet-detail .app-page__image {
    max-height: min(38vh, 400px);
}

.app-page__close {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.08);
    color: #333;
    font-size: 26px;
    line-height: 1;
    cursor: pointer;
    transition: background 0.2s;
    flex-shrink: 0;
}

.app-page__close:hover {
    background: rgba(0, 0, 0, 0.18);
}

.app-page__title {
    margin: 0;
    flex: 1;
    min-width: 0;
    font-family: Arial, sans-serif;
    font-size: clamp(1.1rem, 2.2vw, 1.5rem);
    font-weight: bold;
    color: #222;
    line-height: 1.2;
}

.app-sheet-detail__text-col {
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

/* Right column — video/image with buy buttons stacked directly underneath */
.app-sheet-detail__media-col {
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: clamp(12px, 2vw, 20px);
}

.app-page__grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(220px, 36%);
    gap: clamp(16px, 2.5vw, 28px);
    align-items: start;
}

.app-sheet-detail__grid > .app-sheet-detail__text-col {
    grid-column: 1;
    grid-row: 1;
}

.app-sheet-detail__grid > .app-sheet-detail__media-col {
    grid-column: 2;
    grid-row: 1;
}

.app-sheet-detail__media-col > .app-page__figure {
    width: 100%;
    margin: 0;
}

.app-page__grid.app-page__grid--embed {
    grid-template-columns: 1fr;
    display: flex;
    flex-direction: column;
    flex: 1 1 0%;
    min-height: 0;
}

@media (max-width: 720px) {
    .app-page__grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .app-sheet-detail__grid > .app-sheet-detail__text-col,
    .app-sheet-detail__grid > .app-sheet-detail__media-col {
        grid-column: auto;
        grid-row: auto;
    }

    .app-sheet-detail__buy-wrap {
        width: 100%;
        justify-self: stretch;
        align-self: stretch;
    }

    .app-sheet-detail__support-wrap,
    .app-sheet-detail__privacy-wrap {
        grid-column: 1 / -1;
        width: 100%;
    }

    .app-sheet-detail__text-col {
        width: 100%;
        align-items: stretch;
    }

    .app-sheet-detail__grid > .app-page__figure {
        width: 100%;
    }

    .app-sheet-detail__media-col {
        width: 100%;
    }

    .app-page__buy-now-badge-link,
    .app-page__buy-now-badge-wrap {
        width: auto;
        max-width: 100%;
        justify-content: center;
    }
}

.app-sheet-detail__embed-wrap {
    width: 100%;
    min-height: min(52vh, 520px);
    height: min(68vh, 720px);
    max-height: 78vh;
    border-radius: 12px;
    overflow: hidden;
    background: #fff;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.12);
}

.app-sheet-detail.app-sheet-detail--embed .app-sheet-detail__text-col {
    flex: 1 1 0%;
    min-height: 0;
    align-self: stretch;
    width: 100%;
    align-items: stretch;
}

.app-sheet-detail.app-sheet-detail--embed .app-sheet-detail__embed-wrap {
    position: relative;
    flex: 1 1 0%;
    min-height: 0;
    align-self: stretch;
    width: 100%;
    height: auto;
    max-height: none;
}

.app-sheet-detail.app-sheet-detail--embed .app-sheet-detail__embed {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    min-height: 0;
}

.app-sheet-detail__embed-wrap[hidden] {
    display: none !important;
}

.app-sheet-detail__embed {
    display: block;
    width: 100%;
    height: 100%;
    min-height: inherit;
    border: 0;
}

.app-page__body {
    margin: 0;
    font-family: Arial, sans-serif;
    font-size: clamp(0.95rem, 1.5vw, 1.05rem);
    line-height: 1.55;
    color: #444;
}

.app-page__body p {
    margin: 0 0 1em;
}

.app-page__body p:last-child {
    margin-bottom: 0;
}

.app-page__body-lead {
    margin: 0 0 1.25em;
    font-size: 1.08em;
    line-height: 1.62;
    color: #333;
}

.app-page__body-heading {
    margin: 1.55em 0 0.55em;
    font-family: Arial, sans-serif;
    font-size: 1.02rem;
    font-weight: bold;
    line-height: 1.3;
    color: #222;
    letter-spacing: 0.01em;
}

.app-page__body-heading:first-child {
    margin-top: 0;
}

.app-page__body-subheading {
    margin: 0.9em 0 0.35em;
    font-family: Arial, sans-serif;
    font-size: 0.98rem;
    font-weight: bold;
    line-height: 1.35;
    color: #2a2a2a;
}

.app-page__body-list {
    margin: 0 0 1.05em;
    padding-left: 1.2em;
    font-family: Arial, sans-serif;
    font-size: inherit;
    line-height: 1.55;
    color: #444;
}

.app-page__body-list li {
    margin: 0 0 0.45em;
    padding-left: 0.15em;
}

.app-page__body b,
.app-page__body strong {
    font-weight: 700;
}

.app-page__body-heading b,
.app-page__body-heading strong,
.app-page__body-subheading b,
.app-page__body-subheading strong {
    font-weight: 900;
}

.app-page__body-lead b,
.app-page__body-lead strong {
    font-weight: 800;
}

.app-page__body-list b,
.app-page__body-list strong {
    font-weight: 700;
}

.app-page__body-list li:last-child {
    margin-bottom: 0;
}

.app-page__body > .app-page__body-heading + .app-page__body-list,
.app-page__body > .app-page__body-heading + .app-page__body-subheading {
    margin-top: 0.15em;
}

.app-sheet-detail__buy-wrap {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 12px;
    margin-top: 0;
    flex-shrink: 0;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

/* When a text buy button and App Store badge stack, keep badge at intrinsic size */
.app-sheet-detail__buy-wrap:has(.app-page__buy-now) {
    align-items: stretch;
}

.app-sheet-detail__buy-wrap:has(.app-page__buy-now) .app-page__buy-now {
    width: 100%;
    box-sizing: border-box;
    text-align: center;
}

.app-sheet-detail__buy-wrap:has(.app-page__buy-now) .app-page__buy-now-badge-link,
.app-sheet-detail__buy-wrap:has(.app-page__buy-now) .app-page__buy-now-badge-wrap {
    width: auto;
    align-self: center;
}

.app-sheet-detail__privacy-wrap {
    margin-top: 0.45rem;
    margin-bottom: 1.5rem;
    grid-column: 1 / -1;
}

.app-sheet-detail__support-wrap {
    margin-top: 0.45rem;
    grid-column: 1 / -1;
}

.app-page__privacy {
    border: 1px solid rgba(0, 0, 0, 0.14);
    border-radius: 10px;
    background: #f6f6f6;
    overflow: clip;
}

.app-page__privacy > summary {
    cursor: pointer;
    list-style: none;
    padding: 0.8rem 1rem;
    font-family: Arial, sans-serif;
    font-size: 0.96rem;
    font-weight: bold;
    color: #222;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.88), rgba(245, 245, 245, 0.9));
}

.app-page__privacy > summary::-webkit-details-marker {
    display: none;
}

.app-page__privacy > summary::after {
    content: "▾";
    font-size: 0.9rem;
    color: #555;
    transition: transform 0.18s ease;
}

.app-page__privacy[open] > summary::after {
    transform: rotate(180deg);
}

.app-page__privacy-content {
    padding: 0.9rem 1rem 1rem;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
    font-family: Arial, sans-serif;
    font-size: 0.95rem;
    line-height: 1.55;
    color: #353535;
    background: #f9f9f9;
}

.app-page__privacy-content h4 {
    margin: 0.9rem 0 0.35rem;
    font-size: 0.98rem;
    line-height: 1.3;
    color: #222;
}

.app-page__privacy-content h4:first-child {
    margin-top: 0;
}

.app-page__privacy-content p {
    margin: 0 0 0.75rem;
}

.app-page__privacy-content p:last-child {
    margin-bottom: 0;
}

.app-page__support {
    border: 1px solid rgba(0, 0, 0, 0.14);
    border-radius: 10px;
    background: #f6f6f6;
    overflow: clip;
}

.app-page__support > summary {
    cursor: pointer;
    list-style: none;
    padding: 0.8rem 1rem;
    font-family: Arial, sans-serif;
    font-size: 0.96rem;
    font-weight: bold;
    color: #222;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.88), rgba(245, 245, 245, 0.9));
}

.app-page__support > summary::-webkit-details-marker {
    display: none;
}

.app-page__support > summary::after {
    content: "▾";
    font-size: 0.9rem;
    color: #555;
    transition: transform 0.18s ease;
}

.app-page__support[open] > summary::after {
    transform: rotate(180deg);
}

.app-page__support-content {
    padding: 0.9rem 1rem 1rem;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
    background: #f9f9f9;
}

.app-page__support-prompt {
    margin: 0 0 0.75rem;
    font-family: Arial, sans-serif;
    font-size: 0.95rem;
    line-height: 1.5;
    color: #353535;
}

.app-page__support-form {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.app-page__support-label {
    font-family: Arial, sans-serif;
    font-size: 0.9rem;
    font-weight: bold;
    color: #222;
}

.app-page__support-textarea {
    width: 100%;
    min-height: 120px;
    resize: vertical;
    padding: 0.7rem 0.8rem;
    border: 1px solid rgba(0, 0, 0, 0.22);
    border-radius: 8px;
    background: #fff;
    color: #222;
    font-family: Arial, sans-serif;
    font-size: 0.95rem;
    line-height: 1.4;
}

.app-page__support-textarea:focus-visible {
    outline: 3px solid #1a5f3a;
    outline-offset: 1px;
}

.app-page__support-send {
    align-self: flex-start;
    border: 1px solid rgba(0, 0, 0, 0.12);
    border-radius: 9px;
    padding: 0.62rem 1.1rem;
    min-height: 42px;
    font-family: Arial, sans-serif;
    font-size: 0.92rem;
    font-weight: bold;
    color: #fff;
    background: linear-gradient(180deg, #2d2d2d 0%, #151515 52%, #0d0d0d 100%);
    cursor: pointer;
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.12) inset, 0 2px 8px rgba(0, 0, 0, 0.35);
}

.app-page__support-send:hover {
    background: linear-gradient(180deg, #3a3a3a 0%, #212121 52%, #121212 100%);
}

.app-page__support-notice {
    margin: 0.1rem 0 0;
    font-family: Arial, sans-serif;
    font-size: 0.88rem;
    line-height: 1.45;
    color: #4a4a4a;
}

.app-page__buy-now {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.65em 1.35em;
    min-height: 44px;
    font-family: Arial, sans-serif;
    font-size: clamp(0.95rem, 1.4vw, 1.05rem);
    font-weight: bold;
    letter-spacing: 0.02em;
    text-decoration: none;
    color: #fff;
    background: linear-gradient(180deg, #2ecc71 0%, #1e9c55 48%, #178a4a 100%);
    border: 1px solid rgba(0, 0, 0, 0.12);
    border-radius: 10px;
    box-shadow:
        0 1px 0 rgba(255, 255, 255, 0.22) inset,
        0 2px 8px rgba(30, 156, 85, 0.35);
    transition: background 0.2s ease, box-shadow 0.2s ease, transform 0.15s ease, border-color 0.2s ease;
}

a.app-page__buy-now:hover {
    color: #fff;
    background: linear-gradient(180deg, #3ddb82 0%, #27b564 50%, #1fa356 100%);
    border-color: rgba(0, 0, 0, 0.14);
    box-shadow:
        0 1px 0 rgba(255, 255, 255, 0.28) inset,
        0 4px 14px rgba(30, 156, 85, 0.45);
    transform: translateY(-1px);
}

a.app-page__buy-now:active {
    transform: translateY(0);
    box-shadow:
        0 1px 0 rgba(255, 255, 255, 0.15) inset,
        0 1px 4px rgba(0, 0, 0, 0.15);
}

a.app-page__buy-now:focus-visible {
    outline: 3px solid #1a5f3a;
    outline-offset: 3px;
}

/* Dark button variant for app-specific branding (e.g. Already Dark). */
.app-page__buy-now.app-page__buy-now--dark {
    color: #fff;
    background: linear-gradient(180deg, #2d2d2d 0%, #151515 52%, #0d0d0d 100%);
    border-color: rgba(255, 255, 255, 0.08);
    box-shadow:
        0 1px 0 rgba(255, 255, 255, 0.12) inset,
        0 2px 8px rgba(0, 0, 0, 0.38);
}

a.app-page__buy-now.app-page__buy-now--dark:hover {
    color: #fff;
    background: linear-gradient(180deg, #3a3a3a 0%, #212121 52%, #121212 100%);
    border-color: rgba(255, 255, 255, 0.16);
    box-shadow:
        0 1px 0 rgba(255, 255, 255, 0.16) inset,
        0 4px 14px rgba(0, 0, 0, 0.45);
}

a.app-page__buy-now.app-page__buy-now--dark:focus-visible {
    outline: 3px solid #4f4f4f;
    outline-offset: 3px;
}

/* Same footprint as the link; shown when buyNowUrl is not set (template default) */
.app-page__buy-now--inactive {
    cursor: default;
    user-select: none;
    opacity: 0.72;
    color: rgba(255, 255, 255, 0.92);
    background: linear-gradient(180deg, #6abf8f 0%, #4a9a6c 48%, #3d855d 100%);
    box-shadow:
        0 1px 0 rgba(255, 255, 255, 0.12) inset,
        0 1px 4px rgba(0, 0, 0, 0.08);
}

.app-page__buy-now-badge-link,
.app-page__buy-now-badge-wrap {
    display: inline-flex;
    align-items: center;
    justify-content: flex-end;
    width: auto;
    max-width: 100%;
    padding: 0;
    border: none;
    background: transparent;
    line-height: 0;
}

.app-page__buy-now-badge-link {
    text-decoration: none;
    border-radius: 0;
}

/* Apple badge SVGs: 60px tall (50% above standard 40px 1x artwork) */
.app-page__buy-now-badge {
    display: block;
    width: auto;
    height: 60px;
    max-width: 100%;
    border: none;
    background: transparent;
}

.app-page__buy-now-badge-wrap--inactive {
    opacity: 0.75;
    cursor: default;
}

.app-page__buy-now-badge-notice {
    margin: 0;
    width: auto;
    max-width: min(20rem, 100%);
    font-family: Arial, sans-serif;
    font-size: 0.88rem;
    line-height: 1.45;
    color: #4a4a4a;
    text-align: right;
}

.app-page__figure {
    margin: 0;
    position: relative;
    min-height: 200px;
    border-radius: 12px;
    overflow: hidden;
    background: linear-gradient(145deg, #d8d8d8 0%, #a8a8a8 100%);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.12);
}

.app-page__figure--video,
.app-page__figure--video-embed {
    background: #0a0a0a;
}

.app-page__image {
    display: none;
    width: 100%;
    height: auto;
    object-fit: contain;
    vertical-align: middle;
}

.app-page__figure--image .app-page__image {
    display: block;
}

.app-page__video {
    display: none;
    width: 100%;
    border-radius: 0;
    object-fit: contain;
    vertical-align: middle;
}

.app-page__figure--video .app-page__video {
    display: block;
}

.app-page__video-embed {
    display: none;
    width: 100%;
    aspect-ratio: 16 / 9;
    height: auto;
    border: 0;
    vertical-align: middle;
    background: transparent;
}

.app-page__figure--video-embed .app-page__video-embed {
    display: block;
}

.app-page__figure-placeholder {
    position: absolute;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    font-family: Arial, sans-serif;
    font-size: 14px;
    font-weight: bold;
    letter-spacing: 0.08em;
    color: #555;
    pointer-events: none;
}

.app-page__figure--placeholder .app-page__figure-placeholder {
    display: flex;
}

.app-page__figure--video .app-page__figure-placeholder,
.app-page__figure--video-embed .app-page__figure-placeholder,
.app-page__figure--image .app-page__figure-placeholder {
    display: none;
}

.app-item--selected .app-icon-frame {
    outline: 3px solid #333;
    outline-offset: 2px;
}

.app-item--selected .app-title {
    color: #000;
}

/* Final mobile override: keep Already Dark detail as a strict full-width single column stack. */
@media (max-width: 900px) {
    .app-sheet-detail__grid {
        display: flex;
        flex-direction: column;
        gap: 16px;
        width: 100%;
    }

    .app-sheet-detail__grid > .app-sheet-detail__text-col {
        order: 1;
        width: 100%;
        align-items: stretch;
    }

    .app-sheet-detail__grid > .app-sheet-detail__media-col {
        order: 2;
        width: 100%;
    }

    .app-sheet-detail__buy-wrap {
        order: unset;
        align-items: center;
        width: 100%;
        margin-top: 0;
    }

    .app-sheet-detail__buy-wrap:has(.app-page__buy-now) {
        width: 100%;
        max-width: 100%;
        align-items: stretch;
    }

    .app-page__buy-now-badge-notice {
        text-align: center;
    }

    .app-page__buy-now-badge-link,
    .app-page__buy-now-badge-wrap {
        width: auto;
        max-width: 100%;
        justify-content: center;
    }

    .app-sheet-detail__support-wrap {
        order: 3;
        width: 100%;
    }

    .app-sheet-detail__privacy-wrap {
        order: 4;
        width: 100%;
    }
}
