/* Free tool pages. Loaded after styles.css and article.css, which own the
   tokens, the header and the article layout. Every rule is scoped to .tool
   (set on <body> of a tool page), so nothing here reaches the homepage or the
   guides. Logical properties keep the form correct in right-to-left Arabic. */

/* ------------------------------------------------------------- the form */

.tool .ipc{margin:0 0 56px;border:1px solid var(--line);background:var(--ink-deep)}
.tool .article-body .ipc-heading{margin:0;padding:24px 24px 0}
.tool .ipc-intro{margin:8px 0 0;padding:0 24px 22px;color:var(--muted);font-size:15px}
/* A 1px gap over a line-coloured background draws the grid rules between groups. */
.tool .ipc-form{display:grid;grid-template-columns:repeat(auto-fit,minmax(min(100%,300px),1fr));gap:1px;margin:0;background:var(--line);border-block:1px solid var(--line)}
.tool .ipc-form>fieldset{margin:0;padding:22px 24px 24px;border:0;min-width:0;background:var(--ink-deep)}
.tool .ipc-form>.ipc-wide{grid-column:1/-1}
.tool .ipc-tax{display:grid;grid-template-columns:repeat(auto-fit,minmax(min(100%,220px),1fr));gap:16px 24px}
.tool .ipc-tax .ipc-field{margin:0}
.tool code{font:.92em PlexMono,monospace;color:var(--text);overflow-wrap:anywhere}
.tool .ipc-form legend{margin:0 0 16px;padding:0;color:var(--accent);font:12px/1.6 PlexMono,monospace;letter-spacing:1.1px}
.tool .ipc-field{display:block;margin-block-end:16px}
.tool .ipc-field:last-child{margin-block-end:0}
.tool .ipc-field label,.tool .ipc-mode legend{display:block;font-size:14px;line-height:1.45;margin-block-end:8px;color:var(--text)}
.tool .ipc-field .ipc-hint{display:block;color:var(--muted);font-size:12.5px;line-height:1.45;margin-block-start:6px}
.tool .ipc-form input[type=text],.tool .ipc-form select{width:100%;min-height:48px;padding:0 14px;border:1px solid #63717b;border-radius:0;background:var(--ink);color:var(--text);font-size:16px;font-variant-numeric:tabular-nums}
.tool .ipc-form input[type=text]{direction:ltr;text-align:start}
html[dir=rtl] .tool .ipc-form input[type=text]{text-align:end}
.tool .ipc-form input[type=text]:hover,.tool .ipc-form select:hover{border-color:var(--muted)}
.tool .ipc-form input[type=text]:focus-visible,.tool .ipc-form select:focus-visible{outline:2px solid var(--accent);outline-offset:2px;border-color:var(--accent)}
.tool .ipc-form [aria-invalid=true]{border-color:var(--accent)}
.tool .ipc-error{margin:6px 0 0;color:var(--accent);font-size:13px;line-height:1.45}

/* Square segmented choices for the advance mode and the VAT presets. */
.tool .ipc-form .ipc-mode{margin:0 0 16px;padding:0;border:0}
.tool .ipc-form .ipc-mode legend{font:inherit;font-size:14px;letter-spacing:0;color:var(--text);margin-block-end:8px}
.tool .ipc-segments{display:flex;flex-wrap:wrap;gap:0}
.tool .ipc-segments label{position:relative;flex:1 1 auto;margin:0}
.tool .ipc-segments input{position:absolute;opacity:0;inset:0;margin:0;cursor:pointer}
.tool .ipc-segments span,.tool .ipc-presets button{display:flex;align-items:center;justify-content:center;min-height:44px;padding:0 14px;border:1px solid #63717b;margin-inline-end:-1px;background:transparent;color:var(--text);font-size:14px;cursor:pointer;text-align:center}
.tool .ipc-segments input:checked+span,.tool .ipc-presets button[aria-pressed=true]{background:var(--text);color:var(--ink);border-color:var(--text);position:relative;z-index:1}
.tool .ipc-segments input:focus-visible+span{outline:2px solid var(--accent);outline-offset:2px;position:relative;z-index:2}
.tool .ipc-segments label:hover span,.tool .ipc-presets button:hover{border-color:var(--accent)}
.tool .ipc-presets{display:flex;flex-wrap:wrap;margin-block-start:10px}
.tool .ipc-presets button{min-height:38px;padding:0 12px;font-size:13px}

/* -------------------------------------------------------------- the result */

.tool .ipc-result{padding:24px}
.tool .ipc-result .table-wrap{margin:0 0 18px;background:var(--ink)}
.tool .ipc-result table{transition:opacity .2s var(--ease)}
.tool .ipc-result table.is-stale{opacity:.4}
.tool .ipc-result td{text-align:end;white-space:nowrap;font-variant-numeric:tabular-nums}
.tool .ipc-result tr.ipc-subtotal th,.tool .ipc-result tr.ipc-total th{color:var(--text)}
.tool .ipc-result tr.ipc-total{background:#ffffff0a}
.tool .ipc-result tr.ipc-total td strong{color:var(--accent)}
.tool .ipc-explain{margin:0 0 18px;color:var(--text);max-width:72ch;line-height:1.6}
.tool .ipc-actions{display:flex;flex-wrap:wrap;align-items:center;gap:12px 16px}
.tool .ipc-copy{display:inline-flex;align-items:center;gap:18px;min-height:46px;padding:0 20px;background:#fff;color:var(--ink);font-size:14px;font-weight:500;border:0;border-radius:0}
.tool .ipc-copy:hover:not(:disabled){background:var(--accent)}
.tool .ipc-reset{min-height:46px;padding:0 18px;border:1px solid var(--line);background:transparent;color:var(--text);font-size:14px;border-radius:0}
.tool .ipc-reset:hover{border-color:var(--accent);color:var(--accent)}
.tool .ipc-status{color:var(--muted);font-size:13px}
.tool .ipc-note{margin:16px 0 0;color:var(--muted-ink);font:12px/1.6 PlexMono,monospace;letter-spacing:1px}
.tool .ipc-nojs{padding:16px 24px 0;color:var(--accent);font-size:14px}
.tool .ipc-lang{display:inline-block;margin-block-start:22px;color:var(--muted);font-size:14px;text-decoration:underline;text-underline-offset:3px}
.tool .ipc-lang:hover{color:var(--accent)}

/* Before the script runs, the live controls that need it are inert. */
html:not(.ipc-ready) .tool .ipc-actions,html:not(.ipc-ready) .tool .ipc-presets{display:none}

@media (max-width:600px){
  .tool .ipc-form fieldset,.tool .ipc-result{padding-inline:18px}
  .tool .ipc-result td{text-align:start}
  .tool .ipc-result .table-wrap{margin-inline:-1px}
}

@media (prefers-reduced-motion:reduce){.tool .ipc-result table{transition:none}}

/* ------------------------------------------------- right-to-left (Arabic)
   article.css and the header are written with physical sides for the
   left-to-right guides; these rules mirror them on Arabic tool pages only. */

html[dir=rtl] .tool .brand-descriptor{border-left:0;padding-left:0;border-right:1px solid var(--line);padding-right:26px}
html[dir=rtl] .tool .main-nav{margin-left:0;margin-right:auto}
html[dir=rtl] .tool .skip-link{left:auto;right:16px}
html[dir=rtl] .tool .answer{border-left:0;border-right:2px solid var(--accent)}
html[dir=rtl] .tool .article-body ul{padding-left:0;padding-right:20px}
html[dir=rtl] .tool .article caption,html[dir=rtl] .tool .article th,html[dir=rtl] .tool .article td{text-align:right}
html[dir=rtl] .tool .ipc-result td{text-align:left}

/* IBM Plex Sans and Plex Mono carry no Arabic glyphs, and letter-spacing
   breaks the joins of Arabic script, so Arabic text falls back to a system
   Arabic face with normal spacing. Latin words and figures stay in Plex. */
html[lang=ar] .tool{font-family:Plex,"IBM Plex Sans Arabic","Segoe UI",Tahoma,Arial,sans-serif}
html[lang=ar] .tool h1,html[lang=ar] .tool .article-body h2,html[lang=ar] .tool .article-body h3{font-family:Plex,"IBM Plex Sans Arabic","Segoe UI",Tahoma,Arial,sans-serif;letter-spacing:0;line-height:1.35}
html[lang=ar] .tool .eyebrow,html[lang=ar] .tool .brand-descriptor,html[lang=ar] .tool .article caption,html[lang=ar] .tool .article thead th,html[lang=ar] .tool .ipc-form legend,html[lang=ar] .tool .ipc-note,html[lang=ar] .tool .article-foot .updated,html[lang=ar] .tool .faq summary .expand-mark,html[lang=ar] .tool .article td::before{font-family:Plex,"IBM Plex Sans Arabic","Segoe UI",Tahoma,Arial,sans-serif;letter-spacing:0}
html[lang=ar] .tool p,html[lang=ar] .tool li{line-height:1.8}
@media (max-width:600px){
  html[dir=rtl] .tool .ipc-result td{text-align:right}
}

/* The header link to the English twin, as on the Arabic guides. Repeated
   here so the tool page does not depend on another page's stylesheet. */
html[dir=rtl] .tool .lang-switch{font:12px/1.6 PlexMono,monospace;letter-spacing:1px;color:var(--muted);padding:14px 0;white-space:nowrap}
html[dir=rtl] .tool .lang-switch:hover{color:var(--accent)}
@media (max-width:600px){
  html[dir=rtl] .tool .header-action{margin-left:0}
  html[dir=rtl] .tool .lang-switch{margin-right:auto}
}
