/* Shared styling for the Tools section.
   Loaded AFTER styles.css — reuses the site's design tokens (--accent, --border,
   --surface, --radius, .wrap, .card, .btn, .muted, etc.). Only adds what the
   interactive tools need. */

/* Data tools benefit from a little more room than the 860px prose column. */
.wrap.wide { max-width: 1080px; }

/* ---------- Tool page header block ---------- */

.tool-head { margin-bottom: 8px; }
.tool-head h1 { font-size: 30px; line-height: 1.2; margin: 0 0 10px; letter-spacing: -0.02em; }
.tool-head .lead { margin-bottom: 14px; }

.privacy-note {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--accent-dark);
  background: #e6f0ef;
  border: 1px solid #cfe3e0;
  border-radius: 999px;
  padding: 5px 14px;
  margin-bottom: 8px;
}
.privacy-note svg { width: 15px; height: 15px; flex: 0 0 auto; }

/* ---------- Drop zone + file picker ---------- */

.dropzone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 32px 24px;
  text-align: center;
  transition: border-color 0.15s ease, background 0.15s ease;
  cursor: pointer;
}
.dropzone:hover,
.dropzone:focus-within { border-color: var(--accent); }
.dropzone.dragover {
  border-color: var(--accent);
  background: #eef6f5;
}
.dropzone .dz-icon { font-size: 30px; line-height: 1; margin-bottom: 8px; }
.dropzone p { margin: 0 0 12px; color: var(--muted); font-size: 15px; }
.dropzone .dz-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.dropzone input[type="file"] { display: none; }

/* ---------- Buttons that aren't links ---------- */

button.btn, button.btn-outline { border: 0; cursor: pointer; font-family: inherit; }
button.btn-outline { border: 1px solid var(--border); background: var(--surface); }
button.btn:disabled, button.btn-outline:disabled { opacity: 0.5; cursor: default; transform: none; box-shadow: none; }

.btn-sm { padding: 6px 12px; font-size: 13.5px; }

.toolbar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  margin: 18px 0;
}
.toolbar .spacer { flex: 1 1 auto; }

/* ---------- Status / error / info messages ---------- */

.msg {
  border-radius: var(--radius);
  padding: 12px 16px;
  font-size: 14.5px;
  margin: 16px 0;
  border: 1px solid var(--border);
}
.msg.error { background: #fcecea; border-color: #f0c4bd; color: #7a2318; }
.msg.warn  { background: #fdf6e3; border-color: #efdca6; color: #6b5310; }
.msg.info  { background: #eef6f5; border-color: #cfe3e0; color: var(--accent-dark); }
.msg.hidden { display: none; }
.msg code { background: rgba(0,0,0,0.05); padding: 1px 5px; border-radius: 4px; }

.hidden { display: none !important; }

/* ---------- Result panels ---------- */

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin: 16px 0;
}
.panel > h2:first-child, .panel > h3:first-child { margin-top: 0; }
.panel h3 { font-size: 16px; }

/* Small metadata grid (parquet meta, csv summary) */
.meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
}
.meta-cell {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
}
.meta-cell .k { font-size: 12.5px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.03em; }
.meta-cell .v { font-size: 20px; font-weight: 700; color: var(--accent-dark); line-height: 1.2; margin-top: 3px; word-break: break-word; }
.meta-cell .v.small { font-size: 15px; font-weight: 600; color: var(--text); }

/* ---------- Data tables ---------- */

.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--border); border-radius: var(--radius); }
table.data {
  border-collapse: collapse;
  width: 100%;
  font-size: 13.5px;
  background: var(--surface);
}
table.data th, table.data td {
  text-align: left;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  vertical-align: top;
}
table.data thead th {
  position: sticky;
  top: 0;
  background: #f2efe9;
  font-weight: 700;
  font-size: 12.5px;
  color: var(--text);
  z-index: 1;
}
table.data tbody tr:hover td { background: #f7f5f0; }
table.data td.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data .nullish { color: #b03a2a; font-style: italic; }

/* Schema tree */
.schema-tree { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13.5px; line-height: 1.7; }
.schema-tree .row { display: flex; gap: 10px; flex-wrap: wrap; align-items: baseline; }
.schema-tree .col-name { font-weight: 600; color: var(--text); }
.schema-tree .col-type { color: var(--accent-dark); }
.schema-tree .col-flag { color: var(--muted); font-size: 12px; }
.schema-tree .indent { padding-left: 22px; border-left: 1px dashed var(--border); margin-left: 6px; }

/* ---------- Type / status badges ---------- */

.badge-type {
  display: inline-block;
  font-size: 11.5px;
  font-weight: 700;
  padding: 1px 8px;
  border-radius: 999px;
  background: #e6f0ef;
  color: var(--accent-dark);
  text-transform: lowercase;
  letter-spacing: 0.01em;
}
.badge-type.t-integer, .badge-type.t-float { background: #e4eefb; color: #1b4f8a; }
.badge-type.t-date, .badge-type.t-timestamp { background: #efe8fb; color: #5a3aa0; }
.badge-type.t-boolean { background: #e9f6e6; color: #2e6b1f; }
.badge-type.t-string { background: #f1efe9; color: #6a5a2a; }

.flag {
  display: inline-block;
  font-size: 11.5px;
  font-weight: 600;
  padding: 1px 8px;
  border-radius: 999px;
  background: #fdf6e3;
  color: #6b5310;
  border: 1px solid #efdca6;
  margin: 2px 4px 2px 0;
}
.flag.bad { background: #fcecea; color: #7a2318; border-color: #f0c4bd; }

/* ---------- Code output + tabs ---------- */

.tabs { display: flex; gap: 6px; flex-wrap: wrap; border-bottom: 1px solid var(--border); margin-bottom: 0; }
.tab {
  border: 1px solid transparent;
  border-bottom: none;
  background: none;
  color: var(--muted);
  font-weight: 600;
  font-size: 14px;
  padding: 9px 14px;
  border-radius: var(--radius) var(--radius) 0 0;
  cursor: pointer;
  font-family: inherit;
}
.tab:hover { color: var(--accent); }
.tab.active {
  color: var(--text);
  background: var(--surface);
  border-color: var(--border);
  margin-bottom: -1px;
}
.tabpanel { display: none; }
.tabpanel.active { display: block; }

.code-wrap { position: relative; }
pre.code {
  background: #1d2b2a;
  color: #e8f0ef;
  border-radius: 0 var(--radius) var(--radius) var(--radius);
  padding: 16px 18px;
  overflow-x: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  line-height: 1.6;
  margin: 0;
  max-height: 460px;
}
pre.code .kw { color: #8fd3c8; }
pre.code .str { color: #f0c98a; }
.copy-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(255,255,255,0.12);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}
.copy-btn:hover { background: rgba(255,255,255,0.22); }
.copy-btn.copied { background: var(--accent); border-color: var(--accent); }

/* ---------- Parameter rows (pairwise) ---------- */

.param-rows { display: flex; flex-direction: column; gap: 10px; margin: 16px 0; }
.param-row { display: flex; gap: 10px; align-items: center; }
.param-row input {
  font-family: inherit;
  font-size: 15px;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
}
.param-row .p-name { flex: 0 0 30%; min-width: 110px; }
.param-row .p-vals { flex: 1 1 auto; min-width: 0; }
.param-row .p-del {
  flex: 0 0 auto;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  border-radius: var(--radius);
  width: 40px;
  height: 40px;
  font-size: 18px;
  cursor: pointer;
}
.param-row .p-del:hover { border-color: #f0c4bd; color: #b03a2a; }

/* ---------- Score gauge (csv profiler) ---------- */

.score-card {
  display: flex;
  gap: 20px;
  align-items: center;
  flex-wrap: wrap;
}
.score-ring {
  --val: 0;
  --ring: var(--accent);
  flex: 0 0 auto;
  width: 116px;
  height: 116px;
  border-radius: 50%;
  background: conic-gradient(var(--ring) calc(var(--val) * 1%), var(--border) 0);
  display: grid;
  place-items: center;
}
.score-ring .inner {
  width: 88px; height: 88px; border-radius: 50%;
  background: var(--surface);
  display: grid; place-items: center; text-align: center;
}
.score-ring .num { font-size: 30px; font-weight: 800; color: var(--text); line-height: 1; }
.score-ring .lbl { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }

/* ---------- Sliders / inputs (fabric estimator) ---------- */

.field { margin: 16px 0; }
.field > label { display: block; font-weight: 600; font-size: 14.5px; margin-bottom: 6px; }
.field .hint { font-size: 12.5px; color: var(--muted); font-weight: 400; }
.field select, .field input[type="number"] {
  font-family: inherit;
  font-size: 15px;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  width: 100%;
  max-width: 320px;
}
.field input[type="range"] { width: 100%; max-width: 420px; accent-color: var(--accent); }
.range-row { display: flex; align-items: center; gap: 14px; }
.range-row output { font-weight: 700; color: var(--accent-dark); min-width: 66px; font-variant-numeric: tabular-nums; }

/* Utilization bar with color zones */
.util-bar {
  position: relative;
  height: 26px;
  border-radius: 999px;
  background: var(--border);
  overflow: hidden;
  margin: 8px 0 4px;
}
.util-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.25s ease, background 0.25s ease;
}
.util-fill.green { background: #3aa76d; }
.util-fill.amber { background: #e0a640; }
.util-fill.red { background: #d05c4a; }
.util-scale { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--muted); }

/* ---------- Landing page tool grid ---------- */

.tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
  margin: 26px 0;
}
.tool-grid .card { display: flex; flex-direction: column; }
.tool-grid .card .tool-emoji { font-size: 26px; line-height: 1; margin-bottom: 10px; }
.tool-grid .card h3 { display: flex; align-items: center; gap: 8px; }
.tool-grid .card p { flex: 1 1 auto; }
.tool-grid .card .go { margin-top: 12px; font-weight: 600; font-size: 14px; color: var(--accent); }
.tool-grid .card:hover .go { text-decoration: underline; }
.card-link { color: inherit; }
.card-link:hover { text-decoration: none; }

/* ---------- SEO prose + FAQ ---------- */

.tool-about { margin-top: 40px; }
.faq { margin: 16px 0; }
.faq details {
  border-bottom: 1px solid var(--border);
  padding: 4px 0;
}
.faq summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 16px;
  padding: 12px 0;
  list-style: none;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::before { content: "＋"; color: var(--accent); font-weight: 700; margin-right: 10px; }
.faq details[open] summary::before { content: "－"; }
.faq details p { color: var(--muted); margin: 0 0 14px; padding-left: 26px; }

/* ---------- Small helpers ---------- */

.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.nowrap { white-space: nowrap; }
.mini-note { font-size: 13px; color: var(--muted); margin-top: 8px; }
.bar-mini {
  display: inline-block;
  height: 8px;
  border-radius: 4px;
  background: var(--accent);
  vertical-align: middle;
}

@media (max-width: 560px) {
  .tool-head h1 { font-size: 25px; }
  .param-row { flex-wrap: wrap; }
  .param-row .p-name { flex: 1 1 100%; }
  .score-card { justify-content: center; }
}
