/* ================================================
   RESPONSIVE - MOMA + Universal Design
   レスポンシブデザイン - モバイルファースト

   Created: 2025-10-31
   Design System: MOMA Minimalism + WCAG 2.1 AA

   Contents:
   1. Mobile-First Base Styles
   2. Typography (Responsive + H2 Left Accent Bar)
   3. Layout Responsive
   4. Component Responsive
   5. Tablet (768px+)
   6. Desktop (1024px+)
   7. Accessibility (@media prefers-*)
   ================================================ */

/* ========================================
   1. MOBILE-FIRST BASE STYLES
   モバイルファースト基本スタイル
   ======================================== */

/* Mobile: Default (320px+) */

.container {
    max-width: 100%;
    padding: 0 var(--space-4);
    margin: 0 auto;
}

/* Content Area */
.content-header {
    margin-bottom: var(--space-6);
}

.content-title {
    font-size: var(--font-size-2xl);
    font-weight: var(--font-weight-bold);
    color: var(--color-gray-900);
    margin-bottom: var(--space-3);
}

.content-description {
    font-size: var(--font-size-lg);
    color: var(--color-gray-600);
    line-height: var(--line-height-relaxed);
}

/* ========================================
   2. TYPOGRAPHY - MOMA Minimalist
   タイポグラフィ - MOMAミニマリスト
   ======================================== */

/* Mobile Typography (Default) */

h1 {
    font-size: clamp(1.5rem, 4vw, 2.25rem);  /* 24-36px */
    font-weight: var(--font-weight-bold);
    line-height: var(--line-height-tight);
    margin-top: 0;
    margin-bottom: var(--space-6);
}

h2 {
    font-size: clamp(1.25rem, 3vw, 1.875rem);  /* 20-30px */
    font-weight: var(--font-weight-semibold);
    line-height: var(--line-height-tight);
    margin-top: var(--space-8);
    margin-bottom: var(--space-5);
}

/* First heading in section/card - no top margin */
h2:first-child {
    margin-top: 0;
}

h3 {
    font-size: clamp(1.125rem, 2.5vw, 1.5rem);  /* 18-24px */
    font-weight: var(--font-weight-semibold);
    line-height: var(--line-height-tight);
    margin-top: var(--space-6);
    margin-bottom: var(--space-4);
}

h3:first-child {
    margin-top: 0;
}

h4 {
    font-size: clamp(1rem, 2vw, 1.25rem);  /* 16-20px */
    font-weight: var(--font-weight-medium);
    line-height: var(--line-height-normal);
    margin-top: var(--space-5);
    margin-bottom: var(--space-3);
}

h4:first-child {
    margin-top: 0;
}

h5 {
    font-size: var(--font-size-lg);
    font-weight: var(--font-weight-medium);
    line-height: var(--line-height-normal);
    margin-top: var(--space-4);
    margin-bottom: var(--space-3);
}

h6 {
    font-size: var(--font-size-base);
    font-weight: var(--font-weight-medium);
    line-height: var(--line-height-normal);
    margin-top: var(--space-3);
    margin-bottom: var(--space-2);
}

/* Card Titles - No special styling needed */
.card h2,
.card-header h2,
h2.card-title {
    /* Inherits h2 bottom border style */
}

/* Lists */
ul, ol {
    margin: var(--space-5) 0;
    padding-left: var(--space-8);
    line-height: var(--line-height-relaxed);
}

li {
    margin-bottom: var(--space-3);
    line-height: var(--line-height-relaxed);
}

/* Nested lists */
li > ul,
li > ol {
    margin-top: var(--space-2);
    margin-bottom: var(--space-2);
}

/* Last list item */
li:last-child {
    margin-bottom: 0;
}

/* Blockquote - MOMA Style */
blockquote {
    margin: var(--space-6) 0;
    padding-left: var(--space-6);
    border-left: 3px solid var(--color-accent);
    color: var(--color-gray-700);
    font-style: italic;
}

/* Code */
code {
    font-family: 'Monaco', 'Courier New', monospace;
    font-size: var(--font-size-sm);
    background: var(--color-gray-100);
    padding: var(--space-1) var(--space-2);
    border-radius: var(--radius-sm);
}

pre {
    background: var(--color-gray-100);
    padding: var(--space-4);
    border-radius: var(--radius-md);
    overflow-x: auto;
    margin: var(--space-4) 0;
}

pre code {
    background: none;
    padding: 0;
}

/* ========================================
   3. LAYOUT RESPONSIVE
   レイアウトレスポンシブ
   ======================================== */

/* Mobile: Sidebar controlled by layout.css transform
   (removed display:none to allow transform animation) */

/* Mobile: Full width content */
.main-content {
    padding: var(--space-4);
}

/* Breadcrumbs */
.breadcrumb,
.breadcrumblist {
    font-size: var(--font-size-sm);
    padding: var(--space-2) var(--space-3);
    margin: 0 0 var(--space-4) 0;
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
    background: var(--color-gray-50);
    border: var(--border-width-thin) solid var(--border-color-light);
    border-radius: var(--radius-md);
}

.breadcrumb-item,
.breadcrumblist li {
    display: inline-flex;
    align-items: center;
}

.breadcrumb-item a,
.breadcrumblist li a {
    padding: var(--space-1) var(--space-2);
    border-radius: var(--radius-sm);
    color: var(--color-accent);
    transition: background var(--transition-fast);
}

.breadcrumb-item a:hover,
.breadcrumblist li a:hover {
    background: var(--color-gray-100);
}

.breadcrumb-item + .breadcrumb-item::before,
.breadcrumblist li + li::before {
    content: '/';
    padding: 0 var(--space-2);
    color: var(--color-gray-400);
}

/* ========================================
   4. COMPONENT RESPONSIVE
   コンポーネントレスポンシブ
   ======================================== */

/* Mobile: Stacked Form Layouts */
.form-row {
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
}

/* Mobile: Full Width Buttons */
.btn-group {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}

.btn-group .btn {
    width: 100%;
}

/* Mobile: Copy Button Overlap Prevention */
@media (max-width: 768px) {
    .textarea-wrapper .form-textarea {
        padding-top: 48px;
    }

    .result-display-wrapper .form-textarea {
        padding-bottom: 48px;
    }

    /* Mobile: Card Spacing */
    .card {
        padding: var(--space-6);
        margin-bottom: var(--space-4);
    }

    /* Mobile: Alert Stacking */
    .alert {
        flex-direction: column;
        align-items: flex-start;
    }

    .alert-actions {
        margin-top: var(--space-2);
        align-self: stretch;
    }
}

/* ========================================
   5. SMALL MOBILE (≤640px)
   スマホ対応（さらに小さい画面）
   ======================================== */

@media (max-width: 640px) {
    /* Typography - Smaller for mobile */
    h1 {
        font-size: clamp(1.25rem, 5vw, 1.5rem);  /* 20-24px */
    }

    h2 {
        font-size: clamp(1.125rem, 4vw, 1.25rem);  /* 18-20px */
    }

    h3 {
        font-size: clamp(1rem, 3vw, 1.125rem);  /* 16-18px */
    }

    h4 {
        font-size: clamp(0.875rem, 2.5vw, 1rem);  /* 14-16px */
    }

    .content-title {
        font-size: clamp(1.25rem, 4vw, 1.5rem);  /* 20-24px */
    }

    .content-description {
        font-size: var(--font-size-sm);  /* 14px */
    }

    /* Card padding reduction */
    .card {
        padding: var(--space-4);
    }

    .card-title {
        font-size: var(--font-size-lg);  /* 18px */
    }

    /* Main content padding */
    .main-content {
        padding: var(--space-3);
    }

    /* Content header */
    .content-header {
        margin-bottom: var(--space-4);
    }
}

/* ========================================
   6. TABLET (768px+)
   タブレット対応
   ======================================== */

@media (min-width: 768px) {
    /* Container */
    .container {
        padding: 0 var(--space-6);
    }

    /* Sidebar Visible */
    .sidebar {
        display: block;
    }

    /* Content */
    .main-content {
        padding: var(--space-8);
    }

    /* Typography Adjustments */
    h1 {
        font-size: clamp(1.875rem, 4vw, 2.25rem);  /* 30-36px */
    }

    h2 {
        font-size: clamp(1.5rem, 3vw, 1.875rem);  /* 24-30px */
    }

    h3 {
        font-size: clamp(1.25rem, 2.5vw, 1.5rem);  /* 20-24px */
    }

    /* Form Layouts - Side by Side */
    .form-row {
        flex-direction: row;
        gap: var(--space-6);
    }

    .form-row > * {
        flex: 1;
    }

    /* Button Groups - Horizontal */
    .btn-group {
        flex-direction: row;
        justify-content: flex-start;
    }

    .btn-group .btn {
        width: auto;
    }

    /* Card Spacing */
    .card {
        padding: var(--space-8);
        margin-bottom: var(--space-6);
    }

    /* Alert Horizontal */
    .alert {
        flex-direction: row;
        align-items: flex-start;
    }

    .alert-actions {
        margin-top: 0;
        align-self: auto;
    }

    /* Copy Button - No Overlap */
    .textarea-wrapper .form-textarea,
    .result-display-wrapper .form-textarea {
        padding-top: var(--space-3);
        padding-bottom: var(--space-3);
    }

    /* Touch Targets - Smaller OK on Desktop */
    .btn {
        min-height: var(--touch-target-desktop);
    }

    .form-control,
    .form-textarea,
    .form-select {
        min-height: var(--touch-target-desktop);
        font-size: var(--font-size-sm);
    }
}

/* ========================================
   7. DESKTOP (1024px+)
   デスクトップ対応
   ======================================== */

@media (min-width: 1024px) {
    /* Container */
    .container {
        max-width: var(--max-content-width);
    }

    /* Content */
    .main-content {
        padding: var(--space-12);
    }

    /* Typography - Maximum Sizes */
    h1 {
        font-size: var(--font-size-4xl);  /* 36px */
    }

    h2 {
        font-size: var(--font-size-3xl);  /* 30px */
    }

    h3 {
        font-size: var(--font-size-2xl);  /* 24px */
    }

    h4 {
        font-size: var(--font-size-xl);  /* 20px */
    }

    /* Grid Layouts */
    .grid-2 {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: var(--space-8);
    }

    .grid-3 {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: var(--space-8);
    }

    .grid-4 {
        display: grid;
        grid-template-columns: repeat(4, 1fr);
        gap: var(--space-6);
    }

    /* Related Tools Grid */
    .related-tools {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: var(--space-6);
    }
}

/* ========================================
   8. ACCESSIBILITY (@media prefers-*)
   アクセシビリティ対応
   ======================================== */

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }

    /* Remove transform animations */
    .btn:hover,
    .copy-btn:hover {
        transform: none !important;
    }
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
    /* Increase border visibility */
    .card,
    .alert,
    .form-control,
    .form-textarea,
    .form-select {
        border-width: var(--border-width-medium);
    }

    /* Stronger shadows */
    .card-elevated {
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    }

    /* Bolder text */
    h1, h2, h3, h4, h5, h6 {
        font-weight: var(--font-weight-bold);
    }
}

/* Dark Mode Support (Disabled for now) */
/*
@media (prefers-color-scheme: dark) {
    :root {
        --color-white: #111827;
        --color-gray-50: #1f2937;
        --color-gray-100: #374151;
        --color-gray-800: #f9fafb;
        --color-gray-900: #ffffff;
    }
}
*/

/* ========================================
   PRINT STYLES
   印刷スタイル
   ======================================== */

@media print {
    /* Hide Navigation */
    .sidebar,
    .topbar,
    .site-header,
    .breadcrumb,
    .footer {
        display: none !important;
    }

    /* Remove Shadows & Borders */
    * {
        box-shadow: none !important;
        background: white !important;
        color: black !important;
    }

    /* Page Breaks */
    h1, h2, h3, h4, h5, h6 {
        page-break-after: avoid;
    }

    .card {
        page-break-inside: avoid;
    }

    /* Links */
    a[href]:after {
        content: " (" attr(href) ")";
    }

    /* Remove H2 Accent Bar for Print */
    h2::before {
        display: none;
    }
}

/* ========================================
   MOBILE UTILITIES
   モバイルユーティリティ
   ======================================== */

/* Show/Hide based on screen size */
.mobile-only {
    display: block;
}

.desktop-only {
    display: none;
}

@media (min-width: 768px) {
    .mobile-only {
        display: none;
    }

    .desktop-only {
        display: block;
    }
}

/* ========================================
   LANGUAGE SELECTOR
   言語セレクター
   ======================================== */

#selectLang {
    margin: var(--space-4) 0;
    padding: var(--space-4);
    background: var(--color-gray-50);
    border: var(--border-width-thin) solid var(--border-color-light);
    border-radius: var(--radius-md);
}

#selectLang span {
    display: block;
    margin-bottom: var(--space-2);
    font-weight: var(--font-weight-semibold);
    color: var(--color-gray-800);
}

#selectLang select {
    width: 100%;
    max-width: 400px;
    padding: var(--space-3) var(--space-10) var(--space-3) var(--space-4);
    font-size: 16px;  /* iOS zoom prevention */
    border: var(--border-width-thin) solid var(--border-color-base);
    border-radius: var(--radius-md);
    background: var(--color-white);
    cursor: pointer;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%230066cc' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right var(--space-3) center;
    transition: all var(--transition-base);
}

#selectLang select:focus {
    outline: none;
    border-color: var(--color-accent);
    box-shadow: var(--shadow-focus);
}

#selectLang select:hover:not(:focus) {
    border-color: var(--border-color-dark);
}
