/* The theme selector: the editor's Themes tab and the demo sign-up use the same cards and preview.
   Colours come from --ep-* tokens (editor-theme.css in the editor, the sign-up sets its own). */

/* 4j. Themes tab --------------------------------------------------------- */
/* Markup: partials/workspace.php (#themes). Behaviour: js/editor-settings.js.
   The preview, preset cards and status dots read --tp-* colours set by JS. */
.ep-themes {
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 12px var(--ep-panel-pad) 20px;
    color: var(--ep-text);
    font-size: 13px;
}

/* Current theme */
.ep-theme-current {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    padding: 9px 10px;
    border: 1px solid var(--ep-border);
    border-radius: var(--ep-panel-radius);
    background: var(--ep-surface-2);
}
.ep-theme-current-dots { display: inline-flex; flex: 0 0 auto; }
.ep-theme-current-dots i {
    width: 16px;
    height: 16px;
    margin-left: -5px;
    border: 2px solid var(--ep-surface);
    border-radius: 50%;
    background: var(--ep-border);
}
.ep-theme-current-dots i:first-child { margin-left: 0; }
.ep-theme-current-text { display: flex; flex: 1 1 auto; flex-direction: column; min-width: 0; line-height: 1.25; }
.ep-theme-current-text small { color: var(--ep-muted); font-size: 11px; }
.ep-theme-current-text strong { overflow: hidden; color: var(--ep-ink); font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.ep-theme-undo {
    flex: 0 0 auto;
    height: 28px;
    padding: 0 10px;
    border: 1px solid var(--ep-panel-line);
    border-radius: var(--ep-panel-radius);
    background: var(--ep-surface);
    color: var(--ep-primary-dark);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
}
.ep-theme-undo:hover { border-color: var(--ep-accent); background: var(--ep-primary-50); }
.ep-theme-undo[hidden] { display: none; }

/* Sections */
.ep-theme-section {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding-top: 14px;
    border-top: 1px solid var(--ep-border);
}
.ep-theme-current + .ep-theme-section { padding-top: 0; border-top: 0; }
.ep-theme-head { display: flex; flex-direction: column; gap: 3px; }
.ep-theme-head--row { flex-direction: row; align-items: center; justify-content: space-between; }
.ep-theme-title {
    margin: 0;
    color: var(--ep-ink);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.06em;
    line-height: 1.3;
    text-transform: uppercase;
}
.ep-theme-title .fas { margin-right: 4px; color: var(--ep-primary); }
.ep-theme-sub { margin: 0; color: var(--ep-muted); font-size: 12px; line-height: 1.45; }
.ep-theme-count {
    min-width: 22px;
    padding: 1px 7px;
    border-radius: 999px;
    background: var(--ep-primary-50);
    color: var(--ep-primary-dark);
    font-size: 11px;
    font-weight: 700;
    text-align: center;
}
.ep-theme-count:empty { display: none; }

/* Colour picker row: swatch + hex box + "use site colour" */
.ep-theme-picker { display: flex; align-items: stretch; gap: 8px; min-width: 0; }
.ep-theme-swatch {
    position: relative;
    flex: 0 0 auto;
    width: 40px;
    height: 36px;
    margin: 0;
    overflow: hidden;
    border: 1px solid var(--ep-panel-line);
    border-radius: var(--ep-panel-radius);
    cursor: pointer;
}
.ep-theme-swatch input[type="color"] {
    position: absolute;
    top: -8px;
    left: -8px;
    width: calc(100% + 16px);
    height: calc(100% + 16px);
    padding: 0;
    border: 0;
    cursor: pointer;
}
.ep-theme-swatch:focus-within { box-shadow: var(--ep-focus); }
.ep-theme-hex {
    display: flex;
    flex: 1 1 auto;
    align-items: center;
    min-width: 0;
    height: 36px;
    padding: 0 10px;
    border: 1px solid var(--ep-panel-line);
    border-radius: var(--ep-panel-radius);
    background: var(--ep-surface);
    color: var(--ep-muted);
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.ep-theme-hex:focus-within { border-color: var(--ep-accent); box-shadow: var(--ep-focus); }
.ep-theme-hex input {
    flex: 1 1 auto;
    width: 100%;
    min-width: 0;
    margin-left: 2px;
    padding: 0;
    border: 0;
    outline: 0;
    background: transparent;
    color: var(--ep-ink);
    font: inherit;
    font-size: 13px;
    text-transform: uppercase;
}
.ep-theme-icon-btn {
    flex: 0 0 auto;
    width: 36px;
    height: 36px;
    border: 1px solid var(--ep-panel-line);
    border-radius: var(--ep-panel-radius);
    background: var(--ep-surface);
    color: var(--ep-primary);
    cursor: pointer;
}
.ep-theme-icon-btn:hover { border-color: var(--ep-accent); background: var(--ep-primary-50); }

/* Suggested colours */
.ep-theme-hues { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 5px; }
.ep-theme-hue {
    aspect-ratio: 1 / 1;
    width: 100%;
    min-width: 0 !important;
    min-height: 0 !important;
    height: auto;
    padding: 0;
    border: 2px solid var(--ep-surface);
    border-radius: 50%;
    background: var(--hue);
    box-shadow: 0 0 0 1px var(--ep-border);
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.ep-theme-hue:hover { transform: scale(1.1); }
.ep-theme-hue.is-active { box-shadow: 0 0 0 2px var(--ep-ink); }
.ep-theme-hue:focus-visible { outline: 0; box-shadow: var(--ep-focus); }

/* Mini page drawn with a palette (--tp-* variables): live preview + preset
   thumbnails. Navbar (logo, links, button), hero (heading, text, two
   buttons), three cards and the footer, in the theme's real roles. */
.ep-mini {
    display: flex;
    flex-direction: column;
    width: 100%;
    aspect-ratio: 16 / 10;
    overflow: hidden;
    background: var(--tp-body, var(--ep-surface-2));
    transition: background-color 0.2s ease;
}
:where(.ep-mini) span, :where(.ep-mini) i { display: block; }
.ep-mini-nav {
    display: flex;
    flex: 0 0 14%;
    align-items: center;
    gap: 6%;
    padding: 0 6%;
    background: var(--tp-nav);
    box-shadow: 0 1px 0 rgba(15, 23, 42, 0.08);
}
.ep-mini-logo { flex: 0 0 auto; width: 6%; height: 42%; border-radius: 50%; background: var(--tp-on-nav); opacity: 0.9; }
.ep-mini-links { display: flex; flex: 1 1 auto; justify-content: flex-end; gap: 5%; height: 16%; }
.ep-mini-links i { width: 11%; border-radius: 2px; background: var(--tp-on-nav); opacity: 0.6; }
.ep-mini-cta { flex: 0 0 auto; width: 13%; height: 44%; border-radius: 999px; background: var(--tp-nav-cta, var(--tp-primary)); }
.ep-mini-hero { display: flex; flex: 1 1 auto; flex-direction: column; justify-content: center; gap: 7%; padding: 3% 6% 2%; }
.ep-mini-h { width: 56%; height: 14%; border-radius: 2px; background: var(--tp-heading); }
.ep-mini-p { width: 76%; height: 6%; border-radius: 2px; background: var(--tp-text); opacity: 0.3; }
.ep-mini-p--short { width: 52%; }
.ep-mini-btns { display: flex; gap: 4%; height: 17%; margin-top: 2%; }
.ep-mini-btn { width: 20%; border-radius: 3px; background: var(--tp-primary); }
.ep-mini-btn--ghost { width: 16%; border: 1px solid var(--tp-primary); background: transparent; opacity: 0.85; }
.ep-mini-cards { display: flex; flex: 0 0 25%; gap: 4%; padding: 0 6% 4%; }
.ep-mini-card {
    display: flex;
    flex: 1 1 0;
    flex-direction: column;
    justify-content: center;
    gap: 16%;
    padding: 0 8%;
    border: 1px solid rgba(127, 127, 127, 0.2);
    border-radius: 3px;
    background: var(--tp-card);
}
.ep-mini-card i { height: 13%; border-radius: 2px; background: var(--tp-on-card); opacity: 0.3; }
.ep-mini-card i:first-child { width: 62%; opacity: 0.75; }
.ep-mini-foot { display: flex; flex: 0 0 12%; align-items: center; gap: 5%; padding: 0 6%; background: var(--tp-footer); }
.ep-mini-foot i { width: 13%; height: 20%; border-radius: 2px; background: var(--tp-on-footer); opacity: 0.6; }
.ep-mini-foot i:last-child { margin-left: auto; width: 8%; }

/* Live preview frame */
.ep-theme-preview {
    border: 1px solid var(--ep-border);
    border-radius: var(--ep-panel-radius);
}

/* Palette chips */
.ep-theme-palette { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 4px; margin: 0; padding: 0; list-style: none; }
.ep-theme-palette li { display: flex; flex-direction: column; align-items: center; gap: 3px; min-width: 0; }
.ep-theme-chip { width: 100%; height: 20px; border: 1px solid rgba(15, 23, 42, 0.12); border-radius: 3px; }
.ep-theme-palette small { max-width: 100%; overflow: hidden; color: var(--ep-muted); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }

/* Apply button */
#paraclete-builder .ep-theme-apply,
.ep-theme-apply {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    height: 40px;
    border: 0;
    border-radius: var(--ep-panel-radius);
    background: var(--ep-primary);
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    box-shadow: var(--ep-shadow-sm);
}
#paraclete-builder .ep-theme-apply:hover,
.ep-theme-apply:hover { background: var(--ep-primary-hover); color: #fff; }
.ep-theme-apply:focus-visible { box-shadow: var(--ep-focus); outline: 0; }

/* Busy state (button or preset card being applied) */
.ep-theme-apply.is-busy .fas,
.ep-theme-card.is-busy .ep-tc-check .fas { animation: ep-theme-spin 0.8s linear infinite; }
.ep-theme-apply.is-busy .fas::before { content: "\f110"; }
@keyframes ep-theme-spin { to { transform: rotate(360deg); } }

/* Preset grid */
.ep-theme-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 10px; }
.ep-theme-card {
    position: relative;
    display: flex;
    flex-direction: column;
    min-width: 0;
    padding: 0;
    overflow: hidden;
    border: 1px solid var(--ep-border);
    border-radius: var(--ep-panel-radius);
    background: var(--ep-surface);
    color: var(--ep-text);
    text-align: left;
    cursor: pointer;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}
.ep-theme-card:hover { border-color: var(--ep-accent); box-shadow: 0 6px 16px rgba(15, 23, 42, 0.1); transform: translateY(-1px); }
.ep-theme-card:focus-visible { outline: 0; box-shadow: var(--ep-focus); }
.ep-theme-card.is-active { border-color: var(--ep-primary); box-shadow: 0 0 0 2px var(--ep-primary); }
.ep-tc-preview {
    display: flex;
    flex-direction: column;
    aspect-ratio: 16 / 10;
    background: var(--tp-body, var(--ep-surface-2));
}
.ep-theme-card .ep-tc-preview.ep-mini { border-bottom: 0; }
.ep-theme-card:hover .ep-mini-btn:not(.ep-mini-btn--ghost) { filter: brightness(0.92); }
/* Name row: theme name + main / navbar / footer colour dots */
.ep-tc-name {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
    padding: 7px 9px;
    border-top: 1px solid var(--ep-border);
    color: var(--ep-ink);
    font-size: 12px;
    font-weight: 600;
}
.ep-tc-label { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ep-tc-dots { display: inline-flex; flex: 0 0 auto; }
.ep-tc-dots i {
    width: 10px;
    height: 10px;
    margin-left: -3px;
    border: 1.5px solid var(--ep-surface);
    border-radius: 50%;
    background: var(--tp-primary);
    box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.12);
}
.ep-tc-dots i:nth-child(2) { background: var(--tp-nav); }
.ep-tc-dots i:nth-child(3) { background: var(--tp-footer); }
.ep-tc-check {
    position: absolute;
    top: 6px;
    right: 6px;
    display: none;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--ep-primary);
    color: #fff;
    font-size: 11px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}
.ep-theme-card.is-active .ep-tc-check,
.ep-theme-card.is-busy .ep-tc-check { display: inline-flex; }
.ep-theme-card.is-busy .ep-tc-check .fas::before { content: "\f110"; }

/* Loading skeleton / empty / error */
.ep-theme-card.is-loading { cursor: default; pointer-events: none; }
.ep-theme-card.is-loading .ep-tc-preview,
.ep-theme-card.is-loading .ep-tc-name {
    background: linear-gradient(90deg, var(--ep-surface-2) 25%, var(--ep-border) 50%, var(--ep-surface-2) 75%);
    background-size: 200% 100%;
    animation: ep-theme-shimmer 1.2s ease-in-out infinite;
}
@keyframes ep-theme-shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.ep-theme-empty {
    grid-column: 1 / -1;
    margin: 0;
    padding: 18px 12px;
    border: 1px dashed var(--ep-panel-line);
    border-radius: var(--ep-panel-radius);
    color: var(--ep-muted);
    font-size: 12px;
    text-align: center;
}
.ep-theme-retry {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 8px;
    padding: 5px 10px;
    border: 1px solid var(--ep-panel-line);
    border-radius: var(--ep-panel-radius);
    background: var(--ep-surface);
    color: var(--ep-primary-dark);
    font-weight: 600;
    cursor: pointer;
}

.ep-theme-note {
    display: flex;
    gap: 8px;
    margin: 0;
    padding: 10px;
    border-radius: var(--ep-panel-radius);
    background: var(--ep-primary-50);
    color: var(--ep-primary-dark);
    font-size: 12px;
    line-height: 1.45;
}
.ep-theme-note .fas { margin-top: 2px; }

/* Narrow side panel / phones */
@media (max-width: 767.98px) {
    .ep-theme-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
    .ep-theme-hues { grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; }
    .ep-theme-swatch, .ep-theme-hex, .ep-theme-icon-btn { height: 44px; }
    .ep-theme-swatch, .ep-theme-icon-btn { width: 44px; }
    .ep-theme-hex input { font-size: 16px; }    /* no iOS zoom */
    .ep-theme-apply { height: 46px; }
}
@media (max-width: 360px) {
    .ep-theme-palette { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (prefers-reduced-motion: reduce) {
    .ep-theme-card, .ep-theme-hue, #paraclete-builder .components-list li[data-type].has-icon { transition: none; }
    .ep-theme-card:hover, .ep-theme-hue:hover, #paraclete-builder .components-list li[data-type].has-icon:hover { transform: none; }
    .ep-theme-card.is-loading .ep-tc-preview, .ep-theme-card.is-loading .ep-tc-name { animation: none; }
}


/* ------------------------------------------------------------------------- */
