/* ─── The Projects page, the project dialog and the template dialog ───
   (app/Projects.tsx, app/ProjectDialog.tsx, app/Templates.tsx)
   The page uses the Settings page's shell (.sp in settings_page.css) and the landing page's project
   cards (base.css); what is here is only what those don't have. */

/* Where the React app draws: the box itself takes no part in the layout */
.mount { display: contents; }

/* The landing page's row of two buttons, and its cards' details line */
.projects-actions { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }
.project-btn-tall { min-height: 44px; padding: 0 1rem; border-radius: 12px; }
.project-open .project-what { color: var(--text-muted); }

/* The page: in place of the landing page (body.pp-open), under the same top bar, the small name shown */
.pp { width: 100%; max-width: 1100px; display: grid; align-content: start; gap: 1.5rem; z-index: 1; }
.pp.hidden { display: none; }
body.pp-open .container, body.pp-open .site-footer { display: none; }
body.pp-open .site-brand { clip-path: inset(0); }
.pp-head { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.pp-head h2 { font-family: 'Outfit', sans-serif; font-size: 1.6rem; font-weight: 800; }
.pp-head p { color: var(--text-secondary); font-size: 0.92rem; }
.pp-head .project-btn { display: inline-flex; align-items: center; gap: 0.4rem; }
.pp-body { display: grid; align-content: start; gap: 2.5rem; min-width: 0; }
/* Its two parts are the landing page's cards (css/base.css) */
.pp .sp-card { padding: 2rem; border: 1px solid var(--card-border); border-radius: 16px; background: var(--card-bg); box-shadow: var(--card-shadow); }
.pp .sp-btn { border-radius: 8px; box-shadow: var(--card-btn-shadow); }
.pp-section { display: grid; gap: 1rem; min-width: 0; }
.pp-section-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.pp-section-head h3 { font-family: 'Outfit', sans-serif; font-size: 1.15rem; font-weight: 800; }
.pp-list:empty::after { content: 'No projects yet. Start one with New project, or from a template below.'; color: var(--text-secondary); font-size: 0.9rem; }

/* Templates: a kind at a time, each folding away; a card per template */
.pp-templates { display: grid; gap: 0.6rem; }
.pp-kind { border: 1px solid var(--border-color); border-radius: 12px; background: var(--card-quiet); }
.pp-kind summary { display: flex; align-items: center; gap: 0.6rem; min-height: 46px; padding: 0 1rem; border-radius: 14px; cursor: pointer; list-style: none; }
.pp-kind summary::-webkit-details-marker { display: none; }
.pp-kind summary::before { content: ''; flex: none; width: 7px; height: 7px; border-right: 2px solid var(--text-secondary); border-bottom: 2px solid var(--text-secondary); transform: rotate(-45deg); transition: transform 0.15s; }
.pp-kind[open] summary::before { transform: rotate(45deg); }
.pp-kind summary:focus-visible { outline: 2px solid var(--brand-cyan); outline-offset: 2px; }
.pp-kind summary strong { flex: 1; font-weight: 700; }
.pp-kind summary em { color: var(--text-muted); font-size: 0.82rem; font-style: normal; }
.pp-kind-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 0.8rem; padding: 0.2rem 1rem 1rem; }
@media (prefers-reduced-motion: reduce) { .pp-kind summary::before { transition: none; } }
.pp-template {
    display: grid;
    gap: 0.25rem;
    align-content: start;
    min-width: 0;
    padding: 0.9rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    background: var(--card-bg);
    box-shadow: var(--card-btn-shadow);
    color: var(--text-primary);
    font: inherit;
    text-align: left;
    cursor: pointer;
    transition: border-color 0.15s, transform 0.1s;
}
.pp-template:hover, .pp-template:focus-visible { border-color: var(--border-hover); outline: none; }
.pp-template:active { transform: scale(0.98); }
.pp-template strong { font-weight: 700; overflow-wrap: anywhere; }
.pp-template span { color: var(--text-secondary); font-size: 0.82rem; }

/* The dialogs: over the page and the Projects page, under the shared question dialog */
.pd {
    position: fixed;
    inset: 0;
    z-index: 1200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: rgba(0, 0, 0, 0.55);
}
.pd.hidden { display: none; }
.pd-card {
    display: flex;
    flex-direction: column;
    width: min(680px, 100%);
    max-height: calc(100vh - 2rem);
    box-sizing: border-box;
    border: 1px solid var(--border-color);
    border-radius: 18px;
    background: var(--bg-primary);
    box-shadow: var(--neo-float);
    color: var(--text-primary);
    overflow: hidden;
}
.pd-head { display: flex; align-items: start; justify-content: space-between; gap: 1rem; padding: 1.2rem 1.4rem 0.9rem; border-bottom: 1px solid var(--border-color); }
.pd-head h2 { font-family: 'Outfit', sans-serif; font-size: 1.25rem; font-weight: 800; }
.pd-head p { color: var(--text-secondary); font-size: 0.88rem; }
.pd-body { flex: 1; min-height: 0; overflow-y: auto; scrollbar-width: thin; display: grid; gap: 1.1rem; padding: 1.1rem 1.4rem; }
.pd-section { display: grid; gap: 0.8rem; min-width: 0; padding: 0.9rem 1rem 1rem; border: 1px solid var(--border-color); border-radius: 14px; }
.pd-section legend { padding: 0 0.4rem; color: var(--text-secondary); font-size: 0.8rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; }
.pd-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.9rem; }
.pd-grid .pd-full { grid-column: 1 / -1; }
.pd .sp-field { min-width: 0; align-content: start; }
.pd .sp-field small, .pd-locked p, .pd-list li { color: var(--text-muted); font-size: 0.8rem; line-height: 1.4; }
.pd .sp-field i { font-style: normal; text-transform: none; letter-spacing: 0; font-weight: 400; color: var(--text-muted); }
.pd .sp-field.hidden { display: none; }
.pd-unit { display: flex; align-items: center; gap: 0.5rem; }
.pd-unit em { flex: none; color: var(--text-secondary); font-size: 0.85rem; font-style: normal; }
.pd-badge { margin-left: 0.4rem; padding: 0.1rem 0.5rem; border-radius: 999px; background: var(--bg-deep); color: var(--text-muted); font-size: 0.7rem; letter-spacing: 0.04em; }
.pd-list { display: grid; gap: 0.3rem; padding-left: 1.1rem; }
.pd-foot { display: flex; align-items: center; justify-content: flex-end; gap: 0.6rem; flex-wrap: wrap; padding: 0.9rem 1.4rem; border-top: 1px solid var(--border-color); }
.pd-error { flex: 1; min-width: 0; color: #ef4444; font-size: 0.85rem; }
.pd-foot .sp-btn { min-width: 7rem; }

/* Sharing (app/ShareDialog.tsx): an invite row, general access, the people, the link */
.sh-card { width: min(560px, 100%); }
.sh-card .sp-icon-btn { flex: none; width: 36px; height: 36px; min-width: 36px; }
.sh-invite { display: flex; gap: 0.6rem; padding: 1.1rem 1.4rem 0; }
.sh-invite-field { flex: 1; min-width: 0; display: flex; align-items: center; gap: 0.3rem; padding: 0.25rem 0.3rem 0.25rem 0.9rem; border: 1px solid var(--card-line); border-radius: 12px; background: var(--card-quiet); }
.sh-invite-field:focus-within { border-color: var(--border-hover); }
.sh-invite-field input { flex: 1; min-width: 0; height: 40px; border: 0; background: none; color: var(--text-primary); font: inherit; outline: none; }
.sh-level { height: 36px; padding: 0 0.5rem; border: 1px solid var(--card-border); border-radius: 9px; background: var(--card-bg); color: var(--text-primary); font: inherit; font-size: 0.88rem; cursor: pointer; }
.sh-level:focus-visible, .sh-remove:focus-visible { outline: 2px solid var(--brand-cyan); outline-offset: 2px; }
.sp-btn.sh-dark { min-width: 5.5rem; min-height: 48px; border-color: transparent; background: var(--text-primary); color: var(--bg-primary); }
.sh-error { min-height: 1.2rem; padding: 0.35rem 1.4rem 0; }
.sh-body { gap: 1.2rem; padding-top: 0.6rem; }
.sh-body section { display: grid; gap: 0.2rem; }
.sh-body section + section { padding-top: 1.1rem; border-top: 1px solid var(--border-color); }
.sh-label { margin-bottom: 0.3rem; color: var(--text-muted); font-size: 0.85rem; font-weight: 500; }
.sh-list { list-style: none; display: grid; gap: 0.2rem; }
.sh-row { display: flex; align-items: center; gap: 0.8rem; min-height: 56px; }
.sh-tile, .sh-face { flex: none; display: grid; place-items: center; width: 40px; height: 40px; color: var(--text-primary); font-weight: 700; overflow: hidden; }
.sh-tile { border: 1px solid var(--card-border); border-radius: 10px; background: var(--card-bg); box-shadow: var(--card-btn-shadow); }
.sh-face { border-radius: 50%; background: var(--bg-deep); }
.sh-face img { width: 100%; height: 100%; object-fit: cover; }
.sh-who { flex: 1; min-width: 0; display: grid; }
.sh-who strong { font-weight: 600; overflow-wrap: anywhere; }
.sh-who span { color: var(--text-secondary); font-size: 0.85rem; overflow-wrap: anywhere; }
.sh-owner { color: var(--text-secondary); font-size: 0.9rem; padding-right: 0.4rem; }
.sh-remove { flex: none; width: 36px; height: 36px; border: 0; border-radius: 9px; background: none; color: var(--text-muted); font-size: 1.2rem; line-height: 1; cursor: pointer; }
.sh-remove:hover { background: rgba(239, 68, 68, 0.12); color: #ef4444; }
.sh-switch { flex: none; display: grid; place-items: center; min-width: 44px; min-height: 44px; cursor: pointer; }
.sh-switch input { appearance: none; width: 38px; height: 22px; margin: 0; border: 1px solid var(--card-line); border-radius: 999px; background: var(--bg-deep); position: relative; cursor: pointer; transition: background 0.15s, border-color 0.15s; }
.sh-switch input::after { content: ''; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: var(--text-secondary); transition: transform 0.15s, background 0.15s; }
.sh-switch input:checked { background: rgba(var(--brand-orange-rgb), 0.25); border-color: var(--brand-orange); }
.sh-switch input:checked::after { transform: translateX(16px); background: var(--brand-orange); }
.sh-switch input:focus-visible { outline: 2px solid var(--brand-cyan); outline-offset: 2px; }
.sh-foot { justify-content: space-between; background: var(--card-quiet); }
.sh-address { flex: 1; min-width: 0; color: var(--text-secondary); font-size: 0.9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sh-foot .sp-btn { display: inline-flex; align-items: center; gap: 0.5rem; }
.sp-borrowed { border-color: rgba(var(--brand-orange-rgb), 0.5); }
@media (prefers-reduced-motion: reduce) { .sh-switch input, .sh-switch input::after { transition: none; } }

@media (max-width: 480px) {
    .sh-invite { flex-direction: column; padding-left: 1rem; padding-right: 1rem; }
    .sh-error { padding-left: 1rem; padding-right: 1rem; }
    .sh-row { flex-wrap: wrap; row-gap: 0.2rem; }
    .sh-who { flex-basis: calc(100% - 40px - 0.8rem); }
    .sh-foot .sh-address { flex-basis: 100%; }
    .pd { padding: 0.5rem; }
    .pd-card { max-height: calc(100vh - 1rem); }
    .pd-head, .pd-body, .pd-foot { padding-left: 1rem; padding-right: 1rem; }
    .pd-grid { grid-template-columns: minmax(0, 1fr); }
    .pd-foot .sp-btn { flex: 1; }
    .projects-actions { width: 100%; }
    .projects-actions > * { flex: 1; }
}
