/* Description Generator , tool-specific styles.
 * Sibling of Title Tag Generator. Composes the same shared primitives
 * in code/assets/css/tools.css. Differences from TTG:
 *  - Pixel budgets are 920px / 680px (vs 600 / 480 for titles).
 *  - Description textareas autosize to fit ~3-4 lines (vs 1).
 *  - Char-count badge has good/warn/danger color states based on the
 *    120-160 char sweet spot (vs no states in TTG since titles
 *    don't have a sweet-spot floor).
 *
 * Same guard rails as TTG:
 *  - .mode-toggle pill: per-tool data-mode override.
 *  - [hidden] + display:flex/grid: per-panel override.
 *  - .results-region card-stack inner padding wrapper.
 */

/* ---- Mode toggle ---------------------------------------------------- */
.mode-toggle[data-mode="topic"]::before { transform: translateX(0); }
.mode-toggle[data-mode="url"]::before   { transform: translateX(100%); }

/* ---- Form layout ---------------------------------------------------- */
.dg-mode-body { margin-bottom: 18px; }
.dg-fullwidth { flex: 0 0 auto; width: 100%; box-sizing: border-box; }
.dg-mode-hint { color: var(--ink-500, #788196); font-weight: 400; font-size: 0.85em; margin-left: 8px; }

.dg-options-row {
    display: grid;
    grid-template-columns: 1.4fr 0.9fr 0.9fr;
    gap: 14px;
    margin-bottom: 14px;
}
@media (max-width: 720px) {
    .dg-options-row { grid-template-columns: 1fr; }
}

.dg-kw-preview {
    margin-top: 6px;
    font-size: 0.85em;
    color: var(--ink-700, #4a5568);
    padding: 6px 10px;
    background: var(--ink-50, #f4f6fa);
    border-radius: 6px;
    line-height: 1.5;
}
.dg-kw-preview[hidden] { display: none; }

.dg-styles-row { margin-bottom: 14px; }
.dg-styles-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-top: 8px;
}
@media (max-width: 560px) {
    .dg-styles-grid { grid-template-columns: repeat(2, 1fr); }
}
.dg-style-option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--ink-50, #f4f6fa);
    border-radius: 6px;
    border: 1px solid transparent;
    cursor: pointer;
    font-size: 0.92em;
    user-select: none;
    transition: border-color 120ms, background 120ms;
}
.dg-style-option:hover { border-color: var(--brand-200, #b4cdff); }
.dg-style-checkbox { margin: 0; }

.dg-serp-row {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 14px;
}
.dg-toggle {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    user-select: none;
    font-size: 0.92em;
}
.dg-toggle input { appearance: none; -webkit-appearance: none; width: 0; height: 0; opacity: 0; position: absolute; }
.dg-toggle-track {
    width: 34px; height: 18px;
    background: var(--ink-200, #cbd2dc);
    border-radius: 18px;
    position: relative;
    transition: background 150ms;
    flex: 0 0 34px;
}
.dg-toggle-track::after {
    content: '';
    position: absolute;
    width: 14px; height: 14px;
    border-radius: 50%;
    background: #fff;
    top: 2px; left: 2px;
    transition: transform 150ms;
}
.dg-toggle input:checked ~ .dg-toggle-track { background: var(--brand-500, #4076ff); }
.dg-toggle input:checked ~ .dg-toggle-track::after { transform: translateX(16px); }

.dg-serp-loc-control { position: relative; }
.dg-serp-loc-control[hidden] { display: none; }
.dg-loc-results {
    position: absolute;
    top: 100%; left: 0; right: 0;
    z-index: 30;
    background: #fff;
    border: 1px solid var(--ink-200, #cbd2dc);
    border-radius: 6px;
    margin: 4px 0 0;
    padding: 4px 0;
    max-height: 240px;
    overflow-y: auto;
    list-style: none;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.07);
}
.dg-loc-results[hidden] { display: none; }
.dg-loc-result {
    padding: 8px 12px;
    cursor: pointer;
    font-size: 0.9em;
}
.dg-loc-result:hover { background: var(--ink-50, #f4f6fa); }

.dg-submit-row { margin-top: 10px; }

/* ---- Quota chips ---------------------------------------------------- */
.dg-chips-row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}

/* ---- Progress region ------------------------------------------------ */
/* Loading bar between form and results; visible only during submit. The
 * shared `.progress-region` primitive in tools.css carries the box
 * chrome; per [[scroll-to-progress-on-submit]] every async (or sync-
 * with-spinner) submit MUST set scroll-margin-top so the smooth
 * scroll lands the region just below the page top instead of butting
 * up against it. */
.progress-region { scroll-margin-top: 16px; }

/* ---- Results region ------------------------------------------------- */
.results-region { scroll-margin-top: 16px; }
.dg-result-body { padding: 18px 22px 4px; }
.dg-result-body > *:last-child { margin-bottom: 18px; }

/* ---- Audited block (what we generated for) ------------------------- */
.dg-audited {
    padding: 14px 18px;
    background: var(--ink-50, #f4f6fa);
    border-left: 4px solid var(--brand-500, #4076ff);
    border-radius: 6px;
    margin-bottom: 20px;
}
.dg-audited[hidden] { display: none; }
.dg-audited-label {
    display: block;
    font-size: 0.72em;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--ink-500, #788196);
    font-weight: 600;
    margin-bottom: 4px;
}
.dg-audited-title {
    display: block;
    font-size: 1.05em;
    font-weight: 600;
    color: var(--ink-900, #1a202c);
    line-height: 1.4;
}
.dg-audited-url {
    display: block;
    font-size: 0.85em;
    color: var(--brand-700, #2b59e0);
    margin-top: 4px;
    word-break: break-all;
}
.dg-audited-url:hover { text-decoration: underline; }
.dg-audited-url[hidden] { display: none; }

/* ---- 2-column layout ----------------------------------------------- */
.dg-results-grid {
    display: grid;
    grid-template-columns: 1.4fr 0.85fr;
    gap: 20px;
}
@media (max-width: 880px) {
    .dg-results-grid { grid-template-columns: 1fr; }
}

.dg-cards-col, .dg-stats-col { min-width: 0; }

/* ---- Card -------------------------------------------------------- */
.dg-card {
    background: #fff;
    border: 1px solid var(--ink-200, #e4e8ef);
    border-radius: 8px;
    padding: 14px 16px;
    margin-bottom: 12px;
    transition: box-shadow 150ms;
}
.dg-card.is-regenerating { opacity: 0.6; }
.dg-card:hover { box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04); }

.dg-card-head {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 8px;
}

.dg-style-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.7em;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    background: var(--brand-50, #e6efff);
    color: var(--brand-700, #2b59e0);
}
.dg-style-badge-existing    { background: var(--ink-100, #e4e8ef); color: var(--ink-700, #4a5568); }
.dg-style-badge-benefit-led { background: #e7f6ec; color: #226c3a; }
.dg-style-badge-listicle    { background: #fff4e0; color: #8a5a00; }
.dg-style-badge-question    { background: #ecebff; color: #4639b9; }
.dg-style-badge-how-to      { background: #e4f2fc; color: #205a8c; }
.dg-style-badge-stat-led    { background: #fef4d9; color: #876200; }
.dg-style-badge-direct      { background: var(--ink-100, #e4e8ef); color: var(--ink-700, #4a5568); }

.dg-kw-pill {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.75em;
    font-weight: 600;
}
.dg-kw-pill-full    { background: #e7f6ec; color: #226c3a; }
.dg-kw-pill-partial { background: #fff4e0; color: #8a5a00; }
.dg-kw-pill-missing { background: #fff0f0; color: #b13c3c; }

.dg-card-text-wrap { margin-bottom: 12px; }
.dg-card-text {
    width: 100%;
    box-sizing: border-box;
    border: 1px solid var(--ink-200, #e4e8ef);
    border-radius: 6px;
    padding: 8px 12px;
    font-size: 0.96em;
    line-height: 1.55;
    resize: none;
    outline: none;
    color: var(--ink-900, #1a202c);
    background: var(--ink-50, #f8fafc);
    overflow: hidden;
    font-family: inherit;
    min-height: 64px;
}
.dg-card-text:focus { border-color: var(--brand-500, #4076ff); background: #fff; }

.dg-card-text-readonly {
    display: block;
    padding: 8px 12px;
    background: var(--ink-50, #f4f6fa);
    border-radius: 6px;
    font-size: 0.96em;
    color: var(--ink-900, #1a202c);
    line-height: 1.55;
}

/* ---- Pixel bars --------------------------------------------------- */
.dg-card-bars {
    display: grid;
    grid-template-columns: 1fr;
    gap: 6px;
    margin-bottom: 10px;
}
.dg-pixel-bar {
    display: grid;
    grid-template-columns: 64px 1fr 110px;
    gap: 8px;
    align-items: center;
}
.dg-pixel-bar-label {
    font-size: 0.78em;
    color: var(--ink-500, #788196);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
}
.dg-pixel-bar-track {
    position: relative;
    height: 8px;
    background: var(--ink-100, #e4e8ef);
    border-radius: 4px;
    overflow: hidden;
}
.dg-pixel-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #5fa856, #4a9d4a);
    width: 0;
    transition: width 200ms, background 200ms;
}
.dg-pixel-bar-fill.is-warning {
    background: linear-gradient(90deg, #f4ad42, #f49342);
}
.dg-pixel-bar-fill.is-danger {
    background: linear-gradient(90deg, #e85c5c, #d94545);
}
.dg-pixel-bar-budget {
    position: absolute;
    top: -2px;
    width: 1px;
    height: 12px;
    background: var(--ink-500, #788196);
    pointer-events: none;
    margin-left: -1px;
}
.dg-pixel-bar-text {
    font-size: 0.75em;
    color: var(--ink-700, #4a5568);
    text-align: right;
    font-variant-numeric: tabular-nums;
}

/* ---- Card foot (counts + actions) -------------------------------- */
.dg-card-foot {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.82em;
}
.dg-card-charcount {
    color: var(--ink-500, #788196);
    font-variant-numeric: tabular-nums;
    padding: 1px 6px;
    border-radius: 4px;
}
.dg-card-charcount.is-good   { color: #226c3a; background: #e7f6ec; }
.dg-card-charcount.is-warn   { color: #8a5a00; background: #fff4e0; }
.dg-card-charcount.is-danger { color: #b13c3c; background: #fff0f0; }

.dg-card-foot-spacer { flex: 1; }
.dg-icon-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: transparent;
    border: 1px solid var(--ink-200, #e4e8ef);
    border-radius: 6px;
    padding: 4px 10px;
    cursor: pointer;
    font-size: 0.85em;
    color: var(--ink-700, #4a5568);
    transition: border-color 120ms, background 120ms, color 120ms;
}
.dg-icon-btn:hover { border-color: var(--brand-500, #4076ff); color: var(--brand-700, #2b59e0); background: var(--brand-50, #e6efff); }
.dg-icon-btn:disabled { opacity: 0.55; cursor: wait; }

/* ---- Keyword stats card (right rail) ------------------------------ */
.dg-kw-card {
    background: #fff;
    border: 1px solid var(--ink-200, #e4e8ef);
    border-radius: 8px;
    padding: 10px 14px;
    margin-bottom: 12px;
}
.dg-kw-card[hidden] { display: none; }
.dg-kw-card-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 6px;
    gap: 10px;
}
.dg-kw-card-head strong { font-size: 0.9em; }
.dg-kw-card-keyword {
    font-size: 0.78em;
    color: var(--brand-700, #2b59e0);
    word-break: break-word;
    text-align: right;
}
.dg-kw-stats { display: flex; flex-direction: column; gap: 2px; }
.dg-kw-stat {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
    padding: 2px 0;
}
.dg-kw-stat-label {
    font-size: 0.74em;
    color: var(--ink-500, #788196);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.dg-kw-stat-value {
    font-size: 0.88em;
    font-weight: 600;
    color: var(--ink-900, #1a202c);
}
.dg-kw-trend {
    margin-top: 4px;
    color: var(--brand-500, #4076ff);
}
.dg-kw-trend-label {
    display: block;
    font-size: 0.68em;
    color: var(--ink-500, #788196);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 0;
}

/* ---- SERP top-10 panel (right rail) ------------------------------ */
.dg-serp-panel {
    background: #fff;
    border: 1px solid var(--ink-200, #e4e8ef);
    border-radius: 8px;
    padding: 14px 16px;
}
.dg-serp-panel[hidden] { display: none; }
.dg-serp-panel-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}
.dg-serp-panel-head strong { font-size: 0.92em; }
.dg-serp-panel-meta {
    font-size: 0.78em;
    color: var(--ink-500, #788196);
}
.dg-serp-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.dg-serp-item {
    display: grid;
    grid-template-columns: 28px 1fr;
    gap: 8px;
    padding: 8px 0;
    border-top: 1px dashed var(--ink-100, #e4e8ef);
}
.dg-serp-item:first-child { border-top: none; padding-top: 0; }
.dg-serp-rank {
    font-weight: 600;
    font-size: 0.85em;
    color: var(--ink-500, #788196);
    font-variant-numeric: tabular-nums;
}
.dg-serp-item-body { min-width: 0; }
.dg-serp-item-title {
    font-size: 0.86em;
    color: var(--ink-700, #4a5568);
    font-weight: 600;
    margin-bottom: 2px;
    word-break: break-word;
}
.dg-serp-item-desc {
    font-size: 0.86em;
    color: var(--ink-900, #1a202c);
    line-height: 1.45;
    word-break: break-word;
}
.dg-serp-item-meta {
    font-size: 0.74em;
    color: var(--ink-500, #788196);
    margin-top: 2px;
}
.dg-serp-item-domain { color: var(--brand-700, #2b59e0); }

/* ---- History --------------------------------------------------- */
/* shared .history-item-* primitives in tools.css */

/* ---- Mobile bar layout fallback -------------------------------- */
@media (max-width: 560px) {
    .dg-pixel-bar { grid-template-columns: 56px 1fr 90px; }
    .dg-card-foot { flex-wrap: wrap; }
    .dg-icon-btn-label { display: none; }
}
