/* ================================================
   BASE - MOMA + Universal Design
   ベーススタイル - リセット & タイポグラフィ基礎

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

   Contents:
   1. CSS Reset
   2. Base Styles
   3. Typography Base
   4. Accessibility Features
   ================================================ */

/* ========================================
   1. CSS RESET
   CSSリセット
   ======================================== */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html,
body {
    overflow-x: hidden;
    max-width: 100%;
    position: relative;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
    font-size: var(--font-size-base);
    line-height: var(--line-height-normal);
    color: var(--color-gray-800);
    background: var(--color-white);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    -webkit-text-size-adjust: 100%;

    /* Mobile scrolling optimization */
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain;
}

/* Japanese Font Support */
body[lang="ja"] {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Yu Gothic', 'Hiragino Kaku Gothic ProN', 'Meiryo', sans-serif;
}

/* Touch Device Optimization */
* {
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
}

/* Safe Area Support (iPhone X+) */
@supports (padding: max(0px)) {
    body {
        padding-left: max(0px, env(safe-area-inset-left));
        padding-right: max(0px, env(safe-area-inset-right));
    }
}

/* ========================================
   2. BASE STYLES
   基本スタイル
   ======================================== */

/* Container */
.container {
    max-width: var(--max-content-width);
    margin: 0 auto;
    padding: 0 var(--space-4);
}

/* ========================================
   3. TYPOGRAPHY BASE
   タイポグラフィ基礎
   ======================================== */

h1, h2, h3, h4, h5, h6 {
    font-weight: var(--font-weight-semibold);
    line-height: var(--line-height-tight);
    margin: 0 0 var(--space-4) 0;
    color: var(--color-gray-900);
}

/* Headings spacing */
h1 {
    margin-bottom: var(--space-6);
}

h2 {
    margin-top: var(--space-8);
    margin-bottom: var(--space-5);
}

h3 {
    margin-top: var(--space-6);
    margin-bottom: var(--space-4);
}

h4, h5, h6 {
    margin-top: var(--space-5);
    margin-bottom: var(--space-3);
}

/* First heading in container */
h1:first-child,
h2:first-child,
h3:first-child,
h4:first-child,
h5:first-child,
h6:first-child {
    margin-top: 0;
}

p {
    margin: 0 0 var(--space-4) 0;
    line-height: var(--line-height-relaxed);
}

/* Last paragraph in container */
p:last-child {
    margin-bottom: 0;
}

a {
    color: var(--color-accent);
    text-decoration: none;
    transition: color var(--transition-fast);
}

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

/* Section spacing */
section {
    margin-bottom: var(--space-8);
}

section:last-child {
    margin-bottom: 0;
}

/* Content spacing */
.content-wrapper > *:not(:last-child) {
    margin-bottom: var(--space-6);
}

/* Utility Classes */
.text-center {
    text-align: center;
}

.text-muted {
    color: var(--color-gray-600);
}

/* Spacing utilities */
.mb-1 { margin-bottom: var(--space-1); }
.mb-2 { margin-bottom: var(--space-2); }
.mb-3 { margin-bottom: var(--space-3); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-5 { margin-bottom: var(--space-5); }
.mb-6 { margin-bottom: var(--space-6); }
.mb-8 { margin-bottom: var(--space-8); }

.mt-1 { margin-top: var(--space-1); }
.mt-2 { margin-top: var(--space-2); }
.mt-3 { margin-top: var(--space-3); }
.mt-4 { margin-top: var(--space-4); }
.mt-5 { margin-top: var(--space-5); }
.mt-6 { margin-top: var(--space-6); }
.mt-8 { margin-top: var(--space-8); }

/* ========================================
   4. ACCESSIBILITY FEATURES
   アクセシビリティ機能
   ======================================== */

/* Keyboard Focus Visibility */
*:focus-visible {
    outline: var(--focus-outline-width) solid var(--focus-outline-color);
    outline-offset: var(--focus-outline-offset);
}

/* Screen Reader Only Text */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* Skip to Main Content Link */
.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: var(--color-accent);
    color: var(--color-white);
    padding: var(--space-2) var(--space-4);
    text-decoration: none;
    z-index: var(--z-modal);
}

.skip-link:focus {
    top: 0;
}

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

/* Print Styles */
@media print {
    body::before {
        display: none;
    }

    * {
        background: transparent !important;
        color: black !important;
        box-shadow: none !important;
        text-shadow: none !important;
    }
}
