/* Verkstad – tema för 3dskrivarebloggen.se */

/* Typsnitten ligger lokalt (latin-delmängd, OFL-licens) så att inga anrop går till Google. */
@font-face {
  font-family: "Inter"; font-style: normal; font-weight: 400 700; font-display: swap;
  src: url("../fonts/inter-latin-v20.woff2") format("woff2");
}
@font-face {
  font-family: "PT Mono"; font-style: normal; font-weight: 400; font-display: swap;
  src: url("../fonts/ptmono-latin-v14.woff2") format("woff2");
}

:root {
  --bg: #111316;
  --surface: #1a1d22;
  --surface-2: #14171b;
  --deep: #0d0f12;
  --line: #2a2f36;
  --text: #f2f4f7;
  --muted: #9aa3ad;
  --dim: #6b737d;
  --body: #c9cfd6;
  --accent: #ff6b2c;
  --accent-2: #c6f432;
  --on-accent: #111316;

  --c-projekt: #ff6b2c;
  --c-material: #c6f432;
  --c-guide: #5ec8ff;
  --c-mjukvara: #b18cff;
  --c-teknik: #ffd23f;

  --sans: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "PT Mono", ui-monospace, Menlo, monospace;
  --wrap: 1200px;
  --radius: 14px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
img, svg { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
a:focus-visible, button:focus-visible, input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 6px;
}

.wrap { width: min(var(--wrap), 100% - 48px); margin-inline: auto; }
.mono { font-family: var(--mono); }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 10;
  background: rgba(13, 15, 18, .92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.site-header .wrap {
  display: flex; align-items: center; justify-content: space-between;
  gap: 24px; height: 76px;
}
.logo { display: flex; align-items: center; gap: 12px; font-weight: 700; font-size: 18px; }
.logo em { font-style: normal; color: var(--accent); }
.logo-icon {
  width: 36px; height: 36px; border-radius: 8px; background: var(--accent);
  display: grid; place-content: center; gap: 3px; justify-items: center;
}
.logo-icon i { display: block; height: 3px; border-radius: 1px; background: var(--on-accent); }
.logo-icon i:nth-child(1) { width: 16px; }
.logo-icon i:nth-child(2) { width: 20px; }
.logo-icon i:nth-child(3) { width: 24px; }

.header-right { display: flex; align-items: center; gap: 40px; }
.main-nav ul { display: flex; gap: 32px; list-style: none; margin: 0; padding: 0; }
.main-nav a { color: var(--muted); font-weight: 500; font-size: 15px; transition: color .15s; }
.main-nav a:hover, .main-nav a[aria-current] { color: var(--text); }

.search {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; min-width: 210px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
  color: var(--dim); font: 14px var(--sans); cursor: pointer;
}
.search-icon { flex: none; }
.search kbd { font: 12px var(--mono); color: var(--dim); margin-left: auto; padding-left: 24px; }
.search:hover { border-color: #3a414a; color: var(--muted); }

.menu-toggle {
  display: none; place-items: center; padding: 0; background: none;
  border: 1px solid var(--line); border-radius: 10px;
  width: 44px; height: 44px; color: var(--text); cursor: pointer;
}
.menu-icon, .menu-icon::before, .menu-icon::after {
  display: block; width: 18px; height: 2px; border-radius: 1px; background: currentColor;
  transition: transform .2s, opacity .2s;
}
.menu-icon { position: relative; }
.menu-icon::before, .menu-icon::after { content: ""; position: absolute; left: 0; }
.menu-icon::before { top: -6px; }
.menu-icon::after { top: 6px; }
/* Turns into an X when the menu is open */
.menu-toggle[aria-expanded="true"] .menu-icon { background: transparent; }
.menu-toggle[aria-expanded="true"] .menu-icon::before { transform: translateY(6px) rotate(45deg); }
.menu-toggle[aria-expanded="true"] .menu-icon::after { transform: translateY(-6px) rotate(-45deg); }

/* ---------- Common bits ---------- */
.kicker {
  font: 700 14px var(--mono); letter-spacing: .14em; color: var(--accent);
  text-transform: uppercase; margin: 0;
}
.tag {
  display: inline-flex; align-items: center; gap: 8px;
  font: 700 12px var(--mono); letter-spacing: .08em; text-transform: uppercase;
  color: var(--cat, var(--accent));
}
.tag::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
/* Kategorifärgen sätts per tagg med style="--cat: #rrggbb" (fältet color i tags). */

.meta { font: 12px var(--mono); letter-spacing: .04em; color: var(--dim); text-transform: uppercase; }

.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 12px 20px; border-radius: 10px; border: 1px solid transparent;
  font: 600 15px var(--sans); cursor: pointer; transition: transform .15s, filter .15s;
}
.btn:hover { transform: translateY(-1px); filter: brightness(1.08); }
.btn-accent { background: var(--accent); color: var(--on-accent); }
.btn-lime { background: var(--accent-2); color: var(--on-accent); }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--line); }

/* Genererad illustration "utskrivet lager för lager", när inlägget saknar banner */
.art {
  position: relative; overflow: hidden;
  --art-a: color-mix(in srgb, var(--cat, var(--accent)) 10%, var(--bg));
  --art-b: color-mix(in srgb, var(--cat, var(--accent)) 18%, var(--bg));
  background: linear-gradient(var(--art-a), var(--art-b));
}
.art svg { width: 100%; height: 100%; }

/* ---------- Hero ---------- */
.hero {
  background: linear-gradient(#1b1511, var(--bg));
  padding: 96px 0 56px;
}
.hero h1 {
  font-size: clamp(40px, 6vw, 68px); line-height: 1.1; letter-spacing: -.022em;
  margin: 24px 0; font-weight: 700;
}
.hero .lead { color: var(--muted); font-size: 20px; line-height: 1.55; max-width: 620px; margin: 0; }

.filters { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 40px; }
.pill {
  padding: 8px 16px; border-radius: 999px; border: 1px solid var(--line);
  background: transparent; color: var(--muted); font: 500 14px var(--sans); cursor: pointer;
  transition: border-color .15s, color .15s;
}
.pill:hover { color: var(--text); border-color: #3a414a; }
.pill[aria-pressed="true"], .pill[aria-current] { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 600; }

/* ---------- Featured ---------- */
.featured {
  display: grid; grid-template-columns: 55fr 45fr;
  background: var(--surface); border: 1px solid var(--line); border-radius: 18px; overflow: hidden;
}
.featured .art { min-height: 420px; }
.featured-body { padding: 48px; display: flex; flex-direction: column; justify-content: center; gap: 18px; }
.featured-body h2 { font-size: 34px; line-height: 1.24; letter-spacing: -.015em; margin: 0; }
.featured-body h2 a:hover { color: var(--accent); }
.featured-body p { color: var(--muted); font-size: 17px; line-height: 1.6; margin: 0; }
.badges { display: flex; align-items: center; gap: 14px; }
.badge {
  background: var(--accent-2); color: var(--on-accent);
  font: 700 12px var(--mono); letter-spacing: .08em; padding: 5px 10px; border-radius: 6px;
}
.featured-body .btn { align-self: flex-start; margin-top: 6px; }

/* ---------- Post grid ---------- */
.posts { padding-bottom: 96px; }
.section-head {
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  margin: 56px 0 24px;
}
.section-head h2 { font-size: 28px; margin: 0; }

.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; }
.card {
  display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; transition: border-color .2s, transform .2s;
}
.card:hover { border-color: var(--cat, var(--accent)); transform: translateY(-3px); }
.card .art { aspect-ratio: 16 / 9; }
.card-body { padding: 24px; display: flex; flex-direction: column; gap: 12px; flex: 1; }
.card h3 { font-size: 21px; line-height: 1.33; margin: 0; }
.card p { color: var(--muted); font-size: 15px; line-height: 1.55; margin: 0; flex: 1; }
.card[hidden] { display: none; }

.more { display: flex; justify-content: center; margin-top: 40px; }

/* ---------- Newsletter ---------- */
.newsletter {
  display: flex; align-items: center; justify-content: space-between; gap: 32px; flex-wrap: wrap;
  padding: 48px 56px; margin-bottom: 96px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 18px;
}
.newsletter .kicker { color: var(--accent-2); font-size: 13px; }
.newsletter h2 { font-size: 32px; margin: 10px 0; }
.newsletter p { color: var(--muted); margin: 0; }
.newsletter form { display: flex; gap: 10px; flex-wrap: wrap; }
.newsletter input {
  width: 320px; max-width: 100%; padding: 14px 16px; border-radius: 10px;
  background: var(--bg); border: 1px solid var(--line); color: var(--text); font: 15px var(--sans);
}
.newsletter input::placeholder { color: var(--dim); }

/* ---------- Footer ---------- */
.site-footer { background: #0b0c0e; padding: 64px 0 40px; }
.footer-top { display: flex; justify-content: space-between; gap: 48px; flex-wrap: wrap; }
.footer-top p { color: var(--muted); line-height: 1.6; margin: 20px 0 0; max-width: 340px; }
.footer-cols { display: flex; gap: 96px; }
.footer-cols h3 { font: 700 12px var(--mono); letter-spacing: .1em; color: var(--dim); margin: 0 0 14px; }
.footer-cols ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }
.footer-cols a:hover { color: var(--accent); }
.footer-bottom {
  display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  margin-top: 40px; padding-top: 40px; border-top: 1px solid var(--line);
  color: var(--dim); font-size: 14px;
}
.footer-bottom .mono { font-size: 12px; }

/* ---------- Post page ---------- */
.post-top { padding: 64px 0 48px; }
.crumbs { font: 13px var(--mono); letter-spacing: .08em; color: var(--dim); text-transform: uppercase; }
.crumbs a:hover { color: var(--text); }
.post-top .tag { margin-top: 20px; }
.post-top h1 {
  font-size: clamp(36px, 5vw, 60px); line-height: 1.13; letter-spacing: -.025em;
  margin: 16px 0 20px; max-width: 900px;
}
.post-top .lead { color: var(--muted); font-size: 21px; line-height: 1.52; max-width: 820px; margin: 0; }
.byline { display: flex; align-items: center; gap: 12px; margin-top: 28px; }
.avatar {
  width: 40px; height: 40px; border-radius: 50%; background: var(--accent); color: var(--on-accent);
  display: grid; place-items: center; font-weight: 700; font-size: 14px;
}
.byline strong { display: block; font-size: 15px; font-weight: 600; }


.post-layout {
  display: grid; grid-template-columns: minmax(0, 760px) 340px; justify-content: space-between;
  gap: 48px; padding: 64px 0;
}
.prose { font-size: 18px; line-height: 1.72; color: var(--body); min-width: 0; }
.prose > * { margin: 0 0 22px; }
.prose h2 {
  color: var(--text); font-size: 30px; line-height: 1.27; letter-spacing: -.013em;
  margin-top: 48px; scroll-margin-top: 100px;
}
.prose h3 { color: var(--text); font-size: 21px; line-height: 1.33; margin-top: 32px; }
.prose a { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
.prose ul { padding-left: 1.2em; }
.prose li::marker { color: var(--accent); }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; }
.compare { width: 100%; border-collapse: collapse; font-size: 15px; line-height: 1.4; }
.compare th, .compare td { padding: 14px 20px; text-align: left; }
.compare thead th { font: 700 13px var(--mono); letter-spacing: .06em; color: var(--dim); background: var(--surface); }
.compare thead th:nth-child(2) { color: var(--accent); }
.compare thead th:nth-child(3) { color: var(--accent-2); }
.compare tbody th { color: var(--muted); font-weight: 500; }
.compare tbody td { color: var(--text); }
.compare tbody tr:nth-child(odd) { background: var(--surface-2); }
.compare tbody tr:nth-child(even) { background: var(--surface); }

.tip {
  display: flex; gap: 20px; align-items: baseline;
  padding: 20px 24px; border-radius: 12px; background: var(--accent-2); color: var(--on-accent);
  font-size: 16px; font-weight: 500; line-height: 1.55;
}
.tip b { font: 700 12px var(--mono); letter-spacing: .08em; flex: none; }

.sidebar { display: flex; flex-direction: column; gap: 20px; }
.sidebar-sticky { position: sticky; top: 100px; display: flex; flex-direction: column; gap: 20px; }
.box { padding: 24px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.box h2 { font: 700 12px var(--mono); letter-spacing: .12em; color: var(--dim); margin: 0 0 16px; }
.toc ol { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.toc a {
  display: block; padding: 5px 0 5px 14px; border-left: 2px solid var(--line);
  color: var(--muted); font-size: 15px; font-weight: 500;
}
.toc a:hover { color: var(--text); }
.toc a.active { color: var(--text); border-color: var(--accent); }

.specs { background: var(--deep); }
.specs h2 { color: var(--accent); }
.specs dl { margin: 0; display: grid; gap: 12px; font: 13px var(--mono); }
.specs dl div { display: flex; justify-content: space-between; gap: 16px; }
.specs dt { color: var(--dim); }
.specs dd { margin: 0; color: var(--text); font-weight: 700; }

.related { border-top: 1px solid var(--line); padding: 48px 0 96px; }
.related h2 { font-size: 28px; margin: 0 0 24px; }

/* ---------- Tomt läge ---------- */
.empty {
  padding: 64px 32px; text-align: center;
  border: 1px dashed var(--line); border-radius: var(--radius); color: var(--muted);
}
.empty .mono { display: block; margin-bottom: 12px; color: var(--dim); font-size: 13px; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .header-right { gap: 24px; }
  .main-nav ul { gap: 20px; }
  .search { min-width: 0; width: 44px; height: 44px; padding: 0; justify-content: center; }
  .search .label, .search kbd { display: none; }
  .grid { grid-template-columns: repeat(2, 1fr); }
  .post-layout { grid-template-columns: minmax(0, 1fr); }
  .sidebar { order: -1; }
  .sidebar-sticky { position: static; display: grid; grid-template-columns: 1fr 1fr; }
}
@media (max-width: 860px) {
  .menu-toggle { display: grid; }
  .search { display: none; }
  .main-nav {
    display: none; position: absolute; left: 0; right: 0; top: 76px;
    background: var(--deep); border-bottom: 1px solid var(--line); padding: 8px 24px 20px;
  }
  .main-nav.open { display: block; }
  .main-nav ul { flex-direction: column; gap: 0; }
  .main-nav a { display: block; padding: 12px 0; font-size: 17px; border-bottom: 1px solid var(--line); }
  .featured { grid-template-columns: 1fr; }
  .featured .art { min-height: 0; aspect-ratio: 16 / 9; }
  .featured-body { padding: 28px; }
  .featured-body h2 { font-size: 26px; }
  .newsletter { padding: 32px 28px; }
  .footer-cols { gap: 56px; }
}
@media (max-width: 640px) {
  .hero { padding: 56px 0 40px; }
  .hero .lead, .post-top .lead { font-size: 18px; }
  .grid { grid-template-columns: 1fr; }
  .filters { gap: 8px; margin-top: 32px; }
  .pill { padding: 7px 14px; font-size: 13px; }
  .sidebar-sticky { grid-template-columns: 1fr; }
  .prose { font-size: 17px; }
  .prose h2 { font-size: 25px; }
  .tip { flex-direction: column; gap: 8px; }
  .newsletter input { width: 100%; }
  .newsletter form, .newsletter form .btn { width: 100%; justify-content: center; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; scroll-behavior: auto !important; }
}

/* ---------- Tillägg för CMS:et ---------- */
/* Bannerbilder i stället för genererad illustration */
.thumb { position: relative; overflow: hidden; background: var(--deep); }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.card .thumb { aspect-ratio: 16 / 9; }
.featured .thumb { height: 100%; min-height: 420px; }
.featured > a { display: block; }

/* Nyare/Äldre */
.pager { display: flex; justify-content: space-between; gap: 16px; margin-top: 40px; }

/* Inlägg utan innehållsförteckning */
.post-layout.no-aside { grid-template-columns: minmax(0, 760px); }

/* Markdown-innehåll: bilder, tabeller, kod och citat */
.prose img { height: auto; border-radius: 12px; margin-inline: auto; }
.prose h4 { color: var(--text); font-size: 18px; margin-top: 28px; }
.prose ol { padding-left: 1.4em; }
.prose ol li::marker { color: var(--accent); font-family: var(--mono); }
.prose strong { color: var(--text); }
.prose hr { border: 0; border-top: 1px solid var(--line); margin: 40px 0; }
.prose blockquote {
  margin-inline: 0; padding: 4px 0 4px 20px;
  border-left: 3px solid var(--accent); color: var(--muted);
}
.prose code {
  font: .88em var(--mono); background: var(--surface); border: 1px solid var(--line);
  border-radius: 6px; padding: .1em .35em; color: var(--text);
}
.prose pre {
  overflow-x: auto; padding: 18px 20px; line-height: 1.55;
  background: var(--deep); border: 1px solid var(--line); border-radius: 12px;
}
.prose pre code { background: none; border: 0; padding: 0; font-size: 14px; }
.prose table {
  display: block; overflow-x: auto; width: 100%; border-collapse: collapse;
  font-size: 15px; line-height: 1.4; border: 1px solid var(--line); border-radius: 12px;
}
.prose th, .prose td { padding: 12px 18px; text-align: left; }
.prose thead th { font: 700 13px var(--mono); letter-spacing: .06em; color: var(--dim); background: var(--surface); }
.prose tbody tr:nth-child(odd) { background: var(--surface-2); }
.prose tbody tr:nth-child(even) { background: var(--surface); }
.prose tbody td { color: var(--text); }

/* 404 */
.notfound { padding-bottom: 120px; }
.notfound .mono { color: var(--dim); font-size: 13px; margin: 28px 0 0; }
.notfound .actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 32px; }

@media (max-width: 860px) {
  .featured .thumb { min-height: 0; aspect-ratio: 16 / 9; }
}
@media (max-width: 640px) {
}

/* Granskningsbanner (admin) */
.review-banner { background: var(--accent-2); color: var(--on-accent); font-size: 14px; }
.review-banner .wrap { display: flex; gap: 16px; align-items: baseline; padding: 12px 0; flex-wrap: wrap; }
.review-banner b { font: 700 12px var(--mono); letter-spacing: .1em; }

/* Bilder med bildtext (<figure>), som i de importerade Hugo-inläggen */
.prose figure { margin: 32px 0; text-align: center; }
.prose figure img { margin-inline: auto; max-width: min(700px, 100%); }
.prose figcaption { margin-top: 10px; color: var(--dim); font-size: 14px; line-height: 1.5; }

/* Inläggssidan utan banner: tunn linje mellan ingress och text i stället för bilden */
.post-top { padding-bottom: 40px; }
.post-top + .post-layout { border-top: 1px solid var(--line); padding-top: 48px; }
