/* 暗号カフェ V2 (Sister Site Style: memori-tech.tech) */

:root {
    /* Color Palette (Soft Blue & Clean) */
    --bg-color: #fcfaf7;          /* Warm off-white */
    --card-bg: #ffffff;           /* Clean white */
    --text-primary: #4a3a33;      /* Soft dark brown for readability */
    --text-secondary: #7d6b63;    /* Muted brown for subtext */
    --accent-blue: #5599ff;       /* Sister site main soft blue */
    --accent-blue-hover: #3d84f0; /* Slightly darker for hover states */
    --accent-gold: #d4a373;       /* Muted gold for highlights */
    
    /* Layout Variables */
    --container-width: 1000px;
    --border-radius-card: 16px;
    --border-radius-btn: 30px;
    
    /* Shadows */
    --shadow-sm: 0 4px 10px rgba(0, 0, 0, 0.03);
    --shadow-md: 0 10px 30px rgba(0, 0, 0, 0.06);
    --shadow-hover: 0 15px 40px rgba(85, 153, 255, 0.15); /* Soft blue shadow */
    
    /* Typography */
    --font-main: 'Noto Sans JP', 'Inter', sans-serif;
    --font-heading: 'Outfit', 'Noto Sans JP', sans-serif;
}

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

body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    font-family: var(--font-main);
    line-height: 1.8;
    overflow-x: hidden;
}

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

a:hover {
    color: var(--accent-blue-hover);
}

h1, h2, h3, h4 {
    font-family: var(--font-heading);
    font-weight: 700;
    line-height: 1.4;
    color: var(--text-primary);
}

.container {
    max-width: var(--container-width);
    margin: 0 auto;
    padding: 0 24px;
}

/* === Header / Navigation === */
header {
    background: rgba(252, 250, 247, 0.95);
    backdrop-filter: blur(12px);
    position: fixed;
    width: 100%;
    top: 0;
    z-index: 1000;
    border-bottom: 2px solid var(--accent-blue);
    box-shadow: var(--shadow-sm);
}

header nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 120px; /* Matched to sister site */
}

.logo-link {
    display: flex;
    align-items: center;
    height: 100%;
}

.header-logo {
    height: 100px; /* Matched to sister site */
    width: auto;
    object-fit: contain;
    transition: transform 0.3s ease;
}

.header-logo:hover {
    transform: scale(1.03);
}

.nav-links {
    display: flex;
    list-style: none;
    gap: 32px;
}

.nav-links a {
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.95rem;
    transition: all 0.3s ease;
}

.nav-links a:hover {
    color: var(--accent-blue);
}

/* === Buttons === */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 14px 36px;
    border-radius: var(--border-radius-btn);
    font-weight: 700;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.165, 0.84, 0.44, 1);
}

.btn-primary {
    background-color: var(--accent-blue);
    color: white !important;
    box-shadow: 0 6px 15px rgba(85, 153, 255, 0.3);
}

.btn-primary:hover {
    background-color: var(--accent-blue-hover);
    transform: translateY(-3px);
    box-shadow: 0 10px 20px rgba(85, 153, 255, 0.4);
}

/* === Layout Blocks === */
.section-padding {
    padding: 100px 0;
}

.page-title {
    text-align: center;
    margin-bottom: 60px;
    /* padding-top: 140px; 削除：ヘッダーの余白はAdSense枠（margin-top）で確保されるため不要 */
}

.page-title h1 {
    font-size: clamp(2rem, 5vw, 3rem);
    margin-bottom: 16px;
    color: var(--accent-blue);
}

.page-title p {
    color: var(--text-secondary);
    font-size: 1.1rem;
    max-width: 600px;
    margin: 0 auto;
}

/* === Cards & Lists === */
.grid-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 32px;
}

.card {
    background: var(--card-bg);
    border-radius: var(--border-radius-card);
    padding: 32px;
    box-shadow: var(--shadow-sm);
    border: 1px solid #f0f0f0;
    transition: all 0.4s ease;
    display: block;
    color: inherit;
}

.card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-hover);
    border-color: var(--accent-blue);
}

.card-tag {
    display: inline-block;
    background: var(--bg-color);
    color: var(--accent-blue);
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 700;
    margin-bottom: 16px;
    border: 1px solid var(--accent-blue);
}

.card h3 {
    font-size: 1.4rem;
    margin-bottom: 16px;
}

.card p {
    color: var(--text-secondary);
    font-size: 0.95rem;
    line-height: 1.6;
}

/* === Article Layout === */
.article-header {
    margin-bottom: 40px;
    padding-bottom: 24px;
    border-bottom: 1px solid #eee;
}

.article-meta {
    display: flex;
    gap: 16px;
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 16px;
}

.article-content {
    background: var(--card-bg);
    padding: 60px;
    border-radius: var(--border-radius-card);
    box-shadow: var(--shadow-sm);
    font-size: 1.05rem;
}

.article-content h2 {
    font-size: 1.8rem;
    margin: 48px 0 24px;
    padding-left: 16px;
    border-left: 6px solid var(--accent-blue);
}

.article-content h3 {
    font-size: 1.4rem;
    margin: 32px 0 16px;
    color: var(--text-primary);
}

.article-content p {
    margin-bottom: 24px;
}

.article-content ul, .article-content ol {
    margin-bottom: 24px;
    padding-left: 24px;
}

.article-content li {
    margin-bottom: 8px;
}

.article-content a {
    color: var(--accent-blue);
    text-decoration: underline;
    font-weight: 500;
    transition: color 0.3s ease;
}

.article-content a:hover {
    color: #3b7ce0;
    text-decoration: none;
}

/* === Mofuneko Companion Component === */
.mofuneko-bubble {
    background: #f4f8ff; /* Very light blue background matching reference */
    border: 2px solid var(--accent-blue);
    border-radius: 12px;
    padding: 24px 32px;
    margin: 48px 0;
    position: relative;
    display: flex;
    gap: 24px;
    align-items: center; /* Center vertically like reference */
}

.mofuneko-bubble::before {
    content: var(--bubble-label, "🐾 もふねこ解説");
    position: absolute;
    top: -20px;
    left: 20px;
    background: var(--accent-blue);
    color: white;
    padding: 8px 16px;
    border-radius: 20px 20px 20px 0; /* Tab style like reference */
    font-size: 0.9rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    z-index: 1; /* Ensure tab is above border */
}

.mofuneko-avatar {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: white;
    border: 3px solid var(--accent-blue);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden; /* Ensure image stays inside circle */
    box-shadow: 0 4px 8px rgba(85, 153, 255, 0.2); /* Soft shadow like reference */
}

/* Use emoji as fallback if no image */
.mofuneko-avatar::after {
    content: '🐈‍⬛';
    position: absolute;
    z-index: 1;
}

.mofuneko-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
    position: relative;
    z-index: 2;
}

.mofuneko-text {
    flex: 1;
    font-weight: 500;
    color: var(--text-primary);
    line-height: 1.7;
}

.mofuneko-text p:last-child {
    margin-bottom: 0;
}

/* === Footer === */
footer {
    background: white;
    padding: 60px 0 30px;
    border-top: 1px solid #eee;
    margin-top: 80px;
    text-align: center;
}

.footer-links {
    display: flex;
    justify-content: center;
    gap: 32px;
    margin-bottom: 32px;
    list-style: none;
}

.footer-links a {
    color: var(--text-secondary);
    font-weight: 500;
}

.copyright {
    color: #999;
    font-size: 0.85rem;
}

/* === AdSense Container Safeties === */
.ad-container {
    margin: 40px 0;
    text-align: center;
    min-height: 100px;
    background: #fafafa;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ccc;
    font-size: 0.8rem;
    border: 1px dashed #ddd; /* Development only, removes invisible clicking */
}
.ad-container::before {
    content: 'Advertisement';
}

/* === Utilities === */
.text-center { text-align: center; }
.mb-2 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 16px; }
.mb-8 { margin-bottom: 32px; }

/* === Speech Balloon Chat Component === */
.speech-wrap {
    display: flex;
    gap: 20px;
    align-items: flex-start;
    margin: 40px 0;
    width: 100%;
}

.speech-wrap.sbp-r {
    flex-direction: row-reverse;
}

.speech-person {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 80px;
    flex-shrink: 0;
}

.speech-icon {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    overflow: hidden;
    border: 1px solid #ddd;
    background: #fdf5e6; /* Soft cream background for the avatars to match reference */
    margin: 0 0 8px 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.speech-icon-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.speech-name {
    font-size: 0.8rem;
    color: var(--text-primary);
    text-align: center;
    font-weight: 500;
}

.speech-balloon {
    position: relative;
    background: #ffffff;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    padding: 16px 24px;
    max-width: calc(100% - 100px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.02);
    margin-top: 10px;
    color: var(--text-primary);
}

.speech-balloon p {
    margin: 0 !important;
    line-height: 1.6;
}

/* Left pointing tail (Mofuneko) */
.speech-wrap.sbp-l .speech-balloon::before,
.speech-wrap.sbp-l .speech-balloon::after {
    content: "";
    position: absolute;
    top: 20px;
    width: 0;
    height: 0;
    border-style: solid;
}

.speech-wrap.sbp-l .speech-balloon::before {
    left: -12px;
    border-width: 8px 12px 8px 0;
    border-color: transparent #e0e0e0 transparent transparent;
}

.speech-wrap.sbp-l .speech-balloon::after {
    left: -9px;
    border-width: 7px 10px 7px 0;
    border-color: transparent #ffffff transparent transparent;
}

/* Right pointing tail (Reader) */
.speech-wrap.sbp-r .speech-balloon::before,
.speech-wrap.sbp-r .speech-balloon::after {
    content: "";
    position: absolute;
    top: 20px;
    width: 0;
    height: 0;
    border-style: solid;
}

.speech-wrap.sbp-r .speech-balloon::before {
    right: -12px;
    border-width: 8px 0 8px 12px;
    border-color: transparent transparent transparent #e0e0e0;
}

.speech-wrap.sbp-r .speech-balloon::after {
    right: -9px;
    border-width: 7px 0 7px 10px;
    border-color: transparent transparent transparent #ffffff;
}

/* === Crypto Playground === */
.playground-box {
    background: white;
    padding: 30px;
    border-radius: 8px;
    max-width: 600px;
    margin: 0 auto;
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
}

.crypto-result-wrap {
    background: #eee;
    padding: 15px;
    border-radius: 4px;
    margin-bottom: 15px;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 80px;
}

#encryptedText {
    margin: 0;
    font-size: clamp(1.2rem, 4vw, 1.5rem);
    font-weight: bold;
    color: #333;
    letter-spacing: 2px;
    word-break: break-all;
    text-align: center;
    user-select: all;
    padding-right: 80px; /* Space for absolute button on desktop */
}

#copyBtn {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: white;
    border: 1px solid #ccc;
    border-radius: 4px;
    padding: 8px 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    white-space: nowrap;
}

@media (max-width: 768px) {
    header nav {
        height: auto;
        padding: 8px 0;
        flex-direction: column;
        gap: 8px;
    }
    
    .header-logo {
        height: 50px; 
    }
    
    .nav-links {
        display: flex;
        gap: 12px;
        flex-wrap: wrap;
        justify-content: center;
    }

    .nav-links a {
        font-size: 0.8rem;
    }

    /* ヘッダーの重なり防止：最初のセクションに大きな余白を持たせる */
    section:first-of-type {
        padding-top: 180px !important;
    }
    
    .section-padding {
        padding: 40px 0;
    }

    /* index.html intro section */
    .intro-section {
        padding: 24px 16px !important;
        margin-top: 30px !important;
    }

    /* crypto-playground */
    #crypto-playground {
        padding: 24px 16px !important;
        margin-top: 30px !important;
    }

    .page-title {
        margin-bottom: 40px;
    }

    .article-content {
        padding: 32px 20px;
    }
    
    .mofuneko-bubble {
        flex-direction: column;
        align-items: center;
        text-align: center;
        padding: 40px 24px 24px;
    }
    
    .mofuneko-avatar {
        margin-bottom: 8px;
    }

    .footer-links {
        flex-wrap: wrap;
        gap: 12px 20px;
        justify-content: center;
    }

    .footer-links li {
        white-space: nowrap;
    }

    /* Crypto Playground Mobile */
    .crypto-result-wrap {
        flex-direction: column;
        padding-bottom: 20px;
        min-height: auto;
    }

    #encryptedText {
        padding-right: 0;
        margin-bottom: 10px;
    }

    #copyBtn {
        position: relative;
        right: auto;
        top: auto;
        transform: none;
        width: 100%;
        margin-top: 10px;
    }
    
    .playground-box {
        padding: 20px 15px;
    }

    .playground-form-row {
        flex-direction: column;
        gap: 10px;
    }

    .playground-form-row input {
        width: 100%;
    }

    .playground-form-row button {
        width: 100%;
    }
}

/* === Playground Global Styles === */
.playground-input {
    width: 100%;
    padding: 12px;
    border: 2px solid #ddd;
    border-radius: 6px;
    font-size: 1.1rem;
    box-sizing: border-box;
    font-family: inherit;
}

.playground-range {
    width: 100%;
    cursor: pointer;
}

.btn-playground {
    border: none;
    padding: 12px 24px;
    font-size: 1.1rem;
    border-radius: 50px;
    cursor: pointer;
    font-weight: bold;
    width: 100%;
    transition: transform 0.2s;
}

.btn-accent {
    background-color: #d4a373;
    color: white;
}

.btn-secondary-outline {
    background-color: #fcfaf7;
    color: #555;
    border: 2px solid #ddd;
    border-radius: 6px;
    padding: 10px 15px;
    cursor: pointer;
    font-weight: bold;
    white-space: nowrap;
    transition: background 0.2s;
}

.playground-form-row {
    display: flex;
    gap: 10px;
}

@media (max-width: 480px) {
    .page-title h1 {
        font-size: 1.8rem;
    }

    .grid-cards {
        grid-template-columns: 1fr;
    }

    .footer-links {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
}

/* === Global Mobile-Safe Inputs === */
/* フォーム要素が画面からはみ出さないよう全体に適用 */
input, textarea, select {
    max-width: 100%;
}

/* === Article Navigation === */
.article-navigation {
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 60px;
    padding-top: 30px;
    border-top: 1px solid #eaeaea;
}

.article-navigation .btn {
    flex-shrink: 0;
}

/* === Contact Form === */
.contact-form-container input,
.contact-form-container textarea {
    width: 100%;
    box-sizing: border-box;
}

/* === Sister Site Banner === */
.sister-site-banner {
    word-break: break-word;
}

/* === Dict List Mobile === */
@media (max-width: 600px) {
    .dict-list {
        grid-template-columns: 1fr;
    }
}

/* === Speech Balloon Mobile Fix === */
@media (max-width: 600px) {
    .speech-wrap {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .speech-wrap.sbp-r {
        align-items: flex-end;
    }

    .speech-balloon {
        max-width: 100%;
    }

    .speech-person {
        width: 60px;
    }

    .speech-icon {
        width: 60px;
        height: 60px;
    }
}
