﻿@import url('https://fonts.googleapis.com/css2?family=Noto+Serif+JP:wght@400;700&display=swap');

:root {
    --paper-bg: #fdf5e6;
    --body-bg: #2c241e;
    --ink-color: #3e2723;
    --accent-gold: #b8860b;
    --border-sepia: #d2b48c;
}

* { box-sizing: border-box; }

html {
    scroll-behavior: auto !important;
    scroll-padding-top: 20px;
}

/* =========================================
   ガタつきを隠すフェードインアニメーション
   ========================================= */
@keyframes fadeIn {
    to { opacity: 1; }
}

body {
    font-family: 'Noto Serif JP', serif;
    background-color: var(--body-bg);
    background-image: radial-gradient(#3e2c21 1px, transparent 1px);
    background-size: 20px 20px;
    color: var(--ink-color);
    margin: 0;
    padding: 20px;
    line-height: 1.8;
}

/* --- コンテナと見出し --- */
.container {
    max-width: 1000px; 
    margin: 40px auto;
    background-color: var(--paper-bg);
    padding: 40px 60px;
    border-radius: 3px 10px 10px 3px; 
    position: relative;
    border-left: 15px solid #5d4037; 
    box-shadow: 
        2px 2px 0 var(--paper-bg), 3px 3px 0 var(--border-sepia),
        4px 4px 0 var(--paper-bg), 5px 5px 0 var(--border-sepia),
        10px 10px 20px rgba(0,0,0,0.4);
        
    /* 読み込み時に0.8秒かけてふわっと表示（ガタつきを隠す） */
    opacity: 0;
    animation: fadeIn 0.6s ease-in-out forwards;
}

h1, h2 {
    color: var(--ink-color);
    border-bottom: 1px double var(--border-sepia);
    padding-bottom: 10px;
    margin-top: 0;
    text-align: center;
    letter-spacing: 0.1em;
}

a { color: var(--accent-gold); text-decoration: none; transition: 0.3s; }
a:hover { color: #8b4513; text-decoration: underline; }

/* --- ボタン共通スタイル --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 6px 16px; 
    border-radius: 25px; 
    border: 1px solid var(--accent-gold);
    background: transparent;
    color: var(--accent-gold);
    cursor: pointer;
    font-family: inherit;
    font-weight: bold;
    transition: 0.3s;
    min-width: 110px; 
    font-size: 0.9em;
    line-height: 1.2;
}
.btn:hover { background: var(--accent-gold); color: white; }
.btn-primary { background: var(--accent-gold); color: white; }
.btn-outline { border: 1px solid var(--ink-color); color: var(--ink-color); border-radius: 25px; }
.btn-outline:hover { background: var(--ink-color); color: var(--paper-bg); }
.btn-secondary { background-color: var(--ink-color); color: var(--paper-bg); border: 1px solid var(--ink-color); border-radius: 25px; }
.btn-secondary:hover { background-color: #5d4037; border-color: #5d4037; }

/* --- フォーム入力（共通） --- */
input[type="text"], input[type="password"], input[type="number"], select, textarea {
    width: 100%;
    padding: 12px;
    background-color: rgba(255, 255, 255, 0.5);
    border: none;
    border-bottom: 1px solid var(--border-sepia);
    font-family: inherit;
    font-size: 1.1em;
    color: var(--ink-color);
}
input:focus, textarea:focus {
    outline: none;
    background-color: #fff;
    border-bottom: 1.5px solid var(--accent-gold);
}

/* =========================================
   レイアウトとナビゲーション
   ========================================= */
.top-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    border-bottom: 1px dashed var(--border-sepia);
    padding-bottom: 15px;
}

.flex-container { display: flex; gap: 40px; }
.main-content { flex: 1; }

.sidebar {
    width: 280px;
    font-size: 0.9em;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* =========================================
   cal-list.php (一覧画面) 用スタイル
   ========================================= */
.card {
    background-color: rgba(255, 255, 255, 0.4); 
    border: 1px solid var(--border-sepia);
    border-radius: 8px; 
    padding: 25px;
    margin-bottom: 30px;
    box-shadow: 2px 2px 10px rgba(0,0,0,0.05); 
}

.post-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 20px;
    padding-top: 15px;
    border-top: 1px dotted var(--border-sepia);
}

.post-author-info { font-size: 0.9em; color: var(--ink-color); font-weight: bold; }
.post-author-info span { color: var(--accent-gold); margin-right: 5px; }

.btn-like, .btn-liked {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.85em;
    min-width: 75px;
    height: 30px;
    cursor: pointer;
    transition: 0.3s;
    font-weight: bold;
    border: 1px solid var(--accent-gold);
}
.btn-like { background: transparent; color: var(--accent-gold); }
.btn-like:hover { background: var(--accent-gold); color: white; }
.btn-liked { background: var(--accent-gold); color: white; cursor: default; }

.mini-cal {
    width: 100%;
    max-width: 240px;
    margin: 0 auto 30px auto;
    border: 1px solid var(--border-sepia);
    padding: 10px;
    background-color: rgba(255, 255, 255, 0.2);
}
.mini-cal-table { width: 100%; border-collapse: collapse; margin: 0 auto; text-align: center; }
.mini-cal-table th, .mini-cal-table td { padding: 5px 2px; }
.has-data-link {
    background-color: var(--accent-gold);
    color: white !important;
    border-radius: 50%;
    width: 26px; height: 26px; line-height: 26px; 
    display: inline-block;
    text-align: center;
    font-weight: bold;
}

.sidebar-form {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    flex-wrap: nowrap;
    width: 100%;
    margin-bottom: 20px;
}
.sidebar-form input[type="number"],
.sidebar-form select {
    width: 70px !important;
    height: 34px !important;
    padding: 0 5px !important;
    margin: 0 !important;
    font-size: 0.9em;
    text-align: center;
    border: 1px solid var(--border-sepia);
    background-color: rgba(255, 255, 255, 0.7);
    border-radius: 4px;
    box-sizing: border-box;
    -webkit-appearance: none;
    appearance: none;
}
.sidebar-form .btn, .sidebar-form .btn-primary {
    min-width: 60px;
    height: 34px;
    line-height: 34px;
    padding: 0 10px;
    font-size: 0.8em;
    border-radius: 17px;
}

/* =========================================
   cal-index.php (カレンダー画面) 用スタイル
   ========================================= */
.calendar-table {
    width: 100%;
    border-collapse: collapse;
    background: rgba(255, 255, 255, 0.4);
    table-layout: fixed;
    border: 2px solid var(--border-sepia);
}
.calendar-table th, .calendar-table td {
    border: 1px solid var(--border-sepia);
    padding: 10px;
    vertical-align: top;
}
.calendar-table th {
    background-color: rgba(184, 134, 11, 0.1);
    text-align: center;
    font-weight: bold;
    padding: 10px 5px;
    color: var(--ink-color);
}
.calendar-table td { height: 120px; }
.calendar-table .today { background-color: rgba(210, 180, 140, 0.3); }
.calendar-table .has-post { background-color: rgba(255, 255, 255, 0.6); }
.calendar-table .today.has-post { background-color: rgba(210, 180, 140, 0.5); }

.date-link {
    font-size: 1.2em;
    font-weight: bold;
    color: var(--ink-color);
    display: inline-block;
    margin-bottom: 8px;
}
.date-link:hover { color: var(--accent-gold); text-decoration: none; transform: scale(1.1); }

.post-content {
    font-size: 0.85em;
    padding: 5px;
    margin-bottom: 5px;
    border-bottom: 1px dotted var(--border-sepia);
    word-wrap: break-word;
    line-height: 1.4;
}
.post-content strong { color: var(--accent-gold); margin-right: 5px; }

.form-inline { display: flex; align-items: center; gap: 8px; }
.form-inline input[type="number"], .form-inline select { width: auto; padding: 6px; font-size: 1em; background: rgba(255,255,255,0.7); }
.form-inline button.btn { min-width: 70px; padding: 4px 12px; }

/* =========================================
   PC表示時のレイアウト調整（メイン1列 ＋ サイドバー右1列）
   ========================================= */
@media (min-width: 769px) {
    .flex-container.list-flex {
        display: flex !important;
        gap: 40px; 
    }
    .main-content {
        flex: 1; 
        column-count: 1 !important; /* 絶対に記事を分割させない */
    }
    .sidebar.list-sidebar {
        width: 280px !important;
        position: sticky !important;
        top: 20px;
    }
}

/* =========================================
   スマートフォン・タブレット対応 (768px以下)
   ========================================= */
@media (max-width: 768px) {
    body { padding: 15px !important; }
    .container {
        width: 95% !important;
        padding: 20px !important;
    }    
    .top-nav {
        display: flex !important;
        justify-content: space-between !important;
        align-items: center;
        width: 100%;
        padding: 0 5px;
        margin-bottom: 10px;
    }
    .top-nav h1 { display: none !important; } 
    .top-nav a, .top-nav .btn { margin: 0 !important; font-size: 0.85em; padding: 8px 12px; }

    .calendar-controls { flex-direction: column; gap: 10px; align-items: center; }
    .calendar-table { table-layout: fixed; }
    .calendar-table th, .calendar-table td { padding: 5px 2px !important; font-size: 0.85em; }
    .calendar-table td { height: 60px; }
    .calendar-table td a { display: block; width: 100%; height: 100%; }

    .top-nav h1.list-title {
        display: block !important;
        font-size: 1.4em !important;
        text-align: center;
        margin-bottom: 15px;
        line-height: 1.4;
    }
    .top-nav.list-nav {
        flex-direction: column !important;
        align-items: center !important;
        gap: 10px;
        margin-bottom: 20px;
        padding-top:20px;
    }

    .flex-container { display: block; }
    .flex-container.list-flex {
        display: flex !important;
        flex-direction: column-reverse !important; /* 検索フォームを上に */
    }    
    .sidebar { display: none !important; } 
    .sidebar.list-sidebar {
        width: 100% !important;
        position: relative !important;
        margin-bottom: 30px;
    }
    .sidebar.list-sidebar .mini-cal { display: none !important; } 

    .main-content {
        width: 100% !important;
        column-count: 1 !important; /* スマホでも必ず1列 */
    }
    .card {
        margin-left: 0; margin-right: 0;
        padding: 20px !important;
        width: 100% !important;
    }
    .card h2 { font-size: 1.2em !important; }
    
    .post-footer { flex-direction: column; align-items: flex-start; gap: 10px; }
    .like-section { width: 100%; text-align: right; }
}