/*
Theme Name: Flavor
Theme URI: https://github.com/example/flavor
Author: Cem İbrahim Arı
Author URI: https://kurumsalaglarda.com
Description: Minimal technical blog theme — clean typography, code-first design, dark mode, auto-TOC. Inspired by Stripe & Tailwind engineering blogs.
Version: 1.0.0
Requires at least: 6.0
Tested up to: 6.7
Requires PHP: 8.0
License: GPL-2.0-or-later
Text Domain: flavor
*/

/* ================================================================
   0. CSS CUSTOM PROPERTIES
   ================================================================ */

:root {
  /* Typography */
  --f-font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --f-font-mono: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', 'Consolas', monospace;
  --f-font-heading: var(--f-font-body);

  /* Scale — modular (1.25) */
  --f-text-xs: 0.75rem;
  --f-text-sm: 0.875rem;
  --f-text-base: 1.0625rem;   /* 17px — slightly larger for readability */
  --f-text-lg: 1.25rem;
  --f-text-xl: 1.5rem;
  --f-text-2xl: 1.875rem;
  --f-text-3xl: 2.25rem;
  --f-text-4xl: 3rem;

  /* Line heights */
  --f-leading-tight: 1.25;
  --f-leading-normal: 1.7;
  --f-leading-relaxed: 1.8;

  /* Spacing */
  --f-content-width: 720px;
  --f-wide-width: 1080px;
  --f-site-width: 1280px;
  --f-gutter: 1.5rem;

  /* Radius */
  --f-radius-sm: 6px;
  --f-radius-md: 8px;
  --f-radius-lg: 12px;

  /* Transitions */
  --f-transition: 150ms ease;

  /* Light theme (default) */
  --f-bg: #ffffff;
  --f-bg-alt: #f8f9fa;
  --f-bg-code: #f1f3f5;
  --f-bg-code-block: #1e1e2e;
  --f-text: #1a1a2e;
  --f-text-secondary: #555770;
  --f-text-tertiary: #8b8da3;
  --f-text-code-block: #cdd6f4;
  --f-border: #e2e4e9;
  --f-border-strong: #d0d3da;
  --f-accent: #635bff;          /* Stripe purple */
  --f-accent-hover: #4b45c6;
  --f-accent-bg: #f0efff;
  --f-link: #635bff;
  --f-link-hover: #4b45c6;
  --f-success: #30a46c;
  --f-warning: #f5a623;
  --f-danger: #e5484d;
  --f-shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --f-shadow-lg: 0 4px 12px rgba(0,0,0,0.08);
}

[data-theme="dark"] {
  --f-bg: #0f0f1a;
  --f-bg-alt: #16162a;
  --f-bg-code: #1e1e2e;
  --f-bg-code-block: #11111b;
  --f-text: #e4e4f0;
  --f-text-secondary: #a3a4b8;
  --f-text-tertiary: #6c6d82;
  --f-text-code-block: #cdd6f4;
  --f-border: #2a2a40;
  --f-border-strong: #3a3a55;
  --f-accent: #818cf8;
  --f-accent-hover: #a5b4fc;
  --f-accent-bg: rgba(129,140,248,0.1);
  --f-link: #818cf8;
  --f-link-hover: #a5b4fc;
  --f-shadow: 0 1px 3px rgba(0,0,0,0.3);
  --f-shadow-lg: 0 4px 12px rgba(0,0,0,0.4);
}

/* ================================================================
   1. RESET & BASE
   ================================================================ */

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

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  scroll-behavior: smooth;
  font-size: 16px;
}

body {
  font-family: var(--f-font-body);
  font-size: var(--f-text-base);
  line-height: var(--f-leading-normal);
  color: var(--f-text);
  background: var(--f-bg);
  transition: background var(--f-transition), color var(--f-transition);
}

::selection {
  background: var(--f-accent);
  color: #fff;
}

/* ================================================================
   2. TYPOGRAPHY
   ================================================================ */

h1, h2, h3, h4, h5, h6 {
  font-family: var(--f-font-heading);
  font-weight: 700;
  line-height: var(--f-leading-tight);
  color: var(--f-text);
  letter-spacing: -0.02em;
}

h1 { font-size: var(--f-text-4xl); margin-bottom: 1rem; }
h2 { font-size: var(--f-text-2xl); margin-top: 2.5rem; margin-bottom: 0.75rem; }
h3 { font-size: var(--f-text-xl); margin-top: 2rem; margin-bottom: 0.5rem; }
h4 { font-size: var(--f-text-lg); margin-top: 1.5rem; margin-bottom: 0.5rem; }

p { margin-bottom: 1.25rem; }

a {
  color: var(--f-link);
  text-decoration: none;
  transition: color var(--f-transition);
}
a:hover { color: var(--f-link-hover); text-decoration: underline; }

strong { font-weight: 650; }

blockquote {
  border-left: 3px solid var(--f-accent);
  padding: 0.75rem 1.25rem;
  margin: 1.5rem 0;
  background: var(--f-bg-alt);
  border-radius: 0 var(--f-radius-sm) var(--f-radius-sm) 0;
  color: var(--f-text-secondary);
  font-style: italic;
}
blockquote p:last-child { margin-bottom: 0; }

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

ul, ol {
  margin: 0 0 1.25rem 1.5rem;
}
li { margin-bottom: 0.35rem; }
li > ul, li > ol { margin-top: 0.35rem; margin-bottom: 0; }

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

table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
  font-size: var(--f-text-sm);
}
th, td {
  padding: 0.625rem 1rem;
  border: 1px solid var(--f-border);
  text-align: left;
}
th {
  background: var(--f-bg-alt);
  font-weight: 600;
}

/* ================================================================
   3. CODE — the star of the show
   ================================================================ */

code {
  font-family: var(--f-font-mono);
  font-size: 0.875em;
  background: var(--f-bg-code);
  padding: 0.15em 0.4em;
  border-radius: 4px;
  color: var(--f-accent);
  word-break: break-word;
}

pre {
  position: relative;
  background: var(--f-bg-code-block);
  color: var(--f-text-code-block);
  padding: 1.25rem 1.5rem;
  border-radius: var(--f-radius-md);
  overflow-x: auto;
  margin: 1.5rem 0;
  font-size: var(--f-text-sm);
  line-height: 1.65;
  border: 1px solid var(--f-border);
  tab-size: 4;
}
pre code {
  background: transparent;
  padding: 0;
  color: inherit;
  border-radius: 0;
  font-size: inherit;
}

/* Code block language badge */
pre[data-lang]::before {
  content: attr(data-lang);
  position: absolute;
  top: 0;
  right: 0;
  padding: 0.2rem 0.6rem;
  font-size: var(--f-text-xs);
  font-family: var(--f-font-mono);
  color: var(--f-text-tertiary);
  background: rgba(255,255,255,0.05);
  border-radius: 0 var(--f-radius-md) 0 var(--f-radius-sm);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Copy button */
.code-copy-btn {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  padding: 0.3rem 0.6rem;
  font-size: var(--f-text-xs);
  font-family: var(--f-font-mono);
  color: var(--f-text-tertiary);
  background: transparent;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: var(--f-radius-sm);
  cursor: pointer;
  opacity: 0;
  transition: opacity var(--f-transition), background var(--f-transition);
}
pre:hover .code-copy-btn { opacity: 1; }
.code-copy-btn:hover { background: rgba(255,255,255,0.1); color: #fff; }
.code-copy-btn.copied { color: var(--f-success); border-color: var(--f-success); }

/* ================================================================
   4. LAYOUT
   ================================================================ */

.site-wrapper {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.container {
  width: 100%;
  max-width: var(--f-site-width);
  margin: 0 auto;
  padding: 0 var(--f-gutter);
}

.content-area {
  max-width: var(--f-content-width);
  margin: 0 auto;
}

.wide-content {
  max-width: var(--f-wide-width);
  margin: 0 auto;
}

/* ================================================================
   5. HEADER
   ================================================================ */

.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255,255,255,0.85);
  backdrop-filter: blur(12px) saturate(180%);
  -webkit-backdrop-filter: blur(12px) saturate(180%);
  border-bottom: 1px solid var(--f-border);
  transition: background var(--f-transition);
}

[data-theme="dark"] .site-header {
  background: rgba(15,15,26,0.85);
}

.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}

.site-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 700;
  font-size: var(--f-text-lg);
  color: var(--f-text);
  text-decoration: none;
  letter-spacing: -0.03em;
}
.site-brand:hover { color: var(--f-text); text-decoration: none; }

.site-brand .brand-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  background: var(--f-accent);
  border-radius: 50%;
}

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

.site-nav a {
  font-size: var(--f-text-sm);
  font-weight: 500;
  color: var(--f-text-secondary);
  text-decoration: none;
  transition: color var(--f-transition);
}
.site-nav a:hover { color: var(--f-text); text-decoration: none; }

/* Dark mode toggle */
.theme-toggle {
  background: transparent;
  border: 1px solid var(--f-border);
  border-radius: var(--f-radius-sm);
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--f-text-secondary);
  transition: all var(--f-transition);
  font-size: 1rem;
}
.theme-toggle:hover {
  background: var(--f-bg-alt);
  color: var(--f-text);
}

/* Mobile menu */
.menu-toggle {
  display: none;
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--f-text);
  font-size: 1.25rem;
}

/* ================================================================
   6. POST LIST / ARCHIVE
   ================================================================ */

.posts-grid {
  padding: 3rem 0;
}

.posts-grid .section-title {
  font-size: var(--f-text-sm);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--f-text-tertiary);
  margin-bottom: 2rem;
}

.post-card {
  display: block;
  padding: 1.5rem 0;
  border-bottom: 1px solid var(--f-border);
  text-decoration: none;
  color: inherit;
  transition: background var(--f-transition);
}
.post-card:first-child { border-top: 1px solid var(--f-border); }
.post-card:hover { text-decoration: none; color: inherit; }

.post-card-meta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
  font-size: var(--f-text-sm);
  color: var(--f-text-tertiary);
}

.post-card-meta .category-badge {
  font-size: var(--f-text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--f-accent);
  background: var(--f-accent-bg);
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
}

.post-card-title {
  font-size: var(--f-text-xl);
  font-weight: 650;
  line-height: var(--f-leading-tight);
  margin-bottom: 0.5rem;
  color: var(--f-text);
  transition: color var(--f-transition);
}
.post-card:hover .post-card-title { color: var(--f-accent); }

.post-card-excerpt {
  color: var(--f-text-secondary);
  font-size: var(--f-text-base);
  line-height: var(--f-leading-normal);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ================================================================
   7. SINGLE POST
   ================================================================ */

.post-header {
  padding: 4rem 0 2rem;
  text-align: center;
}

.post-header .category-badge {
  display: inline-block;
  font-size: var(--f-text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--f-accent);
  background: var(--f-accent-bg);
  padding: 0.25rem 0.75rem;
  border-radius: 4px;
  margin-bottom: 1rem;
}

.post-header h1 {
  font-size: var(--f-text-3xl);
  max-width: var(--f-content-width);
  margin: 0 auto 1rem;
}

.post-header .post-meta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  color: var(--f-text-tertiary);
  font-size: var(--f-text-sm);
}
.post-header .post-meta .separator { color: var(--f-border); }

/* Post content layout with TOC sidebar */
.post-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 3rem;
  max-width: var(--f-wide-width);
  margin: 0 auto;
  padding: 0 var(--f-gutter);
}

@media (min-width: 1100px) {
  .post-layout {
    grid-template-columns: var(--f-content-width) 1fr;
  }
}

/* Article body */
.post-content {
  max-width: var(--f-content-width);
  padding-bottom: 4rem;
}

.post-content > *:first-child { margin-top: 0; }

/* Headings anchor links */
.post-content h2,
.post-content h3 {
  position: relative;
}
.post-content .heading-anchor {
  position: absolute;
  left: -1.5rem;
  color: var(--f-text-tertiary);
  font-weight: 400;
  opacity: 0;
  transition: opacity var(--f-transition);
  text-decoration: none;
}
.post-content h2:hover .heading-anchor,
.post-content h3:hover .heading-anchor { opacity: 1; }

/* Info/warning/tip boxes */
.callout {
  padding: 1rem 1.25rem;
  border-radius: var(--f-radius-md);
  margin: 1.5rem 0;
  font-size: var(--f-text-sm);
  border-left: 3px solid;
}
.callout p:last-child { margin-bottom: 0; }
.callout-info  { background: #eff6ff; border-color: #3b82f6; color: #1e40af; }
.callout-warn  { background: #fefce8; border-color: #eab308; color: #854d0e; }
.callout-tip   { background: #f0fdf4; border-color: #22c55e; color: #166534; }
.callout-error { background: #fef2f2; border-color: #ef4444; color: #991b1b; }

[data-theme="dark"] .callout-info  { background: rgba(59,130,246,0.1); color: #93c5fd; }
[data-theme="dark"] .callout-warn  { background: rgba(234,179,8,0.1); color: #fde047; }
[data-theme="dark"] .callout-tip   { background: rgba(34,197,94,0.1); color: #86efac; }
[data-theme="dark"] .callout-error { background: rgba(239,68,68,0.1); color: #fca5a5; }

/* ================================================================
   8. TABLE OF CONTENTS (sidebar)
   ================================================================ */

.toc-sidebar {
  display: none;
}

@media (min-width: 1100px) {
  .toc-sidebar {
    display: block;
    position: relative;
  }
  .toc-inner {
    position: sticky;
    top: 88px; /* header height + gap */
  }
}

.toc-inner h4 {
  font-size: var(--f-text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--f-text-tertiary);
  margin: 0 0 0.75rem;
}

.toc-list {
  list-style: none;
  margin: 0;
  padding: 0;
  border-left: 2px solid var(--f-border);
}
.toc-list li {
  margin: 0;
}
.toc-list a {
  display: block;
  padding: 0.3rem 0 0.3rem 1rem;
  font-size: var(--f-text-sm);
  color: var(--f-text-tertiary);
  text-decoration: none;
  border-left: 2px solid transparent;
  margin-left: -2px;
  transition: all var(--f-transition);
}
.toc-list a:hover { color: var(--f-text-secondary); }
.toc-list a.active {
  color: var(--f-accent);
  border-left-color: var(--f-accent);
  font-weight: 500;
}
.toc-list .toc-h3 { padding-left: 2rem; }

/* ================================================================
   9. AUTHOR BOX
   ================================================================ */

.author-box {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  padding: 1.5rem;
  background: var(--f-bg-alt);
  border-radius: var(--f-radius-lg);
  margin: 3rem 0;
}

.author-avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.author-info .author-name {
  font-weight: 650;
  font-size: var(--f-text-base);
  margin-bottom: 0.25rem;
}
.author-info .author-bio {
  font-size: var(--f-text-sm);
  color: var(--f-text-secondary);
  line-height: 1.5;
  margin: 0;
}

/* ================================================================
   10. POST NAVIGATION
   ================================================================ */

.post-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  padding: 2rem 0;
  border-top: 1px solid var(--f-border);
}

.post-nav a {
  display: block;
  padding: 1rem;
  border: 1px solid var(--f-border);
  border-radius: var(--f-radius-md);
  text-decoration: none;
  color: inherit;
  transition: border-color var(--f-transition), box-shadow var(--f-transition);
}
.post-nav a:hover {
  border-color: var(--f-accent);
  box-shadow: var(--f-shadow);
  text-decoration: none;
}
.post-nav .nav-label {
  font-size: var(--f-text-xs);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--f-text-tertiary);
  margin-bottom: 0.25rem;
}
.post-nav .nav-title {
  font-weight: 600;
  font-size: var(--f-text-base);
}
.post-nav .nav-next { text-align: right; }

/* ================================================================
   11. PAGINATION
   ================================================================ */

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 2rem 0;
}
.pagination a, .pagination span {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--f-radius-sm);
  font-size: var(--f-text-sm);
  font-weight: 500;
  color: var(--f-text-secondary);
  text-decoration: none;
  transition: all var(--f-transition);
}
.pagination a:hover { background: var(--f-bg-alt); color: var(--f-text); text-decoration: none; }
.pagination .current {
  background: var(--f-accent);
  color: #fff;
}

/* ================================================================
   12. FOOTER
   ================================================================ */

.site-footer {
  margin-top: auto;
  padding: 3rem 0;
  border-top: 1px solid var(--f-border);
  font-size: var(--f-text-sm);
  color: var(--f-text-tertiary);
}

.site-footer .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.footer-links {
  display: flex;
  gap: 1.5rem;
}
.footer-links a { color: var(--f-text-tertiary); text-decoration: none; }
.footer-links a:hover { color: var(--f-text-secondary); }

/* ================================================================
   13. RESPONSIVE
   ================================================================ */

@media (max-width: 768px) {
  :root {
    --f-text-3xl: 1.875rem;
    --f-text-4xl: 2.25rem;
  }

  .site-nav { display: none; }
  .site-nav.open {
    display: flex;
    flex-direction: column;
    position: absolute;
    top: 64px;
    left: 0;
    right: 0;
    background: var(--f-bg);
    border-bottom: 1px solid var(--f-border);
    padding: 1rem var(--f-gutter);
    gap: 1rem;
    box-shadow: var(--f-shadow-lg);
  }
  .menu-toggle { display: block; }

  .post-header { padding: 2rem 0 1.5rem; }
  .post-header h1 { font-size: var(--f-text-2xl); }
  .post-nav { grid-template-columns: 1fr; }

  pre { font-size: var(--f-text-xs); padding: 1rem; }
}

/* ================================================================
   14. PRINT
   ================================================================ */

@media print {
  .site-header, .site-footer, .toc-sidebar, .theme-toggle,
  .code-copy-btn, .post-nav, .pagination { display: none !important; }

  body { font-size: 11pt; color: #000; background: #fff; }

  pre {
    background: #f5f5f5 !important;
    color: #333 !important;
    border: 1px solid #ddd;
  }

  a { color: #000; text-decoration: underline; }
  a::after { content: " (" attr(href) ")"; font-size: 0.8em; color: #666; }
}

/* ================================================================
   15. UTILITIES
   ================================================================ */

.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

.text-center { text-align: center; }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
