/* ------------------------------------------------------------------ */
/* CesarcAI Tools — design system                                      */
/* ------------------------------------------------------------------ */

:root {
  color-scheme: light;
  --bg: #f6f8fb;
  --bg-elev: #ffffff;
  --bg-soft: #eef2f8;
  --border: #d9e0ec;
  --border-strong: #b9c4d8;
  --text: #101728;
  --text-muted: #5b6780;
  --accent: #2563eb;
  --accent-soft: rgba(37, 99, 235, 0.1);
  --accent-2: #0891b2;
  --ok: #0f9d58;
  --warn: #b45309;
  --err: #d92d20;
  --code-bg: #0f172a;
  --code-text: #e2e8f0;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 8px 24px rgba(16, 24, 40, 0.06);
  --radius: 14px;
  --radius-sm: 9px;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #0b1120;
    --bg-elev: #111827;
    --bg-soft: #161f33;
    --border: #24304a;
    --border-strong: #33415f;
    --text: #e6ebf5;
    --text-muted: #97a3bb;
    --accent: #60a5fa;
    --accent-soft: rgba(96, 165, 250, 0.14);
    --accent-2: #22d3ee;
    --ok: #34d399;
    --warn: #fbbf24;
    --err: #f87171;
    --code-bg: #060b16;
    --code-text: #dbe4f3;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 12px 32px rgba(0, 0, 0, 0.35);
  }
}

html[data-theme='light'] {
  color-scheme: light;
  --bg: #f6f8fb;
  --bg-elev: #ffffff;
  --bg-soft: #eef2f8;
  --border: #d9e0ec;
  --border-strong: #b9c4d8;
  --text: #101728;
  --text-muted: #5b6780;
  --accent: #2563eb;
  --accent-soft: rgba(37, 99, 235, 0.1);
  --accent-2: #0891b2;
  --code-bg: #0f172a;
  --code-text: #e2e8f0;
}

html[data-theme='dark'] {
  color-scheme: dark;
  --bg: #0b1120;
  --bg-elev: #111827;
  --bg-soft: #161f33;
  --border: #24304a;
  --border-strong: #33415f;
  --text: #e6ebf5;
  --text-muted: #97a3bb;
  --accent: #60a5fa;
  --accent-soft: rgba(96, 165, 250, 0.14);
  --accent-2: #22d3ee;
  --ok: #34d399;
  --warn: #fbbf24;
  --err: #f87171;
  --code-bg: #060b16;
  --code-text: #dbe4f3;
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

.wrap {
  width: min(1180px, 100% - 2rem);
  margin-inline: auto;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

h1,
h2,
h3 {
  line-height: 1.25;
  letter-spacing: -0.015em;
  margin: 0 0 0.5rem;
}

h1 {
  font-size: clamp(1.75rem, 1.2rem + 2vw, 2.6rem);
}

h2 {
  font-size: clamp(1.2rem, 1rem + 0.8vw, 1.5rem);
  margin-top: 2rem;
}

h3 {
  font-size: 1.05rem;
}

p {
  margin: 0 0 1rem;
}

.muted {
  color: var(--text-muted);
}

.small {
  font-size: 0.85rem;
}

.lede {
  font-size: 1.06rem;
  color: var(--text-muted);
  max-width: 70ch;
}

/* ---------------- header ---------------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 30;
  background: color-mix(in srgb, var(--bg-elev) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  display: flex;
  align-items: center;
  gap: 1rem;
  min-height: 60px;
  flex-wrap: wrap;
  padding-block: 0.5rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
}

.brand:hover {
  text-decoration: none;
}

.brand-mark {
  color: var(--accent-2);
  font-size: 1.1rem;
}

.site-nav {
  display: flex;
  gap: 1rem;
  margin-left: auto;
  flex-wrap: wrap;
  font-size: 0.92rem;
}

.site-nav a {
  color: var(--text-muted);
}

.site-nav a:hover {
  color: var(--accent);
}

.theme-toggle {
  border: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--text);
  width: 36px;
  height: 36px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
}

.theme-toggle:hover {
  border-color: var(--border-strong);
}

/* ---------------- hero / search ---------------- */

.hero {
  padding: 2.5rem 0 1.5rem;
  text-align: center;
}

.hero .lede {
  margin-inline: auto;
}

.search-bar {
  max-width: 560px;
  margin: 1.5rem auto 1rem;
}

.search-bar input {
  width: 100%;
  padding: 0.85rem 1rem;
  font-size: 1rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--text);
  box-shadow: var(--shadow);
}

.search-bar input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
}

.chip {
  border: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--text-muted);
  border-radius: 999px;
  padding: 0.4rem 0.9rem;
  font-size: 0.88rem;
  cursor: pointer;
  font-family: inherit;
}

.chip:hover {
  border-color: var(--border-strong);
  color: var(--text);
}

.chip.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.cat-block {
  margin-block: 2.5rem;
}

.cat-head p {
  max-width: 70ch;
}

/* ---------------- layout ---------------- */

.tool-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 2rem;
  align-items: start;
}

@media (max-width: 950px) {
  .tool-layout {
    grid-template-columns: minmax(0, 1fr);
  }
}

.breadcrumbs {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

.breadcrumbs a {
  color: var(--text-muted);
}

.breadcrumbs span[aria-hidden] {
  margin-inline: 0.35rem;
}

/* ---------------- tool panel ---------------- */

.tool-panel {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
  margin-top: 1.5rem;
}

.io-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 1rem;
}

@media (max-width: 820px) {
  .io-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

.io-col {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 0.6rem;
}

.panel-head h2 {
  font-size: 0.95rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin: 0;
}

.btn-row {
  display: flex;
  gap: 0.5rem;
}

.btn {
  font-family: inherit;
  font-size: 0.86rem;
  font-weight: 600;
  padding: 0.42rem 0.8rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--text);
  cursor: pointer;
  transition: transform 0.08s ease, border-color 0.15s ease, background 0.15s ease;
}

.btn:hover {
  border-color: var(--border-strong);
}

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

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn-primary:hover {
  filter: brightness(1.07);
}

.btn-ghost {
  background: transparent;
}

.code-input,
.code-output {
  width: 100%;
  min-height: 260px;
  margin: 0;
  padding: 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-soft);
  color: var(--text);
  font-family: var(--mono);
  font-size: 0.86rem;
  line-height: 1.55;
  tab-size: 2;
}

.code-input {
  resize: vertical;
}

.code-input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.code-output {
  background: var(--code-bg);
  color: var(--code-text);
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

.field-stack {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.field label,
.control label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
}

.field input,
.control input,
.control select {
  width: 100%;
  padding: 0.55rem 0.7rem;
  font-size: 0.92rem;
  font-family: var(--mono);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-soft);
  color: var(--text);
}

.field input:focus,
.control input:focus,
.control select:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 0.85rem;
  padding-top: 0.85rem;
  border-top: 1px dashed var(--border);
}

.control {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  min-width: 150px;
  flex: 1 1 150px;
}

.control-check {
  flex-direction: row;
  align-items: center;
  gap: 0.45rem;
  min-width: 0;
  align-self: flex-end;
  padding-bottom: 0.4rem;
}

.control-check input {
  width: auto;
  accent-color: var(--accent);
}

.status {
  margin: 0.6rem 0 0;
  font-size: 0.85rem;
  color: var(--text-muted);
  min-height: 1.4em;
}

.status.is-ok {
  color: var(--ok);
}

.status.is-error {
  color: var(--err);
}

.privacy-note {
  margin: 1rem 0 0;
  padding: 0.7rem 0.9rem;
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  border: 1px solid color-mix(in srgb, var(--accent) 25%, transparent);
  font-size: 0.86rem;
  color: var(--text);
}

/* ---------------- content blocks ---------------- */

.section {
  margin-top: 2.5rem;
}

.steps {
  list-style: none;
  padding: 0;
  margin: 1rem 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.6rem;
}

.steps li {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.7rem 0.9rem;
}

.step-num {
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 0.78rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.faq {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.6rem;
}

.faq-item {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.2rem 0.9rem;
}

.faq-item summary {
  cursor: pointer;
  font-weight: 600;
  padding: 0.7rem 0;
  list-style: none;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
}

.faq-item summary::-webkit-details-marker {
  display: none;
}

.faq-item summary::after {
  content: '+';
  color: var(--text-muted);
  font-size: 1.2rem;
  line-height: 1;
}

.faq-item[open] summary::after {
  content: '–';
}

.faq-body {
  padding-bottom: 0.8rem;
  color: var(--text-muted);
}

.faq-body p {
  margin: 0;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 0.9rem;
  margin-top: 1rem;
}

.tool-card {
  display: block;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  color: var(--text);
  transition: border-color 0.15s ease, transform 0.12s ease, box-shadow 0.15s ease;
}

.tool-card:hover {
  text-decoration: none;
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.tool-card h3 {
  font-size: 1rem;
  margin-bottom: 0.35rem;
}

.tool-card p {
  color: var(--text-muted);
  font-size: 0.86rem;
  margin: 0 0 0.6rem;
}

.tool-card-cta {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--accent);
}

/* ---------------- sidebar ---------------- */

.tool-side {
  position: sticky;
  top: 76px;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

@media (max-width: 950px) {
  .tool-side {
    position: static;
  }
}

.side-box {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.9rem 1rem;
}

.side-box h3 {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  margin-bottom: 0.6rem;
}

.side-links {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.35rem;
  font-size: 0.9rem;
}

.side-links a {
  color: var(--text);
}

.side-links a:hover {
  color: var(--accent);
}

.promo-card {
  background: linear-gradient(145deg, var(--accent-soft), transparent 70%), var(--bg-elev);
  border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
  border-radius: var(--radius);
  padding: 1rem;
}

.promo-card h3 {
  margin-bottom: 0.3rem;
}

.promo-card p {
  font-size: 0.86rem;
  color: var(--text-muted);
}

.promo-kicker {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent);
  font-weight: 700;
  margin-bottom: 0.35rem;
}

/* ---------------- ads ---------------- */

.ad-slot {
  margin: 1.25rem 0;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-soft);
  padding: 0.5rem;
}

.ad-tag {
  display: inline-block;
  font-size: 0.65rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 0.15rem 0.4rem;
}

.ad-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.15rem;
  min-height: 68px;
  font-size: 0.82rem;
  color: var(--text-muted);
  text-align: center;
}

/* ---------------- footer ---------------- */

.site-footer {
  margin-top: 3rem;
  border-top: 1px solid var(--border);
  background: var(--bg-elev);
  padding-top: 2rem;
}

.footer-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) repeat(3, minmax(0, 1fr));
  gap: 1.5rem;
  padding-bottom: 1.5rem;
}

@media (max-width: 820px) {
  .footer-grid {
    grid-template-columns: 1fr 1fr;
  }
}

.footer-grid h2 {
  font-size: 1.05rem;
  margin-top: 0;
}

.footer-grid h3 {
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
}

.footer-grid ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.3rem;
  font-size: 0.9rem;
}

.footer-grid a {
  color: var(--text-muted);
}

.footer-grid a:hover {
  color: var(--accent);
}

.footer-bottom {
  border-top: 1px solid var(--border);
  padding-block: 1rem;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.footer-bottom p {
  margin: 0;
}

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

@media (max-width: 520px) {
  .site-nav {
    order: 3;
    width: 100%;
    margin-left: 0;
    gap: 0.75rem;
    font-size: 0.85rem;
  }
}

/* ------------------------------------------------------------------ */
/* V2 components                                                       */
/* ------------------------------------------------------------------ */

/* A grid child without min-width:0 refuses to shrink below its content
   width, which is what pushed the tool page 184px past a 390px viewport. */
.tool-main,
.io-input,
.io-output {
  min-width: 0;
}

/* ---------------- notes panel ---------------- */

.notes-panel {
  margin-top: 0.75rem;
  padding: 0.8rem 0.9rem;
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  background: var(--bg-soft);
  font-size: 0.86rem;
  color: var(--text-muted);
}

.notes-panel[hidden] {
  display: none;
}

.notes-title {
  margin: 0 0 0.4rem;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
}

.notes-list {
  margin: 0;
  padding-left: 1.1rem;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.3rem;
}

.notes-list li {
  overflow-wrap: anywhere;
}

/* ---------------- cheat sheet ---------------- */

.table-scroll {
  margin-top: 1rem;
  max-width: 100%;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.cheat-table {
  width: 100%;
  min-width: 440px;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.cheat-table th,
.cheat-table td {
  padding: 0.6rem 0.8rem;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--border);
}

.cheat-table thead th {
  background: var(--bg-soft);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  white-space: nowrap;
}

.cheat-table tbody tr:last-child td {
  border-bottom: 0;
}

.cheat-table code {
  font-family: var(--mono);
  font-size: 0.84rem;
  color: var(--accent);
  white-space: pre;
}

/* ---------------- pitfalls ---------------- */

.pitfall-list {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.7rem;
  margin-top: 1rem;
}

.pitfall {
  min-width: 0;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-left: 3px solid var(--warn);
  border-radius: var(--radius-sm);
  padding: 0.8rem 0.95rem;
}

.pitfall h3 {
  margin: 0 0 0.25rem;
  font-size: 0.98rem;
}

.pitfall p {
  margin: 0;
  font-size: 0.9rem;
  color: var(--text-muted);
}

/* ---------------- worked examples ---------------- */

.example-list {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1rem;
  margin-top: 1rem;
}

.example {
  min-width: 0;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.9rem 1rem;
}

.example h3 {
  margin: 0 0 0.5rem;
  font-size: 0.95rem;
}

.example p {
  margin: 0.5rem 0 0;
  font-size: 0.88rem;
}

.code-block {
  margin: 0;
  padding: 0.8rem 0.9rem;
  max-width: 100%;
  overflow-x: auto;
  border-radius: var(--radius-sm);
  background: var(--code-bg);
  color: var(--code-text);
  font-family: var(--mono);
  font-size: 0.82rem;
  line-height: 1.55;
  white-space: pre;
}

/* ---------------- footer ---------------- */

.footer-group {
  min-width: 0;
}

.footer-grid > * {
  min-width: 0;
}

.footer-tool-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.3rem;
  font-size: 0.88rem;
}

.footer-grid h3 a {
  color: var(--text-muted);
}

.footer-grid li a {
  overflow-wrap: anywhere;
}

@media (max-width: 520px) {
  .footer-grid {
    grid-template-columns: 1fr;
  }
}

/* ---------------- referral + prose ---------------- */

.promo-referral {
  border-color: color-mix(in srgb, var(--accent) 40%, transparent);
}

.promo-referral .btn {
  margin-top: 0.35rem;
}

.prose {
  max-width: 72ch;
}

.prose p {
  color: var(--text-muted);
  overflow-wrap: break-word;
}

.prose h2 {
  margin-top: 1.6rem;
}
