/*! HTML5 Boilerplate v9.0.1 | MIT License | https://html5boilerplate.com/ */

/* main.css 3.0.0 | MIT License | https://github.com/h5bp/main.css#readme */
/*
 * What follows is the result of much research on cross-browser styling.
 * Credit left inline and big thanks to Nicolas Gallagher, Jonathan Neal,
 * Kroc Camen, and the H5BP dev community and team.
 */

/* ==========================================================================
   Base styles: opinionated defaults
   ========================================================================== */

html {
  color: #222;
  font-size: 1em;
  line-height: 1.4;
  box-sizing: border-box;
}

*, *:before, *:after {
  box-sizing: inherit;
}

body {
  margin: 0;
  padding: 0;
  font-family: 'Open Sans', sans-serif;
  background-color: #f0f0f0;
}

/*
 * Remove text-shadow in selection highlight:
 * https://twitter.com/miketaylr/status/12228805301
 *
 * Customize the background color to match your design.
 */

::-moz-selection {
  background: #b3d4fc;
  text-shadow: none;
}

::selection {
  background: #b3d4fc;
  text-shadow: none;
}

/* ==========================================================================
   App layout styles
   ========================================================================== */

.app-container {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  padding: 20px;
}

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

header h1 {
  margin: 0;
  color: #333;
}

.controls {
  display: flex;
  gap: 10px;
}

button {
  padding: 8px 16px;
  background-color: #2c3e50;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  transition: background-color 0.3s;
}

button:hover {
  background-color: #1a2530;
}

main {
  flex: 1;
  display: flex;
  justify-content: center;
}

footer {
  margin-top: 20px;
  text-align: center;
  color: #666;
}

/* ==========================================================================
   A4 Page Editor styles
   ========================================================================== */

.editor-container {
  display: flex;
  justify-content: center;
  padding: 20px;
  overflow: visible; /* Changed from 'auto' to 'visible' to show elements outside the container */
  position: relative; /* Add position relative for absolute positioning context */
}

.a4-page {
  width: 210mm;  /* A4 width */
  height: 297mm; /* A4 height */
  padding: 20mm;
  background-color: white;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
  position: relative;
  overflow: hidden;
  margin: 0 auto;
}

/* Image container styles */
#image-container {
  width: 100%;
  height: 80mm;
  border: 2px dashed #ccc;
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
  overflow: hidden;
  transition: border 0.3s;
}

#image-container.active {
  border: 2px dashed #3498db;
}

#image-container img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
}

.dropzone-prompt {
  color: #999;
  text-align: center;
  pointer-events: none;
}

/* Title styles */
#title-container {
  margin-top: calc(1.5 * 24pt); /* 1.5 times the title font size */
  margin-bottom: 10mm;
}

#page-title {
  font-family: 'Open Sans', sans-serif;
  font-size: 24pt;
  font-weight: bold;
  width: 100%;
  min-height: 1.2em;
  line-height: 1.2;
  color: #000;
  margin-bottom: 5mm;
}

/* Two-column layout for content */
#content-container {
  display: flex;
  gap: 5mm;
  width: 100%;
  height: 142mm; /* Remaining space for content */
}

.column {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Ingress text styles */
.ingress {
  font-family: 'Open Sans', sans-serif;
  font-size: 12pt;
  line-height: 1.4;
  margin-bottom: 5mm;
}

/* Body text styles */
.body-text {
  font-family: 'Merriweather', serif;
  font-size: 10pt;
  line-height: 1.5;
  flex-grow: 1;
  overflow-y: auto;
}

/* Editable content areas */
.editable {
  outline: none;
  min-height: 20px;
}

.editable:empty:before {
  content: attr(data-placeholder);
  color: #888;
  pointer-events: none;
}

.editable:focus {
  box-shadow: 0 0 0 1px rgba(52, 152, 219, 0.3);
}

/* Image controls positioning */
.image-controls {
  position: absolute;
  left: calc(50% + 110mm); /* Position relative to center plus half A4 width plus a bit more space */
  top: 120px; /* Position at approximately the same height as the image area */
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 80px;
  z-index: 100; /* Ensure controls appear above other elements */
}

.image-controls button {
  padding: 6px 8px;
  font-size: 12px;
  background-color: #f0f0f0;
  color: #333;
  border: 1px solid #ccc;
  border-radius: 3px;
  cursor: pointer;
  white-space: nowrap;
}

.image-controls button:hover {
  background-color: #e0e0e0;
}

/* Responsive adjustments */
@media (max-width: 230mm) {
  .a4-page {
    transform: scale(0.9);
    transform-origin: top center;
  }
}

@media (max-width: 210mm) {
  .a4-page {
    transform: scale(0.8);
    transform-origin: top center;
  }
}

@media (max-width: 190mm) {
  .a4-page {
    transform: scale(0.7);
    transform-origin: top center;
  }
}

@media print {
  .app-container > *:not(.editor-container) {
    display: none;
  }

  .editor-container {
    padding: 0;
  }

  .a4-page {
    box-shadow: none;
    transform: none !important;
  }
}
