/* Google Calculator force widget + its operator panels.
 * Loaded on both the Goo homepage (panels only, opened from the 9-dot waffle)
 * and the results page (the widget itself + panels). Scoped under gcalc-/gcset-/
 * gcmode- class names so it shares nothing with results.css / style.css.
 *
 * Cue rings mirror the standalone calculator: a faint white ring on the operator
 * and digit-count keys, sized by the --gc-cue-* vars gcalc.js writes from the
 * ring-size settings. Invisible to a spectator at arm's length, legible to the
 * operator up close. */
:root {
  --gc-cue-w: 3px;   --gc-cue-o: 0.51;
  --gc-cue-w-num: 3px; --gc-cue-o-num: 0.51;
  /* Light widget palette, to match the results page it sits on (see results.css).
     ONLY the .gcalc-* widget is themed — the .gcset-* operator panels below stay
     dark, because those are an operator surface, not part of the fake page.
     The cue ring is the one that MATTERS: it is the operator's secret mark, and a
     white ring on a light key is invisible, so it darkens with the theme. */
  --gc-screen-line: #dadce0;
  --gc-text: #202124;
  --gc-dim: #70757a;
  --gc-key: #f1f3f4;
  --gc-key-op: #e8eaed;
  --gc-key-press: #dee1e3;
  --gc-key-sel: #d7dbdd;
  --gc-eq: #1a73e8;
  --gc-eq-fg: #ffffff;
  --gc-eq-press: #1765cc;
  --gc-solver: #f1f3f4;
  --gc-seg-on: #e8eaed;
  --gc-cue-c: 0, 0, 0;
}
[data-theme="dark"] {
  --gc-screen-line: #5f6368;
  --gc-text: #e8eaed;
  --gc-dim: #9aa0a6;
  --gc-key: #363840;
  --gc-key-op: #2c303d;
  --gc-key-press: #454852;
  --gc-key-sel: #3a3f4d;
  --gc-eq: #a8c7fa;
  --gc-eq-fg: #062e6f;
  --gc-eq-press: #c7dbff;
  --gc-solver: #28292d;
  --gc-seg-on: #3c4043;
  --gc-cue-c: 255, 255, 255;
}

/* ---------------- widget (NO card chrome: sits straight on the page like real
   Google — only the display is outlined) ---------------- */
.gr-calc { margin: 6px 16px 0; }
.gcalc-card {
  max-width: 692px;
  color: var(--gc-text);
  font-family: 'Google Sans', 'Google Sans Text', Roboto, Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
.gcalc-screen {
  position: relative;
  min-height: 76px;
  border: 1px solid var(--gc-screen-line);
  border-radius: 12px;
  padding: 8px 18px 10px;
  margin-bottom: 12px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  overflow: hidden;
}
.gcalc-hist {
  position: absolute; top: 12px; left: 14px;
  background: none; border: 0; padding: 2px; margin: 0;
  color: var(--gc-dim); cursor: pointer; line-height: 0;
  -webkit-tap-highlight-color: transparent;
}
.gcalc-hist svg { display: block; }
.gcalc-expr {
  text-align: right; color: var(--gc-dim); font-size: 16px;
  min-height: 0; white-space: nowrap; overflow: hidden;
}
.gcalc-result {
  text-align: right; color: var(--gc-text); font-size: 42px; font-weight: 400;
  /* Google Sans Text (loaded by results.css) at 400 — the real calculator's font
     and weight. Not the heavier display face, not the system font. */
  font-family: 'Google Sans Text', Roboto, arial, sans-serif;
  line-height: 1.1; white-space: nowrap; overflow-x: auto; overflow-y: hidden;
  -ms-overflow-style: none; scrollbar-width: none;
}
.gcalc-result::-webkit-scrollbar { display: none; }

/* ---------------- keypad ---------------- */
.gcalc-pad {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 7px 6px;   /* tight, like real Google — minimal dead space between keys */
}
.gcalc-key {
  position: relative;
  height: 40px;
  border: 0; border-radius: 20px;   /* full pill */
  background: var(--gc-key); color: var(--gc-text);   /* number keys — the lighter shade */
  font-size: 20px; font-weight: 400;
  font-family: 'Google Sans Text', Roboto, arial, sans-serif;
  cursor: pointer;
  transition: background .12s ease;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
/* The ( ) % AC top row AND the right-column operators (÷ × − +) are the darker,
   cooler shade; only the number keys are the lighter one. */
.gcalc-key[data-k="paren"], .gcalc-key[data-k="percent"], .gcalc-fn,
.gcalc-op { background: var(--gc-key-op); color: var(--gc-text); }
.gcalc-eq { background: var(--gc-eq); color: var(--gc-eq-fg); font-weight: 400; }
.gcalc-key.press { background: var(--gc-key-press); }
.gcalc-eq.press { background: var(--gc-eq-press); }
.gcalc-key.selected { background: var(--gc-key-sel); }

/* Operator + digit-count cue rings (running-sum forces). */
.gcalc-key.cue { box-shadow: inset 0 0 0 var(--gc-cue-w) rgba(var(--gc-cue-c), var(--gc-cue-o)); }
.gcalc-key.cue-num { box-shadow: inset 0 0 0 var(--gc-cue-w-num) rgba(var(--gc-cue-c), var(--gc-cue-o-num)); }

/* 123 | Fx segmented pill, left-aligned like real Google. */
.gcalc-modes {
  display: inline-flex; align-items: stretch; margin: 14px 0 10px;
  border: 1px solid var(--gc-screen-line); border-radius: 999px; overflow: hidden;
}
.gcalc-modeseg { padding: 7px 24px; font-size: 15px; color: var(--gc-text); display: flex; align-items: center; }
.gcalc-modeseg.on { background: var(--gc-seg-on); }
.gcalc-modeseg + .gcalc-modeseg { border-left: 1px solid var(--gc-screen-line); }

.gcalc-solver {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; text-align: center;
  background: var(--gc-solver); border: 0; border-radius: 10px;
  color: var(--gc-text); font-size: 16px; font-family: inherit;
  padding: 13px; margin: 2px 0; cursor: default;
}
.gcalc-solver span { color: var(--gc-dim); font-size: 20px; line-height: 1; }
.gcalc-feedback { text-align: right; color: var(--gc-dim); font-size: 13px; padding: 6px 2px 2px; }

/* ---------------- settings panel + mode sheet ---------------- */
.gcset {
  position: fixed; inset: 0; z-index: 100000;
  background: #202124; color: #e8eaed;
  font-family: 'Google Sans Text', Roboto, Arial, sans-serif;
  transform: translateY(100%); transition: transform .28s cubic-bezier(.32,.72,0,1);
  display: flex; flex-direction: column;
  visibility: hidden;
}
.gcset.open { transform: translateY(0); visibility: visible; }
.gcset-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px calc(14px + env(safe-area-inset-top, 0px));
  padding-top: max(14px, env(safe-area-inset-top, 0px));
  border-bottom: 1px solid #3c4043;
}
.gcset-title { font-size: 18px; font-weight: 500; }
.gcset-done { background: none; border: 0; color: #8ab4f8; font-size: 16px; font-weight: 500; padding: 4px 6px; }
.gcset-body { flex: 1 1 auto; overflow-y: auto; padding: 8px 16px calc(40px + env(safe-area-inset-bottom, 0px)); -webkit-overflow-scrolling: touch; }
.gcset-section { font-size: 13px; font-weight: 500; color: #9aa0a6; text-transform: uppercase; letter-spacing: .04em; margin: 20px 4px 8px; }
.gcset-group { background: #303134; border-radius: 12px; overflow: hidden; }
.gcset-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 12px 14px; border-bottom: 1px solid #3c4043; min-height: 24px;
}
.gcset-row:last-child { border-bottom: 0; }
.gcset-col { flex-direction: column; align-items: stretch; }
.gcset-label { font-size: 15px; }
.gcset-sublabel, .gcset-shared { display: block; font-size: 12px; color: #9aa0a6; margin-top: 2px; }
.gcset-input {
  background: #202124; border: 1px solid #5f6368; border-radius: 8px;
  color: #e8eaed; font-size: 15px; padding: 9px 11px; font-family: inherit; width: 100%;
  margin-top: 6px;
}
.gcset-col > .gcset-label + .gcset-input, .gcset-col .gcset-input:first-child { margin-top: 8px; }
.gcset-hint { font-size: 12px; color: #9aa0a6; margin: 8px 6px 0; line-height: 1.4; }
.gcset-copy {
  align-self: flex-start; margin-top: 8px; background: #3c4043; border: 0; border-radius: 8px;
  color: #8ab4f8; font-size: 13px; padding: 8px 12px; font-family: inherit;
}
.gcset-copy.copied { color: #81c995; }

/* toggle switch */
.gcsw { position: relative; display: inline-block; width: 44px; height: 26px; flex: 0 0 auto; }
.gcsw input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; }
.gcslider { position: absolute; inset: 0; background: #5f6368; border-radius: 999px; transition: background .18s; }
.gcslider::before { content: ''; position: absolute; width: 20px; height: 20px; left: 3px; top: 3px; background: #e8eaed; border-radius: 50%; transition: transform .18s; }
.gcsw input:checked + .gcslider { background: #8ab4f8; }
.gcsw input:checked + .gcslider::before { transform: translateX(18px); background: #1a73e8; }

/* mode checks */
.gcmode-check { width: 22px; height: 22px; border-radius: 50%; border: 2px solid #5f6368; flex: 0 0 auto; position: relative; }
.gcmode-check.on { border-color: #8ab4f8; }
.gcmode-check.on::after { content: ''; position: absolute; width: 12px; height: 12px; border-radius: 50%; background: #8ab4f8; left: 3px; top: 3px; }

/* chips + steppers + segmented */
.gcchip-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.gcchip { background: #202124; border: 1px solid #5f6368; border-radius: 999px; color: #e8eaed; font-size: 13px; padding: 7px 12px; font-family: inherit; }
.gcchip.on { background: #8ab4f8; color: #202124; border-color: #8ab4f8; }
.gcstepper { display: inline-flex; align-items: center; gap: 4px; }
.gcstepper button { width: 32px; height: 32px; border: 0; border-radius: 8px; background: #3c4043; color: #e8eaed; font-size: 18px; }
.gcval { min-width: 34px; text-align: center; font-size: 15px; }
.gcseg { display: flex; gap: 6px; margin: 8px 0; flex-wrap: wrap; }
.gcseg button { flex: 1 1 auto; background: #202124; border: 1px solid #5f6368; border-radius: 8px; color: #e8eaed; font-size: 13px; padding: 8px; font-family: inherit; }
.gcseg button.on { background: #8ab4f8; color: #202124; border-color: #8ab4f8; }

/* quick mode picker */
.gcmode-sheet {
  position: fixed; inset: 0; z-index: 100001;
  background: rgba(0,0,0,.5); display: flex; align-items: flex-end;
  opacity: 0; visibility: hidden; transition: opacity .2s;
}
.gcmode-sheet.open { opacity: 1; visibility: visible; }
.gcmode-card {
  width: 100%; background: #303134; border-radius: 18px 18px 0 0;
  padding: 12px 12px calc(12px + env(safe-area-inset-bottom, 0px));
  font-family: 'Google Sans Text', Roboto, Arial, sans-serif;
}
.gcmode-title { text-align: center; color: #9aa0a6; font-size: 14px; padding: 8px 0 12px; }
.gcmode-opt {
  display: block; width: 100%; text-align: left; background: #202124; border: 0;
  color: #e8eaed; font-size: 16px; padding: 14px 16px; border-radius: 10px; margin-bottom: 8px; font-family: inherit;
}
.gcmode-opt.on { background: #8ab4f8; color: #202124; }
.gcmode-sub { display: block; font-size: 12px; color: #9aa0a6; margin-top: 2px; }
.gcmode-opt.on .gcmode-sub { color: #202124; }
.gcmode-cancel { display: block; width: 100%; background: #3c4043; border: 0; color: #e8eaed; font-size: 16px; padding: 14px; border-radius: 10px; margin-top: 4px; font-family: inherit; }
