/* style.css (Bootstrap 5) */

/* Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Merriweather:ital,wght@0,400;0,700;1,400&display=swap');

/* Design tokens */
:root {
  --accent:      #1a8917;
  --accent-dark: #147012;
  --text-main:   #1a1a1a;
  --text-muted:  #6b7280;
  --border:      #e5e7eb;
  --bg:          #ffffff;
  --bg-soft:     #f9fafb;
  --font-ui:     'Inter', system-ui, sans-serif;
  --font-article:'Merriweather', Georgia, serif;
}

/* Base reset */
*, *::before, *::after { box-sizing: border-box; }

body {
  font-family: var(--font-ui);
  color: var(--text-main);
  background: var(--bg);
  margin: 0;
}

a { color: inherit; }
img { max-width: 100%; }

/* Navbar */
.site-navbar {
  background: #fff;
  border-bottom: 1px solid var(--border);
  padding: .75rem 0;
  position: sticky;
  top: 0;
  z-index: 1000;
}

.navbar-logo {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -.5px;
  color: var(--text-main);
  text-decoration: none;
}

.navbar-logo span { color: var(--accent); }

.nav-link-item {
  font-size: .875rem;
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
  padding: .3rem .65rem;
  border-radius: 6px;
  transition: color .15s, background .15s;
}
.nav-link-item:hover, .nav-link-item.active { color: var(--text-main); background: var(--bg-soft); }

.btn-write-nav {
  background: var(--accent) !important;
  border-color: var(--accent) !important;
  font-size: .82rem;
  font-weight: 500;
  padding: .35rem .85rem;
}
.btn-write-nav:hover { background: var(--accent-dark) !important; border-color: var(--accent-dark) !important; }

.dropdown-toggle-no-caret::after { display: none !important; }

/* Avatar initials */
.avatar-initials {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  color: #fff;
  font-weight: 700;
  flex-shrink: 0;
  letter-spacing: 0;
  line-height: 1;
}

/* Category badge */
.badge-cat {
  display: inline-block;
  font-size: .7rem;
  font-weight: 600;
  padding: .2rem .55rem;
  border-radius: 20px;
  background: #f0fdf4;
  color: var(--accent);
  border: 1px solid #bbf7d0;
  white-space: nowrap;
}

/* Meta text */
.meta-author { font-size: .82rem; font-weight: 600; }
.meta-date, .meta-read { font-size: .8rem; color: var(--text-muted); }
.meta-sep { color: var(--text-muted); font-size: .8rem; }

/* INDEX PAGE */

/* Category filter bar */
.filter-bar {
  border-bottom: 1px solid var(--border);
  padding: .5rem 0;
  display: flex;
  gap: .35rem;
  overflow-x: auto;
  scrollbar-width: none;
}
.filter-bar::-webkit-scrollbar { display: none; }

.filter-btn {
  font-size: .83rem;
  font-weight: 500;
  padding: .35rem .85rem;
  border-radius: 20px;
  border: 1px solid transparent;
  background: none;
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
  transition: all .15s;
}
.filter-btn:hover { background: var(--bg-soft); color: var(--text-main); }
.filter-btn.active {
  background: var(--text-main);
  color: #fff;
  border-color: var(--text-main);
}

/* Featured article */
.featured-card {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
  align-items: center;
  padding: 2.5rem 0;
  border-bottom: 1px solid var(--border);
}

@media (max-width: 767px) {
  .featured-card { grid-template-columns: 1fr; gap: 1rem; }
}

.featured-img-wrap img {
  width: 100%;
  height: 280px;
  object-fit: cover;
  border-radius: 10px;
}

.featured-title {
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1.28;
  color: var(--text-main);
  margin: .6rem 0 .75rem;
  transition: color .15s;
}
.featured-title:hover { color: var(--accent); }

.featured-preview {
  font-size: .95rem;
  color: var(--text-muted);
  line-height: 1.6;
}

/* Article grid */
.article-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 1.75rem;
  padding: 2rem 0;
}

.article-card {
  display: flex;
  flex-direction: column;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border);
  transition: box-shadow .2s, transform .2s;
  background: #fff;
}
.article-card:hover { box-shadow: 0 4px 20px rgba(0,0,0,.08); transform: translateY(-3px); }

.card-img-wrap img {
  width: 100%;
  height: 180px;
  object-fit: cover;
  display: block;
}

.card-body-custom { padding: 1rem; flex: 1; display: flex; flex-direction: column; gap: .4rem; }

.card-author { font-size: .8rem; font-weight: 600; }

.card-title-custom {
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.4;
  color: var(--text-main);
  margin: 0;
  transition: color .15s;
}
.card-title-custom:hover { color: var(--accent); }

.card-preview { font-size: .83rem; color: var(--text-muted); line-height: 1.5; flex: 1; }

.card-footer-custom { margin-top: auto; padding-top: .5rem; border-top: 1px solid var(--border); }

/* Sidebar */
.sidebar-section { margin-bottom: 2rem; }
.sidebar-title {
  font-size: .8rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.topic-chip {
  display: inline-block;
  font-size: .82rem;
  font-weight: 500;
  padding: .35rem .8rem;
  border-radius: 20px;
  background: var(--bg-soft);
  color: var(--text-main);
  text-decoration: none;
  border: 1px solid var(--border);
  margin: 0 .35rem .5rem 0;
  transition: background .15s, border-color .15s;
}
.topic-chip:hover { background: #e5e7eb; border-color: #d1d5db; }

.author-rec-row { padding: .5rem 0; border-bottom: 1px solid var(--border); transition: background-color 0.15s; }
.author-rec-row:last-child { border-bottom: none; }
.author-rec-name { transition: color 0.15s ease; }
.author-rec-row:hover .author-rec-name { color: var(--accent) !important; }

/* AUTH PAGES (login & register) */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-soft);
  padding: 2rem 1rem;
}

.auth-card {
  background: #fff;
  border-radius: 14px;
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 4px 30px rgba(0,0,0,.08);
}

.auth-logo {
  font-size: 1.4rem;
  font-weight: 700;
  text-align: center;
  margin-bottom: .25rem;
  letter-spacing: -.5px;
}
.auth-logo span { color: var(--accent); }

.auth-subtitle {
  text-align: center;
  color: var(--text-muted);
  font-size: .88rem;
  margin-bottom: 1.75rem;
}

.auth-card .form-label {
  font-size: .85rem;
  font-weight: 600;
  margin-bottom: .3rem;
}

.auth-card .form-control {
  font-size: .9rem;
  padding: .55rem .75rem;
  border-radius: 8px;
  border-color: var(--border);
}
.auth-card .form-control:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(26,137,23,.12);
}

.btn-auth {
  background: var(--text-main);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-weight: 600;
  font-size: .9rem;
  padding: .65rem;
  width: 100%;
  transition: background .15s;
}
.btn-auth:hover { background: #333; color: #fff; }

.auth-switch {
  text-align: center;
  font-size: .85rem;
  color: var(--text-muted);
  margin-top: 1.25rem;
}
.auth-switch a { color: var(--accent); font-weight: 600; text-decoration: none; }
.auth-switch a:hover { text-decoration: underline; }

/* ARTICLE DETAIL PAGE */
.article-hero-img {
  width: 100%;
  max-height: 460px;
  object-fit: cover;
  border-radius: 12px;
  margin-bottom: 2rem;
}

.article-header { margin-bottom: 2rem; }

.article-main-title {
  font-family: var(--font-article);
  font-size: 2.2rem;
  font-weight: 700;
  line-height: 1.25;
  color: var(--text-main);
  margin-bottom: 1.25rem;
}

.article-body {
  font-family: var(--font-article);
  font-size: 1.1rem;
  line-height: 1.85;
  color: #1f2937;
  max-width: 680px;
  margin: 0 auto;
}

.article-body h2 {
  font-family: var(--font-ui);
  font-size: 1.4rem;
  font-weight: 700;
  margin: 2rem 0 .75rem;
  color: var(--text-main);
}

.article-body p { margin-bottom: 1.4rem; }

.article-body ul, .article-body ol {
  padding-left: 1.5rem;
  margin-bottom: 1.4rem;
}
.article-body li { margin-bottom: .4rem; }

.article-body code {
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: .85em;
  background: #f3f4f6;
  padding: .1em .4em;
  border-radius: 4px;
  color: #dc2626;
}

.article-body figure { margin: 1.5rem 0; }
.article-body figcaption { font-family: var(--font-ui); }

/* Clap button */
.clap-wrap {
  display: flex;
  align-items: center;
  gap: .6rem;
  margin: 2rem 0;
}

#clap-btn {
  display: flex;
  align-items: center;
  gap: .45rem;
  padding: .5rem 1.1rem;
  border-radius: 24px;
  border: 1.5px solid var(--border);
  background: #fff;
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s;
  color: var(--text-main);
}
#clap-btn:hover { border-color: var(--accent); color: var(--accent); }
#clap-btn.clapped { background: #f0fdf4; border-color: var(--accent); color: var(--accent); }

.clap-icon { font-size: 1.2rem; display: inline-block; }
.clap-animate { animation: clapPop .35s cubic-bezier(.36,.07,.19,.97); }

@keyframes clapPop {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.45) rotate(-10deg); }
  70%  { transform: scale(.9); }
  100% { transform: scale(1); }
}

/* Tags */
.tag-pill {
  display: inline-block;
  font-size: .78rem;
  font-weight: 500;
  padding: .25rem .7rem;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 20px;
  margin: .2rem .2rem 0 0;
  color: var(--text-main);
}

/* Related articles heading */
.related-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 1.25rem;
  padding-bottom: .75rem;
  border-bottom: 2px solid var(--text-main);
  display: inline-block;
}

/*
   PROFILE PAGE
   */
.profile-header {
  padding: 2.5rem 0 1.5rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.5rem;
}

.profile-avatar-wrap {
  margin-bottom: 1rem;
}

.profile-name {
  font-size: 1.6rem;
  font-weight: 700;
  margin-bottom: .3rem;
}

.profile-bio {
  color: var(--text-muted);
  font-size: .92rem;
  max-width: 480px;
  line-height: 1.6;
}

.stat-item {
  text-align: center;
  padding: 0 1.5rem;
  border-right: 1px solid var(--border);
}
.stat-item:last-child { border-right: none; }
.stat-number { font-size: 1.5rem; font-weight: 700; display: block; }
.stat-label  { font-size: .78rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .06em; }

.btn-edit-profile {
  font-size: .85rem;
  font-weight: 600;
  padding: .45rem 1.1rem;
  border-radius: 8px;
  border: 1.5px solid var(--text-main);
  background: #fff;
  color: var(--text-main);
  transition: all .15s;
}
.btn-edit-profile:hover { background: var(--text-main); color: #fff; }

/* Profile tabs */
#profile-tabs .nav-link {
  font-size: .88rem;
  font-weight: 600;
  color: var(--text-muted);
  border: none;
  border-bottom: 2px solid transparent;
  padding: .6rem 1rem;
  border-radius: 0;
  transition: all .15s;
}
#profile-tabs .nav-link.active, #profile-tabs .nav-link:hover {
  color: var(--text-main);
  border-bottom-color: var(--text-main);
  background: none;
}

.profile-article-row {
  padding: 1rem 0;
  border-bottom: 1px solid var(--border);
}
.profile-article-row:last-child { border-bottom: none; }
.profile-article-title { transition: color 0.15s ease; color: var(--text-main); }
.profile-article-title:hover { color: var(--accent) !important; }

.profile-article-thumb {
  width: 80px;
  height: 60px;
  object-fit: cover;
  border-radius: 6px;
  flex-shrink: 0;
}

/* WRITE PAGE */
.write-page { min-height: 100vh; }

.write-container {
  max-width: 720px;
  margin: 0 auto;
  padding: 2rem 1rem 4rem;
}

#article-title.write-title {
  font-family: var(--font-article);
  font-size: 1.85rem;
  font-weight: 700;
  border: none;
  border-bottom: 2px solid var(--border);
  border-radius: 0;
  padding: .6rem 0;
  width: 100%;
  outline: none;
  margin-bottom: 1rem;
  color: var(--text-main);
  background: transparent;
}
#article-title.write-title::placeholder { color: #d1d5db; }
#article-title.write-title:focus { border-bottom-color: var(--accent); box-shadow: none; }

#article-content.write-body {
  font-family: var(--font-article);
  font-size: 1.05rem;
  line-height: 1.9;
  border: none;
  border-radius: 0;
  padding: .5rem 0;
  width: 100%;
  outline: none;
  resize: none;
  min-height: 360px;
  color: var(--text-main);
  background: transparent;
}
#article-content.write-body::placeholder { color: #d1d5db; }
#article-content.write-body:focus { border-color: transparent; box-shadow: none; }

.write-toolbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 0;
  border-top: 1px solid var(--border);
  margin-top: 1.5rem;
}

.btn-publish {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 24px;
  font-size: .9rem;
  font-weight: 600;
  padding: .55rem 1.5rem;
  transition: background .15s;
}
.btn-publish:hover { background: var(--accent-dark); color: #fff; }

.write-select {
  font-size: .88rem;
  padding: .5rem .85rem;
  border-radius: 8px;
  border: 1.5px solid var(--border);
  background: #fff;
  color: var(--text-main);
  cursor: pointer;
}
.write-select:focus { border-color: var(--accent); box-shadow: none; outline: none; }

/* Char counter helper */
.write-hint {
  font-size: .78rem;
  color: var(--text-muted);
  margin-left: auto;
}

/*
   FOOTER
   */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 1.5rem 0;
  font-size: .8rem;
  color: var(--text-muted);
}

.footer-links a {
  color: var(--text-muted);
  text-decoration: none;
  margin-left: 1rem;
}
.footer-links a:hover { color: var(--text-main); }

/*
   RESPONSIVE TWEAKS
   */
@media (max-width: 991px) {
  .sidebar-col { display: none; }
}

@media (max-width: 767px) {
  .article-main-title { font-size: 1.55rem; }
  .article-body { font-size: 1rem; }
  .auth-card { padding: 1.75rem 1.25rem; }
  .featured-title { font-size: 1.3rem; }
}

@media (max-width: 575px) {
  .article-grid { grid-template-columns: 1fr; }
}
