/* Tool-specific styles for Headline Poster Maker. */
.hpm-tool {
  --hpm-accent: #e11d48;
  --hpm-accent-strong: #9f1239;
  --hpm-accent-soft: #fff1f2;
  --hpm-ink: #18181b;
  --hpm-line: #e2e8f0;
  display: grid;
  gap: 14px;
}

.hpm-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background: #f8fafc;
}

.hpm-local-note,
.hpm-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.hpm-local-note {
  flex: 1 1 300px;
  color: #334155;
  font-size: 13px;
  font-weight: 800;
}

.hpm-local-note svg {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  color: var(--hpm-accent);
}

.hpm-local-note span,
.hpm-actions span {
  overflow-wrap: anywhere;
}

.hpm-actions {
  justify-content: flex-end;
}

.hpm-workspace {
  display: grid;
  grid-template-columns: minmax(350px, .88fr) minmax(0, 1.12fr);
  align-items: start;
  gap: 14px;
}

.hpm-panel {
  min-width: 0;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow-sm);
}

.hpm-panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  min-height: 64px;
  padding: 13px 14px;
  border-bottom: 1px solid var(--hpm-line);
}

.hpm-panel-head h2 {
  margin: 0;
  color: var(--hpm-ink);
  font-size: 16px;
  line-height: 1.3;
}

.hpm-panel-head p {
  margin: 4px 0 0;
  color: var(--color-muted);
  font-size: 13px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.hpm-panel-head > svg {
  flex: 0 0 auto;
  width: 19px;
  height: 19px;
  color: var(--hpm-accent);
}

.hpm-editor-body {
  display: grid;
  gap: 15px;
  padding: 14px;
}

.hpm-field,
.hpm-range-field {
  display: grid;
  gap: 7px;
  min-width: 0;
  color: #334155;
  font-size: 13px;
  font-weight: 800;
}

.hpm-field-label,
.hpm-section-label,
.hpm-range-field > span {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 6px 10px;
}

.hpm-field small,
.hpm-section-label small,
.hpm-option-grid small,
.hpm-preview-foot {
  color: var(--color-muted);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.hpm-text-field textarea {
  box-sizing: border-box;
  width: 100%;
  min-height: 180px;
  resize: vertical;
  padding: 14px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: #fff;
  color: #111827;
  font: 700 15px/1.65 "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  letter-spacing: 0;
  transition: border-color .18s var(--ease), box-shadow .18s var(--ease);
}

.hpm-text-field textarea:focus,
.hpm-field select:focus,
.hpm-field input:focus,
.hpm-markup-toolbar button:focus,
.hpm-preset-grid button:focus {
  border-color: var(--hpm-accent);
  box-shadow: 0 0 0 3px rgba(225, 29, 72, .14);
  outline: 0;
}

.hpm-markup-block,
.hpm-presets-block {
  display: grid;
  gap: 9px;
}

.hpm-section-label strong {
  color: #334155;
  font-size: 13px;
}

.hpm-markup-toolbar {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.hpm-markup-toolbar button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 0;
  min-height: 38px;
  padding: 7px 8px;
  border: 1px solid #dbe3ec;
  border-radius: 6px;
  background: #fff;
  color: #334155;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

.hpm-markup-toolbar button:hover {
  border-color: var(--hpm-accent);
  background: var(--hpm-accent-soft);
  color: var(--hpm-accent-strong);
}

.hpm-markup-toolbar svg {
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
}

.hpm-markup-toolbar span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.hpm-preset-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.hpm-preset-grid button {
  display: grid;
  grid-template-rows: 26px auto;
  gap: 5px;
  align-items: center;
  justify-items: stretch;
  min-width: 0;
  min-height: 58px;
  padding: 5px;
  border: 1px solid #dbe3ec;
  border-radius: 6px;
  background: #fff;
  color: #475569;
  font-size: 11px;
  font-weight: 800;
  line-height: 1.15;
  cursor: pointer;
}

.hpm-preset-grid button[aria-pressed="true"] {
  border-color: var(--hpm-accent);
  box-shadow: 0 0 0 2px rgba(225, 29, 72, .13);
  color: var(--hpm-accent-strong);
}

.hpm-preset-grid button > span:last-child {
  overflow-wrap: anywhere;
}

.hpm-swatch {
  display: block;
  width: 100%;
  height: 26px;
  border: 1px solid rgba(15, 23, 42, .14);
  border-radius: 3px;
}

.hpm-preset-grid [data-hpm-preset="editorial"] .hpm-swatch {
  background: linear-gradient(90deg, #f7e654 0 66%, #ef233c 66% 82%, #171717 82%);
}

.hpm-preset-grid [data-hpm-preset="paper"] .hpm-swatch {
  background: linear-gradient(90deg, #fff7d6 0 68%, #ff6b35 68% 84%, #183153 84%);
}

.hpm-preset-grid [data-hpm-preset="noir"] .hpm-swatch {
  background: linear-gradient(90deg, #111 0 68%, #fff 68% 84%, #f43f5e 84%);
}

.hpm-preset-grid [data-hpm-preset="cobalt"] .hpm-swatch {
  background: linear-gradient(90deg, #1640d6 0 68%, #ffdd00 68% 84%, #fff 84%);
}

.hpm-preset-grid [data-hpm-preset="mint"] .hpm-swatch {
  background: linear-gradient(90deg, #c8f5df 0 68%, #006d5b 68% 84%, #18201d 84%);
}

.hpm-settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.hpm-field select,
.hpm-field input[type="text"] {
  box-sizing: border-box;
  width: 100%;
  min-height: 40px;
  padding: 8px 10px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: #fff;
  color: #1e293b;
  font-size: 13px;
  letter-spacing: 0;
}

.hpm-color-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.hpm-color-field {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 38px;
  align-items: center;
  gap: 6px;
  min-width: 0;
  min-height: 46px;
  padding: 7px 8px;
  border: 1px solid #dbe3ec;
  border-radius: 6px;
  color: #475569;
  font-size: 12px;
  font-weight: 800;
}

.hpm-color-field span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.hpm-color-field input[type="color"] {
  box-sizing: border-box;
  width: 38px;
  height: 32px;
  padding: 2px;
  border: 1px solid #cbd5e1;
  border-radius: 5px;
  background: #fff;
  cursor: pointer;
}

.hpm-range-grid {
  display: grid;
  gap: 10px;
}

.hpm-range-field output {
  color: var(--hpm-accent-strong);
  font-variant-numeric: tabular-nums;
}

.hpm-range-field input[type="range"] {
  width: 100%;
  accent-color: var(--hpm-accent);
}

.hpm-option-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.hpm-option-grid > label {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  align-items: start;
  gap: 8px;
  min-width: 0;
  padding: 10px;
  border: 1px solid #dbe3ec;
  border-radius: 6px;
  background: #f8fafc;
  cursor: pointer;
}

.hpm-option-grid input {
  width: 17px;
  height: 17px;
  margin: 1px 0 0;
  accent-color: var(--hpm-accent);
}

.hpm-option-grid span {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.hpm-option-grid strong {
  color: #334155;
  font-size: 13px;
}

.hpm-preview-panel {
  position: sticky;
  top: 12px;
}

.hpm-preview-head {
  align-items: center;
}

.hpm-preview-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 7px;
  min-width: 0;
}

.hpm-preview-action {
  min-height: 34px;
  padding: 6px 9px;
  font-size: 12px;
}

.hpm-preview-action svg {
  width: 15px;
  height: 15px;
}

.hpm-fullscreen-exit-icon,
.hpm-fullscreen-exit-label,
.hpm-preview-action[aria-pressed="true"] .hpm-fullscreen-enter-icon,
.hpm-preview-action[aria-pressed="true"] .hpm-fullscreen-enter-label {
  display: none;
}

.hpm-preview-action[aria-pressed="true"] .hpm-fullscreen-exit-icon,
.hpm-preview-action[aria-pressed="true"] .hpm-fullscreen-exit-label {
  display: inline-flex;
}

.hpm-dimension,
.hpm-local-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
  padding: 5px 8px;
  border: 1px solid #dbe3ec;
  border-radius: 999px;
  background: #f8fafc;
  color: #475569;
  font-size: 11px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.hpm-stage {
  display: grid;
  place-items: center;
  min-height: 520px;
  max-height: 760px;
  padding: 18px;
  overflow: hidden;
  background-color: #e8edf3;
  background-image: linear-gradient(45deg, #d9e0e8 25%, transparent 25%), linear-gradient(-45deg, #d9e0e8 25%, transparent 25%), linear-gradient(45deg, transparent 75%, #d9e0e8 75%), linear-gradient(-45deg, transparent 75%, #d9e0e8 75%);
  background-position: 0 0, 0 10px, 10px -10px, -10px 0;
  background-size: 20px 20px;
}

.hpm-stage canvas {
  display: block;
  width: auto;
  max-width: 100%;
  height: auto;
  max-height: 720px;
  border: 1px solid rgba(15, 23, 42, .16);
  background: #fff;
  box-shadow: 0 16px 36px rgba(15, 23, 42, .18);
}

.hpm-preview-panel.is-fullscreen-active,
.hpm-preview-panel.is-fullscreen-fallback {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  width: 100vw;
  height: 100vh;
  max-width: none;
  max-height: none;
  border: 0;
  border-radius: 0;
  background: #fff;
  box-shadow: none;
}

.hpm-preview-panel.is-fullscreen-active .hpm-stage,
.hpm-preview-panel.is-fullscreen-fallback .hpm-stage {
  min-height: 0;
  max-height: none;
  height: auto;
}

.hpm-preview-panel.is-fullscreen-active .hpm-stage canvas,
.hpm-preview-panel.is-fullscreen-fallback .hpm-stage canvas {
  max-height: 100%;
}

body.hpm-fullscreen-open {
  overflow: hidden;
}

.hpm-print-image,
.hpm-print-page-style {
  display: none;
}

.hpm-preview-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 50px;
  padding: 10px 14px;
  border-top: 1px solid var(--hpm-line);
}

.hpm-local-chip {
  color: #166534;
  background: #f0fdf4;
  border-color: #bbf7d0;
}

.hpm-local-chip svg {
  width: 14px;
  height: 14px;
}

.hpm-status {
  margin: 0;
}

@media (max-width: 980px) {
  .hpm-workspace {
    grid-template-columns: minmax(0, 1fr);
  }

  .hpm-preview-panel {
    position: static;
  }

  .hpm-stage {
    min-height: 460px;
  }
}

@media (max-width: 680px) {
  .hpm-toolbar,
  .hpm-actions,
  .hpm-actions button {
    width: 100%;
  }

  .hpm-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .hpm-actions button {
    justify-content: center;
  }

  .hpm-preview-head {
    align-items: flex-start;
  }

  .hpm-preview-actions {
    justify-content: flex-start;
    width: 100%;
  }

  .hpm-markup-toolbar {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .hpm-markup-toolbar button:last-child {
    grid-column: 1 / -1;
  }

  .hpm-preset-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .hpm-settings-grid,
  .hpm-option-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .hpm-color-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .hpm-color-field {
    grid-template-columns: minmax(0, 1fr) 52px;
  }

  .hpm-color-field input[type="color"] {
    width: 52px;
  }

  .hpm-stage {
    min-height: 390px;
    padding: 10px;
  }
}

@media (max-width: 420px) {
  .hpm-editor-body,
  .hpm-panel-head,
  .hpm-preview-foot {
    padding-left: 10px;
    padding-right: 10px;
  }

  .hpm-preset-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .hpm-stage {
    min-height: 330px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .hpm-tool * {
    scroll-behavior: auto !important;
    transition: none !important;
  }
}

@media print {
  html,
  body {
    width: 100%;
    height: 100%;
    margin: 0 !important;
    padding: 0 !important;
    background: #fff !important;
  }

  body > *:not(.hpm-print-image) {
    display: none !important;
  }

  .hpm-print-image {
    position: fixed;
    inset: 0;
    display: block !important;
    width: 100vw;
    height: 100vh;
    margin: 0;
    object-fit: contain;
    background: #fff;
  }
}
