/*
Theme Name: SKS Finance Theme
Theme URI: https://finance.sahilkumarsingh.com
Author: Sahil Kumar Singh
Author URI: https://www.sahilkumarsingh.com
Description: A newspaper-style WordPress theme matching the Astro site aesthetics.
Version: 1.0.0
Requires at least: 6.0
Tested up to: 6.6
Requires PHP: 7.4
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Text Domain: sks-finance
Tags: blog, two-columns, responsive-layout, custom-logo, news, typography
*/

/* Base reset and fonts (fonts enqueued via functions.php) */

:root {
  --paper-bg: #f9f7f1;
  --ink: #222;
}

html {
  background-image: url('natural-paper.png');
  background-repeat: repeat;
  background-color: var(--paper-bg);
}

body {
  margin: 0;
  width: 100%;
  height: 100%;
  font-family: 'Lora', serif;
  color: var(--ink);
  position: relative;
  z-index: 1;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background: linear-gradient(rgba(0,0,0,0.01), rgba(0,0,0,0.01));
  opacity: 0.5;
  z-index: -1;
  animation: subtleFlicker 15s infinite linear alternate;
  pointer-events: none;
}

@keyframes subtleFlicker {
  0% { opacity: 0.4; }
  100% { opacity: 0.6; }
}

.newspaper-theme { 
  padding: 1rem; 
  width: 100%;
  max-width: 100vw;
  box-sizing: border-box;
  overflow-x: hidden;
}

@media (max-width: 767px) {
  .newspaper-theme {
    padding: 0.5rem;
  }
}

@media (max-width: 480px) {
  .newspaper-theme {
    padding: 0.25rem;
  }
}

.newspaper-container {
  max-width: 1200px;
  margin: 2rem auto;
  border: 3px solid #aaa; /* match Astro */
  background-color: #fdfdfa;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.newspaper-header { 
  padding: 1rem; 
  text-align: center; 
  border-bottom: 1px solid var(--ink); 
  width: 100%;
  box-sizing: border-box;
  overflow-x: hidden;
}

@media (max-width: 767px) {
  .newspaper-header {
    padding: 0.75rem 0.5rem;
  }
}

@media (max-width: 480px) {
  .newspaper-header {
    padding: 0.5rem 0.25rem;
  }
}
.site-title { font-family: 'Playfair Display', serif; font-weight: 900; font-size: 3.5rem; margin: 0 auto; line-height: 1; text-transform: uppercase; letter-spacing: -1px; display: flex; justify-content: center; }
.site-title a { display: inline-block; text-decoration: none; color: var(--ink); background: transparent; }
.site-title a:first-child { font-size: 3.8rem; padding: 0 0.5rem; position: relative; z-index: 1; }
.site-title a:first-child::before { content: ''; position: absolute; top: 0; right: 0; bottom: 0; left: 0; background-color: #a7f3d0; z-index: -1; transform: scaleX(0); transform-origin: left; animation: highlightText 1s ease-out forwards; }
@keyframes highlightText { 0% { transform: scaleX(0); } 100% { transform: scaleX(1); } }
.site-title a:last-child {
  font-size: 2.5rem;
  align-self: center;
  padding-bottom: 0.2rem;
  border: none !important;
  background: none !important;
  box-shadow: none !important;
  outline: none !important;
  text-decoration: none !important;
  border-bottom: 2px solid #000 !important;
  display: inline;
}
/* Responsive: Prevent horizontal scroll and fit all screens */
* {
  box-sizing: border-box;
}

html, body {
  max-width: 100vw;
  overflow-x: hidden;
  width: 100%;
}

.newspaper-container {
  width: 100%;
  max-width: 1200px;
  margin: 2rem auto;
  padding: 0 1rem;
  box-sizing: border-box;
}

.newspaper-section, .newspaper-content {
  width: 100%;
  box-sizing: border-box;
}

.newspaper-grid {
  width: 100%;
  box-sizing: border-box;
  display: grid;
  gap: 1.5rem;
  grid-template-columns: 1fr;
}

.article-image {
  width: 100%;
  max-width: 100%;
  height: 200px;
  object-fit: cover;
  display: block;
}

/* Tablet and Desktop Responsive */
@media (min-width: 768px) {
  .newspaper-grid { 
    grid-template-columns: repeat(2, 1fr);
  }
  .newspaper-container {
    padding: 0 2rem;
  }
}

@media (min-width: 1024px) {
  .newspaper-grid { 
    grid-template-columns: repeat(3, 1fr);
  }
}

/* Mobile specific adjustments */
@media (max-width: 767px) {
  .newspaper-container {
    margin: 1rem auto;
    padding: 0 0.5rem;
    border-left: none;
    border-right: none;
  }
  
  .site-title { 
    font-size: 1.8rem; 
    flex-direction: column;
    gap: 0.25rem;
  }
  
  .site-title a:first-child { 
    font-size: 2rem; 
  }
  
  .site-title a:last-child { 
    font-size: 1.2rem; 
  }
  
  .site-subtitle {
    font-size: 1rem;
  }
  
  .newspaper-content { 
    padding: 1rem 0.5rem; 
  }
  
  .newspaper-heading { 
    font-size: 1.8rem; 
  }
  
  .article-image { 
    height: 180px; 
  }
  
  .article-content {
    padding: 1rem;
  }
  
  .search-container {
    margin-bottom: 1.5rem;
  }
}

/* Extra small mobile devices */
@media (max-width: 480px) {
  .newspaper-container {
    margin: 0.5rem auto;
    padding: 0 0.25rem;
  }
  
  .site-title { 
    font-size: 1.4rem; 
  }
  
  .site-title a:first-child { 
    font-size: 1.6rem; 
  }
  
  .site-title a:last-child { 
    font-size: 1rem; 
  }
  
  .site-subtitle {
    font-size: 0.9rem;
  }
  
  .newspaper-content { 
    padding: 0.5rem 0.25rem; 
  }
  
  .newspaper-heading { 
    font-size: 1.4rem; 
  }
  
  .article-image { 
    height: 150px; 
  }
  
  .article-content {
    padding: 0.75rem;
  }
  
  .article-title {
    font-size: 1.1rem !important;
  }
  
  .article-description {
    font-size: 0.9rem;
    -webkit-line-clamp: 2;
    line-clamp: 2;
  }
}
.site-title .by-sks { font-weight: 700; border-bottom: 2px solid #000; margin-left: 0.5rem; }
.site-subtitle { font-style: italic; margin-top: 0.5rem; font-size: 1.2rem; font-weight: 400; }
.newspaper-date { margin-top: 1rem; font-size: 0.9rem; text-transform: uppercase; letter-spacing: 1px; }

.newspaper-content { padding: 1.5rem; min-height: 70vh; }
.newspaper-footer { padding: 1rem; text-align: center; font-size: 0.8rem; border-top: 1px solid var(--ink); }

/* Header/Footer colors and link styles: force black text/links and no default underlines */
.newspaper-header, .newspaper-footer { color: var(--ink); }
.newspaper-header a, .newspaper-footer a { color: #000 !important; text-decoration: none; background: transparent; }
.newspaper-header a.by-sks { border: none; background: none; box-shadow: none; outline: none; border-bottom: 2px solid #000; }
.newspaper-header a:focus, .newspaper-footer a:focus { outline: none; box-shadow: none; }
.newspaper-header a:hover, .newspaper-footer a:hover, .newspaper-header a:visited, .newspaper-footer a:visited, .newspaper-header a:active, .newspaper-footer a:active {
  color: var(--ink) !important;
}

.newspaper-section { max-width: 1100px; margin: 0 auto; }
.newspaper-heading { font-size: 2.5rem; margin-bottom: 1.5rem; text-align: center; font-family: 'Playfair Display', serif; font-weight: 900; padding-bottom: 0.75rem; border-bottom: 2px solid var(--ink); text-transform: uppercase; letter-spacing: 1px; }

.newspaper-grid { display: grid; grid-template-columns: repeat(1, 1fr); gap: 1.5rem; background-color: transparent; }
.newspaper-grid > * { background-color: #fff; padding: 0; border-right: none; border-left: none; margin-bottom: 0; }

.newspaper-grid .newspaper-article { margin-bottom: 0; }

.error-message, .empty-message { text-align: center; padding: 2rem; font-style: italic; }

.newspaper-article { margin-bottom: 1.5rem; background: #fff; transition: background-color 0.2s ease; }
.newspaper-article:hover { background-color: #f9f7f1; }
.article-link { text-decoration: none; color: inherit; display: block; }
.article-image { width: 100%; height: 200px; object-fit: cover; }
.article-content { padding: 1.25rem; }
.newspaper-article .article-title { margin: 0 0 0.75rem; font-family: 'Playfair Display', serif; font-size: 1.3rem; font-weight: 700; line-height: 1.2; color: var(--ink); }
.article-description { margin: 0.75rem 0; color: #333; line-height: 1.5; font-family: 'Lora', serif; display: -webkit-box; -webkit-line-clamp: 3; line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; text-overflow: ellipsis; max-height: 4.5rem; }
.article-meta { margin-top: 1rem; font-size: 0.875rem; display: flex; justify-content: space-between; color: #555; padding-top: 0.75rem; font-style: italic; }
.article-tags { 
  display: flex; 
  gap: 0.5rem; 
  flex-wrap: wrap; 
  margin-top: 0.75rem; 
  width: 100%;
  box-sizing: border-box;
}

.article-tag { 
  border: 1px solid var(--ink); 
  padding: 0.15rem 0.5rem; 
  font-size: 0.75rem; 
  text-transform: uppercase; 
  letter-spacing: 0.5px; 
  white-space: nowrap;
  box-sizing: border-box;
}

@media (max-width: 767px) {
  .article-tags {
    gap: 0.35rem;
    margin-top: 0.5rem;
  }
  
  .article-tag {
    padding: 0.1rem 0.4rem;
    font-size: 0.7rem;
    letter-spacing: 0.3px;
  }
}

@media (max-width: 480px) {
  .article-tags {
    gap: 0.25rem;
  }
  
  .article-tag {
    padding: 0.1rem 0.3rem;
    font-size: 0.65rem;
    letter-spacing: 0.2px;
  }
}

.newspaper-article-detail { 
  max-width: 950px; 
  margin: 0 auto; 
  padding-bottom: 3rem; 
  width: 100%; 
  box-sizing: border-box;
}

.back-button { 
  margin: 1.5rem 0; 
  padding: 0; 
}

.back-link { 
  display: inline-block; 
  font-family: 'Playfair Display', serif; 
  color: var(--ink); 
  text-decoration: none; 
  border: 1px solid var(--ink); 
  padding: 0.5rem 1rem; 
  font-size: 0.9rem; 
  transition: all 0.2s ease; 
}

.back-link:hover { 
  background-color: var(--ink); 
  color: #fff; 
}

.article-hero { 
  margin-bottom: 2rem; 
  height: 300px; 
  overflow: hidden; 
  width: 100%; 
  box-sizing: border-box;
}

.article-hero-image { 
  width: 100%; 
  height: 100%; 
  object-fit: cover; 
  display: block;
}

.article-container { 
  max-width: 100%; 
  margin: 0 auto; 
  padding: 0 1rem; 
  box-sizing: border-box;
}

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

.article-header .article-title { 
  font-family: 'Playfair Display', serif; 
  font-weight: 900; 
  font-size: 2.5rem; 
  line-height: 1.2; 
  margin-bottom: 1rem; 
  color: var(--ink); 
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.article-body { 
  font-family: 'Lora', serif; 
  line-height: 1.8; 
  color: #333; 
  width: 100%;
  overflow-wrap: break-word;
  word-wrap: break-word;
}

.article-description { 
  font-size: 1.25rem; 
  line-height: 1.6; 
  margin-bottom: 2rem; 
  font-weight: 500; 
  color: #333; 
  font-family: 'Lora', serif; 
  border-left: 3px solid var(--ink); 
  padding-left: 1rem; 
  font-style: italic; 
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.article-body h1, .article-body h2, .article-body h3, .article-body h4, .article-body h5, .article-body h6, .article-title { 
  text-align: left; 
  text-justify: none; 
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.article-body h2 { 
  font-family: 'Playfair Display', serif; 
  font-weight: 700; 
  font-size: 1.8rem; 
  margin: 2rem 0 1rem; 
  border-bottom: 1px solid #ddd; 
  padding-bottom: 0.5rem; 
}

.article-body h3 { 
  font-family: 'Playfair Display', serif; 
  font-weight: 600; 
  font-size: 1.5rem; 
  margin: 1.5rem 0 1rem; 
}

.article-body p { 
  margin-bottom: 1.5rem; 
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.article-body blockquote { 
  border-left: 3px solid var(--ink); 
  padding-left: 1rem; 
  margin-left: 0; 
  margin-right: 0; 
  font-style: italic; 
  word-wrap: break-word;
  overflow-wrap: break-word;
}

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

.article-body li { 
  margin-bottom: 0.5rem; 
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.article-body img {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 1rem auto;
}

.article-body table {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  display: block;
  white-space: nowrap;
}

.article-body pre, .article-body code {
  overflow-x: auto;
  word-wrap: break-word;
  white-space: pre-wrap;
}

/* Justify non-heading text across content areas */
.newspaper-content p,
.newspaper-content li,
.newspaper-content blockquote,
.newspaper-content dd,
.newspaper-content figcaption,
.article-content p,
.article-description,
.article-body p,
.article-body li,
.article-body blockquote,
.comment-content p,
.comment-content li,
.comment-content blockquote {
  text-align: justify;
  text-justify: inter-word;
  hyphens: auto;
}

/* Mobile responsiveness for single posts */
@media (max-width: 767px) {
  .newspaper-article-detail {
    padding-bottom: 2rem;
  }
  
  .article-container {
    padding: 0 0.5rem;
  }
  
  .article-hero {
    height: 200px;
    margin-bottom: 1.5rem;
  }
  
  .article-header .article-title {
    font-size: 1.8rem;
    margin-bottom: 0.75rem;
  }
  
  .article-description {
    font-size: 1.1rem;
    margin-bottom: 1.5rem;
    padding-left: 0.75rem;
  }
  
  .article-body h2 {
    font-size: 1.5rem;
    margin: 1.5rem 0 0.75rem;
  }
  
  .article-body h3 {
    font-size: 1.3rem;
    margin: 1.25rem 0 0.75rem;
  }
  
  .article-body p {
    margin-bottom: 1.25rem;
  }
  
  .back-button {
    margin: 1rem 0;
  }
  
  .back-link {
    font-size: 0.8rem;
    padding: 0.4rem 0.8rem;
  }
}

@media (max-width: 480px) {
  .article-container {
    padding: 0 0.25rem;
  }
  
  .article-hero {
    height: 180px;
    margin-bottom: 1rem;
  }
  
  .article-header .article-title {
    font-size: 1.5rem;
    line-height: 1.3;
  }
  
  .article-description {
    font-size: 1rem;
    margin-bottom: 1.25rem;
    padding-left: 0.5rem;
  }
  
  .article-body h2 {
    font-size: 1.3rem;
  }
  
  .article-body h3 {
    font-size: 1.2rem;
  }
  
  .article-body {
    font-size: 0.95rem;
    line-height: 1.7;
  }
}

/* Search components from Astro home page */
.search-container { 
  display: grid; 
  grid-template-columns: 1fr auto; 
  align-items: center; 
  gap: 0.5rem; 
  margin-bottom: 1rem; 
  width: 100%; 
  box-sizing: border-box;
}

.search-form { 
  width: 100%; 
  display: grid; 
  grid-template-columns: 1fr auto; 
  gap: 0.5rem; 
  align-items: center; 
  box-sizing: border-box;
}

#searchInput, .search-field { 
  padding: 0.5rem 0.75rem; 
  border: 1px solid var(--ink); 
  background: #fff; 
  font-family: 'Lora', serif; 
  width: 100%; 
  box-sizing: border-box;
  min-width: 0;
}

#searchButton, .search-submit { 
  padding: 0.5rem 0.75rem; 
  border: 1px solid var(--ink); 
  background: #fff; 
  cursor: pointer; 
  font-family: 'Playfair Display', serif; 
  white-space: nowrap;
  box-sizing: border-box;
}

#searchButton:hover, .search-submit:hover { 
  background: var(--ink); 
  color: #fff; 
}

/* Mobile search form */
@media (max-width: 767px) {
  .search-container {
    margin-bottom: 1.5rem;
  }
  
  .search-form {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }
  
  #searchInput, .search-field {
    padding: 0.6rem 0.75rem;
    font-size: 1rem;
  }
  
  #searchButton, .search-submit {
    padding: 0.6rem 1rem;
    justify-self: start;
    font-size: 0.9rem;
  }
}

@media (max-width: 480px) {
  #searchInput, .search-field {
    padding: 0.5rem;
    font-size: 0.9rem;
  }
  
  #searchButton, .search-submit {
    padding: 0.5rem 0.75rem;
    font-size: 0.85rem;
  }
}

/* Minimal utility classes for compatibility with Astro markup */
.uppercase { text-transform: uppercase; }
.ml-2 { margin-left: 0.5rem; }
.border-black { border-color: #000; }
.border-b-1 { border-bottom-width: 1px; border-style: solid; }
.border-b-2 { border-bottom-width: 2px; border-style: solid; }
.font-bold { font-weight: 700; }
.flex { display: flex; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }

/* Global responsive images and media */
img, video, iframe, embed, object {
  max-width: 100%;
  height: auto;
  box-sizing: border-box;
}

/* Prevent any content from causing horizontal scroll */
.newspaper-container *,
.newspaper-section *,
.newspaper-content *,
.newspaper-article * {
  max-width: 100%;
  box-sizing: border-box;
}

/* Ensure tables are scrollable on mobile */
.newspaper-content table,
.article-body table {
  width: 100%;
  overflow-x: auto;
  display: block;
  white-space: nowrap;
}

@media (max-width: 767px) {
  .newspaper-content table,
  .article-body table {
    font-size: 0.9rem;
  }
}

/* Responsive utilities for mobile */
@media (max-width: 767px) {
  .ml-2 {
    margin-left: 0.25rem;
  }
  
  .flex {
    flex-wrap: wrap;
  }
}

/* Cards (match Astro-style) */
.newspaper-article { 
  border: 1px solid var(--ink); 
  width: 100%;
  box-sizing: border-box;
  overflow: hidden;
}

.newspaper-article .article-image { 
  height: 200px; 
  border-bottom: 1px solid var(--ink); 
  object-fit: cover; 
  width: 100%; 
  display: block;
  max-width: 100%;
}

.newspaper-article .article-meta { 
  border-top: 1px solid #ddd; 
}

/* Ensure all content within articles fits properly */
.newspaper-article * {
  max-width: 100%;
  box-sizing: border-box;
}

.newspaper-article .article-content {
  width: 100%;
  box-sizing: border-box;
  overflow-wrap: break-word;
  word-wrap: break-word;
}

/* Responsive columns handled above in main responsive section */

/* Comments */
.comment-list { 
  list-style: none; 
  padding-left: 0; 
  width: 100%;
  box-sizing: border-box;
}

.comment-list .comment { 
  border: 1px solid var(--ink); 
  background: #fff; 
  padding: 1rem; 
  margin-bottom: 1rem; 
  word-wrap: break-word;
  overflow-wrap: break-word;
  box-sizing: border-box;
}

.comment-list .children { 
  list-style: none; 
  margin-left: 1rem; 
  padding-left: 1rem; 
  border-left: 1px dashed #ccc; 
  box-sizing: border-box;
}

.comment-meta, .comment-author, .comment-metadata { 
  font-size: 0.875rem; 
  color: #555; 
}

.comment-content { 
  margin-top: 0.5rem; 
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.comment-respond { 
  margin-top: 2rem; 
  border-top: 1px solid var(--ink); 
  padding-top: 1rem; 
  width: 100%;
  box-sizing: border-box;
}

.comment-respond label { 
  display: block; 
  margin: 0.5rem 0 0.25rem; 
}

.comment-respond input[type="text"], 
.comment-respond input[type="email"], 
.comment-respond input[type="url"], 
.comment-respond textarea { 
  width: 100%; 
  border: 1px solid var(--ink); 
  padding: 0.5rem; 
  font-family: 'Lora', serif; 
  box-sizing: border-box;
  max-width: 100%;
}

.comment-respond input[type="submit"] { 
  border: 1px solid var(--ink); 
  background: #fff; 
  padding: 0.5rem 0.75rem; 
  cursor: pointer; 
  font-family: 'Playfair Display', serif; 
  box-sizing: border-box;
}

.comment-respond input[type="submit"]:hover { 
  background: var(--ink); 
  color: #fff; 
}

.comment-respond textarea {
  min-height: 120px;
  resize: vertical;
}

/* Mobile comments */
@media (max-width: 767px) {
  .comment-list .comment {
    padding: 0.75rem;
  }
  
  .comment-list .children {
    margin-left: 0.5rem;
    padding-left: 0.5rem;
  }
  
  .comment-respond {
    margin-top: 1.5rem;
    padding-top: 0.75rem;
  }
  
  .comment-respond input[type="text"], 
  .comment-respond input[type="email"], 
  .comment-respond input[type="url"], 
  .comment-respond textarea {
    padding: 0.6rem;
    font-size: 1rem;
  }
  
  .comment-respond input[type="submit"] {
    padding: 0.6rem 1rem;
    font-size: 0.9rem;
  }
}

@media (max-width: 480px) {
  .comment-list .comment {
    padding: 0.5rem;
  }
  
  .comment-respond input[type="text"], 
  .comment-respond input[type="email"], 
  .comment-respond input[type="url"], 
  .comment-respond textarea {
    padding: 0.5rem;
    font-size: 0.9rem;
  }
  
  .comment-respond input[type="submit"] {
    padding: 0.5rem 0.75rem;
    font-size: 0.85rem;
  }
}

/* Accessibility */
.screen-reader-text {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Pagination */
.pagination { 
  margin: 2rem 0; 
  width: 100%;
  box-sizing: border-box;
}

.pagination .nav-links { 
  display: flex; 
  justify-content: space-between; 
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}

.pagination a { 
  color: var(--ink); 
  text-decoration: none; 
  border: 1px solid var(--ink); 
  padding: 0.4rem 0.8rem; 
  white-space: nowrap;
  box-sizing: border-box;
}

.pagination a:hover { 
  background: var(--ink); 
  color: #fff; 
}

/* Mobile pagination */
@media (max-width: 767px) {
  .pagination {
    margin: 1.5rem 0;
  }
  
  .pagination .nav-links {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
  }
  
  .pagination a {
    padding: 0.6rem 1rem;
    text-align: center;
    font-size: 0.9rem;
  }
}

@media (max-width: 480px) {
  .pagination a {
    padding: 0.5rem 0.75rem;
    font-size: 0.85rem;
  }
}
