/*
Theme Name: AdviceAcademy
Theme URI: https://adviceacademy.co.uk
Author: Your Name
Description: Clean, lightweight, mobile-first WordPress theme. 3-column card grid homepage. Google Discover optimized.
Version: 2.0
Requires at least: 5.8
Tested up to: 6.5
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: adviceacademy
*/

/* =====================================================
   CSS VARIABLES
   ===================================================== */
:root {
    --white:      #ffffff;
    --black:      #1a1a1a;
    --gray-light: #f4f4f5;
    --gray-mid:   #e5e7eb;
    --gray-text:  #6b7280;
    --gray-dark:  #4b5563;
    --font:       -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
    --radius:     6px;
    --shadow:     0 1px 4px rgba(0,0,0,0.08), 0 0 0 1px rgba(0,0,0,0.04);
    --shadow-hover: 0 4px 18px rgba(0,0,0,0.13), 0 0 0 1px rgba(0,0,0,0.05);
    --max:        1100px;
    --narrow:     760px;
    --header-h:   58px;
}

/* =====================================================
   RESET
   ===================================================== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body { font-family: var(--font); font-size: 1rem; line-height: 1.6; color: var(--black); background: var(--gray-light); -webkit-font-smoothing: antialiased; }
img, video { max-width: 100%; height: auto; display: block; }
a { color: var(--black); text-decoration: none; }
a:hover { color: var(--gray-text); }
ul, ol { list-style: none; }
button { cursor: pointer; font-family: inherit; }

/* =====================================================
   SKIP LINK
   ===================================================== */
.skip-link { position: absolute; top: -100%; left: 0; background: var(--black); color: var(--white); padding: .5rem 1rem; font-size: .875rem; z-index: 9999; }
.skip-link:focus { top: 0; }

/* =====================================================
   LAYOUT
   ===================================================== */
.wrap {
    width: 100%;
    max-width: var(--max);
    margin: 0 auto;
    padding: 0 1.25rem;
}
.wrap--narrow {
    width: 100%;
    max-width: var(--narrow);
    margin: 0 auto;
    padding: 0 1.25rem;
}

/* =====================================================
   HEADER
   ===================================================== */
.site-header {
    position: sticky;
    top: 0;
    z-index: 200;
    background: var(--white);
    border-bottom: 1px solid var(--gray-mid);
    height: var(--header-h);
}
.site-header__inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 100%;
    max-width: var(--max);
    margin: 0 auto;
    padding: 0 1.25rem;
    gap: 1rem;
}
.site-logo {
    font-size: 1.1rem;
    font-weight: 800;
    letter-spacing: -.02em;
    color: var(--black);
    flex-shrink: 0;
}
.site-logo:hover { opacity: .75; color: var(--black); }

/* Desktop nav */
.site-nav { display: flex; align-items: center; }
.site-nav__list { display: flex; gap: 1.75rem; align-items: center; }
.site-nav__list a { font-size: .875rem; font-weight: 600; color: var(--black); }
.site-nav__list a:hover { color: var(--gray-text); }

/* Hamburger */
.nav-toggle { display: none; background: none; border: none; padding: 6px; color: var(--black); }

/* Mobile drawer */
.mobile-nav { display: none; position: fixed; inset: 0; z-index: 300; background: rgba(0,0,0,.35); }
.mobile-nav.is-open { display: block; }
.mobile-nav__panel { position: absolute; top: 0; right: 0; width: 260px; height: 100%; background: var(--white); padding: 1.25rem; overflow-y: auto; transform: translateX(100%); transition: transform .25s ease; }
.mobile-nav.is-open .mobile-nav__panel { transform: translateX(0); }
.mobile-nav__close { background: none; border: none; font-size: 1.5rem; line-height: 1; color: var(--black); margin-bottom: 1.5rem; display: block; }
.mobile-nav__list { display: flex; flex-direction: column; }
.mobile-nav__list li { border-bottom: 1px solid var(--gray-mid); }
.mobile-nav__list a { display: block; padding: .85rem 0; font-size: 1rem; font-weight: 600; color: var(--black); }

/* =====================================================
   MAIN
   ===================================================== */
.site-main { min-height: 60vh; }

/* =====================================================
   HOMEPAGE — 3-COLUMN CARD GRID
   ===================================================== */
.home-wrap {
    padding: 2rem 0 5rem;
}

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

/* Single card */
.card {
    background: var(--white);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    transition: box-shadow .2s ease, transform .2s ease;
}
.card:hover {
    box-shadow: var(--shadow-hover);
    transform: translateY(-2px);
}

/* Card thumbnail — top, 16:9 */
.card__thumb {
    display: block;
    width: 100%;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    background: #e5e7eb;
    flex-shrink: 0;
}
.card__thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform .35s ease;
}
.card:hover .card__thumb img { transform: scale(1.04); }

/* Card body */
.card__body {
    padding: 1rem 1.1rem 1.25rem;
    display: flex;
    flex-direction: column;
    flex: 1;
    gap: .35rem;
}

/* Category label */
.card__cat {
    font-size: .7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .09em;
    color: var(--gray-text);
    display: inline-block;
}
.card__cat a { color: inherit; }
.card__cat a:hover { color: var(--black); }

/* Title */
.card__title {
    font-size: 1rem;
    font-weight: 700;
    line-height: 1.35;
    letter-spacing: -.01em;
    margin: 0;
}
.card__title a { color: var(--black); }
.card__title a:hover { color: var(--gray-text); }

/* Meta */
.card__meta {
    font-size: .75rem;
    color: var(--gray-text);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .2rem;
}
.card__meta a { color: var(--gray-text); }
.card__meta-sep { opacity: .5; }

/* Excerpt */
.card__excerpt {
    font-size: .875rem;
    color: var(--gray-dark);
    line-height: 1.6;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin: 0;
}

/* Archive header (category page) */
.archive-header {
    padding: 1.5rem 0 1.25rem;
    border-bottom: 2px solid var(--black);
    margin-bottom: 1.5rem;
}
.archive-header__label {
    font-size: .7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .1em;
    color: var(--gray-text);
    display: block;
    margin-bottom: .3rem;
}
.archive-header__title {
    font-size: 1.75rem;
    font-weight: 800;
    letter-spacing: -.03em;
}

.no-posts { color: var(--gray-text); padding: 2rem 0; }

/* =====================================================
   PAGINATION
   ===================================================== */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: .3rem;
    padding: 2.5rem 0 0;
}
.pagination a,
.pagination span.current,
.pagination span.dots {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 38px;
    height: 38px;
    padding: 0 .6rem;
    font-size: .875rem;
    border: 1px solid var(--gray-mid);
    border-radius: var(--radius);
    background: var(--white);
    color: var(--black);
    transition: background .15s;
}
.pagination a:hover { background: #f3f4f6; }
.pagination span.current { background: var(--black); color: var(--white); border-color: var(--black); }
.pagination span.dots { border-color: transparent; background: transparent; }

/* =====================================================
   SINGLE POST PAGE
   ===================================================== */
.single-outer {
    padding: 2rem 0 5rem;
}
.single-wrap {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 2rem 2.5rem 3rem;
}

/* Post header */
.post-header { margin-bottom: 1.5rem; }

.post-header__cat {
    font-size: .7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .09em;
    color: var(--gray-text);
    display: inline-block;
    margin-bottom: .6rem;
}
.post-header__cat a { color: inherit; }
.post-header__cat a:hover { color: var(--black); }

.post-title {
    font-size: clamp(1.5rem, 4vw, 2rem);
    font-weight: 800;
    line-height: 1.2;
    letter-spacing: -.025em;
    margin-bottom: .85rem;
}
.post-meta {
    font-size: .8rem;
    color: var(--gray-text);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .3rem;
}
.post-meta a { color: var(--gray-text); }
.post-meta-sep { opacity: .5; }

/* Featured image */
.post-thumbnail {
    width: 100%;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    border-radius: var(--radius);
    margin-bottom: 1.75rem;
    background: var(--gray-mid);
}
.post-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Post content */
.entry-content { font-size: 1rem; line-height: 1.8; color: #1f2937; }
.entry-content > * + * { margin-top: 1.2rem; }
.entry-content p { margin-bottom: 1.1rem; }
.entry-content h2 { font-size: 1.3rem; font-weight: 800; letter-spacing: -.02em; line-height: 1.25; margin-top: 2.25rem; margin-bottom: .75rem; }
.entry-content h3 { font-size: 1.1rem; font-weight: 700; margin-top: 1.75rem; margin-bottom: .5rem; }
.entry-content h4 { font-size: 1rem; font-weight: 700; margin-top: 1.25rem; margin-bottom: .4rem; }
.entry-content ul { list-style: disc; padding-left: 1.5rem; margin-bottom: 1rem; }
.entry-content ol { list-style: decimal; padding-left: 1.5rem; margin-bottom: 1rem; }
.entry-content li { margin-bottom: .4rem; }
.entry-content strong { font-weight: 700; }
.entry-content em { font-style: italic; }
.entry-content figure { margin: 1.5rem 0; }
.entry-content figcaption { font-size: .8rem; color: var(--gray-text); text-align: center; margin-top: .35rem; }

/* Blockquote */
.entry-content blockquote {
    background: #f9f9f9;
    border-left: 3px solid #d1d5db;
    padding: 1rem 1.25rem;
    margin: 1.5rem 0;
    border-radius: 0 var(--radius) var(--radius) 0;
    font-style: italic;
    color: var(--gray-dark);
}
.entry-content blockquote p:last-child { margin-bottom: 0; }

/* Table */
.entry-content table { width: 100%; border-collapse: collapse; font-size: .875rem; margin: 1.5rem 0; border: 1px solid var(--gray-mid); border-radius: var(--radius); overflow: hidden; }
.entry-content table thead th { background: #f3f4f6; font-weight: 600; text-align: left; padding: .65rem .9rem; border-bottom: 1px solid var(--gray-mid); }
.entry-content table tbody td { padding: .6rem .9rem; border-bottom: 1px solid var(--gray-mid); vertical-align: top; }
.entry-content table tbody tr:last-child td { border-bottom: none; }
.entry-content table tbody tr:nth-child(even) td { background: #fafafa; }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* Internal links */
.internal-links { border-top: 1px solid var(--gray-mid); border-bottom: 1px solid var(--gray-mid); padding: 1rem 0; margin: 1.75rem 0; display: flex; flex-direction: column; gap: .3rem; }
.internal-links a { font-size: .875rem; color: var(--black); display: flex; align-items: baseline; gap: .4rem; }
.internal-links a::before { content: "➡️"; flex-shrink: 0; }
.internal-links a:hover { color: var(--gray-text); }

/* FAQ */
.faq-section { margin: 2rem 0; }
.faq-section > h3 { font-size: 1.1rem; font-weight: 700; margin-bottom: 1rem; }
.faq-item { border: 1px solid var(--gray-mid); border-radius: var(--radius); margin-bottom: .5rem; overflow: hidden; }
.faq-q { font-size: .875rem; font-weight: 600; padding: .9rem 1rem; cursor: pointer; display: flex; justify-content: space-between; align-items: center; gap: .75rem; background: var(--white); border: none; width: 100%; text-align: left; color: var(--black); transition: background .15s; -webkit-tap-highlight-color: transparent; }
.faq-q:hover { background: #f9fafb; }
.faq-q__icon { flex-shrink: 0; width: 20px; height: 20px; border: 1px solid var(--gray-mid); border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 1rem; font-weight: 400; line-height: 1; transition: transform .2s; }
.faq-item.is-open .faq-q__icon { transform: rotate(45deg); }
.faq-a { display: none; padding: .75rem 1rem 1rem; font-size: .875rem; color: var(--gray-dark); line-height: 1.65; border-top: 1px solid var(--gray-mid); background: #fafafa; }
.faq-item.is-open .faq-a { display: block; }

/* Post navigation */
.post-nav { display: flex; gap: 1rem; padding: 2rem 0 0; border-top: 1px solid var(--gray-mid); margin-top: 1.75rem; }
.post-nav__link { display: flex; align-items: center; gap: .4rem; font-size: .875rem; font-weight: 600; color: var(--black); flex: 1; min-width: 0; }
.post-nav__link--prev { justify-content: flex-start; }
.post-nav__link--next { justify-content: flex-end; text-align: right; }
.post-nav__link:hover { color: var(--gray-text); }
.post-nav__link--prev::before { content: "←"; flex-shrink: 0; }
.post-nav__link--next::after { content: "→"; flex-shrink: 0; }
.post-nav__label { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* Related posts */
.related-posts { padding-top: 2rem; border-top: 1px solid var(--gray-mid); margin-top: 1.75rem; }
.related-posts__heading { font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .12em; color: var(--gray-text); margin-bottom: 1.1rem; }
.related-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: .85rem; }
.related-card { display: flex; flex-direction: column; gap: .4rem; }
.related-card__thumb { width: 100%; aspect-ratio: 4/3; overflow: hidden; border-radius: var(--radius); background: var(--gray-mid); display: block; }
.related-card__thumb img { width: 100%; height: 100%; object-fit: cover; transition: transform .3s ease; }
.related-card:hover .related-card__thumb img { transform: scale(1.05); }
.related-card__title { font-size: .78rem; font-weight: 600; line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.related-card__title a { color: var(--black); }
.related-card__title a:hover { color: var(--gray-text); }

/* =====================================================
   SEARCH PAGE
   ===================================================== */
.search-form-wrap { display: flex; gap: .5rem; margin-bottom: 2rem; }
.search-form-wrap input[type="search"] { flex: 1; padding: .65rem .9rem; border: 1px solid var(--gray-mid); border-radius: var(--radius); font-size: .875rem; outline: none; background: var(--white); }
.search-form-wrap input[type="search"]:focus { border-color: var(--black); }
.search-form-wrap button[type="submit"] { padding: .65rem 1rem; background: var(--black); color: var(--white); border: none; border-radius: var(--radius); font-size: .875rem; font-weight: 600; }

/* Search post card */
.post-list { display: flex; flex-direction: column; }
.post-card { display: grid; grid-template-columns: 200px 1fr; gap: 1.25rem; align-items: flex-start; padding: 1.5rem 0; border-bottom: 1px solid var(--gray-mid); }
.post-card:first-child { padding-top: 0; }
.post-card__thumb { width: 100%; aspect-ratio: 16/9; border-radius: var(--radius); overflow: hidden; background: var(--gray-mid); display: block; }
.post-card__thumb img { width: 100%; height: 100%; object-fit: cover; }
.post-card__body { min-width: 0; }
.post-card__cat { font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .09em; color: var(--gray-text); display: inline-block; margin-bottom: .3rem; }
.post-card__cat a { color: inherit; }
.post-card__title { font-size: 1rem; font-weight: 700; line-height: 1.35; margin-bottom: .3rem; }
.post-card__title a { color: var(--black); }
.post-card__title a:hover { color: var(--gray-text); }
.post-card__meta { font-size: .75rem; color: var(--gray-text); display: flex; flex-wrap: wrap; gap: .2rem; margin-bottom: .4rem; }
.post-card__meta a { color: var(--gray-text); }
.post-card__meta-sep { opacity: .5; }
.post-card__excerpt { font-size: .875rem; color: var(--gray-dark); line-height: 1.55; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* =====================================================
   404 PAGE
   ===================================================== */
.error-wrap { text-align: center; padding: 5rem 0; background: var(--white); border-radius: var(--radius); margin: 2rem 0; box-shadow: var(--shadow); }
.error-wrap h1 { font-size: 5rem; font-weight: 800; letter-spacing: -.05em; line-height: 1; margin-bottom: .5rem; }
.error-wrap p { color: var(--gray-text); margin-bottom: 1.5rem; }
.btn { display: inline-flex; align-items: center; padding: .65rem 1.5rem; background: var(--black); color: var(--white); font-size: .875rem; font-weight: 600; border-radius: var(--radius); transition: opacity .15s; }
.btn:hover { color: var(--white); opacity: .8; }

/* =====================================================
   FOOTER
   ===================================================== */
.site-footer {
    background: var(--white);
    border-top: 1px solid var(--gray-mid);
    padding: 1.5rem 0;
}
.site-footer__inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: .75rem;
    font-size: .8rem;
    color: var(--gray-text);
    max-width: var(--max);
    margin: 0 auto;
    padding: 0 1.25rem;
}
.footer-nav__list { display: flex; flex-wrap: wrap; gap: 1.25rem; }
.footer-nav__list a { color: var(--gray-text); font-size: .8rem; }
.footer-nav__list a:hover { color: var(--black); }

/* =====================================================
   SCROLL TO TOP
   ===================================================== */
.scroll-top { position: fixed; bottom: 1.25rem; right: 1.25rem; width: 38px; height: 38px; background: var(--black); color: var(--white); border: none; border-radius: 50%; display: flex; align-items: center; justify-content: center; opacity: 0; visibility: hidden; transition: opacity .25s, visibility .25s; z-index: 150; -webkit-tap-highlight-color: transparent; }
.scroll-top.is-visible { opacity: 1; visibility: visible; }

/* =====================================================
   WP HELPERS
   ===================================================== */
.screen-reader-text { clip: rect(1px,1px,1px,1px); height: 1px; overflow: hidden; position: absolute !important; width: 1px; }
.entry-content .aligncenter { display: block; margin-left: auto; margin-right: auto; }
.entry-content .alignleft { float: left; margin-right: 1.5rem; margin-bottom: 1rem; max-width: 50%; }
.entry-content .alignright { float: right; margin-left: 1.5rem; margin-bottom: 1rem; max-width: 50%; }
.entry-content .wp-caption { max-width: 100%; }
.entry-content .wp-caption-text { font-size: .8rem; color: var(--gray-text); text-align: center; margin-top: .35rem; }
.entry-content .wp-block-image img { border-radius: var(--radius); }
.entry-content .clearfix::after { content: ""; display: table; clear: both; }

/* =====================================================
   RESPONSIVE — TABLET 900px
   ===================================================== */
@media (max-width: 900px) {
    .card-grid { grid-template-columns: repeat(2, 1fr); gap: 1.1rem; }
    .related-grid { grid-template-columns: repeat(4, 1fr); gap: .65rem; }
    .single-wrap { padding: 1.5rem 1.75rem 2.5rem; }
}

/* =====================================================
   RESPONSIVE — MOBILE 640px
   ===================================================== */
@media (max-width: 640px) {
    /* Header */
    .site-nav { display: none; }
    .nav-toggle { display: flex; }

    /* Card grid */
    .card-grid { grid-template-columns: 1fr; gap: .85rem; }
    .card__title { font-size: .95rem; }

    /* Single */
    .single-outer { padding: 1rem 0 3rem; }
    .single-wrap { padding: 1.25rem 1rem 2rem; border-radius: 0; box-shadow: none; }
    .post-title { font-size: 1.4rem; }
    .entry-content h2 { font-size: 1.15rem; }

    /* Related */
    .related-grid { grid-template-columns: repeat(2, 1fr); gap: .65rem; }
    .related-card__title { font-size: .75rem; }

    /* Post nav */
    .post-nav { flex-direction: column; gap: .75rem; }
    .post-nav__link--next { justify-content: flex-start; text-align: left; }

    /* Search card */
    .post-card { grid-template-columns: 1fr; gap: .75rem; }

    /* Footer */
    .site-footer__inner { flex-direction: column; align-items: flex-start; }
}

@media (max-width: 400px) {
    .card-grid { gap: .65rem; }
}



/* =====================================================
   AD SLOTS — AdInserter compatible
   ===================================================== */

.ad-slot {
    width: 100%;
    clear: both;
    overflow: hidden;
    text-align: center;
}

/* Hide slot wrapper if AdInserter puts nothing inside */
.ad-slot:empty,
.ad-slot--before-content:empty,
.ad-slot--after-content:empty,
.ad-slot--before-related:empty { 
    display: none; 
    margin: 0; 
    padding: 0; 
}

/* Before content (below featured image) */
.ad-slot--before-content {
    margin: 0 0 1.5rem;
}

/* After content */
.ad-slot--after-content {
    margin: 1.75rem 0;
    padding: 1.25rem 0;
    border-top: 1px solid var(--gray-mid);
    border-bottom: 1px solid var(--gray-mid);
}

/* Before related posts */
.ad-slot--before-related {
    margin: 0 0 1.5rem;
}

/* AdInserter injects <div> inside — make it full width */
.ad-slot > div,
.ad-slot > ins,
.ad-slot > iframe,
.ad-slot > script + ins {
    max-width: 100%;
    margin: 0 auto;
}

/* Mobile */
@media (max-width: 640px) {
    .ad-slot--after-content {
        padding: 0.75rem 0;
        margin: 1.25rem 0;
    }
}
