/* ===================================================================
   iCloud Tools & Help

   Shared by the hub block and all twenty tool pages. Builds on
   backlink-maker.css (the bm-* design system) and adds only what the
   suite needs: the local-processing badge, drop zone, progress,
   notices, tables, stat tiles, bar charts, forms and result cards.

   Scoped under .ic. Accent is the A-Z palette colour for the letter I
   (AzColorPalette.PrimaryForLetter('I')), passed in as --ic-accent.
   No Apple gradients, glyphs or colours: the look is the A2Z one.
   =================================================================== */

.ic {
    --ic-accent: #6085ef;
    --bm-accent: var(--ic-accent);
    --bm-accent-strong: color-mix(in srgb, var(--ic-accent) 72%, #000);
    --bm-accent-soft: color-mix(in srgb, var(--ic-accent) 10%, #fff);
    --bm-accent-ring: color-mix(in srgb, var(--ic-accent) 40%, transparent);
    --ic-ok: #17864f; --ic-ok-soft: #e7f6ee;
    --ic-warn: #8f5600; --ic-warn-soft: #fff2dc;
    --ic-bad: #c62f2f; --ic-bad-soft: #fdeeee;
    --ic-t0: #5b8def; --ic-t1: #7b5bf0; --ic-t2: #17a2b8; --ic-t3: #f0655f;
    --ic-t4: #e0a100; --ic-t5: #2fa36b; --ic-t6: #c2569b; --ic-t7: #7a8699;
}

/* Browsers without color-mix fall back to the fixed bm blue shades. */
@supports not (color: color-mix(in srgb, red 50%, blue)) {
    .ic { --bm-accent-strong: #3a5cc2; --bm-accent-soft: #eef2fe; --bm-accent-ring: rgba(96, 133, 239, .35); }
}

.ic :where(section) { padding: 0; overflow: visible; }
.ic .visually-hidden { position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important; margin: -1px !important; overflow: hidden !important; clip: rect(0, 0, 0, 0) !important; white-space: nowrap !important; border: 0 !important; }
.ic :is(a, button, input, select, textarea, summary, [tabindex]):focus-visible { outline: 3px solid var(--bm-accent-ring); outline-offset: 2px; }

/* ---------- Hero ---------- */
.ic-crumbs ol { display: flex; flex-wrap: wrap; gap: 4px; margin: 0 0 12px; padding: 0; list-style: none; font-size: .84rem; color: var(--bm-ink-3); }
.ic-crumbs li { display: inline-flex; align-items: center; gap: 4px; }
.ic-crumbs li + li::before { content: "\203A"; color: var(--bm-ink-3); }
.ic-crumbs a { color: var(--bm-accent-strong); text-decoration: none; }
.ic-crumbs a:hover { text-decoration: underline; }

.ic-privacy {
    display: inline-flex; gap: 10px; align-items: flex-start; margin: 16px 0 0; padding: 10px 14px;
    border-radius: 12px; background: var(--ic-ok-soft); color: var(--ic-ok); font-weight: 600; font-size: .92rem; line-height: 1.45;
}
.ic-privacy i { margin-top: 3px; }

/* ---------- Bench ---------- */
.ic-main { margin-top: 8px; }
.ic-limits {
    margin: 0 0 14px; padding: 12px 16px; border: 1px solid var(--bm-line); border-left: 4px solid var(--bm-accent);
    border-radius: 0 12px 12px 0; background: var(--bm-surface); font-size: .9rem; color: var(--bm-ink-2);
}
.ic-limits-title { margin: 0 0 6px; font-weight: 800; color: var(--bm-ink); }
.ic-limits ul { margin: 0; padding-left: 20px; }
.ic-limits li { margin: 2px 0; }

.ic-bench {
    background: var(--bm-surface); border: 1px solid var(--bm-line); border-radius: var(--bm-r-lg);
    box-shadow: var(--bm-shadow); padding: 20px; min-width: 0;
}
.ic-bench > * + * { margin-top: 16px; }
@media (max-width: 575px) { .ic-bench { padding: 14px; border-radius: 14px; } }

.ic-empty { padding: 24px; text-align: center; color: var(--bm-ink-3); border: 1px dashed var(--bm-line); border-radius: 14px; }

/* ---------- Drop zone ---------- */
.ic-drop {
    position: relative; display: flex; flex-direction: column; align-items: center; text-align: center; gap: 6px;
    padding: 28px 16px; border: 2px dashed color-mix(in srgb, var(--bm-accent) 45%, var(--bm-line));
    border-radius: 16px; background: linear-gradient(180deg, var(--bm-accent-soft), var(--bm-surface));
    transition: border-color .16s, background-color .16s, transform .16s;
}
.ic-drop.is-over { border-color: var(--bm-accent); transform: scale(1.005); background: var(--bm-accent-soft); }
.ic-drop-icon { display: grid; place-items: center; width: 56px; height: 56px; border-radius: 16px; background: var(--bm-surface); color: var(--bm-accent-strong); font-size: 1.5rem; box-shadow: var(--bm-shadow); }
.ic-drop-title { margin: 6px 0 0; font-size: 1.08rem; font-weight: 800; color: var(--bm-ink); }
.ic-drop-hint { margin: 0; font-size: .88rem; color: var(--bm-ink-3); max-width: 60ch; }
.ic-drop-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 10px; }
.ic-drop-actions .bm-btn-primary { min-height: 46px; }

/* ---------- Buttons / toolbar ---------- */
.ic-toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.ic-toolbar.is-end { justify-content: flex-end; }
.ic-toolbar .ic-spacer { flex: 1 1 auto; }
.ic .bm-btn i { font-size: .95em; }

/* ---------- Forms ---------- */
.ic-form { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr)); }
.ic-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.ic-field label, .ic-field .ic-label { font-weight: 700; font-size: .88rem; color: var(--bm-ink); }
.ic-field .ic-help { font-size: .8rem; color: var(--bm-ink-3); margin: 0; }
.ic-field input[type="number"], .ic-field input[type="text"], .ic-field input[type="search"], .ic-field input[type="date"],
.ic-field input[type="datetime-local"], .ic-field input[type="time"], .ic-field select, .ic-field textarea {
    width: 100%; min-height: 42px; padding: 8px 12px; border: 1px solid var(--bm-line); border-radius: 10px;
    background: var(--bm-surface); color: var(--bm-ink); font: inherit; font-size: .95rem;
}
.ic-field input:focus, .ic-field select:focus, .ic-field textarea:focus { border-color: var(--bm-accent); outline: 3px solid var(--bm-accent-ring); outline-offset: 0; }
.ic-field input[aria-invalid="true"] { border-color: var(--ic-bad); }
.ic-inputgroup { display: flex; gap: 6px; min-width: 0; }
.ic-inputgroup > input { flex: 1 1 auto; min-width: 0; }
.ic-inputgroup > select { flex: 0 0 auto; width: auto; }
.ic-fieldset { border: 1px solid var(--bm-line); border-radius: 14px; padding: 14px; margin: 0; min-width: 0; }
.ic-fieldset legend { float: none; width: auto; padding: 0 6px; margin: 0; font-size: .95rem; font-weight: 800; color: var(--bm-ink); }
.ic-check { display: flex; gap: 10px; align-items: flex-start; font-size: .92rem; color: var(--bm-ink-2); }
.ic-check input { margin-top: 4px; width: 18px; height: 18px; accent-color: var(--bm-accent); flex: 0 0 auto; }
.ic-error-text { color: var(--ic-bad); font-size: .82rem; margin: 0; }

/* Segmented control (radio buttons styled as a switch). */
.ic-seg { display: inline-flex; flex-wrap: wrap; gap: 4px; padding: 4px; border: 1px solid var(--bm-line); border-radius: 12px; background: var(--bm-bg); }
.ic-seg label { position: relative; margin: 0; }
.ic-seg input { position: absolute; opacity: 0; inset: 0; }
.ic-seg span { display: inline-block; padding: 7px 12px; border-radius: 9px; font-weight: 700; font-size: .86rem; color: var(--bm-ink-2); cursor: pointer; }
.ic-seg input:checked + span { background: var(--bm-surface); color: var(--bm-accent-strong); box-shadow: var(--bm-shadow); }
.ic-seg input:focus-visible + span { outline: 3px solid var(--bm-accent-ring); }

/* ---------- Progress ---------- */
.ic-progress { padding: 12px 14px; border-radius: 14px; background: var(--bm-bg); border: 1px solid var(--bm-line); }
.ic-progress-row { display: flex; gap: 10px; align-items: center; }
.ic-progress-bar { flex: 1 1 auto; height: 10px; border-radius: 999px; background: var(--bm-line-2); overflow: hidden; }
.ic-progress-fill { display: block; height: 100%; width: 0; border-radius: inherit; background: linear-gradient(90deg, var(--bm-accent), color-mix(in srgb, var(--bm-accent) 60%, #7b5bf0)); transition: width .2s; }
.ic-progress.is-done .ic-progress-fill { background: var(--ic-ok); }
.ic-progress.is-failed .ic-progress-fill { background: var(--ic-warn); }
.ic-progress-text { margin: 8px 0 0; font-size: .88rem; color: var(--bm-ink-2); }

/* ---------- Notices ---------- */
.ic-notice { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 12px; font-size: .92rem; line-height: 1.5; background: var(--bm-accent-soft); color: var(--bm-accent-strong); }
.ic-notice i { margin-top: 4px; }
.ic-notice p { margin: 0; }
.ic-notice ul { margin: 6px 0 0; padding-left: 18px; }
.ic-notice-title { font-weight: 800; }
.ic-notice.is-ok { background: var(--ic-ok-soft); color: var(--ic-ok); }
.ic-notice.is-warn { background: var(--ic-warn-soft); color: var(--ic-warn); }
.ic-notice.is-error { background: var(--ic-bad-soft); color: var(--ic-bad); }
.ic-notice-body { min-width: 0; overflow-wrap: anywhere; }

/* ---------- Stats ---------- */
.ic-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(160px, 100%), 1fr)); gap: 10px; margin: 0; }
.ic-stat { padding: 14px; border: 1px solid var(--bm-line); border-radius: 14px; background: var(--bm-surface); min-width: 0; }
.ic-stat dt { font-size: .78rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--bm-ink-3); }
.ic-stat dd { margin: 4px 0 0; font-size: 1.35rem; font-weight: 800; color: var(--bm-ink); overflow-wrap: anywhere; }
.ic-stat-hint { margin: 4px 0 0; font-size: .8rem; color: var(--bm-ink-3); }
.ic-stat.is-ok dd { color: var(--ic-ok); }
.ic-stat.is-warn dd { color: var(--ic-warn); }
.ic-stat.is-bad dd { color: var(--ic-bad); }
.ic-stat.is-accent { border-color: var(--bm-accent); background: var(--bm-accent-soft); }

/* ---------- Bars ---------- */
.ic-bars { margin: 0; }
.ic-bars figcaption { font-weight: 800; color: var(--bm-ink); margin-bottom: 8px; }
.ic-bar-row { display: grid; grid-template-columns: minmax(90px, 160px) 1fr auto; gap: 10px; align-items: center; padding: 4px 0; font-size: .88rem; }
.ic-bar-label { color: var(--bm-ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ic-bar-track { height: 12px; background: var(--bm-line-2); border-radius: 999px; overflow: hidden; }
.ic-bar-fill { display: block; height: 100%; border-radius: inherit; transition: width .35s var(--bm-ease); }
.ic-bar-value { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--bm-ink); white-space: nowrap; }
.tone-0 { background: var(--ic-t0); } .tone-1 { background: var(--ic-t1); } .tone-2 { background: var(--ic-t2); } .tone-3 { background: var(--ic-t3); }
.tone-4 { background: var(--ic-t4); } .tone-5 { background: var(--ic-t5); } .tone-6 { background: var(--ic-t6); } .tone-7 { background: var(--ic-t7); }
@media (max-width: 480px) { .ic-bar-row { grid-template-columns: 1fr auto; } .ic-bar-track { grid-column: 1 / -1; grid-row: 2; } }

/* ---------- Tables ---------- */
.ic-table-wrap { overflow-x: auto; border: 1px solid var(--bm-line); border-radius: 12px; max-width: 100%; }
.ic-table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.ic-table th, .ic-table td { padding: 8px 10px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--bm-line-2); overflow-wrap: anywhere; max-width: 36ch; }
.ic-table thead th { position: sticky; top: 0; background: var(--bm-bg); color: var(--bm-ink); font-weight: 800; white-space: nowrap; z-index: 1; }
.ic-table tbody tr:hover { background: var(--bm-accent-soft); }
.ic-table .is-num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ic-table-empty { text-align: center !important; color: var(--bm-ink-3); padding: 18px !important; }
.ic-sort { border: 0; background: none; padding: 0; font: inherit; font-weight: 800; color: inherit; cursor: pointer; }
.ic-sort::after { content: " \2195"; color: var(--bm-ink-3); font-weight: 400; }
[aria-sort="ascending"] .ic-sort::after { content: " \2191"; color: var(--bm-accent-strong); }
[aria-sort="descending"] .ic-sort::after { content: " \2193"; color: var(--bm-accent-strong); }
.ic-pager { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: center; margin-top: 10px; }
.ic-pager-status { font-size: .85rem; color: var(--bm-ink-3); }

/* ---------- Cards and results ---------- */
.ic-results-head { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; }
.ic-results-head h3 { margin: 0; font-size: 1.1rem; }
.ic-cards { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(min(240px, 100%), 1fr)); margin: 0; padding: 0; list-style: none; }
.ic-card { position: relative; padding: 14px; border: 1px solid var(--bm-line); border-radius: 14px; background: var(--bm-surface); min-width: 0; overflow-wrap: anywhere; }
.ic-card h4 { margin: 0 0 4px; font-size: 1rem; color: var(--bm-ink); }
.ic-card .ic-meta { margin: 2px 0; font-size: .84rem; color: var(--bm-ink-3); }
.ic-card.is-selected { border-color: var(--bm-accent); box-shadow: 0 0 0 3px var(--bm-accent-ring); }
.ic-thumb { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 10px; background: var(--bm-line-2); }
.ic-group { border: 1px solid var(--bm-line); border-radius: 16px; padding: 14px; background: var(--bm-bg); }
.ic-group + .ic-group { margin-top: 12px; }
.ic-group-head { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.ic-badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 999px; font-size: .76rem; font-weight: 800; background: var(--bm-accent-soft); color: var(--bm-accent-strong); white-space: nowrap; }
.ic-badge.is-ok { background: var(--ic-ok-soft); color: var(--ic-ok); }
.ic-badge.is-warn { background: var(--ic-warn-soft); color: var(--ic-warn); }
.ic-badge.is-bad { background: var(--ic-bad-soft); color: var(--ic-bad); }
.ic-kv { display: grid; grid-template-columns: minmax(100px, max-content) 1fr; gap: 4px 12px; margin: 0; font-size: .88rem; }
.ic-kv dt { font-weight: 700; color: var(--bm-ink-2); }
.ic-kv dd { margin: 0; color: var(--bm-ink); overflow-wrap: anywhere; }

.ic-tabs { display: flex; flex-wrap: wrap; gap: 4px; border-bottom: 1px solid var(--bm-line); }
.ic-tab { border: 0; background: none; padding: 10px 14px; font: inherit; font-weight: 700; color: var(--bm-ink-3); border-bottom: 3px solid transparent; cursor: pointer; }
.ic-tab[aria-selected="true"] { color: var(--bm-accent-strong); border-bottom-color: var(--bm-accent); }

.ic-divider { border: 0; border-top: 1px solid var(--bm-line); margin: 18px 0; }

/* ---------- Related + disclaimer ---------- */
.ic-related { margin-top: 26px; }
.ic-related-head { display: flex; flex-wrap: wrap; gap: 8px; align-items: baseline; justify-content: space-between; }
.ic-related-head h2 { margin: 0; font-size: 1.25rem; }
.ic-related-grid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(min(230px, 100%), 1fr)); margin: 12px 0 0; padding: 0; list-style: none; }
.ic-related-card {
    display: flex; gap: 12px; align-items: center; padding: 12px; border: 1px solid var(--bm-line); border-radius: 14px;
    background: var(--bm-surface); color: var(--bm-ink); text-decoration: none; transition: transform .16s var(--bm-ease), border-color .16s;
}
.ic-related-card:hover { transform: translateY(-2px); border-color: var(--bm-accent); color: var(--bm-ink); }
.ic-related-icon { display: grid; place-items: center; flex: 0 0 40px; height: 40px; border-radius: 12px; background: var(--bm-accent-soft); color: var(--bm-accent-strong); }
.ic-related-text { display: flex; flex-direction: column; min-width: 0; font-size: .82rem; color: var(--bm-ink-3); }
.ic-related-text strong { font-size: .95rem; color: var(--bm-ink); }
.ic-disclaimer { margin: 18px 0 0; font-size: .8rem; color: var(--bm-ink-3); line-height: 1.5; }

/* ---------- Touch + motion ---------- */
@media (pointer: coarse) {
    .ic .bm-btn, .ic .ic-tab, .ic .ic-seg span, .ic .ic-sort { min-height: 44px; }
    .ic .ic-check input { width: 22px; height: 22px; }
}
@media (prefers-reduced-motion: reduce) {
    .ic *, .ic *::before, .ic *::after { transition: none !important; animation: none !important; }
}
@media print {
    .ic-hero .bm-chips, .ic-drop, .ic-toolbar, .ic-related, .bm-ad, .ic-limits, .ic-progress, .ic-noprint { display: none !important; }
    .ic-bench { box-shadow: none; border: 0; padding: 0; }
}
