/* Base reset and variables */
:root{
  --bg:#0f1720;
  --bg-secondary:#071124;
  --surface:#0b1220;
  --surface-hover:#162332;
  --text:#e6eef6;
  --text-muted:#9aa4b2;
  --accent:#3b82f6;
  --accent-2:#60a5fa;
  --border:rgba(255,255,255,0.06);
  --border-hover:rgba(255,255,255,0.12);
  --glass:rgba(255,255,255,0.03);
  --shadow:rgba(2,6,23,0.6);
}

/* Light theme */
[data-theme="light"]{
  --bg:#fafbfc;
  --bg-secondary:#f1f3f5;
  --surface:#ffffff;
  --surface-hover:#f8f9fa;
  --text:#1a202c;
  --text-muted:#4a5568;
  --border:rgba(0,0,0,0.08);
  --border-hover:rgba(0,0,0,0.16);
  --glass:rgba(0,0,0,0.02);
  --shadow:rgba(0,0,0,0.12);
}

/* Light mode hero title fix */
[data-theme="light"] .hero .hero-title {
  color:var(--text);
}

/* System preference detection */
@media (prefers-color-scheme: light) {
  :root:not([data-theme]) {
    --bg:#fafbfc;
    --bg-secondary:#f1f3f5;
    --surface:#ffffff;
    --surface-hover:#f8f9fa;
    --text:#1a202c;
    --text-muted:#4a5568;
    --border:rgba(0,0,0,0.08);
    --border-hover:rgba(0,0,0,0.16);
    --glass:rgba(0,0,0,0.02);
    --shadow:rgba(0,0,0,0.12);
  }
  
  :root:not([data-theme]) .hero .hero-title {
    color:var(--text);
  }
}
*{box-sizing:border-box;margin:0;padding:0}
html,body{height:100%;transition:background-color 0.3s ease, color 0.3s ease}
body{
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial;
  background-color: var(--bg);
  color: var(--text);
  -webkit-font-smoothing:antialiased;
  -moz-osx-font-smoothing:grayscale;
}
.container{max-width:1100px;margin:0 auto;padding:24px}
.site-header{padding:36px 0 18px;border-bottom:1px solid var(--border);background:var(--glass);backdrop-filter:blur(8px)}
.header-inner{display:flex;align-items:center;gap:14px;justify-content:space-between;flex-direction:row}
.site-brand{display:flex;align-items:center;gap:12px}
.site-logo{width:46px;height:46px;border-radius:12px;background-color:var(--accent-2);display:inline-block;box-shadow:0 6px 18px rgba(59,130,246,0.12);flex-shrink:0}
.site-title{font-size:1.8rem;letter-spacing:0.6px;color:var(--text);font-weight:700;display:flex;align-items:center;gap:12px}
.twitter-icon, .youtube-icon{width:24px;height:24px;fill:#000;transition:transform 0.2s ease;}
html[data-theme="light"] .twitter-icon, html[data-theme="light"] .youtube-icon { fill: #000 !important; }
html[data-theme="dark"] .twitter-icon, html[data-theme="dark"] .youtube-icon { fill: #fff !important; }
@media (prefers-color-scheme: light) {
  .twitter-icon, .youtube-icon { fill: #000 !important; }
}
@media (prefers-color-scheme: dark) {
  .twitter-icon, .youtube-icon { fill: #fff !important; }
}
.twitter-icon:hover, .youtube-icon:hover{transform:scale(1.1)}
.site-tag{color:var(--text-muted);font-size:0.95rem}
.intro{margin:20px 0}
.intro .lead{color:var(--muted);margin-top:6px}

.posts-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(280px,1fr));gap:28px;margin-top:20px}
.post-card{background:var(--surface);border:1px solid var(--border);border-radius:16px;overflow:hidden;transition:transform 300ms cubic-bezier(.2,.9,.2,1), box-shadow 300ms, border-color 300ms, opacity 600ms ease, transform 600ms ease;backdrop-filter:blur(10px);display:flex;flex-direction:column;opacity:0;transform:translateY(40px)}
.post-card.loaded{opacity:1;transform:translateY(0)}
.card-link{display:flex;flex-direction:column;height:100%;color:inherit;text-decoration:none}
.card-media{height:180px;background:none;display:block;background-size:cover;position:relative;overflow:hidden}
.card-media img{width:100%;height:100%;object-fit:cover;object-position:center}
.card-media::after{content:'';position:absolute;inset:0;background:transparent;mix-blend-mode:normal}
.card-body{padding:20px;flex:1;display:flex;flex-direction:column}
.post-title{font-size:1.1rem;margin-bottom:10px;color:var(--text);font-weight:600}
.post-excerpt{color:var(--text-muted);font-size:0.96rem;margin-bottom:12px;line-height:1.5;flex:1}
.post-date{color:var(--text-muted);font-size:0.85rem;font-weight:500;margin-top:auto}

/* Hover animation */
.post-card:hover{transform:translateY(-12px) scale(1.02);box-shadow:0 24px 48px var(--shadow),0 8px 16px var(--shadow);border-color:var(--border-hover)}
.post-card:focus-within{outline:2px solid var(--accent-2);outline-offset:2px}

/* Media queries for responsiveness */
@media (max-width:640px){
  .card-media{height:130px}
  .site-title{font-size:1.25rem}
  .hero .hero-title{font-size:2.2rem}
  .hero .hero-sub{font-size:1rem}
}

/* Hero / hero accent */
.hero{display:flex;flex-direction:column;align-items:center;gap:16px;padding:40px 0 16px;text-align:center}
.hero .hero-title{font-size:3rem;font-weight:800;letter-spacing:-0.03em;color:var(--text);margin-bottom:8px;text-shadow:0 2px 8px rgba(0,0,0,0.06)}
.hero .hero-sub{color:var(--text-muted);font-size:1.2rem;line-height:1.6;max-width:600px}
html[data-theme="dark"] .hero .hero-sub { color:var(--text-muted); }
@media (prefers-color-scheme: dark) {
  .hero .hero-sub { color:var(--text-muted); }
}

/* Post page specific */
.post-article{padding:22px 0;max-width:100%;width:100%}
.meta{color:var(--muted);margin-bottom:18px}
.back-btn{display:inline-flex;align-items:center;gap:8px;padding:12px 16px;border-radius:10px;border:none;background:var(--accent-2);color:#fff;text-decoration:none;font-weight:700;cursor:pointer;transition:all 200ms ease;box-shadow:none}
.back-btn:hover{background:var(--accent);transform:translateY(-2px);box-shadow:none}
.back-btn:active{transform:translateY(0)}
.post-content{max-width:900px;width:100%}
.post-content h2{margin-top:20px}
.post-content p{line-height:1.65;margin:20px 0}
.post-content img{max-width:100%;display:block;border-radius:8px;margin:24px auto}
.post-content .image-container{margin:32px auto;text-align:center;display:block;width:100%}
.post-content .image-container img{margin:0 auto;display:block}
.post-content .image-caption{font-size:0.9rem;color:var(--text-muted);margin-top:8px;font-style:italic}
.post-content ul{margin:16px 0 16px 24px;padding-left:0}
.post-content ul li{margin:6px 0;color:var(--text)}
.post-header-row{display:flex;align-items:flex-start;gap:12px;flex-direction:column;max-width:900px;width:100%}
.post-header-row .meta{order:2}
.post-back-row{display:flex;align-items:center;justify-content:flex-start;margin-bottom:10px;max-width:900px;width:100%}

/* Search area */
.search-area{display:flex;align-items:center;gap:12px;margin:24px 0 20px 0;padding:0}
.search-input{flex:1;padding:14px 16px;border-radius:12px;border:1px solid var(--border);background:var(--surface);color:var(--text);font-size:1rem;transition:border-color 0.18s ease, box-shadow 0.18s ease, background-color 0.18s ease}
.search-input:focus,.search-input:hover,.search-input:active{background-color:var(--surface);color:var(--text)}

/* Prevent browser autofill from changing input background/text unexpectedly */
input:-webkit-autofill, .search-input:-webkit-autofill {
  -webkit-box-shadow: 0 0 0 1000px var(--surface) inset !important;
  -webkit-text-fill-color: var(--text) !important;
}
.search-input::placeholder{color:var(--text-muted)}
.search-input:focus{outline:none;border-color:var(--accent-2);box-shadow:0 0 0 3px rgba(59,130,246,0.1)}
.result-count{color:var(--text-muted);font-size:0.95rem;font-weight:500}

/* Pagination */
.pagination{display:flex;gap:10px;justify-content:center;margin:32px 0}
.page-btn{padding:10px 14px;border-radius:10px;border:1px solid var(--border);background:var(--surface);color:var(--text);cursor:pointer;font-weight:500;transition:all 0.2s ease}
.page-btn:hover:not(:disabled){background:var(--surface-hover);border-color:var(--border-hover)}
.page-btn.active{background:var(--accent-2);color:#fff;font-weight:700;border-color:transparent}
.page-btn:disabled{opacity:0.5;cursor:default}

/* Theme selector */
.theme-selector{display:flex;align-items:center;gap:8px}
.theme-btn{padding:8px;border-radius:8px;border:1px solid var(--border);background:var(--surface);color:var(--text-muted);cursor:pointer;transition:all 0.2s ease;font-size:16px}
.theme-btn:hover{background:var(--surface-hover);color:var(--text)}
.theme-btn.active{background:var(--accent-2);color:#fff;border-color:var(--accent-2)}

/* Theme button icons */
.theme-btn .theme-icon-black{display:block}
.theme-btn .theme-icon-white{display:none}
.theme-btn.active .theme-icon-black{display:block}
.theme-btn.active .theme-icon-white{display:none}

/* Dark theme - show white icons by default, black when active */
[data-theme="dark"] .theme-btn .theme-icon-black{display:none}
[data-theme="dark"] .theme-btn .theme-icon-white{display:block}
[data-theme="dark"] .theme-btn.active .theme-icon-black{display:block}
[data-theme="dark"] .theme-btn.active .theme-icon-white{display:none}
/* Light mode button should always show black icon in dark theme */
[data-theme="dark"] .theme-btn[data-theme="light"] .theme-icon-black{display:block}
[data-theme="dark"] .theme-btn[data-theme="light"] .theme-icon-white{display:none}

/* System theme dark preference */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) .theme-btn .theme-icon-black{display:none}
  :root:not([data-theme]) .theme-btn .theme-icon-white{display:block}
  :root:not([data-theme]) .theme-btn.active .theme-icon-black{display:block}
  :root:not([data-theme]) .theme-btn.active .theme-icon-white{display:none}
  /* Light mode button should always show black icon when system is dark */
  :root:not([data-theme]) .theme-btn[data-theme="light"] .theme-icon-black{display:block}
  :root:not([data-theme]) .theme-btn[data-theme="light"] .theme-icon-white{display:none}
}

/* Responsive adjustments */
@media (max-width:768px){
  .header-inner{flex-direction:column;gap:16px;text-align:center}
  .site-brand{flex-direction:column;gap:8px}
  .theme-selector{order:1}
}

/* Scroll to top button */
.scroll-to-top{position:fixed;bottom:24px;right:24px;width:48px;height:48px;border-radius:50%;background:var(--accent-2);border:none;color:#fff;cursor:pointer;box-shadow:none;transition:transform 0.3s ease,opacity 0.3s ease;opacity:0;visibility:hidden;display:flex;align-items:center;justify-content:center;font-size:20px}
.scroll-to-top.visible{opacity:1;visibility:visible}
.scroll-to-top:hover{transform:translateY(-2px) scale(1.1);box-shadow:none}
.scroll-to-top:active{transform:translateY(0) scale(1.05)}

/* Utility */
.visually-hidden{position:absolute!important;height:1px;width:1px;overflow:hidden;clip:rect(1px,1px,1px,1px);white-space:nowrap}

/* Personality touches */
.accent-pill{display:inline-block;padding:8px 14px;border-radius:999px;background:var(--accent-2);color:#fff;font-weight:700;font-size:0.9rem;box-shadow:0 4px 12px rgba(59,130,246,0.08)}

/* Minimal footer */
.site-footer{border-top:1px solid var(--border);padding:32px 0;margin-top:40px;color:var(--text-muted);font-size:0.9rem;text-align:center;background:var(--glass)}
.site-footer .twitter-link { color: #000; font-weight: bold; }
html[data-theme="light"] .site-footer .twitter-link { color: #000 !important; font-weight: bold; }
html[data-theme="dark"] .site-footer .twitter-link { color: #fff !important; font-weight: bold; }
@media (prefers-color-scheme: light) {
  .site-footer .twitter-link { color: #000 !important; font-weight: bold; }
}
@media (prefers-color-scheme: dark) {
  .site-footer .twitter-link { color: #fff !important; font-weight: bold; }
}

/* Accessible focus for links */
.card-link:focus{outline:3px solid rgba(51,153,255,0.18);outline-offset:-3px;border-radius:10px}

/* Twitter tweet alignment */
.tweet-container {
  display: flex;
  justify-content: center;
  margin: 24px 0;
  width: 100%;
}

.twitter-tweet {
  margin: 0 auto !important;
  max-width: 550px;
}

/* Ensure tweets are centered on all screen sizes */
@media (max-width: 768px) {
  .tweet-container {
    margin: 20px 0;
  }
  
  .twitter-tweet {
    max-width: 100%;
    width: 100% !important;
  }
}

/* Cookie Consent Banner */
.cookie-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  box-shadow: 0 -8px 24px var(--shadow);
  z-index: 9999;
  padding: 20px;
  animation: slideUp 0.3s ease;
}

@keyframes slideUp {
  from {
    transform: translateY(100%);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.cookie-banner-content {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.cookie-banner-text {
  flex: 1;
  color: var(--text);
}

.cookie-banner-text p {
  margin: 8px 0;
  font-size: 0.95rem;
  line-height: 1.5;
}

.cookie-banner-text p:first-child {
  margin-top: 0;
}

.cookie-privacy-link {
  color: var(--accent-2);
  text-decoration: none;
}

.cookie-privacy-link:hover {
  text-decoration: underline;
}

.cookie-banner-actions {
  display: flex;
  gap: 12px;
  flex-shrink: 0;
}

.cookie-btn {
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 0.95rem;
}

.cookie-btn-primary {
  background: var(--accent-2);
  color: #fff;
}

.cookie-btn-primary:hover {
  opacity: 0.9;
  transform: translateY(-2px);
}

.cookie-btn-secondary {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}

.cookie-btn-secondary:hover {
  border-color: var(--border-hover);
  background: var(--surface-hover);
}

@media (max-width: 768px) {
  .cookie-banner-content {
    flex-direction: column;
    align-items: stretch;
  }
  
  .cookie-banner-actions {
    flex-direction: column;
  }
  
  .cookie-btn {
    width: 100%;
  }
}
