/* ============================================================================
   ui-modes.css — Simple/Advanced mode gating + topbar toggle + chooser modal
   ----------------------------------------------------------------------------
   PLAN 2 (2DG UI rework). Companion to assets/js/ui-mode.js. Uses app.css
   design tokens. Dark theme overrides live at the bottom (body.narrorift-mode).
   Gating contract (hidden inputs STAY in the DOM — payloads unaffected):
     [data-adv]          advanced-only  → hidden in Simple
     [data-simple-only]  simple-only    → hidden in Advanced
     [data-mode-copy]    copy variants  → only the matching mode's span shows
   ============================================================================ */

html[data-ui-mode="simple"] [data-adv] { display: none !important; }
html[data-ui-mode="advanced"] [data-simple-only] { display: none !important; }
html[data-ui-mode="simple"] [data-mode-copy="advanced"] { display: none !important; }
html[data-ui-mode="advanced"] [data-mode-copy="simple"] { display: none !important; }

/* ── "More options" disclosure (progressive form fields) ──────────────────── */
details.form-more {
    border: 1px dashed var(--line);
    border-radius: var(--radius);
    padding: 0 12px;
    margin: 4px 0;
}
details.form-more > summary {
    cursor: pointer;
    padding: 9px 0;
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--muted);
    list-style: none;
    user-select: none;
}
details.form-more > summary::before { content: "▸ "; }
details.form-more[open] > summary::before { content: "▾ "; }
details.form-more > summary::-webkit-details-marker { display: none; }
details.form-more[open] { padding-bottom: 10px; }

/* ── Topbar mode toggle (header rework: sliding thumb) ─────────────────────── */
.ui-mode-toggle {
    position: relative;
    display: inline-grid;
    grid-template-columns: 1fr 1fr;
    padding: 3px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.10);
    border: 1px solid rgba(255, 255, 255, 0.16);
}
/* The white pill that slides between the two buttons. Position is driven by
   html[data-ui-mode] (set pre-paint in index.php) so there is no flash before
   ui-mode.js runs; the buttons are equal-width columns so a 100% translate
   lands exactly on the second one. */
.ui-mode-thumb {
    position: absolute;
    top: 3px;
    left: 3px;
    width: calc(50% - 3px);
    height: calc(100% - 6px);
    border-radius: 999px;
    background: #fff;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
    pointer-events: none;
    transition: transform 0.22s cubic-bezier(0.4, 0, 0.2, 1);
}
html[data-ui-mode="advanced"] .ui-mode-thumb {
    transform: translateX(100%);
}
.ui-mode-btn {
    position: relative;
    z-index: 1;
    padding: 5px 14px;
    border: none;
    border-radius: 999px;
    background: transparent;
    color: rgba(255, 255, 255, 0.72);
    font: inherit;
    font-size: 0.78rem;
    font-weight: 700;
    cursor: pointer;
    transition: color 0.18s ease;
}
.ui-mode-btn:hover { color: #fff; }
/* Active label colour keyed off both the root attribute (pre-JS) and the
   .is-active class ui-mode.js toggles (post-JS) so it is always correct. */
html[data-ui-mode="simple"] .ui-mode-btn[data-ui-mode-btn="simple"],
html[data-ui-mode="advanced"] .ui-mode-btn[data-ui-mode-btn="advanced"],
.ui-mode-btn.is-active {
    color: var(--charcoal);
}

/* ── Help button + menu ───────────────────────────────────────────────────── */
#studio-help-button { position: relative; }
#studio-help-button.is-nudging::after {
    content: "";
    position: absolute;
    top: 4px; right: 4px;
    width: 8px; height: 8px;
    border-radius: 50%;
    background: var(--amber);
    animation: ui-help-pulse 1.6s ease-in-out infinite;
}
@keyframes ui-help-pulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.5); opacity: 0.55; }
}
/* ── First-run mode chooser ───────────────────────────────────────────────── */
#ui-mode-chooser {
    position: fixed;
    inset: 0;
    z-index: 1500; /* dialog band — above modals (200), below toasts (9000) */
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(8, 11, 18, 0.62);
    backdrop-filter: blur(3px);
}
.ui-chooser-card {
    width: min(720px, 96vw);
    border-radius: 16px;
    background: var(--surface);
    box-shadow: var(--shadow);
    padding: 26px;
}
.ui-chooser-card > h2 { margin: 0 0 4px; }
.ui-chooser-card > p { margin: 0 0 18px; color: var(--muted); font-size: 0.92rem; }
.ui-chooser-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}
.ui-chooser-option {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 18px;
    border: 2px solid var(--line);
    border-radius: 14px;
    background: var(--paper);
    color: var(--ink);
    font: inherit;
    text-align: left;
    cursor: pointer;
    transition: border-color 0.18s ease, transform 0.18s ease;
}
.ui-chooser-option:hover { border-color: var(--blue); transform: translateY(-2px); }
.ui-chooser-option.is-recommended { border-color: var(--accent); }
.ui-chooser-option .ui-chooser-badge {
    align-self: flex-start;
    padding: 2px 10px;
    border-radius: 999px;
    background: var(--accent);
    color: #fff;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}
.ui-chooser-option strong { font-size: 1.05rem; }
.ui-chooser-option span { font-size: 0.85rem; color: var(--muted); line-height: 1.5; }
.ui-chooser-foot {
    margin: 16px 0 0;
    font-size: 0.8rem;
    color: var(--muted);
    text-align: center;
}
@media (max-width: 640px) {
    .ui-chooser-grid { grid-template-columns: 1fr; }
}

/* Narrow desktop windows: compact the mode toggle. (The old .ui-desktop-notice
   banner was removed — phones never see this shell since the mobile studio
   ships its own mobile-shell.php, so the "needs a mouse" copy was dead.) */
@media (max-width: 720px) {
    .ui-mode-btn { padding: 5px 9px; }
}

/* ── Dark theme (narrorift-mode) overrides ────────────────────────────────── */
body.narrorift-mode .ui-chooser-card { background: #12172a; color: #e2e8f0; }
body.narrorift-mode .ui-chooser-card > p,
body.narrorift-mode .ui-chooser-option span,
body.narrorift-mode .ui-chooser-foot { color: #94a3b8; }
body.narrorift-mode .ui-chooser-option {
    background: #0b0f1c;
    border-color: rgba(255, 255, 255, 0.12);
    color: #e2e8f0;
}
body.narrorift-mode details.form-more { border-color: rgba(255, 255, 255, 0.14); }
body.narrorift-mode details.form-more > summary { color: #94a3b8; }

@media (prefers-reduced-motion: reduce) {
    .ui-mode-btn, .ui-chooser-option { transition: none; }
    #studio-help-button.is-nudging::after { animation: none; }
}

/* ── PLAN 2 Phase 2 components ─────────────────────────────────────────────── */

/* Simple-mode guided journey (Home, #simple-journey) */
.simple-journey { margin-bottom: 16px; }
.simple-journey-list { display: flex; flex-direction: column; gap: 8px; margin: 8px 0 12px; }
.simple-journey-step {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--paper);
    color: var(--ink);
    font: inherit;
    text-align: left;
    cursor: pointer;
    transition: border-color 0.15s ease, transform 0.15s ease;
}
.simple-journey-step:hover { border-color: var(--blue); transform: translateX(2px); }
.simple-journey-step.is-done { opacity: 0.72; }
.simple-journey-step.is-done .simple-journey-marker { background: var(--green); }
.simple-journey-marker {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px; height: 26px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    font-size: 0.8rem;
    font-weight: 700;
}
.simple-journey-copy { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.simple-journey-copy small { color: var(--muted); font-size: 0.8rem; line-height: 1.4; }
.simple-journey-next { width: 100%; }

/* Panel Studio pipeline stepper (#panel-studio-steps) */
.panel-studio-steps {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
    padding: 9px 12px;
    border: 1px dashed var(--line);
    border-radius: 10px;
    font-size: 0.8rem;
    color: var(--muted);
}
.panel-studio-step { display: inline-flex; align-items: center; gap: 6px; }
.panel-studio-step-dot {
    width: 9px; height: 9px;
    border-radius: 50%;
    background: var(--line);
}
.panel-studio-step.is-active { color: var(--ink); font-weight: 700; }
.panel-studio-step.is-active .panel-studio-step-dot {
    background: var(--accent);
    animation: panel-studio-pulse 1.1s ease-in-out infinite;
}
.panel-studio-step.is-done { color: var(--green); }
.panel-studio-step.is-done .panel-studio-step-dot { background: var(--green); }
.panel-studio-step-sep { flex: 0 0 14px; height: 1px; background: var(--line); }
@keyframes panel-studio-pulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.45); opacity: 0.6; }
}

/* Submit preflight (#submit-preflight) */
.submit-preflight { margin-bottom: 14px; }
.submit-preflight-list { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; }
.submit-preflight-row {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 9px 12px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--paper);
}
.submit-preflight-row.is-done { border-left: 3px solid var(--green); }
.submit-preflight-row.is-info { opacity: 0.85; }
.submit-preflight-row:not(.is-done):not(.is-info) { border-left: 3px solid var(--amber); }
.submit-preflight-mark { flex-shrink: 0; width: 18px; text-align: center; font-weight: 700; color: var(--green); }
.submit-preflight-row:not(.is-done) .submit-preflight-mark { color: var(--amber); }
.submit-preflight-copy { display: flex; flex-direction: column; gap: 1px; min-width: 0; flex: 1; }
.submit-preflight-copy small { color: var(--muted); font-size: 0.8rem; line-height: 1.4; }
.submit-preflight-fix { flex-shrink: 0; padding: 5px 12px; font-size: 0.78rem; }

/* Dark theme (narrorift-mode) for Phase-2 components */
body.narrorift-mode .simple-journey-step,
body.narrorift-mode .submit-preflight-row {
    background: rgba(255, 255, 255, 0.03);
    border-color: rgba(255, 255, 255, 0.12);
    color: #e2e8f0;
}
body.narrorift-mode .simple-journey-copy small,
body.narrorift-mode .submit-preflight-copy small,
body.narrorift-mode .panel-studio-steps { color: #94a3b8; }
body.narrorift-mode .panel-studio-steps { border-color: rgba(255, 255, 255, 0.14); }
body.narrorift-mode .panel-studio-step.is-active { color: #e2e8f0; }

@media (prefers-reduced-motion: reduce) {
    .simple-journey-step { transition: none; }
    .panel-studio-step.is-active .panel-studio-step-dot { animation: none; }
}
