/* ForgeIEC — Professional Industrial Design
   Inspired by CODESYS, Siemens TIA Portal, B&R Automation
   Amber fire on dark steel. Confident. Industrial. */

/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --amber: #F59E0B;
  --amber-light: #FBBF24;
  --gold: #D97706;
  --gold-dark: #B45309;
  --steel: #1E293B;
  --iron: #0F172A;
  --slate-800: #1E293B;
  --slate-700: #334155;
  --slate-600: #475569;
  --slate-400: #94A3B8;
  --slate-300: #CBD5E1;
  --slate-100: #F1F5F9;
  --cyan: #06B6D4;
  --white: #FFFFFF;
  --text: #E2E8F0;
  --text-muted: #94A3B8;
  --radius: 8px;
  --shadow: 0 4px 6px -1px rgba(0,0,0,0.3), 0 2px 4px -2px rgba(0,0,0,0.2);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.4), 0 4px 6px -4px rgba(0,0,0,0.3);
}

html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--iron);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 2rem;
}

a { color: var(--cyan); text-decoration: none; transition: color 0.2s; }
a:hover { color: var(--amber-light); }

/* ===== HEADER ===== */
.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(12px);
  border-bottom: 2px solid var(--gold);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}

.logo {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--amber) !important;
  letter-spacing: 0.04em;
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.logo-icon {
  font-size: 1.2rem;
}

.main-nav {
  display: flex;
  gap: 2rem;
}

.nav-link {
  color: var(--slate-300) !important;
  font-weight: 500;
  font-size: 0.95rem;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  padding: 0.5rem 0;
  border-bottom: 2px solid transparent;
  transition: color 0.2s, border-color 0.2s;
}

.nav-link:hover {
  color: var(--amber) !important;
  border-bottom-color: var(--amber);
}

.lang-switch {
  display: flex;
  gap: 0.6rem;
}

.lang-link {
  color: var(--slate-400) !important;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  padding: 0.25rem 0.5rem;
  border: 1px solid var(--slate-700);
  border-radius: 4px;
  transition: all 0.2s;
}

.lang-link:hover {
  color: var(--amber) !important;
  border-color: var(--amber);
}

/* ===== HERO SECTION ===== */
.hero {
  position: relative;
  padding: 10rem 0 6rem;
  overflow: hidden;
  min-height: 80vh;
  display: flex;
  align-items: center;
}

.hero-bg {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at 30% 20%, rgba(245, 158, 11, 0.08) 0%, transparent 60%),
    radial-gradient(ellipse at 70% 80%, rgba(6, 182, 212, 0.05) 0%, transparent 50%),
    linear-gradient(180deg, var(--iron) 0%, var(--steel) 100%);
}

.hero-content {
  position: relative;
  z-index: 1;
}

.hero-title {
  display: none; /* Title comes from content h1 */
}

.hero-body {
  max-width: 900px;
  margin: 0 auto;
}

.hero-body h1 {
  font-size: clamp(2.2rem, 5vw, 3.8rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.1;
  margin-bottom: 1.5rem;
  background: linear-gradient(135deg, var(--amber-light) 0%, var(--gold) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-align: center;
}

.hero-body > p:first-of-type {
  font-size: 1.25rem;
  text-align: center;
  color: var(--slate-300);
  margin-bottom: 0.5rem;
}

.hero-body > p:nth-of-type(2) {
  font-size: 1.05rem;
  text-align: center;
  color: var(--slate-400);
  margin-bottom: 2rem;
}

.hero-body > p a {
  display: inline-block;
  padding: 0.8rem 2rem;
  font-weight: 600;
  font-size: 1rem;
  border-radius: var(--radius);
  transition: all 0.25s;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.hero-body > p:last-of-type {
  text-align: center;
}

.hero-body > p a:first-child {
  background: linear-gradient(135deg, var(--amber) 0%, var(--gold) 100%);
  color: var(--iron) !important;
  margin-right: 1rem;
}

.hero-body > p a:first-child:hover {
  background: linear-gradient(135deg, var(--amber-light) 0%, var(--amber) 100%);
  box-shadow: 0 0 20px rgba(245, 158, 11, 0.3);
  transform: translateY(-1px);
}

.hero-body > p a:last-child {
  border: 2px solid var(--slate-600);
  color: var(--slate-300) !important;
}

.hero-body > p a:last-child:hover {
  border-color: var(--amber);
  color: var(--amber) !important;
}

/* ===== CONTENT SECTIONS (from markdown) ===== */
.hero-body hr {
  border: none;
  border-top: 1px solid var(--slate-700);
  margin: 4rem 0;
}

.hero-body h2 {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--white);
  margin-bottom: 1rem;
  letter-spacing: -0.01em;
}

.hero-body h2::before {
  content: '';
  display: block;
  width: 48px;
  height: 3px;
  background: var(--amber);
  margin-bottom: 0.8rem;
  border-radius: 2px;
}

.hero-body > p {
  color: var(--slate-300);
  font-size: 1.05rem;
  line-height: 1.7;
  margin-bottom: 1rem;
}

.hero-body strong {
  color: var(--white);
  font-weight: 600;
}

/* Feature tables → card-like appearance */
.hero-body table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0 0.5rem;
  margin: 1.5rem 0;
}

.hero-body table tr {
  background: var(--steel);
  border-radius: var(--radius);
  transition: transform 0.2s, box-shadow 0.2s;
}

.hero-body table tr:hover {
  transform: translateX(4px);
  box-shadow: var(--shadow);
}

.hero-body table td {
  padding: 1rem 1.2rem;
  border: none;
}

.hero-body table td:first-child {
  border-radius: var(--radius) 0 0 var(--radius);
  width: 30%;
  white-space: nowrap;
}

.hero-body table td:last-child {
  border-radius: 0 var(--radius) var(--radius) 0;
  color: var(--slate-300);
}

.hero-body table td strong {
  color: var(--amber);
  font-weight: 600;
}

/* Lists */
.hero-body ul {
  list-style: none;
  padding: 0;
  margin: 1.5rem 0;
}

.hero-body ul li {
  position: relative;
  padding: 0.6rem 0 0.6rem 1.8rem;
  color: var(--slate-300);
  border-bottom: 1px solid rgba(51, 65, 85, 0.5);
}

.hero-body ul li:last-child {
  border-bottom: none;
}

.hero-body ul li::before {
  content: '▸';
  position: absolute;
  left: 0;
  color: var(--amber);
  font-weight: 700;
}

.hero-body ul li strong {
  color: var(--amber);
}

/* CTA links in content (not hero) */
.hero-body div[style*="text-align:center"] {
  background: var(--steel);
  border: 1px solid var(--slate-700);
  border-radius: var(--radius);
  padding: 3rem !important;
  margin-top: 3rem;
}

.hero-body div[style*="text-align:center"] p strong {
  color: var(--amber);
  font-size: 1.1rem;
}

/* ===== PAGE HERO (features, bus-system) ===== */
.page-hero {
  padding: 8rem 0 3rem;
  background: linear-gradient(180deg, var(--iron) 0%, var(--steel) 100%);
  border-bottom: 2px solid var(--gold);
}

.page-title {
  font-size: 2.4rem;
  font-weight: 800;
  color: var(--amber);
}

.page-subtitle {
  color: var(--slate-400);
  font-size: 1.1rem;
  margin-top: 0.5rem;
}

/* ===== PAGE CONTENT ===== */
.page-content {
  padding: 3rem 0 5rem;
}

.content-wrap {
  max-width: 860px;
}

.content-wrap h2 {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--white);
  margin: 3rem 0 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--gold);
}

.content-wrap h2:first-child {
  margin-top: 0;
}

.content-wrap h3 {
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--amber);
  margin: 2rem 0 0.5rem;
}

.content-wrap p {
  color: var(--slate-300);
  line-height: 1.7;
  margin-bottom: 1rem;
}

.content-wrap strong {
  color: var(--white);
}

.content-wrap ul {
  list-style: none;
  padding: 0;
  margin: 1rem 0;
}

.content-wrap ul li {
  position: relative;
  padding: 0.5rem 0 0.5rem 1.5rem;
  color: var(--slate-300);
}

.content-wrap ul li::before {
  content: '▸';
  position: absolute;
  left: 0;
  color: var(--amber);
  font-weight: 700;
}

.content-wrap ul li strong {
  color: var(--amber);
}

/* Tables in content pages */
.content-wrap table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
  background: var(--steel);
  border-radius: var(--radius);
  overflow: hidden;
}

.content-wrap th {
  background: rgba(245, 158, 11, 0.1);
  color: var(--amber);
  padding: 0.8rem 1rem;
  text-align: left;
  font-weight: 600;
  border-bottom: 2px solid var(--gold);
}

.content-wrap td {
  padding: 0.7rem 1rem;
  border-bottom: 1px solid var(--slate-700);
  color: var(--slate-300);
}

.content-wrap td strong {
  color: var(--amber);
}

.content-wrap tr:last-child td {
  border-bottom: none;
}

.content-wrap tr:hover td {
  background: rgba(245, 158, 11, 0.03);
}

/* Code blocks in content */
.content-wrap pre {
  background: var(--iron) !important;
  border-left: 3px solid var(--gold);
  border-radius: var(--radius);
  padding: 1.2rem;
  overflow-x: auto;
  font-size: 0.9rem;
  margin: 1.5rem 0;
}

.content-wrap code {
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  color: var(--amber-light);
}

.content-wrap p code {
  background: var(--steel);
  padding: 0.15rem 0.4rem;
  border-radius: 3px;
  font-size: 0.9em;
}

/* ===== FOOTER ===== */
.site-footer {
  background: var(--iron);
  border-top: 2px solid var(--gold);
  padding: 3rem 0;
}

.footer-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.footer-logo {
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--amber);
}

.footer-tagline {
  color: var(--slate-400);
  font-size: 0.85rem;
  margin-top: 0.3rem;
}

.footer-contact {
  text-align: right;
}

.footer-contact strong {
  color: var(--amber);
}

.footer-contact p {
  color: var(--slate-400);
  font-size: 0.85rem;
  margin-top: 0.3rem;
}

/* ===== RTL SUPPORT (Arabic) ===== */
html[dir="rtl"] body {
  direction: rtl;
  text-align: right;
}

html[dir="rtl"] .hero-body h1,
html[dir="rtl"] .hero-body > p:first-of-type,
html[dir="rtl"] .hero-body > p:nth-of-type(2),
html[dir="rtl"] .hero-body > p:last-of-type {
  text-align: center;
}

html[dir="rtl"] .hero-body ul li {
  padding: 0.6rem 1.8rem 0.6rem 0;
}

html[dir="rtl"] .hero-body ul li::before {
  left: auto;
  right: 0;
  content: '◂';
}

html[dir="rtl"] .content-wrap ul li {
  padding: 0.5rem 1.5rem 0.5rem 0;
}

html[dir="rtl"] .content-wrap ul li::before {
  left: auto;
  right: 0;
  content: '◂';
}

html[dir="rtl"] .content-wrap pre {
  border-left: none;
  border-right: 3px solid var(--gold);
}

html[dir="rtl"] .footer-contact {
  text-align: left;
}

html[dir="rtl"] .content-wrap th {
  text-align: right;
}

/* ===== COMPONENT BADGES ===== */
.component-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin: 0.4rem 0 1.6rem;
}

.component-badges-label {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-right: 0.25rem;
}

.component-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.25rem 0.8rem 0.25rem 0.4rem;
  border-radius: 1.4rem;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--slate-600);
  font-size: 0.85rem;
  color: var(--text);
  line-height: 1.4;
  white-space: nowrap;
}

.component-badge--studio   { border-color: var(--amber); }
.component-badge--anvild   { border-color: var(--gold); }
.component-badge--bellowsd { border-color: var(--cyan); }
.component-badge--tongs    { border-color: var(--gold-dark); }
.component-badge--hearth   { border-color: #8e44ad; }
.component-badge--screen   { border-color: var(--cyan); }
.component-badge--ledger   { border-color: var(--slate-400); }
.component-badge--anvil    { border-color: var(--amber-light); }

.component-badge img.component-badge-icon,
img.component-badge-icon,
.component-badge-icon {
  width: 1.4rem !important;
  height: 1.4rem !important;
  min-width: 1.4rem;
  max-width: 1.4rem;
  max-height: 1.4rem;
  border-radius: 50%;
  display: inline-block;
  background: var(--iron);
  flex-shrink: 0;
  object-fit: cover;
  vertical-align: middle;
}

.component-badge-emoji {
  display: inline-flex;
  width: 1.4rem;
  height: 1.4rem;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
  line-height: 1;
  flex-shrink: 0;
}

.component-badge-label {
  font-weight: 500;
  letter-spacing: 0.01em;
}

/* ===== DISTRO-INSTALL POPUP ===== */
.distro-install {
  background: rgba(15, 23, 42, 0.6);
  border-left: 4px solid var(--gold);
  border-radius: var(--radius);
  padding: 1.2rem 1.4rem;
  margin: 1.6rem 0;
}

.distro-install p {
  margin: 0 0 0.8rem 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.distro-install label {
  color: var(--amber);
  font-weight: 600;
}

.distro-install select {
  background: var(--iron);
  color: var(--text);
  border: 1px solid var(--slate-600);
  border-radius: var(--radius);
  padding: 0.4rem 0.7rem;
  font-family: inherit;
  font-size: 0.95rem;
  cursor: pointer;
  transition: border-color 0.15s;
}

.distro-install select:hover,
.distro-install select:focus {
  border-color: var(--amber);
  outline: none;
}

.distro-install select option {
  background: var(--iron);
  color: var(--text);
}

.distro-install em {
  color: var(--text-muted);
  font-style: normal;
  font-size: 0.85rem;
}

.distro-install pre {
  margin: 0;
  background: var(--iron);
  color: var(--text);
  padding: 1rem 1.2rem;
  border-radius: var(--radius);
  border-left: 3px solid var(--cyan);
  overflow-x: auto;
}

.distro-install pre code {
  background: transparent;
  color: inherit;
  font-family: ui-monospace, 'SF Mono', Consolas, monospace;
  font-size: 0.9rem;
  line-height: 1.6;
}

.distro-install pre code span[id^="forgeiec-suite"] {
  color: var(--amber);
  font-weight: 600;
}

/* ===== NEWS / POST LIST ===== */
.post-list-section {
  background: var(--steel);
  padding: 3rem 0 5rem;
  border-top: 2px solid var(--slate-700);
}

.post-list {
  display: grid;
  gap: 1.2rem;
  max-width: 900px;
  margin: 0 auto;
}

.post-card {
  display: block;
  padding: 1.4rem 1.6rem;
  background: rgba(15, 23, 42, 0.6);
  border-left: 4px solid var(--gold);
  border-radius: var(--radius);
  text-decoration: none;
  color: inherit;
  transition: all 0.2s;
}

.post-card:hover {
  background: rgba(245, 158, 11, 0.08);
  border-left-color: var(--amber);
  transform: translateX(2px);
  box-shadow: var(--shadow);
  color: inherit;
}

.post-card-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1em;
  flex-wrap: wrap;
  margin-bottom: 0.4rem;
}

.post-card-title {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--amber);
  letter-spacing: -0.01em;
}

.post-card-date {
  color: var(--slate-400);
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.post-card-summary {
  margin: 0;
  color: var(--text);
  font-size: 0.95rem;
  line-height: 1.55;
}

.post-card-pinned::before {
  content: "★ ";
  color: var(--amber-light);
  font-size: 0.9em;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  .header-inner {
    flex-wrap: wrap;
    height: auto;
    padding: 0.8rem 1rem;
    gap: 0.5rem;
  }

  .main-nav {
    gap: 1rem;
    order: 3;
    width: 100%;
    justify-content: center;
    padding-top: 0.5rem;
    border-top: 1px solid var(--slate-700);
  }

  .hero {
    padding: 7rem 0 3rem;
    min-height: auto;
  }

  .hero-body table td:first-child {
    white-space: normal;
  }

  .footer-inner {
    flex-direction: column;
    text-align: center;
    gap: 1rem;
  }

  .footer-contact {
    text-align: center;
  }
}

/* ===== INLINE COMPONENT ICON (for table cells) ===== */
.comp-icon-inline,
img.comp-icon-inline {
  display: inline-block !important;
  width: 1.2rem !important;
  height: 1.2rem !important;
  min-width: 1.2rem !important;
  max-width: 1.2rem !important;
  vertical-align: middle;
  object-fit: contain;
  margin: 0;
  padding: 0;
  border: none;
  background: transparent;
  line-height: 1;
}

.comp-icon-inline-emoji {
  font-size: 1rem;
  text-align: center;
  line-height: 1.2rem;
}

/* ===== MERMAID DIAGRAMS ===== */
pre.mermaid {
  background: transparent;
  border: none;
  padding: 1rem 0;
  margin: 1.5rem 0;
  text-align: center;
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  overflow-x: auto;
}

pre.mermaid svg {
  max-width: 100%;
  height: auto;
  margin: 0 auto;
  display: block;
}

pre.mermaid:not([data-processed="true"]) {
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 0.85rem;
  color: var(--slate-400);
  text-align: left;
  white-space: pre-wrap;
  padding: 1rem;
  border: 1px dashed var(--slate-700);
  border-radius: 0.5rem;
  opacity: 0.6;
}

/* Mermaid diagram container */
pre.mermaid {
  background: transparent;
  border: none;
  padding: 1rem 0;
  margin: 1.5rem 0;
  text-align: center;
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  overflow-x: auto;
}

pre.mermaid svg {
  max-width: 100