/* ------------------------------------------------
   Tekhaus - Dark + pastel palette
   ------------------------------------------------ */

/* Space Grotesk - self-hosted, SIL Open Font License */
@font-face {
  font-family: "Space Grotesk";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("/fonts/space-grotesk-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6,
    U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122,
    U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "Space Grotesk";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("/fonts/space-grotesk-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7,
    U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F,
    U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F,
    U+A720-A7FF;
}

:root {
  --bg-primary: #0d0d1a;
  --bg-secondary: #151526;
  --bg-card: #1c1c33;
  --bg-card-hover: #22223d;
  --text-primary: #e4e4ef;
  --text-secondary: #9d9db5;
  --text-heading: #f0f0f8;
  --accent-lavender: #b8a9d4;
  --accent-mint: #8ecdb8;
  --accent-peach: #e8b89d;
  --accent-blue: #8badc4;
  --border: #2a2a42;
  --border-light: #35355a;
  --font-sans: "Space Grotesk", -apple-system, BlinkMacSystemFont, "Segoe UI",
    Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  --font-mono: "SF Mono", "Fira Code", "Fira Mono", Menlo, Consolas, monospace;
  --max-width: 48rem;
  --header-height: 3.5rem;
}

/* ------------------------------------------------
   Reset & base
   ------------------------------------------------ */

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

html {
  font-size: 100%;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-sans);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.7;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

a {
  color: var(--accent-lavender);
  text-decoration: none;
  transition: color 0.2s;
}

a:hover,
a:focus-visible {
  color: var(--accent-mint);
}

/* ------------------------------------------------
   Skip link (accessibility)
   ------------------------------------------------ */

.skip-link {
  position: absolute;
  top: -100%;
  left: 1rem;
  background: var(--accent-lavender);
  color: var(--bg-primary);
  padding: 0.5rem 1rem;
  border-radius: 0 0 0.25rem 0.25rem;
  z-index: 1000;
  font-weight: 600;
}

.skip-link:focus {
  top: 0;
}

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

.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  height: var(--header-height);
}

.header-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 1.5rem;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: relative;
}

.logo {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-heading);
  letter-spacing: -0.02em;
}

.logo:hover {
  color: var(--accent-mint);
}

/* Navigation */

.main-nav {
  display: flex;
  gap: 2rem;
  align-items: center;
}

.main-nav a {
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 500;
  padding: 0.25rem 0;
  border-bottom: 2px solid transparent;
  transition: color 0.2s, border-color 0.2s;
}

.main-nav a:hover,
.main-nav a:focus-visible {
  color: var(--text-primary);
}

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

/* Burger menu (CSS-only) */

.menu-toggle {
  display: none;
}

.burger {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  cursor: pointer;
  padding: 0.25rem;
  z-index: 10;
}

.burger span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--text-primary);
  border-radius: 1px;
  transition: transform 0.3s, opacity 0.3s;
}

/* ------------------------------------------------
   Mobile menu
   ------------------------------------------------ */

@media (max-width: 640px) {
  .burger {
    display: flex;
  }

  .main-nav {
    display: none;
    position: absolute;
    top: var(--header-height);
    left: 0;
    right: 0;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    flex-direction: column;
    padding: 1rem 1.5rem;
    gap: 0;
  }

  .main-nav a {
    padding: 0.75rem 0;
    font-size: 1rem;
    border-bottom: 1px solid var(--border);
  }

  .main-nav a:last-child {
    border-bottom: none;
  }

  .menu-toggle:checked ~ .main-nav {
    display: flex;
  }

  /* Animate burger → X */
  .menu-toggle:checked ~ .burger span:nth-child(1) {
    transform: rotate(45deg) translate(5px, 5px);
  }

  .menu-toggle:checked ~ .burger span:nth-child(2) {
    opacity: 0;
  }

  .menu-toggle:checked ~ .burger span:nth-child(3) {
    transform: rotate(-45deg) translate(5px, -5px);
  }
}

/* ------------------------------------------------
   Main content
   ------------------------------------------------ */

main {
  flex: 1;
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 2.5rem 1.5rem;
}

/* ------------------------------------------------
   Page content (rendered markdown)
   ------------------------------------------------ */

.page-content h1 {
  font-size: 2rem;
  font-weight: 700;
  color: var(--text-heading);
  margin-bottom: 1.5rem;
  letter-spacing: -0.02em;
}

.page-content h2 {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text-heading);
  margin-top: 2rem;
  margin-bottom: 0.75rem;
}

.page-content h3 {
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--accent-lavender);
  margin-top: 1.5rem;
  margin-bottom: 0.5rem;
}

.page-content p {
  margin-bottom: 1rem;
  color: var(--text-primary);
}

.page-content ul,
.page-content ol {
  margin-bottom: 1rem;
  padding-left: 1.5rem;
}

.page-content li {
  margin-bottom: 0.4rem;
}

.page-content code {
  font-family: var(--font-mono);
  background: var(--bg-card);
  padding: 0.15em 0.4em;
  border-radius: 3px;
  font-size: 0.875em;
}

.page-content pre {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  padding: 1rem 1.25rem;
  overflow-x: auto;
  margin-bottom: 1.5rem;
}

.page-content pre code {
  background: none;
  padding: 0;
}

.page-content blockquote {
  border-left: 3px solid var(--accent-lavender);
  padding-left: 1rem;
  margin: 1rem 0;
  color: var(--text-secondary);
  font-style: italic;
}

.page-content hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2rem 0;
}

/* ------------------------------------------------
   Geometric background animation
   ------------------------------------------------ */

.geo-bg {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 0;
}

.geo-shape {
  position: absolute;
  opacity: 0;
  animation: geo-fade-in 2s ease forwards;
}

/* Hexagon */
.shape-hex {
  width: 120px;
  height: 120px;
  clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
}

/* Triangle */
.shape-tri {
  width: 100px;
  height: 100px;
  clip-path: polygon(50% 0%, 100% 100%, 0% 100%);
}

/* Diamond */
.shape-diamond {
  width: 80px;
  height: 80px;
  clip-path: polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%);
}

/* Ring */
.shape-ring {
  width: 140px;
  height: 140px;
  border-radius: 50%;
  background: transparent !important;
  box-shadow: inset 0 0 0 2px var(--accent-lavender);
}

/* Individual shape placements, colours, and timings */

.shape-1 {
  top: 12%;
  left: 8%;
  background: var(--accent-lavender);
  opacity: 0;
  animation: geo-spin 25s linear infinite, geo-drift-y 18s ease-in-out infinite, geo-fade-in 2s 0.2s ease forwards;
}

.shape-2 {
  top: 60%;
  right: 12%;
  background: var(--accent-mint);
  opacity: 0;
  animation: geo-spin-reverse 30s linear infinite, geo-drift-x 14s ease-in-out infinite, geo-fade-in 2s 0.6s ease forwards;
}

.shape-3 {
  bottom: 20%;
  left: 15%;
  background: var(--accent-peach);
  opacity: 0;
  animation: geo-spin 20s linear infinite, geo-drift-y 20s ease-in-out infinite alternate, geo-fade-in 2s 0.4s ease forwards;
}

.shape-4 {
  top: 25%;
  right: 20%;
  opacity: 0;
  animation: geo-spin-reverse 35s linear infinite, geo-pulse 8s ease-in-out infinite, geo-fade-in 2s 0.8s ease forwards;
}

.shape-5 {
  bottom: 35%;
  right: 35%;
  background: var(--accent-blue);
  width: 70px;
  height: 70px;
  opacity: 0;
  animation: geo-spin 22s linear infinite, geo-drift-x 16s ease-in-out infinite alternate-reverse, geo-fade-in 2s 1s ease forwards;
}

.shape-6 {
  top: 45%;
  left: 30%;
  background: var(--accent-lavender);
  width: 60px;
  height: 60px;
  opacity: 0;
  animation: geo-spin-reverse 28s linear infinite, geo-drift-y 22s ease-in-out infinite alternate, geo-fade-in 2s 0.3s ease forwards;
}

.shape-7 {
  bottom: 10%;
  right: 8%;
  width: 100px;
  height: 100px;
  opacity: 0;
  animation: geo-spin 40s linear infinite, geo-drift-x 20s ease-in-out infinite, geo-fade-in 2s 0.7s ease forwards;
}

.shape-8 {
  top: 8%;
  right: 40%;
  background: var(--accent-mint);
  width: 50px;
  height: 50px;
  opacity: 0;
  animation: geo-spin 18s linear infinite, geo-drift-y 12s ease-in-out infinite alternate-reverse, geo-fade-in 2s 0.5s ease forwards;
}

@keyframes geo-fade-in {
  to {
    opacity: 0.08;
  }
}

@keyframes geo-spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes geo-spin-reverse {
  to {
    transform: rotate(-360deg);
  }
}

@keyframes geo-drift-y {
  0%, 100% {
    translate: 0 0;
  }
  50% {
    translate: 0 40px;
  }
}

@keyframes geo-drift-x {
  0%, 100% {
    translate: 0 0;
  }
  50% {
    translate: 30px 0;
  }
}

@keyframes geo-pulse {
  0%, 100% {
    scale: 1;
  }
  50% {
    scale: 1.15;
  }
}

/* Ring shapes get slightly higher opacity since they're outlines */
.shape-ring.shape-4,
.shape-ring.shape-7 {
  animation: geo-spin-reverse 35s linear infinite, geo-pulse 8s ease-in-out infinite, geo-fade-in-ring 2s 0.8s ease forwards;
}

@keyframes geo-fade-in-ring {
  to {
    opacity: 0.12;
  }
}

/* ------------------------------------------------
   Home-specific
   ------------------------------------------------ */

.home-content {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  text-align: center;
}

.home-content h1 {
  font-size: 1.75rem;
  color: var(--text-secondary);
  font-weight: 400;
  letter-spacing: 0.02em;
}

/* ------------------------------------------------
   Blog listing
   ------------------------------------------------ */

.blog-listing > h1 {
  font-size: 2rem;
  font-weight: 700;
  color: var(--text-heading);
  margin-bottom: 2rem;
}

.blog-post {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  padding: 1.5rem 1.75rem;
  margin-bottom: 1.5rem;
  transition: border-color 0.2s, background 0.2s;
}

.blog-post:hover {
  border-color: var(--border-light);
  background: var(--bg-card-hover);
}

.post-header {
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
}

.post-header h2 {
  font-size: 1.35rem;
  font-weight: 600;
  color: var(--text-heading);
  margin-bottom: 0.25rem;
}

.post-header time {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.post-body {
  color: var(--text-primary);
  line-height: 1.7;
}

.post-body p {
  margin-bottom: 0.75rem;
}

.post-body h3 {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--accent-lavender);
  margin-top: 1.25rem;
  margin-bottom: 0.5rem;
}

.post-body ul,
.post-body ol {
  padding-left: 1.5rem;
  margin-bottom: 0.75rem;
}

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

.post-body code {
  font-family: var(--font-mono);
  background: var(--bg-secondary);
  padding: 0.1em 0.35em;
  border-radius: 3px;
  font-size: 0.875em;
}

/* ------------------------------------------------
   Pagination
   ------------------------------------------------ */

.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.pagination-link {
  font-size: 0.9rem;
  font-weight: 500;
  min-width: 8rem;
}

.pagination-prev {
  text-align: left;
}

.pagination-next {
  text-align: right;
}

.pagination-link.disabled {
  visibility: hidden;
}

.pagination-info {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

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

.site-footer {
  border-top: 1px solid var(--border);
  background: var(--bg-secondary);
  padding: 1.5rem 0;
  margin-top: auto;
}

.footer-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 1.5rem;
  text-align: center;
}

.footer-inner p {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

/* ------------------------------------------------
   Focus styles (accessibility)
   ------------------------------------------------ */

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

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

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

  html {
    scroll-behavior: auto;
  }
}
