/* ═══════════════════════════════════════════════
   tools.css — shared styles for /tools, /calculators, /playground
   Extends styles.css variables (--accent, --dark, --surface, etc.)
═══════════════════════════════════════════════ */

/* ── utility ── */
.hidden { display: none !important; }

/* ═══════════════════════
   LAYOUT — nav clearance
═══════════════════════ */
.page-list,
.page-container {
  padding-top: 80px;
  padding-bottom: 4rem;
}

/* ═══════════════════════
   LIST / HUB VIEW
═══════════════════════ */
.page-list {
  max-width: 1100px;
  margin: 0 auto;
  padding-left: 1.25rem;
  padding-right: 1.25rem;
}

.pl-header {
  text-align: center;
  padding: 1.5rem 0 1rem;
}

.pl-title {
  font-size: 2.2rem;
  font-weight: 800;
  letter-spacing: -.03em;
  color: var(--text);
  margin-bottom: .35rem;
}

.pl-sub {
  color: var(--muted);
  font-size: .95rem;
  max-width: 640px;
  margin: 0 auto;
}

/* ── search ── */
.pl-search-wrap {
  max-width: 420px;
  margin: 1rem auto;
}

.pl-search {
  width: 100%;
  padding: .65rem 1rem;
  border-radius: 10px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-family: var(--font);
  font-size: .95rem;
  outline: none;
  transition: border-color .2s;
}

.pl-search:focus { border-color: var(--accent); }

/* ── category pills ── */
.pl-cats {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  justify-content: center;
  margin: .75rem 0 .5rem;
}

.cat-btn {
  padding: .4rem .95rem;
  border-radius: 50px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  font-family: var(--font);
  font-size: .82rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
  white-space: nowrap;
}

.cat-btn:hover         { border-color: var(--accent); color: var(--text); }
.cat-btn--active       { background: var(--accent); border-color: var(--accent); color: #fff; }
.cat-btn--active:hover { color: #fff; }

/* ── count ── */
.pl-count {
  text-align: center;
  font-size: .78rem;
  color: var(--muted);
  margin-bottom: .75rem;
}

/* ── card grid ── */
.pl-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(175px, 1fr));
  gap: .85rem;
}

.pl-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.1rem 1rem 1rem;
  display: flex;
  flex-direction: column;
  gap: .35rem;
  transition: border-color .2s, transform .2s;
  cursor: default;
}

.pl-card:hover {
  border-color: rgba(108,99,255,.45);
  transform: translateY(-2px);
}

.pl-icon { font-size: 1.8rem; line-height: 1; margin-bottom: .15rem; }

.pl-name {
  font-size: .9rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}

.pl-desc {
  font-size: .77rem;
  color: var(--muted);
  flex: 1;
  line-height: 1.45;
}

.pl-card .play-btn {
  display: block;
  width: 100%;
  margin-top: .5rem;
  padding: .45rem .75rem;
  border-radius: 7px;
  border: none;
  background: var(--accent);
  color: #fff;
  font-family: var(--font);
  font-size: .82rem;
  font-weight: 700;
  cursor: pointer;
  transition: opacity .15s;
}

.pl-card .play-btn:hover { opacity: .85; }

/* ── related links (cross-link between sections) ── */
.pl-related {
  max-width: 1100px;
  margin: 2.5rem auto 0;
  padding: 0 1.25rem;
  text-align: center;
}

.pl-related h2 {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: .75rem;
}

.pl-related-links {
  display: flex;
  flex-wrap: wrap;
  gap: .6rem;
  justify-content: center;
}

.pl-related-links a {
  padding: .5rem 1.1rem;
  border-radius: 50px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: .85rem;
  font-weight: 600;
  transition: border-color .2s, color .2s;
}

.pl-related-links a:hover { border-color: var(--accent); color: var(--accent); }

/* ═══════════════════════
   CONTAINER VIEW (one tool active)
═══════════════════════ */
.page-container {
  max-width: 760px;
  margin: 0 auto;
  padding-left: 1.25rem;
  padding-right: 1.25rem;
}

.pc-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  margin-bottom: .6rem;
  flex-wrap: wrap;
}

.pc-back,
.pc-restart {
  padding: .4rem .9rem;
  border-radius: 8px;
  border: 1.5px solid var(--border);
  background: transparent;
  color: var(--text);
  font-family: var(--font);
  font-size: .82rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color .2s, color .2s;
}

.pc-back:hover,
.pc-restart:hover { border-color: var(--accent); color: var(--accent); }

.pc-title {
  font-size: 1.2rem;
  font-weight: 800;
  flex: 1;
  text-align: center;
  color: var(--text);
}

.pc-instructions {
  text-align: center;
  font-size: .82rem;
  color: var(--muted);
  margin-bottom: 1rem;
  line-height: 1.5;
  min-height: 1rem;
}

.pc-body { min-height: 200px; }

/* ═══════════════════════
   SHARED FORM ELEMENTS
═══════════════════════ */
.t-field {
  margin-bottom: .9rem;
}

.t-field > label {
  display: block;
  font-size: .82rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: .35rem;
}

.t-input,
.t-textarea,
.t-select {
  width: 100%;
  padding: .6rem .85rem;
  border-radius: 9px;
  border: 1.5px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  font-family: var(--font);
  font-size: .92rem;
  outline: none;
  transition: border-color .15s;
}

.t-input:focus,
.t-textarea:focus,
.t-select:focus { border-color: var(--accent); }

.t-textarea {
  font-family: 'Courier New', monospace;
  resize: vertical;
  line-height: 1.5;
  min-height: 140px;
  white-space: pre;
  overflow-x: auto;
}

/* code-style textarea for playground editors */
.t-code {
  font-family: 'Courier New', monospace;
  resize: vertical;
  line-height: 1.55;
  tab-size: 2;
}

/* row of inline fields */
.t-inline {
  display: flex;
  flex-wrap: wrap;
  gap: .75rem;
  align-items: flex-end;
  margin-bottom: .9rem;
}

.t-inline .t-field { flex: 1; min-width: 120px; margin-bottom: 0; }

/* button row */
.t-row {
  display: flex;
  gap: .6rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.t-btn {
  padding: .55rem 1.2rem;
  border-radius: 8px;
  border: 1.5px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  font-family: var(--font);
  font-size: .88rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color .15s, background .15s, opacity .15s;
}

.t-btn:hover { border-color: var(--accent); background: var(--surface); }
.t-btn--primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.t-btn--primary:hover { opacity: .9; background: var(--accent); }
.t-btn:disabled { opacity: .4; cursor: default; }

/* ═══════════════════════
   OUTPUT / RESULTS
═══════════════════════ */
.t-output {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem;
  font-family: 'Courier New', monospace;
  font-size: .88rem;
  line-height: 1.6;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
  overflow-x: auto;
  min-height: 1rem;
  margin-top: .5rem;
}

.t-output:empty { display: none; }

.t-error {
  color: var(--accent2);
  border-color: rgba(255,101,132,.4);
  background: rgba(255,101,132,.08);
}

.t-success {
  color: var(--green);
  border-color: rgba(74,222,128,.4);
  background: rgba(74,222,128,.08);
}

.t-info {
  font-size: .82rem;
  color: var(--muted);
  margin-top: .6rem;
  line-height: 1.6;
}

/* copy button that sits with output */
.t-copy {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .35rem .8rem;
  font-size: .78rem;
  border-radius: 7px;
  border: 1.5px solid var(--border);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: border-color .15s, color .15s;
}

.t-copy:hover { border-color: var(--accent); color: var(--accent); }
.t-copy.done { color: var(--green); border-color: var(--green); }

/* ═══════════════════════
   CALCULATOR RESULT CARDS
═══════════════════════ */
.calc-result {
  display: grid;
  gap: .65rem;
  margin-top: .5rem;
}

.cr-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: .75rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 9px;
}

.cr-row.cr-highlight {
  background: rgba(108,99,255,.12);
  border-color: rgba(108,99,255,.4);
}

.cr-label {
  font-size: .85rem;
  color: var(--muted);
  font-weight: 500;
}

.cr-value {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
  font-family: 'Courier New', monospace;
}

.cr-row.cr-highlight .cr-value { color: var(--accent); font-size: 1.25rem; }

/* ═══════════════════════
   MISC TOOL PIECES
═══════════════════════ */
/* color preview swatch */
.color-swatch {
  width: 100%;
  height: 64px;
  border-radius: 9px;
  border: 1.5px solid var(--border);
  margin-bottom: .9rem;
  transition: background .15s;
}

/* match highlighting for regex */
.regex-matches { line-height: 1.8; }
.regex-matches mark {
  background: rgba(108,99,255,.3);
  color: #fff;
  border-radius: 3px;
  padding: 0 1px;
}

/* segmented control (mode toggle) */
.t-seg {
  display: inline-flex;
  border: 1.5px solid var(--border);
  border-radius: 9px;
  overflow: hidden;
  margin-bottom: .9rem;
}

.t-seg button {
  padding: .5rem 1.1rem;
  border: none;
  background: transparent;
  color: var(--muted);
  font-family: var(--font);
  font-size: .85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, color .15s;
}

.t-seg button.active { background: var(--accent); color: #fff; }

/* QR canvas holder */
#qr-box {
  display: flex;
  justify-content: center;
  padding: 1rem;
  background: #fff;
  border-radius: 10px;
  width: fit-content;
  margin: .5rem auto;
  min-height: 100px;
}
#qr-box:empty { display: none; }

/* playground iframe */
.pg-preview-frame {
  width: 100%;
  min-height: 320px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  background: #fff;
}

/* markdown preview */
.md-preview {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.25rem;
  min-height: 200px;
  font-size: .92rem;
  line-height: 1.7;
  overflow-x: auto;
}

.md-preview h1, .md-preview h2, .md-preview h3 { margin: .8rem 0 .4rem; line-height: 1.3; }
.md-preview h1 { font-size: 1.4rem; }
.md-preview h2 { font-size: 1.2rem; }
.md-preview h3 { font-size: 1.05rem; }
.md-preview p { margin: .5rem 0; }
.md-preview a { color: var(--accent); }
.md-preview ul, .md-preview ol { margin: .5rem 0; padding-left: 1.5rem; }
.md-preview li { margin: .2rem 0; }
.md-preview code {
  background: var(--dark2);
  padding: .15rem .4rem;
  border-radius: 4px;
  font-family: 'Courier New', monospace;
  font-size: .85em;
}
.md-preview pre {
  background: var(--dark2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .9rem;
  overflow-x: auto;
  margin: .6rem 0;
}
.md-preview pre code { background: none; padding: 0; }
.md-preview blockquote {
  border-left: 3px solid var(--accent);
  padding-left: 1rem;
  color: var(--muted);
  margin: .6rem 0;
}

/* split editor layout for playground */
.pg-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .9rem;
  align-items: start;
}

.pg-pane-label {
  font-size: .78rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: .35rem;
}

/* console output for JS playground */
.console-out {
  background: #0a0a12;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: .85rem 1rem;
  font-family: 'Courier New', monospace;
  font-size: .85rem;
  line-height: 1.6;
  color: #d6d6e0;
  white-space: pre-wrap;
  word-break: break-word;
  min-height: 120px;
  max-height: 400px;
  overflow-y: auto;
}

/* API tester response */
.api-resp {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem;
  font-family: 'Courier New', monospace;
  font-size: .85rem;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-x: auto;
  max-height: 460px;
  overflow-y: auto;
}

.api-status {
  display: inline-block;
  padding: .25rem .65rem;
  border-radius: 6px;
  font-weight: 700;
  font-size: .82rem;
  margin-bottom: .6rem;
}
.api-status.ok    { background: rgba(74,222,128,.18); color: var(--green); }
.api-status.err   { background: rgba(255,101,132,.18); color: var(--accent2); }

/* ═══════════════════════
   RESPONSIVE
═══════════════════════ */
@media (max-width: 600px) {
  .pl-grid { grid-template-columns: repeat(auto-fill, minmax(145px, 1fr)); gap: .65rem; }
  .pl-title { font-size: 1.7rem; }
  .cat-btn { font-size: .75rem; padding: .35rem .75rem; }
  .pc-title { font-size: 1.05rem; }

  .pg-split { grid-template-columns: 1fr; }
  .t-inline { flex-direction: column; align-items: stretch; }
}

@media (max-width: 380px) {
  .pl-grid { grid-template-columns: 1fr 1fr; }
}

/* ═══════════════════════
   NAV — mobile: scrollable row on NEW pages only
   (overrides styles.css hide-rule without touching existing pages)
═══════════════════════ */
@media (max-width: 820px) {
  .nav__links {
    gap: 1rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: .25rem;
  }
  .nav__links a:not(.nav__cta) {
    display: inline-flex !important;
    white-space: nowrap;
  }
}
