/* =====================================================
   blog.css — Blog-specific styles only.
   Body resets, fonts, and .navbar come from ../style.css.
   ===================================================== */

/* ------ Layout ------ */
.blog-main {
  max-width: 900px;
  margin: 0 auto;
  padding: 2rem 8% 4rem;
}

.live-preview {
  border: 1px solid #ccc;
  padding: 10px;
  margin-top: 10px;
}

.editor {
  border: 1px solid royalblue;
  min-height: 300px;
  padding: 10px;
  position: relative;
  cursor: text;
  z-index: 1;
}

.editor-toolbar select {
  background: rgba(18, 18, 18, 0.9);
  border: 1px solid rgba(0, 94, 255, 0.4);
  border-radius: 4px;
  color: var(--white);
  font-family: var(--robot-font);
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  padding: 0.35rem 0.6rem;
  cursor: pointer;
  outline: none;
}

.editor-toolbar {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.4rem 0.6rem;
  background: rgba(18, 18, 18, 0.95);
  border: 1px solid rgba(0, 94, 255, 0.25);
  border-radius: 6px 6px 0 0;
  border-bottom: none;
  flex-wrap: wrap;
}

.toolbar-group {
  display: flex;
  align-items: center;
  gap: 0.15rem;
}

.toolbar-divider {
  width: 1px;
  height: 20px;
  background: rgba(255, 255, 255, 0.12);
  margin: 0 0.35rem;
}

.toolbar-btn {
  background: transparent;
  border: 1px solid transparent;
  border-radius: 4px;
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.85rem;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition:
    background 0.15s,
    border-color 0.15s,
    color 0.15s;
  padding: 0;
}

.toolbar-btn:hover {
  background: rgba(0, 94, 255, 0.12);
  border-color: rgba(0, 94, 255, 0.3);
  color: var(--white);
}

.toolbar-btn.active {
  background: rgba(0, 94, 255, 0.2);
  border-color: var(--neon-blue);
  color: var(--neon-blue);
}

.editor-toolbar select {
  background: rgba(18, 18, 18, 0.9);
  border: 1px solid rgba(0, 94, 255, 0.3);
  border-radius: 4px;
  color: rgba(255, 255, 255, 0.7);
  font-family: var(--robot-font);
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  padding: 0.3rem 0.5rem;
  cursor: pointer;
  outline: none;
  height: 28px;
  transition: border-color 0.15s;
}

.editor-toolbar select:focus,
.editor-toolbar select:hover {
  border-color: var(--neon-blue);
  color: var(--white);
}

.image-delete-btn {
  display: none;
  position: absolute;
  top: -10px;
  right: -10px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: none;
  background: #e24b4a;
  color: white;
  font-size: 11px;
  line-height: 1;
  cursor: pointer;
  z-index: 10;
}

.image-wrapper.selected .image-delete-btn {
  display: flex;
  align-items: center;
  justify-content: center;
}

.editor-toolbar select option {
  background: #111;
  color: var(--white);
}

/* Connect toolbar to editor visually */
#editor {
  border-radius: 0 0 6px 6px;
}

.editor-toolbar select:focus {
  border-color: var(--neon-blue);
}

.editor-toolbar select option {
  background: var(--dark-grey);
}

#editor {
  position: relative;
  width: 100%;
  min-height: 400px;
  border: 1px solid #0c27a0;
  padding: 10px;
  box-sizing: border-box;
  z-index: 1;
  background: repeating-linear-gradient(
    25deg,
    transparent,
    transparent 20px,
    rgba(15, 25, 56, 0.3) 21px,
    rgba(15, 25, 56, 0.3) 25px
  );
}

#image-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  /* let clicks fall through by default */
  z-index: 2;
  /* above the editor text */
}

.image-wrapper {
  position: absolute;
  pointer-events: auto;
  /* allow dragging/resizing */
}

.editor::after {
  content: "";
  display: block;
  height: 200px;
  /* space for dragged images */
}

.image-wrapper {
  position: absolute;
  user-select: none;
  z-index: 10;
  transform: translate(0, 0);
  /* forces its own layer */
  pointer-events: auto;
}

.image-wrapper img {
  display: block;
  pointer-events: none;
}

.resize-handle {
  pointer-events: all;
  cursor: se-resize;
}

.image-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  /* 🔥 allows typing */
  z-index: 5;
}

.image-wrapper.selected {
  pointer-events: all;
  border: 4px dashed #007bff;
  /* only interact when selected */
  cursor: move;
}

.post-image {
  display: block;
  max-width: none;
  /* important for resizing */
}

.resize-handle {
  width: 12px;
  height: 12px;
  background: #007bff;
  position: absolute;
  bottom: 0;
  right: 0;
  cursor: se-resize;
  border-radius: 0px 50% 50% 50%;
}

.image-wrapper.selected .resize-handle {
  display: block;
}

.editor img {
  pointer-events: none;
  /* prevents weird selection */
}

.editor-toolbar {
  margin-bottom: 10px;
}

#container {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  animation: slideUp 0.4s ease-out;
}

/* ------ Search bar ------ */
#blog-search-wrapper {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 1.75rem;
}

.blog-search-inputs {
  display: flex;
  gap: 0.75rem;
}

#blog-search,
#blog-search-author {
  flex: 1;
  background: rgba(18, 18, 18, 0.9);
  border: 1px solid rgba(0, 94, 255, 0.4);
  border-radius: 4px;
  color: var(--white);
  font-family: var(--robot-font);
  font-size: 0.75rem;
  letter-spacing: 0.1em;
  padding: 0.75rem 1rem;
  outline: none;
  transition:
    border-color 0.2s,
    box-shadow 0.2s;
}

#blog-search-author {
  flex: 0 0 220px;
}

#blog-search::placeholder,
#blog-search-author::placeholder {
  color: rgba(255, 255, 255, 0.25);
  letter-spacing: 0.08em;
}

#blog-search:focus,
#blog-search-author:focus {
  border-color: var(--neon-blue);
  box-shadow: 0 0 0 2px rgba(0, 94, 255, 0.15);
}

/* Genre pills */
.blog-genre-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.genre-pill {
  background: transparent;
  border: 1px solid #444;
  border-radius: 4px;
  color: rgba(255, 255, 255, 0.5);
  font-family: var(--robot-font);
  font-size: 0.65rem;
  letter-spacing: 0.08em;
  padding: 0.35rem 0.75rem;
  cursor: pointer;
  transition:
    border-color 0.2s,
    color 0.2s,
    background 0.2s;
  white-space: nowrap;
}

.genre-pill:hover {
  border-color: var(--neon-blue);
  color: var(--white);
}

.genre-pill.active {
  border-color: var(--neon-blue);
  color: var(--neon-blue);
  background: rgba(0, 94, 255, 0.1);
  text-shadow: 0 0 8px var(--neon-blue);
}

#blog-search-count {
  font-family: var(--robot-font);
  font-size: 0.65rem;
  letter-spacing: 0.08em;
  color: rgba(255, 255, 255, 0.3);
}

.post-card {
  background: rgba(18, 18, 18, 0.8);
  border: 1px solid #333;
  border-radius: 8px;
  padding: 1.5rem 1.75rem;
  transition: border-color 0.2s;
}

.post-card:hover {
  border-color: var(--neon-blue);
}

.post-card .post-title {
  display: block;
  font-family: var(--robot-font);
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--white);
  text-decoration: none;
  margin-bottom: 0.4rem;
  transition: color 0.2s;
}

.post-card .post-title:hover {
  color: var(--neon-blue);
  text-shadow: 0 0 8px var(--neon-blue);
}

.post-card .author-date {
  display: flex;
  gap: 1.5rem;
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.4);
  margin-bottom: 0.5rem;
  letter-spacing: 0.04em;
}

.post-card .author-date p {
  margin: 0;
}

.post-card .post-genre {
  font-family: var(--robot-font);
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  color: var(--neon-blue);
  margin-bottom: 0.75rem;
}

.post-card .genre-icon {
  margin-right: 4px;
}

.post-card .post-content {
  color: rgba(255, 255, 255, 0.75);
  font-size: 1rem;
  line-height: 1.7;
  margin: 0;
  white-space: pre-wrap;
}

.post-card .post-image {
  display: block;
  max-width: 100%;
  border-radius: 6px;
  margin-top: 1rem;
  border: 1px solid #333;
}

/* ------ Upload form (class: upload-container) ------ */
.upload-container {
  background: rgba(18, 18, 18, 0.8);
  border: 1px solid #333;
  border-radius: 8px;
  padding: 2rem 1.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  animation: slideUp 0.4s ease-out;
}
#user {
  display: grid;
  font-family: var(--robot-font);
  color: rgb(173, 154, 154);
  font-size: 0.6rem;
}

#font-size-select {
  font-size: 0.7em;
  letter-spacing: 0;
  height: auto;
}

.upload-container input[type="text"],
.upload-container textarea,
.upload-container select {
  width: 100%;
  box-sizing: border-box;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(0, 94, 255, 0.3);
  border-radius: 4px;
  color: var(--white);
  font-family: "Rajdhani", sans-serif;
  font-size: 1rem;
  font-weight: 500;
  padding: 0.65rem 0.9rem;
  outline: none;
  transition: border-color 0.2s;
}

.upload-container input[type="text"]:focus,
.upload-container textarea:focus,
.upload-container select:focus {
  border-color: var(--neon-blue);
  box-shadow: 0 0 0 2px rgba(0, 94, 255, 0.15);
}

.upload-container select {
  cursor: pointer;
  appearance: none;
}

.upload-container select option {
  background: var(--dark-grey);
  color: var(--white);
}

.upload-container textarea {
  min-height: 140px;
  resize: vertical;
  line-height: 1.6;
}

.upload-container button {
  font-family: var(--robot-font);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: var(--white);
  border-radius: 4px;
  padding: 0.6rem 1.4rem;
  cursor: pointer;
  align-self: flex-start;
  transition:
    background 0.2s,
    border-color 0.2s;
}

.upload-container button:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.6);
}

.upload-container button[type="submit"] {
  border-color: var(--neon-blue);
  color: var(--neon-blue);
  margin-top: 0.5rem;
}

.upload-container button[type="submit"]:hover {
  background: rgba(0, 94, 255, 0.15);
  text-shadow: 0 0 8px var(--neon-blue);
}

/* Image input rows */
.image-input-row {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  padding: 0.75rem;
  background: rgba(0, 94, 255, 0.04);
  border: 1px solid rgba(0, 94, 255, 0.2);
  border-radius: 4px;
}

.image-input-label {
  font-family: var(--robot-font);
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  color: var(--neon-blue);
}

.image-input-controls {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.file-input-btn {
  font-family: var(--robot-font);
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  background: rgba(0, 94, 255, 0.15);
  border: 1px solid var(--neon-blue);
  color: var(--neon-blue);
  border-radius: 4px;
  padding: 0.4rem 0.9rem;
  cursor: pointer;
  transition: background 0.2s;
  white-space: nowrap;
}

.file-input-btn:hover {
  background: rgba(0, 94, 255, 0.3);
}

.file-input-btn input[type="file"] {
  display: none;
}

.file-name-display {
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.4);
  font-style: italic;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.remove-image-btn {
  background: transparent !important;
  border: 1px solid rgba(220, 60, 60, 0.4) !important;
  color: rgba(220, 60, 60, 0.7) !important;
  border-radius: 4px !important;
  padding: 0.3rem 0.6rem !important;
  cursor: pointer;
  font-size: 0.75rem !important;
  align-self: auto;
  transition:
    background 0.15s,
    color 0.15s !important;
}

.remove-image-btn:hover {
  background: rgba(220, 60, 60, 0.15) !important;
  color: #ff6b6b !important;
}

.image-preview {
  max-width: 100%;
  max-height: 200px;
  border-radius: 4px;
  border: 1px solid #444;
  margin-top: 0.25rem;
  object-fit: contain;
}

/* ------ Login form (id: login-form, injected into #container) ------ */
#login-form {
  max-width: 420px;
  margin: 4rem auto;
  background: rgba(18, 18, 18, 0.8);
  border: 1px solid #333;
  border-radius: 8px;
  padding: 2.5rem 2rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  animation: slideUp 0.4s ease-out;
}

#login-form input {
  width: 100%;
  box-sizing: border-box;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(0, 94, 255, 0.3);
  border-radius: 4px;
  color: var(--white);
  font-family: "Rajdhani", sans-serif;
  font-size: 1rem;
  font-weight: 500;
  padding: 0.65rem 0.9rem;
  outline: none;
  transition: border-color 0.2s;
}

#login-form input:focus {
  border-color: var(--neon-blue);
  box-shadow: 0 0 0 2px rgba(0, 94, 255, 0.15);
}

#login-form button[type="submit"] {
  font-family: var(--robot-font);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: transparent;
  border: 1px solid var(--neon-blue);
  color: var(--neon-blue);
  border-radius: 4px;
  padding: 0.65rem 1.4rem;
  cursor: pointer;
  margin-top: 0.5rem;
  transition: background 0.2s;
}

#login-form button[type="submit"]:hover {
  background: rgba(0, 94, 255, 0.15);
  text-shadow: 0 0 8px var(--neon-blue);
}

/* ------ Alert popup (main.js sets display:block/none directly) ------ */
#alert {
  display: none;
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  min-width: 280px;
  max-width: 90vw;
}

.popup {
  background: rgba(5, 5, 5, 0.97);
  border: 1px solid rgba(0, 94, 255, 0.5);
  border-radius: 6px;
  padding: 0.9rem 2.5rem 0.9rem 1.25rem;
  position: relative;
  box-shadow: 0 4px 24px rgba(0, 94, 255, 0.15);
}

.popup-message {
  font-family: "Rajdhani", sans-serif;
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--white);
  margin: 0;
}

.closebtn {
  position: absolute;
  top: 0.5rem;
  right: 0.75rem;
  font-size: 1.2rem;
  line-height: 1;
  color: rgba(255, 255, 255, 0.45);
  cursor: pointer;
  transition: color 0.15s;
  user-select: none;
}

.closebtn:hover {
  color: var(--white);
}

/* ------ Sign In / Sign Out button in navbar ------ */
/* Resets the <button> so it matches .nav-links a exactly */
#signout {
  background: transparent;
  border: none;
  padding: 0;
  cursor: pointer;
  font-family: var(--robot-font);
  font-size: 0.8rem;
  color: var(--white);
  opacity: 0.6;
  transition: 0.3s;
  letter-spacing: inherit;
  text-decoration: none;
  text-transform: uppercase;
}

#signout:hover {
  opacity: 1;
}

#signout.active {
  opacity: 1;
  color: var(--neon-blue);
  text-shadow: 0 0 8px var(--neon-blue);
}

/* ------ Responsive ------ */
@media screen and (max-width: 768px) {
  .blog-main {
    padding: 1.25rem 4% 3rem;
  }

  .upload-container,
  #login-form {
    padding: 1.25rem 1rem;
  }

  .image-input-controls {
    flex-direction: column;
    align-items: flex-start;
  }

  .blog-search-inputs {
    flex-direction: column;
  }

  #blog-search-author {
    flex: 1;
  }

  /* ---- Image layer mobile fix ---- */
  .post-content-wrapper {
    display: flex;
    flex-direction: column;
  }

  .post-content-wrapper .image-layer {
    position: relative !important; /* flow in document, but still a positioning context */
    width: 100% !important;
    height: var(--mobile-layer-height, 300px); /* fallback, JS will set this */
    min-height: unset !important;
  }

  /* wrappers stay absolute so they can overlap each other */
  .post-content-wrapper .image-layer .image-wrapper {
    position: absolute !important;
    width: 80% !important; /* sensible mobile width */
  }

  .post-content-wrapper .image-layer .image-wrapper img {
    width: 100% !important;
    height: auto !important;
  }

  .post-content-wrapper .image-layer .image-wrapper iframe {
    width: 100% !important;
    aspect-ratio: 16/9 !important;
  }
}
