/*
  Luigi De Matteis — Blog
  Visual system aligned with luigidematteis.github.io
*/

:root {
  color-scheme: dark;
  --black: #050607;
  --panel: #0a0c0e;
  --ink: #f5f7f7;
  --muted: #92999d;
  --dim: #656c70;
  --line: rgba(255, 255, 255, 0.16);
  --line-strong: rgba(255, 255, 255, 0.3);
  --green: #39ff14;
  --max: 1380px;
  --content: 720px;
  font-family: "Inter", Arial, sans-serif;
  font-synthesis: none;
  scroll-behavior: smooth;
}

*, *::before, *::after {
  box-sizing: border-box;
}

html {
  background: var(--black);
}

body {
  margin: 0;
  background: var(--black);
  color: var(--ink);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  line-height: 1.6;
}

body.menu-open {
  overflow: hidden;
}

body.menu-open .site-header {
  background: var(--black);
  border-color: var(--line);
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  color: inherit;
  font: inherit;
}

.skip-link {
  position: fixed;
  z-index: 100;
  top: 1rem;
  left: 1rem;
  padding: 0.75rem 1rem;
  background: var(--green);
  color: var(--black);
  transform: translateY(-200%);
}

.skip-link:focus {
  transform: none;
}

:focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 4px;
}

/* ---------- Header (portfolio-aligned) ---------- */
.site-header {
  position: fixed;
  z-index: 50;
  inset: 0 0 auto;
  display: flex;
  height: 86px;
  align-items: center;
  justify-content: space-between;
  padding: 0 clamp(1.25rem, 4vw, 4.5rem);
  border-bottom: 1px solid transparent;
  transition: height 0.25s, background 0.25s, border-color 0.25s;
}

.site-header.is-scrolled {
  height: 72px;
  background: rgba(5, 6, 7, 0.9);
  border-color: var(--line);
  backdrop-filter: blur(16px);
}

.brand {
  font-family: "Space Grotesk", sans-serif;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.12em;
}

.brand-dot {
  color: var(--green);
}

.site-nav {
  display: flex;
  align-items: center;
  gap: clamp(1.5rem, 3vw, 3.25rem);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.site-nav > a:not(.nav-cta) {
  position: relative;
  color: #c2c7ca;
}

.site-nav > a:not(.nav-cta)::after {
  position: absolute;
  right: 0;
  bottom: -7px;
  left: 0;
  height: 1px;
  background: var(--green);
  content: "";
  transform: scaleX(0);
  transform-origin: right;
  transition: transform 0.2s;
}

.site-nav > a:hover::after,
.site-nav > a.is-active::after {
  transform: scaleX(1);
  transform-origin: left;
}

.site-nav > a.is-active {
  color: var(--ink);
}

.nav-cta {
  padding: 0.75rem 1rem;
  border: 1px solid var(--line-strong);
  transition: 0.2s;
}

.nav-cta:hover {
  border-color: var(--green);
  background: var(--green);
  color: var(--black);
}

.menu-toggle {
  display: none;
  width: 42px;
  height: 42px;
  padding: 12px 8px;
  border: 0;
  background: transparent;
}

.menu-toggle span {
  display: block;
  height: 1px;
  margin: 5px 0;
  background: white;
  transition: transform 0.2s;
}

.menu-toggle[aria-expanded="true"] span:first-child {
  transform: translateY(3px) rotate(45deg);
}

.menu-toggle[aria-expanded="true"] span:last-child {
  transform: translateY(-3px) rotate(-45deg);
}

@media (max-width: 900px) {
  .site-header {
    height: 72px;
  }

  .menu-toggle {
    display: block;
    position: relative;
    z-index: 60;
  }

  .site-nav {
    position: fixed;
    z-index: 55;
    inset: 72px 0 0;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0;
    padding: 2rem 1.25rem;
    background: var(--black);
    transform: translateX(100%);
    transition: transform 0.25s;
  }

  .site-nav.is-open {
    transform: none;
  }

  .site-nav a {
    width: 100%;
    padding: 1.2rem 0;
    border-bottom: 1px solid var(--line);
    font-size: 0.85rem;
  }

  .site-nav > a:not(.nav-cta)::after {
    display: none;
  }

  .nav-cta {
    margin-top: 1rem;
    padding: 1.2rem !important;
    width: 100%;
    text-align: center;
  }
}

/* ---------- Main ---------- */
.site-main {
  max-width: var(--max);
  margin: 0 auto;
  padding: 7.5rem clamp(1.25rem, 4vw, 4.5rem) 4rem;
}

/* ---------- Blog hero ---------- */
.hero {
  position: relative;
  padding: clamp(2rem, 5vw, 4rem) 0 clamp(2.5rem, 5vw, 3.5rem);
  margin-bottom: clamp(2rem, 4vw, 3rem);
  border-bottom: 1px solid var(--line);
}

.hero::before {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.18;
  background-image:
    linear-gradient(var(--line) 1px, transparent 1px),
    linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: clamp(70px, 9vw, 120px) clamp(70px, 9vw, 120px);
  mask-image: linear-gradient(to bottom, black, transparent 85%);
  pointer-events: none;
}

.hero-title {
  position: relative;
  z-index: 1;
  margin: 0;
  font-family: "Space Grotesk", sans-serif;
  font-size: clamp(2.4rem, 5.5vw, 4.2rem);
  font-weight: 600;
  letter-spacing: -0.045em;
  line-height: 0.95;
}

.gradient-text {
  color: transparent;
  -webkit-text-stroke: 1px rgba(255, 255, 255, 0.76);
}

.hero-subtitle {
  position: relative;
  z-index: 1;
  max-width: 560px;
  margin: 1.25rem 0 0;
  color: var(--muted);
  font-size: clamp(1rem, 1.4vw, 1.15rem);
  line-height: 1.65;
}

/* ---------- Eyebrows ---------- */
.eyebrow {
  margin: 0 0 1.4rem;
  color: #b7bdc0;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.18em;
  line-height: 1.6;
  text-transform: uppercase;
}

/* ---------- Cards ---------- */
.posts-section {
  padding-bottom: clamp(3rem, 6vw, 5rem);
}

.cards {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0;
  border-top: 1px solid var(--line);
}

.card {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  padding: clamp(1.75rem, 3vw, 2.5rem) 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  border-radius: 0;
  transition: none;
}

.card:hover,
.card:focus-within {
  transform: none;
  box-shadow: none;
}

.card-head {
  display: flex;
  align-items: center;
  gap: 1.1rem;
}

.card h3 {
  margin: 0;
  font-family: "Space Grotesk", sans-serif;
  font-size: clamp(1.25rem, 2.2vw, 1.7rem);
  font-weight: 500;
  letter-spacing: -0.03em;
  color: var(--ink);
}

.card h3 a {
  text-decoration: none;
}

.card h3 a:hover {
  color: var(--green);
}

.card .meta {
  margin: 0.35rem 0 0;
  color: var(--dim);
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.card > p {
  margin: 0;
  max-width: 640px;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.7;
}

.card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  margin-top: 0.25rem;
  padding-top: 1rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.card-read-more {
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--line-strong);
  color: #c2c7ca;
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.card-read-more:hover {
  border-color: var(--green);
  color: var(--green);
}

/* ---------- Chips ---------- */
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
}

.chip {
  padding: 0.4rem 0.7rem;
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: transparent;
}

.chip:hover {
  border-color: var(--green);
  color: var(--green);
}

/* ---------- Icons ---------- */
.card-icon-container {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  overflow: hidden;
  background: var(--panel);
  border: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.card-icon-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.dot-icon {
  width: 52px;
  height: 52px;
  background-image: radial-gradient(circle, currentColor 1.3px, transparent 1.6px);
  background-size: 5px 5px;
  -webkit-mask-position: center;
  mask-position: center;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-size: contain;
  mask-size: contain;
  flex-shrink: 0;
  color: var(--green);
}

.dot-icon.cloud,
.dot-icon.code,
.dot-icon.lock,
.dot-icon.infinity {
  color: var(--green);
}

.dot-icon.cloud {
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='white' d='M7 18a4 4 0 01-.5-7.97A5 5 0 0117 9a4 4 0 010 8H8z'/%3E%3Cpath fill='none' stroke='white' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round' d='M12 10v7M9 14l3-3 3 3'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='white' d='M7 18a4 4 0 01-.5-7.97A5 5 0 0117 9a4 4 0 010 8H8z'/%3E%3Cpath fill='none' stroke='white' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round' d='M12 10v7M9 14l3-3 3 3'/%3E%3C/svg%3E");
}

.dot-icon.code {
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='none' stroke='white' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round' d='M8 4L2 12l6 8M16 4l6 8-6 8'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='none' stroke='white' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round' d='M8 4L2 12l6 8M16 4l6 8-6 8'/%3E%3C/svg%3E");
}

.dot-icon.lock {
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='none' stroke='white' stroke-width='2.2' d='M6 11V8a6 6 0 0112 0v3'/%3E%3Crect x='4' y='11' width='16' height='9' rx='2' fill='white'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='none' stroke='white' stroke-width='2.2' d='M6 11V8a6 6 0 0112 0v3'/%3E%3Crect x='4' y='11' width='16' height='9' rx='2' fill='white'/%3E%3C/svg%3E");
}

.dot-icon.infinity {
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none'%3E%3Cpath d='M12 12C9.2 8.5 7.5 6 4.5 6A5.5 5.5 0 1010 11.5c.8-1.2 1.5-2.2 2-3.2.5 1 1.2 2 2 3.2A5.5 5.5 0 1019.5 6c-3 0-4.7 2.5-7.5 6z' stroke='white' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none'%3E%3Cpath d='M12 12C9.2 8.5 7.5 6 4.5 6A5.5 5.5 0 1010 11.5c.8-1.2 1.5-2.2 2-3.2.5 1 1.2 2 2 3.2A5.5 5.5 0 1019.5 6c-3 0-4.7 2.5-7.5 6z' stroke='white' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

/* ---------- Post layout ---------- */
.post {
  max-width: var(--content);
  margin: 0 auto;
  padding: clamp(1rem, 3vw, 2rem) 0 clamp(3rem, 6vw, 5rem);
}

.post-header {
  margin-bottom: 2.75rem;
  text-align: left;
  padding-bottom: 1.75rem;
  border-bottom: 1px solid var(--line);
}

.post-header .eyebrow {
  margin-bottom: 1rem;
}

.post-title {
  margin: 0;
  font-family: "Space Grotesk", sans-serif;
  font-size: clamp(2rem, 4.5vw, 3.2rem);
  font-weight: 600;
  letter-spacing: -0.04em;
  line-height: 1.05;
  color: var(--ink);
}

.post-header .chips {
  margin-top: 1.25rem;
}

.post-hero-image {
  margin-bottom: 2.5rem;
  overflow: hidden;
  border: 1px solid var(--line);
}

.post-hero-image img {
  width: 100%;
  height: auto;
  max-height: 400px;
  object-fit: cover;
  display: block;
}

.post-body {
  font-size: 1.02rem;
  line-height: 1.75;
  color: var(--muted);
}

.post-body h2 {
  margin: 2.5rem 0 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--line);
  font-family: "Space Grotesk", sans-serif;
  font-size: clamp(1.4rem, 2.4vw, 1.75rem);
  font-weight: 500;
  letter-spacing: -0.03em;
  color: var(--ink);
}

.post-body h3 {
  margin: 2rem 0 0.75rem;
  font-family: "Space Grotesk", sans-serif;
  font-size: 1.2rem;
  font-weight: 500;
  color: var(--ink);
}

.post-body p {
  margin: 0 0 1.35rem;
}

.post-body a {
  color: var(--green);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: rgba(57, 255, 20, 0.35);
}

.post-body a:hover {
  text-decoration-color: var(--green);
}

.post-body strong {
  color: #d5dad7;
  font-weight: 600;
}

.post-body blockquote {
  margin: 1.75rem 0;
  padding: 0.75rem 0 0.75rem 1.25rem;
  border-left: 2px solid var(--green);
  color: var(--muted);
  font-style: italic;
}

.post-body ul,
.post-body ol {
  margin: 0 0 1.35rem;
  padding-left: 1.25rem;
}

.post-body li {
  margin-bottom: 0.45rem;
}

.post-body code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.88em;
  padding: 0.15rem 0.35rem;
  border: 1px solid var(--line);
  background: var(--panel);
  color: #c7cfca;
}

.post-body pre {
  margin: 1.75rem 0;
  padding: 1.15rem 1.25rem;
  overflow-x: auto;
  border: 1px solid var(--line);
  background: var(--panel);
}

.post-body pre code {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  font-size: 0.88rem;
}

.post-body hr {
  border: 0;
  height: 1px;
  margin: 2.5rem 0;
  background: var(--line);
}

.post-footer {
  margin-top: 3.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--line);
}

.back-link {
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--line-strong);
  color: #c2c7ca;
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.back-link:hover {
  border-color: var(--green);
  color: var(--green);
}

.no-posts {
  color: var(--muted);
}

/* ---------- Footer ---------- */
footer {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 2rem;
  align-items: center;
  padding: 2rem clamp(1.25rem, 4vw, 4.5rem);
  border-top: 1px solid var(--line);
  color: #757c80;
  font-size: 0.6rem;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

footer p {
  margin: 0;
}

footer p:last-child {
  text-align: right;
}

footer div {
  display: flex;
  gap: 1.5rem;
}

footer a:hover {
  color: var(--green);
}

@media (max-width: 900px) {
  footer {
    grid-template-columns: 1fr auto;
  }

  footer p:last-child {
    display: none;
  }
}

@media (max-width: 620px) {
  .site-main {
    padding-top: 6.5rem;
  }

  .card-footer {
    flex-direction: column;
    align-items: flex-start;
  }

  footer {
    grid-template-columns: 1fr;
  }

  footer div {
    grid-row: 1;
  }

  footer p {
    grid-row: 2;
  }
}

@media (prefers-reduced-motion: reduce) {
  :root {
    scroll-behavior: auto;
  }

  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
