﻿/*
Theme Name: BreakTarot
Theme URI: https://example.com/breaktarot
Author: BreakTarot
Author URI: https://example.com
Description: A tarot reading and spiritual guidance WordPress theme.
Version: 1.4.0
License: GNU General Public License v2 or later
Text Domain: breaktarot
*/

/* ==========================================================================
   1. CSS Variables
   ========================================================================== */
:root {
    --primary: #8b9d83;       /* Muted Sage */
    --primary-hover: #6b7c65;
    --accent: #f43f5e;        /* Rose accent */
    --bg-body: #ffffff;      /* White */
    --bg-card: #ffffff;
    --text-main: #3d3d3d;
    --text-muted: #8c8c8c;
    --border: #eceae4;
    --font-sans: 'Noto Sans TC', sans-serif;
    --radius: 4px;
    --max-width: 1200px;
}

/* ==========================================================================
   2. Global Reset & Styles
   ========================================================================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-sans);
    background-color: var(--bg-body);
    color: var(--text-main);
    font-size: 18px;
    line-height: 1.4;
    -webkit-font-smoothing: antialiased;
    overflow-x: clip;
}

h1, h2, h3, h4, h5, h6 {
    line-height: 1.3;
    font-weight: 600;
}

p {
    margin-bottom: 2rem;
}

a {
    text-decoration: none;
    color: inherit;
    transition: all 0.3s ease;
}

a:hover {
    color: var(--primary);
}

ul {
    list-style: none;
}

img {
    max-width: 100%;
    height: auto;
    display: block;
    filter: brightness(0.98);
}

.container {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 30px;
}

/* ==========================================================================
   3. Site Header & Brand
   ========================================================================== */
.site-header {
    background: var(--bg-body);
    padding: 2rem 0 8px;
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    margin-bottom: 3rem;
}

.header-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
}

.site-logo {
    font-size: 1.75rem;
    font-weight: 600;
    color: var(--text-main);
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

/* ==========================================================================
   4. Navigation & Sub-menus
   ========================================================================== */
/* Hamburger toggle (visually hidden but keyboard-focusable) */
.menu-toggle-checkbox {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
    margin: -1px;
    padding: 0;
}

.menu-toggle-btn {
    display: none;
    width: 40px;
    height: 40px;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    user-select: none;
}

.menu-toggle-bars,
.menu-toggle-bars::before,
.menu-toggle-bars::after {
    display: block;
    width: 26px;
    height: 2px;
    background: var(--text-main);
    transition: transform 0.3s ease, top 0.3s ease, opacity 0.2s ease;
    position: relative;
}

.menu-toggle-bars::before,
.menu-toggle-bars::after {
    content: "";
    position: absolute;
    left: 0;
}

.menu-toggle-bars::before { top: -8px; }
.menu-toggle-bars::after  { top:  8px; }

/* Reflect keyboard focus on the visible hamburger label */
.menu-toggle-checkbox:focus-visible ~ .header-inner .menu-toggle-btn {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
    border-radius: var(--radius);
}

/* Animate to "X" when checked */
.menu-toggle-checkbox:checked ~ .header-inner .menu-toggle-bars {
    background: transparent;
}

.menu-toggle-checkbox:checked ~ .header-inner .menu-toggle-bars::before {
    top: 0;
    transform: rotate(45deg);
}

.menu-toggle-checkbox:checked ~ .header-inner .menu-toggle-bars::after {
    top: 0;
    transform: rotate(-45deg);
}

.menu-overlay {
    display: none;
}

/* ==========================================================================
   Desktop nav (≥ 993px) — fully isolated from mobile
   ========================================================================== */
@media (min-width: 993px) {
    .main-nav {
        width: 100%;
        display: flex;
        justify-content: center;
        padding-top: 8px;
        position: relative;
    }

    .main-nav::before {
        content: "";
        position: absolute;
        top: 0;
        left: 50%;
        transform: translateX(-50%);
        width: 100vw;
        height: 1px;
        background: var(--border);
        pointer-events: none;
    }

    .main-nav > ul { /* Only target top-level */
        display: flex;
        gap: 2.5rem;
    }

    .main-nav a {
        font-size: 18px;
        font-weight: 400;
        color: var(--text-muted);
        letter-spacing: 0.05em;
    }

    .main-nav a:hover,
    .main-nav .current-menu-item > a {
        color: var(--primary);
    }

    /* Dropdown Arrow Indicator */
    .menu-item-has-children > a {
        display: flex;
        align-items: center;
    }

    .menu-item-has-children > a::after {
        content: "";
        display: inline-block;
        width: 12px;
        height: 12px;
        margin-left: 5px;
        background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="%238c8c8c" stroke-width="3" stroke-linecap="round" stroke-linejoin="round"><path d="m6 9 6 6 6-6"/></svg>');
        background-size: contain;
        background-repeat: no-repeat;
        transition: transform 0.3s ease;
    }

    .menu-item-has-children:hover > a::after {
        transform: rotate(180deg);
        background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="%238b9d83" stroke-width="3" stroke-linecap="round" stroke-linejoin="round"><path d="m6 9 6 6 6-6"/></svg>');
    }

    /* Sub-menus */
    .main-nav li {
        position: relative;
    }

    .main-nav .sub-menu {
        position: absolute;
        top: 100%;
        left: 50%;
        transform: translateX(-50%) translateY(10px);
        background: var(--bg-card);
        min-width: 180px;
        padding: 0;
        display: block; /* Force block for vertical layout */
        box-shadow: 0 10px 30px rgba(0,0,0,0.1);
        border: 1px solid var(--border);
        opacity: 0;
        visibility: hidden;
        transition: all 0.3s ease;
        z-index: 100;
    }

    .main-nav li:hover > .sub-menu {
        opacity: 1;
        visibility: visible;
        transform: translateX(-50%) translateY(0);
    }

    .main-nav .sub-menu a {
        display: block;
        width: 100%;
        padding: 12px 20px;
        font-size: 18px;
        text-align: center;
        color: var(--text-main);
        white-space: nowrap;
    }

    .main-nav .sub-menu a:hover,
    .main-nav .sub-menu .current-menu-item > a {
        background-color: #3d3d3d;
        color: #ffffff;
    }
}

/* ==========================================================================
   5. Blog List (index.php)
   ========================================================================== */
.blog-grid {
    display: flex;
    flex-direction: column;
    margin-bottom: 5rem;
}

.post-card {
    display: flex;
    gap: 3rem;
    border-bottom: 1px solid var(--border);
    padding: 4.5rem 0; /* Increased and unified padding */
    align-items: center;
}

/* No specific padding for first child to keep it consistent */
.post-card:first-child {
    padding-top: 4.5rem;
}

.post-card:last-child {
    border-bottom: none;
}

.post-thumbnail {
    flex: 0 0 320px;
    aspect-ratio: 4 / 3;
    background: #f0efeb;
    overflow: hidden;
}

.post-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.post-content {
    flex: 1;
}

.post-category {
    font-size: 14px;
    color: var(--primary);
    margin-bottom: 0.75rem;
}

.post-title {
    font-size: 1.6rem;
    margin-bottom: 0.5rem;
}

.post-meta {
    font-size: 15px;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.post-excerpt {
    margin-top: 1rem;
    opacity: 0.85;
}

/* ==========================================================================
   6. Single Post (single.php)
   ========================================================================== */
.entry-title {
    font-size: 2.25rem;
    margin-bottom: 1.5rem;
}

.entry-content a {
    color: var(--primary);
    text-decoration: underline;
    text-underline-offset: 4px;
    text-decoration-thickness: 1px;
}

.entry-content a:hover {
    color: var(--primary-hover);
    text-decoration-thickness: 2px;
}

.single-post .entry-content h2,
.section-title {
    font-size: 1.8rem;
    font-weight: 600;
    margin: 4rem 0 2rem;
    padding-left: 1rem;
    border-left: 5px solid var(--primary); /* The signature sage green line */
    color: var(--text-main);
    line-height: 1.2;
    letter-spacing: 0.05em;
}

/* Page H2 Reset (No border) */
.page .entry-content h2 {
    border-left: none;
    padding-left: 0;
}

.entry-content h3 {
    font-size: 1.4rem;
    margin: 3rem 0 1.5rem;
    color: var(--text-main);
}

.post-featured-image {
    aspect-ratio: 4 / 3;
    margin-bottom: 3rem;
    overflow: hidden;
}

.post-featured-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.entry-content p, .entry-content ul, .entry-content ol {
    margin-bottom: 2rem;
}

.entry-content ul {
    list-style: disc inside;
    padding-left: 1rem;
}

.entry-content ol {
    list-style: decimal inside;
    padding-left: 1rem;
}

.entry-content li {
    margin-bottom: 0.75rem;
}

/* ==========================================================================
   7. Components & UI Elements
   ========================================================================== */
/* Breadcrumbs */
.yoast-breadcrumbs {
    font-size: 15px;
    color: var(--text-muted);
    margin-bottom: 1rem;
    letter-spacing: 0.05em;
}

/* Pagination */
.pagination-wrapper {
    margin: 5rem 0;
    text-align: center;
}

.pagination-wrapper .nav-links {
    display: flex;
    justify-content: center;
    gap: 1rem;
    align-items: center;
}

.pagination-wrapper .page-numbers {
    padding: 8px 16px;
    border: 1px solid var(--border);
    font-size: 15px;
    color: var(--text-muted);
}

.pagination-wrapper .page-numbers.current {
    background-color: var(--primary);
    color: #ffffff;
    border-color: var(--primary);
}

.pagination-wrapper .page-numbers:hover:not(.current) {
    background-color: #f8f8f8;
    color: var(--primary);
}

/* Tables (raw <table> + Gutenberg wp-block-table) */
.entry-content table,
.entry-content .wp-block-table table {
    width: 100%;
    border-collapse: collapse;
    margin: 2.5rem 0;
    font-size: 16px;
    line-height: 1.6;
    background: var(--bg-card);
    border: 1px solid var(--border);
    overflow-wrap: break-word;
}

.entry-content table th,
.entry-content table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    text-align: left;
    vertical-align: top;
}

.entry-content table th {
    background: #f5f4ef;
    font-weight: 600;
    color: var(--text-main);
    border-bottom: 2px solid var(--primary);
    letter-spacing: 0.03em;
}

.entry-content table tbody tr:last-child td {
    border-bottom: none;
}

.entry-content table tbody tr:hover {
    background: #faf9f5;
}

.entry-content .wp-block-table {
    margin: 2.5rem 0;
    overflow-x: auto;          /* 寬表格手機可橫向捲 */
    -webkit-overflow-scrolling: touch;
}

.entry-content .wp-block-table table {
    margin: 0;
}

.entry-content .wp-block-table.is-style-stripes table tbody tr:nth-child(odd) {
    background: #f9f8f3;
}

.entry-content .wp-block-table.is-style-stripes table tbody tr:hover {
    background: #f5f4ef;
}

.entry-content .wp-block-table figcaption {
    margin-top: 0.75rem;
    font-size: 14px;
    color: var(--text-muted);
    text-align: center;
}

/* Gutenberg Blocks */
.wp-block-image {
    margin: 3rem auto;
    max-width: 800px !important;
    text-align: center;
}

.wp-block-image img {
    margin: 0 auto;
    border-radius: var(--radius);
}

.wp-block-image figcaption {
    margin-top: 1rem;
    font-size: 14px;
    color: var(--text-muted);
    text-align: center;
}

.wp-block-image figcaption::before {
    content: "▲";
    margin-right: 8px;
    font-size: 0.75rem;
    color: var(--primary);
}

/* ACF Additional Sections */
.post-qa-section, .post-ref-section {
    margin-top: 5rem;
    padding-top: 3rem;
    border-top: 1px solid var(--border);
}

.section-title {
    font-size: 1.8rem;
    font-weight: 600;
    margin-bottom: 2rem;
    padding-left: 1rem;
    border-left: 5px solid var(--primary);
    color: var(--text-main);
    line-height: 1.2;
    letter-spacing: 0.05em;
}

/* Q&A Style */
.qa-item {
    margin-bottom: 2.5rem;
}

.qa-question, .qa-answer {
    display: flex;
    gap: 1rem;
    align-items: flex-start;
    width: 100%;
}

.qa-question {
    margin-bottom: 0.75rem;
}

.qa-label {
    flex: 0 0 24px;
    height: 24px;
    background: var(--primary);
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
    margin-top: 4px;
}

.qa-text-content {
    flex: 1;
    min-width: 0;
    font-size: 18px;
    color: var(--text-main);
    overflow-wrap: anywhere;
    word-break: break-all;
}

.qa-question .qa-text-content {
    font-weight: 600;
}

.qa-answer .qa-text-content {
    opacity: 0.85;
}

.qa-answer .qa-label {
    background: var(--border);
    color: var(--text-muted);
}

/* Reference Style - Compact List */
.ref-list {
    list-style: none !important;
    padding: 0 !important;
}

.ref-item {
    border-bottom: 1px solid var(--border);
}

.ref-item:last-child {
    border-bottom: none;
}

.ref-item a {
    display: block;
    padding: 1.1rem 0; /* Increased and balanced padding */
    text-decoration: none !important;
    line-height: 1.2; /* Tighter line height to help centering */
}

.ref-title {
    display: inline;
    font-size: 18px;
    font-weight: 600;
    color: var(--text-main);
    overflow-wrap: anywhere;
    word-break: break-all;
}

.ref-site {
    display: inline;
    font-size: 14px;
    color: var(--text-muted);
    margin-left: 10px;
    font-weight: 400;
}

.ref-icon {
    font-size: 12px;
    margin-left: 6px;
    opacity: 0.3;
}

.ref-item a:hover .ref-title {
    color: var(--primary);
}

/* --- Related Posts Section --- */
.post-related-section {
    margin-top: 5rem;
    padding-top: 3rem;
    border-top: 1px solid var(--border);
}

.related-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 2rem;
}

.related-card {
    display: flex;
    flex-direction: column;
}

.related-thumb {
    aspect-ratio: 16 / 10;
    overflow: hidden;
    margin-bottom: 1rem;
    background: #f0efeb;
}

.related-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.4s ease;
}

.related-card:hover .related-thumb img {
    transform: scale(1.05);
}

.related-cat {
    font-size: 13px;
    color: var(--primary);
    margin-bottom: 0.5rem;
    display: block;
}

.related-title {
    font-size: 18px;
    line-height: 1.5;
    font-weight: 600;
}

.related-title a {
    color: var(--text-main) !important;
    text-decoration: none !important;
}

.related-title a:hover {
    color: var(--primary) !important;
}

/* Post Meta Actions */
.post-meta .edit-link a {
    color: var(--accent);
    font-weight: 600;
}

.post-meta .edit-link a:hover {
    text-decoration: underline;
}

.tags-links {
    font-size: 15px;
    color: var(--text-muted);
}

.tags-links a {
    color: var(--primary);
    margin-right: 10px;
}

/* --- Search Form --- */
.search-form {
    display: flex;
    max-width: 500px;
    margin: 0 auto;
    gap: 0;
}

.search-form label {
    flex: 1;
}

.search-field {
    width: 100%;
    padding: 12px 15px;
    border: 1px solid var(--border);
    border-right: none;
    border-radius: var(--radius) 0 0 var(--radius);
    background: #fff;
    font-size: 16px;
    font-family: inherit;
    color: var(--text-main);
    outline: none;
    transition: border-color 0.3s ease;
}

.search-field:focus {
    border-color: var(--primary);
}

.search-submit {
    padding: 12px 25px;
    background: var(--primary);
    color: #fff;
    border: 1px solid var(--primary);
    border-radius: 0 var(--radius) var(--radius) 0;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.search-submit:hover {
    background: var(--primary-hover);
    border-color: var(--primary-hover);
}

.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;
    width: 1px;
    word-wrap: normal !important;
}

/* --- Privacy Policy & Admin Pages --- */
.page-privacy-policy .entry-title,
.privacy-policy .entry-title {
    text-align: center;
    margin-bottom: 4rem;
}

.page-privacy-policy .entry-content,
.privacy-policy .entry-content {
    max-width: 800px; /* Better for reading long text */
    margin: 0 auto;
}

.page-privacy-policy .entry-content h2 {
    font-size: 1.5rem;
    margin: 3.5rem 0 1.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
    color: var(--text-main);
}

.page-privacy-policy .entry-content h3 {
    font-size: 1.25rem;
    margin: 2.5rem 0 1rem;
    color: var(--primary);
}

.page-privacy-policy .entry-content p {
    line-height: 1.8; /* Extra breathing room */
    margin-bottom: 1.5rem;
    color: #555;
}

.page-privacy-policy .entry-content ul {
    background: #f9f9f7;
    padding: 2rem 2rem 2rem 3rem !important;
    border-radius: var(--radius);
    margin: 2rem 0;
}

.page-privacy-policy .entry-content li {
    margin-bottom: 1rem;
    color: #555;
}

/* ==========================================================================
   7b. Page-template Specific Layouts
   ========================================================================== */
/* Archive (category, tag, author, date) */
.archive-header {
    margin-bottom: 3rem;
    padding-bottom: 2rem;
    border-bottom: 1px solid var(--border);
}

.archive-title {
    font-size: 2rem;
    margin-bottom: 1rem;
}

.archive-description {
    color: var(--text-muted);
    opacity: 0.8;
}

/* Search */
.search-header {
    margin-bottom: 3rem;
    padding-bottom: 2rem;
    border-bottom: 1px solid var(--border);
}

.search-title {
    font-size: 2rem;
}

.search-query {
    color: var(--primary);
}

.no-results {
    padding: 5rem 0;
    text-align: center;
}

.no-results-text {
    font-size: 1.2rem;
    margin-bottom: 2rem;
}

/* Page (page.php) */
.page .entry-header {
    margin-bottom: 3rem;
}

.page .entry-title {
    font-size: 2.5rem;
}

/* Single Post (single.php) — header & body spacing */
.single .entry-header {
    margin-top: 3rem;
}

.single .entry-body {
    margin-top: 2rem;
}

.single .entry-footer {
    margin-top: 4rem;
    padding-bottom: 5rem;
}

/* 404 */
.error-404 {
    padding: 10rem 0;
    text-align: center;
}

.error-404 .page-title {
    font-size: 5rem;
    color: var(--primary);
    margin-bottom: 1rem;
}

.error-404-subtitle {
    font-size: 1.5rem;
    margin-bottom: 3rem;
    font-weight: 400;
    opacity: 0.8;
}

.error-404-text {
    margin-bottom: 3rem;
}

.error-404-back {
    margin-top: 5rem;
}

.error-404-back a {
    color: var(--primary);
    text-decoration: underline;
}

/* ==========================================================================
   8. Footer
   ========================================================================== */
.site-footer {
    padding: 2rem 0; /* Compact padding */
    border-top: 1px solid var(--border);
    color: var(--text-muted);
}

.footer-inner {
    text-align: center;
}

.footer-copy {
    font-size: 14px;
}

.footer-sep {
    margin: 0 8px;
    opacity: 0.5;
}

.footer-link:hover {
    color: var(--primary);
    text-decoration: underline;
}

/* ==========================================================================
   9. Responsive (Tablet & Mobile)
   ========================================================================== */

/* --- Tablet & below (≤ 992px) --- */
@media (max-width: 992px) {
    .related-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .post-thumbnail {
        flex: 0 0 240px;
    }

    .post-card {
        gap: 2rem;
        padding: 3rem 0;
    }

    /* --- Header: logo left, hamburger right --- */
    .site-header {
        padding: 1rem 0;
        margin-bottom: 2rem;
        position: relative;
        z-index: 50;
    }

    .header-inner {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        gap: 1rem;
    }

    .menu-toggle-btn {
        display: inline-flex;
        order: 2;
        position: relative;
        z-index: 10000;
    }

    .site-branding {
        order: 1;
    }

    /* Full-screen overlay menu */
    .main-nav {
        order: 3;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100vw;
        height: 100vh;
        height: 100dvh;
        background: var(--bg-body);
        padding: 5rem 1.5rem 3rem;
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.3s ease, visibility 0.3s ease;
        overflow-y: auto;
        overscroll-behavior: contain;
        display: flex;
        flex-direction: column;
        justify-content: flex-start;
        align-items: center;
        z-index: 9999;
    }

    .menu-toggle-checkbox:checked ~ .header-inner .main-nav {
        opacity: 1;
        visibility: visible;
    }

    .main-nav > ul {
        display: flex;
        flex-direction: column;
        width: 100%;
        max-width: 480px;
    }

    .main-nav li {
        width: 100%;
        text-align: center;
        position: relative;
    }

    .main-nav > ul > li {
        border-bottom: 1px solid var(--border);
    }

    .main-nav a {
        display: block;
        padding: 16px 8px;
        font-size: 18px;
        text-align: center;
        color: var(--text-main);
        letter-spacing: 0.05em;
    }

    .main-nav .current-menu-item > a {
        color: var(--primary);
    }

    /* Parent-with-children indicator: same chevron as desktop, rotates 180° when open */
    .menu-item-has-children > a {
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .menu-item-has-children > a::after {
        content: "";
        display: inline-block;
        width: 12px;
        height: 12px;
        margin-left: 8px;
        background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="%238c8c8c" stroke-width="3" stroke-linecap="round" stroke-linejoin="round"><path d="m6 9 6 6 6-6"/></svg>');
        background-size: contain;
        background-repeat: no-repeat;
        transition: transform 0.25s ease;
    }

    .menu-item-has-children.is-open > a::after {
        transform: rotate(180deg);
        background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="%238b9d83" stroke-width="3" stroke-linecap="round" stroke-linejoin="round"><path d="m6 9 6 6 6-6"/></svg>');
    }

    /* Submenu — hidden by default, shown when parent has .is-open */
    .main-nav .sub-menu {
        display: none;
        width: 100%;
    }

    .main-nav .menu-item-has-children.is-open > .sub-menu {
        display: block;
    }

    .main-nav .sub-menu li {
        border-bottom: 1px dashed var(--border);
    }

    .main-nav .sub-menu li:last-child {
        border-bottom: none;
    }

    .main-nav .sub-menu a {
        display: block;
        width: 100%;
        padding: 14px 8px;
        font-size: 18px;
        text-align: center;
        white-space: normal;
        color: var(--text-muted);
    }

    .main-nav .sub-menu .current-menu-item > a {
        color: var(--primary);
    }

    /* Hide hover-mode helper overlay on mobile (replaced by full-screen nav) */
    .menu-overlay {
        display: none;
    }

    /* Lock scroll when overlay open (modern :has() + JS-added .menu-open fallback) */
    body:has(.menu-toggle-checkbox:checked),
    body.menu-open {
        overflow: hidden;
    }
}

/* --- Mobile & small tablet (≤ 768px) --- */
@media (max-width: 768px) {
    body {
        font-size: 16px;
    }

    .container {
        padding: 0 18px;
    }

    /* Header sizing for phones (drawer logic inherited from ≤992px) */
    .site-logo {
        font-size: 1.4rem;
        letter-spacing: 0.08em;
    }

    /* Blog list — stack vertically */
    .post-card {
        flex-direction: column;
        gap: 1.25rem;
        padding: 2.5rem 0;
        align-items: stretch;
    }

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

    .post-thumbnail {
        flex: 1 1 auto;
        width: 100%;
        aspect-ratio: 16 / 10;
    }

    .post-title {
        font-size: 1.3rem;
    }

    .post-meta {
        font-size: 14px;
    }

    /* Hide separator dots so meta wraps cleanly */
    .post-meta .meta-sep {
        display: none;
    }

    .post-meta span {
        display: inline-block;
        margin-right: 0.75rem;
    }

    /* Single post */
    .entry-title {
        font-size: 1.6rem;
        margin-bottom: 1rem;
    }

    .single .entry-header {
        margin-top: 1.5rem;
    }

    .single-post .entry-content h2,
    .section-title {
        font-size: 1.35rem;
        margin: 2.5rem 0 1.25rem;
        padding-left: 0.75rem;
        border-left-width: 4px;
    }

    .entry-content h3 {
        font-size: 1.15rem;
        margin: 2rem 0 1rem;
    }

    .post-featured-image {
        margin-bottom: 2rem;
    }

    /* Related posts */
    .related-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1.25rem;
    }

    .related-title {
        font-size: 15px;
    }

    .post-related-section,
    .post-qa-section,
    .post-ref-section {
        margin-top: 3rem;
        padding-top: 2rem;
    }

    /* Q&A */
    .qa-text-content {
        font-size: 16px;
    }

    /* Tables — wrap & shrink on mobile */
    .entry-content table {
        font-size: 14px;
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        white-space: nowrap;
    }

    .entry-content table th,
    .entry-content table td {
        padding: 8px 12px;
    }

    .entry-content .wp-block-table {
        margin: 2rem -1rem;     /* 撐到容器邊以爭取寬度 */
        padding: 0 1rem;
    }

    /* References */
    .ref-title {
        font-size: 16px;
    }

    .ref-site {
        display: block;
        margin-left: 0;
        margin-top: 4px;
    }

    /* Pagination — allow wrap on small screens */
    .pagination-wrapper {
        margin: 3rem 0;
    }

    .pagination-wrapper .nav-links {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .pagination-wrapper .page-numbers {
        padding: 6px 12px;
        font-size: 14px;
    }

    /* Search form */
    .search-form {
        max-width: 100%;
    }

    .search-field,
    .search-submit {
        font-size: 15px;
        padding: 10px 14px;
    }

    /* Archive / Search header — mobile compact */
    .archive-header,
    .search-header {
        margin-bottom: 2rem;
        padding-bottom: 1.25rem;
    }

    .archive-title,
    .search-title {
        font-size: 1.4rem;
    }

    /* Footer */
    .site-footer {
        padding: 1.5rem 0;
    }

    .footer-copy {
        font-size: 13px;
        line-height: 1.6;
    }

    /* 404 */
    .error-404 {
        padding: 5rem 0;
    }

    .error-404 .page-title {
        font-size: 3.5rem;
    }

    .error-404-subtitle {
        font-size: 1.15rem;
        margin-bottom: 2rem;
    }

    /* Page (page.php) */
    .page .entry-title {
        font-size: 1.75rem;
    }

    .page .entry-header {
        margin-bottom: 2rem;
    }
}

/* --- Phone (≤ 480px) --- */
@media (max-width: 480px) {
    .container {
        padding: 0 14px;
    }

    .site-logo {
        font-size: 1.25rem;
    }

    .post-card {
        padding: 2rem 0;
    }

    .post-title {
        font-size: 1.2rem;
    }

    .related-grid {
        grid-template-columns: 1fr;
    }

    .related-thumb {
        aspect-ratio: 16 / 9;
    }

    .pagination-wrapper .page-numbers {
        padding: 5px 10px;
        font-size: 13px;
    }

    /* Stack search form vertically on very narrow screens */
    .search-form {
        flex-direction: column;
        gap: 8px;
    }

    .search-field {
        border-right: 1px solid var(--border);
        border-radius: var(--radius);
    }

    .search-submit {
        border-radius: var(--radius);
        width: 100%;
    }
}
