/* ==================================================================
   ImageForgeLab Blog — standalone stylesheet
   Matches the main app's deep-blue/obsidian theme without relying on
   webfonts, so the pages keep the strict CSP (font-src 'self' data:).
   ================================================================== */

:root {
  --bg-base: hsl(222, 47%, 7%);
  --bg-surface: hsl(223, 47%, 11%);
  --bg-panel: hsl(223, 45%, 15%);
  --bg-input: hsl(224, 43%, 18%);

  --border-subtle: hsla(220, 20%, 95%, 0.06);
  --border-bright: hsla(220, 30%, 95%, 0.15);

  --text-primary: hsl(210, 40%, 98%);
  --text-secondary: hsl(215, 20%, 75%);
  --text-muted: hsl(215, 15%, 55%);

  --accent: hsl(217, 91%, 60%);
  --accent-hover: hsl(217, 91%, 65%);
  --success: hsl(142, 71%, 45%);
  --danger: hsl(350, 89%, 60%);

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;

  --font: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --mono: ui-monospace, 'Cascadia Code', Consolas, monospace;
}

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

html { scroll-behavior: smooth; }

body {
  background-color: var(--bg-base);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

.container {
  width: min(960px, 100% - 3rem);
  margin-inline: auto;
}

main.container { min-height: 60vh; padding-block: 2.5rem 4rem; }

img { max-width: 100%; height: auto; }
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: underline; }

/* ------------------------------ header ----------------------------- */

.site-header {
  border-bottom: 1px solid var(--border-subtle);
  background: linear-gradient(180deg, rgba(255,255,255,0.02), transparent);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding-block: 1.05rem;
}

.brand {
  font-weight: 700;
  font-size: 1.2rem;
  letter-spacing: -0.01em;
  color: var(--text-primary);
}
.brand:hover { color: var(--accent); text-decoration: none; }

.site-nav { display: flex; gap: 1.4rem; font-size: 0.95rem; }
.site-nav a { color: var(--text-secondary); }
.site-nav a:hover { color: var(--text-primary); }

/* ------------------------------ shared ----------------------------- */

.eyebrow {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--accent);
  margin-bottom: 0.5rem;
}

.page-head { margin-bottom: 2.2rem; }
.page-head h1 { font-size: 2.3rem; line-height: 1.15; letter-spacing: -0.02em; }
.lede { color: var(--text-secondary); margin-top: 0.6rem; max-width: 60ch; }

.empty { color: var(--text-muted); padding-block: 2rem; }

.breadcrumb {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 1.8rem;
}
.breadcrumb a { color: var(--text-muted); }
.breadcrumb a:hover { color: var(--text-primary); }
.breadcrumb .sep { opacity: 0.6; }

.post-meta {
  color: var(--text-muted);
  font-size: 0.85rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
}

.badge {
  display: inline-block;
  padding: 0.1rem 0.6rem;
  border-radius: 999px;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: var(--bg-panel);
  border: 1px solid var(--border-bright);
  color: var(--text-secondary);
}

.badge-ok { color: hsl(152, 60%, 60%); border-color: hsla(142, 71%, 45%, 0.4); }
.badge-muted { color: var(--text-muted); }

.tag {
  font-size: 0.8rem;
  color: var(--text-muted);
}
.tag + .tag::before { content: " "; }

/* --------------------------- post list ---------------------------- */

.post-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.4rem;
}

.post-card {
  display: grid;
  gap: 1.2rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1.4rem;
  transition: border-color var(--transition, 0.2s ease), transform var(--transition, 0.2s ease);
}
.post-card:hover { border-color: var(--border-bright); }

@media (min-width: 700px) {
  .post-card { grid-template-columns: minmax(0, 9fr) minmax(0, 15fr); }
}

.post-card-thumb img {
  width: 100%;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
}

.post-card-body { display: flex; flex-direction: column; gap: 0.5rem; }
.post-card-title { font-size: 1.3rem; line-height: 1.3; }
.post-card-title a { color: var(--text-primary); }
.post-card-title a:hover { color: var(--accent); text-decoration: none; }
.post-card-excerpt { color: var(--text-secondary); }
.read-more { margin-top: 0.3rem; font-size: 0.92rem; }
.read-more a { font-weight: 500; }

/* ------------------------------ article ---------------------------- */

.post-head h1 {
  font-size: 2rem;
  line-height: 1.22;
  letter-spacing: -0.015em;
  margin: 0.8rem 0 0.6rem;
}

.post-hero {
  margin: 1.6rem 0 2rem;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--bg-surface);
}

.post-body {
  font-size: 1.02rem;
  color: var(--text-secondary);
}

.post-body h2 {
  font-size: 1.5rem;
  color: var(--text-primary);
  margin: 2rem 0 0.7rem;
  line-height: 1.25;
}
.post-body h3 {
  font-size: 1.2rem;
  color: var(--text-primary);
  margin: 1.6rem 0 0.5rem;
}
.post-body p { margin-bottom: 1.1rem; }
.post-body ul, .post-body ol { margin: 0 0 1.1rem 1.4rem; }
.post-body li { margin-bottom: 0.35rem; }
.post-body strong { color: var(--text-primary); }
.post-body a { text-decoration: underline; }

.post-body blockquote {
  margin: 1.4rem 0;
  padding: 0.8rem 1.2rem;
  border-left: 3px solid var(--accent);
  background: var(--bg-panel);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--text-primary);
}
.post-body blockquote p { margin-bottom: 0; }

.post-body pre {
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 1rem 1.1rem;
  overflow-x: auto;
  margin-bottom: 1.1rem;
  font-size: 0.9rem;
}
.post-body code {
  font-family: var(--mono);
  font-size: 0.88em;
  background: var(--bg-panel);
  border: 1px solid var(--border-subtle);
  padding: 0.1em 0.4em;
  border-radius: 4px;
}
.post-body pre code { background: none; border: 0; padding: 0; }

.post-body img {
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
}
.post-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 0 0 1.2rem;
  font-size: 0.94rem;
}
.post-body th, .post-body td {
  border: 1px solid var(--border-subtle);
  padding: 0.5rem 0.8rem;
  text-align: left;
}
.post-body th { background: var(--bg-panel); color: var(--text-primary); }

.post-foot { margin-top: 2.2rem; padding-top: 1.2rem; border-top: 1px solid var(--border-subtle); }

.post-nav { margin-top: 2rem; }
.post-nav a { font-weight: 500; }

/* ------------------------------ footer ----------------------------- */

.site-footer {
  border-top: 1px solid var(--border-subtle);
  padding-block: 2rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}
.footer-links { margin-top: 0.4rem; }
.footer-links a { color: var(--text-secondary); }

/* ==================================================================
   ADMIN
   ================================================================== */

.admin-page .container { width: min(1100px, 100% - 3rem); }

.auth-card {
  max-width: 420px;
  margin: clamp(2rem, 8vh, 5rem) auto 0;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 2rem 2rem 2.4rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.auth-card h1 { font-size: 1.5rem; letter-spacing: -0.01em; }
.muted { color: var(--text-muted); font-size: 0.9rem; }
.small { font-size: 0.8rem; margin-top: 0.4rem; }
.error { color: var(--danger); }
.notice {
  color: hsl(152, 65%, 58%);
  background: hsla(142, 71%, 45%, 0.1);
  border: 1px solid hsla(142, 71%, 45%, 0.35);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.9rem;
}

.admin-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  padding-block: 1.2rem;
}
.admin-bar h1 { font-size: 1.6rem; }
.admin-bar-right { display: flex; gap: 0.6rem; flex-wrap: wrap; }

.crumbs { margin-top: 1.5rem; font-size: 0.92rem; }
.crumbs a { color: var(--text-muted); }
.crumbs a:hover { color: var(--text-primary); }

.admin-section { margin-top: 2rem; }
.admin-section h2 {
  font-size: 1rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 0.8rem;
}

.admin-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.admin-table th, .admin-table td {
  border-bottom: 1px solid var(--border-subtle);
  padding: 0.6rem 0.7rem;
  text-align: left;
  vertical-align: middle;
}
.admin-table th { color: var(--text-muted); font-weight: 500; }
.admin-table td strong { color: var(--text-primary); }
.admin-table code {
  font-family: var(--mono);
  font-size: 0.82em;
  background: var(--bg-panel);
  padding: 0.1em 0.4em;
  border-radius: 4px;
}

.ta-r { text-align: right !important; }

.actions { white-space: nowrap; }
.actions form { display: inline-block; }
.inline-form { display: inline-block; }

/* ------------------------------ buttons ---------------------------- */

.btn {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 0.55rem 1.1rem;
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.2s ease;
}
.btn:hover { background: var(--accent-hover); text-decoration: none; color: #fff; }
.btn:active { transform: translateY(1px); }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: var(--border-bright);
  font-weight: 500;
}
.btn-ghost:hover { background: var(--bg-panel); color: var(--text-primary); }

.btn-xs { padding: 0.28rem 0.7rem; font-size: 0.8rem; border-radius: 6px; }

.btn-danger { background: transparent; color: var(--danger); border-color: hsla(350, 89%, 60%, 0.4); }
.btn-danger:hover { background: hsla(350, 89%, 60%, 0.15); color: var(--danger); }

/* ------------------------------ editor ----------------------------- */

.editor-section {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  margin-top: 1.2rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.editor-section h2 {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent);
}

label {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  font-size: 0.9rem;
  color: var(--text-secondary);
  font-weight: 500;
}

input[type="text"], input[type="url"], input[type="password"], textarea, select {
  background: var(--bg-input);
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.8rem;
  font-family: var(--font);
  font-size: 0.95rem;
  width: 100%;
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px hsla(217, 91%, 60%, 0.18);
}
textarea { resize: vertical; line-height: 1.6; }

.editor-area {
  font-family: var(--mono);
  font-size: 0.92rem;
  min-height: 340px;
}

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 640px) { .grid-2 { grid-template-columns: 1fr; } }

.hint { font-size: 0.8rem; color: var(--text-muted); }

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  padding-bottom: 0.6rem;
  border-bottom: 1px solid var(--border-subtle);
}
.tool {
  background: var(--bg-panel);
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  padding: 0.35rem 0.75rem;
  font-size: 0.8rem;
  cursor: pointer;
}
.tool:hover { background: var(--bg-input); color: var(--text-primary); }

.counters { display: flex; gap: 1rem; font-size: 0.8rem; color: var(--text-muted); }
.counters .warn { color: var(--danger); }

label .counter-chip {
  margin-left: auto;
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 400;
}
label .counter-chip.warn { color: var(--danger); }