/* style.css — Responsive UI for Due.im Markdown Live
   Option A: On mobile, give the editor more height (65vh) than the preview (35vh)
*/

/* Reset and base layout */
* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  font-family: Arial, sans-serif;
  background: #f9f9f9;
  color: #24292e;
}

/* Top menu bar */
.top-menu {
  background: #07D065;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0.6em 1em;
  border-bottom: 1px solid rgba(0,0,0,0.08);
  position: sticky;
  top: 0;
  z-index: 10;
  overflow-x: auto;                 /* allow horizontal scroll on narrow screens */
  -webkit-overflow-scrolling: touch;
  margin-bottom: 0.2em;
}

/* Action buttons */
.menu-btn {
  background: #0366d6;
  color: #fff;
  border: none;
  padding: 0.55em 0.9em;            /* larger tap targets */
  border-radius: 6px;
  cursor: pointer;
  font-size: 1em;
  line-height: 1;
  white-space: nowrap;
  flex: 0 0 auto;                   /* prevent button squish */
  transition: background .15s ease, transform .05s ease;
}
.menu-btn:hover { background: #024b93; }
.menu-btn:active { transform: translateY(1px); }

/* Header text at right side on wide screens */
.header-text {
  margin-left: auto;
  color: #fff;
  font-size: 0.95em;
  line-height: 1;
  white-space: nowrap;
}

/* Brand link and logo */
.brand-link {
  display: inline-flex;
  align-items: center;
  margin-left: 0.75em;
  text-decoration: none;
}
.brand-logo {
  height: 24px;
  width: auto;
  display: block;
  image-rendering: -webkit-optimize-contrast;
  image-rendering: crisp-edges;
}

/* Hide native file input but keep accessible */
#fileInput {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0);
  border: 0;
}

/* Main container (editor + preview) */
.container {
  display: flex;
  height: calc(100vh - 56px);       /* approx top bar height */
  min-height: 420px;
}

/* Editor and preview panes */
.editor,
.preview {
  flex: 1 1 50%;
  height: 100%;
  box-sizing: border-box;
  background: #fff;
  overflow: hidden;                  /* inner elements handle scrolling */
}

/* Editor textarea */
textarea {
  width: 100%;
  height: 100%;
  resize: none;
  border: none;                      /* no outer borders */
  outline: none;
  font-size: 1em;
  padding: 1em;
  background: #fff;
  color: #24292e;
  font-family: 'Fira Mono', 'Consolas', 'Menlo', monospace;
}

/* Preview pane content and divider */
.preview {
  padding: 0;                        /* padding applied to #previewPane */
  overflow: auto;
  border-left: 1px solid #ddd;       /* subtle vertical divider */
}

#previewPane {
  padding: 1em;
}

/* Markdown readability tweaks */
#previewPane pre {
  background: #f6f8fa;
  border: 1px solid #e1e4e8;
  border-radius: 6px;
  padding: 12px;
  overflow: auto;
}
#previewPane img { max-width: 100%; height: auto; }
#previewPane code {
  background: #f6f8fa;
  border: 1px solid #e1e4e8;
  border-radius: 4px;
  padding: 2px 4px;
}

/* Focus visibility for accessibility */
.menu-btn:focus-visible,
textarea:focus-visible,
.preview:focus-visible {
  outline: 2px solid #024b93;
  outline-offset: 2px;
}

/* ============== Responsive rules ============== */

/* Stack panes vertically on narrower screens, with taller editor */
@media (max-width: 900px) {
  .container {
    flex-direction: column;
    height: auto;
    min-height: calc(100vh - 56px);
  }

  /* Let flex-basis control heights */
  .editor,
  .preview {
    width: 100%;
    height: auto;
    min-height: 0;
    flex: 0 0 auto;
  }

  /* Give the editor more room than the preview */
  .editor { flex-basis: 45vh; }
  .preview {
    flex-basis: 55vh;
    border-left: none;
    border-top: 1px solid #ddd;     /* horizontal divider when stacked */
  }
}

/* Make top menu wrap nicely on phones */
@media (max-width: 720px) {
  .top-menu {
    flex-wrap: wrap;                 /* allows 2-row menu */
    row-gap: 8px;
  }
  .menu-btn {
    padding: 0.65em 1em;
    font-size: 1rem;
  }
  .header-text {
    order: 3;                        /* move brand to last row */
    width: 100%;
    text-align: center;
    margin-left: 0;
  }
  .brand-link { order: 2; margin-left: auto; }
}

/* Ultra-narrow phones */
@media (max-width: 400px) {
  .top-menu { gap: 6px; }
  .menu-btn { flex: 1 1 auto; }     /* allow buttons to fill row */
  .brand-logo { height: 20px; }
}
