/* --brand / --brand-dark below are fallback defaults only. Every generated
   page overrides them inline (see renderPage() in lib/layout.js) with
   shades derived from site.config.json's "themeColor", so the accent used
   here (links, buttons, Phosphor icons, tool cards...) reflects that
   setting site-wide. These defaults only apply if a page is served
   without that inline override (e.g. this stylesheet opened standalone). */
:root,
[data-theme="dark"] {
  --brand: #2563eb;
  --brand-dark: #60a5fa;
  --bg: #0f1115;
  --bg-elevated: #171a21;
  --bg-elevated-2: #1e222b;
  --text: #e6e8ec;
  --text-muted: #9aa1ac;
  --border: #2a2f3a;
  --radius: 10px;
  --mono: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
  --sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

[data-theme="light"] {
  --brand: #2563eb;
  --brand-dark: #1d4ed8;
  --bg: #f7f8fa;
  --bg-elevated: #ffffff;
  --bg-elevated-2: #eef1f5;
  --text: #12151a;
  --text-muted: #5b6472;
  --border: #dde1e7;
  --radius: 10px;
  --mono: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
  --sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  line-height: 1.55;
  transition: background-color 0.15s ease, color 0.15s ease;
}


a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-dark); text-decoration: underline; }

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 28px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elevated);
  position: sticky;
  top: 0;
  z-index: 10;
}

.site-header .brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1.25rem;
  color: var(--text);
}

.site-header .brand .logo-icon {
  height: 28px;
  width: auto;
  display: inline-flex;
  border-radius: 6px;
}


.site-header nav a {
  margin-left: 20px;
  color: var(--text-muted);
  font-weight: 500;
}

.site-header nav a:hover { color: var(--text); text-decoration: none; }

.header-right {
  display: flex;
  align-items: center;
  gap: 20px;
}

.bmc-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--brand);
  color: #fff;
  font-weight: 600;
  font-size: 0.85rem;
  white-space: nowrap;
}

.bmc-button:hover {
  background: var(--brand-dark);
  color: #fff;
  text-decoration: none;
}

.theme-toggle {
  display: inline-flex;

  align-items: center;
  gap: 6px;
  background: var(--bg-elevated-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px;
  cursor: pointer;
}

.theme-toggle button {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.95rem;
  line-height: 1;
  padding: 6px 9px;
  border-radius: 999px;
  cursor: pointer;
}

.theme-toggle button.active {
  background: var(--bg-elevated);
  color: var(--text);
  box-shadow: 0 0 0 1px var(--border);
}


.container {
  max-width: 1080px;
  margin: 0 auto;
  padding: 40px 28px 80px;
}

.hero {
  text-align: center;
  padding: 56px 20px 40px;
}

.hero h1 {
  font-size: 2.4rem;
  margin: 0 0 12px;
}

.hero p {
  color: var(--text-muted);
  font-size: 1.1rem;
  max-width: 640px;
  margin: 0 auto 28px;
}

.search-box {
  max-width: 480px;
  margin: 0 auto;
}

.search-box input {
  width: 100%;
  padding: 12px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-elevated-2);
  color: var(--text);
  font-size: 1rem;
}

.search-box input:focus {
  outline: none;
  border-color: var(--brand);
}

.categories-toolbar {
  display: flex;
  justify-content: flex-end;
  margin-top: 32px;
}

.toggle-all-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-elevated-2);
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}

.toggle-all-btn:hover {
  color: var(--text);
  border-color: var(--brand);
}

.category-block { margin-top: 44px; }


.category-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  background: none;
  border: none;
  border-bottom: 1px solid var(--border);
  padding: 0 0 8px;
  margin-bottom: 16px;
  cursor: pointer;
  text-align: left;
  font: inherit;
  color: inherit;
}

.category-toggle h2 {
  font-size: 1.1rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin: 0;
  flex: 1;
}

.category-toggle-chevron {
  display: inline-flex;
  color: var(--text-muted);
  font-size: 0.9rem;
  transition: transform 0.15s ease;
  flex-shrink: 0;
}

.category-block[data-collapsed="true"] .category-toggle-chevron {
  transform: rotate(-90deg);
}

.category-count {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--bg-elevated-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px 10px;
  flex-shrink: 0;
}

.category-toggle:hover h2,
.category-toggle:hover .category-toggle-chevron {
  color: var(--text);
}

.category-body {
  overflow: hidden;
}

.category-block[data-collapsed="true"] .category-body {
  display: none;
}

.tool-grid {

  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}

.subcategory-block { margin-top: 24px; }

.subcategory-block:first-of-type { margin-top: 20px; }

.subcategory-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-muted);
  margin: 0 0 12px;
}


.tool-card {
  display: block;
  position: relative;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  transition: border-color 0.15s ease, transform 0.15s ease;
}

.tool-card:hover {
  border-color: var(--brand);
  transform: translateY(-2px);
  text-decoration: none;
}

.tool-card .tool-icon {
  font-size: 1.6rem;
  margin-bottom: 10px;
  display: block;
}

/* Phosphor icon used as the tool's card icon: tint it with the brand
   color so cards keep a visual accent now that emojis are gone.
   Selectors cover every Phosphor weight class so switching the
   site-wide "phosphorWeight" in site.config.json needs no CSS change. */
.tool-card .tool-icon .ph,
.tool-card .tool-icon .ph-thin,
.tool-card .tool-icon .ph-light,
.tool-card .tool-icon .ph-bold,
.tool-card .tool-icon .ph-fill,
.tool-card .tool-icon .ph-duotone {
  color: var(--brand);
}

/* Phosphor icon shown next to the tool page <h1> title. */
.tool-title-icon .ph,
.tool-title-icon .ph-thin,
.tool-title-icon .ph-light,
.tool-title-icon .ph-bold,
.tool-title-icon .ph-fill,
.tool-title-icon .ph-duotone {
  color: var(--brand);
  vertical-align: -0.12em;
}

/* Generic alignment fix for inline Phosphor icons mixed with text
   (execution badges/pills/notices, header buttons, etc.). */
.ph,
.ph-thin,
.ph-light,
.ph-bold,
.ph-fill,
.ph-duotone {
  vertical-align: -0.125em;
  line-height: 1;
}

.tool-card h3 {
  margin: 0 0 6px;
  font-size: 1.05rem;
  color: var(--text);
}

.tool-card p {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.tool-card .tags {
  margin-top: 10px;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.tool-card .tag {
  font-size: 0.72rem;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--bg-elevated-2);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.no-results {
  text-align: center;
  color: var(--text-muted);
  margin-top: 40px;
  display: none;
}

.breadcrumbs {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 20px;
}

.tool-page h1 {
  margin-top: 0;
  font-size: 2rem;
}

.tool-meta {
  display: flex;
  gap: 10px;
  margin: 8px 0 28px;
  flex-wrap: wrap;
  align-items: center;
}

.tool-page .content {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 32px;
}

.tool-page .content h2 {
  margin-top: 36px;
  border-top: 1px solid var(--border);
  padding-top: 24px;
}

.tool-page .content h2:first-child {
  margin-top: 0;
  border-top: none;
  padding-top: 0;
}

.tool-page pre {
  background: var(--bg-elevated-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 0.88rem;
}

.tool-page code {
  font-family: var(--mono);
  background: var(--bg-elevated-2);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.9em;
}

.tool-page pre code { background: none; padding: 0; }

.tool-page table {
  width: 100%;
  border-collapse: collapse;
  margin: 20px 0;
  font-size: 0.92rem;
}

.tool-page table th,
.tool-page table td {
  padding: 10px 14px;
  border: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

.tool-page table th {
  background: var(--bg-elevated-2);
  color: var(--text);
  font-weight: 600;
}

.tool-page table tbody tr:nth-child(odd) {
  background: var(--bg-elevated-2);
}

.tool-page table code { white-space: nowrap; }


.tool-widget {
  margin: 24px 0;
  padding: 20px;
  background: var(--bg-elevated-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.tool-widget label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 6px;
  margin-top: 14px;
}

.tool-widget label:first-child { margin-top: 0; }

.tool-widget input[type="text"],
.tool-widget input[type="datetime-local"],
.tool-widget input[type="number"],
.tool-widget textarea,
.tool-widget select {

  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  font-family: var(--mono);
  font-size: 0.95rem;
}

.tool-widget textarea { min-height: 90px; resize: vertical; }

.tool-widget button {
  margin-top: 16px;
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  background: var(--brand);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
  font-size: 0.95rem;
}

.tool-widget button:hover { background: var(--brand-dark); }

.tool-widget .result {
  margin-top: 16px;
  padding: 14px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: var(--mono);
  font-size: 0.9rem;
  white-space: pre-wrap;
  word-break: break-word;
  min-height: 20px;
}

.tool-widget .row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
}

.tool-widget .info-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.tool-widget .info-row:first-child { margin-top: 0; }
.tool-widget .info-row:last-of-type { border-bottom: none; }

.tool-widget .info-label {
  color: var(--text-muted);
  font-size: 0.9rem;
  flex-shrink: 0;
}

.tool-widget .info-value {
  font-family: var(--mono);
  font-size: 0.95rem;
  color: var(--text);
  text-align: right;
  word-break: break-word;
}

.tool-widget .info-value.result {
  margin-top: 0;
  padding: 0;
  background: none;
  border: none;
  min-height: 0;
  width: 100%;
  text-align: left;
  white-space: normal;
}

.tool-widget button.btn {
  margin-top: 0;
  background: var(--bg-elevated);
  color: var(--text);
  border: 1px solid var(--border);
}

.tool-widget button.btn:hover {
  background: var(--brand);
  color: #fff;
}

.tool-widget .row button.btn { margin-top: 0; }

.tool-widget .status {
  margin-top: 14px;
  color: var(--text-muted);
  font-size: 0.85rem;
  min-height: 1.2em;
}


.site-footer {
  border-top: 1px solid var(--border);
  padding: 24px 28px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.footer-links {
  margin: 10px 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

.footer-links a {
  color: var(--text-muted);
}

.footer-links a:hover {
  color: var(--text);
}

.footer-links-sep {
  color: var(--text-muted);
}

/* Legal pages (Terms of Service / Privacy Policy) reuse the same content
   card styling as tool pages. */
.legal-page .content {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 32px;
}

.legal-page .content h1:first-child,
.legal-page .content h2:first-child {
  margin-top: 0;
}

.legal-page .content h2 {
  margin-top: 32px;
  border-top: 1px solid var(--border);
  padding-top: 20px;
}

.legal-page .content hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 28px 0;
}

.legal-page .content table {
  width: 100%;
  border-collapse: collapse;
  margin: 20px 0;
  font-size: 0.92rem;
}

.legal-page .content table th,
.legal-page .content table td {
  padding: 10px 14px;
  border: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

.legal-page .content table th {
  background: var(--bg-elevated-2);
  color: var(--text);
  font-weight: 600;
}

.legal-page .content code {
  font-family: var(--mono);
  background: var(--bg-elevated-2);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.9em;
}

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--bg-elevated-2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.78rem;
}

/* Execution mode badges — indicate where the tool's logic actually runs
   (client browser vs. server), so users always know where their data
   goes before they use a tool. */
.execution-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-weight: 600;
}

.execution-badge-icon {
  font-size: 0.95em;
  line-height: 1;
}

.execution-badge--client {
  color: #15803d;
  border-color: #15803d55;
  background: #15803d1a;
}

.execution-badge--server {
  color: #b45309;
  border-color: #b4530955;
  background: #b453091a;
}

[data-theme="dark"] .execution-badge--client {
  color: #4ade80;
  border-color: #4ade8055;
  background: #4ade801a;
}

[data-theme="dark"] .execution-badge--server {
  color: #fbbf24;
  border-color: #fbbf2455;
  background: #fbbf241a;
}

.execution-badge--both {
  color: #7c3aed;
  border-color: #7c3aed55;
  background: #7c3aed1a;
}

[data-theme="dark"] .execution-badge--both {
  color: #a78bfa;
  border-color: #a78bfa55;
  background: #a78bfa1a;
}

/* Notice banner shown at the top of every tool page content area,

   explaining in plain language where the data is processed. */
.execution-notice {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 0 0 20px;
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 0.9rem;
  border: 1px solid var(--border);
}

.execution-notice--client {
  background: #15803d0f;
  border-color: #15803d33;
  color: var(--text);
}

.execution-notice--server {
  background: #b453090f;
  border-color: #b4530933;
  color: var(--text);
}

/* Small pill shown in the top-right corner of homepage tool cards. */
.execution-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  position: absolute;
  top: 16px;
  right: 16px;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  border: 1px solid var(--border);
}

.execution-pill--client {
  color: #15803d;
  background: #15803d1a;
}

.execution-pill--server {
  color: #b45309;
  background: #b453091a;
}

[data-theme="dark"] .execution-pill--client {
  color: #4ade80;
  background: #4ade801a;
}

[data-theme="dark"] .execution-pill--server {
  color: #fbbf24;
  background: #fbbf241a;
}

.execution-pill--both {
  color: #7c3aed;
  background: #7c3aed1a;
}

[data-theme="dark"] .execution-pill--both {
  color: #a78bfa;
  background: #a78bfa1a;
}

.execution-notice--both {
  background: #7c3aed0f;
  border-color: #7c3aed33;
  color: var(--text);
}

/* Small logo/icon shown near the tool title indicating where the tool's
   logic runs (client browser, server, or both), so users know at a
   glance where their data is processed. */
.execution-logo {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 1.4rem;
  line-height: 1;
  vertical-align: middle;
  margin-left: 8px;
}

.execution-logo-icon {
  line-height: 1;
}

.execution-logo--client .execution-logo-icon { filter: drop-shadow(0 0 0 transparent); }

.execution-logo--client {
  color: #15803d;
}

.execution-logo--server {
  color: #b45309;
}

.execution-logo--both {
  color: #7c3aed;
}

[data-theme="dark"] .execution-logo--client {
  color: #4ade80;
}

[data-theme="dark"] .execution-logo--server {
  color: #fbbf24;
}

[data-theme="dark"] .execution-logo--both {
  color: #a78bfa;
}


/* ==========================================================================
   Responsive / Mobile improvements
   ========================================================================== */

/* Tablette et petit desktop */
@media (max-width: 768px) {
  .container {
    padding: 24px 18px 60px;
  }

  .hero {
    padding: 36px 12px 28px;
  }

  .hero h1 {
    font-size: 1.9rem;
  }

  .hero p {
    font-size: 1rem;
    margin-bottom: 20px;
  }

  .tool-page .content,
  .legal-page .content {
    padding: 20px 18px;
  }

  .tool-grid {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
  }
}

/* Mobile */
@media (max-width: 600px) {
  /* Header devient vertical pour éviter le débordement */
  .site-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 16px;
  }

  .site-header .brand {
    font-size: 1.1rem;
  }

  .site-header nav {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 14px;
    width: 100%;
  }

  .site-header nav a {
    margin-left: 0;
    font-size: 0.9rem;
  }

  .header-right {
    width: 100%;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
  }

  .bmc-button {
    font-size: 0.8rem;
    padding: 7px 12px;
  }

  /* Hero */
  .hero {
    padding: 28px 8px 24px;
  }

  .hero h1 {
    font-size: 1.6rem;
    line-height: 1.25;
  }

  .hero p {
    font-size: 0.95rem;
  }

  .search-box {
    max-width: 100%;
  }

  .search-box input {
    font-size: 0.95rem;
    padding: 10px 14px;
  }

  /* Toolbar catégories */
  .categories-toolbar {
    justify-content: center;
    margin-top: 22px;
  }

  .toggle-all-btn {
    font-size: 0.8rem;
    padding: 6px 12px;
  }

  /* Grille d'outils en une colonne pleine largeur */
  .tool-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .tool-card {
    padding: 16px 16px;
  }

  .category-toggle h2 {
    font-size: 0.95rem;
  }

  /* Page outil */
  .tool-page h1 {
    font-size: 1.5rem;
    line-height: 1.3;
  }

  .tool-title-icon {
    display: inline-block;
  }

  .tool-meta {
    gap: 8px;
  }

  .tool-page .content,
  .legal-page .content {
    padding: 16px 14px;
    border-radius: 8px;
  }

  .tool-page .content h2 {
    margin-top: 28px;
    padding-top: 18px;
    font-size: 1.15rem;
  }

  .tool-page pre {
    padding: 12px;
    font-size: 0.8rem;
  }

  /* Tables : scroll horizontal au lieu de casser la page */
  .tool-page table,
  .legal-page .content table {
    display: block;
    width: 100%;
    overflow-x: auto;
    white-space: nowrap;
    border: none;
  }

  .tool-page table th,
  .tool-page table td,
  .legal-page .content table th,
  .legal-page .content table td {
    white-space: nowrap;
  }

  /* Widgets d'outils */
  .tool-widget {
    padding: 14px;
    margin: 18px 0;
  }

  .tool-widget .row {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .tool-widget button {
    width: 100%;
  }

  .tool-widget .row button {
    width: 100%;
  }

  /* info-row passe en colonne pour éviter le texte compressé */
  .tool-widget .info-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    padding: 8px 0;
  }

  .tool-widget .info-value {
    text-align: left;
    width: 100%;
  }

  /* Footer */
  .site-footer {
    padding: 20px 16px;
    font-size: 0.8rem;
  }

  .footer-links {
    gap: 8px;
    font-size: 0.8rem;
  }

  /* Badges qui passent à la ligne proprement */
  .execution-logo {
    margin-left: 0;
    margin-top: 6px;
    display: block;
  }
}

/* Très petits écrans (ex: iPhone SE) */
@media (max-width: 380px) {
  .hero h1 {
    font-size: 1.4rem;
  }

  .site-header .brand .logo-icon {
    height: 22px;
  }

  .bmc-button span:not(.ph) {
    display: none; /* garde juste l'icône si le texte prend trop de place, à adapter selon markup réel */
  }
}

/* Empêche tout débordement horizontal global causé par un élément trop large */
html, body {
  overflow-x: hidden;
}

.tool-widget input[type="text"],
.tool-widget input[type="datetime-local"],
.tool-widget input[type="number"],
.tool-widget textarea,
.tool-widget select {
  max-width: 100%;
}

/* Execution notice — mobile-friendly layout */
.execution-notice {
  display: block;
  margin: 0 0 20px;
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 0.9rem;
  line-height: 1.6;
  border: 1px solid var(--border);
}

.execution-notice .ph,
.execution-notice .ph-thin,
.execution-notice .ph-light,
.execution-notice .ph-bold,
.execution-notice .ph-fill,
.execution-notice .ph-duotone {
  margin-right: 6px;
  vertical-align: -0.15em;
}

@media (max-width: 480px) {
  .execution-notice {
    font-size: 0.82rem;
    padding: 10px 12px;
  }
}