/* Reset */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* the hidden attribute always hides, even on elements given a display above or below */
[hidden] {
  display: none !important;
}

/* Base */
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background-color: #f9f9f9;
  color: #111;
  line-height: 1.6;
}

/* Fixed-width centered column, wider than the log's to fit a grid of posts */
.container {
  width: 720px;
  margin: 40px auto;
  padding: 0 16px;
}

/* Header */
.header {
  margin-bottom: 24px;
}

.header h1 {
  font-size: 28px;
  font-weight: 600;
  margin-bottom: 4px;
}

.tagline {
  font-size: 14px;
  color: #666;
}

/* Nav */
.nav {
  display: flex;
  gap: 16px;
  margin-bottom: 32px;
}

.nav a {
  text-decoration: none;
  font-size: 14px;
  color: #333;
}

.nav a:hover {
  text-decoration: underline;
}

/* Post grid */
.post-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

/* a card is one link: an optional cover image, then title, summary, date */
.post-card {
  display: flex;
  flex-direction: column;
  overflow: hidden;

  border: 1px solid #eee;
  border-radius: 6px;
  background: #fff;

  color: inherit;
  text-decoration: none;
}

.post-card:hover {
  border-color: #ccc;
}

/* every cover is cropped to the same shape, so cards in a row line up */
.post-card-image {
  display: block;
  width: 100%;
  aspect-ratio: 3 / 2;
  object-fit: cover;

  background: #f0f0f0;
  border-bottom: 1px solid #eee;
}

/* fills the rest of the card, so the date sits at the bottom with or without an image */
.post-card-body {
  display: flex;
  flex-direction: column;
  flex: 1;
  gap: 6px;

  padding: 14px;
}

.post-card-title {
  font-size: 15px;
  font-weight: 600;
  line-height: 1.35;
}

.post-card:hover .post-card-title {
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* long summaries are cut at four lines so rows stay even */
.post-card-summary {
  font-size: 13px;
  color: #555;

  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.post-card-date {
  margin-top: auto;
  font-size: 12px;
  color: #888;
}

.post-grid-message {
  font-size: 14px;
  color: #666;
}

/* Single post page */
.post {
  max-width: 640px;
}

.post-title {
  font-size: 26px;
  font-weight: 600;
  line-height: 1.3;
  margin-bottom: 6px;
}

.post-date {
  font-size: 13px;
  color: #666;
  margin-bottom: 24px;
}

.post-content {
  font-size: 15px;
}

.post-back {
  display: inline-block;
  margin-top: 40px;

  font-size: 14px;
  color: #555;
  text-decoration: none;
}

.post-back:hover {
  color: #000;
  text-decoration: underline;
}

/* Markdown post content */
.post-content {
  font-size: 14px;
  overflow-wrap: break-word;
}

.post-content p {
  margin-bottom: 10px;
}

.post-content > :first-child {
  margin-top: 0;
}

.post-content > :last-child {
  margin-bottom: 0;
}

/* Markdown headings */
.post-content h1,
.post-content h2,
.post-content h3,
.post-content h4,
.post-content h5,
.post-content h6 {
  line-height: 1.3;
  font-weight: 600;
  margin-top: 20px;
  margin-bottom: 8px;
}

.post-content h1 {
  font-size: 22px;
}

.post-content h2 {
  font-size: 19px;
}

.post-content h3 {
  font-size: 16px;
}

.post-content h4,
.post-content h5,
.post-content h6 {
  font-size: 14px;
}

/* Markdown emphasis */
.post-content strong {
  font-weight: 600;
}

.post-content em {
  font-style: italic;
}

/* Markdown lists */
.post-content ul,
.post-content ol {
  margin: 0 0 10px 22px;
  padding: 0;
}

.post-content ul {
  list-style-type: disc;
}

.post-content ol {
  list-style-type: decimal;
}

.post-content ul ul,
.post-content ol ul {
  list-style-type: circle;
}

.post-content ul ul,
.post-content ul ol,
.post-content ol ul,
.post-content ol ol {
  margin-top: 4px;
  margin-bottom: 4px;
}

.post-content li {
  margin-bottom: 4px;
}

.post-content li:last-child {
  margin-bottom: 0;
}

.post-content li > p {
  margin-bottom: 4px;
}

/* Markdown links */
.post-content a {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.post-content a:hover {
  color: #555;
}

/* Markdown images */
.post-content img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 14px 0;
}

/* set by the editor: <img class="align-center"> */
.post-content img.align-center {
  margin-left: auto;
  margin-right: auto;
}

.post-content img.align-right {
  margin-left: auto;
}

/* Optional Markdown elements supported by most parsers */
.post-content blockquote {
  margin: 14px 0;
  padding-left: 14px;
  border-left: 2px solid #ddd;
  color: #555;
}

.post-content code {
  padding: 1px 4px;

  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas,
    "Liberation Mono", monospace;
  font-size: 0.9em;

  background-color: #eee;
  border-radius: 3px;
}

.post-content pre {
  max-width: 100%;
  margin: 14px 0;
  padding: 12px;

  overflow-x: auto;

  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas,
    "Liberation Mono", monospace;
  font-size: 13px;
  line-height: 1.5;

  background-color: #eee;
  border-radius: 4px;
}

.post-content pre code {
  padding: 0;
  font-size: inherit;
  background: none;
  border-radius: 0;
}

.post-content hr {
  margin: 20px 0;
  border: none;
  border-top: 1px solid #ddd;
}

/* Footer */
.footer {
  margin-top: 40px;
  font-size: 12px;
  color: #888;
}

/* Load more */
#load-more-btn {
  display: block;
  margin: 32px auto 0;

  background: none;
  border: none;

  font-size: 14px;
  color: #555;

  cursor: pointer;
  padding: 0;
}

#load-more-btn:hover {
  text-decoration: underline;
  color: #000;
}

/* Messages */
.form-message {
  min-height: 20px;
  margin-top: 8px;

  font-size: 13px;
  color: #666;
}

.form-message.error {
  color: #a00;
}

.form-message.success {
  color: #060;
}


/* Forms */
.login-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.login-form label {
  display: block;
  font-size: 13px;
  color: #555;
}

.login-form input {
  width: 100%;
  padding: 8px 10px;

  font: inherit;
  font-size: 14px;

  border: 1px solid #ddd;
  border-radius: 4px;

  background: #fff;
  color: #111;
}

.login-form input:focus {
  outline: none;
  border-color: #999;
}

.login-form button {
  margin-top: 8px;

  background: #111;
  color: #fff;

  border: none;
  border-radius: 4px;

  padding: 8px 10px;

  font: inherit;
  font-size: 14px;

  cursor: pointer;
}

.login-form button:hover {
  background: #333;
}

.login-form button:disabled {
  opacity: 0.6;
  cursor: default;
}

/* Entry forms */
.entry-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.entry-form label {
  display: block;
  font-size: 13px;
  color: #555;
}

.entry-form input,
.entry-form textarea {
  width: 100%;

  padding: 8px 10px;

  font: inherit;
  font-size: 14px;

  border: 1px solid #ddd;
  border-radius: 4px;

  background: #fff;
  color: #111;
}

.entry-form textarea {
  resize: vertical;
}

.entry-form input:focus,
.entry-form textarea:focus {
  outline: none;
  border-color: #999;
}

.entry-form button {
  margin-top: 8px;

  background: #111;
  color: #fff;

  border: none;
  border-radius: 4px;

  padding: 8px 10px;

  font: inherit;
  font-size: 14px;

  cursor: pointer;
}

.entry-form button:hover {
  background: #333;
}

.entry-form button:disabled {
  opacity: 0.6;
  cursor: default;
}

/* Entry editor */
.editor-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.entry-form .editor-toolbar button {
  margin-top: 0;
  padding: 4px 10px;

  background: #fff;
  color: #111;

  border: 1px solid #ddd;
  font-size: 13px;
}

.entry-form .editor-toolbar button:hover {
  background: #f0f0f0;
}

/* Write / Preview switch */
.editor-tabs {
  display: flex;
  gap: 4px;
}

.entry-form .editor-tabs button {
  background: none;
  border-color: transparent;
  color: #888;
}

.entry-form .editor-tabs button:hover {
  background: none;
  color: #111;
}

.entry-form .editor-tabs button.active {
  color: #111;
  border-color: #ddd;
  background: #fff;
}

/* takes the textarea's place in Preview mode, styled like it */
.editor-preview {
  position: relative;
  min-height: 60px;
  padding: 8px 10px;

  border: 1px solid #ddd;
  border-radius: 4px;
  background: #fff;
}

.editor-preview img {
  cursor: pointer;
}

/* Selected image in the preview */
.image-tools {
  position: absolute;
  outline: 2px solid #111;
  pointer-events: none;
}

.image-toolbar {
  position: absolute;
  top: 6px;
  left: 6px;

  display: flex;
  gap: 2px;

  pointer-events: auto;
}

/* keep the toolbar inside the preview for small right-aligned images */
.image-tools.right .image-toolbar {
  left: auto;
  right: 6px;
}

.entry-form .image-toolbar button {
  margin-top: 0;
  padding: 2px 6px;

  background: #fff;
  color: #111;

  border: 1px solid #ddd;
  border-radius: 3px;

  font-size: 12px;
}

.entry-form .image-toolbar button:hover,
.entry-form .image-toolbar button.active {
  background: #111;
  color: #fff;
  border-color: #111;
}

.image-handle {
  position: absolute;
  right: -6px;
  bottom: -6px;

  width: 12px;
  height: 12px;

  background: #111;
  border: 2px solid #fff;
  border-radius: 50%;

  cursor: nwse-resize;
  pointer-events: auto;
  touch-action: none;
}

.image-handle.left {
  right: auto;
  left: -6px;
  cursor: nesw-resize;
}

/* Admin forms: keep them at the post page's width */
.post-form {
  max-width: 640px;
}

.field-hint {
  font-size: 12px;
  color: #999;
}

.entry-form label.checkbox {
  display: flex;
  align-items: center;
  gap: 8px;

  font-size: 14px;
  color: #111;
}

.entry-form input[type="checkbox"] {
  width: auto;
}

/* Cover image: url field with upload / remove, and a preview cropped like the card */
.cover-field {
  display: flex;
  gap: 8px;
}

.entry-form .cover-field input {
  flex: 1;
  min-width: 0;
}

.entry-form .cover-field button {
  margin-top: 0;
  padding: 4px 10px;

  background: #fff;
  color: #111;

  border: 1px solid #ddd;
  font-size: 13px;
}

.entry-form .cover-field button:hover {
  background: #f0f0f0;
}

.cover-preview {
  display: block;
  width: 240px;
  max-width: 100%;
  aspect-ratio: 3 / 2;
  object-fit: cover;

  border: 1px solid #eee;
  border-radius: 6px;
  background: #f0f0f0;
}

.form-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
}

.entry-form .form-actions button {
  margin-top: 0;
  flex: 1;
}

.entry-form .form-actions button.secondary {
  background: #fff;
  color: #111;
  border: 1px solid #ccc;
}

.entry-form .form-actions button.secondary:hover {
  background: #f0f0f0;
}

.form-link {
  font-size: 14px;
  color: #555;
}

/* All posts list */
.admin-posts {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.admin-post {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;

  padding-bottom: 14px;
  border-bottom: 1px solid #eee;
}

.admin-post-info {
  min-width: 0;
  flex: 1;
}

.admin-post-title {
  font-size: 15px;
  font-weight: 600;
  color: #111;
  text-decoration: none;
}

.admin-post-title:hover {
  text-decoration: underline;
}

.admin-post-meta {
  margin-top: 2px;
  font-size: 12px;
  color: #888;
  overflow-wrap: anywhere;
}

.status {
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 11px;
}

.status.visible {
  background: #e6f4ea;
  color: #060;
}

.status.hidden {
  background: #eee;
  color: #555;
}

.admin-post-actions {
  display: flex;
  gap: 12px;
  flex-shrink: 0;
}

.admin-post-action {
  background: none;
  border: none;
  padding: 0;

  font: inherit;
  font-size: 13px;
  color: #555;
  text-decoration: none;
  cursor: pointer;
}

.admin-post-action:hover {
  color: #000;
  text-decoration: underline;
}

.admin-post-action.delete:hover {
  color: #a00;
}

/* Smaller screens: fewer columns, full-width column */
@media (max-width: 752px) {
  .container {
    width: 100%;
    margin: 24px auto;
  }

  .post-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 480px) {
  .post-grid {
    grid-template-columns: 1fr;
  }

  .admin-post {
    flex-direction: column;
    gap: 6px;
  }
}
