/* MDUC Responsive Styles */

/* ===== TABLET STYLES (768px - 1024px) ===== */
@media (max-width: 1024px) and (min-width: 768px) {
    /* Main Layout */
    main#main-content {
        margin-left: 180px; /* Reduced space for floating menu */
        padding: 1.5rem;
    }
    
    /* Typography */
    h1 { font-size: 2.2rem; }
    h2 { font-size: 1.8rem; }
    h3 { font-size: 1.4rem; }
    
    /* Post Holder */
    .post-holder {
        padding: 1.5rem;
    }
    
    /* Welcome Section */
    .welcome-message {
        padding: 1.5em !important;
    }
    
    .welcome-message img {
        width: 120px !important;
    }
    
    .welcome-message h2 {
        font-size: 1.8em !important;
    }
    
    .welcome-message p {
        font-size: 1em !important;
    }
    
    /* Quick Links */
    .quick-links {
        flex-direction: column;
        gap: 1rem;
    }
    
    .quick-links a {
        width: 100%;
        text-align: center;
    }
    
    /* Step Items */
    .step-item {
        grid-template-columns: 60px 1fr;
    }
    
    .step-number {
        width: 50px;
        height: 50px;
        font-size: 1.5rem;
    }
    
    /* Cards */
    .card {
        padding: 1.5rem;
    }
    
    /* Download Items */
    .download-buttons {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .download-buttons a {
        width: 100%;
        text-align: center;
    }
    
    /* FAQ Section */
    .faq-item {
        padding: 1rem;
    }
    
    /* Footer */
    .footer-mduc-image {
        width: 180px;
        height: 180px;
    }
    
    /* Contact Form - Tablet */
    .contact-form > div[style*="grid-template-columns: 1fr 1fr"] {
        gap: 1.5em !important;
    }
}

/* ===== MOBILE STYLES (max-width: 767px) ===== */
@media (max-width: 767px) {
    /* Base Typography */
    body {
        font-size: 14px;
        overflow-x: hidden;
        width: 100%;
    }
    
    /* Main Layout */
    main#main-content {
        margin-left: 0;
        padding: 1rem;
        padding-bottom: 80px; /* Space for mobile menu */
    }
    
    /* Typography */
    h1 { 
        font-size: 1.8rem; 
        margin-bottom: 1rem;
    }
    h2 { 
        font-size: 1.5rem;
        margin-bottom: 1rem;
    }
    h3 { 
        font-size: 1.3rem;
        margin-bottom: 0.8rem;
    }
    h4 { font-size: 1.1rem; }
    
    /* Hero Section Mobile */
    .hero-section {
        position: relative;
        height: auto;
        min-height: 70vh;
        padding-bottom: 2rem;
    }
    
    .hero-content-layer {
        flex-direction: column;
        padding: 2rem 1rem;
        gap: 2rem;
    }
    
    .hero-title-panel {
        width: 100%;
        padding: 2rem 1.5rem;
        margin: 0;
    }
    
    .hero-main-title {
        font-size: 1.8rem;
        line-height: 1.3;
    }
    
    .hero-sub-title {
        font-size: 1rem;
    }
    
    .hero-mascot-container {
        width: 100%;
        max-width: 300px;
        margin: 0 auto;
    }
    
    .mduc-flipper {
        width: 100%;
        height: 300px;
    }
    
    #hero-spacer {
        display: none;
    }
    
    /* Post Holder */
    .post-holder {
        padding: 1rem;
        margin-bottom: 1.5rem;
        box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    }
    
    /* Welcome Section */
    .welcome-message {
        padding: 1rem !important;
    }
    
    .welcome-message img {
        width: 100px !important;
        margin-bottom: 0.5em !important;
    }
    
    .welcome-message h2 {
        font-size: 1.5em !important;
        margin-bottom: 0.5em;
    }
    
    .welcome-message p {
        font-size: 0.9em !important;
        line-height: 1.6;
    }
    
    .quick-links {
        margin-top: 1.5em !important;
        flex-direction: column;
        gap: 0.8rem;
    }
    
    .quick-links a {
        width: 100%;
        padding: 0.8em 1.2em;
        font-size: 0.9rem;
    }
    
    /* Section Layouts */
    section > div[style*="display: flex"] {
        flex-direction: column !important;
        gap: 1.5em !important;
    }
    
    /* MDUC Speech Containers - Mobile Optimization */
    .mduc-speech-container {
        display: flex !important;
        flex-direction: column !important;
        gap: 1rem !important;
        margin: 1.5rem 0 !important;
        padding: 1rem !important;
        background: #f8f9fa !important;
        border-radius: 8px !important;
    }
    
    .mduc-speech-image {
        text-align: center !important;
        margin: 0 auto !important;
    }
    
    .mduc-speech-image img {
        width: 80px !important;
        height: 80px !important;
        margin: 0 auto !important;
    }
    
    .mduc-speech-content {
        width: 100% !important;
        max-width: none !important;
    }
    
    .mduc-message {
        padding: 1rem !important;
        background: #ffffff !important;
        border-radius: 6px !important;
        box-shadow: 0 2px 4px rgba(0,0,0,0.05) !important;
    }
    
    .mduc-message p {
        font-size: 0.9rem !important;
        line-height: 1.6 !important;
        margin: 0 !important;
        text-align: center !important;
    }
    
    /* Fee Tables and Accordions - Mobile Optimization */
    .accordion {
        margin: 1rem 0;
    }
    
    .accordion summary {
        padding: 1rem;
        font-size: 1rem;
        cursor: pointer;
        background: #f0f0f0;
        border-radius: 6px;
        margin-bottom: 0.5rem;
    }
    
    .accordion-content {
        padding: 1rem;
        background: #fafafa;
        border-radius: 6px;
    }
    
    .fee-table-container {
        overflow-x: auto;
        margin: 1rem 0;
        background: white;
        border-radius: 6px;
        box-shadow: 0 2px 4px rgba(0,0,0,0.1);
        -webkit-overflow-scrolling: touch;
    }
    
    .fee-table {
        width: 100%;
        min-width: 400px; /* テーブルの最小幅を拡大 */
        border-collapse: collapse;
        table-layout: fixed; /* テーブルレイアウト固定 */
    }
    
    .fee-table th,
    .fee-table td {
        padding: 0.8rem 0.6rem; /* パディングを少し増やす */
        border-bottom: 1px solid #e0e0e0;
        font-size: 0.85rem; /* フォントサイズを小さくして余裕を作る */
        text-align: center;
        white-space: nowrap; /* テキストの折り返しを防ぐ */
        overflow: hidden;
        text-overflow: ellipsis;
    }
    
    .fee-table th:first-child,
    .fee-table td:first-child {
        width: 35%; /* 検査数列の幅 */
    }
    
    .fee-table th:nth-child(2),
    .fee-table td:nth-child(2) {
        width: 35%; /* 価格列の幅 */
    }
    
    .fee-table th:last-child,
    .fee-table td:last-child {
        width: 30%; /* 1件あたり列の幅 */
    }
    
    .fee-table th {
        background: #f8f9fa;
        font-weight: 600;
    }
    
    /* Text content improvements */
    .step-note,
    .fee-note {
        font-size: 0.85rem !important;
        line-height: 1.5 !important;
        color: #666 !important;
    }
    
    /* MDUCちゃん Images */
    div[style*="flex: 0 0 220px"] {
        flex: 1 1 auto !important;
        width: 100% !important;
        max-width: 200px !important;
        margin: 0 auto !important;
    }
    
    div[style*="flex: 0 0 220px"] img {
        width: 150px !important;
        height: 150px !important;
    }
    
    /* Content Areas */
    div[style*="flex: 1"] {
        min-width: 100% !important;
    }
    
    /* Step Items - Improved Mobile Layout */
    .step-item {
        display: flex;
        flex-direction: column;
        gap: 1rem;
        margin-bottom: 2rem;
        padding: 1rem;
        border-left: 4px solid #F39800;
        background: #fafafa;
    }
    
    .step-number {
        width: 60px;
        height: 60px;
        font-size: 1.5rem;
        margin: 0 auto 1rem;
        flex-shrink: 0;
    }
    
    .step-content h4 {
        font-size: 1.1rem;
        margin-bottom: 0.5rem;
    }
    
    .step-content p,
    .step-content ul,
    .step-content ol {
        font-size: 0.9rem;
    }
    
    /* Cards - Improved Mobile Layout */
    .card {
        padding: 1rem;
        margin-bottom: 1rem;
        border-radius: 8px;
    }
    
    .card-title {
        font-size: 1.3rem;
        margin-bottom: 0.8rem;
    }
    
    /* Nested Cards in Steps - Remove extra padding */
    .step-content .card {
        padding: 0.75rem;
        margin: 1rem 0;
        background: #ffffff;
        border: 1px solid #e0e0e0;
    }
    
    /* Step Subsections */
    .step-subsection {
        margin: 1.5rem 0;
        padding: 1rem;
        background: #f8f9fa;
        border-radius: 6px;
    }
    
    .step-subsection h5 {
        font-size: 1rem;
        margin-bottom: 1rem;
        color: #333;
    }
    
    /* Checklist Container - Full Width Mobile */
    .checklist-container {
        display: flex;
        flex-direction: column;
        gap: 0.75rem;
        margin: 1rem 0;
    }
    
    .checklist-item {
        display: flex;
        align-items: flex-start;
        gap: 0.75rem;
        padding: 0.75rem;
        background: #ffffff;
        border-radius: 4px;
        border: 1px solid #e8e8e8;
        line-height: 1.5;
    }
    
    .checklist-icon {
        color: #4CAF50;
        font-weight: bold;
        font-size: 1rem;
        flex-shrink: 0;
        margin-top: 0.1rem;
    }
    
    .checklist-text {
        font-size: 0.9rem;
        color: #333;
        flex: 1;
        word-wrap: break-word;
        overflow-wrap: break-word;
    }
    
    /* Download Items */
    .download-item {
        margin-bottom: 1.5rem;
    }
    
    .download-item h4 {
        font-size: 1rem;
        margin-bottom: 0.8rem;
    }
    
    .download-buttons {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .download-buttons a {
        width: 100%;
        padding: 0.8em 1.2em;
        font-size: 0.9rem;
    }
    
    /* Buttons */
    .btn-primary,
    .btn-secondary {
        padding: 0.8em 1.2em;
        font-size: 0.9rem;
    }
    
    /* FAQ Section */
    .faq-item {
        padding: 0.8rem;
        margin-bottom: 1rem;
    }
    
    .faq-item h4 {
        font-size: 1rem;
        margin-bottom: 0.5em;
    }
    
    .faq-item p {
        font-size: 0.9rem;
    }
    
    /* Contact Section */
    #contact > div[style*="display: flex"] {
        flex-direction: column;
        text-align: center;
    }
    
    #contact img {
        width: 120px !important;
        margin: 0 auto 1rem;
    }
    
    /* Contact Form */
    .contact-form {
        padding: 1.5em !important;
    }
    
    .contact-form > div[style*="grid-template-columns: 1fr 1fr"] {
        grid-template-columns: 1fr !important;
        gap: 1em !important;
    }
    
    .form-group {
        margin-bottom: 1.5em !important;
    }
    
    /* Lists */
    ul, ol {
        padding-left: 1.2rem;
    }
    
    li {
        margin-bottom: 0.5rem;
        font-size: 0.9rem;
    }
    
    /* Footer - モバイルでMDUCアニメーションを非表示 */
    .footer-mduc-section {
        display: none; /* モバイルでは非表示 */
    }
    
    .footer-mduc-image {
        display: none; /* モバイルでは非表示 */
    }
    
    .site-footer {
        padding: 1.5rem 1rem;
        font-size: 0.85rem;
    }
    
    .site-footer p[style*="margin-bottom: 1em"] {
        margin-bottom: 1.5em !important;
    }
    
    /* Section Divider */
    .section-divider {
        margin: 2rem 0;
    }
    
    /* Skip Link */
    .skip-link {
        padding: 0.5em 1em;
        font-size: 0.9rem;
    }
}

/* ===== MOBILE FLOATING MENU ===== */
@media (max-width: 767px) {
    /* Hide desktop floating menu */
    .floating-menu {
        display: none !important;
        visibility: hidden !important;
        opacity: 0 !important;
        pointer-events: none !important;
    }
    
    /* Mobile Bottom Navigation */
    .mobile-nav {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: rgba(255, 255, 255, 0.98);
        border-top: 1px solid #E0E0E0;
        box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
        z-index: 999;
        display: flex;
        justify-content: space-around;
        padding: 0.5rem 0;
        backdrop-filter: blur(10px);
        height: 60px; /* Fixed height for consistency */
    }
    
    /* Add padding to body to prevent content from being hidden */
    body {
        padding-bottom: 60px !important; /* Same as mobile nav height */
    }
    
    /* Ensure main content doesn't overlap with footer */
    main#main-content {
        padding-bottom: 120px; /* Extra space for MDUC animation */
    }
    
    .mobile-nav-item {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        padding: 0.2rem;
        color: #666;
        text-decoration: none;
        transition: all 0.3s ease;
        font-size: 0.65rem;
        min-width: 0;
        max-width: 20%;
    }
    
    .mobile-nav-item span {
        white-space: nowrap;
        overflow: visible;
        width: auto;
        text-align: center;
        line-height: 1.2;
    }
    
    .mobile-nav-item.active {
        color: #F39800;
    }
    
    .mobile-nav-item i {
        font-size: 1.2rem;
        margin-bottom: 0.2rem;
    }
}

/* ===== MDUC INTRO TEXT STYLES ===== */
.mduc-intro-text {
    font-size: 1.15em;
    line-height: 1.8;
    color: #333;
    margin: 0;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.highlight-underline {
    border-bottom: 2px solid #F39800;
    word-break: keep-all; /* 日本語の単語を分割しない */
}

/* 改行を防ぐクラス */
.no-break {
    white-space: nowrap;
    word-break: keep-all;
}

@media (max-width: 767px) {
    .mduc-intro-text {
        font-size: 0.95em;
        line-height: 1.7;
        word-break: keep-all;
        overflow-wrap: anywhere;
        hyphens: auto;
        text-align: left;
    }
    
    .mduc-intro-text br {
        display: none;
    }
    
    .highlight-underline {
        border-bottom-width: 1.5px;
        display: inline;
        word-break: keep-all;
    }
    
    /* その他のテキスト要素も改善 */
    p, .card p, .consultation-content p {
        word-wrap: break-word;
        overflow-wrap: break-word;
        line-height: 1.7;
        text-align: left;
        hyphens: auto;
    }
    
    .consultation-content h4 {
        word-wrap: break-word;
        overflow-wrap: break-word;
        line-height: 1.5;
    }
    
    .news-excerpt, .news-title {
        word-wrap: break-word;
        overflow-wrap: break-word;
        line-height: 1.6;
    }
}

/* ===== ULTRA SMALL DEVICES (max-width: 375px) ===== */
@media (max-width: 375px) {
    /* Further reduce padding and font sizes */
    main#main-content {
        padding: 0.5rem;
    }
    
    .post-holder {
        padding: 0.5rem;
    }
    
    h1 { font-size: 1.5rem; }
    h2 { font-size: 1.3rem; }
    h3 { font-size: 1.1rem; }
    
    .hero-main-title {
        font-size: 1.5rem;
    }
    
    .welcome-message h2 {
        font-size: 1.3em !important;
    }
    
    .welcome-message p {
        font-size: 0.85em !important;
    }
    
    /* Step Items - Even more compact for ultra small */
    .step-item {
        padding: 0.75rem;
        margin-bottom: 1.5rem;
    }
    
    .step-number {
        width: 50px;
        height: 50px;
        font-size: 1.3rem;
    }
    
    /* Nested elements more compact */
    .step-subsection {
        padding: 0.75rem;
        margin: 1rem 0;
    }
    
    .checklist-item {
        padding: 0.5rem;
    }
    
    .checklist-text {
        font-size: 0.85rem;
    }
    
    /* MDUC Speech containers more compact */
    .mduc-speech-container {
        padding: 0.75rem !important;
        margin: 1rem 0 !important;
    }
    
    .mduc-message {
        padding: 0.75rem !important;
    }
    
    .mduc-message p {
        font-size: 0.85rem !important;
    }
    
    /* Fee table adjustments for ultra small screens */
    .fee-table {
        min-width: 350px;
        font-size: 0.8rem;
    }
    
    .fee-table th,
    .fee-table td {
        padding: 0.6rem 0.4rem;
        font-size: 0.8rem;
    }
}

/* ===== LANDSCAPE ORIENTATION ADJUSTMENTS ===== */
@media (max-height: 600px) and (orientation: landscape) {
    .hero-section {
        min-height: auto;
    }
    
    .hero-content-layer {
        flex-direction: row;
        padding: 1rem;
    }
    
    .hero-title-panel {
        padding: 1.5rem;
    }
    
    .hero-mascot-container {
        max-width: 250px;
    }
    
    .mduc-flipper {
        height: 250px;
    }
}

/* ===== PRINT STYLES ===== */
@media print {
    .floating-menu,
    .mobile-nav,
    #animated-background-overlay,
    .hero-section {
        display: none !important;
    }
    
    main#main-content {
        margin-left: 0;
        padding: 0;
    }
    
    .post-holder {
        box-shadow: none;
        border: 1px solid #ddd;
        page-break-inside: avoid;
    }
}