/* UniQuery Tools — shared component system.
   Same brand as theuniquery.com (crimson #C41E3A + navy #16234F from the
   site logo, cyan #00A8FF as the site's own H2 accent), but a deliberately
   different component language from the sibling anupress-tools plugin:
   tabs instead of pill toggles, a badge-style result instead of a full
   gradient banner, rounded-rect buttons instead of pills (pills are
   reserved for small data tags/chips only), and the cyan accent doing
   actual work (focus rings, grade chips) instead of sitting in a faint
   background overlay. Everything is scoped under .uqtool and uses --uq-*
   tokens. Zero external fonts/deps — Bengali fonts are expected to already
   load site-wide; system sans-serif is the fallback for a visitor without
   them. */

.uqtool {
  --uq-ink:   #16234F;   /* headings / strong — site navy */
  --uq-soft:  #4a4f63;   /* body text */
  --uq-mute:  #868da3;   /* meta / muted */
  --uq-bg:    #ffffff;   /* card / base */
  --uq-panel: #F7F4EF;   /* subtle warm-neutral panel */
  --uq-line:  #E5DFD2;   /* borders */
  --uq-brand: #C41E3A;   /* primary accent (crimson) */
  --uq-brand-ink: #16234F; /* brand for text on white (navy) */
  --uq-accent:#00A8FF;   /* secondary accent (site's cyan) — used for focus rings and the "solid" grade tier */
  --uq-good:  #1E9E62;   /* grade tier: A+ / A */
  --uq-caution:#C97C1F;  /* grade tier: C / D */
  --uq-danger:#D6373C;   /* grade tier: F — a distinct token from --uq-brand so it never reads as a brand action */
  --uq-grad:  linear-gradient(135deg, #C41E3A, #16234F);
  --uq-input-line: #D4C9B2;
  --uq-radius: 20px;
  --uq-radius-sm: 12px;

  color: var(--uq-ink);
  font-family: "Noto Sans Bengali", "Hind Siliguri", "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  font-size: 17px;
  line-height: 1.7;
  max-width: 720px;
  margin: 1.5rem auto;
  text-align: left;
  -webkit-font-smoothing: antialiased;
}
.uqtool *, .uqtool *::before, .uqtool *::after { box-sizing: border-box; }

/* ── Card ─────────────────────────────────────────────── */
/* A top accent bar (like a subject-folder tab) instead of anupress's plain
   white card, plus a larger 20px radius throughout. */
.uqtool__card {
  background: var(--uq-bg);
  border: 1px solid var(--uq-line);
  border-top: 5px solid var(--uq-brand);
  border-radius: var(--uq-radius);
  padding: clamp(22px, 4vw, 34px);
  box-shadow: rgba(22, 35, 79, .08) 0 14px 34px;
}
.uqtool__eyebrow {
  text-transform: uppercase; letter-spacing: .08em; font-size: 13px;
  font-weight: 700; color: var(--uq-brand); margin: 0 0 .5rem;
}
.uqtool__title {
  color: var(--uq-ink);
  font-size: clamp(23px, 3.8vw, 31px);
  font-weight: 800; line-height: 1.3; letter-spacing: -.01em;
  margin: 0 0 .3rem;
}
.uqtool__sub { color: var(--uq-soft); margin: 0 0 1.25rem; font-size: 15px; }

/* ── Segmented control, styled as tabs (not pills) ───────
   A bottom-border tab strip instead of a rounded pill switcher — reads
   more like a notebook/textbook section tab, distinct from anupress's
   pill-shaped segmented toggle. */
.uqtool__seg {
  display: flex; flex-wrap: wrap;
  border-bottom: 2px solid var(--uq-line);
  margin-bottom: 1.25rem; gap: 2px;
}
.uqtool__seg button {
  appearance: none; border: 0; background: transparent; color: var(--uq-soft);
  font: 700 14.5px/1 inherit; padding: .85rem 1.1rem; min-height: 46px;
  border-bottom: 3px solid transparent; margin-bottom: -2px;
  border-radius: 10px 10px 0 0;
  cursor: pointer; transition: all .18s;
}
.uqtool__seg button:hover:not([aria-pressed="true"]) {
  color: var(--uq-brand-ink); background: var(--uq-panel);
}
.uqtool__seg button[aria-pressed="true"] {
  color: var(--uq-brand-ink); background: var(--uq-panel);
  border-bottom-color: var(--uq-accent);
}

/* ── Controls grid ────────────────────────────────────── */
.uqtool__grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.uqtool__field { display: flex; flex-direction: column; gap: .45rem; min-width: 0; }
.uqtool__field--wide { grid-column: 1 / -1; }
.uqtool__field label { font-weight: 700; font-size: 15px; color: var(--uq-ink); }

/* The native `hidden` attribute maps to a user-agent-stylesheet `display:none`,
   and author-stylesheet rules always win over user-agent rules regardless of
   specificity, so `.uqtool__grid`/`.uqtool__field`/`.uqtool__row`/
   `.uqtool__actions`/`.uqtool__pill`'s own `display` declarations above silently
   defeat `hidden` on any element carrying one of these classes. This re-asserts
   `display:none` at higher specificity so `hidden` actually hides the element. */
.uqtool__grid[hidden],
.uqtool__field[hidden],
.uqtool__row[hidden],
.uqtool__actions[hidden],
.uqtool__pill[hidden] { display: none; }
/* `.uqtool select` below sets its own `display:flex` (needed for the
   Chromium vertical-centering fix), which is exactly this same trap: any
   tool that toggles a <select>'s `hidden` attribute (e.g. a grade/marks
   mode switch) would find the select never actually disappears. */
.uqtool select[hidden] { display: none; }

/* Checkbox row, e.g. option toggles under a field label. Selector uses two
   classes so it outranks `.uqtool__field label`'s bold field-title style. */
.uqtool__field .uqtool__check {
  display: flex; align-items: center; gap: 8px; cursor: pointer;
  font-weight: 500; user-select: none; margin-top: 2px;
}
.uqtool__check input[type="checkbox"] {
  width: 18px; height: 18px; margin: 0; cursor: pointer; accent-color: var(--uq-brand);
}
.uqtool__check span { font-size: 14px; color: var(--uq-soft); }

/* Range slider — consistent look across Chrome, Firefox, Safari. Used by any
   tool with an [input type="range"]; each tool needs a thumb rule per engine
   because they don't share a common pseudo-element. */
.uqtool input[type="range"] {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 6px; padding: 0; margin: 8px 0 4px;
  background: var(--uq-line); border-radius: 999px; outline: none; border: 0;
}
.uqtool input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--uq-brand); cursor: pointer;
  box-shadow: 0 2px 6px rgba(196, 30, 58, .35);
  border: 2px solid #fff;
}
.uqtool input[type="range"]::-moz-range-thumb {
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--uq-brand); cursor: pointer;
  box-shadow: 0 2px 6px rgba(196, 30, 58, .35);
  border: 2px solid #fff;
}

.uqtool input[type="text"],
.uqtool input[type="number"],
.uqtool input[type="month"],
.uqtool input[type="date"],
.uqtool input[type="search"],
.uqtool select,
.uqtool textarea {
  width: 100%; font: 400 16px/1.4 inherit; color: var(--uq-ink);
  background: #fff; border: 1px solid var(--uq-input-line);
  border-radius: var(--uq-radius-sm); padding: 14px 16px; transition: all .2s;
}
.uqtool textarea { font-family: ui-monospace, Consolas, monospace; resize: vertical; }
/* Cyan focus ring (not crimson) — crimson stays reserved for brand/CTA
   surfaces, cyan marks "you are here" on any interactive control. */
.uqtool input:focus, .uqtool select:focus, .uqtool textarea:focus, .uqtool button:focus-visible {
  outline: none; border-color: var(--uq-accent);
  box-shadow: rgba(0, 168, 255, .18) 0 0 0 4px;
}
/* Selects: even with appearance:none, Chromium's internal value box for a
   <select> doesn't reliably honour line-height/padding for vertical centering
   (a long-standing shadow-DOM quirk). Fixing it needs an EXPLICIT height plus
   flex centering, which controls the internal box directly instead of
   relying on font-metric math. Padding is horizontal-only here; height +
   align-items do the rest. */
.uqtool select {
  appearance: none; -webkit-appearance: none; -moz-appearance: none;
  display: flex; align-items: center;
  height: 48px;
  padding: 0 42px 0 16px;
  line-height: normal;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path d='M1 1l5 5 5-5' fill='none' stroke='%2316234F' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/></svg>");
  background-repeat: no-repeat;
  background-position: right 16px center;
  background-size: 11px 7px;
}
.uqtool select::-ms-expand { display: none; }
/* Prefix/suffix input group: e.g. a unit label sits in its own box beside
   the field, so it never overlaps the value. */
.uqtool__input-affix {
  display: flex; align-items: stretch; background: #fff;
  border: 1px solid var(--uq-input-line); border-radius: var(--uq-radius-sm);
  overflow: hidden; transition: all .2s;
}
.uqtool__input-affix:focus-within {
  border-color: var(--uq-accent); box-shadow: rgba(0, 168, 255, .18) 0 0 0 4px;
}
.uqtool__affix {
  display: flex; align-items: center; padding: 0 12px;
  background: var(--uq-panel); color: var(--uq-soft); font-weight: 600;
  border-right: 1px solid var(--uq-input-line); white-space: nowrap;
}
/* Extra .uqtool prefix raises specificity above `.uqtool input[type=...]`
   so the reset actually wins (otherwise the inner field keeps its own border). */
.uqtool .uqtool__input-affix input {
  flex: 1; min-width: 0; border: 0; border-radius: 0; padding: 14px 16px; background: transparent;
}
.uqtool .uqtool__input-affix input:focus { border: 0; box-shadow: none; }

/* ── Result — a compact badge, not a full-width gradient banner ──
   .uqtool__result-head/.uqtool__result-big/.uqtool__result-label/
   .uqtool__result-actions are shared hooks that tools-common.js also
   targets (copy/share buttons, aria-live, the update pulse), so the
   element structure stays identical to the sibling plugin — only the
   visual treatment changes here. */
.uqtool__result { margin-top: 1.5rem; border: 1px solid var(--uq-line); border-radius: var(--uq-radius); overflow: hidden; background: var(--uq-bg); }
.uqtool__result-head {
  background: var(--uq-panel); padding: 1.3rem 1.3rem 1.1rem;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
  border-bottom: 1px dashed var(--uq-line);
}
.uqtool__result-label { font-weight: 700; font-size: 14px; color: var(--uq-soft); }
.uqtool__result-big {
  display: inline-block;
  font-size: clamp(26px, 5.5vw, 36px); font-weight: 800; letter-spacing: -.01em;
  font-variant-numeric: tabular-nums;
  color: #fff; background: var(--uq-grad);
  padding: 10px 22px; border-radius: 16px;
  box-shadow: rgba(196, 30, 58, .3) 0 8px 20px;
}
.uqtool__rows { padding: .2rem 1.3rem .6rem; background: var(--uq-bg); }
.uqtool__row { display: flex; justify-content: space-between; gap: 1rem; padding: .75rem 0; border-bottom: 1px dashed var(--uq-line); }
.uqtool__row:last-child { border-bottom: 0; }
.uqtool__row span:first-child { color: var(--uq-soft); }
.uqtool__row span:last-child { font-weight: 700; font-variant-numeric: tabular-nums; color: var(--uq-ink); }

/* ── Tables ─────────────────────────────────────────────
   Rounded "row chip" spacing (border-spacing, not border-collapse) so
   each row reads as its own soft card on a panel tint — distinct from
   anupress's dense bordered table. */
.uqtool__table { width: 100%; border-collapse: separate; border-spacing: 0 6px; margin-top: .8rem; font-size: 15px; }
.uqtool__table th { padding: 6px 12px; text-align: right; font-weight: 700; font-size: 12.5px; color: var(--uq-mute); text-transform: uppercase; letter-spacing: .04em; }
.uqtool__table th:first-child { text-align: left; }
.uqtool__table td { padding: 12px; text-align: right; background: var(--uq-panel); font-variant-numeric: tabular-nums; }
.uqtool__table td:first-child { text-align: left; border-radius: 10px 0 0 10px; font-weight: 600; color: var(--uq-ink); }
.uqtool__table td:last-child { border-radius: 0 10px 10px 0; }
.uqtool__table-wrap { overflow-x: auto; }

/* Small colored grade-tier chip inside a table cell (used by the GPA
   calculator's subject breakdown; any future tool with a graded result
   can reuse it). Color alone never carries the meaning — the grade
   letter is always the chip's own text. */
.uqtool__grade-chip {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 46px; padding: 3px 10px; border-radius: 999px;
  font-weight: 800; font-size: 13px; color: #fff;
}
.uqtool__grade-chip--good { background: var(--uq-good); }
.uqtool__grade-chip--ok { background: var(--uq-accent); }
.uqtool__grade-chip--caution { background: var(--uq-caution); }
.uqtool__grade-chip--bad { background: var(--uq-danger); }

/* ── Sections / notes / faq / embed ───────────────────── */
.uqtool__section { margin-top: 1.7rem; }
.uqtool__section h3 { font-size: 20px; color: var(--uq-ink); margin: 0 0 .5rem; font-weight: 700; letter-spacing: -.01em; }
.uqtool__section p { margin: 0 0 .75rem; color: var(--uq-soft); }
.uqtool__note { color: var(--uq-mute); font-size: 14px; }
.uqtool__callout {
  background: #eaf6ff; border: 1px solid #cfe9f8; border-radius: var(--uq-radius-sm);
  padding: 14px 18px; font-size: 15px; color: var(--uq-soft); margin-top: .9rem;
}
.uqtool__callout b { color: var(--uq-ink); }

/* FAQ marker is a circular "?" badge, not a +/− glyph — a small nod to
   the fact this is a student-facing Q&A, not a settings accordion. */
.uqtool__faq details, .uqtool__embed {
  border: 1px solid var(--uq-line); border-radius: var(--uq-radius-sm); padding: 2px 18px;
  margin-top: .7rem; background: var(--uq-bg);
}
.uqtool__faq summary, .uqtool__embed summary {
  cursor: pointer; font-weight: 700; color: var(--uq-ink); padding: 13px 0;
  list-style: none; display: flex; align-items: center; gap: 10px;
}
.uqtool__faq summary::-webkit-details-marker, .uqtool__embed summary::-webkit-details-marker { display: none; }
.uqtool__faq summary::before, .uqtool__embed summary::before {
  content: "?"; flex: none; display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--uq-panel); color: var(--uq-brand); font-weight: 800; font-size: 13px;
  transition: all .18s;
}
.uqtool__faq details[open] summary::before, .uqtool__embed[open] summary::before {
  background: var(--uq-brand); color: #fff;
}
.uqtool__faq details p { padding: 0 0 .9rem 32px; margin: 0; color: var(--uq-soft); }
.uqtool__embed-code { width: 100%; margin: .3rem 0 .7rem; font-size: 13px; }

/* ── Buttons / pills / footer ─────────────────────────── */
/* Rounded-rect, not pill — pills (999px) are reserved for small data tags
   and grade chips only, so an interactive button never gets mistaken for
   a passive label. */
.uqtool__btn {
  appearance: none; cursor: pointer; display: inline-flex; align-items: center; gap: 8px;
  font: 700 15px/1 inherit; color: #fff; background: var(--uq-brand);
  border: 0; border-radius: var(--uq-radius-sm); padding: 13px 24px; transition: all .2s;
}
.uqtool__btn:hover { transform: translateY(-1px); box-shadow: rgba(196, 30, 58, .25) 0 8px 22px; }
.uqtool__btn--ghost { background: var(--uq-panel); color: var(--uq-brand-ink); border: 1px solid var(--uq-line); }
.uqtool__btn--sm { font-size: 13px; padding: 9px 16px; }
.uqtool__pill { display: inline-block; background: var(--uq-panel); border: 1px solid var(--uq-line); border-radius: 999px; padding: 2px 10px; font-size: 13px; font-weight: 600; color: var(--uq-soft); margin: 2px; }
.uqtool__foot { margin-top: 1.1rem; font-size: 14px; color: var(--uq-mute); }
.uqtool__foot a { color: var(--uq-brand); }

/* Row of action buttons below a tool's main controls (copy/download/clear/etc). */
.uqtool__actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 1rem; }

/* Label above a grouped sub-block inside a card (a bordered .uqtool__rows box,
   etc). Not a section <h3> — smaller, sits inside the card. */
.uqtool__section-label {
  display: block; font-weight: 700; font-size: 15px; color: var(--uq-ink); margin-bottom: .5rem;
}

/* Small inline counter next to a field label. */
.uqtool__char-count { font-weight: 500; color: var(--uq-mute); font-size: 12.5px; margin-left: 6px; }

/* Small inline unit suffix next to a bare number input. */
.uqtool__unit-label { font-size: 13px; color: var(--uq-mute); font-weight: 500; }

/* ── Shared enhancements (tools-common.js injects these) ──
   The result head is now a light panel, not a dark gradient, so the
   copy/share buttons need light-surface styling: outlined chip that
   fills with the cyan accent on hover, instead of translucent white. */
.uqtool__result-actions {
  display: inline-flex; align-items: center; gap: 8px; flex: none;
}
.uqtool__copy-result {
  appearance: none; cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
  font: 700 12.5px/1 inherit; color: var(--uq-brand-ink);
  background: #fff; border: 1px solid var(--uq-line); border-radius: 999px; padding: 7px 12px;
  transition: all .15s; flex: none;
}
.uqtool__copy-result:hover { border-color: var(--uq-accent); background: var(--uq-accent); color: #fff; }
.uqtool__copy-result:active { transform: scale(.96); }
.uqtool__copy-result svg { width: 13px; height: 13px; display: block; }
.uqtool__copy-result .uq-ic-check { display: none; }
.uqtool__copy-result.is-copied .uq-ic-copy { display: none; }
.uqtool__copy-result.is-copied .uq-ic-check { display: block; }
.uqtool__copy-result.is-copied { border-color: var(--uq-good); background: var(--uq-good); color: #fff; }

@keyframes uqResultIn { from { opacity: .45; } to { opacity: 1; } }
.uqtool__result-big.is-updated { animation: uqResultIn .3s ease-out; }

/* ── Modal (native <dialog>) — used by the PDF-certificate name prompt
   and reusable by any future tool that needs a small confirm dialog. ── */
.uqtool__modal {
  border: 1px solid var(--uq-line);
  border-top: 5px solid var(--uq-brand);
  border-radius: var(--uq-radius);
  padding: 26px 28px;
  max-width: 380px;
  width: calc(100% - 40px);
  box-shadow: rgba(22, 35, 79, .25) 0 24px 60px;
  color: var(--uq-ink);
  font-family: inherit;
}
.uqtool__modal::backdrop { background: rgba(22, 35, 79, .45); }
.uqtool__modal h3 { margin: 0 0 1rem; font-size: 19px; color: var(--uq-ink); font-weight: 800; }
.uqtool__modal .uqtool__field { margin-bottom: .3rem; }
.uqtool__modal .uqtool__actions { margin-top: 1.2rem; }

/* ── Related-tools strip (rendered by the shortcode) ───── */
.uqtool--related { margin-top: -.4rem; }
.uqtool__related-label {
  display: block; font-weight: 600; font-size: 14px;
  color: var(--uq-mute); margin-bottom: .5rem;
}
.uqtool--related a {
  display: inline-flex; align-items: center; background: var(--uq-panel); border: 1px solid var(--uq-line);
  border-radius: var(--uq-radius-sm); padding: 8px 14px; font-size: 14px; font-weight: 600;
  color: var(--uq-brand-ink); text-decoration: none; margin: 0 6px 6px 0; transition: all .15s;
}
.uqtool--related a:hover { border-color: var(--uq-brand); color: #fff; background: var(--uq-brand); }

/* ── Narrow screens ───────────────────────────────────── */
@media (max-width: 520px) {
  .uqtool__grid { grid-template-columns: 1fr; }
  .uqtool__result-head { flex-direction: column; align-items: flex-start; gap: .6rem; }
  /* `flex-wrap: wrap` used to live here, which on a real phone dropped each
     tab onto its OWN line the moment 2+ tab groups (level/group/mode) sat
     stacked on top of each other -- confirmed on-device: it read as a plain
     bulleted list, not a tab bar, and burned a screenful of height before
     the subject rows even started. A horizontally-scrollable single-line
     strip is the standard mobile pattern for a tab bar that doesn't fit:
     nothing wraps, nothing is cut off, the user swipes. */
  .uqtool__seg {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    margin-bottom: .9rem;
  }
  .uqtool__seg::-webkit-scrollbar { display: none; }
  .uqtool__seg button { flex: none; white-space: nowrap; }
}

/* ── Interaction polish (shared, all tools) ───────────── */
.uqtool button, .uqtool a, .uqtool summary,
.uqtool input, .uqtool select, .uqtool textarea, .uqtool label {
  touch-action: manipulation;
}
.uqtool button, .uqtool a, .uqtool summary { -webkit-tap-highlight-color: transparent; }
.uqtool__btn:active { transform: translateY(0) scale(.98); box-shadow: none; }
.uqtool button:disabled {
  opacity: .5; cursor: not-allowed; transform: none; box-shadow: none;
}
.uqtool summary:focus-visible, .uqtool a:focus-visible {
  outline: 2px solid var(--uq-accent); outline-offset: 2px; border-radius: 4px;
}

/* Bigger touch targets only where the pointer is actually a finger, so the
   desktop density stays exactly as designed. 44px matches the Apple HIG
   minimum; buttons centre their content, so min-height alone is enough. */
@media (pointer: coarse) {
  .uqtool__seg button { min-height: 46px; }
  .uqtool__copy-result { min-height: 40px; padding: 8px 14px; font-size: 13px; }
  .uqtool--related a { min-height: 44px; }
  .uqtool__check { padding-block: 8px; }
}

/* ── Print ────────────────────────────────────────────── */
/* Browsers skip backgrounds by default when printing, but the result badge
   now carries its own background/shadow rather than sitting on a dark
   banner, so it needs its own explicit reset too. */
@media print {
  .uqtool { max-width: 100%; }
  .uqtool__card { box-shadow: none; padding: 16px; }
  .uqtool__result-head { background: none !important; border-bottom: 2px solid #000; }
  .uqtool__result-label { color: #000; }
  .uqtool__result-big { background: none !important; color: #000 !important; box-shadow: none !important; padding: 0 !important; }
  .uqtool__result-actions, .uqtool__actions, .uqtool__embed,
  .uqtool--related, .uqtool__foot { display: none !important; }
  .uqtool__result, .uqtool__row, .uqtool__table tr { break-inside: avoid; }
  .uqtool__table td { background: none !important; }
  .uqtool__grade-chip { background: none !important; color: #000 !important; font-weight: 800; }
  .uqtool__seg button[aria-pressed="true"] {
    background: none; color: #000; box-shadow: none;
    font-weight: 800; text-decoration: underline;
  }
}

/* ── Reduced motion ───────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .uqtool *, .uqtool *::before, .uqtool *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
  .uqtool__btn:hover { transform: none; }
}
