/* ══════════════════════════════════════
   baumgaertel.it – Site Stylesheet
   Geist Sans · Dark/Light Theming
   ══════════════════════════════════════ */

/* ── Font ── */
@font-face {
  font-family: 'Geist Sans';
  src: url('../fonts/GeistVF.woff2') format('woff2');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

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

/* ── Theme Variables ── */
:root {
  --font: 'Geist Sans', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --radius: 10px;
  --transition: 0.25s ease;
  --max-width: 720px;
  --nav-height: 56px;
}

[data-theme="dark"] {
  --bg:          #09090b;
  --bg-subtle:   #111114;
  --bg-card:     #16161a;
  --border:      #1e1e24;
  --border-hover:#2a2a32;
  --text:        #e4e4e8;
  --text-muted:  #6e6e7a;
  --accent:      #8b8bff;
  --accent-dim:  rgba(139,139,255,0.1);
  --code-bg:     #131317;
  --modal-bg:    rgba(0,0,0,0.75);
  --shadow:      0 8px 32px rgba(0,0,0,0.4);
}

[data-theme="light"] {
  --bg:          #fafafa;
  --bg-subtle:   #f0f0f2;
  --bg-card:     #ffffff;
  --border:      #e2e2e6;
  --border-hover:#cbcbd0;
  --text:        #1a1a1e;
  --text-muted:  #6e6e7a;
  --accent:      #5555dd;
  --accent-dim:  rgba(85,85,221,0.08);
  --code-bg:     #f4f4f6;
  --modal-bg:    rgba(0,0,0,0.45);
  --shadow:      0 8px 32px rgba(0,0,0,0.1);
}

/* ── Base ── */
html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background var(--transition), color var(--transition);
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color var(--transition);
}
a:hover { opacity: 0.8; }

img { max-width: 100%; height: auto; border-radius: var(--radius); }

/* ── Page Background ── */
#page-bg {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: -1;
  background-size: cover;
  background-position: center top;
  background-repeat: no-repeat;
  opacity: 0.25;
  pointer-events: none;
  transition: opacity 0.5s ease;
}

body.has-page-bg #page-bg {
  opacity: 0.3;
}

[data-theme="light"] #page-bg {
  opacity: 0.15;
}

/* ── Navigation ── */
#main-nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 100;
  height: var(--nav-height);
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
  transition: background var(--transition), border-color var(--transition);
}

.nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  max-width: var(--max-width);
}

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

.nav-right {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

#nav-links {
  display: flex;
  gap: 1.25rem;
  font-size: 0.85rem;
}

#nav-links a { color: var(--text-muted); }
#nav-links a:hover { color: var(--text); opacity: 1; }

/* ── Controls (Theme/Language Switcher) ── */
.controls {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.dropdown {
  position: relative;
}

.dropdown > button {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 0.3rem 0.6rem;
  border-radius: 6px;
  font-family: var(--font);
  font-size: 0.75rem;
  cursor: pointer;
  transition: border-color var(--transition), color var(--transition);
}

.dropdown > button:hover {
  border-color: var(--border-hover);
  color: var(--text);
}

.dropdown-menu {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  min-width: 100px;
  box-shadow: var(--shadow);
  z-index: 200;
}

.dropdown-menu.open { display: block; }

.dropdown-menu > div {
  padding: 0.5rem 0.75rem;
  font-size: 0.8rem;
  cursor: pointer;
  color: var(--text-muted);
  transition: background var(--transition), color var(--transition);
}

.dropdown-menu > div:hover {
  background: var(--accent-dim);
  color: var(--text);
}

/* ── Main Content ── */
main {
  flex: 1;
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: calc(var(--nav-height) + 2.5rem) 1.5rem 3rem;
}

/* ── Markdown Typography ── */
main h1 {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.04em;
  line-height: 1.15;
  margin-bottom: 1rem;
}

main h2 {
  font-size: 1.4rem;
  font-weight: 600;
  letter-spacing: -0.03em;
  margin-top: 2.5rem;
  margin-bottom: 0.75rem;
}

main h3 {
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin-top: 2rem;
  margin-bottom: 0.5rem;
}

main p {
  margin-bottom: 1rem;
  color: var(--text);
}

main ul, main ol {
  margin-bottom: 1rem;
  padding-left: 1.5rem;
}

main li { margin-bottom: 0.35rem; }

main blockquote {
  border-left: 3px solid var(--accent);
  padding: 0.5rem 1rem;
  margin: 1.5rem 0;
  color: var(--text-muted);
  background: var(--accent-dim);
  border-radius: 0 var(--radius) var(--radius) 0;
}

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

main strong { font-weight: 600; }

/* ── Code Blocks ── */
main code {
  font-family: 'Geist Mono', 'SF Mono', 'Fira Code', monospace;
  font-size: 0.85em;
  background: var(--code-bg);
  padding: 0.15em 0.4em;
  border-radius: 4px;
}

main pre {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  overflow-x: auto;
  margin: 1.5rem 0;
}

main pre code {
  background: none;
  padding: 0;
  font-size: 0.82rem;
  line-height: 1.6;
}

/* ── Tables ── */
main table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
  font-size: 0.9rem;
}

main th, main td {
  padding: 0.6rem 0.75rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

main th {
  font-weight: 600;
  color: var(--text-muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* ── Carousel (Cover-Flow) ── */
.carousel {
  --slide-width: 60%;
  --slide-gap: 0.75rem;
  position: relative;
  margin: 2rem -1.5rem;
  overflow: hidden;
  padding: 1.5rem 0;
  outline: none;
}

.carousel-track {
  display: flex;
  gap: var(--slide-gap);
  transition: transform 0.45s cubic-bezier(0.25, 0.1, 0.25, 1);
  will-change: transform;
}

.carousel-slide {
  min-width: var(--slide-width);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.45s ease, opacity 0.45s ease, filter 0.45s ease;
  transform: scale(0.82);
  opacity: 0.45;
  filter: brightness(0.7);
  cursor: pointer;
}

.carousel-slide.active {
  transform: scale(1);
  opacity: 1;
  filter: brightness(1);
  z-index: 1;
}

.carousel-slide img {
  max-height: 420px;
  width: 100%;
  object-fit: contain;
  border-radius: 8px;
  pointer-events: none;
}

.carousel-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: color-mix(in srgb, var(--bg) 80%, transparent);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border);
  color: var(--text);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-size: 1.2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
  opacity: 0;
  z-index: 10;
}

.carousel:hover .carousel-btn,
.carousel:focus-within .carousel-btn { opacity: 1; }
.carousel-btn:hover { background: var(--bg-card); border-color: var(--border-hover); }
.carousel-prev { left: 10px; }
.carousel-next { right: 10px; }

.carousel-dots {
  display: flex;
  justify-content: center;
  gap: 6px;
  padding: 0.75rem 0 0;
}

.carousel-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--border);
  border: none;
  cursor: pointer;
  transition: background var(--transition), transform var(--transition);
}

.carousel-dot.active { background: var(--accent); transform: scale(1.3); }

/* Single image carousel – no effects */
.carousel.single-slide { margin: 2rem 0; }
.carousel.single-slide .carousel-slide { transform: scale(1); opacity: 1; filter: none; }

@media (max-width: 600px) {
  .carousel { --slide-width: 75%; margin: 1.5rem -1rem; }
}

/* ── App Icon (top image on detail pages) ── */
.app-icon {
  display: block;
  width: var(--icon-size, 100px);
  height: auto;
  margin: 0 auto 1rem;
  border-radius: 22%;
}

/* ── Profile Image (index page) ── */
.profile-img {
  display: block;
  width: 120px;
  height: 120px;
  object-fit: cover;
  border-radius: 50%;
  margin: 0 0 1.5rem;
  border: 2px solid var(--border);
}

/* ── Cards ── */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
  margin: 2rem 0;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  transition: border-color var(--transition), transform 0.2s ease;
}

.card:hover {
  border-color: var(--border-hover);
  transform: translateY(-2px);
}

.card h3 {
  margin-top: 0;
  margin-bottom: 0.5rem;
}

.card p {
  font-size: 0.9rem;
  color: var(--text-muted);
}

.card a {
  display: inline-block;
  margin-top: 0.75rem;
  font-size: 0.85rem;
  font-weight: 500;
}

/* ── Modal ── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: var(--modal-bg);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  align-items: center;
  justify-content: center;
  padding: 2rem;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.modal-overlay.open {
  display: flex;
  opacity: 1;
}

.modal-container {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  max-width: 640px;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
  padding: 2rem;
  position: relative;
  box-shadow: var(--shadow);
}

.modal-close {
  position: absolute;
  top: 0.75rem;
  right: 1rem;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  transition: color var(--transition);
  line-height: 1;
}
.modal-close:hover { color: var(--text); }

/* Modal inherits markdown typography */
#modal-content h1 { font-size: 1.4rem; margin-bottom: 0.75rem; }
#modal-content h2 { font-size: 1.15rem; margin-top: 1.5rem; margin-bottom: 0.5rem; }
#modal-content p { font-size: 0.9rem; color: var(--text-muted); }

/* ── Footer ── */
footer {
  padding: 1.25rem 1.5rem;
  border-top: 1px solid var(--border);
  font-size: 0.75rem;
  color: var(--text-muted);
  transition: border-color var(--transition);
}

.footer-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
}

#footer-links {
  display: flex;
  gap: 1.25rem;
}

#footer-links a {
  color: var(--text-muted);
  font-size: 0.75rem;
}
#footer-links a:hover { color: var(--text); }

/* ── Scroll-to-top ── */
#scroll-top {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 1rem;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
  z-index: 50;
}
#scroll-top.visible { display: flex; }
#scroll-top:hover { border-color: var(--border-hover); color: var(--text); }

/* ── Loading State ── */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 200px;
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* ── Error State ── */
.error {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
}
.error h2 { color: var(--text); margin-bottom: 0.5rem; }

/* ── Responsive ── */
@media (max-width: 600px) {
  #main-nav { padding: 0 1rem; }
  main { padding: calc(var(--nav-height) + 1.5rem) 1rem 2rem; }
  main h1 { font-size: 1.6rem; }
  .cards-grid { grid-template-columns: 1fr; }
  .footer-inner { flex-direction: column; align-items: flex-start; }
  .modal-container { padding: 1.5rem; margin: 1rem; }
  .nav-right { gap: 0.75rem; }
  #nav-links { gap: 0.75rem; }
}
