/*
 * The announcement maker («صانع الإعلانات», js/maker.js): the form on the inline start, and the
 * poster on a screen hanging from the ceiling rail at the inline end, on the same lit wall as the
 * Screens view. All colours are --fm-* tokens from /brand.css.
 */

.page-head--action { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--space-4); flex-wrap: wrap; }
.page-head--action .btn .icon { width: 18px; height: 18px; }

.dialog--maker[open] {
  width: min(1180px, calc(100vw - 2 * var(--margin)));
  max-width: none;
  height: min(900px, calc(100vh - 48px));
  grid-template-columns: minmax(0, 1fr) minmax(300px, 42%);
  overflow: hidden;
}

/* ---------- The form ---------- */
.mk-form { display: grid; align-content: start; gap: var(--space-5); padding: var(--space-5); overflow-y: auto; min-height: 0; }
.mk-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); }
.mk-head h2 { font: var(--type-h2); }

.mk-templates { border: 0; padding: 0; margin: 0; min-width: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: var(--space-3); }
.mk-templates legend { margin-block-end: var(--space-2); }
.mk-tpl { display: grid; gap: var(--space-2); align-content: start; cursor: pointer; min-width: 0; }
.mk-tpl input { position: absolute; opacity: 0; pointer-events: none; }
.mk-tpl-art {
  position: relative; display: block; aspect-ratio: 9 / 16; overflow: hidden;
  background: var(--fm-device-bg);
  outline: 1px solid var(--fm-border); outline-offset: 0;
  transition: outline-color var(--motion-fast) var(--ease-out);
}
.mk-tpl-art canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.mk-tpl-name { font: var(--type-small); font-weight: 600; line-height: 18px; }
.mk-tpl:has(input:checked) .mk-tpl-art { outline: 2px solid var(--fm-primary-text); outline-offset: 2px; }
.mk-tpl:has(input:checked) .mk-tpl-name { color: var(--fm-primary-text); }
.mk-tpl:has(input:focus-visible) .mk-tpl-art { outline: 2px solid var(--fm-focus); outline-offset: 4px; }
@media (hover: hover) and (pointer: fine) { .mk-tpl:hover .mk-tpl-art { outline-color: var(--fm-border-strong); } }
.mk-hint { margin-block-start: calc(-1 * var(--space-3)); }

.mk-variant { display: flex; align-items: center; gap: var(--space-4); }
.mk-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-4); }
.mk-fields .field--wide { grid-column: 1 / -1; }
.mk-fields textarea.input { min-height: 96px; padding-block: var(--space-2); line-height: 24px; resize: vertical; }
.mk-fields .field .hint { margin-block-start: calc(-1 * var(--space-1)); }
.mk-image { display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; }
.mk-image .file-pick { flex: 1 1 auto; min-width: 0; }
.mk-image .btn--ghost { height: 44px; }
.mk-field-error { font: var(--type-small); color: var(--fm-offline); }
.mk-actions { position: sticky; inset-block-end: calc(-1 * var(--space-5)); padding-block: var(--space-3) var(--space-5); margin-block-end: calc(-1 * var(--space-5)); background: var(--fm-surface-raised); border-block-start: 1px solid var(--fm-border); }

/* ---------- The screen: a 1080x1920 device on the lit wall ---------- */
.mk-stage {
  position: relative; isolation: isolate; overflow: hidden;
  display: grid; justify-items: center; align-content: center; gap: var(--space-4);
  padding: 64px var(--space-5) var(--space-5);
  background: linear-gradient(to bottom, var(--fm-wall-top), var(--fm-wall-bottom));
  border-inline-start: 1px solid var(--fm-border);
}
.mk-stage::before, .mk-stage::after { content: ''; position: absolute; inset: 0; z-index: -1; pointer-events: none; }
.mk-stage::before { background: var(--fm-wall-light); }
.mk-stage::after {
  background-image: var(--fm-wall-grain);
  opacity: var(--fm-wall-grain-opacity);
  mix-blend-mode: var(--fm-wall-grain-blend);
  -webkit-mask-image: var(--fm-wall-grain-mask);
  mask-image: var(--fm-wall-grain-mask);
}
.mk-rail {
  position: absolute; inset-inline: 0; inset-block-start: 24px; height: 8px;
  background: linear-gradient(to bottom, var(--fm-rail-hi), var(--fm-rail-lo));
  box-shadow: var(--fm-rail-shadow);
}
.mk-device {
  position: relative;
  height: min(700px, calc(100vh - 200px)); max-width: 100%; aspect-ratio: 9 / 16;
  border: 5px solid var(--fm-device-bezel); border-radius: 8px;
  background: var(--fm-device-bg);
  box-shadow: var(--fm-device-shadow);
}
.mk-device::before { content: ''; position: absolute; inset-inline-start: calc(50% - 1.5px); inset-block-start: -38px; width: 3px; height: 32px; background: linear-gradient(to bottom, var(--fm-rod-hi), var(--fm-rod-lo)); }
.mk-device::after { content: ''; position: absolute; inset-inline-start: calc(50% - 28px); inset-block-start: -12px; width: 56px; height: 6px; border-radius: 2px; background: var(--fm-cap); }
.mk-canvas { display: block; width: 100%; height: 100%; border-radius: 3px; }
.mk-caption { font: var(--type-small); color: var(--fm-text-secondary); }
.mk-stage.is-busy .mk-canvas { opacity: .6; }

@media (max-width: 899px) {
  .dialog--maker[open] { grid-template-columns: minmax(0, 1fr); height: calc(100vh - 32px); overflow-y: auto; }
  .mk-stage { order: -1; border-inline-start: 0; border-block-end: 1px solid var(--fm-border); padding-block: 56px var(--space-4); }
  .mk-device { height: auto; width: min(220px, 60vw); }
  .mk-form { overflow: visible; }
  .mk-fields { grid-template-columns: minmax(0, 1fr); }
}
