/* ===========================================================
   C Program Compiler Online — Design System
   "Terminal-meets-paper": a warm paper page holding a dark
   ink terminal panel as the centerpiece.
   =========================================================== */

:root{
  /* Color */
  --paper: #F3F4EF;
  --paper-dim: #E9EBE3;
  --ink: #1B1F23;
  --ink-soft: #3C4249;
  --editor-bg: #14181D;
  --editor-line: #1F252C;
  --editor-border: #2B323A;
  --editor-text: #E7E9E4;
  --editor-muted: #8C949E;
  --amber: #E3A72E;
  --amber-dark: #B5810E;
  --green: #4FAE7A;
  --red: #E2564F;
  --line: #D8DAD1;

  /* Type */
  --font-head: 'Space Grotesk', 'Segoe UI', sans-serif;
  --font-body: 'IBM Plex Sans', 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'Courier New', monospace;

  /* Layout */
  --maxw: 1120px;
  --maxw-text: 760px;
  --radius: 6px;
}

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

html{ scroll-behavior: smooth; }

body{
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

img{ max-width: 100%; display:block; }

a{ color: var(--amber-dark); text-decoration: none; }
a:hover{ text-decoration: underline; }

h1,h2,h3,h4{
  font-family: var(--font-head);
  color: var(--ink);
  margin: 0 0 0.5em;
  line-height: 1.2;
  font-weight: 600;
}

h1{ font-size: clamp(1.7rem, 3.2vw, 2.5rem); }
h2{ font-size: clamp(1.35rem, 2.4vw, 1.9rem); }
h3{ font-size: 1.15rem; }

p{ margin: 0 0 1em; color: var(--ink-soft); }

code, pre{ font-family: var(--font-mono); }

:focus-visible{
  outline: 2px solid var(--amber-dark);
  outline-offset: 2px;
}

.container{
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 20px;
}

.container-text{
  max-width: var(--maxw-text);
  margin: 0 auto;
  padding: 0 20px;
}

/* ---------------- Header ---------------- */
.site-header{
  border-bottom: 1px solid var(--line);
  background: var(--paper);
  position: sticky;
  top: 0;
  z-index: 50;
}

.site-header .wrap{
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand{
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--ink);
}

.brand .dot{ color: var(--amber-dark); }

.main-nav{ display: flex; gap: 22px; }

.main-nav a{
  color: var(--ink-soft);
  font-size: 0.95rem;
}

.main-nav a:hover{ color: var(--ink); text-decoration: none; border-bottom: 2px solid var(--amber); }

.nav-toggle{
  display: none;
  background: none;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 6px 10px;
  font-family: var(--font-mono);
  cursor: pointer;
}

/* ---------------- Hero / Intro ---------------- */
.intro{
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 34px 20px 10px;
}

.intro h1{ margin-bottom: 8px; }
.intro .lede{
  max-width: 62ch;
  color: var(--ink-soft);
  font-size: 1.05rem;
}

/* ---------------- Compiler Tool ---------------- */
.tool-section{
  max-width: var(--maxw);
  margin: 18px auto 10px;
  padding: 0 20px;
}

.editor-window{
  background: var(--editor-bg);
  border: 1px solid var(--editor-border);
  border-radius: var(--radius);
  overflow: hidden;
}

.editor-titlebar{
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--editor-border);
  background: var(--editor-line);
}

.win-dots{ display:flex; gap:6px; }
.win-dots span{
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--editor-muted); opacity: .5;
}

.file-label{
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--editor-muted);
}

.editor-body{
  display: grid;
  grid-template-columns: 1fr;
}

@media (min-width: 900px){
  .editor-body{ grid-template-columns: 1.4fr 1fr; }
}

.pane-code{
  border-bottom: 1px solid var(--editor-border);
}

@media (min-width: 900px){
  .pane-code{ border-bottom: none; border-right: 1px solid var(--editor-border); }
}

.CodeMirror{
  height: 480px;
  font-family: var(--font-mono);
  font-size: 14.5px;
  background: var(--editor-bg) !important;
  color: var(--editor-text);
}

.pane-io{
  display: flex;
  flex-direction: column;
  min-height: 480px;
}

.stdin-toggle{
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  border-bottom: 1px solid var(--editor-border);
  background: transparent;
  border-top: none;
  border-left: none;
  border-right: none;
  width: 100%;
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  letter-spacing: 0.02em;
  color: var(--editor-muted);
  text-align: left;
}

.stdin-toggle:hover{ color: var(--editor-text); }

.stdin-toggle .chev{
  transition: transform 0.15s ease;
  display: inline-block;
}

.stdin-toggle[aria-expanded="true"] .chev{
  transform: rotate(90deg);
}

.stdin-panel{
  display: none;
  border-bottom: 1px solid var(--editor-border);
  flex: none;
}

.stdin-panel.open{ display: flex; flex-direction: column; }

textarea#stdin-box{
  resize: none;
  border: none;
  background: transparent;
  color: var(--editor-text);
  font-family: var(--font-mono);
  font-size: 13.5px;
  padding: 10px 14px;
  min-height: 80px;
  width: 100%;
}

textarea#stdin-box:focus{ outline: none; }

#output-box{
  flex: 1;
  min-height: 140px;
  padding: 12px 14px;
  font-family: var(--font-mono);
  font-size: 13.5px;
  color: var(--editor-text);
  white-space: pre-wrap;
  word-break: break-word;
  overflow-y: auto;
}

#output-box.state-empty{ color: var(--editor-muted); }
#output-box.state-error{ color: #F2938E; }
#output-box.state-success{ color: var(--editor-text); }

.editor-toolbar{
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-top: 1px solid var(--editor-border);
  background: var(--editor-line);
}

.btn{
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.92rem;
  border-radius: var(--radius);
  padding: 9px 18px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform 0.08s ease, background 0.15s ease;
}

.btn:active{ transform: translateY(1px); }

.btn-run{
  background: var(--amber);
  color: #1B1300;
}
.btn-run:hover{ background: #EFB444; }
.btn-run:disabled{ opacity: 0.6; cursor: progress; }

.btn-ghost{
  background: transparent;
  border-color: var(--editor-border);
  color: var(--editor-text);
}
.btn-ghost:hover{ background: rgba(255,255,255,0.06); }

.toolbar-status{
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--editor-muted);
}

.toolbar-status.busy::before{
  content: "● ";
  color: var(--amber);
}
.toolbar-status.ok::before{
  content: "● ";
  color: var(--green);
}
.toolbar-status.err::before{
  content: "● ";
  color: var(--red);
}

/* ---------------- Feature strip ---------------- */
.features{
  max-width: var(--maxw);
  margin: 46px auto;
  padding: 0 20px;
}

.feature-grid{
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
}

.feature-item{
  background: var(--paper);
  padding: 20px 18px;
}

.feature-item h3{
  font-size: 1rem;
  margin-bottom: 6px;
}

.feature-item p{ margin: 0; font-size: 0.92rem; }

/* ---------------- How to use / steps ---------------- */
.howto{
  max-width: var(--maxw-text);
  margin: 54px auto;
  padding: 0 20px;
}

.step-list{
  list-style: none;
  margin: 22px 0 0;
  padding: 0;
  counter-reset: step;
}

.step-list li{
  counter-increment: step;
  display: flex;
  gap: 16px;
  padding: 16px 0;
  border-top: 1px solid var(--line);
}

.step-list li:last-child{ border-bottom: 1px solid var(--line); }

.step-list li::before{
  content: counter(step);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--amber-dark);
  border: 1px solid var(--line);
  border-radius: 50%;
  width: 26px; height: 26px;
  flex: none;
  display: flex; align-items: center; justify-content: center;
  margin-top: 2px;
}

.step-list h3{ margin: 0 0 4px; font-size: 1rem; }
.step-list p{ margin: 0; font-size: 0.95rem; }

/* ---------------- FAQ ---------------- */
.faq{
  max-width: var(--maxw-text);
  margin: 54px auto;
  padding: 0 20px;
}

.faq-item{
  border-top: 1px solid var(--line);
  padding: 16px 0;
}

.faq-item:last-child{ border-bottom: 1px solid var(--line); }

.faq-item h3{ font-size: 1rem; margin-bottom: 6px; }
.faq-item p{ margin: 0; font-size: 0.95rem; }

/* ---------------- Ad slots ---------------- */
.ad-slot{
  max-width: var(--maxw);
  margin: 34px auto;
  padding: 0 20px;
  text-align: center;
}

.ad-slot .ad-inner{
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  padding: 10px;
  min-height: 90px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-soft);
  font-size: 0.78rem;
  font-family: var(--font-mono);
}

/* ---------------- Footer ---------------- */
.site-footer{
  border-top: 1px solid var(--line);
  margin-top: 60px;
  padding: 32px 0 40px;
  background: var(--paper-dim);
}

.footer-wrap{
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 24px;
}

.footer-col h4{
  font-size: 0.85rem;
  color: var(--ink-soft);
  margin-bottom: 10px;
}

.footer-col a{
  display: block;
  color: var(--ink-soft);
  font-size: 0.9rem;
  margin-bottom: 6px;
}

.footer-col a:hover{ color: var(--ink); }

.footer-bottom{
  max-width: var(--maxw);
  margin: 24px auto 0;
  padding: 16px 20px 0;
  border-top: 1px solid var(--line);
  font-size: 0.82rem;
  color: var(--ink-soft);
}

/* ---------------- Static content pages ---------------- */
.page-content{
  max-width: var(--maxw-text);
  margin: 40px auto 60px;
  padding: 0 20px;
}

.page-content h2{ margin-top: 1.6em; }
.page-content ul{ color: var(--ink-soft); }
.page-content li{ margin-bottom: 6px; }

.breadcrumb{
  font-size: 0.85rem;
  color: var(--ink-soft);
  margin-bottom: 6px;
}

/* ---------------- Contact form ---------------- */
.contact-form{
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-width: 480px;
  margin-top: 20px;
}

.contact-form label{
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink);
}

.contact-form input,
.contact-form textarea{
  font-family: var(--font-body);
  font-size: 0.95rem;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
}

.contact-form textarea{ min-height: 120px; resize: vertical; }

.contact-form button{ align-self: flex-start; }

/* ---------------- Responsive ---------------- */
@media (max-width: 720px){
  .main-nav{
    position: absolute;
    top: 100%; left: 0; right: 0;
    background: var(--paper);
    border-bottom: 1px solid var(--line);
    flex-direction: column;
    padding: 12px 20px 18px;
    display: none;
    gap: 12px;
  }
  .main-nav.open{ display: flex; }
  .nav-toggle{ display: inline-block; }
}
