/* Shared app chrome: launcher, frame, feedback, related essays.
   Tokens come from tokens.css. Hosts load this after that file. */

.apps-launcher {
    --apps-icon: 68px;
}

@media (min-width: 480px) {
    .apps-launcher {
        --apps-icon: 76px;
    }
}

@media (min-width: 860px) {
    .apps-launcher {
        --apps-icon: 92px;
    }
}

.apps-theme-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 2px;
    margin: 0 0 0.85rem;
    padding: 3px;
    border: 1px solid var(--kld-line);
    border-radius: 12px;
    background: var(--kld-wash);
}

a.apps-theme-chip,
a.apps-theme-chip:link,
a.apps-theme-chip:visited {
    flex: 1 1 auto;
    display: inline-block;
    border: 0;
    border-radius: 9px;
    padding: 0.42rem 0.7rem;
    background: transparent;
    color: var(--kld-muted);
    font-family: Inter, Arial, Helvetica, sans-serif;
    font-size: 0.82rem;
    font-weight: 600;
    line-height: 1.25;
    text-align: center;
    text-decoration: none;
    white-space: nowrap;
}

a.apps-theme-chip:hover {
    color: var(--kld-ink);
    text-decoration: none;
}

a.apps-theme-chip.is-active,
a.apps-theme-chip.is-active:link,
a.apps-theme-chip.is-active:visited,
a.apps-theme-chip.is-active:hover {
    background: var(--kld-paper);
    color: var(--kld-ink);
    box-shadow: 0 1px 1px rgba(23, 32, 43, 0.08);
}

a.apps-theme-chip:focus-visible {
    outline: 2px solid var(--kld-blue);
    outline-offset: 1px;
}

.apps-launcher-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 1.35rem 0.5rem;
    justify-items: center;
    padding: 1.15rem 0.35rem 0.95rem;
    border: 1px solid var(--kld-line);
    border-radius: 18px;
    background: var(--kld-wash);
}

.apps-tile {
    position: relative;
    align-self: start;
    width: 100%;
}

.apps-tile[hidden] {
    display: none;
}

.apps-tile-open {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.4rem;
    width: 100%;
    text-align: center;
    color: var(--kld-ink);
    text-decoration: none;
}

a.apps-tile-open:link,
a.apps-tile-open:visited,
a.apps-tile-open:hover,
a.apps-tile-open:focus {
    color: var(--kld-ink);
    text-decoration: none;
}

.apps-tile-icon {
    width: var(--apps-icon);
    height: var(--apps-icon);
    border-radius: 22%;
    object-fit: cover;
    background: var(--kld-paper);
    box-shadow: 0 1px 2px rgba(23, 32, 43, 0.14);
    transition: transform 80ms ease;
}

a.apps-tile-open:hover .apps-tile-icon {
    box-shadow: 0 1px 2px rgba(23, 32, 43, 0.2);
}

a.apps-tile-open:active .apps-tile-icon {
    transform: scale(0.96);
}

.apps-tile.is-current .apps-tile-icon {
    box-shadow: 0 0 0 2px var(--kld-blue);
}

.apps-tile.is-later .apps-tile-open {
    opacity: 0.42;
}

.apps-tile-name {
    display: block;
    max-width: 100%;
    color: var(--kld-ink);
    font-family: Inter, Arial, Helvetica, sans-serif;
    font-size: 0.75rem;
    font-weight: 500;
    line-height: 1.25;
    text-align: center;
    overflow-wrap: anywhere;
}

.apps-tile-soon {
    display: block;
    margin-top: -0.15rem;
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    line-height: 1.2;
    text-transform: uppercase;
    color: var(--kld-muted);
}

.apps-tile-about {
    position: absolute;
    z-index: 2;
    top: -6px;
    left: calc(50% + (var(--apps-icon) / 2) - 18px);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    border: 1px solid var(--kld-line);
    border-radius: 50%;
    background: var(--kld-paper);
    color: var(--kld-ink);
    cursor: pointer;
}

.apps-tile-about svg {
    display: block;
}

.apps-tile-about:hover {
    border-color: var(--kld-ink);
}

a.apps-tile-open:focus-visible .apps-tile-icon,
.apps-tile-open:focus-visible .apps-tile-icon,
.apps-tile-about:focus-visible {
    outline: 2px solid var(--kld-blue);
    outline-offset: 3px;
}

/* A fine pointer that can hover gets the pane from the icon itself. */
@media (min-width: 860px) and (hover: hover) and (pointer: fine) {
    .apps-tile-about {
        display: none;
    }
}

@media (forced-colors: active) {
    a.apps-tile-open:focus-visible .apps-tile-icon,
    .apps-tile-open:focus-visible .apps-tile-icon,
    .apps-tile-about:focus-visible,
    a.apps-theme-chip.is-active {
        outline: 2px solid CanvasText;
    }
}

@media (prefers-reduced-motion: reduce) {
    .apps-tile-icon {
        transition: none;
    }

    a.apps-tile-open:active .apps-tile-icon {
        transform: none;
    }
}

@media (max-width: 859px) {
    .apps-launcher-pane {
        display: none;
    }
}

@media (min-width: 860px) {
    .apps-launcher-layout {
        display: grid;
        grid-template-columns: minmax(0, 1fr) minmax(240px, 320px);
        column-gap: 1.75rem;
        align-items: start;
    }

    .apps-launcher-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 1.5rem 0.85rem;
    }

    .apps-launcher-pane {
        position: sticky;
        top: 1.25rem;
        border: 1px solid var(--kld-line);
        border-radius: 14px;
        background: var(--kld-paper);
        padding: 1.05rem 1.1rem 1.15rem;
        box-shadow: none;
    }
}

@media (min-width: 1100px) {
    .apps-launcher-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

.apps-launcher-pane-empty {
    margin: 0;
    color: var(--kld-muted);
    font-size: 0.95rem;
    line-height: 1.5;
}

.apps-launcher-pane-body:focus {
    outline: none;
}

.apps-detail-name {
    margin: 0 0 0.35rem;
    color: var(--kld-ink);
    font-size: 1.2rem;
    line-height: 1.25;
}

.apps-detail-status {
    margin: 0 0 0.55rem;
    color: var(--kld-muted);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    line-height: 1.3;
    text-transform: uppercase;
}

.apps-detail-status.is-live {
    color: var(--kld-rust);
}

.apps-detail-status.is-beta {
    color: var(--kld-blue);
}

.apps-detail-themes {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin: 0 0 0.75rem;
}

.apps-detail-theme {
    display: inline-block;
    padding: 0.12rem 0.45rem;
    border-radius: 999px;
    background: var(--kld-sage);
    color: var(--kld-blue);
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    line-height: 1.3;
    text-transform: uppercase;
}

.apps-detail-summary {
    margin: 0;
    color: var(--kld-muted);
    font-size: 0.95rem;
    line-height: 1.55;
}

.apps-launcher-sheet {
    position: fixed;
    inset: auto 0 0 0;
    width: 100%;
    max-width: none;
    height: fit-content;
    max-height: min(78vh, 34rem);
    margin: 0;
    padding: 0 0 env(safe-area-inset-bottom);
    border: 0;
    border-radius: 18px 18px 0 0;
    background: var(--kld-paper);
    color: var(--kld-ink);
    box-shadow: 0 -8px 30px rgba(23, 32, 43, 0.18);
}

.apps-launcher-sheet::backdrop {
    background: rgba(23, 32, 43, 0.48);
}

.apps-launcher-sheet[open] {
    display: flex;
    flex-direction: column;
}

.apps-launcher-sheet-bar {
    display: flex;
    justify-content: flex-end;
    padding: 0.55rem 0.7rem 0;
}

.apps-launcher-sheet-close {
    border: 0;
    background: transparent;
    color: var(--kld-blue);
    font: inherit;
    font-weight: 600;
    padding: 0.4rem 0.6rem;
    cursor: pointer;
}

.apps-launcher-sheet-close:focus-visible {
    outline: 2px solid var(--kld-blue);
    outline-offset: 2px;
}

.apps-launcher-sheet-body {
    overflow: auto;
    padding: 0.15rem 1.15rem 1.25rem;
}

.app-summary {
    margin: 1.35rem 0 0;
    color: var(--kld-muted);
    font-size: 0.98rem;
    line-height: 1.55;
}

.app-related {
    margin: 0.7rem 0 0;
    color: var(--kld-muted);
    font-size: 0.88rem;
    line-height: 1.45;
}

.app-related a {
    color: var(--kld-rust-dark);
    font-weight: 600;
    text-decoration: none;
}

.app-related a:hover {
    color: var(--kld-blue);
    text-decoration: underline;
}

.app-related span {
    margin: 0 0.35rem;
    color: var(--kld-line);
}

/* Slim site bar: navbar, and All The Apps on an app page. No hero image. */
.kld-appbar {
    background-color: #111827;
    background-image: none;
    color: #ffffff;
}

.kld-appbar-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.35rem 0.75rem;
}

.kld-appbar-row > nav {
    flex: 1 1 16rem;
    min-width: 0;
}

.kld-appbar .kld-hero-actions {
    margin: 0;
    padding: 0 1rem 0.65rem;
}

@media (min-width: 860px) {
    .kld-appbar .kld-hero-actions {
        padding: 0 1.25rem 0 0;
    }
}

.kld-appbar .kld-button {
    width: auto;
    min-height: 2.2rem;
    padding: 0.4rem 0.8rem;
    font-size: 0.92rem;
}

.app-frame {
    box-sizing: border-box;
    width: 100%;
    margin-top: 1.5rem;
    border: 1px solid var(--kld-line);
    border-radius: 16px;
    background: var(--kld-paper);
    box-shadow: 0 16px 40px rgba(23, 32, 43, 0.08);
    overflow: hidden;
}

.app-frame-heading {
    padding: 0.95rem 1.1rem 0.15rem;
}

.app-frame-title {
    margin: 0;
    color: var(--kld-ink);
    font-family: Inter, Arial, Helvetica, sans-serif;
    font-size: 1.55rem;
    font-weight: 600;
    line-height: 1.2;
}

.app-frame-lede {
    margin: 0.4rem 0 0;
    color: var(--kld-muted);
    font-size: 0.98rem;
    line-height: 1.5;
}

.app-frame-lede a {
    color: var(--kld-rust-dark);
    font-weight: 600;
    text-decoration: none;
}

.app-frame-lede a:hover {
    color: var(--kld-blue);
    text-decoration: underline;
}

.app-frame-toolbar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.7rem 0.9rem;
    border-bottom: 1px solid var(--kld-line);
    background: var(--kld-wash);
}

h1.app-frame-name {
    font-size: 1.05rem;
    font-weight: 600;
}

h1.app-frame-name a {
    color: inherit;
    text-decoration: none;
}

.app-frame-icon {
    flex: none;
    width: 36px;
    height: 36px;
    border-radius: 9px;
    object-fit: cover;
    background: var(--kld-paper);
}

.app-frame-identity {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    min-width: 0;
}

.app-frame-beta {
    flex: none;
    padding: 0.12rem 0.45rem;
    border: 1px solid var(--kld-blue);
    border-radius: 999px;
    background: var(--kld-paper);
    color: var(--kld-blue);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    line-height: 1.3;
}

.app-frame-name {
    margin: 0;
    color: var(--kld-ink);
    font-size: 1.05rem;
    font-weight: 600;
    line-height: 1.25;
    text-decoration: none;
}

a.app-frame-name:hover {
    color: var(--kld-rust-dark);
    text-decoration: none;
}

.app-frame-controls {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 0.4rem;
    margin-left: auto;
}

.app-frame-controls .kld-button {
    width: auto;
    min-height: 2.2rem;
    padding: 0.4rem 0.75rem;
    border: 1px solid var(--kld-line);
    border-radius: 6px;
    background: var(--kld-paper);
    color: var(--kld-ink);
    font-size: 0.92rem;
}

.app-frame-controls .kld-button:hover {
    border-color: var(--kld-ink);
    background: var(--kld-paper);
    color: var(--kld-ink);
}

.app-frame-body {
    padding: 1rem 1.1rem 1.25rem;
    overflow-x: auto;
}

.app-frame-body > :first-child {
    margin-top: 0;
}

.app-feedback-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin: 2.5rem 0 1rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--kld-sage);
}

.app-feedback-section .app-feedback-toggle {
    font-size: 0.92rem;
}

.app-feedback-form {
    box-sizing: border-box;
    width: 100%;
    max-width: 480px;
    margin-top: 1rem;
    padding: 1.25rem;
    border: 1px solid var(--kld-sage);
    border-radius: 8px;
    background: var(--kld-wash);
}

.app-feedback-form-inner {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.app-feedback-label {
    margin-bottom: 0.25rem;
    color: var(--kld-ink);
    font-size: 0.92rem;
    font-weight: 600;
}

.app-feedback-message,
.app-feedback-email {
    box-sizing: border-box;
    width: 100%;
    padding: 0.65rem 0.75rem;
    border: 1px solid var(--kld-sage);
    border-radius: 4px;
    background: var(--kld-paper);
    color: var(--kld-ink);
    font-family: inherit;
    font-size: 0.95rem;
}

.app-feedback-message {
    min-height: 5rem;
    resize: vertical;
}

.app-feedback-message:focus,
.app-feedback-email:focus {
    border-color: var(--kld-rust);
    outline: none;
}

.app-feedback-honeypot {
    position: absolute;
    left: -9999px;
    opacity: 0;
    pointer-events: none;
}

.app-feedback-actions {
    display: flex;
    gap: 0.65rem;
    margin-top: 0.35rem;
}

.app-feedback-actions .kld-button {
    width: auto;
    min-width: 5.5rem;
}

.app-feedback-actions .kld-button-secondary {
    border: 1px solid var(--kld-line);
    background: var(--kld-paper);
    color: var(--kld-ink);
}

.app-feedback-actions .kld-button-secondary:hover {
    border-color: var(--kld-ink);
    background: var(--kld-wash);
    color: var(--kld-ink);
}

.app-feedback-status {
    margin: 0.5rem 0 0;
    color: var(--kld-muted);
    font-size: 0.92rem;
}

.app-feedback-success {
    color: #1a7f37;
}

.app-feedback-error {
    color: #cf222e;
}
