/* ═══════════════════════════════════════════
   TechQueries Forum — common.css
   Edit ONE file → changes apply everywhere
   ═══════════════════════════════════════════ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ── Design tokens ── */
:root {
  /* ── Palette: warm paper + forest green + ink ── */
  --bg:           #f7f5f0;        /* warm off-white — paper, not dashboard */
  --surface:      #ffffff;
  --surface-alt:  #f2efe9;        /* warm tint for inputs/code */
  --border:       #ddd8ce;        /* warmer than cool gray */
  --border-hover: #b8b0a2;
  --text-primary: #1c1917;        /* near-black ink, not pure #000 */
  --text-secondary:#44403c;       /* stone-700 */
  --text-muted:   #a8a29e;        /* stone-400 */

  /* ── Accent: forest green — trust, resolved, authority ── */
  --accent:       #0f7c5a;
  --accent-hover: #0a5e44;
  --accent-bg:    #ecfdf5;        /* very light green tint */
  --accent-text:  #065f46;

  /* ── Solved / Hot / Tags ── */
  --solved-bg:    #ecfdf5;
  --solved-text:  #065f46;
  --hot-bg:       #fff7ed;
  --hot-text:     #9a3412;
  --hot-border:   #fed7aa;
  --tag-bg:       #f5f3ef;
  --tag-text:     #57534e;        /* stone-600 */

  /* ── Layout ── */
  --radius:       7px;            /* less rounded — more editorial, less bubbly */
  --max-width:    1160px;
  --header-height:68px;
  --logo-size:    20px;
  --logo-color:   var(--text-primary);
  --header-bg:    #ffffff;
  --body-font-size:17px;

  /* ── Typography: editorial body, system UI nav ── */
  --font:         -apple-system, 'Segoe UI', Arial, sans-serif;
  --font-serif:   Georgia, 'Times New Roman', serif;   /* thread titles */

  font-family: var(--font);
  background: var(--bg);
  color: var(--text-primary);
  font-size: var(--body-font-size);
  line-height: 1.75;
}

/* ── Base ── */
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text-primary);
  font-size: var(--body-font-size);
  line-height: 1.75;
}
a { color: inherit; text-decoration: none; }
button { font-family: var(--font); cursor: pointer; }

/* ══════════════════════════════
   HEADER
══════════════════════════════ */
.header {
  background: var(--header-bg);
  position: sticky;
  top: 0;
  z-index: 100;
}
.header-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 24px;
  height: var(--header-height);
  display: flex;
  align-items: center;
  gap: 20px;
  border-bottom: 2px solid var(--text-primary);
}
.logo {
  font-size: var(--logo-size);
  font-weight: 700;
  color: var(--logo-color);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  text-decoration: none;
}
.logo i { font-size: 28px; }
.logo:hover { opacity: 0.85; }

/* Search */
.header-search { flex: 1; max-width: 420px; position: relative; }
.header-search i {
  position: absolute; left: 14px; top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted); font-size: 19px;
  pointer-events: none;
}
.header-search input {
  width: 100%; height: 44px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0 14px 0 46px;
  font-size: 16px;
  font-family: var(--font);
  background: var(--surface-alt);
  color: var(--text-primary);
  outline: none;
  transition: border-color 0.15s, background 0.15s;
}
.header-search input:focus { border-color: var(--accent); background: var(--surface); }

/* Search results dropdown */
.search-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0; right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0,0,0,0.10);
  z-index: 300;
  overflow: hidden;
  display: none;
}
.search-dropdown.open { display: block; }
.search-result-item {
  display: flex; align-items: flex-start;
  gap: 12px; padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.1s;
  text-decoration: none;
  color: inherit;
}
.search-result-item:last-child { border-bottom: none; }
.search-result-item:hover { background: var(--surface-alt); }
.search-result-icon {
  width: 32px; height: 32px; border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; flex-shrink: 0; margin-top: 2px;
}
.search-result-title { font-size: 14px; font-weight: 500; color: var(--text-primary); margin-bottom: 3px; }
.search-result-meta { font-size: 12px; color: var(--text-muted); }
.search-no-result { padding: 18px 16px; font-size: 14px; color: var(--text-muted); text-align: center; }
.search-highlight { background: #fde68a; border-radius: 1px; padding: 0 1px; }

/* Nav */
.header-nav { display: flex; align-items: center; gap: 4px; margin-left: auto; }
.nav-link {
  padding: 6px 14px; border-radius: 5px;
  font-size: 14px; font-weight: 500;
  color: var(--text-secondary);
  transition: color 0.1s;
  white-space: nowrap;
}
.nav-link:hover { color: var(--text-primary); background: none; }
.nav-link.active { color: var(--text-primary); font-weight: 600; background: none; border-bottom: 2px solid var(--text-primary); border-radius: 0; }
.btn-ask {
  padding: 8px 18px;
  background: var(--text-primary); color: #fff;
  border: none; border-radius: 5px;
  font-size: 14px; font-weight: 600;
  display: flex; align-items: center; gap: 6px;
  transition: opacity 0.12s;
  margin-left: 12px;
  white-space: nowrap;
  text-decoration: none;
  letter-spacing: 0.01em;
}
.btn-ask:hover { opacity: 0.82; }

/* Hamburger */
.hamburger {
  display: none;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 42px; height: 42px;
  align-items: center; justify-content: center;
  font-size: 22px;
  color: var(--text-secondary);
  cursor: pointer;
  flex-shrink: 0;
  margin-left: 4px;
}

/* Mobile nav drawer */
.mobile-nav { display: none; position: fixed; inset: 0; z-index: 200; }
.mobile-nav.open { display: block; }
.mobile-nav-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.45); }
.mobile-nav-drawer {
  position: absolute; top: 0; right: 0;
  width: 270px; height: 100%;
  background: var(--surface);
  padding: 20px 16px;
  box-shadow: -4px 0 28px rgba(0,0,0,0.13);
  display: flex; flex-direction: column; gap: 4px;
  overflow-y: auto;
}
.mobile-nav-close {
  align-self: flex-end;
  background: none; border: 1px solid var(--border);
  border-radius: var(--radius); width: 38px; height: 38px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; color: var(--text-secondary); cursor: pointer;
  margin-bottom: 12px;
}
.mobile-nav-link {
  display: block; padding: 13px 16px;
  border-radius: var(--radius); font-size: 16px; font-weight: 500;
  color: var(--text-primary); transition: background 0.12s;
  text-decoration: none;
}
.mobile-nav-link:hover { background: var(--surface-alt); }
.mobile-nav-link.active { background: var(--accent-bg); color: var(--accent-text); }
.mobile-nav-link.btn-style {
  background: var(--accent); color: #fff;
  text-align: center; margin-top: 10px;
}
.mobile-nav-link.btn-style:hover { background: var(--accent-hover); }
.mobile-nav-divider { border: none; border-top: 1px solid var(--border); margin: 6px 0; }

/* ══════════════════════════════
   FOOTER
══════════════════════════════ */
.site-footer {
  background: #1c1917;
  color: #94a3b8;
  margin-top: 60px;
}
.footer-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 52px 24px 30px;
}
.footer-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 48px;
  margin-bottom: 44px;
}
.footer-brand .footer-logo {
  font-size: 22px; font-weight: 700;
  color: #fff; display: flex; align-items: center;
  gap: 9px; margin-bottom: 14px;
}
.footer-brand .footer-logo i { font-size: 26px; color: #6ee7b7; }
.footer-brand p { font-size: 15px; line-height: 1.75; max-width: 280px; }
.footer-col h4 {
  font-size: 13px; font-weight: 700;
  color: #e2e8f0; text-transform: uppercase;
  letter-spacing: 0.08em; margin-bottom: 16px;
}
.footer-col a {
  display: block; font-size: 15px;
  color: #94a3b8; margin-bottom: 11px;
  line-height: 1.5;
  transition: color 0.12s;
}
.footer-col a:last-child { margin-bottom: 0; }
.footer-col a:hover { color: #fff; }
.footer-bottom {
  border-top: 1px solid #292524;
  padding-top: 24px;
  display: flex; align-items: center;
  justify-content: space-between; flex-wrap: wrap; gap: 12px;
  font-size: 14px;
}
.footer-bottom-links { display: flex; gap: 22px; }
.footer-bottom-links a { color: #94a3b8; }
.footer-bottom-links a:hover { color: #fff; }

/* ══════════════════════════════
   SHARED UTILITY CLASSES
══════════════════════════════ */
.breadcrumb {
  display: flex; align-items: center; gap: 8px;
  font-size: 14px; color: var(--text-muted);
  margin-bottom: 22px; flex-wrap: wrap;
}
.breadcrumb a { color: var(--text-secondary); text-decoration: underline; text-underline-offset: 2px; }
.breadcrumb a:hover { text-decoration: underline; }
.breadcrumb i { font-size: 13px; }

.tag {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 3px;
  font-size: 13px; font-weight: 500;
  background: var(--tag-bg); color: var(--tag-text);
  white-space: nowrap;
}
.tag i { font-size: 13px; }
.tag.solved { background: var(--solved-bg); color: var(--solved-text); border: 1px solid #86efac; }
.tag.hot { background: var(--hot-bg); color: var(--hot-text); border: 1px solid var(--hot-border); }

.widget { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.widget-header {
  padding: 12px 16px; border-bottom: 1px solid var(--border);
  font-size: 12px; font-weight: 600; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.08em;
  display: flex; align-items: center; gap: 7px;
}
.widget-header i { font-size: 14px; color: var(--text-muted); }
.widget-body { padding: 16px 18px; }

/* Toast */
.toast {
  position: fixed; bottom: 24px; right: 24px;
  background: var(--text-primary); color: #fff;
  padding: 13px 20px; border-radius: var(--radius);
  font-size: 15px; display: flex; align-items: center; gap: 10px;
  z-index: 500;
  transform: translateY(80px); opacity: 0;
  transition: all 0.25s ease;
  pointer-events: none;
}
.toast.show { transform: translateY(0); opacity: 1; }
.toast i { font-size: 18px; color: #4ade80; }

/* ══════════════════════════════
   RESPONSIVE — HEADER & FOOTER
══════════════════════════════ */
@media (max-width: 900px) {
  .footer-grid { grid-template-columns: 1fr 1fr; gap: 28px; }
}

@media (max-width: 640px) {
  :root {
    --header-height: 56px;
    --body-font-size: 15px;
  }

  /* ══ HEADER ══ */
  .header-inner {
    padding: 0 12px;
    gap: 8px;
    height: 56px;
  }
  .logo { font-size: 17px; gap: 6px; }
  .logo i { font-size: 20px; }
  .header-search { display: none; }
  .header-nav { gap: 4px; }
  .header-nav .nav-link { display: none; }
  .header-nav .btn-ask {
    font-size: 13px;
    padding: 7px 10px;
    border-radius: var(--radius);
    gap: 4px;
    white-space: nowrap;
    margin-left: 0;
  }
  .hamburger { display: flex; width: 36px; height: 36px; font-size: 19px; }

  /* ══ SEARCH DROPDOWN ══ */
  .search-dropdown {
    position: fixed;
    top: 56px; left: 0; right: 0;
    border-radius: 0;
    border-left: none; border-right: none;
    max-height: 60vh;
    overflow-y: auto;
  }
  .search-result-item { padding: 10px 14px; gap: 10px; }
  .search-result-title { font-size: 13px; }
  .search-result-meta { font-size: 11px; }

  /* ══ FOOTER ══ */
  .footer-inner { padding: 36px 18px 20px; }

  /* Brand full width on top, then 2 columns below */
  .footer-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 28px 24px;
    margin-bottom: 28px;
  }
  .footer-brand {
    grid-column: 1 / -1; /* spans both columns */
    padding-bottom: 4px;
  }
  .footer-brand .footer-logo { font-size: 19px; margin-bottom: 8px; }
  .footer-brand p { font-size: 14px; line-height: 1.7; }

  /* Forum col — left, Support col — right, side by side */
  .footer-col { display: flex; flex-direction: column; }
  .footer-col h4 {
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.08em;
    margin-bottom: 12px;
    color: #e2e8f0;
  }
  .footer-col a {
    font-size: 14px;
    margin-bottom: 10px;
    color: #94a3b8;
    line-height: 1.5;
  }
  .footer-col a:hover { color: #fff; }

  /* Footer bottom */
  .footer-bottom {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    padding-top: 18px;
    font-size: 13px;
  }
  .footer-bottom-links { flex-wrap: wrap; gap: 12px; }

  /* ══ MOBILE NAV DRAWER ══ */
  .mobile-nav-drawer { width: 240px; padding: 16px 12px; }
  .mobile-nav-link { font-size: 15px; padding: 11px 14px; }
}

/* ════════════════════════════════════════════════
   CORE WEB VITALS — Performance & Mobile Fixes
   ════════════════════════════════════════════════ */

/* ── LCP: ensure above-fold content paints fast ── */
/* will-change removed — only use on actively animating elements */
.logo { font-size:clamp(16px,2.5vw,24px); }

/* ── Header is position:sticky — no body padding needed ── */

/* ── Inter font-display:swap handled via Google Fonts URL &display=swap ── */

/* ── Smooth interactions ── */
a, button { -webkit-tap-highlight-color:transparent; }
img { max-width:100%; height:auto; display:block; }

/* ── Mobile: prevent 300ms tap delay ── */
html { touch-action:manipulation; }

/* ── Mobile: min tap target 44×44px (WCAG 2.5.5) ── */
@media (max-width:768px) {
  /* iOS font zoom prevention */
  input, select, textarea { font-size:16px !important; }
  /* Smooth scroll */
  html { scroll-behavior:smooth; -webkit-overflow-scrolling:touch; }
  /* Code overflow */
  pre, code { overflow-x:auto; white-space:pre-wrap; word-break:break-word; }
  /* Post readability */
  .post-body { font-size:15px; line-height:1.8; }
}

/* ── Accessibility ── */
:focus-visible {
  outline:2px solid var(--accent);
  outline-offset:2px;
  border-radius:4px;
}
:focus:not(:focus-visible) { outline:none; }

/* ── Reduce motion for users who prefer it ── */
@media (prefers-reduced-motion:reduce) {
  *, *::before, *::after {
    animation-duration:0.01ms !important;
    transition-duration:0.01ms !important;
  }
}

/* ── Dark mode support (optional, future-proof) ── */
@media (prefers-color-scheme:dark) {
  /* Intentionally left blank — add dark theme vars here when needed */
}

/* ── Screen reader only utility ── */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

/* ── Thread Reply Widget (injected by common.js) ── */
.reply-section { background:var(--surface); border:1px solid var(--border); border-radius:var(--radius); padding:24px; margin-top:20px; }
.reply-section h3 { font-size:17px; font-weight:600; margin-bottom:14px; display:flex; align-items:center; gap:8px; }
.reply-section h3 i { color:var(--accent); }
.reply-section textarea { width:100%; min-height:110px; border:1px solid var(--border); border-radius: var(--radius); padding:12px; font-size:14px; font-family:var(--font); color:var(--text-primary); background:var(--surface-alt); resize:vertical; outline:none; transition:border-color .15s; margin-bottom:12px; line-height:1.7; }
.reply-section textarea:focus { border-color:var(--accent); background:var(--surface); }
.reply-actions { display:flex; align-items:center; justify-content:space-between; gap:10px; }
.reply-note { font-size:12px; color:var(--text-muted); display:flex; align-items:center; gap:5px; }
.reply-user-grid { display:grid; grid-template-columns:1fr 1fr; gap:14px; margin-bottom:14px; }
.reply-label { font-size:13px; font-weight:500; color:var(--text-primary); display:block; margin-bottom:6px; }
.reply-input { width:100%; height:40px; border:1px solid var(--border); border-radius: var(--radius); padding:0 12px; font-size:14px; font-family:var(--font); background:var(--surface-alt); outline:none; color:var(--text-primary); transition:border-color .15s; }
.reply-input:focus { border-color:var(--accent); }
.btn-back-reply { padding:9px 18px; border:1px solid var(--border); border-radius: var(--radius); background:var(--surface); font-size:14px; color:var(--text-secondary); cursor:pointer; font-family:var(--font); display:flex; align-items:center; gap:6px; transition:background .12s; }
.btn-back-reply:hover { background:var(--surface-alt); }
.reply-success-icon { width:56px; height:56px; background:#f0fdf4; border:2px solid #bbf7d0; border-radius:50%; display:flex; align-items:center; justify-content:center; margin:0 auto 16px; font-size:26px; color:var(--accent); }
@media (max-width:640px) {
  .reply-section { padding:14px; }
  .reply-user-grid { grid-template-columns:1fr; }
  .reply-actions { flex-direction:column; align-items:stretch; }
  .btn-back-reply, .btn-submit { width:100%; justify-content:center; }
}
