/* Premium Visual & Screen-Reader Accessible Stylesheet for hmdqr.me */
:root {
  --primary-color: #0f172a; /* Sleek Deep Slate */
  --primary-hover: #1e293b;
  --accent-color: #1e40af; /* Premium Indigo Accent */
  --accent-hover: #1d4ed8;
  --bg-color: #f8fafc; /* Beautiful soft grayish white */
  --card-bg: #ffffff;
  --text-main: #0f172a;
  --text-muted: #475569;
  --border-color: #e2e8f0;
  --header-bg: rgba(255, 255, 255, 0.85);
  --header-text: #0f172a;
  --header-border: rgba(226, 232, 240, 0.8);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05), 0 1px 2px rgba(0, 0, 0, 0.03);
  --shadow-md: 0 4px 12px -1px rgba(15, 23, 42, 0.06), 0 2px 4px -2px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 12px 24px -5px rgba(15, 23, 42, 0.08), 0 8px 16px -6px rgba(15, 23, 42, 0.04);
}

[data-theme="dark"] {
  --primary-color: #020617;
  --primary-hover: #0f172a;
  --accent-color: #3b82f6;
  --accent-hover: #60a5fa;
  --bg-color: #0b0f19; /* High-end dark charcoal */
  --card-bg: #111827;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --border-color: #1f2937;
  --header-bg: rgba(11, 15, 25, 0.85);
  --header-text: #f8fafc;
  --header-border: rgba(31, 41, 55, 0.8);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 4px 12px -1px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 16px 32px -5px rgba(0, 0, 0, 0.5);
}

body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI Arabic", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  margin: 0;
  padding: 0;
  line-height: 1.8;
  background: var(--bg-color);
  color: var(--text-main);
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* --- Screen-reader layout & A11Y support --- */
.visually-hidden, .screen-reader-text {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0);
  white-space: nowrap; border: 0;
}
.skip-link {
  position: absolute;
  inset-inline-start: 1rem;
  top: -100px;
  z-index: 1000;
  padding: 0.75rem 1.25rem;
  background: var(--accent-color);
  color: #fff;
  text-decoration: none;
  border-radius: 8px;
  box-shadow: var(--shadow-lg);
  font-weight: bold;
  transition: top 0.2s ease;
}
.skip-link:focus {
  top: 1rem;
}

/* Premium sleek focus states - gorgeous for sighted, fully accessible for keyboard navigating screen-readers */
a:focus-visible, button:focus-visible, summary:focus-visible, [tabindex]:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.45);
  border-radius: 6px;
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--accent-color);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}
main:focus { outline: none; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; scroll-behavior: auto !important; }
}

/* --- Layout --- */
header {
  background: var(--header-bg);
  color: var(--header-text);
  padding: 0.85rem 2rem;
  border-bottom: 1px solid var(--header-border);
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: background-color 0.3s ease, border-color 0.3s ease;
}
nav {
  max-width: 1000px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}
nav a {
  color: var(--header-text);
  opacity: 0.85;
  text-decoration: none;
  font-weight: 500;
  padding: 0.65rem 1rem;
  border-radius: 8px;
  min-height: 48px;
  display: inline-flex;
  align-items: center;
  box-sizing: border-box;
  transition: all 0.2s ease;
}
nav a:hover {
  background: rgba(15, 23, 42, 0.05);
  color: var(--accent-color);
  opacity: 1;
}
[data-theme="dark"] nav a:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  opacity: 1;
}

/* Theme toggle button */
.theme-toggle {
  background: transparent;
  border: 0;
  color: #fff;
  cursor: pointer;
  font-size: 1.2rem;
  margin-inline-start: auto;
  width: 48px;
  height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
}
main {
  max-width: 900px;
  margin: 3.5rem auto;
  padding: 0 1.5rem;
}
footer {
  text-align: center;
  padding: 4rem 1.5rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border-color);
  margin-top: 6rem;
  background: var(--card-bg);
}

/* --- Components & Elements --- */
h1, h2, h3, h4, h5, h6 {
  color: var(--text-main);
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-top: 0;
}
h1 { font-size: 2.5rem; margin-bottom: 1.5rem; }
h2 { font-size: 1.85rem; margin-bottom: 1rem; }

.posts {
  display: flex;
  flex-direction: column;
  gap: 2.25rem;
}
.posts article {
  background: var(--card-bg);
  padding: 2.5rem;
  border-radius: 16px;
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}
.posts article:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
}
.posts h2 {
  margin: 0 0 0.75rem;
}
.posts h2 a {
  color: var(--text-main);
  text-decoration: none;
  transition: color 0.2s ease;
}
.posts h2 a:hover {
  color: var(--accent-color);
}
.meta {
  color: var(--text-muted);
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}
.meta-sep {
  color: var(--border-color);
}
.error { color: #ef4444; font-weight: 500; }
.flash { color: #10b981; font-weight: 500; }

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--card-bg);
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  margin-bottom: 2.5rem;
}
th, td {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border-color);
  text-align: right;
}
th {
  background: var(--primary-color);
  color: #fff;
  font-weight: 600;
}
[data-theme="dark"] th {
  background: var(--primary-hover);
}

/* --- Forms & Controls --- */
form label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 500;
}
input, textarea, select {
  box-sizing: border-box;
  width: 100%;
  padding: 0.75rem 1.15rem;
  font-size: 1rem;
  border-radius: 10px;
  border: 1px solid var(--border-color);
  background: var(--card-bg);
  color: var(--text-main);
  transition: border-color 0.2s, box-shadow 0.2s;
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--accent-color);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}
textarea {
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
}
button, .button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: auto;
  padding: 0.75rem 1.5rem;
  border: 0;
  border-radius: 8px;
  background: var(--accent-color);
  color: #fff;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  box-shadow: 0 2px 4px rgba(37, 99, 235, 0.15);
  transition: background-color 0.2s, transform 0.1s, box-shadow 0.2s;
}
button:hover, .button:hover {
  background: var(--accent-hover);
  box-shadow: 0 4px 8px rgba(37, 99, 235, 0.25);
}
button:active, .button:active {
  transform: scale(0.98);
}
.nav-form { display: inline; margin: 0; }
.nav-form button {
  background: transparent;
  color: var(--header-text);
  opacity: 0.85;
  padding: 0.65rem 1rem;
  font-weight: 500;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  box-shadow: none;
  min-height: 48px;
  display: inline-flex;
  align-items: center;
  box-sizing: border-box;
  transition: all 0.2s ease;
}
.nav-form button:hover {
  background: rgba(15, 23, 42, 0.05);
  color: var(--accent-color);
  opacity: 1;
  box-shadow: none;
}
[data-theme="dark"] .nav-form button:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  opacity: 1;
}

.nav-group { display: inline-block; position: relative; }
.nav-group > summary {
  cursor: pointer;
  list-style: none;
  color: inherit;
  padding: 0.65rem 1rem;
  border-radius: 8px;
  opacity: 0.85;
  min-height: 48px;
  display: inline-flex;
  align-items: center;
  box-sizing: border-box;
  transition: all 0.2s ease;
}
.nav-group > summary::-webkit-details-marker { display: none; }
.nav-group > summary::after { content: " \25be"; font-size: 0.75rem; vertical-align: middle; margin-inline-start: 0.25rem; }
.nav-group[open] > summary::after { content: " \25b4"; }
.nav-group > ul { list-style: none; margin: 0.25rem 0 0; padding: 0.25rem 0; }
.nav-group > ul li { margin: 0; }
header .nav-group > ul {
  position: absolute;
  inset-inline-start: 0;
  top: 100%;
  min-width: 12rem;
  background: var(--card-bg);
  padding: 0.5rem;
  border-radius: 12px;
  z-index: 20;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border-color);
}
header .nav-group > ul a {
  display: block;
  padding: 0.5rem 0.75rem;
  color: var(--text-main);
  border-radius: 8px;
  font-weight: 500;
}
header .nav-group > ul a:hover {
  background: rgba(15, 23, 42, 0.05);
  color: var(--accent-color);
}
[data-theme="dark"] header .nav-group > ul a:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}
@media (max-width: 640px) { header .nav-group > ul { position: static; min-width: 0; box-shadow: none; border: none; } }

.admin-heading { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 2rem; }
.editor-form { background: var(--card-bg); padding: 2rem; border-radius: 16px; box-shadow: var(--shadow-sm); border: 1px solid var(--border-color); }
.lang-chooser { background: var(--card-bg); padding: 2rem; border-radius: 16px; box-shadow: var(--shadow-sm); border: 1px solid var(--border-color); }
.chooser-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; margin: 1rem 0; }
.chooser-card { display: flex; align-items: center; justify-content: center; min-height: 4.5rem; padding: 1rem; text-align: center; font-weight: 600; text-decoration: none; color: var(--text-main); background: var(--bg-color); border: 1px solid var(--border-color); border-radius: 12px; transition: border-color .15s, transform .15s; }
.chooser-card:hover, .chooser-card:focus-visible { border-color: var(--accent-color); transform: translateY(-2px); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.5rem; }
.checkbox-row { display: flex; flex-direction: row; align-items: center; gap: .6rem; margin-top: 1.25rem; font-weight: 600; cursor: pointer; }
.checkbox-row input[type="checkbox"] { width: 1.15rem; height: 1.15rem; flex: 0 0 auto; cursor: pointer; }
.content {
  background: var(--card-bg);
  padding: 3rem;
  border-radius: 16px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-color);
  font-size: 1.15rem;
  line-height: 1.85;
}
@media (max-width: 640px) { .form-grid, .admin-heading { display: block; } }

/* --- Admin dashboard --- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 1.25rem; margin-bottom: 2rem; }
.stat-card {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  background: var(--card-bg);
  padding: 1.5rem;
  border-radius: 12px;
  box-shadow: var(--shadow-sm);
  text-decoration: none;
  color: var(--text-main);
  border-inline-start: 5px solid var(--primary-color);
  border: 1px solid var(--border-color);
  transition: transform 0.2s, box-shadow 0.2s;
}
.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
.stat-card.stat-ok { border-inline-start-color: #10b981; }
.stat-card.stat-warn { border-inline-start-color: #f59e0b; }
.stat-num { font-size: 2rem; font-weight: 800; line-height: 1; color: var(--text-main); }
.stat-label { color: var(--text-muted); font-size: 0.875rem; font-weight: 500; }

.admin-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 1.5rem; margin-bottom: 2.5rem; }
.panel { background: var(--card-bg); border-radius: 12px; box-shadow: var(--shadow-sm); border: 1px solid var(--border-color); padding: 1.5rem; }
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; border-bottom: 1px solid var(--border-color); padding-bottom: 0.75rem; }
.panel-head h2 { margin: 0; font-size: 1.25rem; }
.panel-head a { font-size: 0.875rem; font-weight: 500; color: var(--accent-color); text-decoration: none; }
.panel-head a:hover { text-decoration: underline; }
.panel table { box-shadow: none; border: none; }
.empty { color: var(--text-muted); padding: 1rem 0; }
.quick-links { display: flex; flex-wrap: wrap; gap: 1rem; }
.quick-links a { background: var(--card-bg); padding: 0.75rem 1.25rem; border-radius: 10px; border: 1px solid var(--border-color); box-shadow: var(--shadow-sm); text-decoration: none; color: var(--text-main); font-weight: 500; transition: transform 0.2s, box-shadow 0.2s; }
.quick-links a:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); }

/* --- Status badges --- */
.badge { display: inline-block; padding: 0.25rem 0.75rem; border-radius: 9999px; font-size: 0.8rem; font-weight: 600; }
.badge-ok { background: #d1fae5; color: #065f46; }
.badge-warn { background: #fef3c7; color: #92400e; }
.badge-muted { background: #f3f4f6; color: #1f2937; }

/* --- Posts table actions --- */
.posts-table .actions { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.posts-table .actions form { display: inline; margin: 0; width: auto; }
.btn-sm { width: auto; display: inline-flex; align-items: center; justify-content: center; padding: 0.4rem 0.8rem; font-size: 0.875rem; font-weight: 600; border: 0; border-radius: 6px; background: var(--primary-color); color: #fff; text-decoration: none; cursor: pointer; transition: background-color 0.1s; }
.btn-ok { background: #10b981; }
.btn-ok:hover { background: #059669; }
.btn-warn { background: #f59e0b; }
.btn-warn:hover { background: #d97706; }
.btn-danger { background: #ef4444; }
.btn-danger:hover { background: #dc2626; }

/* --- Footer navigation --- */
.footer-nav { display: flex; flex-wrap: wrap; gap: 1.5rem; justify-content: center; margin-bottom: 1.5rem; }
.footer-nav a { color: var(--text-main); text-decoration: none; font-weight: 500; opacity: 0.85; transition: all 0.2s ease; padding: 0.65rem 1rem; border-radius: 8px; min-height: 48px; display: inline-flex; align-items: center; box-sizing: border-box; }
.footer-nav a:hover { color: var(--accent-color); text-decoration: none; opacity: 1; }

/* --- Blog pagination --- */
.pagination { display: flex; align-items: center; gap: 1.25rem; margin: 3rem 0; flex-wrap: wrap; }
.pagination .page-num { color: var(--text-muted); font-weight: 500; }
.more-link { margin-top: 2rem; }

/* --- Admin quick actions --- */
.admin-quick { display: flex; flex-wrap: wrap; gap: 1rem; margin-bottom: 2rem; }
.admin-quick a { background: var(--card-bg); padding: 0.75rem 1.25rem; border-radius: 10px; border: 1px solid var(--border-color); box-shadow: var(--shadow-sm); text-decoration: none; color: var(--text-main); font-weight: 500; transition: transform 0.2s, box-shadow 0.2s; }
.admin-quick a:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); }

/* --- Admin top bar (shown on every /admin page) --- */
.admin-bar { gap: 0.5rem; padding-bottom: 1rem; margin-bottom: 1.5rem; border-bottom: 1px solid var(--border-color); }
.admin-bar a { padding: 0.5rem 0.9rem; font-size: 0.95rem; }

/* --- Admin section titles & collapsible analytics --- */
.section-title { font-size: 1.1rem; margin: 1.5rem 0 0.75rem; color: var(--text-muted, var(--text-main)); }
.admin-advanced { margin-top: 1rem; }
.admin-advanced > summary { cursor: pointer; font-weight: 600; padding: 0.75rem 1rem; background: var(--card-bg); border: 1px solid var(--border-color); border-radius: 10px; box-shadow: var(--shadow-sm); }
.admin-advanced[open] > summary { margin-bottom: 1.5rem; }

/* --- Admin menu rows --- */
.menu-row { border-inline-start: 5px solid var(--accent-color); margin-bottom: 1.5rem; }
.menu-row-actions { margin-top: 1rem; }

/* --- Dark mode system sync is implemented in JS --- */

/* --- Sleek Premium Interactive Enhancements (Auto-Copy, Reading-Progress, Back-to-Top) --- */

.reading-progress-bar {
  position: fixed;
  top: 0;
  inset-inline-start: 0;
  width: 0%;
  height: 4px;
  background: var(--accent-color);
  z-index: 10001;
  transition: width 0.15s ease-out;
}

pre {
  position: relative;
  padding-top: 2.75rem !important;
}

.pre-copy-button {
  position: absolute;
  top: 0.5rem;
  inset-inline-end: 0.5rem;
  width: auto;
  padding: 0.25rem 0.65rem;
  font-size: 0.8rem;
  font-weight: 600;
  border-radius: 6px;
  border: 1px solid var(--border-color);
  background: var(--card-bg);
  color: var(--text-muted);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.25s ease, background-color 0.2s, border-color 0.2s, color 0.15s;
  z-index: 10;
}

pre:hover .pre-copy-button,
.pre-copy-button:focus-visible {
  opacity: 1;
}

.pre-copy-button:hover {
  background: var(--accent-color);
  border-color: var(--accent-color);
  color: #ffffff;
}

.pre-copy-button.copied {
  background: #10b981;
  border-color: #10b981;
  color: #ffffff;
}

.back-to-top-btn {
  position: fixed;
  bottom: 1.5rem;
  inset-inline-end: 1.5rem;
  width: 2.75rem;
  height: 2.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--accent-color);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: var(--shadow-lg);
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px);
  transition: opacity 0.3s ease, transform 0.3s ease, visibility 0.3s, background-color 0.2s;
  z-index: 999;
}

.back-to-top-btn.visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.back-to-top-btn:hover,
.back-to-top-btn:focus-visible {
  background: var(--accent-hover);
  transform: translateY(-3px);
  outline: none;
}

@media (max-width: 640px) {
  .back-to-top-btn {
    bottom: 1rem;
    inset-inline-end: 1rem;
    width: 2.5rem;
    height: 2.5rem;
  }
}

/* ── CSP-safe utilities (replace inline style= so style-src 'self' holds) ── */
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 1rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-4 { margin-bottom: 1rem; }
.mb-5 { margin-bottom: 1.5rem; }
.mb-6 { margin-bottom: 2rem; }
.inline-form { display: inline; margin: 0; }
.row-actions { display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: center; }
.filter-bar { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-bottom: 1rem; }
.tab-bar { display: flex; gap: 0.5rem; margin-bottom: 1rem; }
.pager-center { justify-content: center; gap: 0.5rem; margin: 1rem 0; }
.button.is-active { background: #444; }
.page-current { background: #666; cursor: default; }
.btn-muted { background: #666; }
.btn-info { background: #2b6cb0; }
.btn-compact { padding: 0.25rem 0.5rem; }
.hint-block { display: block; margin-top: 0.25rem; margin-bottom: 1.5rem; }
.meta-modified { margin-top: 0; margin-bottom: 1.5rem; font-size: 0.85rem; }
.admin-edit-link { margin: 0 0 1rem; }
.admin-edit-link a { display: inline-block; padding: 0.3rem 0.8rem; font-size: 0.85rem; font-weight: 600; text-decoration: none; color: var(--accent-color); background: var(--card-bg); border: 1px solid var(--border-color); border-radius: 999px; transition: border-color .15s, color .15s; }
.admin-edit-link a:hover, .admin-edit-link a:focus-visible { border-color: var(--accent-color); }

/* ── Post editor (moved out of admin_post_form inline <style>) ── */
.editor-container {
  border: 1px solid var(--border-color);
  border-radius: 12px;
  background: var(--card-bg);
  overflow: hidden;
  margin-bottom: 0.5rem;
}
.editor-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  padding: 0.5rem;
  background: rgba(127, 127, 127, 0.05);
  border-bottom: 1px solid var(--border-color);
  align-items: center;
}
.toolbar-btn {
  all: unset;
  cursor: pointer;
  font-size: 0.9rem;
  padding: 0.35rem 0.75rem;
  border-radius: 6px;
  color: var(--text-main);
  background: transparent;
  border: 1px solid transparent;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: none;
  font-weight: 500;
}
.toolbar-btn:hover {
  background: rgba(127, 127, 127, 0.15);
  border-color: var(--border-color);
  box-shadow: none;
}
.toolbar-btn:active { transform: none; }
.toolbar-sep { color: var(--border-color); margin: 0 0.5rem; }
#editor-textarea {
  border: none;
  border-radius: 0;
  box-shadow: none;
  resize: vertical;
}
#editor-textarea:focus {
  box-shadow: none;
  outline: none;
}


