/* ═══════════════════════════════════════════════════════════════
   Photo Editor — interactive canvas editor styles
   ─────────────────────────────────────────────────────────────
   Loaded only on /photo-editor/. Reuses qtool.css design tokens.
   Phase 1: text overlay editor. Phase 2+ tools disabled in UI.
   ═══════════════════════════════════════════════════════════════ */

/* Add missing @font-face for editor (Geist + Instrument Serif Regular) */
@font-face {
  font-family: 'Geist';
  src: url('/static/fonts/geist/Geist-Regular.woff2') format('woff2');
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Geist';
  src: url('/static/fonts/geist/Geist-Medium.woff2') format('woff2');
  font-weight: 500; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Geist';
  src: url('/static/fonts/geist/Geist-SemiBold.woff2') format('woff2');
  font-weight: 600; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Geist';
  src: url('/static/fonts/geist/Geist-Bold.woff2') format('woff2');
  font-weight: 700; font-style: normal; font-display: swap;
}

/* Layout */
.editor-body {
  background: var(--bg);
  color: var(--fg);
  min-height: 100vh;
  font-family: 'Inter', system-ui, sans-serif;
}

.editor {
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 60px);
}

/* Hero */
.editor__hero {
  padding: 48px 0 32px;
  background: linear-gradient(180deg, var(--bg-soft) 0%, var(--bg) 100%);
  border-bottom: 1px solid var(--border);
}
.editor__title {
  margin: 18px 0 16px;
  font-size: clamp(36px, 6vw, 64px);
  line-height: 1.05;
}
.editor__lede {
  font-size: 17px;
  color: var(--fg-muted);
  max-width: 60ch;
  line-height: 1.5;
}

/* Workspace */
.editor__workspace {
  flex: 1;
  display: flex;
  flex-direction: column;
}

/* Empty state */
.editor__empty {
  padding: 64px 24px;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 60vh;
}
.editor__empty-card {
  background: var(--bg-card);
  border: 2px dashed var(--border-strong);
  border-radius: 12px;
  padding: 56px 40px;
  text-align: center;
  max-width: 480px;
  width: 100%;
  transition: border-color .2s, background .2s;
}
.editor__empty-card.dragover {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.editor__empty-icon {
  width: 64px; height: 64px;
  color: var(--fg-subtle);
  margin-bottom: 24px;
}
.editor__empty h2 {
  font-size: 24px;
  margin: 0 0 8px;
  letter-spacing: -0.02em;
}
.editor__empty p {
  color: var(--fg-muted);
  margin: 0 0 24px;
  line-height: 1.5;
}
.editor__empty kbd {
  display: inline-block;
  padding: 2px 6px;
  background: var(--kbd-bg);
  color: var(--kbd-fg);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  line-height: 1;
  vertical-align: middle;
}
.editor__empty-hint {
  margin-top: 16px;
  font-size: 13px;
  color: var(--fg-subtle);
}

/* Main editor layout — 3 columns desktop */
.editor__main {
  display: grid;
  grid-template-columns: 88px 1fr 320px;
  gap: 0;
  min-height: 60vh;
  border-top: 1px solid var(--border);
}

@media (max-width: 980px) {
  .editor__main {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr auto;
  }
}

/* Left toolbar */
.editor__tools {
  background: var(--bg-soft);
  border-right: 1px solid var(--border);
  padding: 16px 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
@media (max-width: 980px) {
  .editor__tools {
    flex-direction: row;
    border-right: none;
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
  }
}
.tool {
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 12px 8px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  color: var(--fg-muted);
  font-size: 11px;
  font-weight: 500;
  position: relative;
  transition: all .15s;
  min-width: 72px;
}
.tool svg {
  width: 24px;
  height: 24px;
}
.tool:not(:disabled):hover {
  background: var(--bg-hover);
  color: var(--fg);
}
.tool.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-fg);
}
.tool:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.tool__badge {
  position: absolute;
  top: 4px;
  right: 4px;
  background: var(--fg-subtle);
  color: var(--bg-card);
  font-size: 9px;
  padding: 1px 5px;
  border-radius: 3px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* Canvas */
.editor__canvas-wrap {
  background: var(--bg-soft);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px;
  position: relative;
}
.editor__canvas-frame {
  background:
    repeating-conic-gradient(#E5E3DC 0% 25%, transparent 0% 50%) 50% / 16px 16px;
  background-color: #F4F2EC;
  box-shadow: var(--shadow-md);
  max-width: 100%;
  max-height: 70vh;
  display: inline-block;
  position: relative;
}
[data-theme="dark"] .editor__canvas-frame {
  background:
    repeating-conic-gradient(#1A1A22 0% 25%, transparent 0% 50%) 50% / 16px 16px;
  background-color: #14141A;
}
#editor-canvas {
  display: block;
  max-width: 100%;
  max-height: 70vh;
  height: auto;
  cursor: move;
  touch-action: none;
}
.editor__canvas-info {
  margin-top: 16px;
  display: flex;
  gap: 16px;
  align-items: center;
  font-size: 13px;
  color: var(--fg-muted);
}

/* Right properties panel */
.editor__props {
  background: var(--bg-card);
  border-left: 1px solid var(--border);
  padding: 24px 20px;
  overflow-y: auto;
  max-height: 70vh;
}
@media (max-width: 980px) {
  .editor__props {
    border-left: none;
    border-top: 1px solid var(--border);
    max-height: none;
  }
}

.prop-group {
  margin-bottom: 20px;
}
.prop-group--row {
  display: flex;
  gap: 12px;
}
.prop-half {
  flex: 1;
}
.prop-group__label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--fg-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 6px;
}
.prop-group--hint {
  background: var(--bg-soft);
  padding: 12px;
  border-radius: 6px;
  border: 1px solid var(--border);
}
.prop-group--hint small {
  color: var(--fg-muted);
  font-size: 12px;
  line-height: 1.5;
}
.prop-group--hint kbd {
  display: inline-block;
  padding: 1px 5px;
  background: var(--kbd-bg);
  color: var(--kbd-fg);
  border: 1px solid var(--border);
  border-radius: 3px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  line-height: 1;
  vertical-align: middle;
}

/* Phase 2: Layer panel */
.prop-group--layers {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px;
}
.layers-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.layers-actions {
  display: flex;
  gap: 4px;
}
.layer-action-btn {
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  width: 28px;
  height: 28px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--fg-muted);
  transition: all .15s;
}
.layer-action-btn:hover:not(:disabled) {
  background: var(--bg-hover);
  color: var(--fg);
  border-color: var(--fg-subtle);
}
.layer-action-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.layer-action-btn--accent {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}
.layer-action-btn--accent:hover:not(:disabled) {
  background: var(--accent-fg);
  border-color: var(--accent-fg);
  color: white;
}
.layer-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 200px;
  overflow-y: auto;
}
.layer-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
  color: var(--fg);
  transition: all .12s;
}
.layer-item:hover {
  background: var(--bg-hover);
  border-color: var(--fg-subtle);
}
.layer-item.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-fg);
}
.layer-item__preview {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 500;
}
.layer-item__delete {
  background: transparent;
  border: none;
  color: var(--fg-subtle);
  cursor: pointer;
  padding: 0 6px;
  font-size: 16px;
  line-height: 1;
  border-radius: 3px;
  transition: all .12s;
}
.layer-item__delete:hover {
  background: rgba(255, 91, 34, 0.15);
  color: var(--accent);
}
.layer-item.active .layer-item__delete {
  color: var(--accent-fg);
}

/* Phase 3: Crop tool */
.prop-section__title {
  font-size: 14px;
  font-weight: 700;
  margin: 0 0 16px;
  letter-spacing: -0.01em;
}
.aspect-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}
.aspect-btn {
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  padding: 8px 4px;
  cursor: pointer;
  color: var(--fg);
  font-size: 12px;
  font-weight: 500;
  transition: all .12s;
}
.aspect-btn:hover {
  background: var(--bg-hover);
  border-color: var(--fg-subtle);
}
.aspect-btn.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-fg);
}
.crop-size {
  background: var(--bg-soft);
  padding: 12px;
  border-radius: 4px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  text-align: center;
  color: var(--fg);
}
.prop-actions {
  display: flex;
  gap: 8px;
}
.prop-actions .btn {
  flex: 1;
}
.btn--ghost {
  background: transparent;
  border: 1px solid var(--border-strong);
  color: var(--fg);
}
.btn--ghost:hover {
  background: var(--bg-hover);
}

/* Crop overlay — рисуется JS поверх canvas в той же frame */
.crop-canvas {
  cursor: crosshair !important;
}

.editor__props textarea,
.editor__props select,
.editor__props input[type="text"] {
  width: 100%;
  padding: 8px 10px;
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  color: var(--fg);
  font-family: inherit;
  font-size: 14px;
  resize: vertical;
}
.editor__props textarea:focus,
.editor__props select:focus,
.editor__props input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.editor__props input[type="color"] {
  width: 100%;
  height: 36px;
  padding: 2px;
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  cursor: pointer;
}

.editor__props input[type="range"] {
  width: 100%;
  margin: 4px 0 0;
  accent-color: var(--accent);
}

.align-row {
  display: flex;
  gap: 6px;
}
.align-btn {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  padding: 8px;
  cursor: pointer;
  color: var(--fg-muted);
  font-size: 18px;
  transition: all .15s;
}
.align-btn:hover {
  background: var(--bg-hover);
  color: var(--fg);
}
.align-btn.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-fg);
}

/* Action bar (sticky bottom) */
.editor__actionbar {
  position: sticky;
  bottom: 0;
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  padding: 12px 0;
  box-shadow: 0 -8px 32px -16px rgba(0,0,0,0.1);
  z-index: 10;
}
.actionbar__inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 24px;
  flex-wrap: wrap;
}
.actionbar__left {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  flex: 1;
}
.actionbar__label {
  font-size: 13px;
  font-weight: 600;
  color: var(--fg-muted);
}
.actionbar__inner select {
  padding: 6px 10px;
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  color: var(--fg);
  font-family: inherit;
}
.actionbar__quality {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  color: var(--fg-muted);
}
.actionbar__quality input[type="range"] {
  width: 120px;
  accent-color: var(--accent);
}
.actionbar__right .btn svg {
  vertical-align: middle;
  margin-right: 6px;
}

/* Info section under editor */
.editor__about {
  max-width: 70ch;
  padding: 48px 0;
}
.steps {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 24px;
  margin-top: 24px;
}
.step {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 24px;
}
.step__num {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  color: var(--accent);
  letter-spacing: 0.08em;
  margin-bottom: 12px;
}
.step__title {
  font-size: 18px;
  margin: 0 0 8px;
  letter-spacing: -0.01em;
}
.step p {
  color: var(--fg-muted);
  margin: 0;
  font-size: 14px;
  line-height: 1.5;
}

.feat-list {
  list-style: none;
  padding: 0;
  margin: 24px 0 0;
}
.feat-list li {
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  color: var(--fg-muted);
  line-height: 1.5;
}
.feat-list li:last-child {
  border-bottom: none;
}
.feat-list strong {
  color: var(--fg);
  display: block;
  margin-bottom: 4px;
}

.faq-item {
  margin: 16px 0;
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
}
.faq-item summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 16px;
  letter-spacing: -0.01em;
}
.faq-item summary:hover {
  color: var(--accent);
}
.faq-item p {
  margin: 12px 0 0;
  color: var(--fg-muted);
  line-height: 1.6;
}

/* Footer */
.footer {
  background: var(--bg-soft);
  border-top: 1px solid var(--border);
  padding: 32px 0;
  font-size: 13px;
  color: var(--fg-muted);
}
.footer .container {
  display: flex;
  align-items: center;
}
.footer a {
  color: var(--fg-muted);
  text-decoration: none;
  margin: 0 8px;
}
.footer a:hover {
  color: var(--accent);
  text-decoration: underline;
}

/* Button helpers (если в qtool.css нет btn--lg) */
.btn--lg {
  font-size: 16px;
  padding: 12px 24px;
}
.btn--sm {
  font-size: 12px;
  padding: 4px 10px;
}
