/*
Theme Name: Clarity
Theme URI: https://728.hk
Author: Clarity Studio
Description: A clean, editorial-style blog theme. Warm monochrome palette, generous whitespace, typographic contrast. No gradients, no clutter.
Version: 1.0.0
Requires at least: 6.0
Tested up to: 6.8
Requires PHP: 7.4
License: GNU General Public License v2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Text Domain: clarity
Tags: blog, one-column, custom-colors, custom-menu, editor-style, featured-images, translation-ready
*/

/* ============================
   CSS Custom Properties
   ============================ */
:root {
  /* Palette - Warm Monochrome */
  --canvas: #FBFBFA;
  --surface: #FFFFFF;
  --border: #EAEAEA;
  --border-hover: #D4D4D4;
  --text-primary: #1A1A1A;
  --text-body: #2F3437;
  --text-secondary: #787774;
  --text-tertiary: #A0A0A0;

  /* Accent Pastels */
  --accent-red-bg: #FDEBEC;
  --accent-red-text: #9F2F2D;
  --accent-blue-bg: #E1F3FE;
  --accent-blue-text: #1F6C9F;
  --accent-green-bg: #EDF3EC;
  --accent-green-text: #346538;
  --accent-yellow-bg: #FBF3DB;
  --accent-yellow-text: #956400;

  /* Typography */
  --font-sans: 'SF Pro Display', 'Geist Sans', 'Helvetica Neue', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-serif: 'Newsreader', 'Noto Serif SC', 'Source Han Serif SC', 'Playfair Display', Georgia, serif;
  --font-mono: 'SF Mono', 'JetBrains Mono', 'Fira Code', Consolas, monospace;

  /* Spacing */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 40px;
  --space-2xl: 64px;
  --space-3xl: 96px;

  /* Layout */
  --max-width: 720px;
  --max-width-wide: 1080px;
  --radius: 8px;
  --radius-sm: 4px;
}

/* ============================
   Reset & Base
   ============================ */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

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

body {
  font-family: var(--font-sans);
  color: var(--text-body);
  background-color: var(--canvas);
  line-height: 1.7;
  overflow-x: hidden;
}

::selection {
  background-color: #2F3437;
  color: #FFFFFF;
}

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

a {
  color: var(--text-primary);
  text-decoration: none;
  transition: color 0.2s ease;
}

a:hover {
  color: var(--text-secondary);
}

/* ============================
   Typography
   ============================ */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-serif);
  color: var(--text-primary);
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

h1 { font-size: 2.5rem; line-height: 1.1; letter-spacing: -0.03em; }
h2 { font-size: 1.75rem; }
h3 { font-size: 1.375rem; }
h4 { font-size: 1.125rem; }

p {
  margin-bottom: 1.5em;
  max-width: 65ch;
}

blockquote {
  border-left: 3px solid var(--text-primary);
  padding-left: var(--space-lg);
  margin: var(--space-xl) 0;
  font-family: var(--font-serif);
  font-style: italic;
  color: var(--text-secondary);
  font-size: 1.125rem;
  line-height: 1.6;
}

code {
  font-family: var(--font-mono);
  font-size: 0.875em;
  background: var(--canvas);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 2px 6px;
}

pre {
  background: var(--text-primary);
  color: #E8E6E3;
  border-radius: var(--radius);
  padding: var(--space-lg);
  overflow-x: auto;
  margin: var(--space-xl) 0;
  font-family: var(--font-mono);
  font-size: 0.875rem;
  line-height: 1.6;
  border: none;
}

pre code {
  background: none;
  border: none;
  padding: 0;
  color: inherit;
  font-size: inherit;
}

hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: var(--space-2xl) 0;
}

/* ============================
   Layout Container
   ============================ */
.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--space-lg);
}

.container--wide {
  max-width: var(--max-width-wide);
}

/* ============================
   Site Header
   ============================ */
.site-header {
  padding: var(--space-xl) 0;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: rgba(251, 251, 250, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 100;
}

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

.site-branding {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.site-title {
  font-family: var(--font-serif);
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

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

.site-title a:hover {
  color: var(--text-secondary);
}

.site-description {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  letter-spacing: 0.01em;
}

/* Navigation */
.main-navigation ul {
  list-style: none;
  display: flex;
  gap: var(--space-lg);
  align-items: center;
}

.main-navigation a {
  font-size: 0.875rem;
  color: var(--text-secondary);
  transition: color 0.2s ease;
  position: relative;
}

.main-navigation a:hover,
.main-navigation a.active {
  color: var(--text-primary);
}

.main-navigation a::after {
  content: '';
  position: absolute;
  bottom: -4px;
  left: 0;
  width: 0;
  height: 1.5px;
  background: var(--text-primary);
  transition: width 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.main-navigation a:hover::after,
.main-navigation a.active::after {
  width: 100%;
}

/* Mobile Menu Toggle */
.menu-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: var(--space-sm);
}

.menu-toggle span {
  display: block;
  width: 20px;
  height: 1.5px;
  background: var(--text-primary);
  margin: 5px 0;
  transition: all 0.3s ease;
}

/* ============================
   Hero / Page Header
   ============================ */
.page-header {
  padding: var(--space-3xl) 0 var(--space-2xl);
  text-align: center;
}

.page-header h1 {
  font-size: 2.75rem;
  margin-bottom: var(--space-md);
  letter-spacing: -0.035em;
}

.page-header .archive-description {
  font-size: 1.0625rem;
  color: var(--text-secondary);
  max-width: 50ch;
  margin: 0 auto;
  line-height: 1.6;
}

/* ============================
   Post Card (Archive / Index)
   ============================ */
.posts-grid {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.post-card {
  padding: var(--space-xl) 0;
  border-bottom: 1px solid var(--border);
  opacity: 0;
  transform: translateY(16px);
  animation: fadeInUp 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.post-card:first-child {
  padding-top: 0;
}

.post-card:nth-child(1) { animation-delay: 0ms; }
.post-card:nth-child(2) { animation-delay: 80ms; }
.post-card:nth-child(3) { animation-delay: 160ms; }
.post-card:nth-child(4) { animation-delay: 240ms; }
.post-card:nth-child(5) { animation-delay: 320ms; }
.post-card:nth-child(6) { animation-delay: 400ms; }

.post-card__meta {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  margin-bottom: var(--space-sm);
  font-size: 0.8125rem;
  color: var(--text-tertiary);
  letter-spacing: 0.01em;
}

.post-card__category {
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 9999px;
  background: var(--accent-blue-bg);
  color: var(--accent-blue-text);
}

.post-card__title {
  font-size: 1.5rem;
  margin-bottom: var(--space-sm);
  line-height: 1.3;
  letter-spacing: -0.025em;
}

.post-card__title a:hover {
  color: var(--text-secondary);
}

.post-card__excerpt {
  font-size: 0.9375rem;
  color: var(--text-secondary);
  line-height: 1.65;
  max-width: 60ch;
  margin-bottom: var(--space-md);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.post-card__read-more {
  font-size: 0.8125rem;
  color: var(--text-primary);
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: gap 0.3s ease;
}

.post-card__read-more:hover {
  gap: 10px;
}

.post-card__read-more svg {
  width: 14px;
  height: 14px;
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.post-card__read-more:hover svg {
  transform: translateX(2px);
}

/* Featured Image on Card */
.post-card__image {
  margin-bottom: var(--space-lg);
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
}

.post-card__image img {
  width: 100%;
  height: auto;
  aspect-ratio: 16/9;
  object-fit: cover;
  transition: transform 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.post-card__image:hover img {
  transform: scale(1.02);
}

/* Featured Post (First) */
.post-card--featured {
  padding-bottom: var(--space-2xl);
  border-bottom: 1px solid var(--border);
}

.post-card--featured .post-card__title {
  font-size: 2rem;
}

.post-card--featured .post-card__excerpt {
  font-size: 1rem;
  -webkit-line-clamp: 4;
}

/* ============================
   Single Post
   ============================ */
.single-post-header {
  padding: var(--space-3xl) 0 var(--space-xl);
  text-align: center;
}

.single-post-header .post-category {
  display: inline-block;
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 9999px;
  background: var(--accent-blue-bg);
  color: var(--accent-blue-text);
  margin-bottom: var(--space-lg);
}

.single-post-header h1 {
  font-size: 2.75rem;
  max-width: 16ch;
  margin: 0 auto var(--space-lg);
  letter-spacing: -0.035em;
  line-height: 1.1;
}

.single-post-meta {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: var(--space-md);
  font-size: 0.8125rem;
  color: var(--text-tertiary);
}

.single-post-meta .separator {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--text-tertiary);
}

/* Featured Image */
.single-post-thumbnail {
  margin: var(--space-xl) auto;
  max-width: var(--max-width-wide);
  padding: 0 var(--space-lg);
}

.single-post-thumbnail img {
  width: 100%;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  aspect-ratio: 21/9;
  object-fit: cover;
}

/* Post Content */
.post-content {
  padding: var(--space-xl) 0 var(--space-3xl);
}

.post-content .entry-content {
  font-size: 1.0625rem;
  line-height: 1.8;
}

.post-content .entry-content h2 {
  margin-top: var(--space-2xl);
  margin-bottom: var(--space-lg);
  font-size: 1.625rem;
}

.post-content .entry-content h3 {
  margin-top: var(--space-xl);
  margin-bottom: var(--space-md);
}

.post-content .entry-content img {
  border-radius: var(--radius);
  border: 1px solid var(--border);
  margin: var(--space-xl) 0;
}

.post-content .entry-content ul,
.post-content .entry-content ol {
  padding-left: var(--space-lg);
  margin-bottom: 1.5em;
}

.post-content .entry-content li {
  margin-bottom: 0.5em;
}

.post-content .entry-content a {
  color: var(--accent-blue-text);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: rgba(31, 108, 159, 0.3);
  transition: text-decoration-color 0.2s ease;
}

.post-content .entry-content a:hover {
  text-decoration-color: var(--accent-blue-text);
}

/* Post Tags */
.post-tags {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  padding: var(--space-xl) 0;
  border-top: 1px solid var(--border);
}

.post-tags a {
  font-size: 0.75rem;
  padding: 4px 12px;
  border-radius: 9999px;
  background: var(--canvas);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  transition: all 0.2s ease;
}

.post-tags a:hover {
  border-color: var(--border-hover);
  color: var(--text-primary);
  background: var(--surface);
}

/* Post Navigation */
.post-navigation {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-lg);
  padding: var(--space-xl) 0;
  border-top: 1px solid var(--border);
}

.post-navigation a {
  padding: var(--space-lg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: all 0.3s ease;
}

.post-navigation a:hover {
  border-color: var(--border-hover);
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

.post-navigation .nav-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-tertiary);
  margin-bottom: var(--space-xs);
}

.post-navigation .nav-title {
  font-family: var(--font-serif);
  font-size: 1rem;
  color: var(--text-primary);
  line-height: 1.3;
}

.post-navigation .nav-next {
  text-align: right;
}

/* ============================
   Author Box
   ============================ */
.author-box {
  display: flex;
  gap: var(--space-lg);
  padding: var(--space-xl);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin: var(--space-xl) 0;
  align-items: center;
}

.author-box__avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  border: 1px solid var(--border);
}

.author-box__name {
  font-family: var(--font-serif);
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 2px;
}

.author-box__bio {
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* ============================
   Comments
   ============================ */
.comments-area {
  padding: var(--space-2xl) 0;
  border-top: 1px solid var(--border);
}

.comments-area h2 {
  font-size: 1.375rem;
  margin-bottom: var(--space-xl);
}

.comment-list {
  list-style: none;
}

.comment {
  padding: var(--space-lg) 0;
  border-bottom: 1px solid var(--border);
}

.comment:last-child {
  border-bottom: none;
}

.comment-author {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-bottom: var(--space-sm);
}

.comment-author img {
  width: 32px;
  height: 32px;
  border-radius: 50%;
}

.comment-author .fn {
  font-weight: 600;
  font-size: 0.875rem;
}

.comment-metadata {
  font-size: 0.75rem;
  color: var(--text-tertiary);
  margin-bottom: var(--space-md);
}

.comment-body p {
  font-size: 0.9375rem;
  line-height: 1.6;
}

/* Comment Form */
.comment-respond {
  margin-top: var(--space-xl);
}

.comment-respond h3 {
  font-size: 1.125rem;
  margin-bottom: var(--space-lg);
}

.comment-form label {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-secondary);
  display: block;
  margin-bottom: var(--space-xs);
}

.comment-form input[type="text"],
.comment-form input[type="email"],
.comment-form input[type="url"],
.comment-form textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-size: 0.9375rem;
  color: var(--text-body);
  background: var(--surface);
  margin-bottom: var(--space-md);
  transition: border-color 0.2s ease;
  outline: none;
}

.comment-form input:focus,
.comment-form textarea:focus {
  border-color: var(--text-primary);
}

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

.comment-form .submit {
  background: var(--text-primary);
  color: #FFFFFF;
  border: none;
  padding: 10px 24px;
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.comment-form .submit:hover {
  background: #333333;
}

.comment-form .submit:active {
  transform: scale(0.98);
}

/* ============================
   Sidebar / Widgets
   ============================ */
.widget-area {
  padding: var(--space-xl) 0;
}

.widget {
  margin-bottom: var(--space-xl);
}

.widget-title {
  font-family: var(--font-sans);
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 600;
  color: var(--text-tertiary);
  margin-bottom: var(--space-md);
  padding-bottom: var(--space-sm);
  border-bottom: 1px solid var(--border);
}

.widget ul {
  list-style: none;
}

.widget li {
  padding: var(--space-sm) 0;
  border-bottom: 1px solid rgba(0,0,0,0.04);
  font-size: 0.875rem;
}

.widget li a {
  color: var(--text-body);
}

.widget li a:hover {
  color: var(--text-primary);
}

/* Search Widget */
.widget_search .search-form {
  display: flex;
  gap: var(--space-sm);
}

.widget_search input[type="search"] {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-family: var(--font-sans);
  outline: none;
  background: var(--surface);
}

.widget_search input:focus {
  border-color: var(--text-primary);
}

.widget_search .search-submit {
  padding: 8px 16px;
  background: var(--text-primary);
  color: #FFFFFF;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
  cursor: pointer;
}

/* ============================
   Pagination
   ============================ */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-2xl) 0;
}

.pagination a,
.pagination span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 36px;
  padding: 0 var(--space-md);
  font-size: 0.8125rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  transition: all 0.2s ease;
}

.pagination a:hover {
  border-color: var(--text-primary);
  color: var(--text-primary);
}

.pagination .current {
  background: var(--text-primary);
  color: #FFFFFF;
  border-color: var(--text-primary);
}

/* ============================
   Footer
   ============================ */
.site-footer {
  padding: var(--space-2xl) 0;
  border-top: 1px solid var(--border);
  margin-top: var(--space-3xl);
}

.footer-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8125rem;
  color: var(--text-tertiary);
}

.footer-content a {
  color: var(--text-secondary);
}

.footer-content a:hover {
  color: var(--text-primary);
}

.footer-links {
  display: flex;
  gap: var(--space-lg);
  list-style: none;
}

/* ============================
   Scroll Animations
   ============================ */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.fade-in {
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.6s cubic-bezier(0.16, 1, 0.3, 1),
              transform 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.fade-in.visible {
  opacity: 1;
  transform: translateY(0);
}

/* ============================
   404 Page
   ============================ */
.error-404 {
  text-align: center;
  padding: var(--space-3xl) 0;
}

.error-404 h1 {
  font-size: 6rem;
  color: var(--border);
  line-height: 1;
  margin-bottom: var(--space-md);
}

.error-404 p {
  font-size: 1.125rem;
  color: var(--text-secondary);
  margin-bottom: var(--space-xl);
}

/* ============================
   Back to Top
   ============================ */
.back-to-top {
  position: fixed;
  bottom: var(--space-xl);
  right: var(--space-xl);
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 50%;
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
  z-index: 50;
}

.back-to-top.visible {
  opacity: 1;
  visibility: visible;
}

.back-to-top:hover {
  border-color: var(--text-primary);
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.back-to-top svg {
  width: 16px;
  height: 16px;
  color: var(--text-secondary);
}

/* ============================
   Responsive
   ============================ */
@media (max-width: 768px) {
  :root {
    --space-xl: 32px;
    --space-2xl: 48px;
    --space-3xl: 64px;
  }

  h1 { font-size: 2rem; }
  h2 { font-size: 1.5rem; }

  .page-header h1,
  .single-post-header h1 {
    font-size: 2rem;
    max-width: none;
  }

  .menu-toggle {
    display: block;
  }

  .main-navigation {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: var(--space-lg);
  }

  .main-navigation.active {
    display: block;
  }

  .main-navigation ul {
    flex-direction: column;
    gap: var(--space-md);
  }

  .post-card--featured .post-card__title {
    font-size: 1.5rem;
  }

  .post-navigation {
    grid-template-columns: 1fr;
  }

  .author-box {
    flex-direction: column;
    text-align: center;
  }

  .footer-content {
    flex-direction: column;
    gap: var(--space-md);
    text-align: center;
  }

  .comment-form input[type="text"],
  .comment-form input[type="email"],
  .comment-form input[type="url"] {
    width: 100%;
  }
}

@media (max-width: 480px) {
  .single-post-header h1 {
    font-size: 1.75rem;
  }

  .post-card__title {
    font-size: 1.25rem;
  }

  .single-post-meta {
    flex-wrap: wrap;
    justify-content: center;
  }
}

/* ============================
   WordPress Core Alignment
   ============================ */
.alignwide {
  max-width: var(--max-width-wide);
  margin-left: calc(50% - min(50vw, var(--max-width-wide) / 2));
  margin-right: calc(50% - min(50vw, var(--max-width-wide) / 2));
}

.alignfull {
  max-width: none;
  margin-left: calc(50% - 50vw);
  margin-right: calc(50% - 50vw);
  width: 100vw;
}

.wp-caption {
  max-width: 100%;
}

.wp-caption-text {
  font-size: 0.8125rem;
  color: var(--text-tertiary);
  margin-top: var(--space-sm);
  text-align: center;
}

.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: var(--space-sm);
  margin: var(--space-xl) 0;
}

.gallery-item img {
  border-radius: var(--radius-sm);
}

/* Print Styles */
@media print {
  .site-header,
  .site-footer,
  .comments-area,
  .post-navigation,
  .back-to-top,
  .menu-toggle {
    display: none !important;
  }

  body {
    background: #FFFFFF;
    color: #000000;
    font-size: 12pt;
  }

  .container {
    max-width: none;
    padding: 0;
  }
}
