/* graph.css — оформление страницы «Графики функций» */

body { display: flex; flex-direction: column; height: 100vh; }

/* Две колонки: панель слева (340px) и график справа (всё остальное) */
.graph-page {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
}

.panel {
  padding: 18px;
  border-right: 1px solid var(--line);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* --- Поле ввода --- */
.entry { display: flex; align-items: center; gap: 8px; }
.entry label { font-family: var(--font-math); font-style: italic; font-size: 20px; color: var(--muted); }
.entry input {
  flex: 1;
  min-width: 0;
  font: 18px var(--font);
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 12px;
  outline: none;
}
.entry input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(91, 155, 255, .2); }
.entry button { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.entry button:hover { background: #4a88ee; }

/* «Понял как: y = x³» под полем */
.preview { min-height: 28px; font-size: 15px; color: var(--muted); margin-top: -8px; }
.preview.error { color: var(--danger); }

/* --- Красивая формула (её рисует parser.js → toHtml) --- */
.math { font-family: var(--font-math); font-size: 19px; color: var(--text); white-space: nowrap; }
.math sup { font-size: 0.7em; }
.math .frac { display: inline-flex; flex-direction: column; vertical-align: middle; text-align: center; font-size: 0.9em; margin: 0 2px; }
.math .frac > span:first-child { border-bottom: 1px solid currentColor; padding: 0 3px; }
.math .frac > span:last-child { padding: 0 3px; }
.math .rad { border-top: 1px solid currentColor; padding: 0 2px; }

/* --- Список построенных графиков --- */
.fn-list { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.fn-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 8px 10px;
}
.fn-list li.hidden { opacity: .45; }
.swatch {                                  /* цветной кружок: щёлкни — спрятать/показать */
  width: 18px; height: 18px; flex: none;
  border-radius: 50%;
  padding: 0;
  color: inherit;                          /* цвет берётся от строки списка (цвет графика) */
  border: 2px solid currentColor;
  background: currentColor;
}
.fn-list li.hidden .swatch { background: transparent; }
.fn-list .math { flex: 1; overflow-x: auto; cursor: pointer; }
.remove { padding: 2px 9px; color: var(--muted); background: transparent; border-color: transparent; font-size: 18px; }
.remove:hover { color: var(--danger); border-color: transparent; }

/* --- Примеры --- */
.examples { display: flex; flex-wrap: wrap; gap: 6px; }
.examples-title { width: 100%; color: var(--muted); font-size: 14px; }
.examples button { font-family: var(--font-math); font-size: 16px; padding: 5px 11px; }

.clear { align-self: flex-start; color: var(--muted); font-size: 14px; }

/* --- Подсказка --- */
.help { color: var(--muted); font-size: 14px; }
.help summary { cursor: pointer; color: var(--text); }
.help table { margin: 10px 0; border-collapse: collapse; width: 100%; }
.help td { padding: 4px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
.help code { color: var(--accent); font-size: 14px; }

/* --- Область графика --- */
.plot-wrap { position: relative; min-height: 0; }
#plot { width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; }
#plot.dragging { cursor: grabbing; }
.zoom { position: absolute; right: 14px; bottom: 14px; display: flex; flex-direction: column; gap: 6px; }
.zoom button { width: 40px; height: 40px; padding: 0; font-size: 20px; background: rgba(22, 27, 34, .9); }

/* --- Телефон: панель сверху, график снизу --- */
@media (max-width: 760px) {
  body { height: auto; }
  .graph-page { grid-template-columns: 1fr; }
  .panel { border-right: none; border-bottom: 1px solid var(--line); overflow: visible; }
  .plot-wrap { height: 75vh; }
}
