/* ==================================================
   Codexal — Tools section
   Loaded only by /tools and the tool pages. Uses the tokens from site.css
   (--line, --muted, --panel, brand colours) so the section cannot drift
   away from the rest of the site.
   All comments in English only.
================================================== */

/* The converter shows one state at a time by toggling the hidden attribute.
   A class that sets `display` outranks the user agent's `[hidden]` rule, so
   every state would otherwise be painted at once. */
.tool-app [hidden],
.tools-grid [hidden] {
  display: none !important;
}

/* ===== Hub grid ===== */
.tools-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 16px;
}

.tool-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  text-decoration: none;
  color: inherit;
}

.tool-card__head {
  display: flex;
  align-items: center;
  gap: 14px;
}

.tool-card__icon {
  width: 52px;
  height: 52px;
  flex: 0 0 52px;
}

.tool-card__title {
  margin: 0;
  font-size: 1.12rem;
}

.tool-card__desc {
  margin: 0;
  color: var(--muted);
}

.tool-card__meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: auto;
  padding-top: 6px;
  flex-wrap: wrap;
}

.tool-badge {
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(52, 168, 83, .10);
  color: #1e7e34;
}

.tool-chip {
  font-size: .74rem;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 8px;
  background: rgba(2, 8, 23, .05);
  color: var(--muted);
}

/* A slot in the grid for a tool that is not built yet. */
.tool-card--soon {
  opacity: .62;
  border-style: dashed;
}

.tool-card--soon:hover {
  transform: none;
  box-shadow: none;
}

/* ===== Tool page hero ===== */
.tool-hero {
  padding: 56px 0 28px;
}

.tool-hero__head {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
}

.tool-hero__icon {
  width: 76px;
  height: 76px;
  flex: 0 0 76px;
}

.tool-hero h1 {
  font-size: clamp(28px, 4.6vw, 46px);
  margin: 0;
}

.tool-hero .lead {
  margin: 14px 0 0;
  max-width: 760px;
}

/* ===== Converter ===== */
.tool-app {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel);
  padding: 10px;
  box-shadow: 0 10px 34px rgba(2, 8, 23, .05);
}

.tool-drop {
  border: 2px dashed rgba(10, 88, 255, .28);
  border-radius: 14px;
  background: #f7faff;
  padding: 44px 22px;
  text-align: center;
  transition: background .2s ease, border-color .2s ease;
  cursor: pointer;
}

.tool-drop.is-over {
  border-color: #0a58ff;
  background: rgba(10, 88, 255, .07);
}

.tool-drop__icon {
  width: 56px;
  height: 56px;
  margin: 0 auto 12px;
}

.tool-drop__title {
  margin: 0 0 6px;
  font-weight: 700;
  font-size: 1.08rem;
}

.tool-drop__hint {
  margin: 0 0 18px;
  color: var(--muted);
  font-size: .94rem;
}

.tool-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 0;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  padding: 12px 26px;
  border-radius: 12px;
  background: #0a58ff;
  color: #fff;
  box-shadow: 0 4px 15px rgba(10, 88, 255, .22);
  transition: background .2s ease, transform .2s ease;
  text-decoration: none;
}

.tool-btn:hover {
  background: #0042da;
  transform: translateY(-1px);
  color: #fff;
}

.tool-btn--ghost {
  background: transparent;
  color: #0a58ff;
  border: 1px solid rgba(10, 88, 255, .3);
  box-shadow: none;
  padding: 10px 20px;
}

.tool-btn--ghost:hover {
  background: rgba(10, 88, 255, .06);
  color: #0a58ff;
}

/* Chosen file + progress + result all share one padded row. */
.tool-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px;
  flex-wrap: wrap;
}

.tool-file__icon {
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
}

.tool-file__meta {
  min-width: 0;
  flex: 1 1 200px;
}

.tool-file__name {
  display: block;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tool-file__size {
  color: var(--muted);
  font-size: .86rem;
}

.tool-link {
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  color: var(--muted);
  cursor: pointer;
  text-decoration: underline;
}

.tool-link:hover {
  color: var(--text);
}

.tool-progress {
  width: 100%;
  height: 7px;
  border-radius: 999px;
  background: rgba(2, 8, 23, .07);
  overflow: hidden;
  margin-top: 4px;
}

.tool-progress__bar {
  height: 100%;
  width: 10%;
  border-radius: 999px;
  background: linear-gradient(90deg, #4285F4, #34A853);
  transition: width .35s ease;
}

.tool-status__text {
  color: var(--muted);
  font-size: .92rem;
}

.tool-result {
  border-top: 1px solid var(--line);
}

.tool-result__ok {
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  color: #34A853;
}

.tool-error {
  margin: 0;
  padding: 14px 18px;
  border-radius: 12px;
  background: rgba(234, 67, 53, .07);
  color: #b3261e;
  font-size: .95rem;
}

/* The privacy line is the point of the tool, so it sits with it. */
.tool-privacy {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 14px 0 0;
  color: var(--muted);
  font-size: .88rem;
}

.tool-privacy svg {
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
  color: #34A853;
}

/* ===== Content blocks ===== */
.tool-steps {
  counter-reset: step;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 18px;
  padding: 0;
  margin: 0;
  list-style: none;
}

.tool-steps li {
  counter-increment: step;
  padding-top: 44px;
  position: relative;
}

.tool-steps li::before {
  content: counter(step);
  position: absolute;
  top: 0;
  inset-inline-start: 0;
  width: 32px;
  height: 32px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-weight: 800;
  color: #0a58ff;
  background: rgba(10, 88, 255, .09);
}

.tool-steps h3 {
  margin: 0 0 6px;
  font-size: 1.02rem;
}

.tool-steps p {
  margin: 0;
  color: var(--muted);
}

.tool-faq {
  display: grid;
  gap: 10px;
  max-width: 860px;
}

.tool-faq details {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  padding: 14px 18px;
}

.tool-faq summary {
  cursor: pointer;
  font-weight: 700;
  list-style: none;
}

.tool-faq summary::-webkit-details-marker {
  display: none;
}

.tool-faq summary::after {
  content: "+";
  float: inline-end;
  color: var(--muted);
  font-weight: 700;
}

.tool-faq details[open] summary::after {
  content: "–";
}

.tool-faq p {
  margin: 10px 0 0;
  color: var(--muted);
}

.tool-specs {
  width: 100%;
  border-collapse: collapse;
  max-width: 720px;
}

.tool-specs th,
.tool-specs td {
  text-align: start;
  padding: 11px 14px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

.tool-specs th {
  width: 42%;
  font-weight: 600;
  color: var(--muted);
}

/* Cross-links between tools at the foot of a tool page. */
.tool-more {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 14px;
}

/* ===== Off-screen A4 sheet used to typeset DOCX before capture =====
   The sheet has to be laid out for real, because html2canvas cannot
   photograph display:none. So it is parked outside the viewport — but by a
   WRAPPER, never by the sheet itself: html2pdf clones the element it is
   given into its own staging overlay, and a clone that carries
   `left:-100000px` lands outside the capture area and comes back blank. */
.tool-stage {
  position: fixed;
  top: 0;
  left: -100000px;
  pointer-events: none;
  /* Width is set from JS to the PDF page's inner width. */
}

.tool-sheet {
  width: 100%;
  padding: 0;
  background: #fff;
  color: #111;
  font-family: "Inter", "Noto Sans", "Noto Sans Arabic", "Noto Sans Devanagari", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.55;
}

/* The sheet shows the visitor's document, not our page, so site typography
   must not leak into it. letter-spacing matters most: html2canvas falls back
   to drawing letter by letter when it is set, which breaks the cursive
   joining in Arabic and Urdu and turns a heading into loose glyphs. */
.tool-sheet,
.tool-sheet * {
  letter-spacing: normal !important;
  word-spacing: normal;
}

.tool-sheet h1,
.tool-sheet h2,
.tool-sheet h3,
.tool-sheet h4,
.tool-sheet h5,
.tool-sheet h6 {
  font-family: inherit;
  color: inherit;
  font-weight: 700;
}

.tool-sheet h1 {
  font-size: 26px;
  margin: 0 0 12px;
}

.tool-sheet h2 {
  font-size: 21px;
  margin: 20px 0 10px;
}

.tool-sheet h3 {
  font-size: 17px;
  margin: 16px 0 8px;
}

.tool-sheet p {
  margin: 0 0 10px;
}

.tool-sheet table {
  border-collapse: collapse;
  width: 100%;
  margin: 0 0 12px;
}

.tool-sheet td,
.tool-sheet th {
  border: 1px solid #c7ccd3;
  padding: 6px 9px;
}

.tool-sheet img {
  max-width: 100%;
  height: auto;
}

.tool-sheet[dir="rtl"] {
  text-align: right;
}

/* ===== Small screens ===== */
@media (max-width: 640px) {
  .tool-drop {
    padding: 32px 16px;
  }

  .tool-hero__icon {
    width: 60px;
    height: 60px;
    flex-basis: 60px;
  }

  .tool-specs th {
    width: 48%;
  }
}
