/* ============================================================
   martin-jensen.dk — simple tech, light blue
   Pale blue ground, white surfaces, navy ink, one clear blue.
   ============================================================ */

/* ---------- Design tokens ---------- */

:root {
  color-scheme: light;

  --bg:        #e9f1f7;   /* pale blue paper       */
  --surface:   #fbfdfe;
  --ink:       #12283a;
  --ink-soft:  #33495c;
  --muted:     #5b7188;
  --line:      #c7d8e5;
  --line-soft: #dbe7f0;
  --code-bg:   #eef4f9;

  --accent:        #2f80d6;
  --accent-strong: #1b5fa8;
  --accent-ink:    #ffffff;

  --font-display: "Familjen Grotesk", "Segoe UI", sans-serif;
  --font-body:    "Instrument Sans", "Segoe UI", sans-serif;
  --font-mono:    "Spline Sans Mono", "SFMono-Regular", Consolas, monospace;

  --wrap: 62rem;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg:        #0e1722;
    --surface:   #16202c;
    --ink:       #dce8f2;
    --ink-soft:  #b3c6d8;
    --muted:     #8aa0b5;
    --line:      #24374c;
    --line-soft: #1c2c3f;
    --code-bg:   #121d2a;

    --accent:        #6ab3f5;
    --accent-strong: #8ec5f8;
    --accent-ink:    #0a1622;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg:        #0e1722;
  --surface:   #16202c;
  --ink:       #dce8f2;
  --ink-soft:  #b3c6d8;
  --muted:     #8aa0b5;
  --line:      #24374c;
  --line-soft: #1c2c3f;
  --code-bg:   #121d2a;

  --accent:        #6ab3f5;
  --accent-strong: #8ec5f8;
  --accent-ink:    #0a1622;
}

/* ---------- Base ---------- */

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background-color: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 1.0625rem;
  line-height: 1.7;
  display: flex;
  min-height: 100vh;
  flex-direction: column;
}

main { flex: 1; }

.wrap {
  max-width: var(--wrap);
  margin: 0 auto;
  padding: 0 1.5rem;
}

.mono {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  letter-spacing: 0.01em;
}

h1, h2, h3 {
  font-family: var(--font-display);
  line-height: 1.12;
  margin: 0;
  letter-spacing: -0.015em;
  text-wrap: balance;
}

a { color: var(--accent-strong); text-underline-offset: 3px; }

a:hover { color: var(--ink); }

::selection { background: var(--accent); color: var(--accent-ink); }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 3px;
}

kbd {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 4px;
  background: var(--surface);
  padding: 0.08em 0.4em;
  color: var(--muted);
}

.skip-link {
  position: absolute;
  left: 1rem;
  top: -3rem;
  z-index: 300;
  background: var(--accent);
  color: var(--accent-ink);
  padding: 0.5rem 1rem;
  border-radius: 6px;
  text-decoration: none;
  font-weight: 600;
  transition: top 0.15s ease;
}

.skip-link:focus { top: 1rem; color: var(--accent-ink); }

/* ---------- Header ---------- */

.site-header {
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 82%, var(--surface));
  position: sticky;
  top: 0;
  z-index: 50;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 3.7rem;
}

.brand {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.08rem;
  color: var(--ink);
  text-decoration: none;
}

.brand:hover { color: var(--ink); }

.brand .tld { color: var(--accent-strong); }

.site-nav {
  display: flex;
  align-items: center;
  gap: 1.2rem;
}

.site-nav a {
  text-decoration: none;
  font-weight: 500;
  font-size: 0.95rem;
  color: var(--muted);
  padding: 0.25rem 0;
  border-bottom: 2px solid transparent;
}

.site-nav a:hover { color: var(--ink); }

.site-nav a[aria-current="page"] {
  color: var(--ink);
  border-bottom-color: var(--accent);
}

.cmdk-hint {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  color: var(--muted);
  padding: 0.35rem 0.65rem;
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease;
}

.cmdk-hint:hover {
  border-color: var(--accent);
  color: var(--ink);
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  color: var(--ink-soft);
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease;
}

.theme-toggle:hover {
  border-color: var(--accent);
  color: var(--accent-strong);
}

/* sun shows in dark mode (click → light), moon in light mode */
.icon-sun { display: none; }
.icon-moon { display: block; }

:root[data-theme="dark"] .icon-sun { display: block; }
:root[data-theme="dark"] .icon-moon { display: none; }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .icon-sun { display: block; }
  :root:not([data-theme="light"]) .icon-moon { display: none; }
}

/* ---------- Hero ---------- */

.hero { border-bottom: 1px solid var(--line); }

.hero > .wrap {
  padding-top: 5rem;
  padding-bottom: 4rem;
}

.eyebrow {
  color: var(--muted);
  margin: 0 0 1.1rem;
}

.hero h1,
.page-head h1 {
  font-size: clamp(2.2rem, 5.4vw, 3.6rem);
  font-weight: 700;
}

.hero-sub {
  color: var(--ink-soft);
  font-size: 1.125rem;
  max-width: 34rem;
  margin: 1.3rem 0 1.8rem;
}

.hero-cta {
  display: inline-block;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.98rem;
  text-decoration: none;
  background: var(--accent);
  color: var(--accent-ink);
  padding: 0.7rem 1.4rem;
  border-radius: 8px;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}

.hero-cta:hover {
  color: var(--accent-ink);
  transform: translateY(-2px);
  box-shadow: 0 8px 20px color-mix(in srgb, var(--accent) 30%, transparent);
}

/* ---------- Page head (blog / post) ---------- */

.page-head { border-bottom: 1px solid var(--line); }

.page-head .wrap {
  padding-top: 3.5rem;
  padding-bottom: 3rem;
}

.head-tag {
  color: var(--accent-strong);
  margin-left: 0.9rem;
}

/* ---------- Post list ---------- */

.log-section .wrap {
  padding-top: 3rem;
  padding-bottom: 3.5rem;
}

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.8rem;
}

.section-title {
  font-size: 1.3rem;
  font-weight: 600;
}

.section-count { color: var(--muted); }

.post-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.post-entry {
  position: relative;
  display: grid;
  grid-template-columns: 7.5rem 1fr;
  gap: 1.5rem;
  padding: 1.5rem 1.1rem;
  margin: 0 -1.1rem;
  border-radius: 10px;
  border-bottom: 1px solid var(--line-soft);
  transition: background-color 0.15s ease, box-shadow 0.15s ease;
}

.post-entry:last-child { border-bottom-color: transparent; }

.post-entry:hover {
  background: var(--surface);
  box-shadow: 0 6px 18px rgba(15, 40, 60, 0.08);
}

.post-date {
  color: var(--muted);
  padding-top: 0.4rem;
  white-space: nowrap;
}

.post-title {
  font-size: 1.22rem;
  font-weight: 600;
}

.post-title a {
  color: var(--ink);
  text-decoration: none;
}

.post-title a:hover { color: var(--accent-strong); }

/* stretch the whole row into the link's click target */
.post-title a::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 10px;
}

.post-excerpt {
  color: var(--ink-soft);
  font-size: 0.99rem;
  max-width: 40rem;
  margin: 0.5rem 0 0;
}

.tag-list {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin: 0.8rem 0 0;
  padding: 0;
  color: var(--muted);
}

.tag-list li {
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--accent) 7%, var(--surface));
  border-radius: 5px;
  padding: 0.05rem 0.55rem;
}

.all-posts-link {
  margin: 2rem 0 0;
  font-weight: 500;
}

.year-group + .year-group { margin-top: 2.6rem; }

/* ---------- Post page ---------- */

.read-progress {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left;
  z-index: 60;
}

.post-page > .wrap {
  padding-top: 3rem;
  padding-bottom: 4rem;
}

.post-content { max-width: 42rem; }

.post-content h2 {
  font-size: 1.35rem;
  font-weight: 600;
  margin: 2.4rem 0 0.9rem;
  padding-bottom: 0.35rem;
  border-bottom: 2px solid color-mix(in srgb, var(--accent) 35%, transparent);
  display: inline-block;
}

.post-content p { margin: 0 0 1.2rem; }

.post-content figure { margin: 1.6rem 0; }

.post-content figure img {
  display: block;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.post-content figcaption {
  color: var(--muted);
  margin-top: 0.5rem;
}

.post-content code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  background: var(--code-bg);
  border: 1px solid var(--line-soft);
  border-radius: 4px;
  padding: 0.1em 0.35em;
}

.post-content pre {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 1.1rem 1.3rem;
  overflow-x: auto;
  margin: 0 0 1.4rem;
  line-height: 1.6;
}

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

/* ---------- About ---------- */

.about-section {
  border-top: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 55%, transparent);
}

.about-grid {
  display: grid;
  grid-template-columns: minmax(8rem, 13rem) 1fr;
  gap: 3rem;
  padding-top: 3.2rem;
  padding-bottom: 3.2rem;
}

.about-text {
  max-width: 38rem;
  color: var(--ink-soft);
}

.about-text p { margin: 0 0 1.1rem; }
.about-text p:last-child { margin-bottom: 0; }

/* ---------- Footer ---------- */

.site-footer { border-top: 1px solid var(--line); }

.footer-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  padding-top: 1.5rem;
  padding-bottom: 1.5rem;
  color: var(--muted);
}

/* ---------- Systems ---------- */

.system-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(20rem, 1fr));
  gap: 1.1rem;
}

.system-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 1.4rem 1.5rem 1.3rem;
  display: flex;
  flex-direction: column;
}

.system-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
}

.system-name {
  font-size: 1.25rem;
  font-weight: 600;
}

.system-name a {
  color: var(--ink);
  text-decoration: none;
}

.system-name a:hover {
  color: var(--accent-strong);
  text-decoration: underline;
  text-underline-offset: 4px;
}

.badge {
  border-radius: 5px;
  padding: 0.1rem 0.55rem;
  white-space: nowrap;
}

.badge-free {
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--accent) 9%, var(--surface));
  color: var(--accent-strong);
}

.badge-paid {
  background: var(--accent);
  color: var(--accent-ink);
}

.system-desc {
  color: var(--ink-soft);
  margin: 0.7rem 0 0;
}

.system-links {
  display: flex;
  flex-wrap: wrap;
  gap: 1.4rem;
  margin-top: 1.1rem;
  font-weight: 500;
  font-size: 0.95rem;
}

.empty-state {
  border: 1px dashed var(--line);
  border-radius: 10px;
  padding: 2rem 1.6rem;
  color: var(--ink-soft);
  max-width: 40rem;
}

.empty-state p { margin: 0; }

/* ---------- Command palette ---------- */

.cmdk {
  position: fixed;
  inset: 0;
  z-index: 200;
}

body.cmdk-open { overflow: hidden; }

.cmdk-backdrop {
  position: absolute;
  inset: 0;
  background: color-mix(in srgb, var(--bg) 55%, transparent);
  backdrop-filter: blur(4px);
}

.cmdk-box {
  position: relative;
  width: min(34rem, 92vw);
  margin: 12vh auto 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 24px 60px rgba(10, 30, 50, 0.28);
}

.cmdk-input-row {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.9rem 1.1rem;
  border-bottom: 1px solid var(--line-soft);
}

.cmdk-prompt { color: var(--accent-strong); }

#cmdk-input {
  flex: 1;
  border: none;
  background: none;
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 1rem;
  outline: none;
}

#cmdk-input::placeholder { color: var(--muted); }

.cmdk-list {
  list-style: none;
  margin: 0;
  padding: 0.4rem;
  max-height: 46vh;
  overflow-y: auto;
}

.cmdk-list a {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.6rem 0.8rem;
  text-decoration: none;
  color: var(--ink);
  border-radius: 7px;
}

.cmdk-list li.active a {
  background: color-mix(in srgb, var(--accent) 13%, var(--surface));
}

.cmdk-title { font-weight: 500; }
.cmdk-date { color: var(--muted); flex: none; }

.cmdk-empty {
  margin: 0;
  padding: 1rem 1.2rem;
  color: var(--muted);
}

/* ---------- Responsive ---------- */

@media (max-width: 46rem) {
  .header-inner {
    height: auto;
    min-height: 3.7rem;
    flex-wrap: wrap;
    padding: 0.55rem 0;
    row-gap: 0.2rem;
  }

  .site-nav {
    flex-wrap: wrap;
    gap: 0.85rem;
  }

  .site-nav a { font-size: 0.9rem; }

  .hero > .wrap {
    padding-top: 3.5rem;
    padding-bottom: 3rem;
  }

  .post-entry {
    grid-template-columns: 1fr;
    gap: 0.35rem;
    padding: 1.25rem 1.1rem;
  }

  .post-date { padding-top: 0; }

  .about-grid {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }

  .cmdk-hint-keys { display: none; }

  .cmdk-box { margin-top: 8vh; }
}

/* ---------- Reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-delay: 0ms !important;
    transition-duration: 0.01ms !important;
  }
}
