/**
 * Theme Name: PHH Child Theme
 * Description: Child theme của Phạm Huy Hoàng
 * Author: Phạm Huy Hoàng
 * Template: blocksy
 * Text Domain: blocksy
 */

/* ═══════════════════════════════════════════════════
   PHH Child Theme — Blog Typography & Code Blocks
   Áp dụng cho tất cả bài viết và trang nội dung
   ═══════════════════════════════════════════════════ */

/* ── Variables ───────────────────────────────────── */
:root {
  --phh-blue:    #2563eb;
  --phh-text:    #0f172a;
  --phh-muted:   #64748b;
  --phh-border:  #e2e8f0;
  --phh-bg:      #f8fafc;
  --phh-code-bg: #0f1623;
}
[data-theme="dark"] {
  --phh-text:   #f1f5f9;
  --phh-muted:  #94a3b8;
  --phh-border: #1e293b;
  --phh-bg:     #111827;
}

/* ── H2 — Section heading with accent bar ────────── */
.entry-content h2,
.wp-block-post-content h2 {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--phh-text);
  margin: 2.75rem 0 1rem;
  padding: 0 0 0 14px;
  border-left: 3px solid var(--phh-blue);
  line-height: 1.4;
  letter-spacing: -0.02em;
}
.entry-content h2:first-child,
.wp-block-post-content h2:first-child {
  margin-top: 0;
}

/* ── H3 — Sub-section with bottom rule ───────────── */
.entry-content h3,
.wp-block-post-content h3 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--phh-text);
  margin: 2rem 0 0.75rem;
  padding-bottom: 8px;
  border-bottom: 1.5px solid var(--phh-border);
  line-height: 1.4;
  letter-spacing: -0.01em;
}

/* ── H4 — Minor heading ──────────────────────────── */
.entry-content h4,
.wp-block-post-content h4 {
  font-size: 0.975rem;
  font-weight: 700;
  color: var(--phh-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: 1.5rem 0 0.5rem;
}

/* ── Inline code ─────────────────────────────────── */
.entry-content code,
.wp-block-post-content code {
  font-family: 'JetBrains Mono', 'Fira Code', 'Courier New', monospace;
  font-size: 0.875em;
  background: var(--phh-bg);
  border: 1px solid var(--phh-border);
  border-radius: 5px;
  padding: 1px 6px;
  color: var(--phh-blue);
}
[data-theme="dark"] .entry-content code,
[data-theme="dark"] .wp-block-post-content code {
  background: #1e293b;
  border-color: #334155;
  color: #60a5fa;
}

/* ── phh-code-block: styled code box + copy btn ─── */
.phh-code-block {
  position: relative;
  margin: 1.75rem 0;
  border-radius: 12px;
  overflow: hidden;
  font-family: 'JetBrains Mono', 'Fira Code', 'Courier New', monospace;
  font-size: 13.5px;
  line-height: 1.75;
  box-shadow: 0 4px 24px rgba(0,0,0,.18);
  border: 1px solid rgba(255,255,255,.06);
}
.phh-code-block__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: #1e2433;
  border-bottom: 1px solid rgba(255,255,255,.07);
}
.phh-code-block__label {
  display: flex;
  align-items: center;
  gap: 6px;
  color: #94a3b8;
  font-size: 12px;
  font-family: inherit;
}
.phh-code-block__copy {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 4px 12px;
  border-radius: 6px;
  border: 1px solid rgba(255,255,255,.15);
  background: transparent;
  color: #94a3b8;
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  transition: all .2s;
}
.phh-code-block__copy:hover {
  border-color: rgba(255,255,255,.35);
  color: #e2e8f0;
}
.phh-code-block__copy.copied {
  color: #4ade80;
  border-color: #4ade80;
}
.phh-code-block__body {
  overflow-x: auto;
  background: var(--phh-code-bg);
}
.phh-code-block__body pre {
  margin: 0;
  padding: 20px 22px;
  color: #e2e8f0;
  background: transparent;
  font-size: inherit;
  line-height: inherit;
}
.phh-code-block__body code {
  font-family: inherit;
  font-size: inherit;
  color: #e2e8f0 !important;
  background: transparent !important;
  border: none !important;
  padding: 0 !important;
  border-radius: 0 !important;
}

/* ── WP default code block override ─────────────── */
.wp-block-code {
  border-radius: 10px;
  font-family: 'JetBrains Mono', 'Fira Code', 'Courier New', monospace;
  font-size: 13.5px;
  background: var(--phh-code-bg) !important;
  color: #e2e8f0 !important;
  border: 1px solid rgba(255,255,255,.06);
  padding: 20px 22px;
}

/* ── Blockquote ──────────────────────────────────── */
.entry-content blockquote,
.wp-block-quote {
  border-left: 3px solid var(--phh-blue);
  padding: 14px 20px;
  margin: 1.5rem 0;
  background: var(--phh-bg);
  border-radius: 0 8px 8px 0;
  color: var(--phh-muted);
  font-style: normal;
}
[data-theme="dark"] .entry-content blockquote,
[data-theme="dark"] .wp-block-quote {
  background: #1e293b;
}

/* ── Table ───────────────────────────────────────── */
.entry-content table,
.wp-block-table table {
  font-size: 14px;
  border-collapse: collapse;
  width: 100%;
}
.entry-content th,
.wp-block-table th {
  background: var(--phh-bg);
  font-weight: 700;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--phh-muted);
  padding: 10px 14px;
  border-bottom: 2px solid var(--phh-border);
  text-align: left;
}
.entry-content td,
.wp-block-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--phh-border);
  vertical-align: top;
}
.entry-content tr:last-child td,
.wp-block-table tr:last-child td {
  border-bottom: none;
}
[data-theme="dark"] .entry-content th,
[data-theme="dark"] .wp-block-table th {
  background: #1e293b;
  border-bottom-color: #334155;
}
[data-theme="dark"] .entry-content td,
[data-theme="dark"] .wp-block-table td {
  border-bottom-color: #1e293b;
}

/* ── Responsive ──────────────────────────────────── */
@media (max-width: 640px) {
  .entry-content h2, .wp-block-post-content h2 { font-size: 1.2rem; }
  .entry-content h3, .wp-block-post-content h3 { font-size: 1rem; }
  .phh-code-block { font-size: 12.5px; border-radius: 8px; }
  .wp-block-table { overflow-x: auto; display: block; }
}

/* ═══════════════════════════════════════════════════
   Dark Mode Fixes — Blog, Forms, Comments
   ═══════════════════════════════════════════════════ */

/* ── Headings dark mode (override Blocksy specificity) ── */
[data-theme="dark"] .entry-content h1,
[data-theme="dark"] .entry-content h2,
[data-theme="dark"] .entry-content h3,
[data-theme="dark"] .entry-content h4,
[data-theme="dark"] .entry-content h5,
[data-theme="dark"] .entry-content h6,
[data-theme="dark"] .wp-block-post-content h1,
[data-theme="dark"] .wp-block-post-content h2,
[data-theme="dark"] .wp-block-post-content h3,
[data-theme="dark"] .wp-block-post-content h4,
[data-theme="dark"] .entry-title,
[data-theme="dark"] .page-title,
[data-theme="dark"] .wp-block-heading {
  color: #f1f5f9 !important;
}

/* ── Post content text ───────────────────────────── */
[data-theme="dark"] .entry-content,
[data-theme="dark"] .wp-block-post-content,
[data-theme="dark"] .entry-content p,
[data-theme="dark"] .entry-content li,
[data-theme="dark"] .entry-content td {
  color: #cbd5e1;
}

/* ── Post meta, tags, author, date ──────────────── */
[data-theme="dark"] .entry-meta,
[data-theme="dark"] .post-meta,
[data-theme="dark"] .cat-links,
[data-theme="dark"] .tags-links,
[data-theme="dark"] .posted-on,
[data-theme="dark"] .byline {
  color: #64748b;
}

/* ── Separator ──────────────────────────────────── */
[data-theme="dark"] .wp-block-separator {
  border-color: #1e293b;
  opacity: 1;
}

/* ── Code block copy button — chắc chắn thấy ────── */
[data-theme="dark"] .phh-code-block__copy {
  color: #94a3b8;
  border-color: rgba(255,255,255,.2);
}

/* ── Form inputs (toàn trang) ───────────────────── */
[data-theme="dark"] input[type="text"],
[data-theme="dark"] input[type="email"],
[data-theme="dark"] input[type="url"],
[data-theme="dark"] input[type="password"],
[data-theme="dark"] input[type="search"],
[data-theme="dark"] input[type="tel"],
[data-theme="dark"] input[type="number"],
[data-theme="dark"] textarea,
[data-theme="dark"] select {
  background-color: #1e293b !important;
  border-color: #334155 !important;
  color: #e2e8f0 !important;
}

[data-theme="dark"] input[type="text"]::placeholder,
[data-theme="dark"] input[type="email"]::placeholder,
[data-theme="dark"] input[type="url"]::placeholder,
[data-theme="dark"] textarea::placeholder {
  color: #475569 !important;
}

[data-theme="dark"] input[type="text"]:focus,
[data-theme="dark"] input[type="email"]:focus,
[data-theme="dark"] input[type="url"]:focus,
[data-theme="dark"] textarea:focus {
  border-color: #2563eb !important;
  outline: none;
  box-shadow: 0 0 0 3px rgba(37,99,235,.15);
}

/* ── Comment form ───────────────────────────────── */
[data-theme="dark"] #respond,
[data-theme="dark"] .comment-respond {
  background: transparent;
}

[data-theme="dark"] #respond h3,
[data-theme="dark"] .comment-reply-title {
  color: #f1f5f9 !important;
}

[data-theme="dark"] .comment-form label {
  color: #94a3b8;
}

[data-theme="dark"] .comment-form input,
[data-theme="dark"] .comment-form textarea,
[data-theme="dark"] #comment,
[data-theme="dark"] #author,
[data-theme="dark"] #email,
[data-theme="dark"] #url {
  background: #1e293b !important;
  border-color: #334155 !important;
  color: #e2e8f0 !important;
  border-radius: 8px;
}

[data-theme="dark"] .comment-form-cookies-consent label {
  color: #64748b;
}

/* ── Comment list ────────────────────────────────── */
[data-theme="dark"] .comment-body {
  background: #111827;
  border-color: #1e293b;
}

[data-theme="dark"] .comment-author .fn,
[data-theme="dark"] .comment-meta a {
  color: #94a3b8;
}

[data-theme="dark"] .comment-content p {
  color: #cbd5e1;
}

/* ── Submit button ──────────────────────────────── */
[data-theme="dark"] .comment-form .submit,
[data-theme="dark"] input[type="submit"] {
  background: #2563eb;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 10px 24px;
  cursor: pointer;
  font-weight: 600;
  transition: background .2s;
}

[data-theme="dark"] .comment-form .submit:hover,
[data-theme="dark"] input[type="submit"]:hover {
  background: #1d4ed8;
}

/* ── Search form ────────────────────────────────── */
[data-theme="dark"] .search-form input,
[data-theme="dark"] .wp-block-search__input {
  background: #1e293b !important;
  border-color: #334155 !important;
  color: #e2e8f0 !important;
}

/* ── WooCommerce checkout/account forms ─────────── */
[data-theme="dark"] .woocommerce-input-wrapper input,
[data-theme="dark"] .woocommerce-input-wrapper select,
[data-theme="dark"] .woocommerce-input-wrapper textarea,
[data-theme="dark"] .woocommerce form .input-text,
[data-theme="dark"] .woocommerce form select {
  background: #1e293b !important;
  border-color: #334155 !important;
  color: #e2e8f0 !important;
}

[data-theme="dark"] .woocommerce form label {
  color: #94a3b8;
}

/* ═══════════════════════════════════════════════════
   Mobile — Thu nhỏ tiêu đề & hero section bài viết
   ═══════════════════════════════════════════════════ */

@media (max-width: 768px) {

  /* ── Hero section (vùng tiêu đề đầu trang bài viết) ── */
  .hero-section[data-type="type-2"] > [class*="ct-container"] {
    padding: 24px 0 !important;
    min-height: unset !important;
  }
  .hero-section[data-type="type-1"] {
    margin-bottom: 20px !important;
  }

  /* ── Tiêu đề bài viết (page-title) ───────────────── */
  .page-title,
  .entry-header .page-title,
  h1.page-title,
  .hero-section .page-title {
    font-size: 1.5rem !important;
    line-height: 1.35 !important;
  }

  /* ── H2/H3/H4 trong nội dung bài viết ───────────── */
  .entry-content h2,
  .wp-block-post-content h2 {
    font-size: 1.15rem !important;
    margin: 1.75rem 0 0.75rem !important;
  }
  .entry-content h3,
  .wp-block-post-content h3 {
    font-size: 1rem !important;
    margin: 1.5rem 0 0.6rem !important;
  }
  .entry-content h4,
  .wp-block-post-content h4 {
    font-size: 0.9rem !important;
    margin: 1.25rem 0 0.5rem !important;
  }

  /* ── Giảm padding entry-header ───────────────────── */
  .entry-header {
    padding-top: 0 !important;
    margin-bottom: 20px !important;
  }

  /* ── Meta (ngày, tác giả) ────────────────────────── */
  .entry-meta {
    font-size: 13px !important;
  }

  /* ── Code block ──────────────────────────────────── */
  .phh-code-block {
    font-size: 12px !important;
    border-radius: 8px !important;
  }
  .phh-code-block__body pre {
    padding: 14px 16px !important;
  }
  .phh-code-block__header {
    padding: 8px 12px !important;
  }

  /* ── Table scroll ngang ──────────────────────────── */
  .wp-block-table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .wp-block-table table {
    min-width: 500px;
  }
  .entry-content td,
  .entry-content th,
  .wp-block-table td,
  .wp-block-table th {
    padding: 8px 10px !important;
    font-size: 13px !important;
  }
}

@media (max-width: 480px) {

  /* ── Tiêu đề còn nhỏ hơn trên màn hình rất nhỏ ─── */
  .page-title,
  .entry-header .page-title,
  h1.page-title {
    font-size: 1.3rem !important;
  }

  .hero-section[data-type="type-2"] > [class*="ct-container"] {
    padding: 18px 0 !important;
  }
}
