/*
 Theme Name: kichava
 Theme URI: https://navatar.blog/my-own-wordpress-theme/
 Author: Kiran Chava
 Author URI: https://navatar.blog
 Description: A minimalist, typography-first WordPress theme for poetry and essays.
 Version: 1.1.0
 Requires at least: 6.0
 Tested up to: 6.4
 Requires PHP: 7.4
 License: GNU General Public License v3 or later
 License URI: https://www.gnu.org/licenses/gpl-3.0.html
 Text Domain: kichava
 Tags: blog, custom-menu, custom-logo, editor-style, featured-images, footer-widgets, full-width-template, rtl-language-support, sticky-post, theme-options, threaded-comments, translation-ready, typography, poetry, minimalist, one-column, two-columns, accessibility-ready

 Copyright (C) 2024 Kiran Chava

 This program is free software: you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
 the Free Software Foundation, either version 3 of the License, or
 (at your option) any later version.

 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.

 You should have received a copy of the GNU General Public License
 along with this program.  If not, see <https://www.gnu.org/licenses/>.
*/

:root {
  --text: #1d1c1a;
  --muted: #6e655b;
  --background: #faf7f2;
  --card: #fffdf8;
  --border: #e2d9cc;
  --accent: #b65c34;
  --accent-dark: #8a4423;
  --serif: "Source Serif 4", Georgia, serif;
  --sans: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --max-width: 1100px;
}

/* Dark mode variables */
@media (prefers-color-scheme: dark) {
  :root:not(.light-mode) {
    --text: #e8e6e3;
    --muted: #a8a39d;
    --background: #1a1815;
    --card: #24211d;
    --border: #3a3630;
    --accent: #d67a52;
    --accent-dark: #c4623a;
  }
}

/* Manual dark mode override */
.dark-mode {
  --text: #e8e6e3;
  --muted: #a8a39d;
  --background: #1a1815;
  --card: #24211d;
  --border: #3a3630;
  --accent: #d67a52;
  --accent-dark: #c4623a;
}

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

html,
body {
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--sans);
  line-height: 1.75;
  background: var(--background);
  color: var(--text);
  min-height: 100vh;
}

a {
  color: inherit;
}

.skip-link {
  position: absolute;
  left: -999px;
  top: auto;
  width: 1px;
  height: 1px;
  overflow: hidden;
}
.skip-link:focus {
  position: static;
  width: auto;
  height: auto;
  padding: 0.5rem 0.75rem;
  background: var(--accent);
  color: #fff;
  text-decoration: none;
}

/* Screen reader text - accessible but visually hidden */
.screen-reader-text {
  border: 0;
  clip: rect(1px, 1px, 1px, 1px);
  clip-path: inset(50%);
  height: 1px;
  margin: -1px;
  overflow: hidden;
  padding: 0;
  position: absolute !important;
  width: 1px;
  word-wrap: normal !important;
}

.screen-reader-text:focus {
  background-color: var(--card);
  border-radius: 3px;
  box-shadow: 0 0 2px 2px rgba(0, 0, 0, 0.6);
  clip: auto !important;
  clip-path: none;
  color: var(--text);
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  height: auto;
  left: 5px;
  line-height: normal;
  padding: 0.9375rem 1.4375rem 0.875rem;
  text-decoration: none;
  top: 5px;
  width: auto;
  z-index: 100000;
}

.site-wrapper {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: clamp(1.5rem, 4vw, 2.5rem) clamp(1rem, 3vw, 1.5rem) clamp(2rem, 5vw, 3.5rem);
}

.custom-header {
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 clamp(1rem, 3vw, 1.5rem);
  margin-bottom: 2rem;
}

.custom-header img {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.site-header {
  grid-column: 1 / -1;
  text-align: center;
  padding-bottom: 2rem;
  border-bottom: 1px solid var(--border);
}

.site-nav-row {
  display: flex;
  gap: 1.5rem;
  align-items: center;
  justify-content: space-between;
  margin-top: 1.5rem;
  flex-wrap: wrap;
}

.nav-search {
  margin-left: auto;
  flex-shrink: 0;
}

.nav-search .search-form {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.nav-search .search-field {
  width: 160px;
  min-width: 120px;
}

.site-title {
  margin: 0.25rem 0;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-size: clamp(1.8rem, 3vw, 2.5rem);
}

.site-title a {
  text-decoration: none;
  color: var(--text);
}

.site-description {
  margin: 0.35rem 0 1.5rem;
  color: var(--muted);
  font-size: 0.95rem;
}

.site-nav .menu,
.site-nav .menu ul {
  list-style: none;
  display: flex;
  flex-wrap: nowrap;
  justify-content: flex-start;
  align-items: center;
  gap: 1.5rem;
  padding: 0;
  margin: 0;
  text-transform: uppercase;
  font-size: 0.85rem;
  letter-spacing: 0.08em;
  overflow-x: auto;
  scrollbar-width: none;
}
.site-nav .menu::-webkit-scrollbar,
.site-nav .menu ul::-webkit-scrollbar {
  display: none;
}
.site-nav .menu li,
.site-nav .menu ul li {
  white-space: nowrap;
}

.site-nav a {
  text-decoration: none;
  color: var(--muted);
}

.site-nav a:hover,
.site-nav .current-menu-item a {
  color: var(--text);
}

.site-main {
  min-width: 0;
}

/* Breadcrumbs */
.breadcrumbs {
  margin-bottom: 2rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.breadcrumb-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.breadcrumb-item {
  display: flex;
  align-items: center;
}

.breadcrumb-item:not(:last-child)::after {
  content: "›";
  margin-left: 0.5rem;
  color: var(--muted);
}

.breadcrumb-item a {
  text-decoration: none;
  color: var(--muted);
  transition: color 0.2s ease;
}

.breadcrumb-item a:hover {
  color: var(--text);
}

.breadcrumb-item:last-child {
  color: var(--text);
  font-weight: 500;
}

.post {
  margin: 0 0 2.5rem;
  padding-bottom: 2.5rem;
  border-bottom: 1px solid var(--border);
}

.post:last-child {
  border-bottom: 0;
}

/* Sticky posts */
.post.sticky {
  background: var(--card);
  padding: 2rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
  margin-bottom: 3rem;
}

.post.sticky::before {
  content: "Featured";
  display: inline-block;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent);
  background: var(--background);
  padding: 0.25rem 0.75rem;
  border-radius: 999px;
  margin-bottom: 1rem;
  font-weight: 600;
}

.dark-mode .post.sticky,
:root:not(.light-mode) .post.sticky {
  background: var(--card);
  border-color: var(--border);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.post-header {
  margin-bottom: 0.85rem;
}

.post-meta {
  margin: 0;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}
.post-meta a {
  text-decoration: none;
  color: inherit;
}

.post-title {
  font-family: var(--serif);
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  margin: 0.35rem 0;
  line-height: 1.2;
}

.post-title a {
  text-decoration: none;
}

.post-thumbnail {
  margin: 1.25rem 0;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.08);
  max-width: 480px;
  margin-left: 0;
  margin-right: auto;
}
.post-thumbnail img {
  width: 100%;
  display: block;
  height: auto;
}

.post-content {
  font-family: var(--serif);
  font-size: clamp(1rem, 2.5vw, 1.08rem);
}

.post-content p {
  margin: 0 0 1.4rem;
}

.post-content a {
  color: var(--accent-dark);
  text-decoration: underline;
}

.post-footer,
.post-tags {
  font-size: 0.9rem;
  color: var(--muted);
}

.read-more {
  margin-top: 1.5rem;
}

.button-link,
.search-submit {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: var(--accent);
  color: #fff;
  padding: clamp(0.5rem, 1.5vw, 0.6rem) clamp(1rem, 2.5vw, 1.2rem);
  border-radius: 999px;
  text-decoration: none;
  font-size: clamp(0.85rem, 2vw, 0.9rem);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  border: none;
  cursor: pointer;
  transition: background 0.2s ease;
}
.button-link:hover,
.search-submit:hover {
  background: var(--accent-dark);
}

.pagination {
  margin-top: 2rem;
}

.pagination .page-numbers {
  display: inline-block;
  margin-right: 0.5rem;
  padding: 0.4rem 0.8rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  text-decoration: none;
  font-size: 0.85rem;
}
.pagination .current {
  background: var(--text);
  color: #fff;
  border-color: var(--text);
}

.sidebar {
  margin-top: 4rem;
  padding-top: 2.5rem;
  border-top: 1px solid var(--border);
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 2rem;
}

.widget {
  margin-bottom: 1.8rem;
}
.widget:last-child {
  margin-bottom: 0;
}
.widget-title {
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin: 0 0 0.75rem;
  color: var(--muted);
}
.widget ul {
  list-style: none;
  padding: 0;
  margin: 0;
}
.widget li {
  margin-bottom: 0.5rem;
}
.widget a {
  text-decoration: none;
  color: var(--text);
}
.widget a:hover {
  color: var(--accent-dark);
}

.search-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.5rem;
}
.search-field {
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.5rem 1rem;
  font-family: inherit;
}

.comments-area {
  margin-top: 3rem;
  border-top: 1px solid var(--border);
  padding-top: 2rem;
}
.comments-title {
  margin-top: 0;
  font-size: 1.25rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.comment-list {
  list-style: none;
  padding: 0;
  margin: 0 0 2rem;
}
.comment {
  margin-bottom: 1.5rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
}
.comment.bypostauthor {
  background: var(--card);
  padding: 1.5rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.comment.bypostauthor .comment-meta {
  color: var(--accent-dark);
  font-weight: 500;
}
.comment-meta {
  font-size: 0.85rem;
  color: var(--muted);
}
.comment-content {
  font-family: var(--serif);
}

.comment-navigation {
  margin-bottom: 2rem;
}

.site-footer {
  margin-top: 4rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border);
}

.footer-widgets {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}

.footer-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  justify-content: space-between;
  align-items: center;
  color: var(--muted);
  font-size: 0.9rem;
}

.footer-menu {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  gap: 1rem;
}
.footer-menu a {
  text-decoration: none;
  color: inherit;
}

blockquote {
  border-left: 3px solid var(--accent);
  padding-left: 1rem;
  font-style: italic;
  color: var(--accent-dark);
}

pre,
code {
  font-family: "JetBrains Mono", "SFMono-Regular", Consolas, monospace;
}
pre {
  background: #151515;
  color: #f5f2f0;
  padding: 1rem;
  border-radius: 10px;
  overflow-x: auto;
}

.dark-mode pre {
  background: #0d0d0d;
  color: #e8e6e3;
}

@media (prefers-color-scheme: dark) {
  :root:not(.light-mode) pre {
    background: #0d0d0d;
    color: #e8e6e3;
  }
}

/* Dark mode toggle button */
.dark-mode-toggle {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.5rem 0.75rem;
  border-radius: 999px;
  cursor: pointer;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin-left: 0.5rem;
}

.dark-mode-toggle:hover {
  background: var(--border);
  border-color: var(--accent);
}

.dark-mode-toggle:focus {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

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

/* Image captions - Classic editor */
.wp-caption {
  max-width: 100%;
  margin: 1.5rem 0;
  text-align: center;
}

.wp-caption img {
  display: block;
  margin: 0 auto;
  max-width: 100%;
  height: auto;
}

.wp-caption-text {
  margin: 0.75rem 0 0;
  padding: 0;
  font-size: 0.9rem;
  color: var(--muted);
  font-style: italic;
  line-height: 1.5;
  text-align: center;
}

.wp-caption-dd {
  margin: 0.75rem 0 0;
  padding: 0;
  font-size: 0.9rem;
  color: var(--muted);
  font-style: italic;
  line-height: 1.5;
  text-align: center;
}

/* Gallery captions - Classic editor */
.gallery-caption {
  margin: 0.75rem 0 0;
  padding: 0;
  font-size: 0.9rem;
  color: var(--muted);
  font-style: italic;
  line-height: 1.5;
  text-align: center;
}

/* Image captions - Block editor */
.wp-block-image figcaption,
.wp-block-gallery figcaption {
  margin-top: 0.75rem;
  font-size: 0.9rem;
  color: var(--muted);
  font-style: italic;
  line-height: 1.5;
  text-align: center;
}

.wp-block-image {
  margin: 1.5rem 0;
}

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

/* Gallery captions */
.wp-block-gallery {
  margin: 1.5rem 0;
}

.wp-block-gallery figcaption {
  margin-top: 0.5rem;
}

/* Image alignment - Classic editor */
.alignleft {
  float: left;
  margin: 0.5rem 1.5rem 1rem 0;
  max-width: 50%;
}

.alignright {
  float: right;
  margin: 0.5rem 0 1rem 1.5rem;
  max-width: 50%;
}

.aligncenter {
  display: block;
  margin: 1.5rem auto;
  text-align: center;
}

.alignnone {
  margin: 1.5rem 0;
}

/* Clear floats */
.alignleft::after,
.alignright::after {
  content: "";
  display: table;
  clear: both;
}

/* Poetry pattern styles */
.wp-block-group.alignwide .has-text-align-center {
  font-family: var(--serif);
}

.wp-block-group.alignwide p.has-text-align-center {
  margin-bottom: 0.5rem;
}

/* Poetry category specific styles */
.category-poetry .post-content {
  text-align: left;
}

.category-poetry .post-content p {
  font-family: var(--serif);
  line-height: 2.2;
  margin-bottom: 0.5rem;
}

.category-poetry .post-content p:last-child {
  margin-bottom: 0;
}

/* Tablet and below */
@media (max-width: 900px) {
  .sidebar {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }

  .footer-widgets {
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  }

  .footer-meta {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
  }

  .footer-menu {
    flex-wrap: wrap;
  }
}

/* Mobile */
@media (max-width: 600px) {
  .site-header {
    padding-bottom: 1.5rem;
  }

  .site-nav-row {
    flex-direction: column;
    align-items: stretch;
    gap: 1rem;
    margin-top: 1rem;
  }

  .dark-mode-toggle {
    align-self: flex-end;
    margin-left: 0;
    margin-top: 0.5rem;
  }

  .nav-search {
    margin-left: 0;
    width: 100%;
  }

  .nav-search .search-form {
    width: 100%;
  }

  .nav-search .search-field {
    flex: 1;
    min-width: 0;
    width: 100%;
  }

  .site-nav .menu,
  .site-nav .menu ul {
    flex-wrap: wrap;
    gap: 1rem;
  }

  .post {
    margin: 0 0 2rem;
    padding-bottom: 2rem;
  }

  .post-thumbnail {
    margin: 1rem 0;
    border-radius: 8px;
    max-width: 100%;
  }

  .pagination .page-numbers {
    padding: 0.35rem 0.7rem;
    font-size: 0.8rem;
    margin-right: 0.35rem;
  }

  .sidebar {
    margin-top: 3rem;
    padding-top: 2rem;
    gap: 1.25rem;
  }

  .site-footer {
    margin-top: 3rem;
    padding-top: 1.5rem;
  }

  .footer-widgets {
    grid-template-columns: 1fr;
    gap: 1.25rem;
  }

  .comments-area {
    margin-top: 2rem;
    padding-top: 1.5rem;
  }

  blockquote {
    padding-left: 0.75rem;
    margin-left: 0.5rem;
  }

  pre {
    padding: 0.75rem;
    border-radius: 8px;
    font-size: 0.9rem;
  }
}

/* Small mobile */
@media (max-width: 400px) {
  .site-wrapper {
    padding-left: 1rem;
    padding-right: 1rem;
  }

  .post-title {
    font-size: clamp(1.5rem, 6vw, 1.8rem);
  }

  .site-title {
    font-size: clamp(1.5rem, 5vw, 1.8rem);
  }
}
