/* base.css — Chọn Mã UNSPSC site styles
   Wikipedia vector-2022 inspired. Plain CSS, no preprocessor.
   Target: ≤ 20KB gzipped. System font stack, light mode only. */

/* ===== CSS Variables ===== */
:root {
  --color-text: #202122;
  --color-text-muted: #54595d;
  --color-bg: #fff;
  --color-bg-alt: #f8f9fa;
  --color-border: #a2a9b1;
  --color-border-light: #eaecf0;
  --color-link: #1E3A8A;
  --color-link-visited: #0b0080;
  --color-link-hover: #3366bb;
  --color-accent: #0F766E;
  --color-badge-green: #d1e7dd;
  --color-badge-yellow: #fff3cd;
  --color-banner-hidden: #fff3cd;
  --color-banner-preview: #cfe2ff;

  --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;

  --max-container: 1120px;
  --width-content: 720px;
  --width-toc: 200px;
  --width-infobox: 280px;
  --gap-col: 24px;

  --header-height: 56px;
  --radius: 4px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.12);
}

/* ===== Reset ===== */
*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.7;
  color: var(--color-text);
  background: var(--color-bg);
}

h1, h2, h3, h4, h5, h6 {
  margin-top: 1.5em;
  margin-bottom: 0.5em;
  line-height: 1.3;
  font-weight: 600;
}
h1 { font-size: 2rem; margin-top: 0; }
h2 { font-size: 1.5rem; border-bottom: 1px solid var(--color-border-light); padding-bottom: 4px; }
h3 { font-size: 1.25rem; }
h4 { font-size: 1.1rem; }

p { margin: 0 0 1em; }

a { color: var(--color-link); text-decoration: none; }
a:visited { color: var(--color-link-visited); }
a:hover, a:focus { color: var(--color-link-hover); text-decoration: underline; }

ul, ol { padding-left: 1.5em; margin: 0 0 1em; }
li { margin-bottom: 0.25em; }

code, kbd, samp {
  font-family: var(--font-mono);
  font-size: 0.875em;
  background: var(--color-bg-alt);
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius);
  padding: 1px 4px;
}

pre {
  background: var(--color-bg-alt);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1em;
  overflow-x: auto;
  font-size: 0.875em;
  line-height: 1.5;
  position: relative;
}
pre code { background: none; border: none; padding: 0; }

table {
  border-collapse: collapse;
  width: 100%;
  margin-bottom: 1em;
  font-size: 0.9375em;
}
th, td {
  border: 1px solid var(--color-border);
  padding: 6px 10px;
  text-align: left;
  vertical-align: top;
}
th {
  background: var(--color-bg-alt);
  font-weight: 600;
}
tr:nth-child(even) td { background: var(--color-bg-alt); }

blockquote {
  border-left: 3px solid var(--color-accent);
  margin: 0 0 1em 0;
  padding: 0.5em 1em;
  color: var(--color-text-muted);
  background: var(--color-bg-alt);
}

img { max-width: 100%; height: auto; }

/* ===== Skip link (a11y) ===== */
.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 300;
  background: var(--color-bg);
  color: var(--color-link);
  padding: 8px 12px;
  border: 2px solid var(--color-link);
  text-decoration: none;
}
.skip-link:focus { left: 8px; top: 8px; }

/* ===== Layout container ===== */
.header-inner,
.footer-inner {
  max-width: var(--max-container);
  margin: 0 auto;
  padding: 0 16px;
}

/* ===== Site Header ===== */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-border-light);
  box-shadow: var(--shadow-sm);
  height: var(--header-height);
}

.header-inner {
  display: flex;
  align-items: center;
  gap: 24px;
  height: 100%;
}

.site-logo {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--color-link);
  text-decoration: none;
  white-space: nowrap;
  flex-shrink: 0;
}
.site-logo:hover { text-decoration: none; color: var(--color-link-hover); }

.site-logo-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 6px;
  background: var(--color-link);
  border-radius: 8px;
  flex-shrink: 0;
}
.site-logo-mark img { display: block; width: 100%; height: 100%; }

.site-nav { flex: 1; }
.site-nav ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  align-items: center;
  gap: 4px;
}
.site-nav li { margin: 0; }
.site-nav a {
  display: block;
  padding: 6px 10px;
  border-radius: var(--radius);
  font-size: 0.9375em;
  line-height: 1.4;
  white-space: nowrap;
}
.site-nav a:hover { background: var(--color-bg-alt); text-decoration: none; }

.site-search {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}
.site-search input {
  width: 220px;
  padding: 6px 10px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 0.9375em;
  font-family: inherit;
}
.site-search input:focus {
  outline: 2px solid var(--color-link);
  outline-offset: 1px;
  border-color: var(--color-link);
}
.site-search button {
  padding: 6px 14px;
  background: var(--color-link);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.9375em;
  font-family: inherit;
}
.site-search button:hover { background: var(--color-link-hover); }

/* ===== Main content ===== */
#main-content {
  max-width: var(--max-container);
  margin: 0 auto;
  padding: 24px 16px 48px;
  min-height: calc(100vh - var(--header-height) - 120px);
}

/* Anchor-link offset: sticky header (56px) covers the heading when the
   browser jumps to #id. Push targets down so their top aligns below the
   header. Applies to any scrollable anchor target site-wide. */
:target,
[id] {
  scroll-margin-top: calc(var(--header-height) + 24px);
}

/* ===== Banners ===== */
.banner {
  padding: 10px 16px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: 0.9375em;
}
.banner-hidden { background: var(--color-banner-hidden); border: 1px solid #ffc107; }
.banner-preview { background: var(--color-banner-preview); border: 1px solid #0d6efd; }

/* ===== Breadcrumb ===== */
/* Stack vertically (1 item per line) on all viewports — breadcrumb titles
   often include long VN names + English terms, so horizontal flow wraps
   unpredictably and is hard to scan. */
.breadcrumb ol {
  list-style: none;
  margin: 0 0 16px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.875em;
  color: var(--color-text-muted);
}
.breadcrumb li + li::before { content: "› "; margin-right: 4px; }
.breadcrumb [aria-current="page"] { color: var(--color-text); font-weight: 500; }

/* ===== Article 3-column layout ===== */
.article-layout {
  display: grid;
  grid-template-columns: var(--width-toc) 1fr var(--width-infobox);
  grid-template-areas: "toc body infobox";
  gap: var(--gap-col);
  align-items: start;
}

.article-toc   { grid-area: toc; }
.article-body  { grid-area: body; max-width: var(--width-content); }
.article-infobox { grid-area: infobox; }

/* Hub/guide pages have no infobox — collapse to 2 columns so body
   widens gracefully instead of leaving a ghost column on the right. */
.article-layout-no-infobox {
  grid-template-columns: var(--width-toc) 1fr;
  grid-template-areas: "toc body";
}
.article-layout-no-infobox .article-body { max-width: 100%; }

/* ===== Article header ===== */
.article-header { margin-bottom: 20px; }
.article-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 0.875em;
  color: var(--color-text-muted);
  margin-top: 8px;
}
.version-tag {
  background: var(--color-bg-alt);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1px 6px;
  font-size: 0.8125em;
}

/* ===== TOC ===== */
.toc {
  position: sticky;
  top: calc(var(--header-height) + 16px);
  background: var(--color-bg-alt);
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius);
  padding: 12px;
  font-size: 0.875em;
}
.toc details summary {
  cursor: pointer;
  font-weight: 600;
  list-style: none;
  padding: 4px 0;
}
.toc details summary::-webkit-details-marker { display: none; }
.toc ol {
  margin: 8px 0 0;
  padding-left: 16px;
}
.toc li { margin-bottom: 4px; }
.toc a { color: var(--color-text); }
.toc a:hover { color: var(--color-link); }

/* ===== Hatnote ===== */
.hatnote {
  font-style: italic;
  color: var(--color-text-muted);
  border-left: 2px solid var(--color-accent);
  padding-left: 10px;
  margin-bottom: 16px;
  font-size: 0.9375em;
}

/* ===== Section anchors ===== */
.section-anchor {
  display: none;
  font-size: 0.8em;
  color: var(--color-border);
  text-decoration: none;
  margin-left: 6px;
}
h2:hover .section-anchor,
h3:hover .section-anchor { display: inline; }

/* ===== Infobox ===== */
.infobox {
  background: var(--color-bg-alt);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 0.875em;
  padding: 12px;
}
.infobox table { margin-bottom: 0; font-size: 1em; }
.infobox th {
  background: none;
  font-weight: 600;
  white-space: nowrap;
  width: 40%;
  color: var(--color-text-muted);
}
.infobox td { background: none; }
.infobox-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

/* ===== Tags ===== */
.tag {
  display: inline-block;
  background: var(--color-bg-alt);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  padding: 2px 8px;
  font-size: 0.8125em;
  color: var(--color-text);
}
.tag-list { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }

/* ===== Badges ===== */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 0.8125em;
  font-weight: 500;
}
.badge-green { background: var(--color-badge-green); color: #0a3622; }
.badge-yellow { background: var(--color-badge-yellow); color: #664d03; }

/* ===== FAQ ===== */
.article-faq dl {
  margin: 0;
  padding: 0;
}
.article-faq dt {
  font-weight: 600;
  color: var(--color-text);
  margin-top: 20px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.article-faq dt::before {
  content: "Q";
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--color-link);
  color: #fff;
  font-size: 0.75em;
  font-weight: 700;
}
.article-faq dd {
  margin: 8px 0 0 28px;
  color: var(--color-text);
}
.article-faq dd > :first-child { margin-top: 0; }
.article-faq dd > :last-child { margin-bottom: 0; }

/* ===== Article footer ===== */
.article-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px;
  font-size: 0.875em;
  color: var(--color-text-muted);
  border-top: 1px solid var(--color-border-light);
  margin-top: 32px;
  padding-top: 12px;
}

/* ===== Feedback ===== */
.feedback-section { margin-left: auto; }
.feedback-link {
  display: inline-block;
  padding: 4px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 0.875em;
  color: var(--color-text-muted);
}
.feedback-link:hover { border-color: var(--color-link); color: var(--color-link); }

/* ===== Commodity page ===== */
.page-commodity { max-width: var(--width-content); margin: 0 auto; }
.commodity-body h1 { margin-bottom: 16px; }
.commodity-meta {
  background: var(--color-bg-alt);
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius);
  padding: 12px 16px;
  font-size: 0.9375em;
  margin: 16px 0;
}

/* ===== Search forms ===== */
.search-form-large {
  display: flex;
  gap: 8px;
  max-width: 600px;
  margin: 16px 0;
}
.search-form-large input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 1em;
  font-family: inherit;
}
.search-form-large input:focus {
  outline: 2px solid var(--color-link);
  outline-offset: 1px;
}
.search-form-large button {
  padding: 10px 20px;
  background: var(--color-link);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 1em;
  font-family: inherit;
  white-space: nowrap;
}
.search-form-large button:hover { background: var(--color-link-hover); }

/* ===== Search results ===== */
.search-query-echo { color: var(--color-text-muted); margin-bottom: 16px; }
.result-list { list-style: none; padding: 0; }
.result-card {
  border-bottom: 1px solid var(--color-border-light);
  padding: 12px 0;
}
.result-title { font-size: 1.1em; font-weight: 600; display: block; }
.result-desc { margin: 4px 0; color: var(--color-text-muted); font-size: 0.9375em; }
.result-slug { font-size: 0.8125em; color: var(--color-accent); font-family: var(--font-mono); }

.pagination {
  display: flex;
  gap: 16px;
  align-items: center;
  margin-top: 24px;
  font-size: 0.9375em;
}

.no-results {
  padding: 32px 0;
  color: var(--color-text-muted);
  text-align: center;
}

/* ===== Homepage ===== */
.home-hero {
  padding: 32px 0 24px;
  border-bottom: 1px solid var(--color-border-light);
  margin-bottom: 32px;
}
.home-hero h1 { font-size: 2rem; margin-bottom: 16px; }
.home-hero-sub { color: var(--color-text-muted); font-size: 0.9375em; margin-top: 8px; }
.home-intro, .home-section { margin-bottom: 32px; }

/* ===== Segment grid ===== */
.segment-grid {
  list-style: none;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}
.segment-card {
  background: var(--color-bg-alt);
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius);
  padding: 10px 12px;
  font-size: 0.9375em;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.segment-code { font-family: var(--font-mono); font-size: 0.8125em; color: var(--color-text-muted); }

/* ===== Hub / guide grids ===== */
.hub-grid {
  list-style: none;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 10px;
}
.hub-card {
  background: var(--color-bg-alt);
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius);
  padding: 10px 12px;
  font-size: 0.9375em;
}
.guide-list { list-style: disc; padding-left: 1.5em; }

/* ===== Listing index (/huong-dan, /nganh, /tinh-huong) ===== */
/* Fills the container (= header width) so cards align with nav edges. */
.page-listing-index {
  max-width: var(--max-container);
}
.page-listing-index h1 {
  font-size: 2rem;
  margin-bottom: 8px;
}
.listing-index-lead {
  color: var(--color-text-muted);
  font-size: 1.0625em;
  line-height: 1.6;
  margin: 0 0 28px;
  max-width: 62ch;
}
.listing-cards {
  list-style: none;
  padding: 0;
  margin: 0 0 32px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}
.listing-card {
  background: var(--color-bg-alt);
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius);
  padding: 16px 18px;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}
.listing-card:hover {
  border-color: var(--color-link);
  background: var(--color-bg);
}
.listing-card h2 {
  border-bottom: none;
  font-size: 1.125rem;
  margin: 0 0 6px;
  padding: 0;
  font-weight: 600;
  line-height: 1.35;
}
.listing-card h2 a { text-decoration: none; }
.listing-card:hover h2 a { text-decoration: underline; }
.listing-card-desc {
  margin: 0;
  color: var(--color-text-muted);
  font-size: 0.9375em;
  line-height: 1.55;
}
.listing-index-empty {
  color: var(--color-text-muted);
  font-style: italic;
  padding: 24px 0;
}
.listing-index-footer {
  margin-top: 32px;
  padding-top: 16px;
  border-top: 1px solid var(--color-border-light);
  font-size: 0.9375em;
  color: var(--color-text-muted);
}
.listing-index-footer a { color: var(--color-text-muted); }
.listing-index-footer a:hover { color: var(--color-link); }

@media (min-width: 720px) {
  .listing-cards { grid-template-columns: repeat(2, 1fr); gap: 16px; }
}
@media (min-width: 1024px) {
  .listing-cards { grid-template-columns: repeat(3, 1fr); }
}

/* ===== Static / trust pages ===== */
/* Center the whole page at reading width so breadcrumb + banner + body
   align at the same left edge — avoids the "wide banner, narrow body"
   visual mismatch on large screens. */
.page-static {
  max-width: var(--width-content);
  margin: 0 auto;
}
.page-static .static-body { max-width: 100%; }
.page-static .static-section { margin-top: 28px; }
.page-static .static-section h2 { margin-bottom: 12px; }
.static-footer { font-size: 0.875em; color: var(--color-text-muted); margin-top: 32px; border-top: 1px solid var(--color-border-light); padding-top: 12px; }

/* ===== Cookie banner ===== */
.cookie-banner {
  position: fixed;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: 0 2px 12px rgba(0,0,0,.15);
  padding: 12px 16px;
  max-width: 480px;
  width: calc(100% - 32px);
  z-index: 200;
  font-size: 0.9375em;
}
.cookie-banner p { margin: 0 0 10px; }
.cookie-banner-actions { display: flex; gap: 8px; }
.cookie-banner-actions button {
  padding: 6px 16px;
  border-radius: var(--radius);
  cursor: pointer;
  font-family: inherit;
  font-size: 0.9375em;
  border: 1px solid var(--color-border);
  background: var(--color-bg);
}
#cookie-accept {
  background: var(--color-link);
  color: #fff;
  border-color: var(--color-link);
}
#cookie-accept:hover { background: var(--color-link-hover); }

/* ===== Copy-code button ===== */
.copy-btn {
  position: absolute;
  top: 6px;
  right: 6px;
  padding: 3px 8px;
  font-size: 0.75em;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  cursor: pointer;
  font-family: inherit;
  opacity: 0;
  transition: opacity 0.15s;
}
pre:hover .copy-btn { opacity: 1; }

/* ===== Site Footer ===== */
.site-footer {
  border-top: 1px solid var(--color-border-light);
  background: var(--color-bg-alt);
  padding: 20px 0;
  font-size: 0.875em;
}
.footer-inner nav ul {
  list-style: none;
  margin: 0 0 12px;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
}
.footer-copy { color: var(--color-text-muted); margin: 0; }

/* ===== Search landing ===== */
.search-landing-hero { padding: 32px 0 24px; }
.search-landing-intro { margin-bottom: 24px; }
.segment-grid-section, .search-landing-section { margin-bottom: 32px; }

/* ===== Responsive — mobile ===== */
@media (max-width: 768px) {
  .article-layout {
    grid-template-columns: 1fr;
    grid-template-areas:
      "infobox"
      "toc"
      "body";
  }

  .article-infobox { order: -2; }
  .article-toc { order: -1; }

  .toc {
    position: static;
    margin-bottom: 16px;
  }

  .article-body { max-width: 100%; }

  .site-header { height: auto; padding: 8px 0; }
  .header-inner {
    flex-wrap: nowrap;
    gap: 8px;
    padding: 8px 12px;
  }
  .site-logo-text { display: none; }
  .site-nav { display: none; }
  .site-search { flex: 1; min-width: 0; }
  .site-search input { width: auto; flex: 1; min-width: 0; }

  .search-form-large { flex-direction: column; }
  .search-form-large input { width: 100%; }

  .segment-grid { grid-template-columns: repeat(2, 1fr); }
  .hub-grid { grid-template-columns: repeat(2, 1fr); }

  .cookie-banner { bottom: 8px; }
}
