/* pages.css — hero, editor workspace, crop overlay, content pages. */

/* ------------------------------------------------------------------ Hero */
.hero { position: relative; padding-block: var(--sp-10) var(--sp-8); background: var(--grad-hero); overflow: hidden; }
.hero__inner { text-align: center; max-width: 760px; margin: 0 auto; }
.hero h1 { background: linear-gradient(135deg, var(--text), var(--secondary)); -webkit-background-clip: text; background-clip: text; }
.hero__sub { font-size: var(--fs-xl); color: var(--muted); margin: var(--sp-4) auto var(--sp-5); max-width: 56ch; }
.hero__badges { display: flex; gap: var(--sp-4); justify-content: center; flex-wrap: wrap; color: var(--muted); font-size: var(--fs-sm); }
.hero__badge { display: inline-flex; align-items: center; gap: 6px; }
.hero__badge .icon { color: var(--success); }

/* ------------------------------------------------------------- Dropzone */
.dropzone {
  margin: var(--sp-6) auto 0; max-width: 720px;
  border: 2px dashed var(--border-strong); border-radius: var(--r-xl);
  background: var(--bg); padding: var(--sp-10) var(--sp-6); text-align: center;
  cursor: pointer; transition: all 0.2s var(--ease); box-shadow: var(--sh-md);
}
.dropzone:hover { border-color: var(--primary); transform: translateY(-2px); box-shadow: var(--sh-lg); }
.dropzone.is-drag { border-color: var(--primary); background: var(--primary-soft); transform: scale(1.01); }
.dropzone.is-compact { padding: var(--sp-5); max-width: var(--container); }
.dropzone.is-compact .dropzone__big { display: none; }
.dropzone__icon { display: grid; place-items: center; width: 64px; height: 64px; margin: 0 auto var(--sp-4); border-radius: 20px; background: var(--primary-soft); color: var(--primary); }
.dropzone__title { font-size: var(--fs-xl); font-weight: 700; }
.dropzone__hint { color: var(--muted); margin: var(--sp-2) 0 var(--sp-4); }
.dropzone__formats { font-size: var(--fs-xs); color: var(--muted-2); margin-top: var(--sp-3); }
.dropzone__error { color: var(--danger); font-weight: 600; margin-top: var(--sp-3); }
.dropzone.is-compact .dropzone__compact { display: inline-flex; }
.dropzone__compact { display: none; align-items: center; gap: var(--sp-3); justify-content: center; }

/* ------------------------------------------------------------- Editor */
.editor {
  margin-top: var(--sp-6);
  border: 1px solid var(--border); border-radius: var(--r-xl);
  background: var(--bg); box-shadow: var(--sh-lg); overflow: hidden;
}
.editor__bar {
  display: flex; align-items: center; gap: var(--sp-4); flex-wrap: wrap;
  padding: var(--sp-3) var(--sp-5); border-bottom: 1px solid var(--border); background: var(--surface);
}
.editor__file { display: flex; align-items: center; gap: var(--sp-3); min-width: 0; }
.editor__file-name { font-weight: 600; max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.editor__meta { display: flex; gap: var(--sp-4); color: var(--muted); font-size: var(--fs-sm); font-variant-numeric: tabular-nums; }
.editor__meta span { display: inline-flex; align-items: center; gap: 4px; }
.editor__bar-spacer { flex: 1; }
.meta-badge { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-xs); font-weight: 600; color: var(--success); background: color-mix(in srgb, var(--success) 12%, transparent); padding: 4px 10px; border-radius: var(--r-full); }

.editor__body { display: grid; grid-template-columns: 330px 1fr; min-height: 520px; }

.sidebar { border-right: 1px solid var(--border); display: flex; flex-direction: column; background: var(--bg); }
.tooltabs { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--sp-1); padding: var(--sp-3); border-bottom: 1px solid var(--border); }
.tooltab {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: var(--sp-3) var(--sp-2); border: 1px solid transparent; border-radius: var(--r-md);
  background: transparent; color: var(--muted); font-size: 0.72rem; font-weight: 600;
  transition: all 0.15s var(--ease);
}
.tooltab:hover { background: var(--surface); color: var(--text); }
.tooltab.is-active { background: var(--primary-soft); color: var(--primary); }
.toolpanel { padding: var(--sp-5); overflow-y: auto; flex: 1; }
.panel__head { margin-bottom: var(--sp-5); }
.panel__title { font-size: var(--fs-lg); }
.panel__hint { color: var(--muted); font-size: var(--fs-sm); margin-top: 4px; }

/* Preview stage with checkerboard for transparency */
.preview { position: relative; display: flex; flex-direction: column; background: var(--surface-2); }
.stage {
  position: relative; flex: 1; display: grid; place-items: center; padding: var(--sp-6);
  overflow: hidden; min-height: 360px;
  background-image:
    linear-gradient(45deg, var(--border) 25%, transparent 25%),
    linear-gradient(-45deg, var(--border) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, var(--border) 75%),
    linear-gradient(-45deg, transparent 75%, var(--border) 75%);
  background-size: 22px 22px;
  background-position: 0 0, 0 11px, 11px -11px, -11px 0;
}
#previewCanvas {
  max-width: 100%; max-height: 62vh; border-radius: var(--r-sm);
  box-shadow: var(--sh-lg); background: #fff;
}

/* Crop overlay */
.crop-overlay { position: absolute; z-index: 5; touch-action: none; }
.crop-box {
  position: absolute; box-sizing: border-box; cursor: move;
  /* Bright dashed frame; the area outside the selection is strongly darkened
     so the kept area stands out. Apply removes the dark part for real. */
  border: 2px dashed #fff;
  outline: 1px solid rgba(0, 0, 0, 0.6);
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.62);
}
.crop-grid { position: absolute; inset: 0; pointer-events: none;
  background-image: linear-gradient(#fff6 1px, transparent 1px), linear-gradient(90deg, #fff6 1px, transparent 1px);
  background-size: 33.33% 33.33%; opacity: 0.6; }
.crop-handle {
  position: absolute; width: 14px; height: 14px; background: #fff; border: 2px solid var(--primary);
  border-radius: 3px; box-shadow: var(--sh-sm);
}
.crop-handle[data-h="nw"] { top: -7px; left: -7px; cursor: nwse-resize; }
.crop-handle[data-h="ne"] { top: -7px; right: -7px; cursor: nesw-resize; }
.crop-handle[data-h="sw"] { bottom: -7px; left: -7px; cursor: nesw-resize; }
.crop-handle[data-h="se"] { bottom: -7px; right: -7px; cursor: nwse-resize; }

/* Download bar */
.download-bar {
  display: flex; align-items: center; gap: var(--sp-4); flex-wrap: wrap;
  padding: var(--sp-4) var(--sp-5); border-top: 1px solid var(--border); background: var(--surface);
}
.download-bar__info { display: flex; gap: var(--sp-5); flex-wrap: wrap; font-size: var(--fs-sm); }
.download-bar__info b { font-variant-numeric: tabular-nums; }
.download-bar__info .muted { color: var(--muted); margin-right: 4px; }
.download-bar__spacer { flex: 1; }
.download-bar .field--select { display: inline-flex; align-items: center; }
.select {
  border: 1px solid var(--border); border-radius: var(--r-sm); background: var(--bg);
  padding: 0.5rem 0.7rem; font-size: var(--fs-sm); font-weight: 600;
}
.dl-strip { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-sm); color: var(--muted); cursor: pointer; }

/* Responsive editor */
@media (max-width: 900px) {
  .editor__body { grid-template-columns: 1fr; }
  .preview { order: -1; }
  .sidebar { border-right: 0; border-top: 1px solid var(--border); }
  .tooltabs { grid-template-columns: repeat(4, 1fr); }
  #previewCanvas { max-height: 48vh; }
  .toolpanel { max-height: 360px; }
}
@media (max-width: 520px) {
  .tooltabs { grid-template-columns: repeat(4, 1fr); gap: 2px; }
  .tooltab { font-size: 0.62rem; padding: var(--sp-2) 2px; }
  .editor__meta { display: none; }
  .download-bar { position: sticky; bottom: 0; }
}

/* ------------------------------------------------------------- Content pages */
.page { padding-block: var(--sp-10); }
.page__inner { max-width: 760px; margin: 0 auto; }
.page h1 { margin-bottom: var(--sp-4); }
.page h2 { font-size: var(--fs-2xl); margin: var(--sp-6) 0 var(--sp-3); }
.page p { color: var(--muted); margin-bottom: var(--sp-4); }
.page ul { color: var(--muted); padding-left: 1.2rem; margin-bottom: var(--sp-4); display: grid; gap: var(--sp-2); }
.page a { color: var(--primary); font-weight: 500; }
.prose-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: var(--sp-6); }

/* Landing page hero CTA block */
.landing-cta { display: flex; gap: var(--sp-3); flex-wrap: wrap; margin: var(--sp-5) 0; }
.contact-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-4); margin-top: var(--sp-5); }
.contact-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: var(--sp-5); }
.contact-card h3 { font-size: var(--fs-base); margin-bottom: 4px; }
@media (max-width: 560px) { .contact-grid { grid-template-columns: 1fr; } }

/* =================================================================
   APP MODE + PREMIUM EDITOR POLISH
   When an image is loaded the marketing page collapses and the editor
   becomes a focused, full-height workspace.
   ================================================================= */
body.is-editing .home-only { display: none; }
body.is-editing { background: var(--surface-2); }
body.is-editing main { padding-top: var(--sp-5); padding-bottom: var(--sp-6); }
body.is-editing .editor {
  margin-top: 0;
  min-height: calc(100vh - var(--nav-h) - 56px);
  display: flex;
  flex-direction: column;
  animation: editorIn 0.45s var(--ease) both;
}
body.is-editing .editor__body { flex: 1; }
@keyframes editorIn {
  from { opacity: 0; transform: translateY(14px) scale(0.992); }
  to { opacity: 1; transform: none; }
}

/* Editor frame — softer, deeper, premium */
.editor {
  border-radius: var(--r-xl);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--text) 5%, transparent), 0 24px 60px -24px rgba(0, 0, 0, 0.35);
}

/* Top bar: filename chip, meta pills, actions */
.editor__bar { background: var(--surface); padding: var(--sp-3) var(--sp-4); gap: var(--sp-3); }
.editor__file-icon {
  display: grid; place-items: center; width: 30px; height: 30px;
  border-radius: 9px; background: var(--primary-soft); color: var(--primary); flex: 0 0 auto;
}
.editor__file-name { font-weight: 600; }
.editor__meta span {
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--r-full);
  padding: 3px 11px; font-weight: 500; color: var(--muted);
}

/* Tool tabs — bigger targets, clear active state with accent */
.tooltabs { gap: var(--sp-2); padding: var(--sp-4); }
.tooltab {
  padding: 13px 8px; gap: 7px; border-radius: var(--r-md); font-weight: 600;
  position: relative; border: 1px solid transparent;
}
.tooltab .icon { color: var(--muted-2); transition: color 0.15s var(--ease), transform 0.15s var(--ease); }
.tooltab:hover { background: var(--surface); color: var(--text); }
.tooltab:hover .icon { color: var(--text); transform: translateY(-1px); }
.tooltab.is-active {
  background: var(--primary-soft); color: var(--text);
  box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--text) 12%, transparent);
}
.tooltab.is-active .icon { color: var(--primary); }
.tooltab.is-active::after {
  content: ''; position: absolute; left: 50%; bottom: 6px; transform: translateX(-50%);
  width: 16px; height: 3px; border-radius: 3px; background: var(--primary);
}

/* Panel fade-in on tool switch */
.toolpanel > .panel { animation: panelIn 0.28s var(--ease) both; }
@keyframes panelIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* Preview stage — subtler checkerboard, framed canvas */
.stage { background-color: var(--surface-2); }
#previewCanvas {
  border-radius: 6px;
  box-shadow: 0 16px 50px -16px rgba(0, 0, 0, 0.45), 0 0 0 1px color-mix(in srgb, var(--text) 8%, transparent);
}

/* Download bar — prominent CTA, gradient hairline, green savings */
.download-bar { background: var(--bg); padding: var(--sp-4) var(--sp-5); position: relative; }
.download-bar::before {
  content: ''; position: absolute; top: -1px; left: 0; right: 0; height: 1px;
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--primary) 32%, transparent), transparent);
}
.download-bar__info b { font-weight: 700; }
#downloadBtn { box-shadow: var(--sh-glow); }

/* Savings readout: green only when actually smaller */
[data-saved] { color: var(--muted); transition: color 0.2s; }
[data-saved].is-positive { color: var(--success); }
[data-saved].is-negative { color: var(--warning); }
.stats__row--accent strong[data-saved].is-negative { color: var(--warning); }
