/* FormatterHub — visual identity layered on Bootstrap 5.
   Palette follows the brief; the "signature" is the monospace wordmark and
   the code-editor panes with a live line-number gutter. */

:root {
  --fh-primary: #0D6EFD;
  --fh-secondary: #6610F2;
  --fh-success: #198754;
  --fh-warning: #FFC107;
  --fh-danger: #DC3545;
  --fh-bg: #F8F9FA;
  --fh-dark: #212529;

  --fh-font-body: "Inter", system-ui, -apple-system, sans-serif;
  --fh-font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --fh-radius: 14px;
  --fh-shadow: 0 6px 24px rgba(16, 24, 40, 0.08);
  --fh-shadow-sm: 0 2px 8px rgba(16, 24, 40, 0.06);

  --fh-surface: #ffffff;
  --fh-border: #e6e8ec;
  --fh-muted: #6c757d;
}

[data-bs-theme="dark"] {
  --fh-bg: #14161a;
  --fh-surface: #1c1f26;
  --fh-border: #2b3038;
  --fh-muted: #9aa4b2;
}

body {
  font-family: var(--fh-font-body);
  background: var(--fh-bg);
  color: var(--fh-dark);
}
[data-bs-theme="dark"] body { color: #e7eaee; }

/* ---------- Navbar ---------- */
.fh-navbar {
  background: color-mix(in srgb, var(--fh-surface) 88%, transparent);
  backdrop-filter: saturate(160%) blur(10px);
  border-bottom: 1px solid var(--fh-border);
  min-height: 112px;            /* doubled from the default ~56px */
  padding-top: .75rem; padding-bottom: .75rem;
}
.fh-nav-inner {
  width: 100%; max-width: 1600px; margin: 0 auto;
  padding: 0 1.25rem; display: flex; align-items: center;
  flex-wrap: wrap; gap: .5rem; position: relative;
}
.fh-navbar .navbar-collapse { flex-basis: auto; }
.fh-powered strong { color: var(--fh-primary); }
.fh-brand {
  font-family: var(--fh-font-mono);
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--fh-dark) !important;
  display: inline-flex;
  align-items: center;
  gap: .45rem;
}
[data-bs-theme="dark"] .fh-brand { color: #fff !important; }
.fh-brand span { color: var(--fh-primary); }
.fh-brand i { color: var(--fh-secondary); }
.fh-brand-logo { border-radius: .3rem; flex-shrink: 0; }

/* ---------- Hero ---------- */
.fh-hero {
  padding: 5.5rem 0 4rem;
  background:
    radial-gradient(1200px 400px at 50% -10%,
      color-mix(in srgb, var(--fh-secondary) 16%, transparent), transparent 70%),
    var(--fh-bg);
}
.fh-eyebrow {
  font-family: var(--fh-font-mono);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--fh-primary);
}
.fh-hero-title {
  font-weight: 700;
  font-size: clamp(2.2rem, 5vw, 3.6rem);
  line-height: 1.05;
  letter-spacing: -0.03em;
  margin: 0.6rem 0 1rem;
  background: linear-gradient(120deg, var(--fh-primary), var(--fh-secondary));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.fh-hero-sub {
  font-size: 1.12rem;
  color: var(--fh-muted);
  max-width: 40rem;
  margin: 0 auto 2rem;
}
.fh-hero-cta { display: flex; gap: 0.75rem; justify-content: center; flex-wrap: wrap; }

/* ---------- Sections ---------- */
.fh-section { padding: 4rem 0; }
.fh-section-alt { background: var(--fh-surface); border-block: 1px solid var(--fh-border); }
.fh-section-title {
  font-weight: 700; letter-spacing: -0.02em; margin-bottom: 2rem; font-size: 1.9rem;
}

/* ---------- Tool cards ---------- */
.fh-tool-card {
  display: block; height: 100%;
  padding: 1.75rem; border-radius: var(--fh-radius);
  background: var(--fh-surface); border: 1px solid var(--fh-border);
  box-shadow: var(--fh-shadow-sm); text-decoration: none; color: inherit;
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.fh-tool-card:hover { transform: translateY(-4px); box-shadow: var(--fh-shadow); border-color: var(--fh-primary); }
.fh-tool-icon {
  width: 48px; height: 48px; border-radius: 12px; display: grid; place-items: center;
  font-size: 1.4rem; color: #fff; margin-bottom: 1rem;
  background: linear-gradient(135deg, var(--fh-primary), var(--fh-secondary));
}
.fh-tool-card h3 { font-size: 1.2rem; font-weight: 600; }
.fh-tool-card p { color: var(--fh-muted); margin-bottom: 1rem; }
.fh-tool-go { font-family: var(--fh-font-mono); font-size: .85rem; color: var(--fh-primary); }

/* ---------- Features ---------- */
.fh-feature i { font-size: 1.8rem; }
.fh-feature h4 { font-size: 1.1rem; font-weight: 600; margin-top: .6rem; }
.fh-feature p { color: var(--fh-muted); }

/* ---------- Tool workspace ---------- */
.fh-tool-page {
  padding: 2rem 1.25rem 4rem; position: relative;
  width: 100%; max-width: 1600px; margin: 0 auto;
}
.fh-breadcrumb { margin-bottom: 1rem; }
.fh-breadcrumb a { text-decoration: none; }
.fh-tool-head h1 { font-weight: 700; letter-spacing: -0.02em; }
.fh-tool-head p { color: var(--fh-muted); }
.fh-toolbar { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin: 1.25rem 0; }

.fh-pane {
  background: var(--fh-surface); border: 1px solid var(--fh-border);
  border-radius: var(--fh-radius); overflow: hidden; box-shadow: var(--fh-shadow-sm);
}
.fh-pane-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: .6rem .9rem; border-bottom: 1px solid var(--fh-border);
  font-size: .85rem; font-weight: 600; background: var(--fh-bg);
}
.fh-stats { font-family: var(--fh-font-mono); font-weight: 500; color: var(--fh-muted); font-size: .78rem; }
.fh-pane-actions .btn-link { color: var(--fh-muted); text-decoration: none; }
.fh-pane-actions .btn-link:hover { color: var(--fh-primary); }

.fh-editor { display: flex; height: 820px; }
.fh-gutter {
  font-family: var(--fh-font-mono); font-size: .82rem; line-height: 1.55;
  padding: .75rem .5rem .75rem .75rem; text-align: right; color: var(--fh-muted);
  background: var(--fh-bg); border-right: 1px solid var(--fh-border);
  user-select: none; white-space: pre; overflow: hidden; min-width: 3rem;
}
.fh-input {
  flex: 1; border: 0; outline: 0; resize: none; padding: .75rem;
  font-family: var(--fh-font-mono); font-size: .82rem; line-height: 1.55;
  background: var(--fh-surface); color: inherit; tab-size: 2;
}

.fh-output-wrap { height: 820px; overflow: auto; }

/* Keep the tall editors sensible on small screens. */
@media (max-width: 991.98px) {
  .fh-editor, .fh-output-wrap { height: 460px; }
}
.fh-output { margin: 0; height: 100%; }
.fh-output code {
  display: block; padding: .75rem; font-family: var(--fh-font-mono);
  font-size: .82rem; line-height: 1.55; background: transparent !important;
}
.fh-tree { padding: .75rem; font-family: var(--fh-font-mono); font-size: .82rem; }
.fh-tree ul { list-style: none; margin: 0; padding-left: 1.1rem; }
.fh-tree .fh-node-toggle { cursor: pointer; user-select: none; color: var(--fh-secondary); }
.fh-tree .fh-key { color: var(--fh-primary); }
.fh-tree .fh-val-str { color: var(--fh-success); }
.fh-tree .fh-val-num { color: var(--fh-danger); }
.fh-tree .collapsed > ul { display: none; }

/* ---------- Validation panel ---------- */
.fh-validation { margin-top: 1.25rem; padding: 1rem 1.25rem; border-radius: var(--fh-radius); font-family: var(--fh-font-mono); font-size: .85rem; }
.fh-validation.ok { background: color-mix(in srgb, var(--fh-success) 12%, var(--fh-surface)); border: 1px solid var(--fh-success); }
.fh-validation.err { background: color-mix(in srgb, var(--fh-danger) 10%, var(--fh-surface)); border: 1px solid var(--fh-danger); }

/* ---------- Recent ---------- */
.fh-recent { margin-top: 2.5rem; }
.fh-recent-title { font-size: 1.2rem; font-weight: 600; margin-bottom: 1rem; }

/* ---------- Drag & drop overlay ---------- */
.fh-drop-overlay {
  position: fixed; inset: 0; display: none; place-items: center; z-index: 1050;
  background: color-mix(in srgb, var(--fh-primary) 20%, rgba(0,0,0,.55));
  color: #fff; text-align: center;
}
.fh-drop-overlay.show { display: grid; }
.fh-drop-overlay i { font-size: 3rem; }

/* ---------- Footer ---------- */
.fh-footer { background: var(--fh-surface); border-top: 1px solid var(--fh-border); padding: 3rem 0 2rem; margin-top: 3rem; }
.fh-foot-head { font-size: .8rem; text-transform: uppercase; letter-spacing: .1em; color: var(--fh-muted); }
.fh-foot-links a { display: block; padding: .2rem 0; text-decoration: none; color: inherit; }
.fh-foot-links a:hover { color: var(--fh-primary); }

/* ---------- Error pages ---------- */
.fh-error-page { padding: 5rem 0; }
.fh-error-code { font-family: var(--fh-font-mono); font-size: 4.5rem; font-weight: 700; color: var(--fh-primary); }

/* ---------- Accessibility & motion ---------- */
:focus-visible { outline: 3px solid color-mix(in srgb, var(--fh-primary) 60%, transparent); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* ---------- Loading spinner ---------- */
.fh-btn-loading { position: relative; color: transparent !important; }
.fh-btn-loading::after {
  content: ""; position: absolute; inset: 0; margin: auto; width: 1rem; height: 1rem;
  border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%;
  color: #fff; animation: fh-spin .6s linear infinite;
}
@keyframes fh-spin { to { transform: rotate(360deg); } }

/* ---------- Content pages & forms ---------- */
.fh-content-page { padding: 2rem 0 4rem; max-width: min(900px, 94vw); }
.fh-prose { line-height: 1.7; }
.fh-prose h1 { font-weight: 700; letter-spacing: -0.02em; margin-bottom: 1rem; }
.fh-prose h3 { font-weight: 600; margin-top: 1.5rem; font-size: 1.15rem; }
.fh-prose p, .fh-prose li { color: var(--fh-body, inherit); }
.fh-prose ul { padding-left: 1.25rem; }

/* ---------- MD File Viewer ---------- */
.fh-md-viewer-body h1, .fh-md-viewer-body h2 {
  border-bottom: 1px solid var(--fh-border); padding-bottom: .3rem;
}
.fh-md-viewer-body pre {
  background: var(--fh-surface); border: 1px solid var(--fh-border);
  border-radius: 8px; padding: 1rem; overflow-x: auto;
}
.fh-md-viewer-body code {
  background: var(--fh-surface); border: 1px solid var(--fh-border);
  padding: .15em .35em; border-radius: 4px; font-size: .9em;
}
.fh-md-viewer-body pre code { background: none; border: none; padding: 0; }
.fh-md-viewer-body blockquote {
  border-left: 4px solid var(--fh-border); margin: 0; padding: .2rem 1rem; color: var(--fh-muted);
}
.fh-md-viewer-body table { border-collapse: collapse; width: 100%; margin: 1rem 0; }
.fh-md-viewer-body th, .fh-md-viewer-body td {
  border: 1px solid var(--fh-border); padding: .4rem .8rem; text-align: left;
}
.fh-md-viewer-body img { max-width: 100%; }
.fh-md-viewer-body hr { border: none; border-top: 1px solid var(--fh-border); margin: 1.5rem 0; }
.fh-form {
  margin-top: 2rem; background: var(--fh-surface); border: 1px solid var(--fh-border);
  border-radius: var(--fh-radius); padding: 1.5rem; box-shadow: var(--fh-shadow-sm);
}
.fh-form .form-label { font-weight: 500; font-size: .9rem; }

/* ---------- Admin ---------- */
.fh-admin { background: var(--fh-bg); min-height: 100vh; }
.fh-admin-nav {
  background: var(--fh-surface); border-bottom: 1px solid var(--fh-border);
  padding: .6rem 1rem; box-shadow: var(--fh-shadow-sm);
}
.fh-admin-main { max-width: 1100px; }
.fh-admin-card {
  background: var(--fh-surface); border: 1px solid var(--fh-border);
  border-radius: var(--fh-radius); padding: 2rem; box-shadow: var(--fh-shadow-sm);
}
.fh-admin-tile {
  display: block; text-decoration: none; color: inherit; height: 100%;
  background: var(--fh-surface); border: 1px solid var(--fh-border);
  border-radius: var(--fh-radius); padding: 1.25rem; box-shadow: var(--fh-shadow-sm);
  transition: transform .12s ease, box-shadow .12s ease;
}
.fh-admin-tile:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(0,0,0,.08); color: var(--fh-primary); }
.fh-admin-tile > i { font-size: 1.4rem; color: var(--fh-primary); }
.fh-admin-tile-num { font-size: 1.9rem; font-weight: 700; line-height: 1.1; margin: .35rem 0 .1rem; }
.fh-msg-body { white-space: pre-wrap; }
.fh-code-area { font-family: var(--fh-font-mono); font-size: .82rem; line-height: 1.5; tab-size: 2; }

/* ---------- Search / go-to subbar ---------- */
.fh-subbar { display: flex; flex-wrap: wrap; gap: .75rem; margin: -.25rem 0 1rem; }
.fh-subbar .fh-search { max-width: 460px; flex: 1 1 320px; }
.fh-subbar .fh-goto { max-width: 320px; flex: 0 1 auto; }
.fh-subbar .fh-goto input[type="number"] { max-width: 5.5rem; }
.fh-search-count { font-family: var(--fh-font-mono); font-size: .75rem; min-width: 4.5rem; justify-content: center; }

/* ---------- Enriched validation ---------- */
.fh-verr { padding: .35rem 0; }
.fh-verr + .fh-verr { border-top: 1px dashed var(--fh-border); margin-top: .5rem; }
.fh-verr-msg { font-weight: 600; }
.fh-verr-snippet {
  margin: .5rem 0; padding: .5rem .75rem; background: var(--fh-bg);
  border: 1px solid var(--fh-border); border-radius: 8px; overflow-x: auto;
  font-family: var(--fh-font-mono); font-size: .8rem; line-height: 1.4; white-space: pre;
}
.fh-verr-snippet .fh-caret { color: var(--fh-danger); font-weight: 700; }
.fh-verr-hint { margin: .35rem 0; color: var(--fh-body, inherit); }
.fh-verr-hint .bi { color: var(--fh-warning); }
.fh-verr-near { font-size: .8rem; color: var(--fh-muted); margin-bottom: .35rem; }
.fh-verr-near code { color: var(--fh-secondary); }
.fh-jump { margin-top: .25rem; }
.fh-verr-actions { margin-top: .75rem; display: flex; gap: .5rem; flex-wrap: wrap; }

/* ---------- AI explanation panel ---------- */
.fh-ai {
  margin-top: 1rem; border: 1px solid var(--fh-border); border-radius: var(--fh-radius);
  background: var(--fh-surface); box-shadow: var(--fh-shadow-sm); overflow: hidden;
}
.fh-ai-disabled { border-style: dashed; opacity: .95; }
.fh-ai-head {
  display: flex; align-items: center; gap: .5rem; padding: .6rem .9rem;
  border-bottom: 1px solid var(--fh-border); font-weight: 600; font-size: .9rem;
  background: linear-gradient(90deg, color-mix(in srgb, var(--fh-secondary) 12%, transparent), transparent);
}
.fh-ai-head .bi-robot { color: var(--fh-secondary); }
.fh-ai-body { padding: .9rem; font-size: .9rem; line-height: 1.6; white-space: pre-wrap; }
.fh-ai-body code { font-family: var(--fh-font-mono); font-size: .82rem; }
.fh-ai-code {
  white-space: pre; background: var(--fh-bg); border: 1px solid var(--fh-border);
  border-radius: 8px; padding: .6rem .8rem; overflow-x: auto; font-size: .82rem;
}
.fh-ai-loading { color: var(--fh-muted); display: inline-flex; align-items: center; gap: .5rem; }

/* ---------- Utility tools (Base64 / URL / Regex / UUID) ---------- */
.fh-util .fh-util-type { max-width: 340px; }
.fh-util textarea.fh-input { border: 0; outline: 0; resize: none; background: var(--fh-surface); color: inherit; }
.fh-mono { font-family: var(--fh-font-mono); }
.fh-regex-error {
  margin-top: .6rem; color: var(--fh-danger); font-family: var(--fh-font-mono);
  font-size: .82rem; background: color-mix(in srgb, var(--fh-danger) 8%, transparent);
  padding: .5rem .75rem; border-radius: .4rem;
}
.fh-regex-highlight {
  font-family: var(--fh-font-mono); font-size: .85rem; line-height: 1.6;
  white-space: pre-wrap; word-break: break-word; border-bottom: 1px solid var(--fh-border);
}
.fh-rx-hit { background: color-mix(in srgb, var(--fh-warning) 55%, transparent); border-radius: .2rem; padding: 0 .05rem; }
.fh-regex-matches { font-family: var(--fh-font-mono); font-size: .8rem; }
.fh-rx-row { padding: .35rem 0; border-bottom: 1px dashed var(--fh-border); }
.fh-rx-idx { color: var(--fh-muted); margin-right: .5rem; }
.fh-rx-group { display: inline-block; margin-left: .6rem; color: var(--fh-secondary); }
.fh-nav-inner .navbar-brand { margin-right: 1.5rem; }

/* ---------- Mega menu + compact tool cards ---------- */
/* Left-aligned directly under its own "Formatters" trigger (standard
   dropdown behaviour) rather than anchored to the far side of the navbar --
   the trigger sits near the left of the nav, so right-anchoring made the
   menu pop up disconnected from where the user clicked. Width/height are
   still capped with internal scroll so a long formatter list can never
   overflow the viewport or overrun the page. */
.fh-mega {
  position: absolute; top: 100%; left: 0; right: auto;
  width: max-content; max-width: min(92vw, 760px);
  max-height: min(70vh, 480px); overflow-y: auto;
  gap: 1.5rem; padding: 1rem 1.25rem;
}
.dropdown-menu.show.fh-mega { display: flex; }
.fh-mega-col { min-width: 150px; }
.fh-mega-col .dropdown-header { padding-left: 0; font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; }
.fh-mega-col .dropdown-item { padding: .25rem .5rem; border-radius: .35rem; }
.fh-navbar .dropdown-menu:not(.fh-mega) { max-height: min(70vh, 420px); overflow-y: auto; max-width: calc(100vw - 2rem); }
@media (max-width: 991.98px) {
  .fh-mega { flex-direction: column; gap: .5rem; max-width: calc(100vw - 2rem); left: 0; right: auto; }
}
.fh-tool-card-sm { padding: 1rem 1.1rem; }
.fh-tool-card-sm h3 { font-size: 1rem; margin-bottom: .15rem; }
.fh-tool-card-sm p { font-size: .8rem; color: var(--fh-muted); margin-bottom: .4rem; }

/* ---------- Error line marker, compression stats, replace ---------- */
.fh-gutter-err { color: #fff; background: var(--fh-danger); border-radius: .2rem; padding: 0 .3rem; }
.fh-minstats {
  display: flex; flex-wrap: wrap; gap: 1.25rem; margin-top: 1rem;
  padding: .75rem 1rem; border-radius: var(--fh-radius);
  background: color-mix(in srgb, var(--fh-success) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--fh-success) 30%, transparent);
  font-size: .85rem; font-family: var(--fh-font-mono);
}
.fh-minstats strong { color: var(--fh-success); }
.fh-replace { max-width: 340px; }
.fh-verr-lint { color: var(--fh-warning); }

/* ---------- Validation warning state + indent select ---------- */
.fh-validation.warn {
  background: color-mix(in srgb, var(--fh-warning) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--fh-warning) 40%, transparent);
}
.fh-indent { max-width: 170px; }

/* ---------- EEAT byline, tool H2, documentation figures ---------- */
.fh-tool-sub { font-size: 1rem; font-weight: 400; color: var(--fh-muted); margin: 0; }
.fh-byline { font-size: .85rem; margin-bottom: 1.25rem; display: flex; flex-wrap: wrap; gap: .5rem; }
.fh-byline a { color: var(--fh-primary); text-decoration: none; }
.fh-doc-figure { margin: 1.25rem 0; }
.fh-doc-shot {
  display: flex; align-items: center; justify-content: center; min-height: 160px;
  border: 2px dashed var(--fh-border); border-radius: var(--fh-radius);
  color: var(--fh-muted); font-family: var(--fh-font-mono); font-size: .85rem;
  background: color-mix(in srgb, var(--fh-primary) 4%, transparent); text-align: center; padding: 1rem;
}
.fh-doc-figure figcaption { font-size: .82rem; color: var(--fh-muted); margin-top: .4rem; }

/* ---------- Footer: "coming soon" badge + social icons ---------- */
.fh-soon-badge {
  font-size: .68rem; font-weight: 600; color: var(--fh-primary);
  background: color-mix(in srgb, var(--fh-primary) 12%, transparent);
  padding: .1rem .4rem; border-radius: .3rem; margin-left: .35rem;
  white-space: nowrap; vertical-align: middle;
}
.fh-social-links { display: flex; gap: .6rem; }
.fh-social-links a {
  display: inline-flex; align-items: center; justify-content: center;
  width: 2.15rem; height: 2.15rem; border-radius: 50%;
  background: var(--fh-surface); border: 1px solid var(--fh-border);
  color: inherit; text-decoration: none; font-size: 1rem;
  transition: transform .12s ease, color .12s ease, border-color .12s ease;
}
.fh-social-links a:hover { transform: translateY(-2px); color: var(--fh-primary); border-color: var(--fh-primary); }
.fh-prose article + article { margin-top: 2rem; padding-top: 1.5rem; border-top: 1px solid var(--fh-border); }
.fh-prose article h2 { font-size: 1.15rem; margin-bottom: .2rem; }
.fh-prose .fh-post-date { font-size: .8rem; color: var(--fh-muted); display: block; margin-bottom: .6rem; }
