/*
Theme Name: SGMRスタンダードテーマ
Theme URI: https://example.com/sgmr-standard
Author: SGMR factory
Author URI: https://example.com
Description: SGMR Official Block Theme.
Version: 0.0.4
Requires at least: 6.0
Tested up to: 6.9.1
Requires PHP: 8.0
*/

/* --- Base Variables & Reset --- */
:root {
    /* Light Mode: Black, White & Gray */
    --bg-body: #ffffff;
    --text-main: #333333;
    --text-sub: #666666;
    --text-head: #000000;
    --link-color: #000000;
    
    /* Header Colors */
    --header-bg-top: #000000;
    --header-text-top: #ffffff;
    --header-bg-bottom: rgba(255, 255, 255, 0.95);
    --header-text-bottom: #000000;
    --nav-link: #333333;
    --nav-link-hover: #000000;
    
    /* News Bar Colors */
    --news-bg: #000000;
    --news-text: #ffffff;
    --news-border: rgba(255, 255, 255, 0.2);
    
    --card-bg: #ffffff;
    --card-border: transparent;
    --card-shadow: 0 4px 20px -2px rgba(0, 0, 0, 0.05), 0 2px 6px -2px rgba(0, 0, 0, 0.05);
    
    --card-hover-border: transparent;
    --card-hover-bg: #ffffff;
    --card-hover-shadow: 0 20px 30px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -5px rgba(0, 0, 0, 0.05);

    /* Footer Colors */
    --footer-bg: #000000;
    --footer-text: #ffffff;
    --footer-border: #333333;
    
    --icon-bg-def: #f5f5f5;
    --icon-color-def: #000000;

    /* Material 3 Expressive Additions */
    --m3-radius-m: 12px;
    --m3-radius-l: 16px;
    --m3-radius-xl: 24px;
    --m3-surface-gap: 24px;
}

/* --- Dark Mode Dynamic Override --- */
:root[data-theme="dark"],
body[data-theme="dark"],
body.is-dark {
    --wp--preset--color--base: #000000 !important;
    --wp--preset--color--main: #e5e5e5 !important;
    --wp--preset--color--sub: #999999 !important;
    --wp--preset--color--head: #ffffff !important;
    --wp--preset--color--accent: #ffffff !important;
    --wp--preset--color--card-bg: #111111 !important;
    --wp--preset--color--card-border: rgba(255, 255, 255, 0.1) !important;
    --wp--preset--color--white: #ffffff !important;
    
    --bg-body: #000000;
    --text-main: #e5e5e5;
    --text-sub: #999999;
    --text-head: #ffffff;
    --link-color: #ffffff;
    
    /* Header Colors (Dark Mode) */
    --header-bg-top: #111111;
    --header-text-top: #ffffff;
    --header-bg-bottom: rgba(17, 17, 17, 0.95);
    --header-text-bottom: #ffffff;
    --nav-link: #cccccc;
    --nav-link-hover: #ffffff;

    /* News Bar Colors (Dark Mode) */
    --news-bg: #1a1a1a;
    --news-text: #ffffff;
    --news-border: rgba(255, 255, 255, 0.1);

    --card-bg: #111111;
    --card-border: rgba(255, 255, 255, 0.1);
    
    /* Footer Colors (Dark Mode) */
    --footer-bg: #0a0a0a;
    --footer-text: #999999;
    --footer-border: #333333;
    
    --icon-bg-def: rgba(255, 255, 255, 0.1);
    --icon-color-def: #ffffff;
}

/* --- Base & Reset --- */
body {
    background-color: var(--bg-body) !important;
    background-image: radial-gradient(rgba(0,0,0,0.05) 1px, transparent 1px);
    background-size: 24px 24px;
    background-attachment: fixed;
    color: var(--text-main) !important;
    transition: background-color 0.3s, color 0.3s;
    
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

body.is-dark {
    background-image: none;
}

a { text-decoration: none; transition: color 0.2s; color: inherit; }
img { max-width: 100%; height: auto; }

/* Main Content Wrapper */
.d-main-content {
    flex: 1;
    width: 100%;
    margin-top: 140px; 
    padding-bottom: 60px;
}

.d-container {
    width: 100%; max-width: 1200px;
    margin: 0 auto; padding: 0 24px;
    box-sizing: border-box;
}

/* --- Content Surface --- */
.d-content-surface {
    background-color: var(--card-bg);
    border-radius: var(--m3-radius-xl);
    padding: 48px;
    box-shadow: var(--card-shadow);
    max-width: 960px; margin: 0 auto;
    color: var(--text-main);
}

/* --- Hero Header --- */
.d-hero-header { margin-bottom: 40px; text-align: center; }
.d-hero-header .wp-block-post-title { font-size: clamp(2rem, 5vw, 3rem); font-weight: 800; color: var(--text-head); }
.d-hero-header .wp-block-post-featured-image img { width: 100%; height: auto; max-height: 480px; object-fit: cover; border-radius: var(--m3-radius-xl); box-shadow: var(--card-shadow); }

/* --- Header --- */
.d-header {
    position: fixed !important; top: 0; left: 0; width: 100%; z-index: 9999;
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1);
    display: flex; flex-direction: column;
    gap: 0 !important;
}

/* Admin Bar Fix */
body.admin-bar .d-header { top: 32px; }
@media (max-width: 782px) { body.admin-bar .d-header { top: 46px; } }

.d-header-top {
    background: var(--header-bg-top); 
    height: 90px;
    display: flex; align-items: center;
    padding: 0;
    margin: 0 !important;
    border-bottom: none;
    box-sizing: border-box;
    transition: background 0.3s;
}

.d-header-top-inner { display: flex; justify-content: space-between; align-items: center; width: 100%; }
.d-header-logo-area { display: flex; align-items: center; gap: 16px; }
.d-header-logo-text h1 { margin: 0; line-height: 1; }
.d-header-logo-text h1 a { color: var(--header-text-top) !important; text-decoration: none; }
.d-header-logo-text p { color: rgba(255,255,255,0.7) !important; font-size: 13px; margin: 2px 0 0; line-height: 1.2; font-weight: 500; }
body.is-dark .d-header-logo-text p { color: #999999 !important; }

.d-header-bottom {
    background: var(--header-bg-bottom);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    height: auto;
    min-height: 48px;
    display: flex; align-items: center;
    border-bottom: 1px solid rgba(0,0,0,0.05);
    margin: 0 !important;
    padding: 0;
    box-sizing: border-box;
    transition: background 0.3s;
}
body.is-dark .d-header-bottom { border-bottom-color: rgba(255,255,255,0.05); }

/* Navigation */
.d-header-nav ul.wp-block-navigation__container {
    display: flex; gap: 4px; margin: 0; padding: 0; list-style: none; align-items: center;
}
.d-header-nav .wp-block-navigation-item__content {
    color: var(--nav-link) !important; 
    font-weight: 600; font-size: 14px;
    padding: 12px 16px; 
    border-radius: 999px;
    transition: background-color 0.2s, color 0.2s;
    display: block;
}
.d-header-nav .wp-block-navigation-item__content:hover {
    color: var(--nav-link-hover) !important; 
    background-color: rgba(0,0,0,0.05);
    text-decoration: none;
}
body.is-dark .d-header-nav .wp-block-navigation-item__content:hover {
    color: #ffffff !important; 
    background-color: rgba(255,255,255,0.15);
}

/* Hamburger Menu (Mobile) */
.wp-block-navigation__responsive-container-open {
    padding: 12px !important;
    border-radius: 8px;
    color: var(--nav-link) !important;
}
.wp-block-navigation__responsive-container-open:hover,
.wp-block-navigation__responsive-container-open:focus {
    background-color: rgba(0,0,0,0.05);
}
body.is-dark .wp-block-navigation__responsive-container-open {
    color: white !important;
}
body.is-dark .wp-block-navigation__responsive-container-open:hover {
    background-color: rgba(255,255,255,0.1);
}
.wp-block-navigation__responsive-container-open svg {
    width: 28px;
    height: 28px;
}

/* --- Dark Mode Toggle (Button Style) --- */
.d-dark-mode-toggle {
    background: transparent !important; border: none !important; padding: 8px !important; margin: 0 !important;
    cursor: pointer !important; outline: none; display: flex; align-items: center; justify-content: center;
    border-radius: 50%; transition: background-color 0.2s; z-index: 10000;
}
.d-dark-mode-toggle:hover { background-color: rgba(255,255,255,0.2); }

.d-toggle-track {
    display: flex; align-items: center; justify-content: space-between;
    width: 52px; height: 28px;
    background-color: rgba(255, 255, 255, 0.3);
    border-radius: 34px; position: relative; padding: 0 4px; box-sizing: border-box;
    transition: background-color 0.4s; pointer-events: none;
}
body.is-dark .d-toggle-track { background-color: rgba(255, 255, 255, 0.15); }

.d-toggle-handle {
    position: absolute; height: 20px; width: 20px; left: 4px; bottom: 4px;
    background-color: white; border-radius: 50%; transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 2;
    box-shadow: 0 2px 4px rgba(0,0,0,0.15);
}
body.is-dark .d-toggle-handle { transform: translateX(24px); }

.d-dark-mode-toggle i { font-size: 14px; z-index: 1; line-height: 1; display: flex; color: #ffffff; }
body.is-dark .d-dark-mode-toggle i { color: #cccccc; }
.d-dark-mode-toggle i.icon-sun { opacity: 1; color: #ffffff; }
.d-dark-mode-toggle i.icon-moon { opacity: 0.8; }
body.is-dark .d-dark-mode-toggle i.icon-sun { opacity: 0.5; color: #999999; }
body.is-dark .d-dark-mode-toggle i.icon-moon { opacity: 1; color: #ffffff; }

/* --- Hero --- */
.d-hero-section {
    background: linear-gradient(120deg, #333333 0%, #000000 100%);
    border-radius: var(--m3-radius-xl);
    color: white;
    padding: 80px 40px; 
    text-align: center;
    box-shadow: var(--card-shadow);
    transition: transform 0.3s;
    margin-bottom: 40px;
}
body.is-dark .d-hero-section { background: linear-gradient(120deg, #1a1a1a 0%, #050505 100%); }

.d-hero-title { font-size: 3rem; font-weight: 800; margin: 0 0 24px; line-height: 1.1; color: white; letter-spacing: -0.02em; }
.d-hero-desc { font-size: 1.25rem; margin-bottom: 2.5rem; color: #e5e5e5; max-width: 600px; margin-inline: auto; font-weight: 500; }
.d-hero-btns { display: flex; justify-content: center; gap: 16px; flex-wrap: wrap; }
.d-btn { 
    padding: 14px 32px; border-radius: 9999px; font-weight: bold; display: inline-block; text-decoration: none; 
    transition: transform 0.2s, box-shadow 0.2s;
    color: white !important;
}
.d-btn:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,0.15); }
.d-btn-primary { background: white; color: #000000 !important; border: 2px solid white; }
.d-btn-secondary { background: transparent; color: white !important; border: 2px solid rgba(255,255,255,0.6); }
.d-btn-secondary:hover { border-color: white; background: rgba(255,255,255,0.1); }

/* --- News Bar --- */
.d-news-bar { 
    background-color: var(--news-bg);
    color: var(--news-text);
    border-radius: var(--m3-radius-l); padding: 32px 24px; margin-bottom: 60px;
    box-shadow: var(--card-shadow);
    transition: background-color 0.3s;
}

.d-news-list { 
    display: flex; flex-direction: column; 
    margin: 0; padding: 0; 
    background: #ffffff;
    border-radius: var(--m3-radius-m);
    box-shadow: 0 4px 6px rgba(0,0,0,0.05); 
    gap: 0 !important;
}
body.is-dark .d-news-list { 
    background: var(--card-bg); 
    box-shadow: 0 4px 6px rgba(0,0,0,0.2);
}

.d-news-list > * {
    margin: 0 !important;
}

.d-news-item { 
    display: flex; align-items: center; gap: 12px; 
    border-bottom: 1px solid rgba(0,0,0,0.05); 
    padding: 12px 16px; 
    transition: background-color 0.2s;
    margin: 0 !important;
}
body.is-dark .d-news-item {
    border-bottom-color: rgba(255,255,255,0.05);
}

.d-news-item:first-child { border-top-left-radius: var(--m3-radius-m); border-top-right-radius: var(--m3-radius-m); }
.d-news-item:last-child { border-bottom: none; border-bottom-left-radius: var(--m3-radius-m); border-bottom-right-radius: var(--m3-radius-m); }

.d-news-item:hover { background-color: rgba(0,0,0,0.02); }
body.is-dark .d-news-item:hover { background-color: rgba(255,255,255,0.03); }

.d-news-item .wp-block-post-date { 
    color: var(--text-sub) !important; 
    font-size: 0.85rem; 
    letter-spacing: 0.02em; 
    margin: 0;
}
body.is-dark .d-news-item .wp-block-post-date {
    color: rgba(255,255,255,0.6) !important;
}

.d-news-text { 
    color: var(--text-main) !important; 
    font-size: 0.95rem; 
    line-height: 1.4; 
    margin: 0;
}
body.is-dark .d-news-text {
    color: var(--text-head) !important;
}

.d-news-text a { 
    color: var(--text-main) !important; 
    text-decoration: none; 
    font-weight: 500; 
    transition: opacity 0.2s, color 0.2s; 
}
body.is-dark .d-news-text a {
    color: var(--text-head) !important;
}

.d-news-text a:hover { 
    text-decoration: underline; 
    color: var(--link-color) !important; 
    opacity: 1; 
}

p.d-news-badge {
    display: flex !important;
    align-items: center;
    justify-content: center;
    width: 28px; 
    height: 28px;
    background-color: #000000; /* Black base */
    color: white !important;
    font-size: 14px;
    font-weight: bold;
    border-radius: 50%;
    margin: 0 !important;
    padding: 0;
    line-height: 1;
    flex-shrink: 0;
    font-family: serif;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* --- Tools Grid --- */
.d-tools-section { padding: 0 0 60px; }
.d-tools-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 24px; margin-bottom: 24px; }

.d-card {
    background: var(--card-bg); 
    border: none;
    border-radius: var(--m3-radius-xl);
    padding: 32px;
    display: flex; flex-direction: column;
    box-shadow: var(--card-shadow); 
    transition: transform 0.3s, box-shadow 0.3s;
    will-change: transform, box-shadow;
}
.d-card:hover { transform: translateY(-8px); box-shadow: var(--card-hover-shadow); }

.d-icon-box {
    width: 64px; height: 64px; border-radius: 20px;
    display: flex; align-items: center; justify-content: center;
    font-size: 32px; margin-bottom: 20px;
    background-color: var(--icon-bg-def); color: var(--icon-color-def);
    transition: transform 0.3s;
}
.d-icon-box svg { width: 32px; height: 32px; fill: currentColor; }
.d-card:hover .d-icon-box { transform: scale(1.1); }

.d-card h3 { margin: 0 0 12px; font-size: 1.25rem; font-weight: 800; line-height: 1.4; }
.d-card h3 a { color: var(--text-head); text-decoration: none; }
.d-card:hover h3 a { color: var(--link-color); text-decoration: underline; }
.d-card p { font-size: 0.95rem; color: var(--text-sub); margin: 0 0 24px; flex-grow: 1; line-height: 1.7; }

.d-card-footer {
    border-top: 1px solid var(--card-border); padding-top: 20px; margin-top: auto;
    display: flex; justify-content: space-between; align-items: center; width: 100%;
}

.d-version { font-size: 11px; font-weight: bold; padding: 4px 10px; border-radius: 6px; display: inline-block; }
.d-category-name { font-size: 11px; color: var(--text-sub); font-family: monospace; }
.d-arrow-icon { color: var(--link-color); font-size: 14px; transition: transform 0.3s; }
.d-card:hover .d-arrow-icon { transform: translateX(4px); }

/* --- Footer --- */
.d-footer { 
    background: var(--footer-bg); color: white; padding: 60px 0 40px; margin-top: auto;
    border-top-left-radius: var(--m3-radius-xl); border-top-right-radius: var(--m3-radius-xl);
    transition: background-color 0.3s;
}
.d-footer-links { display: flex; gap: 32px; margin-bottom: 32px; justify-content: center; }
.d-footer-links a { color: rgba(255,255,255,0.7); font-size: 15px; font-weight: 500; }
.d-footer-links a:hover { color: white; text-decoration: underline; }
.d-copyright { text-align: center; font-size: 13px; color: rgba(255,255,255,0.5); margin: 0; }
body.is-dark .d-footer-links a { color: #999999; }
body.is-dark .d-footer-links a:hover { color: white; }
body.is-dark .d-copyright { color: #666666; }

/* --- Tools Anchor Offset --- */
#tools {
    scroll-margin-top: 140px;
}

/* Editor Fixes */
.editor-styles-wrapper .d-header { position: absolute !important; }
.editor-styles-wrapper .d-main-content { margin-top: 140px; }

/* Copy Prevention (For Company Profile) */
.d-no-select {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
}

@media (max-width: 768px) {
    .d-main-content { margin-top: 120px; }
    .d-content-surface { padding: 24px; border-radius: var(--m3-radius-l); }
    .d-hero-section { padding: 40px 24px; border-radius: var(--m3-radius-l); }
    .d-hero-title { font-size: 2rem; }
    .d-news-item { flex-direction: row; align-items: center; gap: 12px; }
    .d-news-content { width: 100%; }
    .d-news-text { white-space: normal; }
}