/* AI Vibe – Custom Theme
   Dark default, Light opt-in, Electric Purple accent #7c3aed
*/

:root {
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
               Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --radius: 10px;
  --radius-sm: 6px;
  --container: 800px;
  --container-wide: 1000px;
  --transition: 180ms ease;
}

:root[data-theme="dark"] {
  --bg: #0a0a0a;
  --bg-elev: #141416;
  --bg-card: #18181b;
  --fg: #e5e5e5;
  --fg-muted: #a1a1aa;
  --fg-faint: #71717a;
  --border: #27272a;
  --border-strong: #3f3f46;
  --accent: #7c3aed;
  --accent-hover: #8b5cf6;
  --accent-soft: rgba(124, 58, 237, 0.12);
  --code-bg: #1f1f23;
  --selection: rgba(124, 58, 237, 0.35);
  color-scheme: dark;
}

:root[data-theme="light"] {
  --bg: #fafafa;
  --bg-elev: #ffffff;
  --bg-card: #ffffff;
  --fg: #18181b;
  --fg-muted: #52525b;
  --fg-faint: #a1a1aa;
  --border: #e4e4e7;
  --border-strong: #d4d4d8;
  --accent: #7c3aed;
  --accent-hover: #6d28d9;
  --accent-soft: rgba(124, 58, 237, 0.08);
  --code-bg: #f4f4f5;
  --selection: rgba(124, 58, 237, 0.25);
  color-scheme: light;
}

* { box-sizing: border-box; }

.skip-link {
  position: absolute;
  top: -100px;
  left: 1rem;
  background: var(--accent);
  color: #fff;
  padding: 0.6rem 1rem;
  border-radius: var(--radius);
  z-index: 100;
  font-weight: 600;
  text-decoration: none;
  transition: top 150ms ease;
}
.skip-link:focus { top: 1rem; outline: 2px solid #fff; outline-offset: 2px; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-sans);
  font-size: 17px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

::selection { background: var(--selection); }

a {
  color: var(--accent);
  text-decoration: none;
  transition: color var(--transition);
}
a:hover { color: var(--accent-hover); text-decoration: underline; }
a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 3px;
}

code, pre {
  font-family: var(--font-mono);
  font-size: 0.92em;
}
code {
  background: var(--code-bg);
  padding: 0.15em 0.4em;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}
pre {
  background: var(--code-bg);
  padding: 1rem 1.1rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow-x: auto;
  line-height: 1.55;
}
pre code {
  background: transparent;
  padding: 0;
  border: 0;
}

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

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

/* ---------- Header ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in oklab, var(--bg) 88%, transparent);
  backdrop-filter: saturate(150%) blur(10px);
  -webkit-backdrop-filter: saturate(150%) blur(10px);
  border-bottom: 1px solid var(--border);
}
.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding-top: 0.85rem;
  padding-bottom: 0.85rem;
}
.logo {
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--fg);
  display: inline-flex;
  align-items: baseline;
  gap: 0.4rem;
}
.logo span { color: var(--accent); }
.logo .logo-vibe { color: var(--accent); }
.logo .tagline {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--fg-faint);
  letter-spacing: 0;
}
.logo:hover { text-decoration: none; color: var(--fg); }

.site-header nav {
  display: flex;
  align-items: center;
  gap: 1.1rem;
}
.site-header nav a {
  color: var(--fg-muted);
  font-weight: 500;
  font-size: 0.95rem;
}
.site-header nav a:hover { color: var(--accent); text-decoration: none; }

#theme-toggle {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--fg-muted);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}
#theme-toggle:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-soft);
}

.lang-switch {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--fg-faint);
  margin-left: 0.4rem;
}
.lang-switch a {
  color: var(--fg-faint);
  padding: 0.15rem 0.35rem;
  border-radius: var(--radius-sm);
  transition: color var(--transition), background var(--transition);
  text-decoration: none;
}
.lang-switch a:hover { color: var(--fg); text-decoration: none; }
.lang-switch a.is-active {
  color: var(--accent);
  background: var(--accent-soft);
}
.lang-switch .lang-sep {
  color: var(--fg-faint);
  opacity: 0.5;
}

/* ---------- Hero ---------- */
.hero {
  padding: 3.5rem 0 2rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 2.5rem;
}
.hero h1 {
  font-size: clamp(2rem, 5vw, 2.8rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  margin: 0 0 0.6rem;
  line-height: 1.1;
}
.hero .lead {
  font-size: 1.15rem;
  color: var(--fg-muted);
  margin: 0;
  max-width: 60ch;
}

/* ---------- Post cards ---------- */
.posts { display: grid; gap: 1.1rem; }
.post-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: all var(--transition);
}
.post-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px -12px rgba(124, 58, 237, 0.4);
}
.post-card a {
  display: block;
  padding: 1.4rem 1.5rem;
  color: var(--fg);
  text-decoration: none;
}
.post-card a:hover { text-decoration: none; }
.post-card h2 {
  margin: 0 0 0.4rem;
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.25;
}
.post-card .meta {
  margin: 0 0 0.6rem;
  color: var(--fg-faint);
  font-size: 0.88rem;
}
.post-card .excerpt {
  margin: 0.4rem 0 0;
  color: var(--fg-muted);
  font-size: 1rem;
  line-height: 1.55;
}

.empty {
  color: var(--fg-muted);
  padding: 2rem;
  text-align: center;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}

/* ---------- Tags ---------- */
.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.7rem;
}
.tag {
  display: inline-block;
  padding: 0.2rem 0.65rem;
  font-size: 0.78rem;
  font-weight: 500;
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 999px;
  border: 1px solid color-mix(in oklab, var(--accent) 30%, transparent);
}

/* ---------- Single post ---------- */
.post {
  max-width: 70ch;
  margin: 0 auto;
  padding: 2rem 0 4rem;
}
.post-header {
  margin-bottom: 2.5rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
}
.post-header h1 {
  font-size: clamp(1.8rem, 4vw, 2.4rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.15;
  margin: 0 0 0.7rem;
}
.post-header .meta {
  color: var(--fg-faint);
  font-size: 0.92rem;
  margin: 0;
}

.post-content { font-size: 1.05rem; }
.post-content > *:first-child { margin-top: 0; }
.post-content h2 {
  font-size: 1.6rem;
  margin: 2.5rem 0 1rem;
  letter-spacing: -0.02em;
}
.post-content h3 {
  font-size: 1.3rem;
  margin: 2rem 0 0.8rem;
}
.post-content p { margin: 1.1rem 0; }
.post-content ul, .post-content ol { padding-left: 1.5rem; margin: 1.1rem 0; }
.post-content li { margin: 0.4rem 0; }
.post-content blockquote {
  margin: 1.5rem 0;
  padding: 0.6rem 1.1rem;
  border-left: 3px solid var(--accent);
  background: var(--accent-soft);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--fg-muted);
  font-style: italic;
}
.post-content a { text-decoration: underline; text-underline-offset: 3px; }

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

/* ---------- Legal page ---------- */
.legal { max-width: 70ch; margin: 0 auto; padding: 2rem 0 4rem; }
.legal h1 {
  font-size: 1.8rem;
  margin: 0 0 1.5rem;
  letter-spacing: -0.02em;
}
.legal .content { color: var(--fg-muted); }
.legal .content h2, .legal .content h3 { color: var(--fg); }
.legal .content a { text-decoration: underline; }

/* ---------- Footer ---------- */
.site-footer {
  margin-top: 5rem;
  padding: 2rem 0;
  border-top: 1px solid var(--border);
  color: var(--fg-faint);
  font-size: 0.9rem;
}
.site-footer a { color: var(--fg-muted); }
.site-footer a:hover { color: var(--accent); }
.site-footer p { margin: 0; text-align: center; }

/* ---------- Responsive ---------- */
@media (max-width: 640px) {
  body { font-size: 16px; }
  .hero { padding: 2.2rem 0 1.5rem; margin-bottom: 1.8rem; }
  .post-card a { padding: 1.1rem 1.2rem; }
  .post-card h2 { font-size: 1.2rem; }
  .site-header nav { gap: 0.8rem; }
  .site-header nav a { font-size: 0.9rem; }
  .container { padding: 0 1rem; }
  .post { padding: 1.5rem 0 3rem; }
}

@media (min-width: 768px) {
  body { font-size: 18px; }
}

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