/* ========================================
   HomeKit Directory — Vanilla CSS
   ======================================== */

/* --- Reset & Base --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1.5;
    color: #1e293b;
    background: #F5F5F5;
}

img { max-width: 100%; height: auto; display: block; }
a { color: inherit; text-decoration: none; }
ul, ol { list-style: none; }
button { cursor: pointer; }
h1, h2, h3, h4, h5, h6 { font-size: inherit; font-weight: inherit; }

/* --- Screen-reader only --- */
.sr-only {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}
.sr-only:focus {
    position: absolute; width: auto; height: auto; padding: 0.5rem 1rem;
    margin: 0; overflow: visible; clip: auto; white-space: normal;
    top: 0.5rem; left: 0.5rem; z-index: 50;
    background: #fff; border-radius: 0.25rem; box-shadow: 0 1px 3px rgba(0,0,0,.2);
}

/* --- Container --- */
.container { max-width: 1280px; margin-left: auto; margin-right: auto; }

/* --- Header --- */
.site-header { padding: 0 1rem; }
.header-inner {
    max-width: 1280px; margin: 0 auto;
    display: flex; align-items: center; justify-content: space-between;
    padding: 1.5rem 0; gap: 1rem;
}
.site-logo { font-weight: 600; font-size: 1.5rem; display: block; }
.site-logo img { height: 2rem; }

/* Desktop nav */
.nav-desktop { display: none; }
.nav-desktop ul { display: flex; gap: 1rem; }

/* Mobile menu button */
.mobile-menu-btn { padding: 0.5rem; background: none; border: none; }

/* Mobile menu */
#mobile-menu { display: none; max-width: 1280px; margin: 0 auto; padding-bottom: 1rem; }
#mobile-menu.open { display: block; }
#mobile-menu ul { display: flex; flex-direction: column; gap: 0.75rem; text-align: center; }
#mobile-search { margin-top: 1rem; }

/* Search bar */
.search-bar { max-width: 1280px; margin: 0 auto; padding: 0.5rem 1rem; }

/* Breadcrumb bar */
.breadcrumb-bar { display: flex; padding: 0.75rem 0; }
.breadcrumb-bar-inner {
    max-width: 1280px; margin: 0 auto; width: 100%;
    display: flex; justify-content: center; font-size: 0.75rem;
}

/* Current page indicator */
[aria-current="page"] { color: #3b82f6; font-weight: 600; }

/* --- Breadcrumbs --- */
.breadcrumbs {
    box-shadow: 0 2px 15px 0 rgba(69,69,69,.1) inset;
    background: #F7F7F7;
    display: flex; align-items: center;
    padding: 0.5rem 1rem; border-radius: 9999px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.breadcrumbs li { display: inline; }
.breadcrumbs li:not(:last-child)::after {
    content: "/"; margin: 0 0.5rem; color: #6b7280;
}

/* --- Glass Card --- */
.glass-card {
    border-radius: 20px;
    background: rgba(255,255,255,.1);
    box-shadow: 0 10px 20px 2px rgba(0,0,0,.05);
    transition: all 0.2s;
}
.glass-card:hover {
    transform: translate(4px, 4px);
    box-shadow: 0 2px 4px rgba(0,0,0,.05);
}

/* --- Buttons --- */
.btn {
    display: inline-block;
    border: 2px solid #000; padding: 0.25rem 1rem;
    border-radius: 9999px; transition: all 0.2s;
    font-size: inherit; background: transparent;
}
.btn:hover { transform: translateY(4px); box-shadow: none; }
.btn-alt { background: #e5e5e5; color: #171717; }
.btn-white { background: #fff; color: #000; }

/* --- Badges --- */
.badge-purple {
    font-size: 0.75rem; padding: 0.125rem 0.25rem;
    border-radius: 0.125rem; background: #f3e8ff; color: #6d28d9;
    display: inline-block;
}
.badge-amber {
    font-size: 0.75rem; padding: 0.125rem 0.25rem;
    border-radius: 0.125rem; background: #fef3c7; color: #b45309;
    display: inline-block;
}

/* --- Ads --- */
.ads { background: #e5e5e5; }
.ads-banner { margin-top: 1rem; }
.ads-inline { margin: 1rem 0; }

/* --- Grid System --- */
.grid-1-2-3 { display: grid; grid-template-columns: 1fr; gap: 0.75rem; }
.grid-2-2-4 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.75rem; }
.grid-2-3 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1.5rem; }
.grid-content { display: grid; grid-template-columns: 1fr; gap: 1.5rem; }

/* Type card (icon + text) */
.type-card {
    display: grid; grid-template-columns: 1fr 4fr;
    align-items: center; overflow: hidden;
}
.type-card img { width: 100%; margin: 0.5rem; }
.type-card-body { padding: 0.25rem 2rem; }
.type-card-body h2 { font-weight: 600; line-height: 1.25; }
.type-card-body p { color: #4b5563; font-size: 0.75em; }

/* Type listing card (with image) */
.type-list-card {
    display: grid; grid-template-columns: 1fr 3fr;
    align-items: center; overflow: hidden;
}
.type-list-card img { width: 100%; }
.type-list-card-body { padding: 0.25rem 2rem; }
.type-list-card-body h2 { font-weight: 600; line-height: 1.25; }
.type-list-card-body p { color: #4b5563; font-size: 0.75em; }

/* Brand card */
.brand-card {
    display: flex; align-items: center; justify-content: space-between;
    padding: 0.5rem;
}
.brand-card h2 { font-size: 0.875rem; font-weight: 600; }
.brand-card-count {
    color: #4b5563; font-size: 0.65em;
    display: flex; align-items: center;
}
.count-circle {
    border-radius: 9999px; background: #e5e7eb;
    width: 1.5rem; height: 1.5rem;
    display: flex; align-items: center; justify-content: center;
    margin-right: 0.5rem;
}

/* Product card */
.product-card { padding: 1.5rem; display: block; }

/* --- Content/sidebar layout --- */
.content-with-sidebar { display: grid; grid-template-columns: 1fr; gap: 1.5rem; }
.main-content { display: flex; flex-direction: column; gap: 0.5rem; }
.sidebar { display: flex; flex-direction: column; gap: 1.5rem; }
.sidebar-section { display: flex; flex-direction: column; gap: 0.75rem; }
.sidebar-list { display: flex; flex-direction: column; gap: 1rem; }
.sidebar-list a { display: flex; justify-content: space-between; align-items: center; }
.sidebar-list h2 { font-weight: 600; }

/* --- Page sections --- */
.page-section { max-width: 1280px; margin: 0 auto; padding: 2rem 1rem; }

/* --- Hero / headings --- */
.hero-center { text-align: center; display: flex; flex-direction: column; gap: 2rem; }
.page-title {
    text-wrap: balance; font-size: 1.5rem; font-weight: 600;
    letter-spacing: -0.025em; color: #111827;
}
.page-title-lg {
    text-wrap: balance; font-size: 2.25rem; font-weight: 600;
    letter-spacing: -0.025em; color: #111827;
}
.section-title {
    text-wrap: balance; font-weight: 600;
    letter-spacing: -0.025em; color: #111827; font-size: 1.5rem;
}
.subtitle { text-wrap: pretty; color: #6b7280; font-size: 0.875rem; }
.subtitle-lg { text-wrap: balance; font-weight: 500; color: #6b7280; }

/* --- Term header (type term page) --- */
.term-header { background: #fff; display: grid; grid-template-columns: 1fr; margin-bottom: 2rem; }
.term-header-body {
    padding: 1.5rem; display: flex; flex-direction: column;
    justify-content: center; gap: 1rem; order: 2;
}
.term-header-body h1 {
    text-wrap: balance; font-size: 2.25rem; font-weight: 600;
    letter-spacing: -0.025em; color: #111827;
}
.term-header-body .term-desc { text-wrap: pretty; font-weight: 500; color: #6b7280; }
.term-header img { width: 100%; order: 1; }

/* --- Brand term header --- */
.brand-term-header {
    max-width: 1280px; margin: 0 auto; padding: 2rem 1rem;
    text-align: center; display: flex; flex-direction: column; gap: 2rem;
}
.brand-term-header h1 {
    text-wrap: balance; font-size: 2.5rem; font-weight: 600;
    letter-spacing: -0.025em; color: #111827;
}
.brand-term-links { display: flex; justify-content: center; gap: 0.5rem; }

/* --- Product single --- */
.product-hero { background: #fff; }
.product-hero-inner {
    max-width: 1280px; margin: 0 auto; padding: 1rem;
    display: flex; flex-direction: column; gap: 2rem;
}
.product-hero-inner h1 {
    text-wrap: balance; font-size: 2.25rem; font-weight: 600;
    letter-spacing: -0.025em; color: #111827; text-align: center;
}
.product-date { font-size: 0.875rem; color: #6b7280; }
.product-links { display: flex; justify-content: center; gap: 0.5rem; }
.product-content { background: #f5f5f5; padding: 2rem 0; }
.product-content-inner { max-width: 1280px; margin: 0 auto; padding: 1rem; }

/* Article single */
.article-hero { background: #fff; }
.article-hero-inner {
    max-width: 1280px; margin: 0 auto; padding: 1rem;
    display: flex; flex-direction: column; gap: 2rem; text-align: center;
}
.article-hero-inner h1 {
    text-wrap: balance; font-size: 2.25rem; font-weight: 600;
    letter-spacing: -0.025em; color: #111827;
}
.article-content { background: #f5f5f5; padding: 2rem 0; }
.article-content-inner { max-width: 1280px; margin: 0 auto; padding: 1rem; }
.article-image { width: 100%; border-radius: 0.5rem; }

/* Related products */
.related-section { max-width: 1280px; margin: 0 auto; padding: 2rem 1rem; }
.related-section h2 {
    font-size: 1.5rem; font-weight: 600; letter-spacing: -0.025em;
    color: #111827; margin-bottom: 1rem;
}

/* --- Product count text --- */
.product-count { font-size: 0.875rem; color: #6b7280; padding-bottom: 1rem; }

/* --- Footer --- */
.footer-cards { max-width: 1280px; margin: 0 auto; padding: 2rem 1rem; }
.footer-cards-grid { display: grid; grid-template-columns: 1fr; gap: 1.5rem; }
.footer-card {
    padding: 1rem; display: flex; flex-direction: column; gap: 0.75rem;
}
.footer-card h2 { font-weight: 600; letter-spacing: -0.025em; color: #111827; font-size: 1.5rem; }
.footer-card p { text-wrap: pretty; color: #6b7280; font-size: 0.875rem; }

.footer-bottom { background: #E7E5E4; }
.footer-bottom-inner {
    max-width: 1280px; margin: 0 auto; padding: 0 1rem;
    display: flex; flex-direction: column; align-items: center; gap: 1.5rem;
}
.footer-logo img { height: 1.5rem; }
.footer-nav ul { display: flex; gap: 1rem; font-size: 0.75rem; }
.footer-disclaimer {
    border-top: 1px solid #d1d5db; padding: 1rem 0;
    font-size: 0.75rem; color: #6b7280; line-height: 1.625;
}

/* --- Pagination --- */
.pagination { display: flex; justify-content: center; gap: 0.5rem; padding: 2rem 0; }
.pagination a, .pagination span {
    padding: 0.5rem 0.75rem; border-radius: 0.25rem; font-size: 0.875rem;
}
.pagination a { background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.1); }
.pagination a:hover { background: #f9fafb; }
.pagination-active { background: #3b82f6 !important; color: #fff !important; }

/* --- 404 --- */
.page-404 {
    max-width: 1280px; margin: 0 auto; padding: 4rem 1rem;
    text-align: center; display: flex; flex-direction: column; gap: 2rem;
}
.page-404 h1 {
    font-size: 2.25rem; font-weight: 600; letter-spacing: -0.025em; color: #111827;
}
.page-404 p { font-size: 1.125rem; color: #6b7280; }
.page-404-links { display: flex; justify-content: center; gap: 1rem; }

/* --- Back to top button --- */
.back-to-top {
    position: fixed; bottom: 1.5rem; right: 1.5rem;
    background: #fff; box-shadow: 0 4px 6px rgba(0,0,0,.1);
    border-radius: 9999px; width: 2.5rem; height: 2.5rem;
    display: flex; align-items: center; justify-content: center;
    color: #4b5563; border: none;
    transition: opacity 0.2s; opacity: 0; pointer-events: none; z-index: 50;
}
.back-to-top:hover { color: #111827; }

/* --- Article list card --- */
.article-card { overflow: hidden; }
.article-card img { width: 100%; }
.article-card-body { padding: 1rem; font-size: 0.875rem; }

/* --- Content typography --- */
.content { display: flex; flex-direction: column; gap: 1rem; }
.content h1 {
    text-wrap: balance; font-size: 1.875rem; font-weight: 600;
    letter-spacing: -0.025em; color: #111827; text-align: center;
}
.content h2 {
    text-wrap: balance; font-size: 1.25rem; font-weight: 500;
    letter-spacing: -0.025em; color: #111827;
}
.content h3 {
    text-wrap: balance; font-size: 1.125rem; font-weight: 500;
    letter-spacing: -0.025em; color: #111827;
}
.content ul { list-style: disc; margin-left: 1.5rem; }
.content ol { list-style: decimal; margin-left: 1.5rem; }
.content li { margin-bottom: 0.5rem; }
.content hr { border: none; border-top: 4px solid #e5e5e5; margin: 2rem 0; }
.content a {
    text-decoration: underline; text-decoration-thickness: 2px;
    background: #f3e8ff; color: #1a0533;
    text-decoration-color: #d8b4fe;
}
.content a:hover { text-decoration-color: #a855f7; }
.content table {
    width: 100%; text-align: left; font-size: 0.875rem;
    border: 1px solid #e5e7eb; border-collapse: collapse;
}
.content thead {
    background: #f3f4f6; font-size: 0.75rem;
    text-transform: uppercase; color: #374151;
}
.content th { padding: 0.75rem 1rem; border-bottom: 1px solid #e5e7eb; }
.content tbody tr { border-bottom: 1px solid #e5e7eb; }
.content td { padding: 0.75rem 1rem; }

/* Taxonomy content area */
.taxonomy-content { max-width: 640px; margin: 0 auto; padding: 2rem 1rem; }

/* Self-start utility */
.self-start { align-self: flex-start; }

/* Section title block (used in home page, etc.) */
.section-header { text-align: center; max-width: 1280px; margin: 0 auto; padding: 2rem 1rem; }

/* Brand listing page grid wrapper */
.brand-list-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.75rem; }

/* Simple page title */
.listing-title {
    font-size: 2.25rem; font-weight: 700; margin-bottom: 2rem;
}

/* ========================================
   Responsive — sm (640px)
   ======================================== */
@media (min-width: 640px) {
    .page-title { font-size: 4.5rem; }
    .product-hero-inner h1 { font-size: 3.75rem; }
    .article-hero-inner h1 { font-size: 3.75rem; }
    .page-404 h1 { font-size: 3.75rem; }
    .content h1 { font-size: 4.5rem; }
    .content h2 { font-size: 1.875rem; }
    .content h3 { font-size: 1.5rem; }
    .brand-term-header h1 { font-size: 4.5rem; }
    .subtitle-lg { font-size: 1.25rem; line-height: 2rem; }
}

/* ========================================
   Responsive — md (768px)
   ======================================== */
@media (min-width: 768px) {
    .site-header { padding: 0; }
    .search-bar { padding: 0.5rem 0; }
    .breadcrumb-bar-inner { justify-content: flex-start; font-size: 0.875rem; }
    .breadcrumbs { padding: 0.5rem 1.5rem; }

    .grid-1-2-3 { grid-template-columns: repeat(2, 1fr); gap: 2.5rem; }
    .grid-2-2-4 { gap: 1rem; }
    .grid-2-3 { gap: 1.5rem; }

    .brand-card { padding: 0.75rem 1.5rem; }
    .brand-card h2 { font-size: 1.125rem; }
    .brand-card-count { font-size: 0.75em; }

    .term-header-body { padding: 3rem; }
    .term-header-body h1 { font-size: 3.75rem; }
    .term-header-body .term-desc { font-size: 1.125rem; }

    .page-section { padding: 2rem 0; }
    .product-hero-inner { padding: 1rem 0; }
    .product-content-inner { padding: 1rem 0; }
    .article-content-inner { padding: 1rem 0; }
    .related-section { padding: 2rem 0; }

    .footer-bottom-inner { gap: 3rem; }
    .footer-logo img { height: 2rem; }
    .footer-nav ul { font-size: 0.875rem; }
    .article-card-body { font-size: 1rem; }

    .brand-list-grid { grid-template-columns: repeat(2, 1fr); gap: 1rem; }
}

/* ========================================
   Responsive — lg (1024px)
   ======================================== */
@media (min-width: 1024px) {
    /* Header nav */
    .nav-desktop { display: block; }
    .mobile-menu-btn { display: none; }
    #mobile-menu { display: none !important; }

    /* Grids */
    .grid-1-2-3 { grid-template-columns: repeat(3, 1fr); }
    .grid-2-2-4 { grid-template-columns: repeat(4, 1fr); }
    .grid-2-3 { grid-template-columns: repeat(3, 1fr); }
    .grid-content { grid-template-columns: 3fr 1fr; gap: 6rem; }
    .content-with-sidebar { grid-template-columns: 9fr 3fr; gap: 6rem; }

    /* Term header side-by-side */
    .term-header { grid-template-columns: 2fr 1fr; }
    .term-header-body { order: 1; }
    .term-header img { order: 2; }

    /* Sections */
    .page-section { padding: 4rem 0; }
    .brand-term-header { padding: 4rem 8rem; }
    .product-hero-inner { padding: 4rem 8rem; }
    .article-hero-inner { padding: 4rem 8rem; }

    /* Footer */
    .footer-cards { padding: 5rem 0; }
    .footer-cards-grid { grid-template-columns: repeat(2, 1fr); gap: 5rem; }
    .footer-card { padding: 2rem; }

    /* Taxonomy content */
    .taxonomy-content { padding: 4rem 1rem; }

    /* Ads banner */
    .ads-banner { margin-top: 5rem; }

    /* Brand list */
    .brand-list-grid { grid-template-columns: repeat(4, 1fr); }
}
