/* Readability Checker , tool-specific styles.
 * Brand accent: violet (#7c3aed) to differentiate from
 * AGC (deep blue), SCC (green), SR (indigo), ATG (teal),
 * AISUM (orange), TLC/DG (red), PG (forest green).
 */

:root {
    --rdc-brand: #7c3aed;
    --rdc-brand-dark: #6d28d9;
    --rdc-brand-fade: #ede9fe;
    --rdc-brand-tint: #f5f3ff;
}

/* ---- Mode toggle (3 tabs) -------------------------------------- */
/* Per [[mode-toggle-pill-data-mode]]: shared CSS hardcodes 2-tab.
 * Buttons share the toggle width equally via flex: 1 1 0 so the
 * 33.333% pill ALIGNS with each button (otherwise the natural
 * button width can exceed the pill width and the centered text
 * sits right-of-pill-center, looking unpadded). */
.rdc-mode-toggle .mode-btn {
    flex: 1 1 0;
    min-width: 120px;
    text-align: center;
    padding-left: 18px;
    padding-right: 18px;
}
.rdc-mode-toggle::before { width: calc(33.333% - 4px) !important; }
.rdc-mode-toggle[data-mode="paste"]::before  { transform: translateX(0)    !important; }
.rdc-mode-toggle[data-mode="url"]::before    { transform: translateX(100%) !important; }
.rdc-mode-toggle[data-mode="upload"]::before { transform: translateX(200%) !important; }

/* ---- Form ----------------------------------------------------- */
.rdc-mode-panel { display: none; margin-top: 16px; }
.rdc-mode-panel.is-visible { display: block; }
.rdc-field-label {
    display: block;
    font-size: 0.85em;
    font-weight: 600;
    color: var(--ink-700);
    margin-bottom: 6px;
}
.rdc-textarea {
    width: 100%;
    box-sizing: border-box;
    min-height: 200px;
    font-family: inherit;
    resize: vertical;
    flex: 0 0 auto;
}
/* URL input: shared .text-input ships flex:1 1 320px which collapses
 * the input inside a block parent. Force full-width per
 * [[text-input-flex-basis-height]]. */
.rdc-url-input {
    width: 100%;
    box-sizing: border-box;
    flex: 0 0 auto;
}
.rdc-paste-meta {
    display: flex;
    justify-content: space-between;
    margin-top: 6px;
    font-size: 0.8em;
    color: var(--ink-500);
}
.rdc-word-counter { font-weight: 500; }
.rdc-word-limit-hint { color: var(--ink-400); }
.rdc-word-counter.is-near-cap { color: #d97706; font-weight: 600; }
.rdc-word-counter.is-over-cap { color: #dc2626; font-weight: 600; }

.rdc-mode-hint {
    margin-top: 8px;
    font-size: 0.8em;
    color: var(--ink-500);
}

.rdc-upload-dropzone {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: var(--ink-50);
    border: 1px dashed var(--ink-300);
    border-radius: 8px;
}
.rdc-upload-file-label {
    color: var(--ink-600);
    font-size: 0.88em;
}
.rdc-upload-file-label.has-file { color: var(--ink-800); font-weight: 600; }

/* Audience / options row */
.rdc-options {
    display: flex;
    gap: 16px;
    margin-top: 16px;
    flex-wrap: wrap;
}
.rdc-option-cell { flex: 1 1 220px; min-width: 200px; }
.rdc-select {
    width: 100%;
    box-sizing: border-box;
    padding: 8px 12px;
    border: 1px solid var(--ink-300);
    border-radius: 6px;
    font-family: inherit;
    font-size: 0.95em;
    background: white;
}
.rdc-select:focus {
    outline: none;
    border-color: var(--rdc-brand);
    box-shadow: 0 0 0 3px var(--rdc-brand-fade);
}

.rdc-submit-row {
    margin-top: 18px;
    display: flex;
    justify-content: flex-end;
}

/* ---- Progress region ------------------------------------------ */
.rdc-progress-bar-track {
    height: 6px;
    background: var(--ink-100);
    border-radius: 6px;
    overflow: hidden;
}
.rdc-progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--rdc-brand), var(--rdc-brand-dark));
    transition: width 0.6s ease;
    width: 10%;
}
.rdc-whimsy-msg {
    margin-top: 10px;
    color: var(--ink-600);
    font-size: 0.9em;
    text-align: center;
}

/* ---- Results body --------------------------------------------- */
.rdc-results-body { padding: 18px 22px 4px; }
.rdc-results-body > :last-child { margin-bottom: 18px; }

.rdc-source-subhead {
    border-left: 4px solid var(--brand-blue, #3b82f6);
    background: var(--brand-blue-50, #eff6ff);
    padding: 12px 16px;
    margin-bottom: 18px;
    border-radius: 0 6px 6px 0;
}
.rdc-source-label {
    display: inline-block;
    font-size: 0.7em;
    letter-spacing: 0.08em;
    color: var(--ink-500);
    text-transform: uppercase;
    font-weight: 700;
    margin-bottom: 4px;
}
.rdc-source-title {
    display: block;
    font-size: 1.05em;
    font-weight: 700;
    color: var(--ink-800);
    word-break: break-word;
}
.rdc-source-url {
    display: block;
    font-size: 0.85em;
    color: var(--rdc-brand);
    margin-top: 4px;
    word-break: break-all;
}
.rdc-source-meta {
    margin-top: 4px;
    font-size: 0.8em;
    color: var(--ink-500);
}

/* ---- Summary panel (overall headline) ------------------------- */
.rdc-summary-panel {
    background: linear-gradient(135deg, var(--rdc-brand-tint), white);
    border: 1px solid var(--rdc-brand-fade);
    border-radius: 12px;
    padding: 22px 24px;
    margin-bottom: 18px;
}
.rdc-summary-headline {
    display: flex;
    align-items: center;
    gap: 24px;
    flex-wrap: wrap;
}
.rdc-grade-stack {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex-shrink: 0;
}
.rdc-grade-circle {
    width: 110px;
    height: 110px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--rdc-brand), var(--rdc-brand-dark));
    color: white;
    box-shadow: 0 4px 12px rgba(124, 58, 237, 0.3);
}
.rdc-grade-circle.is-warn { background: linear-gradient(135deg, #f59e0b, #d97706); box-shadow: 0 4px 12px rgba(245, 158, 11, 0.3); }
.rdc-grade-circle.is-danger { background: linear-gradient(135deg, #ef4444, #dc2626); box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3); }
.rdc-grade-score {
    font-size: 2.8em;
    font-weight: 700;
    line-height: 1;
}
.rdc-grade-band {
    margin-top: 10px;
    font-size: 0.88em;
    font-weight: 600;
    color: var(--ink-700);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    text-align: center;
    max-width: 140px;
    line-height: 1.25;
}
.rdc-summary-blurb { flex: 1 1 300px; min-width: 250px; }
.rdc-summary-title {
    margin: 0 0 4px;
    font-size: 1.2em;
    color: var(--ink-800);
}
.rdc-summary-text {
    margin: 0 0 10px;
    color: var(--ink-600);
    font-size: 0.95em;
    line-height: 1.5;
}
.rdc-summary-pills { display: flex; flex-wrap: wrap; gap: 6px; }
.rdc-meta-pill {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    background: white;
    border: 1px solid var(--ink-200);
    border-radius: 999px;
    font-size: 0.82em;
    color: var(--ink-700);
    font-weight: 500;
}
.rdc-meta-pill.is-good    { background: #d1fae5; border-color: #6ee7b7; color: #065f46; }
.rdc-meta-pill.is-warn    { background: #fef3c7; border-color: #fcd34d; color: #92400e; }
.rdc-meta-pill.is-danger  { background: #fee2e2; border-color: #fca5a5; color: #991b1b; }
.rdc-meta-pill.is-info    { background: #dbeafe; border-color: #93c5fd; color: #1e40af; }

/* ---- 8-formula grid ------------------------------------------- */
.rdc-formula-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 12px;
    margin-bottom: 18px;
}
.rdc-formula-card {
    background: white;
    border: 1px solid var(--ink-200);
    border-radius: 10px;
    padding: 14px 16px;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.rdc-formula-card:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.06);
}
.rdc-formula-name {
    font-size: 0.78em;
    color: var(--ink-500);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 6px;
}
.rdc-formula-value {
    font-size: 1.8em;
    font-weight: 700;
    color: var(--rdc-brand);
    line-height: 1;
    margin-bottom: 4px;
    font-variant-numeric: tabular-nums;
}
.rdc-formula-grade {
    font-size: 0.85em;
    color: var(--ink-700);
    font-weight: 500;
    margin-bottom: 8px;
}
.rdc-formula-blurb {
    font-size: 0.78em;
    color: var(--ink-500);
    line-height: 1.4;
}

/* ---- Sentence breakdown panel --------------------------------- */
.rdc-sentence-panel {
    background: white;
    border: 1px solid var(--ink-200);
    border-radius: 10px;
    padding: 18px 22px;
    margin-bottom: 18px;
}
.rdc-sentence-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
    flex-wrap: wrap;
}
.rdc-panel-title {
    margin: 0;
    font-size: 1.05em;
    color: var(--ink-800);
}
.rdc-sentence-legend {
    display: flex;
    gap: 12px;
    align-items: center;
    font-size: 0.78em;
    color: var(--ink-600);
    flex-wrap: wrap;
}
.rdc-legend-item { display: inline-flex; align-items: center; gap: 5px; }
.rdc-legend-swatch {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 3px;
}
.rdc-legend-swatch.is-easy      { background: #d1fae5; border: 1px solid #6ee7b7; }
.rdc-legend-swatch.is-hard      { background: #fef3c7; border: 1px solid #fcd34d; }
.rdc-legend-swatch.is-very-hard { background: #fee2e2; border: 1px solid #fca5a5; }
.rdc-legend-hint {
    margin-left: 8px;
    color: var(--rdc-brand);
    font-style: italic;
}

.rdc-sentence-body {
    line-height: 1.85;
    font-size: 1.02em;
    color: var(--ink-800);
    background: var(--ink-50);
    padding: 16px 18px;
    border-radius: 8px;
    max-height: 480px;
    overflow-y: auto;
}
.rdc-sentence {
    display: inline;
    border-radius: 3px;
    padding: 1px 0;
    transition: background-color 0.15s ease;
}
.rdc-sentence.is-easy      { background: transparent; }
.rdc-sentence.is-medium    { background: transparent; }
.rdc-sentence.is-hard      { background: #fef3c7; cursor: pointer; }
.rdc-sentence.is-very-hard { background: #fee2e2; cursor: pointer; }
.rdc-sentence.is-hard:hover,
.rdc-sentence.is-very-hard:hover {
    outline: 2px solid var(--rdc-brand);
    outline-offset: 1px;
}
.rdc-sentence.is-active {
    outline: 2px solid var(--rdc-brand);
    outline-offset: 1px;
}

/* Per-sentence rewrite popover */
.rdc-rewrite-panel {
    display: block;
    margin: 12px 0;
    background: white;
    border: 1px solid var(--rdc-brand-fade);
    border-radius: 8px;
    padding: 14px 16px;
    box-shadow: 0 4px 12px rgba(124, 58, 237, 0.08);
}
.rdc-rewrite-original {
    font-size: 0.85em;
    color: var(--ink-700);
    background: var(--ink-50);
    padding: 8px 12px;
    border-radius: 6px;
    margin-bottom: 10px;
    font-style: italic;
}
.rdc-rewrite-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-bottom: 10px;
}
.rdc-rewrite-btn {
    padding: 6px 14px;
    background: var(--rdc-brand);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 0.85em;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.15s ease;
}
.rdc-rewrite-btn:hover { background: var(--rdc-brand-dark); }
.rdc-rewrite-btn:disabled {
    background: var(--ink-300);
    cursor: not-allowed;
}
.rdc-rewrite-close {
    background: transparent;
    border: none;
    color: var(--ink-500);
    cursor: pointer;
    padding: 4px 8px;
    font-size: 0.85em;
}
.rdc-rewrite-close:hover { color: var(--ink-800); }
.rdc-rewrite-loading {
    text-align: center;
    color: var(--ink-500);
    font-size: 0.85em;
    padding: 12px;
}
.rdc-rewrite-variants {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.rdc-rewrite-variant {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 12px;
    background: #f0fdf4;
    border: 1px solid #86efac;
    border-radius: 6px;
}
.rdc-rewrite-variant-text {
    flex: 1;
    color: var(--ink-800);
    font-size: 0.95em;
    line-height: 1.45;
}
.rdc-rewrite-variant-copy {
    flex-shrink: 0;
    padding: 4px 10px;
    background: white;
    border: 1px solid #86efac;
    border-radius: 4px;
    color: #065f46;
    font-size: 0.78em;
    font-weight: 600;
    cursor: pointer;
}
.rdc-rewrite-variant-copy:hover {
    background: #d1fae5;
}
.rdc-rewrite-error {
    color: #991b1b;
    font-size: 0.85em;
    padding: 8px 12px;
    background: #fee2e2;
    border-radius: 6px;
}

/* ---- Stats panel ---------------------------------------------- */
.rdc-stats-panel {
    background: white;
    border: 1px solid var(--ink-200);
    border-radius: 10px;
    padding: 18px 22px;
    margin-bottom: 18px;
}
.rdc-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 14px;
    margin-top: 12px;
}
.rdc-stat-cell {
    display: flex;
    flex-direction: column;
    padding: 10px 12px;
    background: var(--ink-50);
    border-radius: 6px;
}
.rdc-stat-label {
    font-size: 0.72em;
    color: var(--ink-500);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-weight: 600;
}
.rdc-stat-value {
    font-size: 1.3em;
    color: var(--ink-800);
    font-weight: 700;
    margin-top: 2px;
    font-variant-numeric: tabular-nums;
}
.rdc-stat-unit {
    font-size: 0.65em;
    color: var(--ink-500);
    font-weight: 500;
    margin-left: 4px;
}

/* ---- Caveat block --------------------------------------------- */
.rdc-caveat {
    background: var(--ink-50);
    border: 1px solid var(--ink-200);
    border-radius: 8px;
    padding: 14px 16px;
}
.rdc-caveat summary {
    cursor: pointer;
    font-weight: 600;
    color: var(--ink-700);
    font-size: 0.92em;
}
.rdc-caveat p {
    margin: 10px 0 0;
    font-size: 0.88em;
    color: var(--ink-600);
    line-height: 1.55;
}

/* ---- Hidden override for grid/flex panels --------------------- */
/* Per [[hidden-attribute-with-flex]] every grid/flex element that
 * toggles via the hidden attribute needs an explicit display:none
 * override or it stays visible. */
.rdc-summary-panel[hidden],
.rdc-formula-grid[hidden],
.rdc-sentence-panel[hidden],
.rdc-stats-panel[hidden],
.rdc-mode-panel[hidden],
.rdc-source-subhead[hidden],
.rdc-meta-pill[hidden] {
    display: none !important;
}

/* ---- Responsive ----------------------------------------------- */
@media (max-width: 640px) {
    .rdc-formula-grid { grid-template-columns: 1fr 1fr; }
    .rdc-summary-headline { flex-direction: column; text-align: center; align-items: center; }
    .rdc-grade-circle { width: 90px; height: 90px; }
    .rdc-grade-score { font-size: 2.2em; }
}
