/* ============================================================
   modern.css — Component modernization layer
   Loads AFTER styles.css to refine existing components.
   Uses tokens from theme.css. Class names unchanged so all
   existing pages/scripts keep working.
   ============================================================ */

/* ---------- Top account bar ---------- */
.account-bar {
  height: var(--header-h);
  background: linear-gradient(180deg,
              rgba(13, 29, 33, 0.55) 0%,
              rgba(13, 29, 33, 0.30) 100%);
  -webkit-backdrop-filter: blur(10px) saturate(140%);
  backdrop-filter: blur(10px) saturate(140%);
  border-bottom: 1px solid rgba(255, 255, 255, 0.10);
  box-shadow: var(--shadow-sm);
}

.icon {
  height: var(--header-h);
  padding: 0.55rem;
  transition: transform var(--transition-fast), opacity var(--transition-fast);
}
.icon:hover { transform: scale(1.08); opacity: 0.9; }

.account {
  border-radius: var(--radius-pill);
  padding: 0.5rem 1.1rem;
  height: auto;
  font-weight: 600;
  font-size: var(--fs-300);
  letter-spacing: 0.01em;
  background: rgba(255, 255, 255, 0.95);
  box-shadow: var(--shadow-sm);
  transition: background var(--transition-fast), transform var(--transition-fast);
}
.account:hover { transform: translateY(-50%) scale(1.03); }
.account.logged-in:hover { background: #ffffff; }

/* ---------- Hero ---------- */
.hero {
  height: clamp(22rem, 60vh, 34rem);
  margin: 0;
  margin-top: var(--header-h);
  position: relative;
}

.hero-content,
.hero-small-content {
  font-size: var(--fs-400);
  animation: vr-rise 0.6s ease both;
}

.hero-content h1 {
  font-size: var(--fs-900);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: var(--lh-tight);
}

.hero-content .introduction,
.hero-content p {
  font-size: var(--fs-500);
}
.introduction { color: var(--color-on-dark-muted); letter-spacing: 0.04em; }

.hero-small { margin: 0; margin-top: var(--header-h); height: auto; min-height: 5rem; padding: 0.5rem 0; }
.hero-small-content h1 { font-size: var(--fs-600); margin: 0; }

/* ---------- Navigation grid ---------- */
.grid-container,
.grid-container-small {
  font-size: var(--fs-400);
  height: auto;
}

.grid-item,
.grid-item-small {
  background-color: var(--color-ink);
  padding: clamp(1rem, 2.5vw, 1.75rem);
  font-weight: 600;
  letter-spacing: 0.02em;
  position: relative;
  transition: background-color var(--transition), color var(--transition), transform var(--transition-fast);
}

.grid-item::after,
.grid-item-small::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 0.7rem;
  width: 0;
  height: 2px;
  background: var(--color-accent);
  transform: translateX(-50%);
  transition: width var(--transition);
}

.grid-item:hover,
.grid-item-small:hover {
  background-color: var(--color-accent);
  color: #0d1d21;
}
.grid-item:hover::after,
.grid-item-small:hover::after { width: 40%; }

/* ---------- Buttons ---------- */
button {
  border-radius: var(--radius-sm);
  font-weight: 600;
  transition: background-color var(--transition-fast), color var(--transition-fast), transform var(--transition-fast);
}
button:hover { transform: translateY(-1px); }
button:active { transform: translateY(0); }

.read-more-btn,
.edit-profile-btn,
.new-post-btn,
.new-project-btn {
  background: var(--color-primary);
  color: #fff;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
}
.read-more-btn:hover,
.edit-profile-btn:hover,
.new-post-btn:hover,
.new-project-btn:hover {
  background: var(--color-primary-hover);
  color: #fff;
}

/* ---------- Section titles ---------- */
.section-title {
  font-size: var(--fs-600);
  letter-spacing: -0.01em;
  color: var(--color-primary);
  border-bottom: 2px solid var(--color-primary);
}

/* ---------- Cards (blog + projects) ---------- */
.featured-post,
.blog-post-card,
.project-card {
  border-radius: var(--radius);
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition), transform var(--transition), border-color var(--transition);
  padding: 10px;
}

.featured-post { box-shadow: var(--shadow); }

.blog-post-card:hover,
.project-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow);
  border-color: var(--color-primary);
}

.featured-badge {
  background: var(--color-primary);
  border-radius: var(--radius-pill);
  letter-spacing: 0.06em;
}

/* ---------- Tags ---------- */
.tag {
  background: var(--color-surface-alt);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-pill);
  transition: background var(--transition-fast), color var(--transition-fast);
}
.tag:hover { background: var(--color-primary); color: #fff; border-color: var(--color-primary); }

/* ---------- Sidebars ---------- */
.blog-sidebar {
  border-radius: var(--radius);
  border: 1px solid var(--color-border);
  background: var(--color-surface-alt);
  box-shadow: var(--shadow-sm);
}

/* ---------- Home recent-posts list (added in v1.1) ---------- */
.home-recent-item { border-radius: var(--radius-sm); }
.home-recent-item:hover { background: rgba(2, 45, 51, 0.06); }
.home-view-all {
  color: var(--color-primary);
  font-weight: 600;
}
.home-view-all:hover { color: var(--color-primary-hover); }

/* ---------- Blog/home layout entrance ---------- */
.home-blog-layout .featured-post { animation: vr-rise 0.6s ease both; }

/* ---------- Phase reorder controls (project editor) ---------- */
.phase-buttons {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
}

.move-btn {
  background: var(--color-surface-alt);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  color: var(--color-primary);
  font-weight: 700;
  line-height: 1;
  padding: 0.4rem 0.7rem;
  min-width: 2.2rem;
}
.move-btn:hover {
  background: var(--color-primary);
  color: #fff;
  border-color: var(--color-primary);
}
.move-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ---------- Edit Project button (viewer modal, editors only) ---------- */
#edit-project-btn {
  margin: 0 0 1rem 0;
}

/* ---------- Editor action buttons (publish/unpublish/delete) ---------- */
.project-actions { display: flex; gap: 0.6rem; flex-wrap: wrap; align-items: center; }
.project-actions .save-btn,
.project-actions .publish-btn {
  background: var(--color-primary);
  color: #fff;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
}
.project-actions .save-btn:hover,
.project-actions .publish-btn:hover { background: var(--color-primary-hover); color: #fff; }

.project-actions .unpublish-btn {
  background: var(--color-surface-alt);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
}
.project-actions .unpublish-btn:hover { background: #e9eded; color: var(--color-text); }

.project-actions .delete-btn {
  background: #fff;
  color: var(--color-error);
  border: 1px solid var(--color-error);
  border-radius: var(--radius-sm);
}
.project-actions .delete-btn:hover { background: var(--color-error); color: #fff; }

/* ============================================================
   Mobile (shared across ALL pages, since every page loads modern.css)
   - Centered page titles in the small hero header
   - Projects layout spans the full container width (with padding)
   ============================================================ */
@media (max-width: 768px) {
  .hero-small { justify-content: center; text-align: center; }
  .hero-small-content { text-align: center; padding: 0 15px; }
  .hero-small-content h1 { font-size: 7vw; color: #ffffff; margin: 0; }

  /* Projects: full-width cards on mobile (desktop keeps its narrow column) */
  .projects-layout { max-width: 100%; padding: 24px 15px; }
}

/* ===== About Me page ===== */
#aboutme-container {
  max-width: 800px;
  margin: 40px auto;
  padding: 0 20px;
  line-height: 1.7;
}
#aboutme-content img { max-width: 100%; height: auto; }
#edit-aboutme-btn,
#aboutme-editor button {
  margin-top: 20px;
  padding: 10px 18px;
  border: none;
  border-radius: 6px;
  background: #2b2b2b;
  color: #fff;
  cursor: pointer;
  font-family: inherit;
}
#edit-aboutme-btn:hover,
#aboutme-editor button:hover { background: #444; }
#aboutme-editor-area {
  min-height: 240px;
  padding: 16px;
  border: 1px solid #ccc;
  border-radius: 6px;
  background: #fff;
  color: #111;
}
.aboutme-editor-buttons { display: flex; gap: 10px; }
#save-aboutme-btn { background: #1f7a3d; }
#save-aboutme-btn:hover { background: #26944a; }

/* ===== Attachments — display (blog post viewer, projects, project editor) ===== */
.phase-attachments { margin: 8px 0 14px; font-size: 0.95rem; }
.attachments-label { font-weight: 600; margin-right: 8px; }
.attachment-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0 8px 6px 0;
  background: rgba(2, 45, 51, 0.08);
  border-radius: 6px;
  padding: 3px 10px;
}
.attachment-item a { color: #022d33; text-decoration: none; word-break: break-word; }
.attachment-item a:hover { text-decoration: underline; }
.attachment-remove { cursor: pointer; font-weight: bold; color: #a00; }
.attachments-empty { color: #888; font-style: italic; }

/* Blog Post Viewer: "Attachments:" container on the right margin */
.post-attachments-sidebar {
  float: right;
  width: 240px;
  margin: 0 0 16px 24px;
  padding: 14px 16px;
  background: #f4f7f7;
  border: 1px solid #dbe6e6;
  border-radius: 10px;
}
.post-attachments-sidebar h3 { margin: 0 0 10px; font-size: 1.05rem; }
.post-attachments-sidebar ul { list-style: none; margin: 0; padding: 0; }
.post-attachments-sidebar li { margin-bottom: 8px; }
.post-attachments-sidebar a { color: #022d33; text-decoration: none; word-break: break-word; }
.post-attachments-sidebar a:hover { text-decoration: underline; }

@media (max-width: 768px) {
  .post-attachments-sidebar { float: none; width: auto; margin: 0 0 16px 0; }
}

/* ===== Project tags (under title on cards + in the project modal) ===== */
.project-card-tags,
.project-modal-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 6px 0 10px;
}

/* ===== Fullscreen image lightbox ===== */
.image-lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  cursor: zoom-out;
  padding: 20px;
}
.image-lightbox.active { display: flex; }
.image-lightbox img {
  max-width: 92%;
  max-height: 92%;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.5);
}

/* ===== Editor-only drafts bar + modal (Blog) ===== */
.drafts-bar {
  background: #fff8d1;
  border: 1px solid #f0e39a;
  border-left: 5px solid #e6c200;
  color: #5c4d00;
  padding: 12px 18px;
  margin: 12px 20px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 500;
  text-align: center;
  transition: background var(--transition, 0.2s);
}
.drafts-bar:hover { background: #fef3b0; }

.drafts-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1500;
  padding: 20px;
}
.drafts-modal.active { display: flex; }
.drafts-modal-content {
  background: #fff;
  color: #022d33;
  border-radius: 10px;
  max-width: 600px;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
  padding: 28px;
  position: relative;
}
.drafts-modal-content h2 { margin-top: 0; }
.draft-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid #eee;
}
.draft-info { display: flex; flex-direction: column; }
.draft-title { font-weight: 600; }
.draft-date { font-size: 12px; color: #888; }
.draft-actions { display: flex; gap: 8px; flex-shrink: 0; }
.draft-edit, .draft-delete {
  border: none;
  border-radius: 6px;
  padding: 6px 12px;
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
}
.draft-edit { background: #022d33; color: #fff; }
.draft-delete { background: #c0392b; color: #fff; }

/* ===== Recent project cards: image as a left thumbnail beside text ===== */
.project-card {
  display: flex;
  gap: 16px;
  align-items: flex-start;
}
.project-card .project-preview-image {
  flex: 0 0 auto;
  width: 140px;
  height: 140px;
  max-width: 140px;
  margin: 0;              /* override the stacked/centered image styling */
  border-radius: 8px;
}
.project-card .project-preview-image.has-custom-image { object-fit: cover; }   /* photos fill the box */
.project-card .project-preview-image.default-logo    { object-fit: contain; } /* logo not cropped */
.project-card-body {
  flex: 1 1 auto;
  min-width: 0;           /* let long text wrap inside the flex row */
}
.project-card-body h3 { margin-top: 0; }

/* Stack image on top again on very narrow screens */
@media (max-width: 600px) {
  .project-card { flex-direction: column; }
  .project-card .project-preview-image {
    width: 100%;
    max-width: 100%;
    height: 90px;
  }
}

/* ===== Projects page: two-column layout (main + search/contact sidebar) ===== */
.projects-layout {
  display: flex;
  gap: 32px;
  max-width: 1200px;
  margin: 0 auto;
  padding: 40px 20px;
  align-items: flex-start;
  justify-content: flex-start;
}
.projects-main { flex: 1 1 auto; min-width: 0; }
.projects-sidebar {
  flex: 0 0 320px;
  position: sticky;
  top: 20px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* Search panel */
.projects-sidebar .search-section {
  background: var(--color-surface, #fff);
  border: 1px solid var(--color-border, #e5e7e7);
  border-radius: var(--radius, 12px);
  box-shadow: var(--shadow-sm, 0 1px 3px rgba(2, 45, 51, 0.08));
  padding: 18px;
}
.projects-sidebar .search-section h3 { margin-top: 0; }
.projects-sidebar .search-box { display: flex; gap: 8px; }
.projects-sidebar .search-box input {
  flex: 1; min-width: 0; padding: 8px 10px;
  border: 1px solid #ccc; border-radius: 6px; font-family: inherit;
}
.projects-sidebar .search-btn {
  border: none; border-radius: 6px; background: #022d33; color: #fff;
  padding: 8px 12px; cursor: pointer;
}
.project-filter-group { margin-top: 14px; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.project-filter-group label { font-weight: 600; font-size: 13px; }
.project-filter-group select,
.project-filter-group input[type="date"] {
  flex: 1 1 120px; min-width: 0; padding: 7px 9px;
  border: 1px solid #ccc; border-radius: 6px; font-family: inherit;
}
.projects-sidebar .clear-search-btn {
  margin-top: 14px; width: 100%;
  border: 1px solid #ccc; border-radius: 6px;
  background: #f4f7f7; padding: 8px; cursor: pointer; font-family: inherit;
}

/* Contact form duplicated into the sidebar (reuses .contact-form + .cf-*) */
.projects-contact h3 { margin: 0 0 10px; }
.projects-contact .contact-form { padding: 18px; }

/* Stack to one column on smaller screens */
@media (max-width: 900px) {
  .projects-layout { flex-direction: column; }
  .projects-sidebar { flex-basis: auto; width: 100%; position: static; }
}

/* ===== Admin account dropdown (in the account bar) ===== */
.account-menu {
  position: absolute;
  top: 100%;
  right: 12px;
  min-width: 180px;
  background: #fff;
  border: 1px solid var(--color-border, #e5e7e7);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
  overflow: hidden;
  display: none;
  z-index: 20;
}
.account-menu.open { display: block; }
.account-menu-item {
  display: block;
  padding: 10px 16px;
  color: #022d33;
  text-decoration: none;
  font-size: 0.95rem;
}
.account-menu-item:hover { background: #f2f6f6; }

/* ===== Admin console ===== */
.admin-wrap { max-width: 1000px; margin: 30px auto 60px; padding: 0 20px; }
.admin-section { margin-bottom: 36px; }
.admin-section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.admin-badge { background: #e6c200; color: #5c4d00; border-radius: 12px; padding: 2px 10px; font-size: 0.8rem; margin-left: 6px; }
.admin-hint { color: #667; font-size: 0.85rem; margin: 6px 0 12px; }
.admin-list { display: flex; flex-direction: column; gap: 10px; }
.admin-row {
  display: flex; flex-wrap: wrap; align-items: center; gap: 16px;
  padding: 12px 16px; border: 1px solid var(--color-border, #e5e7e7);
  border-radius: 10px; background: #fff;
}
.admin-row.is-disabled { opacity: 0.55; }
.admin-cell { display: flex; flex-direction: column; gap: 4px; }
.admin-cell-main { flex: 1 1 220px; min-width: 0; }
.admin-user-name { font-weight: 600; }
.admin-user-email { font-size: 0.8rem; color: #778; word-break: break-all; }
.admin-mini { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.04em; color: #889; }
.admin-role-select { padding: 6px 8px; border: 1px solid #ccc; border-radius: 6px; font-family: inherit; }
.admin-tag { font-size: 0.85rem; }
.admin-tag.ok { color: #1f7a4d; font-weight: 600; }
.admin-tag.pending { color: #a86a00; font-weight: 600; }
.admin-btn {
  border: none; border-radius: 6px; background: #022d33; color: #fff;
  padding: 6px 12px; cursor: pointer; font-family: inherit; font-size: 0.85rem;
}
.admin-btn:hover { background: #034048; }
.admin-btn.danger { background: #c0392b; }
.admin-btn.danger:hover { background: #a93226; }
.admin-link { color: #022d33; font-weight: 600; }
.admin-status { min-height: 1.2em; margin-top: 12px; }
.admin-status.is-success { color: #1f7a4d; }
.admin-status.is-error { color: #b3261e; }

/* ===== Code Blocks (project phases) ===== */
.code-container {
    position: relative;
    display: block;
    margin: 12px 0;
    padding: 14px 16px;
    background: #1e1e2e;
    color: #e6e6e6;
    border: 1px solid #313244;
    border-radius: 8px;
    font-family: "SF Mono", "Consolas", "Menlo", "Monaco", monospace;
    font-size: 0.9rem;
    line-height: 1.5;
    max-height: 420px;
    overflow: auto;
    white-space: pre;
    tab-size: 4;
}

.code-container code {
    display: block;
    background: none;
    color: inherit;
    padding: 0;
    font-family: inherit;
    white-space: pre;
    word-break: normal;
}

.code-language-label {
    position: sticky;
    top: -14px;
    left: 0;
    display: inline-block;
    margin: -6px 0 8px -4px;
    padding: 2px 8px;
    background: #313244;
    color: #a6adc8;
    border-radius: 0 0 6px 0;
    font-size: 0.72rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    font-family: "SF Mono", "Consolas", monospace;
    user-select: none;
}

/* Editor affordance: show it's clickable to edit */
.editor .code-container {
    cursor: pointer;
}

.editor .code-container:hover {
    border-color: #007bff;
}

/* Custom scrollbar for code blocks */
.code-container::-webkit-scrollbar {
    height: 10px;
    width: 10px;
}
.code-container::-webkit-scrollbar-track {
    background: #181825;
    border-radius: 8px;
}
.code-container::-webkit-scrollbar-thumb {
    background: #45475a;
    border-radius: 8px;
}
.code-container::-webkit-scrollbar-thumb:hover {
    background: #585b70;
}

/* Code modal textarea */
.code-input {
    width: 100%;
    min-height: 220px;
    font-family: "SF Mono", "Consolas", "Menlo", monospace;
    font-size: 0.9rem;
    white-space: pre;
    overflow: auto;
    tab-size: 4;
}
