/* ─── LearnWithOtti shared diagram stylesheet ─────────────────────────────── */

:root {
  --demand:     #e04060;
  --supply:     #2563eb;
  --brand:      #6C63FF;
  --brand-1:    #2952f5;
  --brand-2:    #6a3bff;
  --cs:         rgba(99, 179, 237, 0.28);
  --ps:         rgba(72, 187, 120, 0.28);
  --dwl:        rgba(239, 68, 68, 0.28);
  --ink:        #1E1B3A;
  --ink-soft:   #6b7280;
  --ink-faint:  #d1d5db;
  --bg:         #ffffff;
  --grid-line:  rgba(99, 102, 241, 0.08);
}

/* ─── Reset / base ────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
}

body {
  font-family: 'Space Grotesk', 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.4;
}

body.standalone {
  height: 100%;
  background: #f8f9fc;
  display: flex;
  align-items: stretch;
}

/* ─── Layout ──────────────────────────────────────────────────────────────── */
.diagram-page {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  padding: 8px;
}

.diagram-card {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 16px;
  padding: 12px 16px;
  overflow: hidden;
  box-sizing: border-box;
}

.diagram-card.wide,
.diagram-card.wider {
  /* no min-width — let the card fill the iframe */
}

/* ─── Grid background ─────────────────────────────────────────────────────── */
.bg-grid {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background-image:
    linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: 40px 40px;
  pointer-events: none;
}

/* ─── Horizontal rule accent ──────────────────────────────────────────────── */
.hr {
  height: 3px;
  background: linear-gradient(90deg, var(--brand-1), var(--brand-2));
  border-radius: 2px;
  margin-bottom: 10px;
  grid-column: 1;
}

/* ─── Header ──────────────────────────────────────────────────────────────── */
.title {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 8px;
  position: relative;
  z-index: 1;
}

.title h1 {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -0.01em;
  line-height: 1.25;
}

.sub {
  font-size: 0.72rem;
  color: var(--ink-soft);
  font-weight: 500;
  letter-spacing: 0.01em;
}

/* ─── Brand / logo ────────────────────────────────────────────────────────── */
.brand {
  position: absolute;
  top: 18px;
  right: 20px;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--ink);
  z-index: 2;
}

.brand img {
  width: 18px;
  height: 18px;
  border-radius: 4px;
  object-fit: contain;
}

.brand .b1 { color: var(--ink); }
.brand .b2 { color: var(--brand); }

/* ─── Plot host ───────────────────────────────────────────────────────────── */
.plot-host {
  flex: 1;
  position: relative;
  z-index: 1;
  min-height: 0;
}

.plot-host svg {
  width: 100%;
  height: 100%;
}

/* ─── Footer URL watermark ────────────────────────────────────────────────── */
.footer-url {
  position: absolute;
  bottom: 52px;
  right: 22px;
  font-size: 0.62rem;
  color: var(--ink-faint);
  letter-spacing: 0.03em;
  z-index: 2;
  pointer-events: none;
}

/* ─── Legend ──────────────────────────────────────────────────────────────── */
.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
  margin-top: 8px;
  padding-top: 6px;
  border-top: 1px solid #f3f4f6;
  z-index: 1;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.68rem;
  color: var(--ink-soft);
  font-weight: 500;
}

.sw {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 2px;
  flex-shrink: 0;
}

/* ─── Caption ─────────────────────────────────────────────────────────────── */
.caption {
  font-size: 0.67rem;
  color: var(--ink-faint);
  margin-top: 4px;
  line-height: 1.5;
  z-index: 1;
}

/* ─── SVG element styles ──────────────────────────────────────────────────── */

/* Axes */
.axis {
  stroke: var(--ink);
  stroke-width: 1.8;
  stroke-linecap: square;
}

.axis-arrow {
  fill: var(--ink);
}

.axis-label {
  font-size: 11px;
  fill: var(--ink-soft);
  font-family: inherit;
  font-weight: 500;
}

/* Ticks */
.tick {
  stroke: var(--ink);
  stroke-width: 1.5;
}

.tick-label {
  font-size: 10.5px;
  fill: var(--ink);
  font-family: inherit;
  font-weight: 600;
}

/* Guide lines */
.guide {
  stroke: var(--ink-soft);
  stroke-width: 1px;
  stroke-dasharray: 4 3;
  opacity: 0.7;
}

/* Curves — base */
.curve {
  stroke: var(--brand-1);
  stroke-width: 2.2;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.curve.demand, line.demand, path.demand {
  stroke: var(--demand);
}

.curve.demand2 {
  stroke: var(--demand);
  stroke-dasharray: 5 4;
  opacity: 0.7;
}

.curve.supply {
  stroke: var(--supply);
}

.curve.supply2 {
  stroke: var(--supply);
  stroke-dasharray: 5 4;
  opacity: 0.7;
}

.curve.brand {
  stroke: var(--brand);
}

/* Curve labels */
.curve-label {
  font-size: 12px;
  font-weight: 700;
  fill: var(--brand-1);
  font-family: inherit;
}

.curve-label.demand {
  fill: var(--demand);
}

.curve-label.supply {
  fill: var(--supply);
}

.curve-label.brand {
  fill: var(--brand);
}

/* Annotations */
.annot {
  font-size: 10.5px;
  fill: var(--ink-soft);
  font-family: inherit;
  font-weight: 500;
}

.annot-em {
  font-size: 11px;
  fill: var(--ink);
  font-family: inherit;
  font-weight: 700;
}

/* Area fills */
.area-cs {
  fill: var(--cs);
  stroke: none;
}

.area-ps {
  fill: var(--ps);
  stroke: none;
}

.area-dwl {
  fill: var(--dwl);
  stroke: none;
}

.area-soft {
  fill: rgba(108, 99, 255, 0.06);
  stroke: none;
}
