/* ==========================================================================
   Vision — Moodboard Builder
   Tool-specific styles, built on top of the gsweb-concept design tokens.
   ========================================================================== */

/* ---------- Top bar ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: var(--z-header);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-4) var(--container-pad);
  background: rgba(6, 6, 7, 0.72);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}

:root[data-theme="light"] .topbar {
  background: rgba(250, 250, 249, 0.78);
}

.topbar__brand {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}

.topbar__logo {
  width: auto;
  height: 2rem;
  object-fit: contain;
  padding-top: 0.1rem;
}

.beta-badge {
  display: inline-flex;
  margin-left: 1rem;
  padding: 4px 9px 4px 9px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--fg-muted);
  font-size: var(--fs-2xs);
  font-weight: 500;
  white-space: nowrap;
  cursor: default;
}

.topbar__actions {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.privacy-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px 6px 10px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border);
  background: var(--accent-muted-soft, rgba(168, 77, 168, 0.08));
  color: var(--fg-muted);
  font-size: var(--fs-2xs);
  font-weight: 500;
  white-space: nowrap;
  cursor: default;
}

.privacy-badge svg {
  width: 14px;
  height: 14px;
  color: var(--accent);
  flex-shrink: 0;
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  border-radius: var(--radius-full);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--fg-muted);
}

.theme-toggle:hover {
  background: var(--surface-hover);
  color: var(--fg);
}

.theme-toggle svg {
  width: 17px;
  height: 17px;
}

/* ---------- Intro ---------- */

.intro {
  text-align: center;
  padding: var(--space-7) var(--container-pad) var(--space-6);
}

.intro h1 {
  font-size: var(--fs-2xl);
  margin-bottom: var(--space-2);
}

.intro p {
  max-width: 520px;
  margin-inline: auto;
  font-size: var(--fs-sm);
}

/* ---------- Control panel (meta form + toolbar) ---------- */

.control-panel {
  width: 100%;
  max-width: 1040px;
  margin: 0 auto var(--space-7);
  padding-inline: var(--container-pad);
}

.control-panel__divider {
  height: 1px;
  background: var(--border);
  margin: var(--space-5) 0;
}

/* ---------- Meta form (project / client name) ---------- */

.meta-form {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-4);
}

.field {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  flex: 1 1 220px;
}

.field label {
  font-size: var(--fs-2xs);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wider);
  color: var(--fg-subtle);
}

.field input[type="text"] {
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-full);
  border: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--fg);
  font-size: var(--fs-sm);
}

.field input[type="text"]:focus-visible {
  border-color: var(--border-focus);
}

.field input[type="text"]::placeholder {
  color: var(--fg-subtle);
}

/* ---------- Toolbar ---------- */

.toolbar {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
}

.toolbar__row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: var(--space-6) var(--space-8);
  padding-top: var(--space-5);
  border-top: 1px solid var(--border);
}

.toolbar__group {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.toolbar__group--full {
  width: 100%;
}

.toolbar__label {
  font-size: var(--fs-2xs);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wider);
  color: var(--fg-subtle);
}

.toolbar__buttons {
  display: flex;
  gap: var(--space-2);
}

/* Icons inside toolbar buttons (Raster / PDF-Hintergrund) — the buttons
   themselves are plain .btn elements so every toolbar group shares the exact
   same pill shape, sizing and selected/unselected styling. */
.layout-select__icon {
  width: 20px;
  height: 15px;
  flex-shrink: 0;
}

.toolbar-icon {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}

/* ---------- Canvas ---------- */

.canvas-wrap {
  padding: 0 var(--container-pad) var(--space-9);
  display: flex;
  justify-content: center;
}

.canvas-board {
  position: relative;
  width: 100%;
  max-width: 1040px;
  padding: var(--space-6);
  border-radius: var(--radius-xl);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
}

.moodboard-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-5);
  flex-wrap: wrap;
}

.moodboard-title__name {
  font-family: var(--font-display);
  font-size: var(--fs-xl);
  font-weight: 700;
}

.moodboard-title__client {
  font-size: var(--fs-sm);
  color: var(--fg-subtle);
}

.grid-canvas {
  display: grid;
  gap: var(--space-3);
  width: 100%;
  border-radius: var(--radius-md);
  overflow: hidden;
}

.extra-grid-wrap {
  margin-top: var(--space-5);
}

.extra-grid__label {
  display: block;
  font-size: var(--fs-2xs);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wider);
  color: var(--fg-subtle);
  margin-bottom: var(--space-3);
}

.extra-grid {
  display: grid;
  gap: var(--space-3);
}

.cell {
  position: relative;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  min-height: 0;
  min-width: 0;
}

.cell[draggable="true"] {
  cursor: grab;
}

.cell.is-dragover {
  outline: 2px dashed var(--accent);
  outline-offset: -2px;
}

.cell--empty {
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  background: var(--bg-elev);
  border: 1.5px dashed var(--border-strong);
  color: var(--fg-subtle);
  transition: border-color var(--dur-fast) var(--ease-out-quart),
    color var(--dur-fast) var(--ease-out-quart);
}

.cell--empty:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.cell--empty svg {
  width: 26px;
  height: 26px;
}

.cell__delete-empty {
  position: absolute;
  top: 6px;
  right: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: var(--radius-full);
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  color: var(--fg-subtle);
  opacity: 0;
  transition: opacity var(--dur-fast) var(--ease-out-quart);
}

.cell--empty:hover .cell__delete-empty,
.cell__delete-empty:focus-visible {
  opacity: 1;
}

.cell__delete-empty:hover {
  color: var(--danger);
  border-color: var(--danger);
}

.cell__delete-empty svg {
  width: 12px;
  height: 12px;
}

/* Resize handle — only on user-added "extra" fields, lets them be dragged
   to any size in whole units of the active layout's own grid (columns and
   unit size are set inline by app.js to match the board above). */
.cell__resize-handle {
  position: absolute;
  right: 4px;
  bottom: 4px;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: var(--radius-sm);
  background: rgba(10, 10, 11, 0.6);
  color: #fff;
  cursor: nwse-resize;
  opacity: 0;
  touch-action: none;
  backdrop-filter: blur(4px);
  transition: opacity var(--dur-fast) var(--ease-out-quart),
    background var(--dur-fast) var(--ease-out-quart);
}

.cell:hover .cell__resize-handle,
.cell.is-resizing .cell__resize-handle {
  opacity: 1;
}

.cell__resize-handle:hover {
  background: var(--accent);
}

.cell__resize-handle svg {
  width: 13px;
  height: 13px;
}

.cell.is-resizing {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.cell__img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  user-select: none;
  -webkit-user-drag: none;
}

.cell__color-hex {
  position: absolute;
  left: var(--space-2);
  bottom: var(--space-2);
  padding: 2px 8px;
  border-radius: var(--radius-full);
  background: rgba(0, 0, 0, 0.35);
  color: #fff;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: var(--tracking-wide);
  backdrop-filter: blur(4px);
}

.cell__overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: flex-start;
  justify-content: flex-end;
  gap: 6px;
  padding: 6px;
  opacity: 0;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.35), transparent 40%);
  transition: opacity var(--dur-fast) var(--ease-out-quart);
}

.cell:hover .cell__overlay,
.cell:focus-within .cell__overlay {
  opacity: 1;
}

.cell__icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: var(--radius-full);
  background: rgba(10, 10, 11, 0.6);
  color: #fff;
  backdrop-filter: blur(4px);
}

.cell__icon-btn:hover {
  background: var(--accent);
}

.cell__icon-btn svg {
  width: 14px;
  height: 14px;
}

/* Empty-cell popover: choose image or color */

.cell-popover {
  position: absolute;
  z-index: var(--z-overlay);
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 6px;
  min-width: 170px;
  border-radius: var(--radius-md);
  background: var(--bg-elev-2);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-lg);
}

.cell-popover button {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  font-size: var(--fs-sm);
  color: var(--fg);
  text-align: left;
}

.cell-popover button:hover {
  background: var(--surface-hover);
}

.cell-popover svg {
  width: 16px;
  height: 16px;
  color: var(--accent);
  flex-shrink: 0;
}

/* Color popover: swatches + native picker + hex field */

.color-popover {
  position: absolute;
  z-index: var(--z-overlay);
  width: 220px;
  padding: var(--space-4);
  border-radius: var(--radius-md);
  background: var(--bg-elev-2);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-lg);
}

.color-popover__swatches {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}

.color-swatch {
  width: 100%;
  aspect-ratio: 1;
  border-radius: var(--radius-full);
  border: 1px solid rgba(0, 0, 0, 0.12);
  cursor: pointer;
  transition: transform var(--dur-fast) var(--ease-out-quart);
}

.color-swatch:hover {
  transform: scale(1.12);
}

.color-popover__custom {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.color-popover__native {
  width: 38px;
  height: 38px;
  flex-shrink: 0;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: none;
  cursor: pointer;
}

.color-popover__native::-webkit-color-swatch-wrapper {
  padding: 2px;
}

.color-popover__native::-webkit-color-swatch {
  border: none;
  border-radius: 4px;
}

.color-popover__hex {
  flex: 1;
  min-width: 0;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--fg);
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  text-transform: uppercase;
}

.color-popover__hex:focus-visible {
  border-color: var(--border-focus);
}

/* ---------- Toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: var(--space-6);
  transform: translate(-50%, 12px);
  padding: var(--space-3) var(--space-5);
  border-radius: var(--radius-full);
  background: var(--bg-inverse);
  color: var(--fg-inverse);
  font-size: var(--fs-sm);
  box-shadow: var(--shadow-lg);
  z-index: var(--z-modal);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur-base) var(--ease-out-quart),
    transform var(--dur-base) var(--ease-out-quart);
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* ---------- Footer ---------- */

.site-footer {
  border-top: 1px solid var(--border);
  padding: var(--space-6) var(--container-pad);
  text-align: center;
}

.site-footer p {
  font-size: var(--fs-xs);
  color: var(--fg-subtle);
}

.site-footer a {
  color: var(--fg-muted);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.site-footer__legal {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  margin-top: var(--space-3);
  font-size: var(--fs-2xs);
  color: var(--fg-subtle);
}

.site-footer__legal a {
  color: var(--fg-subtle);
  text-decoration: none;
}

.site-footer__legal a:hover {
  color: var(--fg-muted);
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* ---------- Hidden helpers ---------- */

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

[hidden] {
  display: none !important;
}

/* ---------- Responsive ---------- */

@media (max-width: 720px) {
  .topbar__tool-name { display: none; }
  .privacy-badge__text { display: none; }
  .privacy-badge { padding: 8px; }
  .canvas-board { padding: var(--space-4); border-radius: var(--radius-lg); }
  .grid-canvas, .extra-grid { gap: var(--space-2); }
  .cell__icon-btn { width: 24px; height: 24px; }
  .intro h1 { font-size: var(--fs-xl); }
  .toolbar__row { flex-direction: column; }
}

@media (max-width: 480px) {
  .toolbar__buttons { flex-wrap: wrap; }
}
