/* ==========================================================================
   microtools365 — shared stylesheet
   Loaded by every page. Keep this file the single source of design truth:
   colors, type, spacing and reusable components (.btn, .card, .panel, etc.)
   all live here so every new tool page automatically looks consistent.
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@500;600;700&family=Inter:wght@400;500;600&family=JetBrains+Mono:wght@500;600&display=swap');

:root {
  /* Color */
  --bg: #FAFAF8;
  --surface: #FFFFFF;
  --ink: #1A1D29;
  --muted: #6B6F7D;
  --border: #E5E3DC;
  --accent: #FF5A1F;
  --accent-ink: #FFFFFF;
  --accent-soft: #FFE8DC;
  --success: #0C8C6B;
  --success-soft: #DCF2E9;
  --danger: #D93636;
  --danger-soft: #FBE1E1;

  /* Type */
  --font-display: 'Space Grotesk', 'Inter', sans-serif;
  --font-body: 'Inter', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', 'SFMono-Regular', monospace;

  /* Layout */
  --radius: 10px;
  --radius-sm: 6px;
  --container: 1100px;
  --shadow: 0 1px 2px rgba(26, 29, 41, 0.04), 0 8px 24px rgba(26, 29, 41, 0.05);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; display: block; }

a { color: inherit; text-decoration: none; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.container {
  max-width: var(--container);
  margin: 0 auto;
  padding: 0 24px;
}

h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 600;
  line-height: 1.15;
  margin: 0 0 .5em;
}

p { margin: 0 0 1em; color: var(--ink); }
.muted { color: var(--muted); }

/* ---------- Header ---------- */
.site-header {
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 50;
}

.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 68px;
}

.logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.25rem;
  letter-spacing: -0.01em;
  color: var(--ink);
  text-decoration: none;
}
.logo img {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
}
.logo span { color: var(--accent); }

.nav { display: flex; align-items: center; gap: 28px; }

.nav a {
  font-size: .95rem;
  font-weight: 500;
  color: var(--muted);
}
.nav a:hover, .nav a.active { color: var(--ink); }

.nav-toggle {
  display: none;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  width: 40px;
  height: 40px;
  font-size: 1.1rem;
  cursor: pointer;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 20px;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-weight: 600;
  font-size: .95rem;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform .08s ease, background .15s ease, border-color .15s ease;
}
.btn:active { transform: translateY(1px); }

.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: #E64F18; }

.btn-secondary { background: var(--surface); color: var(--ink); border-color: var(--border); }
.btn-secondary:hover { border-color: var(--ink); }

.btn-sm { padding: 7px 14px; font-size: .85rem; }

/* ---------- Catalog tag (the "tool number" signature) ---------- */
.catalog-tag {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .04em;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 3px 8px;
  border-radius: 4px;
}

/* ---------- Hero ---------- */
.hero {
  padding: 64px 0 40px;
  border-bottom: 1px solid var(--border);
}
.hero h1 {
  font-size: clamp(2rem, 4vw, 2.75rem);
  max-width: 14ch;
}
.hero .lede {
  font-size: 1.1rem;
  color: var(--muted);
  max-width: 50ch;
}

.search-wrap {
  margin-top: 28px;
  max-width: 480px;
}
.search-label {
  font-family: var(--font-mono);
  font-size: .72rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
  display: block;
  margin-bottom: 6px;
}
.search-input {
  width: 100%;
  padding: 13px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-family: var(--font-body);
  font-size: 1rem;
  color: var(--ink);
}
.search-input:focus { border-color: var(--accent); }

/* ---------- Tool grid / cards ---------- */
.section { padding: 48px 0; }
.section-title { font-size: 1.5rem; margin-bottom: 24px; }

.tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}

.tool-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  transition: border-color .15s ease, transform .15s ease;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.tool-card:hover { border-color: var(--accent); transform: translateY(-2px); }

.tool-card h3 { font-size: 1.1rem; margin: 0; }
.tool-card p { font-size: .92rem; color: var(--muted); margin: 0; flex-grow: 1; }
.tool-card .go { font-size: .85rem; font-weight: 600; color: var(--accent); }

.empty-state {
  display: none;
  text-align: center;
  color: var(--muted);
  padding: 40px 0;
}

/* ---------- Tool page layout ---------- */
.tool-header { padding: 40px 0 8px; }
.breadcrumb { font-size: .85rem; color: var(--muted); margin-bottom: 14px; }
.breadcrumb a:hover { color: var(--ink); }

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px;
  margin: 24px 0;
}

.field { margin-bottom: 18px; }
.field label {
  display: block;
  font-size: .85rem;
  font-weight: 600;
  margin-bottom: 6px;
}
.field input[type="text"],
.field input[type="number"],
textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 1rem;
  color: var(--ink);
  background: var(--bg);
}
textarea { min-height: 220px; resize: vertical; line-height: 1.6; }
.field input:focus, textarea:focus { border-color: var(--accent); background: var(--surface); }

/* Readout: the "calculator LCD" signature element on tool pages */
.readout {
  font-family: var(--font-mono);
  background: var(--ink);
  color: #F4FFFA;
  border-radius: var(--radius-sm);
  padding: 20px;
  display: flex;
  flex-wrap: wrap;
  gap: 24px;
}
.readout .stat { min-width: 90px; }
.readout .stat .n { font-size: 1.6rem; font-weight: 600; display: block; }
.readout .stat .l { font-size: .68rem; letter-spacing: .06em; text-transform: uppercase; opacity: .6; }

.limits-list { margin-top: 18px; display: grid; gap: 10px; }
.limit-row {
  display: flex; align-items: center; justify-content: space-between;
  font-size: .88rem; padding: 10px 14px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
}
.limit-row .count { font-family: var(--font-mono); font-weight: 600; }
.limit-row.over { border-color: var(--danger); background: var(--danger-soft); }
.limit-row.over .count { color: var(--danger); }

.tabs { display: flex; gap: 8px; margin-bottom: 20px; flex-wrap: wrap; }
.tab-btn {
  padding: 9px 16px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: .88rem;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
}
.tab-btn.active { background: var(--ink); color: #fff; border-color: var(--ink); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

.result-box {
  font-family: var(--font-mono);
  background: var(--success-soft);
  color: #084A38;
  border: 1px solid var(--success);
  border-radius: var(--radius-sm);
  padding: 18px;
  font-size: 1.3rem;
  font-weight: 600;
  margin-top: 4px;
}

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--ink);
  color: #fff;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-size: .9rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- Footer ---------- */
.site-footer {
  border-top: 1px solid var(--border);
  margin-top: 64px;
  padding: 32px 0;
  font-size: .85rem;
  color: var(--muted);
}
.site-footer .container {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}

/* ---------- Responsive ---------- */
@media (max-width: 720px) {
  .nav { position: fixed; inset: 68px 0 auto 0; background: var(--surface); flex-direction: column; align-items: flex-start; padding: 16px 24px; border-bottom: 1px solid var(--border); transform: translateY(-130%); transition: transform .2s ease; }
  .nav.open { transform: translateY(0); }
  .nav-toggle { display: block; }
  .panel { padding: 20px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
  html { scroll-behavior: auto; }
}

/* ---------- Category dropdown nav ---------- */
.nav-item { position: relative; }
.nav-dropdown-toggle {
  background: none; border: none; cursor: pointer;
  font-family: var(--font-body); font-size: .95rem; font-weight: 500;
  color: var(--muted); padding: 0; display: flex; align-items: center; gap: 4px;
}
.nav-dropdown-toggle:hover, .nav-dropdown-toggle.open { color: var(--ink); }
.nav-dropdown-toggle .caret { font-size: .7rem; transition: transform .15s ease; }
.nav-dropdown-toggle.open .caret { transform: rotate(180deg); }

.nav-dropdown-menu {
  display: none;
  position: absolute;
  top: calc(100% + 14px);
  left: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  min-width: 200px;
  padding: 8px;
  z-index: 60;
}
.nav-dropdown-menu.open { display: block; }
.nav-dropdown-menu a {
  display: block;
  padding: 9px 12px;
  border-radius: 6px;
  font-size: .9rem;
  color: var(--ink);
}
.nav-dropdown-menu a:hover { background: var(--bg); }

@media (max-width: 720px) {
  .nav-dropdown-menu {
    display: block;
    position: static;
    border: none;
    box-shadow: none;
    padding: 0 0 8px 12px;
    min-width: 0;
  }
  .nav-dropdown-toggle .caret { display: none; }
}
/* ==========================================================================
   Dark mode
   Toggled via html.dark-mode class (added by js/main.js). Only the color
   variables change — layout, spacing and fonts stay identical.
   ========================================================================== */
html.dark-mode {
  --bg: #14161C;
  --surface: #1C1F27;
  --ink: #EDEDEB;
  --muted: #9A9DAA;
  --border: #2C2F3A;
  --accent: #FF6B3D;
  --accent-ink: #FFFFFF;
  --accent-soft: #3D2416;
  --success: #3DDBA0;
  --success-soft: #123526;
  --danger: #FF7272;
  --danger-soft: #3A1414;
}

/* A handful of components deliberately use a fixed dark surface (calculator
   LCD readouts, active-tab pills, numbered badges) regardless of theme —
   force those back to a constant dark color so they don't invert to a pale
   background in dark mode. !important is needed here because several tool
   pages redeclare these same selectors in their own inline <style> blocks
   later in the document, which would otherwise win the cascade. */
html.dark-mode .readout,
html.dark-mode .tab-btn.active,
html.dark-mode .step-num,
html.dark-mode .thumb-num {
  background: #14161C !important;
  color: #F4FFFA !important;
}

/* Theme toggle button (injected into the header by js/main.js) */
.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1.05rem;
  margin-left: 8px;
  flex-shrink: 0;
  transition: border-color .15s ease, transform .15s ease;
}
.theme-toggle:hover { border-color: var(--accent); }
.theme-toggle:active { transform: scale(0.92); }
/* ==========================================================================
   Dark mode fixes — round 2
   ========================================================================== */

/* Helps browser-native form control chrome (some input/select rendering,
   scrollbars) match the dark theme more consistently. */
html.dark-mode {
  color-scheme: dark;
}

/* More "always-dark surface" components that were missed in the first pass —
   same issue as .readout/.tab-btn.active: they use var(--ink) as a background
   assuming it's always dark, which breaks once --ink flips to a light color
   for dark-mode text. Force them back to a fixed dark surface. */
html.dark-mode .pw-display,
html.dark-mode .rate-btn.active,
html.dark-mode .preset-btn.active {
  background: #14161C !important;
  color: #F4FFFA !important;
}

/* ==========================================================================
   BMI Calculator — fix color bar to match real category widths
   ========================================================================== */
.bmi-scale div:nth-child(1) { flex: 0 0 14% !important; } /* Underweight: 15–18.5 */
.bmi-scale div:nth-child(2) { flex: 0 0 26% !important; } /* Normal: 18.5–25 */
.bmi-scale div:nth-child(3) { flex: 0 0 20% !important; } /* Overweight: 25–30 */
.bmi-scale div:nth-child(4) { flex: 0 0 40% !important; } /* Obese: 30–40 */
/* ==========================================================================
   Mobile menu scroll fix
   ========================================================================== */
@media (max-width: 720px) {
  .nav {
    top: 68px;
    right: 0;
    bottom: 0;
    left: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
}

body.nav-locked {
  overflow: hidden;
}

.blog-card {
  background: var(--surface);
}