/* Styles specific to the text tool group. */

/* ---------- counter ---------- */

.counter-stat-grid {
    gap: 10px;
    grid-template-columns: repeat(auto-fill, minmax(118px, 1fr));
}

.counter-stat-grid .stat-tile {
    padding: 10px 8px;
}

.counter-stat-grid .stat-value {
    font-size: 20px;
}

.counter-top-label {
    font-size: 11px;
    font-weight: 650;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--text-faint);
    flex-shrink: 0;
}

.counter-word-chip {
    gap: 8px;
}

.counter-word-count {
    font-size: 11px;
    font-weight: 700;
    padding: 1px 7px;
    border-radius: 12px;
    background: rgba(0, 0, 0, 0.3);
    color: var(--text-dim);
}

/* ---------- case ---------- */

.case-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
    gap: 10px;
    margin-top: 12px;
}

.case-card {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--bg-input);
    transition: border-color 0.25s, transform 0.25s var(--ease-spring);
}

.case-card:hover {
    border-color: var(--accent-border);
    transform: translateY(-2px);
}

.case-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.case-card-head .icon-button {
    width: 26px;
    height: 26px;
}

.case-card-label {
    font-size: 11.5px;
    font-weight: 650;
    letter-spacing: 0.4px;
    color: var(--text-faint);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.case-card-output {
    font-family: var(--font-mono);
    font-size: 13px;
    min-height: 20px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.case-card-empty {
    color: var(--text-faint);
}

/* ---------- diff ---------- */

.diff-results-panel {
    animation: diff-panel-in 0.3s var(--ease-out);
}

@keyframes diff-panel-in {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.diff-output {
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--bg-input);
    font-family: var(--font-mono);
    font-size: 13px;
    line-height: 1.55;
    padding: 5px 0;
    max-height: 520px;
    overflow: auto;
}

.diff-line {
    display: flex;
    gap: 10px;
    padding: 1px 12px;
    white-space: pre-wrap;
    word-break: break-word;
    animation: diff-line-in 0.24s var(--ease-out) both;
    animation-delay: calc(var(--i) * 14ms);
}

@keyframes diff-line-in {
    from { opacity: 0; transform: translateX(-8px); }
    to { opacity: 1; transform: translateX(0); }
}

.diff-line-gutter {
    flex-shrink: 0;
    width: 14px;
    text-align: center;
    user-select: none;
    color: var(--text-faint);
}

.diff-line-text {
    flex: 1;
    min-width: 0;
}

.diff-line-add {
    background: rgba(63, 221, 154, 0.1);
}

.diff-line-add .diff-line-gutter {
    color: var(--ok);
}

.diff-line-del {
    background: rgba(255, 100, 116, 0.1);
}

.diff-line-del .diff-line-gutter {
    color: var(--err);
}

.diff-line-same {
    color: var(--text-dim);
}

.diff-truncated {
    padding: 6px 12px;
}

.diff-badge-pulse {
    animation: diff-badge-pop 0.45s var(--ease-spring);
}

@keyframes diff-badge-pop {
    40% { transform: scale(1.18); }
}

/* ---------- regex ---------- */

.regex-pattern-wrap {
    display: flex;
    align-items: center;
    padding: 0 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--bg-input);
    transition: border-color 0.22s, box-shadow 0.22s;
}

.regex-pattern-wrap.regex-pattern-valid {
    border-color: rgba(63, 221, 154, 0.45);
}

.regex-pattern-wrap:focus-within {
    border-color: var(--accent-border);
    box-shadow: 0 0 0 4px var(--accent-soft);
}

.regex-pattern-wrap.regex-pattern-valid:focus-within {
    border-color: rgba(63, 221, 154, 0.55);
    box-shadow: 0 0 0 4px rgba(63, 221, 154, 0.12);
}

.regex-pattern-wrap input {
    border: none;
    background: transparent;
    padding: 11px 8px;
}

.regex-pattern-wrap input:focus {
    box-shadow: none;
}

.regex-slash {
    font-family: var(--font-mono);
    font-size: 16px;
    color: var(--text-faint);
    user-select: none;
}

.regex-flag-toggle {
    min-width: 34px;
    justify-content: center;
    font-weight: 700;
}

.regex-pop {
    animation: regex-panel-in 0.3s var(--ease-out);
}

@keyframes regex-panel-in {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.regex-lower-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-top: 16px;
    align-items: start;
}

.regex-lower-grid > .panel {
    margin-top: 0;
}

.chip.regex-chip-zero {
    background: rgba(255, 100, 116, 0.14);
    color: var(--err);
}

.regex-mark {
    background: hsl(var(--accent-h) 90% 60% / 0.32);
    color: inherit;
    border-radius: 3px;
    padding: 1px 1px;
    animation: regex-mark-glow 1.8s ease-in-out infinite alternate;
}

.regex-mark-alt {
    background: hsl(305 85% 62% / 0.3);
}

@keyframes regex-mark-glow {
    from { box-shadow: 0 0 2px hsl(var(--accent-h) 90% 65% / 0.15); }
    to { box-shadow: 0 0 9px hsl(var(--accent-h) 90% 65% / 0.5); }
}

.regex-match-card {
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--bg-input);
    padding: 8px 12px;
    margin-bottom: 6px;
    animation: regex-row-in 0.3s var(--ease-out) both;
    animation-delay: calc(var(--i) * 30ms);
}

.regex-match-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.regex-match-text {
    font-family: var(--font-mono);
    font-size: 13px;
    color: var(--text);
    word-break: break-all;
}

.regex-group-row {
    display: flex;
    gap: 12px;
    margin-top: 5px;
    font-family: var(--font-mono);
    font-size: 12.5px;
}

.regex-group-name {
    flex-shrink: 0;
    min-width: 46px;
    color: var(--accent);
}

.regex-group-value {
    color: var(--text-dim);
    word-break: break-all;
}

.regex-group-missing {
    color: var(--text-faint);
    font-style: italic;
}

.regex-explain-grid {
    display: grid;
    grid-template-columns: minmax(96px, max-content) 1fr;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.regex-token,
.regex-token-desc {
    padding: 7px 12px;
    border-bottom: 1px solid var(--border);
    font-size: 12.5px;
    animation: regex-row-in 0.3s var(--ease-out) both;
    animation-delay: calc(var(--i) * 30ms);
}

.regex-token {
    font-family: var(--font-mono);
    color: var(--accent);
    background: rgba(0, 0, 0, 0.18);
    word-break: break-all;
}

.regex-token-desc {
    color: var(--text-dim);
}

.regex-token:nth-last-child(2),
.regex-token-desc:last-child {
    border-bottom: none;
}

@keyframes regex-row-in {
    from { opacity: 0; transform: translateX(-6px); }
    to { opacity: 1; transform: translateX(0); }
}

@media (max-width: 780px) {
    .regex-lower-grid {
        grid-template-columns: 1fr;
    }
}

/* ---------- markdown ---------- */

.markdown-word-chip {
    text-transform: none;
    letter-spacing: 0;
}

.markdown-preview {
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--bg-input);
    padding: 14px 18px;
    min-height: 420px;
    max-height: 70vh;
    overflow: auto;
    font-size: 14.5px;
    line-height: 1.65;
}

.markdown-preview-flash {
    animation: markdown-border-flash 0.6s ease-out;
}

@keyframes markdown-border-flash {
    0% { border-color: var(--accent-border); box-shadow: 0 0 0 3px var(--accent-soft); }
    100% { border-color: var(--border); box-shadow: 0 0 0 0 transparent; }
}

.markdown-preview > :first-child {
    margin-top: 0;
}

.markdown-preview h1,
.markdown-preview h2,
.markdown-preview h3,
.markdown-preview h4,
.markdown-preview h5,
.markdown-preview h6 {
    margin: 1.2em 0 0.5em;
    line-height: 1.3;
}

.markdown-preview h1 {
    font-size: 24px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border);
}

.markdown-preview h2 {
    font-size: 20px;
}

.markdown-preview h3 {
    font-size: 17px;
}

.markdown-preview p {
    margin: 0.55em 0;
}

.markdown-preview a {
    color: var(--accent);
}

.markdown-preview code {
    font-family: var(--font-mono);
    font-size: 0.88em;
    background: rgba(0, 0, 0, 0.35);
    padding: 2px 6px;
    border-radius: 5px;
}

.markdown-preview pre {
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 12px 14px;
    overflow: auto;
}

.markdown-preview pre code {
    background: none;
    padding: 0;
}

.markdown-preview blockquote {
    margin: 0.8em 0;
    padding: 6px 16px;
    border-left: 3px solid var(--accent-border);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    background: var(--accent-soft);
    color: var(--text-dim);
}

.markdown-preview ul,
.markdown-preview ol {
    padding-left: 24px;
}

.markdown-preview table {
    border-collapse: collapse;
    margin: 0.8em 0;
}

.markdown-preview th,
.markdown-preview td {
    border: 1px solid var(--border);
    padding: 6px 12px;
    text-align: left;
}

.markdown-preview th {
    background: rgba(0, 0, 0, 0.25);
}

.markdown-preview img {
    max-width: 100%;
    border-radius: var(--radius-sm);
}

.markdown-preview hr {
    border: none;
    height: 1px;
    background: var(--border);
}
