/*
Theme Name: 9to5Gemini
Author: Gemini CLI & かのあゆ
Description: A gadget blog theme inspired by 9to5Mac.
Version: 1.0
Requires at least: 5.0
Tested up to: 6.8.3
Requires PHP: 7.4
*/

/* ==========================================================================
   1. Custom Properties (CSS Variables)
   ========================================================================== */
:root {
    --primary-color: #007aff; /* Apple Blue */
    --secondary-color: #8e8e93; /* Light Gray for text */
    --text-color: #f2f2f7; /* Light text on dark background */
    --light-text-color: #aeaeb2; /* Lighter text for secondary info */
    --background-color: #1c1c1e; /* Dark background */
    --card-background: #2c2c2e; /* Slightly lighter dark for cards */
    --border-color: #3a3a3c; /* Darker border */
    --header-footer-bg: #000000; /* Pure black for header/footer */
    --header-footer-text: #ffffff; /* White text for header/footer */
    --link-hover-color: #32d74b; /* Green for hover, like 9to5Mac */
}

/* ==========================================================================
   2. Base Styles & Typography
   ========================================================================== */
*, *::before, *::after {
    box-sizing: border-box;
}

html {
    font-size: 16px;
    line-height: 1.5;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: "SF Pro Display", "SF Pro Text", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    color: var(--text-color);
    background-color: var(--background-color);
    margin: 0;
    padding: 0;
    display: grid;
    grid-template-areas:
        "header"
        "main-content"
        "footer";
    grid-template-columns: 1fr;
    min-height: 100vh;
}

a {
    color: var(--primary-color);
    text-decoration: none;
    transition: color 0.3s ease;
}

a:hover {
    color: #0056b3;
}

h1, h2, h3, h4, h5, h6 {
    margin-top: 0;
    margin-bottom: 0.5em;
    line-height: 1.2;
    color: var(--text-color);
}

p {
    margin-top: 0;
    margin-bottom: 1em;
}

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

/* ==========================================================================
   3. Layout Structure
   ========================================================================== */
.site-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    display: grid;
    grid-template-columns: 1fr; /* Default to single column */
    gap: 30px;
}

/* Main content area for 2-column layout */
.content-sidebar-wrap {
    display: grid;
    grid-template-columns: 3fr 1fr; /* Main 3, Sidebar 1 */
    grid-template-areas: "main sidebar"; /* エリアを明示的に定義 */
    gap: 30px;
}

@media (max-width: 767px) {
    .content-sidebar-wrap {
        grid-template-columns: 1fr; /* Mobile: single column */
    }
    #secondary {
        display: none; /* モバイルではサイドバーを非表示 */
    }
}

.content-area {
    grid-area: main;
    background-color: var(--card-background);
    padding: 25px;
    border-radius: 8px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.05);
}

#secondary {
    grid-area: sidebar;
    background-color: var(--card-background);
    padding: 25px;
    border-radius: 8px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.05);
}

/* Mobile Sidebar Styles */
@media (max-width: 767px) {
    #secondary {
        position: fixed;
        top: 0;
        right: -80%; /* 画面外に配置 */
        width: 80%;
        height: 100%;
        overflow-y: auto;
        z-index: 1000;
        transition: transform 0.3s ease-in-out;
        box-shadow: -2px 0 8px rgba(0,0,0,0.2);
        display: block; /* モバイルで非表示にした設定を上書き */
    }

    #secondary.active {
        transform: translateX(-100%); /* 画面内にスライドイン */
    }

    #sidebar-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background-color: rgba(0, 0, 0, 0.6);
        z-index: 999;
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.3s ease-in-out, visibility 0.3s ease-in-out;
    }

    #sidebar-overlay.active {
        opacity: 1;
        visibility: visible;
    }
}

#secondary img {
    max-width: 100%;
    height: auto;
}

#secondary .widget {
    word-break: break-word;
}

/* ==========================================================================
   4. Header
   ========================================================================== */
.site-header {
    grid-area: header;
    background-color: var(--header-footer-bg);
    color: var(--header-footer-text);
    padding: 15px 0;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    margin-bottom: 30px;
}

.site-header .site-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px; /* Override site-container padding for header */
    position: relative; /* For absolute positioning of search form */
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 15px;
}

.header-actions button {
    background: none;
    border: none;
    color: var(--header-footer-text);
    cursor: pointer;
    padding: 0;
    font-size: 1.2em; /* Adjust icon size */
}

.header-actions button:hover {
    color: var(--primary-color);
}

.header-actions .icon {
    width: 24px; /* SVG icon size */
    height: 24px;
    vertical-align: middle;
}

.screen-reader-text {
    clip: rect(1px, 1px, 1px, 1px);
    position: absolute !important;
    height: 1px;
    width: 1px;
    overflow: hidden;
    word-wrap: normal !important;
}

/* Search form styling */
.header-search-form {
    position: absolute;
    top: 100%; /* Position below header */
    left: 0;
    width: 100%;
    background-color: var(--header-footer-bg);
    padding: 15px 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    display: none; /* Hidden by default, will be toggled by JS */
    z-index: 100;
}

.header-search-form .search-form {
    display: flex;
    justify-content: center;
    align-items: center;
}

.header-search-form .search-field {
    flex-grow: 1;
    padding: 10px 15px;
    border: 1px solid var(--border-color);
    border-radius: 5px;
    background-color: var(--card-background);
    color: var(--text-color);
    font-size: 1em;
}

.header-search-form .search-submit {
    background-color: var(--primary-color);
    color: var(--header-footer-text);
    border: none;
    padding: 10px 20px;
    border-radius: 5px;
    margin-left: 10px;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

.header-search-form .search-submit:hover {
    background-color: var(--link-hover-color);
}

.site-branding h1 {
    margin: 0;
    font-size: 2.2em;
}

.site-branding a {
    color: var(--header-footer-text);
    text-decoration: none;
}

/* Main navigation */
.main-navigation {
    /* Default to hidden on mobile, shown on desktop */
    display: none;
}

.main-navigation ul {
    margin: 0;
    padding: 0;
    list-style: none;
}

.main-navigation li {
    display: block; /* Stack vertically on mobile */
    margin: 0;
}

.main-navigation a {
    color: var(--header-footer-text);
    text-decoration: none;
    font-weight: 600;
    padding: 10px 20px;
    display: block;
    position: relative;
}

.main-navigation a::after {
    content: '';
    position: absolute;
    left: 0;
    bottom: 0;
    width: 0;
    height: 2px;
    background-color: var(--primary-color);
    transition: width 0.3s ease;
}

.main-navigation a:hover::after {
    width: 100%;
}

/* Desktop styles for navigation */
@media (min-width: 768px) {
    .main-navigation {
        display: block !important; /* Always show on desktop */
    }

    .main-navigation ul {
        display: flex;
    }

    .main-navigation li {
        margin-left: 25px;
        display: inline-block;
    }

    .main-navigation a {
        padding: 5px 0;
    }

    .menu-toggle {
        display: none; /* Hide hamburger menu on desktop */
    }
}

/* Mobile specific styles */
@media (max-width: 767px) {
    .site-header .site-container {
        flex-wrap: wrap; /* Allow items to wrap */
        justify-content: center;
    }

    .site-branding {
        width: 100%;
        text-align: center;
        margin-bottom: 15px;
    }

    .header-actions {
        width: 100%;
        justify-content: center;
        margin-bottom: 15px;
    }

    .main-navigation {
        width: 100%;
        background-color: var(--header-footer-bg);
        position: absolute;
        top: 100%;
        left: 0;
        box-shadow: 0 2px 8px rgba(0,0,0,0.1);
        z-index: 99;
        /* display: none; will be toggled by JS */
    }

    .main-navigation.toggled {
        display: block; /* Show when toggled */
    }

    .main-navigation ul {
        flex-direction: column;
        text-align: center;
    }

    .main-navigation li {
        border-bottom: 1px solid var(--border-color);
    }

    .main-navigation li:last-child {
        border-bottom: none;
    }

    .search-toggle {
        display: block; /* Show search toggle on mobile */
    }
}

/* ==========================================================================
   5. Post Grids & Cards
   ========================================================================== */
.posts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); /* PC: 300px以上の幅で自動調整 */
    gap: 30px;
    margin-top: 30px;
}

.posts-grid article {
    background-color: var(--card-background);
    border-radius: 8px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.05);
    overflow: hidden; /* 角丸からはみ出さないように */
    display: flex;
    flex-direction: column;
    transition: transform 0.2s ease-in-out;
}

.posts-grid article:hover {
    transform: translateY(-5px);
}

.posts-grid article .post-thumbnail {
    width: 100%;
    height: 200px; /* アイキャッチ画像の高さを固定 */
    overflow: hidden;
}

.posts-grid article .post-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover; /* 画像がはみ出さないように調整 */
}

.posts-grid article .entry-header,
.posts-grid article .entry-content,
.posts-grid article .entry-footer {
    padding: 15px;
}

.posts-grid article .entry-header h2.entry-title {
    font-size: 1.3em;
    margin-bottom: 10px;
}

.posts-grid article .entry-header h2.entry-title a {
    color: var(--text-color);
}

.posts-grid article .entry-content {
    flex-grow: 1; /* 抜粋がカードの下部に揃うように */
    font-size: 0.9em;
    color: var(--light-text-color);
}

.posts-grid article .entry-footer {
    font-size: 0.8em;
    color: var(--light-text-color);
    border-top: 1px solid var(--border-color);
    margin-top: auto; /* フッターをカードの下部に固定 */
}

/* Mobile specific styles for posts-grid */
@media (max-width: 767px) {
    .posts-grid {
        grid-template-columns: 1fr; /* スマホでは1カラム */
        gap: 20px; /* スマホでのカード間の余白 */
    }

    .posts-grid article .entry-header h2.entry-title {
        font-size: 1.2em; /* スマホでのタイトルサイズ調整 */
    }

    .posts-grid article .entry-content {
        font-size: 0.85em; /* スマホでの抜粋サイズ調整 */
    }
}

/* ==========================================================================
   10. Mobile Bottom Bar
   ========================================================================== */
.mobile-bottom-bar {
    display: none; /* Hidden by default, shown on mobile */
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background-color: var(--header-footer-bg);
    color: var(--header-footer-text);
    box-shadow: 0 -2px 8px rgba(0,0,0,0.1);
    z-index: 999;
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: 5px 0;
}

.mobile-bottom-bar .bottom-bar-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-decoration: none;
    color: var(--header-footer-text);
    font-size: 0.7em;
    padding: 5px;
    flex-grow: 1;
    transition: color 0.3s ease;
}

.mobile-bottom-bar .bottom-bar-item:hover {
    color: var(--primary-color);
}

.mobile-bottom-bar .bottom-bar-item .icon {
    width: 22px;
    height: 22px;
    margin-bottom: 3px;
    fill: currentColor; /* SVGの色を親要素のcolorに合わせる */
    display: block; /* SVGをブロック要素として扱う */
}

/* Adjust body padding for fixed bottom bar on mobile */
@media (max-width: 767px) {
    body {
        padding-bottom: 60px; /* Height of the bottom bar */
    }

    .mobile-bottom-bar {
        display: flex; /* Show on mobile */
    }
}

@media (min-width: 768px) {
    .mobile-bottom-bar {
        display: none; /* Hide on desktop */
    }
}

/* ==========================================================================
   11. Link Card (oEmbed) Styles
   ========================================================================== */
.wp-block-embed {
    background-color: #333; /* 周囲より少し明るい色 */
    border: 1px solid #444;
    border-radius: 12px; /* 少し大きめの角丸 */
    padding: 20px;
    margin: 2em 0;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
    transition: transform 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
}

.wp-block-embed:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 15px rgba(0,0,0,0.25);
}

.wp-block-embed a {
    text-decoration: none;
}

/* 埋め込みコンテンツのラッパー */
.wp-block-embed__wrapper {
    background: transparent; /* ラッパーの背景は透明に */
}

/* 埋め込みプロバイダーのサイト名 */
.wp-block-embed__site-name {
    font-size: 0.8em;
    color: var(--light-text-color);
    margin-bottom: 8px;
    text-transform: uppercase;
}

/* 埋め込みコンテンツのタイトル (存在する場合) */
.wp-block-embed .wp-embedded-content__title {
    font-size: 1.2em;
    font-weight: 600;
    color: var(--text-color);
    margin-bottom: 8px;
}

/* 埋め込みコンテンツの抜粋 (存在する場合) */
.wp-block-embed .wp-embedded-content__excerpt {
    color: var(--light-text-color);
    font-size: 0.9em;
}

/* YouTubeなどの動画埋め込みのアスペクト比を保持 */
.wp-block-embed.is-type-video iframe {
    border-radius: 8px; /* 動画自体にも角丸を適用 */
}

/* ==========================================================================
   12. Header Search Form Active State
   ========================================================================== */
.header-search-form.active {
    display: block;
}

/* ==========================================================================
   12. Header Search Form Active State
   ========================================================================== */
.header-search-form.active {
    display: block;
}
