/* ==========================================================================
   SmartGen HTML Code Library — Design System
   One shared stylesheet for every page. Edit here, it updates everywhere.
   ========================================================================== */

/* ---- Tokens -------------------------------------------------------------- */
:root {
  /* Brand (extends SmartGen's core blue) */
  --brand: #2451EA;
  --brand-deep: #16309E;
  --brand-soft: #EEF1FF;
  --signal: #E85D2C;        /* HTML5-orange-derived accent: live/beta/copy states */
  --signal-soft: #FDECE3;

  /* Surface & text */
  --paper: #F7F8FC;
  --panel: #FFFFFF;
  --ink: #10121B;
  --ink-soft: #565A72;
  --ink-faint: #8B8FA3;
  --border: #E3E6F0;
  --border-strong: #CBD0E0;

  /* Code panel (the signature element) */
  --code-bg: #0F1220;
  --code-panel: #171A2C;
  --code-text: #D9DCF2;
  --code-tag: #7FB2FF;
  --code-attr: #C9A6FF;
  --code-string: #8FE3B0;
  --code-comment: #6B7094;

  /* Status */
  --success: #189B62;
  --success-soft: #E4F7EC;
  --warn: #B4780A;
  --warn-soft: #FBF0DC;

  /* Type */
  --font-display: "Space Grotesk", "Segoe UI", ui-sans-serif, system-ui, sans-serif;
  --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;

  /* Rhythm */
  --radius-sm: 8px;
  --radius: 14px;
  --radius-lg: 20px;
  --shadow-sm: 0 1px 2px rgba(16, 18, 27, 0.06);
  --shadow: 0 8px 24px rgba(16, 18, 27, 0.08);
  --shadow-lg: 0 24px 60px rgba(16, 18, 27, 0.14);
  --container: 1180px;
}

/* ---- Reset ---------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; scroll-behavior: auto !important; }
}
body { margin: 0; }
img, svg { display: block; max-width: 100%; }
a { color: inherit; }
button { font: inherit; }
ul, ol { padding: 0; margin: 0; }
h1, h2, h3, h4, p, ul, ol, figure { margin: 0; }

/* ---- Base ------------------------------------------------------------------ */
body {
  font-family: var(--font-body);
  background: var(--paper);
  color: var(--ink);
  line-height: 1.6;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { font-family: var(--font-display); font-weight: 600; letter-spacing: -0.01em; color: var(--ink); line-height: 1.2; }
code, pre, .mono { font-family: var(--font-mono); }
:focus-visible { outline: 2.5px solid var(--brand); outline-offset: 2px; border-radius: 4px; }

.container { max-width: var(--container); margin: 0 auto; padding: 0 24px; }
main.container { padding-top: 32px; padding-bottom: 72px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; }
.skip-link { position: absolute; left: -999px; top: 0; background: var(--brand); color: #fff; padding: 10px 16px; z-index: 999; border-radius: 0 0 8px 0; }
.skip-link:focus { left: 0; }

/* ---- Header ----------------------------------------------------------------- */
.site-header { position: sticky; top: 0; z-index: 40; background: rgba(247, 248, 252, 0.86); backdrop-filter: saturate(180%) blur(10px); border-bottom: 1px solid var(--border); }
.site-header .bar { display: flex; align-items: center; gap: 20px; height: 68px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; font-family: var(--font-display); font-weight: 700; font-size: 1.05rem; color: var(--ink); white-space: nowrap; }
.brand .mark { width: 34px; height: 34px; border-radius: 9px; background: linear-gradient(155deg, var(--brand), var(--brand-deep)); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.brand .mark svg { width: 18px; height: 18px; }
.brand .sub { display: block; font-family: var(--font-body); font-weight: 500; font-size: 0.68rem; color: var(--ink-faint); letter-spacing: 0.02em; }

.main-nav { display: flex; align-items: center; gap: 4px; flex: 1; overflow-x: auto; scrollbar-width: none; }
.main-nav::-webkit-scrollbar { display: none; }
.main-nav a { display: inline-flex; padding: 8px 12px; border-radius: 8px; font-size: 0.88rem; font-weight: 500; color: var(--ink-soft); text-decoration: none; white-space: nowrap; }
.main-nav a:hover { background: var(--brand-soft); color: var(--brand-deep); }
.main-nav a.active { color: var(--brand-deep); background: var(--brand-soft); }

.header-actions { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.gh-link { display: inline-flex; align-items: center; gap: 7px; padding: 8px 13px; border: 1px solid var(--border-strong); border-radius: 9px; text-decoration: none; font-size: 0.84rem; font-weight: 600; color: var(--ink); background: var(--panel); }
.gh-link:hover { border-color: var(--brand); color: var(--brand-deep); }
.gh-link svg { width: 15px; height: 15px; }
.nav-toggle { display: none; }

/* ---- Breadcrumb --------------------------------------------------------------- */
.breadcrumb { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 0.82rem; color: var(--ink-faint); margin-bottom: 18px; }
.breadcrumb a { text-decoration: none; color: var(--ink-soft); }
.breadcrumb a:hover { color: var(--brand); }
.breadcrumb .sep { opacity: 0.6; }
.breadcrumb .current { color: var(--ink); font-weight: 600; }

/* ---- Page head ------------------------------------------------------------------ */
.page-head { max-width: 760px; margin-bottom: 34px; }
.page-head h1 { font-size: clamp(1.7rem, 3.4vw, 2.5rem); margin-bottom: 12px; }
.page-head .lead { font-size: 1.06rem; color: var(--ink-soft); line-height: 1.65; }
.kicker { display: inline-flex; align-items: center; gap: 7px; font-size: 0.72rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--brand-deep); background: var(--brand-soft); padding: 5px 11px; border-radius: 100px; margin-bottom: 14px; }

/* ---- Section rhythm --------------------------------------------------------------- */
.section { margin-top: 44px; }
.section > h2 { font-size: 1.2rem; margin-bottom: 4px; }
.section .section-hint { color: var(--ink-faint); font-size: 0.88rem; margin-bottom: 16px; }
.section-num { display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; border-radius: 6px; background: var(--brand-soft); color: var(--brand-deep); font-size: 0.72rem; font-weight: 700; margin-right: 8px; font-family: var(--font-mono); }

/* ---- Card / tool panel ---------------------------------------------------------------- */
.panel { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow-sm); }
.tool-card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 26px; box-shadow: var(--shadow); }
.tool-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 22px; align-items: start; }
@media (max-width: 860px) { .tool-grid { grid-template-columns: 1fr; } }

/* ---- Form controls ------------------------------------------------------------------------ */
.field { margin-bottom: 15px; }
.field label { display: block; font-size: 0.82rem; font-weight: 600; color: var(--ink); margin-bottom: 6px; }
.field .hint { font-size: 0.76rem; color: var(--ink-faint); margin-top: 5px; }
.field-row { display: flex; gap: 12px; flex-wrap: wrap; }
.field-row .field { flex: 1; min-width: 130px; }
input[type=text], input[type=number], input[type=url], input[type=email], select, textarea {
  width: 100%; padding: 10px 12px; border: 1.5px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--paper); color: var(--ink); font-size: 0.92rem; font-family: var(--font-body); transition: border-color .15s, box-shadow .15s;
}
textarea { font-family: var(--font-mono); font-size: 0.86rem; resize: vertical; min-height: 96px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3.5px var(--brand-soft); }
input[type=color] { -webkit-appearance: none; appearance: none; width: 46px; height: 38px; padding: 3px; border: 1.5px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--panel); cursor: pointer; }
input[type=range] { width: 100%; accent-color: var(--brand); }
.color-field { display: flex; gap: 8px; align-items: center; }
.color-field input[type=text] { flex: 1; }
.chip-select { display: flex; flex-wrap: wrap; gap: 8px; }
.chip-select label { display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border: 1.5px solid var(--border-strong); border-radius: 100px; font-size: 0.82rem; font-weight: 500; cursor: pointer; margin: 0; color: var(--ink-soft); }
.chip-select input { position: absolute; opacity: 0; width: 0; height: 0; }
.chip-select input:checked + span { color: var(--brand-deep); font-weight: 700; }
.chip-select label:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); }
.checkbox-row { display: flex; align-items: center; gap: 8px; font-size: 0.86rem; color: var(--ink-soft); }
.checkbox-row input { width: 16px; height: 16px; accent-color: var(--brand); }

/* ---- Buttons ------------------------------------------------------------------------------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 10px 17px; border-radius: var(--radius-sm); font-size: 0.87rem; font-weight: 600; text-decoration: none; border: none; cursor: pointer; transition: transform .1s, background .15s, border-color .15s, color .15s; }
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-deep); }
.btn-ghost { background: transparent; border: 1.5px solid var(--border-strong); color: var(--ink); }
.btn-ghost:hover { border-color: var(--brand); color: var(--brand-deep); }
.btn-copy { background: var(--code-panel); color: var(--code-text); border: 1px solid #2A2E4A; }
.btn-copy:hover { background: #20233C; }
.btn-copy.is-copied { background: var(--success); color: #fff; border-color: var(--success); }
.btn svg { width: 15px; height: 15px; flex-shrink: 0; }
.btn-sm { padding: 6px 11px; font-size: 0.78rem; }
.btn-block { width: 100%; }

/* ---- Code panel (signature component) --------------------------------------------------------- */
.code-panel { background: var(--code-bg); border-radius: var(--radius); overflow: hidden; border: 1px solid #232746; }
.code-panel .code-chrome { display: flex; align-items: center; gap: 8px; padding: 10px 14px; background: var(--code-panel); border-bottom: 1px solid #232746; }
.code-panel .dots { display: flex; gap: 6px; }
.code-panel .dots span { width: 9px; height: 9px; border-radius: 50%; background: #3A3F63; }
.code-panel .filename { font-family: var(--font-mono); font-size: 0.74rem; color: var(--ink-faint); margin-left: 4px; }
.code-panel .live-badge { margin-left: auto; display: inline-flex; align-items: center; gap: 5px; font-size: 0.68rem; font-weight: 700; letter-spacing: 0.03em; color: var(--signal); text-transform: uppercase; }
.code-panel .live-badge .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--signal); animation: pulse-dot 1.8s ease-in-out infinite; }
@keyframes pulse-dot { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }
.code-panel pre { margin: 0; padding: 18px 16px; overflow-x: auto; font-size: 0.84rem; line-height: 1.65; color: var(--code-text); }
.code-panel .actions { display: flex; gap: 8px; padding: 10px 14px; border-top: 1px solid #232746; background: var(--code-panel); }
.tok-tag { color: var(--code-tag); }
.tok-attr { color: var(--code-attr); }
.tok-string { color: var(--code-string); }
.tok-comment { color: var(--code-comment); }

/* ---- Preview window --------------------------------------------------------------------------- */
.preview-window { border: 1.5px dashed var(--border-strong); border-radius: var(--radius); background: var(--panel); background-image: linear-gradient(45deg, #F0F1F7 25%, transparent 25%), linear-gradient(-45deg, #F0F1F7 25%, transparent 25%), linear-gradient(45deg, transparent 75%, #F0F1F7 75%), linear-gradient(-45deg, transparent 75%, #F0F1F7 75%); background-size: 18px 18px; background-position: 0 0, 0 9px, 9px -9px, -9px 0px; padding: 26px; min-height: 110px; display: flex; align-items: center; justify-content: center; text-align: center; overflow: auto; }
.preview-window.solid-bg { background-image: none; background: var(--panel); }
.preview-label { font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink-faint); margin-bottom: 10px; }

/* ---- Steps (How To Use) ------------------------------------------------------------------------ */
.steps { list-style: none; counter-reset: step; display: grid; gap: 14px; }
.steps li { counter-increment: step; display: flex; gap: 14px; align-items: flex-start; }
.steps li::before { content: counter(step); flex-shrink: 0; width: 28px; height: 28px; border-radius: 50%; background: var(--brand-soft); color: var(--brand-deep); font-family: var(--font-mono); font-weight: 700; font-size: 0.82rem; display: flex; align-items: center; justify-content: center; }
.steps li .step-body strong { display: block; font-size: 0.92rem; margin-bottom: 2px; }
.steps li .step-body span { font-size: 0.86rem; color: var(--ink-soft); }

/* ---- Compatibility table ------------------------------------------------------------------------ */
.compat-table, .ref-table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.compat-table th, .compat-table td, .ref-table th, .ref-table td { padding: 11px 14px; text-align: left; border-bottom: 1px solid var(--border); }
.compat-table th, .ref-table th { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--ink-faint); font-weight: 700; }
.ref-table { font-family: var(--font-mono); }
.support-yes { color: var(--success); font-weight: 700; }
.support-partial { color: var(--warn); font-weight: 700; }
.support-no { color: var(--ink-faint); }
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--panel); }
.table-wrap table { margin: 0; }

/* ---- Related pages ---------------------------------------------------------------------------------- */
.related-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.related-card { display: block; padding: 15px 16px; border: 1px solid var(--border); border-radius: var(--radius-sm); text-decoration: none; background: var(--panel); }
.related-card:hover { border-color: var(--brand); box-shadow: var(--shadow-sm); }
.related-card .cat { font-size: 0.68rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--brand); margin-bottom: 5px; }
.related-card .ttl { font-size: 0.92rem; font-weight: 600; color: var(--ink); }

/* ---- Badges / pills ------------------------------------------------------------------------------------ */
.badge-row { display: flex; flex-wrap: wrap; gap: 9px; }
.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 0.78rem; font-weight: 600; color: var(--ink-soft); background: var(--panel); border: 1px solid var(--border); padding: 7px 12px; border-radius: 100px; }
.badge svg { width: 13px; height: 13px; color: var(--success); flex-shrink: 0; }
.pill { display: inline-block; font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; padding: 3px 9px; border-radius: 100px; }
.pill-beta { background: var(--signal-soft); color: var(--signal); }
.pill-new { background: var(--success-soft); color: var(--success); }

/* ---- Beta banner --------------------------------------------------------------------------------------- */
.beta-banner { display: flex; gap: 12px; align-items: flex-start; background: var(--signal-soft); border: 1px solid #F3C7AC; color: #8A3E1B; padding: 14px 16px; border-radius: var(--radius); font-size: 0.86rem; margin-bottom: 28px; }
.beta-banner svg { width: 18px; height: 18px; flex-shrink: 0; margin-top: 1px; }
.beta-banner strong { display: block; margin-bottom: 2px; }

/* ---- Index page: hero -------------------------------------------------------------------------------------- */
.hero { padding: 56px 0 20px; }
.hero-grid { display: grid; grid-template-columns: 1.05fr 0.95fr; gap: 44px; align-items: center; }
@media (max-width: 940px) { .hero-grid { grid-template-columns: 1fr; } }
.hero h1 { font-size: clamp(2.1rem, 4.6vw, 3.35rem); margin-bottom: 16px; }
.hero h1 .accent { color: var(--brand); }
.hero .lead { font-size: 1.1rem; color: var(--ink-soft); max-width: 520px; margin-bottom: 26px; }
.hero-actions { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 30px; }
.stat-row { display: flex; gap: 28px; flex-wrap: wrap; }
.stat-row .stat b { display: block; font-family: var(--font-display); font-size: 1.5rem; color: var(--ink); }
.stat-row .stat span { font-size: 0.78rem; color: var(--ink-faint); }

/* ---- Index page: search + category nav ------------------------------------------------------------------------- */
.search-box { position: relative; margin: 0 0 30px; }
.search-box svg { position: absolute; left: 16px; top: 50%; transform: translateY(-50%); width: 17px; height: 17px; color: var(--ink-faint); }
.search-box input { width: 100%; padding: 13px 16px 13px 44px; border-radius: var(--radius); border: 1.5px solid var(--border-strong); font-size: 0.95rem; background: var(--panel); }
.cat-filter { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 30px; }
.cat-filter button { padding: 7px 14px; border-radius: 100px; border: 1.5px solid var(--border-strong); background: var(--panel); font-size: 0.8rem; font-weight: 600; color: var(--ink-soft); cursor: pointer; }
.cat-filter button.active, .cat-filter button:hover { border-color: var(--brand); background: var(--brand-soft); color: var(--brand-deep); }

/* ---- Index page: category sections + tool grid ------------------------------------------------------------------- */
.category-block { margin-top: 46px; scroll-margin-top: 90px; }
.category-block h2 { display: flex; align-items: center; gap: 10px; font-size: 1.25rem; margin-bottom: 4px; }
.category-block .cat-icon { width: 32px; height: 32px; border-radius: 9px; background: var(--brand-soft); color: var(--brand-deep); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.category-block .cat-icon svg { width: 17px; height: 17px; }
.category-block .cat-desc { color: var(--ink-faint); font-size: 0.86rem; margin: 4px 0 16px 42px; }
.tools-index-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(255px, 1fr)); gap: 14px; }
.tool-tile { display: block; padding: 16px 17px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--panel); text-decoration: none; position: relative; transition: border-color .15s, transform .15s; }
.tool-tile:hover { border-color: var(--brand); transform: translateY(-2px); }
.tool-tile .ttl { font-size: 0.93rem; font-weight: 700; color: var(--ink); margin-bottom: 4px; display: block; }
.tool-tile .desc { font-size: 0.79rem; color: var(--ink-faint); line-height: 1.5; }
.tool-tile.is-soon { opacity: 0.55; cursor: default; }
.tool-tile.is-soon:hover { transform: none; border-color: var(--border); }
.soon-tag { position: absolute; top: 14px; right: 14px; font-size: 0.62rem; font-weight: 700; text-transform: uppercase; color: var(--ink-faint); background: var(--paper); border: 1px solid var(--border); padding: 2px 7px; border-radius: 100px; }

/* ---- Live-demo hero panel (index) ---------------------------------------------------------------------------------- */
.hero-demo .code-panel pre { min-height: 132px; }
.hero-demo .preview-window { margin-top: 14px; min-height: 90px; }
.type-cursor::after { content: "▍"; color: var(--signal); animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }

/* ---- Footer ------------------------------------------------------------------------------------------------------------ */
.site-footer { border-top: 1px solid var(--border); margin-top: 80px; padding: 46px 0 30px; background: var(--panel); }
.footer-grid { display: grid; grid-template-columns: 1.4fr repeat(3, 1fr); gap: 32px; margin-bottom: 34px; }
@media (max-width: 760px) { .footer-grid { grid-template-columns: 1fr 1fr; } }
.footer-col h4 { font-size: 0.76rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink-faint); margin-bottom: 13px; }
.footer-col ul { list-style: none; display: grid; gap: 9px; }
.footer-col a { font-size: 0.85rem; color: var(--ink-soft); text-decoration: none; }
.footer-col a:hover { color: var(--brand); }
.footer-brand p { font-size: 0.85rem; color: var(--ink-faint); max-width: 320px; margin-top: 10px; }
.footer-bottom { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 12px; padding-top: 24px; border-top: 1px solid var(--border); font-size: 0.79rem; color: var(--ink-faint); }
.footer-bottom .status-dot { display: inline-flex; align-items: center; gap: 6px; }
.footer-bottom .status-dot span.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--success); }

/* ---- Marquee / motion demo helpers (used by animation-demo pages) -------------------------------------------------------- */
.marquee-track { overflow: hidden; white-space: nowrap; }
.marquee-track .item { display: inline-block; }
@keyframes marquee-scroll { 0% { transform: translateX(100%); } 100% { transform: translateX(-100%); } }
@keyframes marquee-slide { 0% { transform: translateX(100%); } 100% { transform: translateX(0%); } }
@keyframes marquee-bounce { 0%, 100% { transform: translateX(0%); } 50% { transform: translateX(calc(100% - 100%)); } }
@keyframes fade-slide-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes bounce-y { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-14px); } }

/* ---- Responsive: header / nav collapse ----------------------------------------------------------------------------------- */
@media (max-width: 880px) {
  .nav-toggle { display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 38px; border-radius: 9px; border: 1.5px solid var(--border-strong); background: var(--panel); margin-left: auto; }
  .nav-toggle svg { width: 18px; height: 18px; }
  .main-nav { position: fixed; inset: 68px 0 0 0; background: var(--paper); flex-direction: column; align-items: stretch; padding: 14px 20px; overflow-y: auto; display: none; z-index: 39; }
  .main-nav.is-open { display: flex; }
  .main-nav a { padding: 13px 6px; border-bottom: 1px solid var(--border); border-radius: 0; }
  .header-actions { margin-left: 8px; }
  .header-actions .gh-link span { display: none; }
}
@media (max-width: 620px) {
  .tool-grid, .footer-grid { grid-template-columns: 1fr; }
  main.container { padding-top: 22px; }
  .code-panel pre { font-size: 0.78rem; }
}

/* ---- Print (nice to have, near-zero cost) ---------------------------------------------------------------------------------- */
@media print {
  .site-header, .site-footer, .btn, .search-box, .cat-filter { display: none; }
}
