/* ============================================================
   BLOG — Custom CSS
   Tailwind utility classes handle layout/spacing/color.
   This file covers keyframes, custom properties, prose styles,
   view transitions, and reduced-motion support.
   ============================================================ */

/* ── Custom Properties ── */
:root {
  --accent: #537f53;        /* sage-500 */
  --accent-light: #a4bfa4;  /* sage-300 */
  --text-body: #1a1a1a;     /* charcoal-950 */
  --transition-view: 280ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── Base typography ── */
html {
  scroll-behavior: smooth;
}

body {
  font-feature-settings: "kern" 1, "liga" 1;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ── View section transitions ── */
.view-section {
  animation: fadeInUp 0.32s cubic-bezier(0.4, 0, 0.2, 1) both;
}

.view-section.hidden {
  display: none;
}

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

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(24px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes slideInUp {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateX(32px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes toastOut {
  from {
    opacity: 1;
    transform: translateX(0);
  }
  to {
    opacity: 0;
    transform: translateX(32px);
  }
}

.fade-in {
  animation: fadeIn 0.2s ease both;
}

/* ── Post card hover effect ── */
.post-card {
  border-bottom: 1px solid #e7e5e4; /* stone-200 */
  transition: background-color 0.15s ease;
  cursor: pointer;
}

.post-card:first-child {
  border-top: 1px solid #e7e5e4;
}

.post-card:hover {
  background-color: #fafaf9; /* stone-50 */
}

.post-card:hover .post-card-title {
  color: var(--accent);
}

.post-card-title {
  transition: color 0.15s ease;
}

/* ── Prose / reading view ── */
.prose-content {
  max-width: 72ch;
}

.prose-content p {
  margin-bottom: 1.5em;
  line-height: 1.8;
  color: #292524; /* stone-800 equivalent */
}

.prose-content h2 {
  font-family: 'Noto Serif KR', Georgia, serif;
  font-size: 1.5rem;
  font-weight: 600;
  color: #1a1a1a;
  margin-top: 2.5em;
  margin-bottom: 0.75em;
  line-height: 1.3;
}

.prose-content h3 {
  font-family: 'Noto Serif KR', Georgia, serif;
  font-size: 1.2rem;
  font-weight: 600;
  color: #1a1a1a;
  margin-top: 2em;
  margin-bottom: 0.6em;
  line-height: 1.4;
}

.prose-content blockquote {
  border-left: 3px solid var(--accent-light);
  padding-left: 1.25em;
  margin: 1.75em 0;
  color: #57534e; /* stone-600 */
  font-style: italic;
}

.prose-content code {
  font-family: 'SF Mono', 'Fira Mono', 'Cascadia Code', Consolas, monospace;
  font-size: 0.875em;
  background-color: #f5f5f4; /* stone-100 */
  color: #537f53;
  padding: 0.15em 0.4em;
  border-radius: 0.25rem;
}

.prose-content pre {
  background-color: #1a1a1a;
  color: #e7e5e4;
  padding: 1.25em 1.5em;
  border-radius: 0.5rem;
  overflow-x: auto;
  margin: 1.75em 0;
  font-size: 0.875em;
  line-height: 1.7;
}

.prose-content pre code {
  background: none;
  color: inherit;
  padding: 0;
  font-size: inherit;
}

.prose-content strong {
  font-weight: 700;
  color: #1a1a1a;
}

.prose-content em {
  font-style: italic;
}

.prose-content ul {
  list-style-type: disc;
  padding-left: 1.5em;
  margin: 1.25em 0;
  space-y: 0.5em;
}

.prose-content ol {
  list-style-type: decimal;
  padding-left: 1.5em;
  margin: 1.25em 0;
}

.prose-content li {
  margin-bottom: 0.4em;
  line-height: 1.7;
}

.prose-content a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.prose-content a:hover {
  color: #344f35;
}

.prose-content hr {
  border: none;
  border-top: 1px solid #e7e5e4;
  margin: 2.5em 0;
}

/* ── Tag pill ── */
.tag-pill {
  display: inline-flex;
  align-items: center;
  padding: 0.2em 0.7em;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 500;
  background-color: #e6ede6; /* sage-100 */
  color: #3f6340;             /* sage-600 */
  letter-spacing: 0.01em;
}

/* ── Draft badge ── */
.draft-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.1em 0.6em;
  border-radius: 9999px;
  font-size: 0.7rem;
  font-weight: 600;
  background-color: #fef9c3;
  color: #854d0e;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

/* ── Toast ── */
.toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.75rem 1rem;
  border-radius: 0.625rem;
  font-size: 0.875rem;
  font-weight: 500;
  box-shadow: 0 4px 12px rgba(0,0,0,0.12), 0 1px 3px rgba(0,0,0,0.08);
  max-width: 320px;
  animation: toastIn 0.25s cubic-bezier(0.34, 1.56, 0.64, 1) both;
  min-height: 44px;
}

.toast.out {
  animation: toastOut 0.2s ease forwards;
}

.toast-success {
  background-color: #fff;
  border: 1px solid #ccdacc; /* sage-200 */
  color: #1a1a1a;
}

.toast-success .toast-icon {
  color: var(--accent);
}

.toast-error {
  background-color: #fff;
  border: 1px solid #fecaca;
  color: #1a1a1a;
}

.toast-error .toast-icon {
  color: #dc2626;
}

.toast-info {
  background-color: #fff;
  border: 1px solid #e7e5e4;
  color: #1a1a1a;
}

.toast-info .toast-icon {
  color: #57534e;
}

/* ── Textarea auto-resize hint ── */
textarea {
  field-sizing: content;
  min-height: 280px;
}

/* ── Nav active state ── */
.nav-btn.active {
  background-color: #f5f5f4;
  color: #1a1a1a;
}

/* ── Reading progress bar ── */
#reading-progress {
  position: fixed;
  top: 0;
  left: 0;
  width: 0%;
  height: 2px;
  background: linear-gradient(to right, var(--accent), var(--accent-light));
  z-index: 100;
  transition: width 0.1s linear;
}

/* ── Reduced motion ── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ── Focus visible global ── */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ── Scrollbar ── */
::-webkit-scrollbar {
  width: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: #c8c8c8;
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: #999;
}

/* ── Print ── */
@media print {
  header, footer, #back-to-feed-btn, #read-edit-btn, #read-delete-btn,
  #read-prev-btn, #read-next-btn, #reading-progress {
    display: none !important;
  }
  body {
    font-size: 12pt;
    background: white;
  }
  .prose-content {
    max-width: 100%;
  }
}
