/* ============================================================================
   CODEAYAN — TOOLS STYLES
   Location: /style/tools.css
   ----------------------------------------------------------------------------
   Same conventions as prep.css:
   - global.css forces font-weight 400 with !important, so any bold here also
     needs !important.
   - global.css disables text selection on body; tool inputs, results and
     articles re-enable it so people can copy their numbers.
   - Grid tracks use minmax(0, 1fr) and flex/grid children get min-width: 0 so
     wide tables and code never push the page wider than the phone.
   ============================================================================ */

:root {
    --tools-amber:  #f29111;
    --tools-violet: #8b5cf6;
    --tools-radius: 14px;
}

.tool-app, .tool-app *,
.tool-article, .tool-article *,
.tools-faq, .tools-faq * {
    user-select: text !important;
    -webkit-user-select: text !important;
    -moz-user-select: text !important;
}

/* ── Preview bar (admins only) ───────────────────────────────────────────── */
.tools-preview-bar {
    background: #fff7e8;
    border-bottom: 1px solid #f2c27a;
    color: #7a4a00;
    font-size: .88rem;
    padding: .6rem 1rem;
    text-align: center;
}
.tools-preview-bar strong { font-weight: 700 !important; }

/* ── Shared primitives ───────────────────────────────────────────────────── */
.tools-eyebrow {
    font-size: .72rem;
    letter-spacing: .16em;
    text-transform: uppercase;
    color: var(--brand-blue);
    font-weight: 700 !important;
    display: block;
    margin-bottom: .6rem;
}

.tools-crumbs {
    font-size: .85rem;
    color: var(--ink-light);
    margin-bottom: 1.25rem;
}
.tools-crumbs a { color: var(--ink-light); }
.tools-crumbs a:hover { color: var(--brand-blue); }
.tools-crumbs .sep { margin: 0 .45rem; opacity: .5; }

/* ══════════════════════════════════════════════════════════════════════════
   LANDING
   ══════════════════════════════════════════════════════════════════════════ */
.tools-hero { padding-top: 2.5rem; }
.tools-hero .section-body { max-width: 640px; }

.tools-search-shell {
    max-width: 640px;
    margin: 2rem auto 0;
    position: relative;
}
.tools-search-shell i {
    position: absolute;
    left: 1.1rem; top: 50%;
    transform: translateY(-50%);
    color: var(--ink-light);
}
.tools-search {
    width: 100%;
    border: 1px solid var(--border-subtle);
    border-radius: 100px;
    background: var(--surface-card);
    padding: .95rem 1.25rem .95rem 2.9rem;
    font-size: 1rem;
    color: var(--ink-dark);
    box-shadow: 0 10px 30px rgba(0,0,0,.04);
    transition: border-color .25s, box-shadow .25s;
}
.tools-search:focus {
    outline: none;
    border-color: var(--brand-blue);
    box-shadow: 0 0 0 4px rgba(40,151,201,.12);
}

.tools-chip-row {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: .6rem;
    margin: 1.5rem 0 0;
}
.tools-chip {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    padding: .55rem 1rem;
    border: 1px solid var(--border-subtle);
    border-radius: 100px;
    background: var(--surface-bg);
    color: var(--ink-medium);
    font-size: .9rem;
    cursor: pointer;
    transition: all .25s ease;
}
.tools-chip:hover { border-color: var(--brand-blue); color: var(--brand-blue); }
.tools-chip.is-active {
    background: var(--ink-dark);
    border-color: var(--ink-dark);
    color: #fff;
}
.tools-chip:focus-visible { outline: 3px solid var(--brand-mint); outline-offset: 2px; }

.tools-group { margin-top: 3.5rem; }
.tools-group-head {
    display: flex;
    align-items: center;
    gap: .75rem;
    margin-bottom: 1.25rem;
}
.tools-group-head .gicon {
    width: 38px; height: 38px;
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.tools-group-head h2 { font-size: 1.45rem; margin: 0; color: var(--ink-dark); }

.tool-card {
    display: flex;
    flex-direction: column;
    height: 100%;
    padding: 1.5rem;
    background: var(--surface-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--tools-radius);
    text-decoration: none;
    transition: transform .3s cubic-bezier(.16,1,.3,1), box-shadow .3s ease, border-color .3s ease;
}
a.tool-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 14px 32px rgba(0,164,182,.10);
    border-color: var(--brand-teal);
}
.tool-card.is-soon { opacity: .6; border-style: dashed; }
.tool-card-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: .5rem;
    margin-bottom: 1rem;
}
.tool-card-icon {
    width: 46px; height: 46px;
    border-radius: 11px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.2rem;
}
.tool-card h3 { font-size: 1.15rem; color: var(--ink-dark); margin-bottom: .45rem; }
.tool-card p  { font-size: .92rem; color: var(--ink-light); line-height: 1.6; margin-bottom: 1rem; flex: 1; }
.tool-card-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-top: 1px solid rgba(0,0,0,.06);
    padding-top: .85rem;
    font-size: .8rem;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--ink-light);
}
.tool-status {
    font-size: .66rem;
    letter-spacing: .08em;
    text-transform: uppercase;
    font-weight: 700 !important;
    padding: .25rem .55rem;
    border-radius: 100px;
    white-space: nowrap;
}
.tool-status-planned { background: rgba(0,0,0,.05); color: var(--ink-light); }
.tool-status-draft   { background: rgba(242,145,17,.12); color: #a35f00; }

.tools-empty {
    display: none;
    text-align: center;
    color: var(--ink-light);
    padding: 3rem 1rem;
}
.tools-empty.is-shown { display: block; }

.tools-trust {
    margin-top: 4.5rem;
    background: var(--surface-card);
    border: 1px solid var(--border-subtle);
    border-radius: 18px;
    padding: 2.25rem;
    position: relative;
    overflow: hidden;
}
.tools-trust::before {
    content: '';
    position: absolute; top: 0; left: 0;
    width: 100%; height: 4px;
    background: linear-gradient(90deg, var(--brand-mint), var(--brand-blue));
}
.tools-trust .trust-item { display: flex; gap: .9rem; }
.tools-trust .trust-item i {
    color: var(--brand-blue);
    font-size: 1.15rem;
    margin-top: .3rem;
    width: 1.3rem;
    text-align: center;
    flex-shrink: 0;
}
.tools-trust h3 { font-size: 1.05rem; margin-bottom: .3rem; color: var(--ink-dark); }
.tools-trust p  { font-size: .9rem; color: var(--ink-light); margin: 0; line-height: 1.6; }

/* ── FAQ (landing + tool pages) ──────────────────────────────────────────── */
.tools-faq { max-width: 820px; margin: 0 auto; }
.tools-faq details {
    border-bottom: 1px solid rgba(0,0,0,.08);
    padding: 1.1rem 0;
}
.tools-faq summary {
    cursor: pointer;
    list-style: none;
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    font-size: 1.08rem;
    color: var(--ink-dark);
    font-family: var(--font-heading, Georgia, serif) !important;
}
.tools-faq summary::-webkit-details-marker { display: none; }
.tools-faq summary::after {
    content: '+';
    font-family: var(--font-body, system-ui, sans-serif) !important;
    color: var(--brand-blue);
    font-size: 1.3rem;
    line-height: 1;
}
.tools-faq details[open] summary::after { content: '−'; }
.tools-faq details p {
    margin: .8rem 0 0;
    color: var(--ink-medium);
    line-height: 1.75;
}

/* ══════════════════════════════════════════════════════════════════════════
   TOOL PAGE
   ══════════════════════════════════════════════════════════════════════════ */
.tool-head { padding-top: 2.5rem; }
.tool-head h1 { margin-bottom: .75rem; }
.tool-head .lead-text {
    font-size: 1.05rem;
    color: var(--ink-medium);
    line-height: 1.75;
    max-width: 760px;
}

.tool-shell {
    display: grid;
    grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
    gap: 1.5rem;
    align-items: start;
    margin-top: 2rem;
}
.tool-shell > * { min-width: 0; }

.tool-panel {
    background: var(--surface-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--tools-radius);
    padding: 1.5rem;
    box-shadow: 0 10px 30px rgba(0,0,0,.03);
    min-width: 0;
}
.tool-panel + .tool-panel { margin-top: 1.5rem; }
.tool-panel-title {
    font-size: 1.15rem;
    color: var(--ink-dark);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: .55rem;
}
.tool-panel-title i { color: var(--brand-blue); font-size: .95rem; }

.tool-label {
    display: block;
    font-size: .78rem;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--ink-medium);
    margin-bottom: .4rem;
}
.tool-help { font-size: .82rem; color: var(--ink-light); margin-top: .4rem; line-height: 1.55; }

.tool-input,
.tool-textarea {
    width: 100%;
    border: 1px solid #d5e0e4;
    border-radius: 9px;
    background: #f8fafb;
    color: var(--ink-dark);
    padding: .7rem .85rem;
    font-size: .95rem;
    transition: border-color .25s, box-shadow .25s, background .25s;
}
.tool-textarea {
    min-height: 220px;
    resize: vertical;
    font-family: var(--font-mono, ui-monospace, Menlo, Consolas, monospace) !important;
    font-size: .88rem;
    line-height: 1.6;
    white-space: pre;
    overflow-x: auto;
}
.tool-input:focus,
.tool-textarea:focus {
    outline: none;
    background: #fff;
    border-color: var(--brand-blue);
    box-shadow: 0 0 0 3px rgba(40,151,201,.13);
}

.tool-row { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: .8rem; }
.tool-row > * { min-width: 0; }

.tool-actions { display: flex; flex-wrap: wrap; gap: .6rem; margin-top: 1.1rem; }
.tool-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    border-radius: 9px;
    padding: .7rem 1.25rem;
    font-size: .95rem;
    cursor: pointer;
    border: 1px solid var(--border-subtle);
    background: var(--surface-card);
    color: var(--ink-dark);
    transition: all .25s ease;
}
.tool-btn:hover { border-color: var(--brand-blue); color: var(--brand-blue); }
.tool-btn-primary {
    background: var(--brand-mint);
    border-color: var(--brand-mint);
    color: #111;
    font-weight: 700 !important;
}
.tool-btn-primary:hover { color: #111; transform: translateY(-2px); box-shadow: 0 10px 24px rgba(6,215,184,.28); }
.tool-btn-sm { padding: .45rem .85rem; font-size: .85rem; }
.tool-btn:focus-visible { outline: 3px solid var(--brand-mint); outline-offset: 2px; }

.tool-msg {
    display: none;
    margin-top: 1rem;
    border-radius: 9px;
    padding: .75rem .95rem;
    font-size: .9rem;
    line-height: 1.55;
}
.tool-msg.is-shown { display: block; }
.tool-msg.is-error { background: rgba(217,83,79,.08); color: #9c2f2b; border: 1px solid rgba(217,83,79,.25); }
.tool-msg.is-note  { background: rgba(242,145,17,.09); color: #7a4a00; border: 1px solid rgba(242,145,17,.28); }

/* Results */
.tool-empty-state {
    text-align: center;
    color: var(--ink-light);
    padding: 3rem 1rem;
}
.tool-empty-state i { font-size: 2rem; color: var(--border-subtle); margin-bottom: .8rem; display: block; }

.tool-equation {
    background: var(--ink-dark);
    color: #fff;
    border-radius: 12px;
    padding: 1.15rem 1.3rem;
    margin-bottom: 1.1rem;
}
.tool-equation .eq-label {
    font-size: .7rem;
    letter-spacing: .14em;
    text-transform: uppercase;
    color: var(--brand-mint);
    display: block;
    margin-bottom: .35rem;
}
.tool-equation .eq {
    font-size: clamp(1.15rem, 2.6vw, 1.55rem);
    font-family: var(--font-heading, Georgia, serif) !important;
    overflow-wrap: anywhere;
}

.tool-kpis {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: .7rem;
    margin-bottom: 1.1rem;
}
.tool-kpi {
    border: 1px solid rgba(0,0,0,.08);
    border-radius: 11px;
    padding: .8rem .9rem;
    background: var(--surface-bg);
    min-width: 0;
}
.tool-kpi .k {
    font-size: .7rem;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--ink-light);
    display: block;
}
.tool-kpi .v {
    font-size: 1.3rem;
    color: var(--ink-dark);
    font-variant-numeric: tabular-nums;
    overflow-wrap: anywhere;
}

.tool-verdict {
    border-left: 4px solid var(--brand-mint);
    background: rgba(6,215,184,.07);
    border-radius: 0 10px 10px 0;
    padding: .9rem 1.1rem;
    color: var(--ink-medium);
    line-height: 1.7;
    margin-bottom: 1.1rem;
}
.tool-verdict.is-weak { border-left-color: var(--tools-amber); background: rgba(242,145,17,.07); }

.tool-tabs { display: flex; gap: .4rem; flex-wrap: wrap; margin-bottom: .9rem; }
.tool-tab {
    border: 1px solid var(--border-subtle);
    background: var(--surface-bg);
    color: var(--ink-medium);
    border-radius: 100px;
    padding: .4rem .9rem;
    font-size: .85rem;
    cursor: pointer;
}
.tool-tab.is-active { background: var(--ink-dark); border-color: var(--ink-dark); color: #fff; }

.tool-chart { width: 100%; }
.ca-plot { width: 100%; height: auto; display: block; }
.ca-plot .ca-grid  { stroke: rgba(0,0,0,.06); stroke-width: 1; }
.ca-plot .ca-frame { fill: none; stroke: rgba(0,0,0,.15); stroke-width: 1; }
.ca-plot .ca-tick  { font-size: 12px; fill: #777; font-family: var(--font-body, system-ui, sans-serif); }
.ca-plot .ca-axis-title { font-size: 13px; fill: #444; font-family: var(--font-body, system-ui, sans-serif); }
.ca-plot .ca-pt    { fill: rgba(40,151,201,.85); stroke: #fff; stroke-width: 1.5; }
.ca-plot .ca-pt-hi { fill: var(--tools-amber); stroke: #fff; stroke-width: 2; }
.ca-plot .ca-fit   { stroke: #06b89d; stroke-width: 2.5; }
.ca-plot .ca-zero  { stroke: #06b89d; stroke-width: 2; stroke-dasharray: 6 5; }

.tool-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; max-width: 100%; }
.tool-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .9rem;
    font-variant-numeric: tabular-nums;
}
.tool-table th,
.tool-table td {
    padding: .55rem .7rem;
    border-bottom: 1px solid rgba(0,0,0,.07);
    text-align: right;
    white-space: nowrap;
}
.tool-table th:first-child,
.tool-table td:first-child { text-align: left; }
.tool-table th {
    font-size: .72rem;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--ink-light);
    background: var(--surface-bg);
}

.tool-steps details {
    border: 1px solid rgba(0,0,0,.08);
    border-radius: 11px;
    padding: .9rem 1.1rem;
    margin-top: .9rem;
}
.tool-steps summary { cursor: pointer; color: var(--ink-dark); }
.tool-steps ol { margin: .9rem 0 0; padding-left: 1.2rem; }
.tool-steps li { margin-bottom: .55rem; line-height: 1.7; color: var(--ink-medium); }
.tool-steps code,
.tool-article code {
    font-family: var(--font-mono, ui-monospace, Menlo, Consolas, monospace) !important;
    background: rgba(40,151,201,.08);
    color: #1a6f95;
    padding: .1rem .38rem;
    border-radius: 4px;
    font-size: .88em;
    overflow-wrap: anywhere;
}

.tool-predict {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: .6rem;
    align-items: end;
}
.tool-predict-out { margin-top: .9rem; font-size: .95rem; color: var(--ink-medium); line-height: 1.7; }
.tool-predict-out strong { color: var(--ink-dark); font-weight: 700 !important; }

/* ── Explainer article under the tool ────────────────────────────────────── */
.tool-article {
    max-width: 780px;
    margin: 0 auto;
    color: var(--ink-medium);
    font-size: 1.02rem;
    line-height: 1.85;
}
.tool-article h2 { font-size: 1.7rem; color: var(--ink-dark); margin: 2.75rem 0 1rem; }
.tool-article h3 { font-size: 1.25rem; color: var(--ink-dark); margin: 2rem 0 .75rem; }
.tool-article p  { margin-bottom: 1.1rem; }
.tool-article ul, .tool-article ol { margin-bottom: 1.2rem; }
.tool-article li { margin-bottom: .45rem; }
.tool-article strong { color: var(--ink-dark); font-weight: 700 !important; }
.tool-article a { color: var(--brand-blue); text-decoration: underline; text-underline-offset: 3px; }
.tool-article .formula {
    background: var(--surface-card);
    border: 1px solid var(--border-subtle);
    border-radius: 11px;
    padding: 1rem 1.2rem;
    margin: 1.2rem 0;
    font-family: var(--font-heading, Georgia, serif) !important;
    font-size: 1.1rem;
    color: var(--ink-dark);
    overflow-x: auto;
}
.tool-article pre {
    background: #0f1720;
    color: #e6edf3;
    border-radius: 10px;
    padding: 1.1rem 1.25rem;
    overflow-x: auto;
    font-size: .88rem;
    line-height: 1.7;
    margin: 1.2rem 0;
}
.tool-article pre code { background: none; color: inherit; padding: 0; font-size: inherit; }

.tool-related {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: .8rem;
    margin-top: 1rem;
}
.tool-related a {
    display: flex;
    align-items: center;
    gap: .7rem;
    border: 1px solid var(--border-subtle);
    border-radius: 11px;
    padding: .85rem 1rem;
    color: var(--ink-dark);
    text-decoration: none;
    background: var(--surface-card);
    transition: all .25s ease;
    min-width: 0;
}
.tool-related a:hover { border-color: var(--brand-blue); color: var(--brand-blue); }
.tool-related a i { color: var(--brand-blue); flex-shrink: 0; }
.tool-related a span { overflow-wrap: anywhere; }

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 991px) {
    .tool-shell { grid-template-columns: minmax(0, 1fr); }
    /* Phones and tablets: data, then results, then the prediction box. */
    .tool-inputs { display: contents; }
    .tool-panel-data    { order: 1; }
    .tool-panel-results { order: 2; }
    .tool-panel-predict { order: 3; }
    .tool-panel + .tool-panel { margin-top: 0; }
    .tool-kpis  { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 576px) {
    .tools-trust { padding: 1.5rem; }
    .tool-panel  { padding: 1.15rem; }
    .tool-row    { grid-template-columns: minmax(0, 1fr); }
    .tool-related { grid-template-columns: minmax(0, 1fr); }
    .tool-predict { grid-template-columns: minmax(0, 1fr); }
}
