/* ============================================================================
 * Pokitap front-end stylesheet
 *
 * Modules in order:
 *   1. Reset / base typography
 *   2. Layout primitives (container, main, hero, sidebar)
 *   3. Header / nav / footer
 *   4. Article cards (card grid + mixed layout)
 *   5. Article detail
 *   6. Search box
 *   7. Author profile
 *   8. Compliance pages
 *   9. 404 page
 *  10. AdSense slots
 *  11. Misc (mark, loading skeletons)
 *  12. Responsive breakpoints
 * ========================================================================== */


/* ----------------------------------------------------------------------------
 * 1. Reset / base typography
 * -------------------------------------------------------------------------- */

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    margin: 0;
    font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI",
        "Helvetica Neue", Helvetica, Arial, sans-serif;
    color: #172033;
    background: #ffffff;
    line-height: 1.65;
    font-size: 16px;
}

h1, h2, h3, h4, h5, h6 {
    color: #0f172a;
    line-height: 1.25;
    margin: 0 0 0.5em;
    font-weight: 700;
}

h1 {
    font-size: clamp(1.8rem, 1.4rem + 1.2vw, 2.6rem);
    letter-spacing: -0.01em;
}

h2 {
    font-size: 1.4rem;
    letter-spacing: -0.005em;
}

h3 {
    font-size: 1.15rem;
}

p {
    margin: 0 0 1em;
}

a {
    color: #2563eb;
    text-decoration: none;
}

a:hover,
a:focus-visible {
    text-decoration: underline;
}

img {
    max-width: 100%;
    height: auto;
    display: block;
}

button {
    font: inherit;
    cursor: pointer;
}

input,
button,
select,
textarea {
    font: inherit;
}

::selection {
    background: #bfdbfe;
    color: #0f172a;
}


/* ----------------------------------------------------------------------------
 * 2. Layout primitives
 * -------------------------------------------------------------------------- */

main {
    max-width: 1120px;
    margin: 0 auto;
    padding: 32px 20px 60px;
}

.hero {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 320px;
    gap: 40px;
    align-items: flex-start;
}

.sidebar {
    display: flex;
    flex-direction: column;
    gap: 24px;
    position: sticky;
    top: 24px;
}

.layout-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    margin: 4px 0 24px;
    padding: 12px 16px;
    background: #f8fafc;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
}

.layout-toolbar .result-count {
    color: #64748b;
    font-size: 14px;
}

.layout-toggle {
    display: inline-flex;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    overflow: hidden;
    background: #ffffff;
}

.layout-toggle button {
    appearance: none;
    border: 0;
    background: transparent;
    padding: 8px 12px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: #475569;
    font-size: 13px;
    line-height: 1;
}

.layout-toggle button + button {
    border-left: 1px solid #e5e7eb;
}

.layout-toggle button.is-active {
    background: #0f172a;
    color: #ffffff;
}

.layout-toggle button:hover:not(.is-active) {
    background: #f1f5f9;
    color: #0f172a;
}

.layout-toggle .icon {
    width: 16px;
    height: 16px;
    flex: 0 0 16px;
}


/* ----------------------------------------------------------------------------
 * 3. Header / nav / footer
 * -------------------------------------------------------------------------- */

header.site-header {
    display: flex;
    gap: 24px;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    padding: 16px max(20px, calc((100vw - 1120px) / 2));
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: saturate(180%) blur(12px);
    border-bottom: 1px solid #e5e7eb;
    position: sticky;
    top: 0;
    z-index: 10;
}

header.site-header .brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
}

header.site-header .brand img {
    height: 32px;
    width: auto;
    display: block;
}

header.site-header nav {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    align-items: center;
}

header.site-header nav a {
    color: #334155;
    text-decoration: none;
    margin-right: 14px;
    padding: 6px 0;
    font-weight: 500;
}

header.site-header nav a:hover,
header.site-header nav a:focus-visible {
    color: #0f172a;
    text-decoration: none;
    border-bottom: 2px solid #2563eb;
}

header.site-header .header-search {
    display: inline-flex;
    align-items: center;
    gap: 0;
}

footer.site-footer {
    display: flex;
    gap: 16px;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    padding: 24px max(20px, calc((100vw - 1120px) / 2));
    border-top: 1px solid #e5e7eb;
    margin-top: 60px;
    color: #64748b;
    font-size: 14px;
}

footer.site-footer .compliance-links {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

footer.site-footer a {
    color: #475569;
    text-decoration: none;
}

footer.site-footer a:hover,
footer.site-footer a:focus-visible {
    color: #0f172a;
    text-decoration: underline;
}


/* ----------------------------------------------------------------------------
 * 4. Article cards (grid + mixed layouts)
 * -------------------------------------------------------------------------- */

.article-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}

.article-list {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.card {
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 18px;
    padding: 18px;
    margin: 0;
    transition: transform 160ms ease, box-shadow 160ms ease,
        border-color 160ms ease;
}

.card:hover {
    border-color: #cbd5e1;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
    transform: translateY(-2px);
}

.article-card .cover {
    width: 100%;
    aspect-ratio: 16 / 9;
    object-fit: cover;
    border-radius: 14px;
    background: #f1f5f9;
    margin-bottom: 14px;
}

.article-card h2 {
    margin: 0 0 8px;
    font-size: 1.15rem;
    line-height: 1.35;
}

.article-card h2 a {
    color: #0f172a;
    text-decoration: none;
}

.article-card h2 a:hover,
.article-card h2 a:focus-visible {
    color: #2563eb;
}

.article-card .summary {
    margin: 0;
    color: #475569;
    font-size: 0.95rem;
    line-height: 1.55;
}

.article-card .meta {
    color: #64748b;
    font-size: 13px;
    margin: 0 0 8px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* Mixed layout (left-cover / right-text) — single column, fixed-width cover. */
.article-list .article-card {
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr);
    gap: 24px;
    padding: 18px;
    align-items: stretch;
}

.article-list .article-card .cover-wrap {
    margin: 0;
}

.article-list .article-card .cover {
    width: 100%;
    height: 100%;
    min-height: 158px;
    aspect-ratio: auto;
    margin: 0;
}

.article-list .article-card .body {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 6px;
}

.article-list .article-card .meta {
    margin: 0;
}

.article-list .article-card h2 {
    font-size: 1.25rem;
    margin: 0;
}

.article-list .article-card .summary {
    margin: 4px 0 0;
}


/* ----------------------------------------------------------------------------
 * 5. Article detail page
 * -------------------------------------------------------------------------- */

article.content {
    max-width: 760px;
    margin: 0 auto;
}

article.content .breadcrumb {
    color: #64748b;
    font-size: 14px;
    margin: 0 0 12px;
}

article.content .breadcrumb a {
    color: #475569;
}

article.content .article-cover {
    margin: 0 0 28px;
    border-radius: 18px;
    overflow: hidden;
    background: #f1f5f9;
}

article.content .article-cover img {
    width: 100%;
    aspect-ratio: 16 / 9;
    object-fit: cover;
    display: block;
}

article.content h1 {
    margin: 0 0 14px;
}

article.content .byline {
    color: #64748b;
    font-size: 14px;
    margin: 0 0 28px;
}

article.content .byline a {
    color: #334155;
    font-weight: 500;
}

article.content .tip {
    border-left: 4px solid #2563eb;
    background: #eff6ff;
    padding: 14px 16px;
    border-radius: 10px;
    color: #1e3a8a;
    margin: 0 0 28px;
}

article.content .article-body {
    font-size: 1.05rem;
    line-height: 1.75;
    color: #1e293b;
}

article.content .article-body img {
    max-width: 100%;
    height: auto;
    border-radius: 12px;
    margin: 8px 0;
}

article.content .article-body h2,
article.content .article-body h3 {
    margin-top: 1.6em;
}

article.content .article-body pre {
    background: #0f172a;
    color: #e2e8f0;
    padding: 16px 18px;
    border-radius: 12px;
    overflow-x: auto;
    font-size: 0.9rem;
    line-height: 1.55;
}

article.content .article-body code {
    background: #f1f5f9;
    padding: 2px 6px;
    border-radius: 6px;
    font-size: 0.92em;
}

article.content .article-body pre code {
    background: transparent;
    padding: 0;
}

article.content .article-body blockquote {
    margin: 1.4em 0;
    padding: 6px 18px;
    border-left: 3px solid #cbd5e1;
    color: #475569;
}


/* ----------------------------------------------------------------------------
 * 6. Search box (header + dedicated /search page)
 * -------------------------------------------------------------------------- */

.search-form {
    display: inline-flex;
    align-items: center;
    gap: 0;
    border: 1px solid #e5e7eb;
    border-radius: 999px;
    padding: 0;
    background: #ffffff;
    overflow: hidden;
    transition: border-color 160ms ease, box-shadow 160ms ease;
}

.search-form:focus-within {
    border-color: #2563eb;
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12);
}

.search-form input[type="search"],
.search-form input[type="text"] {
    appearance: none;
    border: 0;
    background: transparent;
    padding: 8px 14px;
    min-width: 0;
    width: 220px;
    color: #0f172a;
    outline: none;
}

.search-form button {
    appearance: none;
    border: 0;
    background: #0f172a;
    color: #ffffff;
    padding: 8px 14px;
    font-size: 13px;
    font-weight: 600;
}

.search-form button:hover,
.search-form button:focus-visible {
    background: #1e293b;
}

.search-page-form {
    display: flex;
    gap: 8px;
    margin: 0 0 28px;
}

.search-page-form input {
    flex: 1 1 auto;
    appearance: none;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 10px 14px;
    background: #ffffff;
}

.search-page-form input:focus-visible {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12);
}

.search-page-form button {
    appearance: none;
    border: 0;
    border-radius: 10px;
    background: #0f172a;
    color: #ffffff;
    padding: 10px 18px;
    font-weight: 600;
}


/* ----------------------------------------------------------------------------
 * 7. Author profile
 * -------------------------------------------------------------------------- */

.author-profile {
    display: grid;
    grid-template-columns: 128px 1fr;
    gap: 24px;
    align-items: center;
    padding: 24px;
    background: #f8fafc;
    border: 1px solid #e5e7eb;
    border-radius: 18px;
    margin: 0 0 32px;
}

.author-profile img.avatar {
    width: 128px;
    height: 128px;
    border-radius: 50%;
    object-fit: cover;
    background: #e2e8f0;
}

.author-profile h1 {
    margin: 0 0 4px;
}

.author-profile .role {
    color: #64748b;
    font-size: 14px;
    margin: 0 0 12px;
}

.author-profile .bio {
    margin: 0;
}


/* ----------------------------------------------------------------------------
 * 8. Compliance pages
 * -------------------------------------------------------------------------- */

article.compliance {
    max-width: 760px;
    margin: 0 auto;
}

article.compliance h1 {
    margin: 0 0 24px;
}

article.compliance h2 {
    margin-top: 1.6em;
}


/* ----------------------------------------------------------------------------
 * 9. 404 page
 * -------------------------------------------------------------------------- */

.not-found {
    max-width: 560px;
    margin: 60px auto;
    text-align: center;
}

.not-found h1 {
    font-size: 3rem;
    margin: 0 0 8px;
}

.not-found p {
    color: #64748b;
}

.not-found a {
    display: inline-block;
    margin-top: 16px;
    padding: 10px 18px;
    background: #0f172a;
    color: #ffffff;
    border-radius: 10px;
}

.not-found a:hover,
.not-found a:focus-visible {
    background: #1e293b;
    text-decoration: none;
}


/* ----------------------------------------------------------------------------
 * 10. AdSense slots
 * -------------------------------------------------------------------------- */

.acup-ad-container {
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 150px auto;
    width: 100%;
    background: #fafafa;
    border: 1px solid #eaeaea;
    color: #64748b;
    border-radius: 12px;
    padding: 8px;
}

.acup-ad-container .meta {
    font-size: 12px;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-right: 12px;
}


/* ----------------------------------------------------------------------------
 * 11. Misc — search highlight, utility helpers
 * -------------------------------------------------------------------------- */

mark {
    background: #fef3c7;
    color: inherit;
    padding: 0 2px;
    border-radius: 3px;
}

.empty-state {
    color: #64748b;
    padding: 32px;
    text-align: center;
    background: #f8fafc;
    border: 1px dashed #cbd5e1;
    border-radius: 14px;
}


/* ----------------------------------------------------------------------------
 * 12. Responsive breakpoints
 * -------------------------------------------------------------------------- */

@media (max-width: 860px) {
    header.site-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
        position: static;
    }

    header.site-header nav {
        width: 100%;
        overflow-x: auto;
        flex-wrap: nowrap;
    }

    header.site-header nav a {
        white-space: nowrap;
    }

    .hero {
        grid-template-columns: 1fr;
        gap: 24px;
    }

    .sidebar {
        position: static;
        display: none; /* hide ads on mobile to honour PRD §5.1.1 mobile-first density */
    }

    main {
        padding: 20px 16px 40px;
    }

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

    .article-list .article-card {
        grid-template-columns: 120px minmax(0, 1fr);
        gap: 14px;
    }

    .article-list .article-card .cover {
        min-height: 120px;
    }

    .author-profile {
        grid-template-columns: 1fr;
        text-align: left;
    }

    .author-profile img.avatar {
        width: 96px;
        height: 96px;
    }

    footer.site-footer {
        flex-direction: column;
        align-items: flex-start;
    }
}