/* Home page (/) styles: composer, job card, course preview. Loads after
   shell.css (which owns .main's flex/min-width/padding and the mobile
   `.app .main` override); the .main rule here only adds home's inner layout.
   `auth-spin` keyframes come from base.html's inline auth-spinner block. */

.main {
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
}
#viewHome, #viewJob { width: 100%; display: flex; flex-direction: column; align-items: center; }

.greeting {
    font-family: var(--display); font-weight: 500; font-size: 28px;
    color: var(--text); text-align: center;
}
.subtitle {
    font-size: 15px; color: var(--text-2); text-align: center;
    margin: 8px 0 24px; max-width: 560px;
}

/* ============ Composer ============ */
.composer {
    width: 700px; max-width: 100%;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 16px; padding: 16px 16px 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,.04);
    transition: border-color .15s, box-shadow .15s;
    position: relative;
}
.composer:focus-within { border-color: var(--text-3); }
.composer.dropping { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(14,107,98,.12); }
.composer.is-busy > :not(.composer-loading) { opacity: .35; }
.composer-loading {
    position: absolute; inset: 0; z-index: 2;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 10px; border-radius: inherit;
    color: var(--text-2); font-size: 13.5px; font-weight: 500;
}
.composer-loading[hidden] { display: none; }
.composer-loading i {
    width: 28px; height: 28px; border-radius: 50%;
    border: 3px solid var(--border); border-top-color: var(--accent);
    animation: auth-spin .8s linear infinite;
}
.composer textarea {
    /* Height is driven by content (autoGrowBrief in home.js), clamped to this
       range; no manual resize handle. Scrolls once it hits max-height. */
    width: 100%; min-height: 64px; max-height: 320px; resize: none;
    overflow-y: auto;
    border: none; font: inherit; color: var(--text);
    background: none;
}
.composer textarea:focus { outline-color: transparent; }
.composer textarea::placeholder { color: var(--text-3); }
.file-chip {
    display: flex; align-items: center; gap: 8px;
    background: var(--ivory); border: 1px solid var(--hairline);
    border-radius: 8px; padding: 6px 10px; margin: 8px 0 0;
    font-size: 13px; color: var(--text-2);
    width: fit-content; max-width: 100%;
}
.file-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-chip button {
    border: none; background: none; color: var(--text-3);
    font-size: 15px; cursor: pointer; line-height: 1; flex: none;
}
.file-chip button:hover { color: var(--error); }
.composer-error { font-size: 13px; color: var(--error); margin-top: 8px; }
/* wrap lets the pills reflow onto a second row on narrow screens
   instead of overflowing; a no-op on desktop where they fit in 700px. */
.pillrow { display: flex; align-items: flex-start; gap: 8px; margin-top: 12px; justify-content: space-between;}
.pillrow-block { display: flex; gap: 4px; flex-wrap: wrap; }
.pill {
    display: inline-flex; align-items: center; gap: 6px; height: 32px;
    border: 1px solid var(--border); border-radius: 999px;
    padding: 0 13px; font-size: 13px; color: var(--text-2);
    background: var(--surface); cursor: pointer; white-space: nowrap;
}
.pill:hover { border-color: var(--text-3); color: var(--text); }
.pill[aria-expanded="true"] { background: var(--sidebar); color: var(--text); }
.pill b { font-weight: 500; color: var(--text); }
.pill svg { flex: none; }
.pill .caret { color: var(--text-3); }
.pill:disabled { opacity: .55; cursor: default; }
.send {
    flex: none; width: 32px; height: 32px; border-radius: 6px;
    border: none; background: var(--accent); color: #fff;
    display: inline-flex; align-items: center; justify-content: center;
    cursor: pointer; transition: background .15s;
}
.send:hover { background: var(--accent-hover); }
.send:disabled { background: #CFCFCF; cursor: default; }

/* ============ Popovers (composer-specific; primitives in shell.css) ============ */
#langPop { width: 220px; }
#themePop { width: 320px; display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
#themePop[hidden] { display: none; }
/* Compact color swatch (chip + name), mirroring the course view's
   deck-theme-swatch. */
.theme-opt {
    display: flex; align-items: center; gap: 8px; min-width: 0;
    border: 1px solid var(--border); border-radius: 10px; padding: 7px 8px;
    background: none; cursor: pointer; text-align: left;
    transition: border-color .15s ease, box-shadow .15s ease;
}
.theme-opt:hover, .theme-opt:focus-visible { border-color: var(--accent); }
.theme-opt[aria-selected="true"] {
    border-color: var(--accent); box-shadow: 0 0 0 2px rgba(14, 107, 98, .18);
}
.theme-chip {
    flex: none; position: relative; overflow: hidden;
    width: 26px; height: 26px; border-radius: 8px;
    border: 1px solid rgba(17, 17, 17, .12);
    background: var(--chip-bg, #fff);   /* preset background */
}
.theme-chip::after {                    /* a diagonal wedge of the primary */
    content: ''; position: absolute; inset: 0;
    background: var(--chip-primary, #111);
    clip-path: polygon(100% 0, 100% 100%, 0 100%);
}
.theme-opt .tname {
    min-width: 0;   /* let the flex child shrink so the ellipsis engages */
    font-size: 12.5px; font-weight: 500; color: var(--text);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ============ Job card (State 2 / 2b) ============ */
.jobcard {
    width: 640px; max-width: 100%;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 16px; padding: 22px;
    box-shadow: 0 1px 3px rgba(0,0,0,.04);
}
.jobtitle { font-family: var(--display); font-weight: 500; font-size: 20px; color: var(--text); }
.jobmeta { font-size: 13px; color: var(--text-3); margin: 4px 0 16px; }
.phases { list-style: none; margin-bottom: 16px; }
.phases li {
    display: flex; align-items: center; gap: 10px;
    font-size: 13.5px; color: var(--text-3); padding: 3px 0;
}
.phases li .ph-mark {
    flex: none; width: 16px; height: 16px; border-radius: 50%;
    border: 1.5px solid var(--border);
    display: inline-flex; align-items: center; justify-content: center;
}
.phases li.done { color: var(--text-2); }
.phases li.done .ph-mark { border-color: var(--accent); background: var(--accent); }
.phases li.done .ph-mark svg { display: block; }
.phases li .ph-mark svg { display: none; }
.phases li.current { color: var(--text); font-weight: 500; }
.phases li.current .ph-mark { border-color: var(--accent); }
.phases li.current .ph-mark::after {
    content: ''; width: 6px; height: 6px; border-radius: 50%;
    background: var(--accent); animation: ph-pulse 1.2s ease-in-out infinite;
}
@keyframes ph-pulse { 50% { opacity: .35; } }
.jobmsg { font-size: 13px; color: var(--text-2); margin-bottom: 10px; min-height: 1.2em; }
.bar {
    height: 8px; border-radius: 4px; background: var(--ivory);
    overflow: hidden; margin-bottom: 6px;
}
.bar i {
    display: block; height: 100%; width: 0%;
    background: var(--accent); border-radius: 4px; transition: width .5s ease;
}
.jobpct { font-size: 12px; color: var(--text-3); }
.job-actions { display: flex; align-items: center; gap: 10px; margin-top: 16px; }
.job-cancel-error { font-size: 13px; color: var(--error); margin-top: 10px; }
.joberror p { font-size: 14px; color: var(--error); margin-bottom: 14px; }
.btn-secondary {
    display: inline-flex; align-items: center; gap: 7px; height: 36px;
    border-radius: 999px; padding: 0 18px; font-size: 13.5px;
    cursor: pointer; font-weight: 500;
}
.btn-secondary { background: var(--surface); border: 1px solid var(--border); color: var(--text-2); }
.btn-secondary:hover { border-color: var(--text-3); color: var(--text); }
.btn-danger-secondary { color: var(--error); }
.btn-danger-secondary:hover { border-color: var(--error); color: var(--error); background: rgba(179,38,30,.06); }
.btn-danger-secondary:disabled { opacity: .6; cursor: default; }

/* ============ Course view (State 3) ============ */
#viewCourse { width: 100%; height: 100%; flex: 1; display: flex; flex-direction: column; }
.courseview {
    /* max-width centered: today's breathing margin is the future editor rail. */
    width: 100%; max-width: 920px; margin: 0 auto; flex: 1;
    display: flex; flex-direction: column; min-height: 0;
}
/* Header above the preview: title/meta left, the shared action toolbar
   (.course-toolbar, styled in shell.css) right; wraps on narrow screens. */
.cv-head {
    display: flex; align-items: center; justify-content: space-between;
    gap: 10px 16px; flex-wrap: wrap; margin-bottom: 6px;
}
.cv-headings { min-width: 0; }
.cv-title { font-family: var(--display); font-weight: 500; font-size: 20px; color: var(--text); }
.cv-meta { font-size: 13px; color: var(--text-3); margin: 4px 0 0; display: flex; align-items: center; gap: 6px; }
.cv-frame {
    position: relative; flex: 1; min-height: 420px;
    border: 1px solid var(--border); border-radius: 12px;
    background: var(--surface); overflow: hidden;
}
.cv-frame iframe { width: 100%; height: 100%; border: none; display: block; }
/* Transparent click shield over the preview iframe (see index.html).
   Captures clicks so the sandboxed course can't be interacted with in-shell;
   clicking opens the full course instead (wired in openCourse → View action). */
.cv-overlay {
    position: absolute; inset: 0; margin: 0; padding: 0;
    border: none; background: transparent; cursor: pointer;
    appearance: none; -webkit-appearance: none;
}
.cv-overlay:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.cv-loading, .cv-error {
    position: absolute; inset: 0; display: flex; flex-direction: column;
    align-items: center; justify-content: center; gap: 12px;
    font-size: 14px; color: var(--text-3); background: var(--ivory);
}
.cv-loading i {
    width: 28px; height: 28px; border-radius: 50%;
    border: 3px solid var(--border); border-top-color: var(--accent);
    animation: auth-spin .8s linear infinite;
}
.cv-feedback { font-size: 13.5px; margin-bottom: 8px; min-height: 1.2em; }
.cv-feedback.ok { color: var(--ok); }
.cv-feedback.err { color: var(--error); }

/* ============ Custom color presets ============ */
/* Wrapped custom option: same grid cell as .theme-opt, tools overlaid at the
   right edge of the row and revealed on hover. The swatch keeps room clear. */
.theme-optwrap { position: relative; min-width: 0; }
.theme-optwrap .theme-opt { width: 100%; }
.theme-optwrap:hover .theme-opt, .theme-optwrap:focus-within .theme-opt {
    padding-right: 52px;   /* clear the two hover tools */
}
.theme-optwrap .opt-tools {
    position: absolute; top: 50%; right: 6px; transform: translateY(-50%);
    z-index: 2; display: none; gap: 4px;
}
.theme-optwrap:hover .opt-tools, .theme-optwrap:focus-within .opt-tools { display: flex; }
.opt-tool {
    width: 22px; height: 22px; border-radius: 6px; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    font-size: 11px; line-height: 1;
    background: var(--surface); border: 1px solid var(--border); color: var(--text-2);
}
.opt-tool:hover { border-color: var(--accent); color: var(--accent); }

/* "+ Add custom preset" — a full-width dashed card closing the swatch grid. */
.theme-add {
    grid-column: 1 / -1;
    border: 1px dashed var(--border); border-radius: 10px; padding: 8px;
    background: none; cursor: pointer;
    font-size: 12.5px; color: var(--text-2); text-align: center;
}
.theme-add:hover, .theme-add:focus-visible {
    border-color: var(--accent); color: var(--accent); background: var(--ivory);
}

/* Preset editor dialog. */
dialog.preset-dialog { max-width: 380px; width: calc(100vw - 32px); }
.preset-form { display: flex; flex-direction: column; gap: .6rem; margin-top: .75rem; }
.preset-row {
    display: flex; align-items: center; justify-content: space-between; gap: .75rem;
    font-size: .82rem; color: var(--text-2);
}
.preset-row input[type="text"] {
    flex: 1; max-width: 210px; padding: .4rem .6rem;
    border: 1px solid var(--border); border-radius: 8px;
    font-size: .82rem; color: var(--text); background: var(--surface);
}
.preset-row input[type="color"] {
    width: 44px; height: 30px; padding: 2px; cursor: pointer;
    border: 1px solid var(--border); border-radius: 8px; background: var(--surface);
}
#presetAdvanced summary {
    font-size: .78rem; color: var(--text-3); cursor: pointer;
    margin-bottom: .35rem;
}
#presetAdvanced .preset-row { margin: .3rem 0 0 .9rem; }
.preset-preview {
    border: 1px solid var(--hairline); border-radius: 10px;
    padding: 14px 16px; position: relative; overflow: hidden;
}
.preset-preview .pv-rail {
    position: absolute; left: 0; top: 0; bottom: 0; width: 4px; display: block;
}
.preset-preview .pv-title {
    font-family: var(--display); font-size: .95rem; font-weight: 600;
    color: #111111; margin-bottom: .2rem;
}
.preset-preview .pv-body { font-size: .75rem; color: #111111; opacity: .75; }
.preset-preview .pv-chips { display: flex; gap: .5rem; margin-top: .6rem; align-items: center; }
.preset-preview .pv-btn {
    color: #fff; font-size: .72rem; font-weight: 500;
    padding: .28rem .7rem; border-radius: 999px;
}
.preset-preview .pv-card {
    flex: 1; height: 26px; border-radius: 7px; border: 1px solid transparent;
}
.contrast-warn { font-size: .75rem; color: #9a6a00; }
.preset-err { font-size: .78rem; color: var(--error); }
