/* HandCalc — scientific calculator (calculator.html, assets/sci-calc.js). Colours from site.css. */
.calc-page .section { padding: 34px 0 56px; }
.sc-wrap { display: grid; grid-template-columns: minmax(0, 440px) minmax(0, 320px); gap: 24px; justify-content: center; align-items: start; }

/* keypad, display and history lines keep the left-to-right layout on Arabic pages too */
.sc-calc, .sc-hist-list { direction: ltr; }
.sc-calc { background: var(--navy); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow-md); }
.sc-screen { background: #f3f7fc; border-radius: 10px; padding: 10px 14px 12px; margin-bottom: 14px; min-height: 128px; display: flex; flex-direction: column; justify-content: flex-end; }
.sc-status { display: flex; gap: 10px; align-items: center; font-size: 11px; font-weight: 700; letter-spacing: 0.06em; color: var(--ink-3); min-height: 16px; }
.sc-status .sc-2nd { visibility: hidden; color: #9a6b0a; }
.sc-status .sc-2nd.on { visibility: visible; }
.sc-status .sc-last { margin-left: auto; font-weight: 500; letter-spacing: 0; font-variant-numeric: tabular-nums; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 60%; }
.sc-prev { font-size: 13.5px; color: var(--ink-3); text-align: right; min-height: 20px; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.sc-expr { width: 100%; border: 0; background: transparent; text-align: right; font: 600 28px/1.25 var(--font-ui); color: var(--ink); font-variant-numeric: tabular-nums; padding: 2px 0; outline: none; caret-color: var(--c-m); }
.sc-expr::placeholder { color: var(--ink-3); opacity: 0.55; }
.sc-out { display: flex; justify-content: flex-end; align-items: baseline; gap: 10px; min-height: 22px; }
.sc-result { font-size: 16px; color: var(--ink-3); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; text-align: right; }
.sc-msg { font-size: 14px; font-weight: 600; color: var(--c-r); }
.sc-msg:empty { display: none; }

.sc-keys { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; }
.sc-key { height: 50px; border: 0; border-radius: 9px; font: 600 17px/1 var(--font-ui); cursor: pointer; color: var(--ink); background: #fff;
  box-shadow: 0 1px 0 rgba(0,0,0,0.25); transition: transform 80ms, background 120ms; -webkit-tap-highlight-color: transparent; touch-action: manipulation; user-select: none; }
.sc-key:active { transform: translateY(1px); }
.sc-key:focus-visible { outline: 3px solid var(--accent); outline-offset: 1px; }
.sc-key.num { font-size: 20px; }
.sc-key.num:hover { background: var(--surface-alt); }
.sc-key.fn { background: #2b4573; color: var(--on-dark); font-size: 15px; font-weight: 500; }
.sc-key.fn:hover { background: #355384; }
.sc-key.fn.on { background: var(--accent); color: var(--navy); font-weight: 700; }
.sc-key.op { background: #dfe7f3; color: var(--navy); font-size: 21px; }
.sc-key.op:hover { background: #d1dcec; }
.sc-key.clr { background: #f3d3cf; color: #8c2116; font-size: 15px; }
.sc-key.clr:hover { background: #efc4be; }
.sc-key.eq { background: var(--accent); color: var(--navy); font-size: 22px; }
.sc-key.eq:hover { background: var(--accent-2); }

.sc-hist { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 16px 10px; box-shadow: var(--shadow-sm); max-height: 520px; display: flex; flex-direction: column; }
.sc-hist-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.sc-hist-head h2 { font-size: 15px; font-weight: 700; color: var(--ink); }
.sc-hist-clear { border: 0; background: transparent; color: var(--ink-3); font: 500 13px var(--font-ui); cursor: pointer; padding: 4px 6px; border-radius: 6px; }
.sc-hist-clear:hover { background: var(--surface-alt); color: var(--ink); }
.sc-hist-empty { font-size: 13.5px; color: var(--ink-3); padding: 8px 0 14px; }
.sc-hist-list { list-style: none; overflow-y: auto; margin: 0 -6px; }
.sc-hist-list button { display: block; width: 100%; text-align: right; border: 0; background: transparent; padding: 8px 6px; border-radius: 8px; cursor: pointer; font-family: var(--font-ui); font-variant-numeric: tabular-nums; }
.sc-hist-list button:hover { background: var(--surface-alt); }
.sc-h-e { display: block; font-size: 12.5px; color: var(--ink-3); overflow-wrap: anywhere; }
.sc-h-r { display: block; font-size: 16px; font-weight: 600; color: var(--ink); overflow-wrap: anywhere; }

.sc-help { max-width: 784px; margin: 28px auto 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px 26px; box-shadow: var(--shadow-sm); }
.sc-help h2 { font-size: 16px; font-weight: 700; margin: 0 0 8px; color: var(--ink); }
.sc-help h2 + p, .sc-help p + h2 { margin-top: 0; }
.sc-help p { font-size: 14.5px; color: var(--ink-2); line-height: 1.6; margin-bottom: 14px; }
.sc-help p:last-child { margin-bottom: 0; }
.sc-help kbd { font-family: var(--font-ui); font-size: 12.5px; font-weight: 600; background: var(--surface-alt); border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 5px; padding: 1px 6px; color: var(--ink); }

@media (max-width: 820px) {
  .sc-wrap { grid-template-columns: minmax(0, 480px); }
  .sc-hist { max-height: 340px; }
}
@media (max-width: 480px) {
  .calc-page .page-head { padding: 16px 0 14px; }
  .calc-page .page-head h1 { font-size: 26px; margin-bottom: 4px; }
  .calc-page .page-head p { font-size: 14px; line-height: 1.5; }
  .calc-page .section { padding: 16px 0 40px; }
  .sc-screen { min-height: 108px; margin-bottom: 12px; }
  .sc-calc { padding: 12px; }
  .sc-keys { gap: 6px; }
  .sc-key { height: 48px; font-size: 15px; }
  .sc-key.fn { font-size: 13.5px; }
  .sc-expr { font-size: 25px; }
  .sc-help { padding: 18px; }
}

/* home page: link to the calculator under the section grid */
.calc-strip { display: flex; align-items: center; gap: 16px; margin-top: 22px; padding: 16px 20px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); color: var(--ink); transition: border-color 150ms, box-shadow 150ms; }
.calc-strip:hover { border-color: var(--line-2); box-shadow: var(--shadow-md); }
.calc-strip-icon { flex: none; width: 44px; height: 44px; border-radius: 10px; background: var(--navy); display: inline-flex; align-items: center; justify-content: center; }
.calc-strip-icon svg { width: 24px; height: 24px; }
.calc-strip-text { flex: 1; font-size: 14.5px; color: var(--ink-3); line-height: 1.5; }
.calc-strip-text strong { display: block; color: var(--ink); font-size: 15.5px; }
.calc-strip-go { flex: none; font-weight: 600; font-size: 14px; color: var(--ink); white-space: nowrap; }
@media (max-width: 560px) { .calc-strip-go { display: none; } }

/* pop-up on the calculator pages (site.js toolCalc), above the round button at the bottom corner: its own colours,
   since each calculator page has its own theme */
.hc-calc-pop {
  --navy: #0c1c38; --ink: #0c1e3e; --ink-2: #2c4670; --ink-3: #6c7f9c; --surface: #fff; --surface-alt: #f5f8fc;
  --line: #d6dfeb; --line-2: #9eb3cf; --on-dark: #eef3fb; --accent: #2f80ed; --accent-2: #5aa0f3; --c-m: #1565c0; --c-r: #c0392b;
  --radius: 12px; --shadow-sm: none; --shadow-md: none;
  --font-ui: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, system-ui, sans-serif;
  position: fixed; z-index: 1000; right: 20px; bottom: calc(84px + env(safe-area-inset-bottom, 0px)); width: 340px;
  max-height: calc(100vh - 104px); overflow-y: auto;
  background: #fff; color: var(--ink); font-family: var(--font-ui); font-size: 14px; line-height: 1.5; text-align: left;
  border: 1px solid #d6dfeb; border-radius: 16px; box-shadow: 0 24px 60px -18px rgba(12, 30, 62, 0.5);
}
.hc-calc-pop[hidden] { display: none; }
.hc-calc-pop * { box-sizing: border-box; }
.hc-calc-pop-head { display: flex; align-items: center; gap: 8px; padding: 6px 6px 6px 16px; border-bottom: 1px solid #e6edf6;
  cursor: move; user-select: none; touch-action: none; }
.hc-calc-pop-t { flex: 1; min-width: 0; font-size: 14px; font-weight: 700; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hc-calc-pop-tools { display: flex; gap: 2px; }
.hc-calc-pop-icon { width: 34px; height: 34px; padding: 0; display: inline-flex; align-items: center; justify-content: center; border: 0;
  border-radius: 8px; background: transparent; color: var(--ink-3); cursor: pointer; }
.hc-calc-pop-icon:hover { background: var(--surface-alt); color: var(--ink); }
.hc-calc-pop-icon:focus-visible { outline: 3px solid rgba(47, 128, 237, 0.35); }
.hc-calc-pop-icon svg { width: 17px; height: 17px; }
.hc-calc-pop-body { padding: 12px; }
.hc-calc-pop .sc-wrap { display: block; }
.hc-calc-pop .sc-calc { padding: 10px; border-radius: 12px; }
.hc-calc-pop .sc-screen { min-height: 92px; margin-bottom: 10px; padding: 8px 12px 10px; }
.hc-calc-pop .sc-expr { font-size: 24px; }
.hc-calc-pop .sc-keys { gap: 6px; }
.hc-calc-pop .sc-key { height: 40px; font-size: 15px; }
.hc-calc-pop .sc-key.num { font-size: 17px; }
.hc-calc-pop .sc-key.fn { font-size: 13.5px; }
.hc-calc-pop .sc-key.op, .hc-calc-pop .sc-key.eq { font-size: 19px; }
.hc-calc-pop .sc-hist { margin-top: 10px; max-height: 150px; padding: 10px 12px 4px; border-radius: 12px; }
.hc-calc-pop .sc-hist-head { margin-bottom: 2px; }
.hc-calc-pop .sc-hist-head h2 { font-size: 13px; margin: 0; }
.hc-calc-pop .sc-hist-empty { padding: 2px 0 8px; font-size: 13px; }
.hc-calc-pop .sc-hist-list { padding: 0; }
.hc-calc-pop .sc-hist-list button { padding: 5px 6px; }
.hc-calc-pop .sc-h-r { font-size: 14.5px; }
html[dir="rtl"] .hc-calc-pop { right: auto; left: 20px; text-align: right; }
@media (max-width: 640px) {
  .hc-calc-pop, html[dir="rtl"] .hc-calc-pop { top: auto !important; left: 0 !important; right: 0 !important; bottom: 0 !important;
    width: auto; max-height: 88vh; border-radius: 16px 16px 0 0; }
  .hc-calc-pop-head { cursor: default; }
  .hc-calc-pop .sc-key { height: 46px; }
  .hc-calc-pop .sc-hist { max-height: 120px; }
}
