@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+JP:wght@300;400;500;700&display=swap');

/* --- 変数定義 (Design Tokens) --- */
:root {
    /* Colors */
    --primary-color: #08385c;   /* 知的なディープブルー */
    --primary-light: #165b8f;   /* ホバー用ライトブルー */
    --accent-color: #db0000;    /* インパクトのある赤 */
    --accent-light: #ff4d4d;    /* ホバー用ライトレッド */
    
    --text-main: #333333;       /* メインテキスト */
    --text-sub: #666666;        /* サブテキスト */
    --bg-body: #f4f7f9;         /* 全体の背景色（薄い青グレー） */
    --bg-card: #ffffff;         /* カード背景 */
    
    --white: #ffffff;
    --border-color: #e2e8f0;

    /* Spacing & Layout */
    --max-width: 1280px;        /* 修正: 最大幅を1000pxから1280pxに拡大 */
    --header-height: 70px;      /* ヘッダーの基準高さ */
    --border-radius: 8px;      /* モダンな角丸 */
    
    /* Shadows (未来的・浮遊感) */
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-glow: 0 0 15px rgba(8, 56, 92, 0.15); /* ほのかな発光感 */
}

/* --- Base Styles --- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: "Noto Sans JP", "Hiragino Kaku Gothic ProN", "Meiryo", sans-serif;
    background-color: var(--bg-body);
    color: var(--text-main);
    line-height: 1.6;
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    padding-bottom: 40px; /* 下部に少し余裕を持たせる */
}

a {
    color: var(--primary-color);
    text-decoration: none;
    transition: all 0.3s ease;
}

a:hover {
    color: var(--primary-light);
}

img {
    max-width: 100%;
    height: auto;
    display: block;
}

ul {
    list-style: none;
}

/* --- Utilities --- */
.container {
    width: 100%;
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 20px;
}

/* --- Header (.title) --- */
.title {
    width: 100%;
    background: #1a202c; /* ダークグレーで引き締め */
    color: var(--white);
    min-height: var(--header-height);
    padding: 10px 0; /* 上下の余白 */
    
    box-shadow: var(--shadow-md);
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(10px); /* すりガラス効果 */
    background: rgba(26, 32, 44, 0.95);
    
    display: flex;
    flex-direction: column; /* 縦並び (about.html対応) */
    justify-content: center; /* 垂直中央 */
    align-items: stretch;   /* 幅いっぱい */
}

.title-inner {
    width: 100%;
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    align-items: center;
    height: 100%;
}

/* about.html などのレガシーヘッダー要素への対応 */
.title p {
    /* インラインスタイルを強制的にリセット */
    margin: 0 !important;
    padding: 0 20px; /* 左右の余白を確保 */
    max-width: var(--max-width);
    margin-left: auto !important;
    margin-right: auto !important;
    width: 100%;
    line-height: 1.4;
    
    font-family: "Noto Sans JP", sans-serif;
    font-weight: 300;
    letter-spacing: 0.1em;
}

/* 1行目（パンくず/リンク）: 小さく薄く */
.title p:first-child {
    font-size: 0.85rem !important;
    opacity: 0.8;
}

/* 2行目（ページタイトル）: 大きく */
.title p:last-child {
    font-size: 1.4rem !important;
    font-weight: 500;
    padding-bottom: 2px;
}

/* index.html の .title-inner 内の p は1つだけなのでスタイル調整 */
.title-inner p {
    padding: 0; /* innerがpaddingを持っているのでリセット */
    font-size: 1.5rem !important;
    letter-spacing: 0.15em;
    font-weight: 300;
}


/* --- Hero Image --- */
.hero-wrapper {
    width: 100%;
    max-width: var(--max-width);
    margin: 30px auto;
    padding: 0 20px;
    border-radius: var(--border-radius);
    overflow: hidden;
}

/* 修正: .container内では幅100%にする */
.container .hero-wrapper {
    padding: 0;
    width: 100%;
}

.hero-wrapper img {
    width: 100%;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-md);
}

/* --- Headings --- */
h3 {
    font-size: 1.5rem;
    color: var(--primary-color);
    margin: 3rem 0 0.8rem;
    padding-left: 1rem;
    border-left: 5px solid var(--primary-color);
    font-weight: 500;
    letter-spacing: 0.08em;
    position: relative;
    /* 修正: inline-block から block に変更し、確実に改行させる */
    display: block; 
}

h4 {
    font-size: 1.2rem;
    color: var(--text-main);
    margin: 2rem 0 1rem;
    font-weight: 700;
}

/* --- Navigation Buttons (#button) --- */
#button {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
    margin: 0 0 3rem; 
}

@media (min-width: 768px) {
    #button {
        grid-template-columns: repeat(4, 1fr);
    }
}

#button a {
    display: block;
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: var(--shadow-md);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.3s ease;
    background: var(--white);
}

#button a:hover {
    transform: translateY(-5px) scale(1.02);
    box-shadow: var(--shadow-lg);
}

/* --- Universal Box Styles (.box1, .box2, etc.) --- */
/* デフォルト（about.html等）：中央寄せで幅制限あり */
.box1, .box2, .box3, .box4 {
    /* 修正: 元の左右4%余白と同じ感覚になるよう92%に設定 */
    width: 92%;
    max-width: var(--max-width);
    /* 修正: インラインスタイル(style="margin-left: 4%")を強制上書きして中央寄せにする */
    margin-left: auto !important;
    margin-right: auto !important;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-md);
    position: relative;
    overflow: hidden;
}

/* 修正: .container内（index.html等）では幅いっぱいにする */
.container .box1,
.container .box2,
.container .box3,
.container .box4 {
    width: 100%;
    margin-left: 0 !important;
    margin-right: 0 !important;
}

/* 修正: ボックス内の最初のh3の上マージンを削除（余白調整） */
.box1 h3:first-child,
.box2 h3:first-child,
.box3 h3:first-child,
.box4 h3:first-child {
    margin-top: 0;
}


/* --- News Box (.box1) --- */
.box1 {
    background: var(--bg-card);
    padding: 2rem;
    margin-bottom: 4rem;
    border: none;
}

.box1::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: linear-gradient(90deg, var(--primary-color), var(--primary-light));
}

.box1 ul {
    margin: 0;
    padding: 0;
}

.box1 li {
    padding: 1rem 0;
    border-bottom: 1px solid var(--border-color);
    transition: background-color 0.2s;
}

.box1 li:last-child {
    border-bottom: none;
}

.box1 li:hover {
    background-color: #f8fafc;
    padding-left: 0.5rem;
}

.box1 p a {
    display: inline-flex;
    align-items: center;
    font-weight: 500;
    font-size: 0.9rem;
    color: var(--primary-color);
    padding: 0.5rem 1rem;
    border-radius: 20px;
    background: rgba(8, 56, 92, 0.05);
    transition: all 0.3s ease;
}

.box1 p a:hover {
    background: var(--primary-color);
    color: var(--white);
}

/* --- Standard Box (.box2) --- */
/* about.html などで使用 */
.box2 {
    background: var(--bg-card);
    padding: 2rem;
    margin-top: 2rem;
    margin-bottom: 2rem;
    border-left: 5px solid var(--text-sub);
}

/* box2内のテキスト調整 */
.box2 p {
    margin-bottom: 1em;
    color: var(--text-main);
}
.box2 li {
    margin-left: 1.5em;
    list-style-type: disc;
    margin-bottom: 0.5em;
}

/* --- Blue Header Box (.box3) --- */
.box3 {
    margin-top: 2rem;
    margin-bottom: 2rem;
    background: var(--bg-card);
    border: 1px solid rgba(8, 56, 92, 0.1);
}

.box3 .box-title {
    background: var(--primary-color);
    color: var(--white);
    padding: 1rem;
    font-weight: 700;
    text-align: center;
    font-size: 1.1rem;
    letter-spacing: 0.05em;
}

.box3-content, .box3 > p {
    padding: 1.5rem;
}

/* --- Red Alert Box (.box4) --- */
.box4 {
    margin-top: 2rem;
    margin-bottom: 2rem;
    background: #fff5f5;
    border: 1px solid #fed7d7;
}

.box4 .box-title {
    background: var(--accent-color);
    color: var(--white);
    padding: 0.8rem;
    text-align: center;
    font-weight: 700;
    font-size: 1.1rem;
}

.box4 p, .box4 ul {
    padding: 1.5rem;
    color: #9b2c2c;
}

/* --- Submit Button (.submit_btn) --- */
.submit_btn {
    display: block;
    width: 100%;
    max-width: 300px;
    margin: 2rem auto;
    padding: 1rem 2rem;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-light));
    color: var(--white);
    font-size: 1rem;
    font-weight: 700;
    text-align: center;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(8, 56, 92, 0.3);
    transition: all 0.3s ease;
}

.submit_btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(8, 56, 92, 0.4);
    opacity: 1;
    filter: brightness(1.1);
}

/* --- 追加: フォームとダウンロード数表示の配置調整 --- */
/* ダウンロードページのformと、その下のdiv（ダウンロード数）を、box3と同じ配置ルールで強制する */
body > form,
body > form + div {
    /* 修正: ボックスと同じ92%に設定して左端を揃える */
    width: 92%;
    max-width: var(--max-width);
    /* HTMLのインラインスタイルを上書きして中央寄せ */
    margin-left: auto !important;
    margin-right: auto !important;
    padding: 0;
}

/* 修正: input[type="image"] の場合のみ、CSSボタンの装飾を無効化し、サイズを制限する */
input[type="image"].submit_btn {
    background: none;
    padding: 0;
    box-shadow: none;
    border-radius: 0; 

    /* 修正: 画面いっぱいに広がらないよう最大幅を設定 */
    width: 100%;
    max-width: 300px; 
    height: auto;
    
    /* 修正: 左寄せに変更 (margin: 0)。親要素(form)が中央寄せされているため、その左端に揃う */
    display: block;
    margin: 2rem 0;
}

/* 画像ボタンのホバー時は少し明るくする程度に留める */
input[type="image"].submit_btn:hover {
    transform: translateY(-2px);
    box-shadow: none;
    opacity: 0.8;
    filter: brightness(1.1);
}

/* ダウンロード数テキストの微調整 */
body > form + div {
    margin-top: 0;
    margin-bottom: 2rem;
    color: var(--text-main);
}

/* --- 追加: ファイルアップロードエリアのレスポンシブ修正 --- */
/* HTML内のインラインスタイル(vw指定)を無効化し、ボックス内に収める */
.box3 input[type="file"] {
    width: 92% !important;        /* ボックス幅に対して92%（適度な余白） */
    max-width: 100% !important;
    margin: 20px auto !important; /* 中央寄せ */
    height: 200px !important;     /* 高さを固定（PCで巨大化するのを防ぐ） */
    display: block;
}

/* --- Responsive Adjustments --- */
@media (max-width: 600px) {
    :root {
        --header-height: 60px;
    }
    
    .title p:last-child {
        font-size: 1.1rem !important;
    }

    h3 {
        font-size: 1.2rem;
        margin: 2rem 0 1rem;
    }
    
    .box1, .box2, .box3, .box4 {
        padding: 1.5rem;
        width: 92%; 
    }
    
    /* コンテナ内なら100% */
    .container .box1,
    .container .box2,
    .container .box3,
    .container .box4 {
        width: 100%;
    }

    /* スマホでのフォーム幅調整 */
    body > form,
    body > form + div {
        width: 92%;
    }

    /* --- 追加: スマホでinputの横幅が狭くなる問題を解消 --- */
    input[type="text"],
    input[type="number"],
    input[type="password"],
    input[type="email"],
    select,
    textarea {
        /* インラインスタイルの width: 40% を強制上書き */
        width: 100% !important; 
        max-width: 100%;
        
        /* スマホで使いやすいサイズ感に調整 */
        font-size: 16px !important; /* 自動ズーム防止 */
        height: auto !important;
        padding: 12px;
        margin-bottom: 1em;
        border: 1px solid var(--border-color);
        border-radius: 8px;
    }
}