/* =================================================================
   Kaden Yeung — Blog
   Loaded after main.css. Reuses the same design tokens.
   index grid · article reader · studio editor
   ================================================================= */

/* ----- Blog page header ----- */
.blog-hero {
  padding-block: clamp(2.5rem, 6vw, 4rem) clamp(1.5rem, 4vw, 2.5rem);
}

.blog-hero .section-heading {
  font-size: clamp(2.4rem, 6vw, 3.6rem);
}

.blog-empty {
  color: var(--text-secondary);
  padding: 3rem 0;
  text-align: center;
}

.section-flush-top {
  padding-top: 0;
}

/* ----- Featured / latest card ----- */
.feature-card {
  display: grid;
  grid-template-columns: 1.15fr 1fr;
  gap: clamp(1.5rem, 4vw, 3rem);
  align-items: stretch;
  color: inherit;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: clamp(2.5rem, 5vw, 3.75rem);
  transition: transform var(--t) var(--ease),
    box-shadow var(--t) var(--ease), border-color var(--t) var(--ease);
}

.feature-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-md);
  border-color: var(--border-strong);
}

.feature-media {
  position: relative;
  min-height: 260px;
  background: var(--bg-subtle);
}

.feature-media img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.feature-media-text,
.post-card-media-text {
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #1d2535, #2563eb 140%);
  color: #fff;
}

/* Cover-less posts get an intentional typographic card: a big serif
   quotation mark, signalling "an essay" rather than a missing image. */
.feature-media-text span,
.post-card-media-text span {
  font-family: var(--font-serif);
  font-weight: 600;
  line-height: 0;
  opacity: 0.9;
}

.feature-media-text span {
  font-size: 12rem;
}

.post-card-media-text span {
  font-size: 8rem;
}

.feature-body {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.9rem;
  padding: clamp(1.75rem, 4vw, 2.75rem);
}

.post-kicker {
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
}

.feature-title {
  font-family: var(--font-serif);
  font-weight: 500;
  font-size: clamp(1.6rem, 3.2vw, 2.25rem);
  line-height: 1.12;
  letter-spacing: -0.015em;
  color: var(--text);
}

.feature-excerpt {
  color: var(--text-secondary);
  max-width: 48ch;
}

.post-meta {
  font-size: 0.875rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* ----- Post grid ----- */
.post-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: clamp(1.25rem, 3vw, 1.75rem);
}

.post-card {
  display: flex;
  flex-direction: column;
  color: inherit;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: transform var(--t) var(--ease),
    box-shadow var(--t) var(--ease), border-color var(--t) var(--ease);
}

.post-card:hover {
  transform: translateY(-6px);
  box-shadow: var(--shadow-md);
  border-color: var(--border-strong);
}

.post-card-media {
  position: relative;
  aspect-ratio: 16 / 10;
  background: var(--bg-subtle);
  overflow: hidden;
}

.post-card-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform var(--t) var(--ease);
}

.post-card:hover .post-card-media img {
  transform: scale(1.04);
}

.post-card-body {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  padding: 1.4rem 1.4rem 1.6rem;
  flex: 1;
}

.post-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.post-tags li {
  padding: 0.25rem 0.6rem;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.post-card-title {
  font-family: var(--font-serif);
  font-weight: 500;
  font-size: 1.25rem;
  line-height: 1.2;
  letter-spacing: -0.01em;
  color: var(--text);
}

.post-card-excerpt {
  color: var(--text-secondary);
  font-size: 0.95rem;
  flex: 1;
}

/* Long words / URLs can never push text out of a card or the article column. */
.feature-title,
.feature-excerpt,
.post-card-title,
.post-card-excerpt,
.post-body {
  overflow-wrap: break-word;
  word-break: break-word;
}

/* =================================================================
   Article reader (post.html)
   ================================================================= */
.article {
  padding-block: clamp(2rem, 5vw, 3.5rem) clamp(3rem, 6vw, 5rem);
}

.article-shell {
  max-width: 720px;
  margin-inline: auto;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 1.75rem;
  transition: color var(--t-fast) var(--ease), gap var(--t-fast) var(--ease);
}

.back-link:hover {
  color: var(--text);
  gap: 0.6rem;
}

.post-hero-title {
  font-size: clamp(2rem, 5vw, 3rem);
  line-height: 1.1;
  margin-bottom: 0.85rem;
}

.post-hero-subtitle {
  font-family: var(--font-serif);
  font-weight: 400;
  font-style: italic;
  font-size: clamp(1.1rem, 2.4vw, 1.4rem);
  color: var(--text-secondary);
  line-height: 1.4;
  margin-bottom: 1.4rem;
}

.post-hero-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.55rem;
  font-size: 0.9rem;
  color: var(--text-muted);
  padding-bottom: 1.75rem;
  border-bottom: 1px solid var(--border);
}

.post-hero-meta .dot {
  opacity: 0.5;
}

.post-hero-tag {
  padding: 0.2rem 0.6rem;
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: var(--radius-pill);
  font-weight: 600;
  font-size: 0.78rem;
}

.post-cover {
  margin: 2rem 0 0;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
}

.post-cover img {
  width: 100%;
  height: auto;
  display: block;
}

/* ----- Rendered markdown body ----- */
.post-body {
  font-size: 1.12rem;
  line-height: 1.75;
  color: #1c2230;
  margin-top: 2.5rem;
}

.post-body > *:first-child {
  margin-top: 0;
}

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

.post-body h1,
.post-body h2 {
  font-family: var(--font-serif);
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -0.015em;
  margin: 2.4rem 0 1rem;
}

.post-body h1 { font-size: 1.85rem; }
.post-body h2 { font-size: 1.55rem; }

.post-body h3,
.post-body h4 {
  font-family: var(--font-sans);
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 2rem 0 0.85rem;
}

.post-body h3 { font-size: 1.28rem; }
.post-body h4 { font-size: 1.1rem; }

.post-body a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-thickness: 1px;
}

.post-body a:hover { color: var(--accent-hover); }

.post-body ul,
.post-body ol {
  margin: 0 0 1.4rem;
  padding-left: 1.4rem;
}

.post-body ul { list-style: disc; }
.post-body ol { list-style: decimal; }

.post-body li {
  margin-bottom: 0.5rem;
  padding-left: 0.2rem;
}

.post-body blockquote {
  margin: 1.8rem 0;
  padding: 0.4rem 0 0.4rem 1.4rem;
  border-left: 3px solid var(--accent);
  color: var(--text-secondary);
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 1.2rem;
  line-height: 1.5;
}

.post-body code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.9em;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.1rem 0.4rem;
}

.post-body hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2.5rem 0;
}

.post-body strong { font-weight: 700; color: var(--text); }

/* figures + galleries inside the article */
.post-figure {
  margin: 2rem 0;
}

.post-figure img {
  width: 100%;
  height: auto;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-subtle);
}

/* A single (non-gallery) image keeps its aspect ratio and never grows
   taller than the viewport — stops tall phone screenshots dominating. */
.post-figure > img {
  width: auto;
  max-width: 100%;
  max-height: 78vh;
  margin-inline: auto;
}

.post-figcaption {
  margin-top: 0.7rem;
  font-size: 0.9rem;
  color: var(--text-muted);
  text-align: center;
  font-style: italic;
}

.post-gallery-grid {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}

.post-gallery.is-two .post-gallery-grid {
  grid-template-columns: repeat(2, 1fr);
}

/* ----- Prev / next ----- */
.post-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  max-width: 720px;
  margin: 3.5rem auto 0;
  padding-top: 2rem;
  border-top: 1px solid var(--border);
}

.post-nav-link {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 1.1rem 1.25rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: inherit;
  transition: border-color var(--t-fast) var(--ease),
    transform var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}

.post-nav-link:hover {
  border-color: var(--border-strong);
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

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

.post-nav-dir {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
}

.post-nav-link.next .post-nav-dir { justify-content: flex-end; }

.post-nav-title {
  font-family: var(--font-serif);
  font-weight: 500;
  font-size: 1rem;
  line-height: 1.25;
  color: var(--text);
}

/* ----- Subscribe CTA at the foot of an article ----- */
.post-cta {
  max-width: 720px;
  margin: 3rem auto 0;
  padding: clamp(1.75rem, 4vw, 2.5rem);
  text-align: center;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.post-cta h2 {
  font-size: 1.5rem;
  margin-bottom: 0.5rem;
}

.post-cta p {
  color: var(--text-secondary);
  margin-bottom: 1.25rem;
}

/* =================================================================
   Project pages (project.html)
   ================================================================= */
.project-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1.75rem;
}

.project-page-link {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.7rem 1.15rem;
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-pill);
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text);
  transition: transform var(--t-fast) var(--ease),
    border-color var(--t-fast) var(--ease), background var(--t-fast) var(--ease),
    color var(--t-fast) var(--ease);
}

.project-page-link i {
  font-size: 1.15rem;
}

.project-page-link:hover {
  transform: translateY(-2px);
  border-color: var(--text);
}

/* the GitHub link reads as the primary action */
.project-page-link[href*="github"] {
  background: var(--text);
  color: #fff;
  border-color: var(--text);
}

.project-page-link[href*="github"]:hover {
  background: #000;
}

.project-more {
  max-width: 720px;
  margin: 3.5rem auto 0;
  padding-top: 2rem;
  border-top: 1px solid var(--border);
}

.project-more-title {
  font-family: var(--font-serif);
  font-weight: 500;
  font-size: 1.4rem;
  margin-bottom: 1.25rem;
}

.project-more-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1rem;
}

.project-more-card {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 1.1rem 1.25rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: inherit;
  transition: border-color var(--t-fast) var(--ease),
    transform var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}

.project-more-card:hover {
  border-color: var(--border-strong);
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

.project-more-name {
  font-weight: 600;
  color: var(--text);
}

.project-more-tagline {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

/* =================================================================
   Studio (writing CMS) — studio.html
   ================================================================= */
.studio {
  padding-block: clamp(1.5rem, 4vw, 2.5rem) clamp(3rem, 6vw, 5rem);
}

.studio-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.studio-bar h1 {
  font-size: clamp(1.6rem, 4vw, 2.2rem);
}

.studio-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.studio-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  align-items: start;
}

.studio-pane {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: clamp(1.1rem, 2.5vw, 1.6rem);
}

.studio-pane h2 {
  font-size: 1.1rem;
  font-family: var(--font-sans);
  font-weight: 700;
  margin-bottom: 1rem;
}

.studio-pane h2.gap-top {
  margin-top: 1.5rem;
}

.studio-preview .post-hero-title {
  font-size: 1.9rem;
}

.studio-preview .post-hero-subtitle {
  font-size: 1.1rem;
}

.studio-preview .post-cover {
  margin-top: 1.25rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 1rem;
}

.field label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.field input,
.field textarea {
  font-family: var(--font-sans);
  font-size: 0.95rem;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 0.65rem 0.8rem;
  width: 100%;
}

.field input:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--ring);
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.8rem;
}

.editor-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0.6rem;
}

.tool-btn {
  font-family: var(--font-sans);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.4rem 0.65rem;
  cursor: pointer;
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}

.tool-btn:hover {
  background: var(--accent-soft);
  color: var(--accent);
}

#editor {
  min-height: 460px;
  resize: vertical;
  line-height: 1.6;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.92rem;
}

.studio-preview {
  position: sticky;
  top: calc(var(--nav-h) + 1rem);
  max-height: calc(100vh - var(--nav-h) - 2rem);
  overflow-y: auto;
}

.studio-preview .post-body {
  margin-top: 1rem;
  font-size: 1rem;
}

.studio-status {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.75rem;
}

.studio-help {
  margin-top: 1.5rem;
  font-size: 0.92rem;
  color: var(--text-secondary);
}

.studio-help-title { font-size: 1rem; }
.studio-help-tip { margin-top: 0.5rem; }
.studio-help ol { padding-left: 1.3rem; }
.studio-help li { margin-bottom: 0.45rem; }
.studio-help code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.85em;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.1rem 0.35rem;
}

.studio-output {
  display: none;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.8rem;
  white-space: pre-wrap;
  word-break: break-word;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1rem;
  margin-top: 0.75rem;
  max-height: 240px;
  overflow: auto;
}

.toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%) translateY(120%);
  background: var(--text);
  color: #fff;
  padding: 0.75rem 1.3rem;
  border-radius: var(--radius-pill);
  font-weight: 600;
  font-size: 0.92rem;
  box-shadow: var(--shadow-lg);
  z-index: 3000;
  transition: transform var(--t) var(--ease);
}

.toast.is-visible {
  transform: translateX(-50%) translateY(0);
}

/* =================================================================
   Responsive
   ================================================================= */
@media (max-width: 820px) {
  .feature-card {
    grid-template-columns: 1fr;
  }
  .feature-media {
    min-height: 200px;
    aspect-ratio: 16 / 9;
  }
  .studio-grid {
    grid-template-columns: 1fr;
  }
  .studio-preview {
    position: static;
    max-height: none;
  }
}

@media (max-width: 560px) {
  .post-nav {
    grid-template-columns: 1fr;
  }
  .post-nav-link.next { text-align: left; }
  .post-nav-link.next .post-nav-dir { justify-content: flex-start; }
  .field-row { grid-template-columns: 1fr; }
}
