/* SA Element Registry — styles */
:root {
  --navy: #0B212D;
  --navy-deep: #000000;
  /* Foundry — official brand orange (ratified June 1, 2026), replaced legacy #F89C22 */
  --orange: #D97706;
  --orange-hover: #B45309;
  /* Visible Depth gradient — the only approved dark/button surface */
  --depth: linear-gradient(0deg, #000000 0%, #0B212D 100%);
  --text: #0B212D;
  --text-muted: #5a6b75;
  --bg: #f7f8fa;
  --card-bg: #ffffff;
  --border: #e3e7eb;
  --code-bg: #1e293b;
  --radius: 12px;
  --shadow-sm: 0 1px 2px rgba(11, 33, 45, 0.06);
  --shadow-md: 0 4px 14px rgba(11, 33, 45, 0.08);
  --shadow-lg: 0 12px 32px rgba(11, 33, 45, 0.14);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Poppins', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  color: var(--text);
  background: var(--bg);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

.wrap { max-width: 1280px; margin: 0 auto; padding: 0 24px; }

/* Header — Visible Depth gradient */
.site-header {
  background: linear-gradient(135deg, #000000 0%, #0B212D 100%);
  color: #fff;
  padding: 18px 0;
  border-bottom: 3px solid var(--orange);
  position: sticky; top: 0; z-index: 50;
  box-shadow: var(--shadow-md);
}
.header-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.brand { display: flex; align-items: center; gap: 12px; color: #fff; text-decoration: none; font-weight: 600; }
.brand-mark {
  width: 28px; height: 28px; border-radius: 6px;
  background: var(--depth);
  border: 2px solid var(--orange);
  box-shadow: 0 2px 8px rgba(11, 33, 45, 0.35);
}
.brand-name { font-size: 16px; letter-spacing: 0.2px; }
.nav { display: flex; align-items: center; gap: 18px; }
.nav a { color: #cfd8de; text-decoration: none; font-size: 14px; font-weight: 500; transition: color .15s; }
.nav a:hover { color: #fff; }
.btn-add {
  background: var(--depth); color: var(--orange) !important;
  border: 1.5px solid var(--orange);
  padding: 8px 14px; border-radius: 8px; font-weight: 600;
}
.btn-add:hover { color: #fff !important; border-color: #fff; }

main { padding: 32px 0 80px; }

.hero-block { margin-bottom: 28px; }
.hero-block h1 { font-size: 32px; margin: 0 0 8px; color: var(--navy); font-weight: 700; }
.lede { color: var(--text-muted); font-size: 16px; margin: 0 0 18px; }
.count { color: var(--orange); font-weight: 600; }

/* Toolbar */
.toolbar { margin-bottom: 14px; }
#searchBox {
  width: 100%;
  padding: 12px 16px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  font-size: 15px;
  font-family: inherit;
  background: #fff;
  transition: border-color .15s, box-shadow .15s;
}
#searchBox:focus { outline: none; border-color: var(--orange); box-shadow: 0 0 0 3px rgba(248,156,34,0.18); }

/* Filter chips */
.filter-bar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
.chip {
  border: 1.5px solid var(--border);
  background: #fff;
  color: var(--text);
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-family: inherit;
  font-weight: 500;
  cursor: pointer;
  transition: all .15s;
}
.chip:hover { border-color: var(--orange); }
.chip-active { background: var(--navy); color: #fff; border-color: var(--navy); }

/* Category section */
.cat-block { margin: 36px 0 8px; }
.cat-title { font-size: 20px; margin: 0 0 16px; color: var(--navy); font-weight: 600; display: flex; align-items: center; gap: 10px; }
.cat-count { background: var(--navy); color: var(--orange); font-size: 12px; padding: 2px 9px; border-radius: 999px; font-weight: 700; }

/* Grid */
.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
@media (max-width: 980px) { .grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 640px) { .grid { grid-template-columns: 1fr; } }

/* Card */
.card { background: var(--card-bg); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-sm); border: 1px solid var(--border); transition: transform .18s, box-shadow .18s; }
.card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); border-color: #d1d8de; }
.card-link { display: block; color: inherit; text-decoration: none; }
.card-preview {
  height: 140px;
  display: flex; align-items: center; justify-content: center;
  color: rgba(255,255,255,0.92);
  font-weight: 600;
  font-size: 15px;
  text-align: center;
  padding: 16px;
  letter-spacing: 0.2px;
  text-shadow: 0 2px 8px rgba(0,0,0,0.35);
}
.preview-name { word-break: break-word; }
.card-body { padding: 16px 18px 18px; }
.card-meta { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.card-title { font-size: 15px; margin: 0 0 6px; color: var(--navy); font-weight: 600; word-break: break-all; }
.ver { color: var(--text-muted); font-weight: 400; font-size: 12px; }
.card-desc { color: var(--text-muted); font-size: 13px; margin: 0 0 8px; line-height: 1.5; }
.when { font-size: 12px; color: var(--text-muted); margin: 0 0 8px; }
.when strong { color: var(--navy); }
.src { font-size: 12px; color: var(--text-muted); margin: 0 0 10px; }
.src code { background: #f0f3f5; padding: 2px 6px; border-radius: 4px; font-size: 11px; color: var(--navy); }
.view-btn { color: var(--orange); font-size: 13px; font-weight: 600; }

/* Badges */
.badge { display: inline-block; font-size: 11px; font-weight: 600; padding: 3px 9px; border-radius: 999px; letter-spacing: 0.2px; }
.badge-cat { background: #eaf1f5; color: var(--navy); }
.badge-status-live { background: #d8f4e1; color: #176b3a; }
.badge-status-beta { background: #fff3cd; color: #7a5800; }
.badge-status-deprecated { background: #f8d7d7; color: #7a1f1f; }

/* Detail page */
.back-link { color: var(--orange); text-decoration: none; font-size: 13px; font-weight: 500; display: inline-block; margin-bottom: 16px; }
.back-link:hover { text-decoration: underline; }
.detail-head { background: #fff; padding: 28px; border-radius: var(--radius); border: 1px solid var(--border); margin-bottom: 24px; }
.detail-head h1 { margin: 12px 0 8px; color: var(--navy); }
.detail-meta { display: flex; gap: 8px; flex-wrap: wrap; }
.block { background: #fff; padding: 22px 28px; border-radius: var(--radius); border: 1px solid var(--border); margin-bottom: 18px; }
.block h2 { margin: 0 0 12px; font-size: 16px; color: var(--navy); }
.rules-list { margin: 0; padding-left: 20px; }
.rules-list li { margin: 6px 0; }

/* Code panels */
.code-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-bottom: 18px; }
@media (max-width: 900px) { .code-grid { grid-template-columns: 1fr; } }
.code-panel { background: var(--code-bg); border-radius: var(--radius); overflow: hidden; border: 1px solid #334155; }
.code-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; background: #0f172a; border-bottom: 1px solid #334155; }
.code-head h3 { margin: 0; color: #f8fafc; font-size: 13px; font-weight: 600; letter-spacing: 0.4px; }
.copy-btn { background: transparent; border: 1.5px solid var(--orange); color: var(--orange); font-weight: 600; font-size: 12px; padding: 4px 12px; border-radius: 6px; cursor: pointer; font-family: inherit; }
.copy-btn:hover { background: rgba(217,119,6,0.12); }
.code-panel pre { margin: 0; padding: 16px; max-height: 540px; overflow: auto; font-size: 12.5px; }
.empty-code { padding: 24px; color: #94a3b8; font-size: 13px; font-style: italic; text-align: center; }

/* Admin table */
.admin-table { width: 100%; border-collapse: collapse; background: #fff; border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-sm); }
.admin-table th, .admin-table td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--border); font-size: 13px; }
.admin-table th { background: var(--navy); color: #fff; font-weight: 600; text-transform: uppercase; font-size: 11px; letter-spacing: 0.6px; }
.admin-table tbody tr:hover { background: #f7f9fb; }
.admin-table a { color: var(--navy); font-weight: 600; text-decoration: none; }
.admin-table a:hover { color: var(--orange); }
.actions { white-space: nowrap; }

/* Buttons */
.btn { display: inline-block; padding: 8px 16px; border-radius: 8px; background: #fff; color: var(--navy); border: 1.5px solid var(--border); font-size: 13px; font-weight: 500; text-decoration: none; cursor: pointer; font-family: inherit; transition: all .15s; }
.btn:hover { border-color: var(--orange); color: var(--orange); }
.btn-primary { background: var(--depth); border-color: var(--navy); color: var(--orange); font-weight: 600; }
.btn-primary:hover { color: #fff; border-color: var(--navy); }
.btn-sm { padding: 5px 11px; font-size: 12px; }
.btn-danger { color: #b00020; border-color: #f1cccc; }
.btn-danger:hover { background: #fdecec; color: #b00020; border-color: #b00020; }

/* Form */
.el-form { background: #fff; padding: 24px; border-radius: var(--radius); border: 1px solid var(--border); display: flex; flex-direction: column; gap: 16px; }
.el-form label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 500; color: var(--navy); }
.el-form input, .el-form select, .el-form textarea {
  font-family: inherit; font-size: 14px; padding: 10px 12px;
  border: 1.5px solid var(--border); border-radius: 8px; background: #fff; color: var(--text);
}
.el-form input:focus, .el-form select:focus, .el-form textarea:focus { outline: none; border-color: var(--orange); box-shadow: 0 0 0 3px rgba(248,156,34,0.18); }
.el-form .mono { font-family: 'SF Mono', Menlo, Consolas, monospace; font-size: 12.5px; }
.el-form .row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 640px) { .el-form .row { grid-template-columns: 1fr; } }
.form-actions { display: flex; gap: 10px; margin-top: 8px; }

/* ---- Live preview: card thumbnails ---- */
.card-preview-live {
  position: relative;
  /* Aspect-ratio box: the scaled iframe fills it exactly, no clipping of width. */
  width: 100%;
  aspect-ratio: 16 / 10;
  padding: 0;
  overflow: hidden;
  background: #fff;
  border-bottom: 1px solid var(--border);
}
.thumb-scaler {
  /* Rendered at a fixed logical desktop width so element CSS (which assumes a
     ~1180px container) lays out correctly, then uniformly scaled DOWN by JS so
     the full element width fits the card. Centered, top-aligned. */
  position: absolute;
  top: 0; left: 0;
  width: var(--thumb-w, 1180px);
  transform-origin: top left;
  transform: scale(var(--thumb-scale, 0.29));
  pointer-events: none;
}
.thumb-frame {
  display: block;
  width: 100%;
  /* tall enough to capture the hero/top section; the box clips the overflow */
  height: 760px;
  border: 0;
  background: #fff;
}
.thumb-label {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  background: linear-gradient(180deg, rgba(11,33,45,0) 0%, rgba(11,33,45,0.85) 100%);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.2px;
  padding: 22px 12px 8px;
  text-align: center;
  word-break: break-all;
  pointer-events: none;
  z-index: 2;
}
/* Hover affordance: the whole card is a link to the full preview */
.card-preview-live::after {
  content: "Open full preview \2197";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(11,33,45,0.55);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.3px;
  opacity: 0;
  transition: opacity .18s ease;
  z-index: 3;
}
.card:hover .card-preview-live::after { opacity: 1; }

/* ---- Live preview: detail page ---- */
.preview-section {
  background: #fff;
  padding: 18px 20px 20px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  margin-bottom: 24px;
}
.preview-bar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap; margin-bottom: 14px;
}
.preview-bar h2 { margin: 0; font-size: 16px; color: var(--navy); }
.preview-toggle { display: flex; gap: 6px; }
.pv-btn {
  border: 1.5px solid var(--border); background: #fff; color: var(--text);
  padding: 6px 14px; border-radius: 8px; font-size: 13px; font-weight: 500;
  font-family: inherit; cursor: pointer; text-decoration: none; transition: all .15s;
}
.pv-btn:hover { border-color: var(--orange); color: var(--orange); }
.pv-btn-active { background: var(--navy); color: #fff; border-color: var(--navy); }
.pv-btn-active:hover { color: #fff; }
.pv-open { color: var(--orange); }
.preview-stage {
  background: #eef1f4;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  display: flex;
  justify-content: center;
}
.preview-frame-wrap {
  width: 100%;
  max-width: 100%;
  transition: max-width .25s ease;
  background: #fff;
  border-radius: 8px;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.preview-stage[data-mode="mobile"] .preview-frame-wrap {
  max-width: 390px;
  box-shadow: var(--shadow-lg);
}
.preview-frame {
  width: 100%;
  height: 520px;
  border: 0;
  display: block;
  background: #fff;
}

/* ---- Importer box ---- */
.import-box {
  background: #fff;
  border: 1.5px dashed var(--orange);
  border-radius: var(--radius);
  padding: 22px 24px;
  margin-bottom: 22px;
}
.import-box h2 { margin: 0 0 6px; font-size: 17px; color: var(--navy); }
.import-help { color: var(--text-muted); font-size: 13px; margin: 0 0 14px; }
.import-help code, .import-box code { background: #f0f3f5; padding: 1px 5px; border-radius: 4px; font-size: 12px; color: var(--navy); }
.import-drop {
  border: 1.5px dashed var(--border);
  border-radius: 10px;
  padding: 22px;
  text-align: center;
  color: var(--text-muted);
  background: #fafbfc;
  transition: border-color .15s, background .15s;
}
.import-drop.drag { border-color: var(--orange); background: #fff7ec; }
.import-drop p { margin: 4px 0; font-size: 13px; }
.import-filename { color: var(--navy); font-weight: 600; font-size: 12px; }
.import-paste { margin-top: 14px; }
.import-paste summary { cursor: pointer; font-size: 13px; font-weight: 600; color: var(--navy); }
.import-paste label { display: flex; flex-direction: column; gap: 6px; font-size: 12px; font-weight: 500; color: var(--navy); margin-top: 12px; }
.import-paste textarea {
  font-family: 'SF Mono', Menlo, Consolas, monospace; font-size: 12px;
  padding: 10px 12px; border: 1.5px solid var(--border); border-radius: 8px; background: #fff; color: var(--text);
}
.import-paste textarea:focus { outline: none; border-color: var(--orange); box-shadow: 0 0 0 3px rgba(248,156,34,0.18); }
.import-actions { display: flex; align-items: center; gap: 14px; margin-top: 16px; flex-wrap: wrap; }
.import-status { font-size: 13px; color: var(--text-muted); }
.import-status-ok { color: #176b3a; font-weight: 600; }
.import-status-err { color: #b00020; font-weight: 600; }

/* Footer */
.site-footer { padding: 32px 0; color: var(--text-muted); font-size: 12px; text-align: center; border-top: 1px solid var(--border); margin-top: 40px; }

/* ============================================================
   ALL-CAPS + CENTERED titles, headers & CTA button text
   (per sa-copywriting §2 — headings centered + uppercase;
    body copy stays left-aligned)
   ============================================================ */

/* Brand / nav */
.brand-name { text-transform: uppercase; letter-spacing: 0.6px; }
.nav a, .btn-add { text-transform: uppercase; letter-spacing: 0.4px; }

/* Page + section titles */
.hero-block h1,
.cat-title,
.detail-head h1,
.block h2,
.preview-bar h2,
.code-head h3 { text-transform: uppercase; text-align: center; }

/* .cat-title uses flex for the count chip — keep it centered */
.cat-title { justify-content: center; }

/* Card names */
.card-title { text-transform: uppercase; text-align: center; letter-spacing: 0.3px; }
.preview-name, .thumb-label { text-transform: uppercase; letter-spacing: 0.4px; }

/* The version tag should stay lowercase 'v' to read as a version, not shout */
.card-title .ver, .detail-head h1 .ver { text-transform: none; }

/* CTA / button text */
.view-btn,
.btn,
.btn-primary,
.btn-add,
.copy-btn,
.pv-btn,
.chip { text-transform: uppercase; letter-spacing: 0.4px; }

/* Center the card's View Details CTA */
.view-btn { display: block; text-align: center; }
