/**
 * Hero Section Layout Styles
 * Implements CSS variables system and container queries according to technical specification
 */

/* CSS Variables System - Enhanced with comprehensive design tokens */
:root {
    /* Hero dimensions */
    --hero-min-height: 100vh;
    --hero-max-height: 120vh;
    --hero-padding-mobile: 2rem;
    --hero-padding-desktop: 4rem;
    --hero-padding-small: 1rem;
    --hero-padding-large: 6rem;

    /* Responsive breakpoints - 2-tier system */
    --breakpoint-mobile: 768px;
    --breakpoint-desktop: 768px; /* Unified with mobile breakpoint */
    --breakpoint-desktop-large: 1200px;
    --breakpoint-wide: 1400px;

    /* Performance optimization - Reduced motion support */
    --hero-transition-duration: 0.3s;
    --hero-transition-duration-fast: 0.15s;
    --hero-transition-duration-slow: 0.45s;
    --hero-transition-easing: cubic-bezier(0.4, 0, 0.2, 1);
    --hero-transition-easing-bounce: cubic-bezier(0.68, -0.55, 0.265, 1.55);

    /* Layout spacing with consistent scale */
    --hero-content-gap: 2rem;
    --hero-content-gap-small: 1rem;
    --hero-content-gap-large: 3rem;
    --hero-border-width: 1px;
    --hero-border-color: white;
    --hero-border-color-hover: rgba(255, 255, 255, 0.8);

    /* Typography scale */
    --hero-font-size-base: 1rem;
    --hero-font-size-small: 0.875rem;
    --hero-font-size-large: 1.25rem;
    --hero-font-weight-normal: 400;
    --hero-font-weight-medium: 500;
    --hero-font-weight-bold: 700;

    /* Color system */
    --hero-color-primary: #ffffff;
    --hero-color-secondary: #000000;
    --hero-color-accent: #f0f0f0;
    --hero-color-text: var(--hero-color-primary);
    --hero-color-background: var(--hero-color-secondary);

    /* Z-index management */
    --hero-z-index-background: 0;
    --hero-z-index-content: 2;
    --hero-z-index-navigation: 3;
    --hero-z-index-modal: 1000;

    /* Shadow system */
    --hero-shadow-small: 0 1px 3px rgba(0, 0, 0, 0.12);
    --hero-shadow-medium: 0 4px 6px rgba(0, 0, 0, 0.12);
    --hero-shadow-large: 0 10px 25px rgba(0, 0, 0, 0.15);

    /* Border radius system */
    --hero-border-radius-small: 0.25rem;
    --hero-border-radius-medium: 0.5rem;
    --hero-border-radius-large: 1rem;
}

/* Base Hero Section - Performance optimized with proper stacking context */
.hero-section-responsive {
    container-type: inline-size;
    height: 100vh;
    min-height: 100vh;
    max-height: 100vh;
    display: grid;
    place-items: center;
    position: relative;
    overflow: hidden;
    background-color: var(--hero-color-background);
    color: var(--hero-color-text);
    /* Create root stacking context for proper z-index management */
    z-index: 1;
    isolation: isolate;
    /* Performance optimizations */
    content-visibility: auto;
    contain-intrinsic-size: 100vw 100vh;
    /* GPU acceleration for smooth animations */
    transform: translateZ(0);
    will-change: auto;
    /* Prevent layout shifts */
    aspect-ratio: 16/9;
    min-aspect-ratio: 4/3;
    max-aspect-ratio: 21/9;
}

/* Hero Section Bottom Gradient Overlay - All Viewports */
.hero-section-responsive::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 30vh; /* ビューポート高さの30% */
    background: linear-gradient(to bottom, 
        rgba(0, 0, 0, 0) 0%,     /* 完全透明 */
        rgba(0, 0, 0, 0.3) 50%,  /* 30%透明 */
        rgba(0, 0, 0, 1) 100%    /* 完全不透明 */
    );
    pointer-events: none; /* クリックイベントを透過 */
    z-index: 5; /* コンテンツより上、UI要素より下 */
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .hero-section-responsive {
        --hero-border-color: var(--hero-color-primary);
        --hero-color-text: var(--hero-color-primary);
        border: 2px solid var(--hero-border-color);
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .hero-section-responsive,
    .hero-section-responsive * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* Error state styling */
.hero-section-responsive.hero-init-error {
    background: linear-gradient(45deg,
        var(--hero-color-background) 25%,
        rgba(255, 0, 0, 0.1) 25%,
        rgba(255, 0, 0, 0.1) 50%,
        var(--hero-color-background) 50%);
    background-size: 20px 20px;
}

.hero-section-responsive.hero-error-state::before {
    content: "⚠️ ヒーローセクションの読み込みに問題が発生しました";
    position: absolute;
    top: 1rem;
    left: 1rem;
    background: rgba(255, 0, 0, 0.9);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: var(--hero-border-radius-small);
    font-size: var(--hero-font-size-small);
    z-index: var(--hero-z-index-modal);
}

/* Content Container - Fixed stacking context issue */
.hero-content-wrapper {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--hero-content-gap);
    padding: var(--hero-padding-mobile);
    position: relative;
    z-index: var(--hero-z-index-content);
    /* Prevent creating new stacking context that interferes with background videos */
    isolation: auto;
}

/* Logo Container */
.hero-logo-container {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    max-width: 100%;
    aspect-ratio: 1180.38/199.66;
}

.hero-mobile-container {
    width: 90%;
    max-width: 500px;
    aspect-ratio: auto;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.hero-mobile-logo {
    width: 70%;
    max-width: 400px;
    aspect-ratio: 1180.38/199.66;
}

/* Container Queries for Mobile */
@container (max-width: 768px) {
    .hero-content-wrapper {
        padding: var(--hero-padding-mobile);
        text-align: center;
        gap: 1.5rem;
    }

    .hero-logo-container {
        width: clamp(70%, 80%, 90%);
        min-width: 250px;
    }

    .hero-text-content {
        padding: 0.75rem;
        gap: 0.75rem;
    }

    /* .hero-subtitle moved to main definition with responsive clamp */

    .hero-text-fallback {
        font-size: clamp(1.8rem, 4.5vw, 3rem);
        letter-spacing: 0.05em;
    }
}

/* Container Queries for Desktop */
@container (min-width: 769px) {
    .hero-content-wrapper {
        padding: var(--hero-padding-desktop);
        text-align: left;
    }

    .hero-logo-container {
        width: clamp(55%, 61.5%, 70%);
        min-width: 300px;
    }
}

/* Layout Variations */
.hero-section-responsive[data-layout="centered"] {
    text-align: center;
}

.hero-section-responsive[data-layout="centered"] .hero-content-wrapper {
    align-items: center;
    text-align: center;
}

.hero-section-responsive[data-layout="split"] {
    display: grid;
    grid-template-columns: 1fr 1fr;
    align-items: center;
}

.hero-section-responsive[data-layout="split"] .hero-content-wrapper {
    justify-content: flex-start;
}

/* Title Styles */
.hero-title-default,
.hero-title-centered,
.hero-title-primary {
    font-size: clamp(2rem, 5vw, 4rem);
    font-weight: 300;
    margin: 0;
    line-height: 1.2;
}

.hero-title-centered {
    text-align: center;
}

.hero-description-centered {
    text-align: center;
    font-size: clamp(1rem, 2.5vw, 1.5rem);
    margin-top: 1rem;
    opacity: 0.9;
}

.hero-title-split {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.hero-title-secondary {
    font-size: clamp(1.2rem, 3vw, 2rem);
    opacity: 0.8;
}

/* Text Content Styles */
.hero-text-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: 0.5rem;
    width: 100%;
    padding: 1rem;
    /* メインテキスト: サブタイトルより少し小さく設定 */
    font-size: clamp(1.125rem, 2.5vw, 1.75rem);
    line-height: 1.6;
    letter-spacing: 0.02em;
}

.hero-subtitle {
    /* サブタイトル: 現在より少し大きく設定 */
    font-size: clamp(1.5rem, 3.5vw, 2.25rem);
    font-weight: var(--hero-font-weight-medium);
    text-transform: uppercase;
    /* Responsive letter-spacing */
    letter-spacing: clamp(0.1em, 0.15em, 0.15em);
    margin: 0;
    opacity: 0.9;
    color: var(--hero-color-text);
}

/* Main text styling - inherits from hero-text-content */
.hero-main-text {
    margin: 0;
    line-height: 1.4;
    color: var(--hero-color-text);
    /* Font size is inherited from .hero-text-content */
}

/* Fallback text styling for hero-media */
.hero-text-fallback {
    font-size: clamp(2rem, 5vw, 3.5rem);
    font-weight: var(--hero-font-weight-bold);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    text-align: center;
    margin: 0;
    line-height: 1.1;
    color: var(--hero-color-text);
}

/* Navigation Styles */
.hero-navigation {
    position: absolute;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 3;
}

.hero-nav-container {
    display: flex;
    gap: 2rem;
    align-items: center;
}

/* CTA Styles */
.hero-cta-area {
    margin-top: 2rem;
    display: flex;
    justify-content: center;
}

.hero-cta-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 1rem 2rem;
    background: transparent;
    border: 2px solid white;
    color: white;
    text-decoration: none;
    transition: all var(--hero-transition-duration) var(--hero-transition-easing);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.hero-cta-button:hover,
.hero-cta-button:focus {
    background: white;
    color: black;
    transform: translateY(-2px);
}

.hero-cta-primary {
    background: white;
    color: black;
}

.hero-cta-primary:hover,
.hero-cta-primary:focus {
    background: transparent;
    color: white;
}

/* Background Media - Explicit z-index management */
.hero-background-image {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: var(--hero-z-index-background);
    background-repeat: no-repeat;
}

.hero-background-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.hero-video-background {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: var(--hero-z-index-background);
    overflow: hidden;
}

.hero-background-video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
}

/* Lazy Loading Placeholder */
.hero-lazy-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f0f0f0;
    color: #666;
    font-size: 0.875rem;
}

/* Performance Optimizations */
.hero-background-image {
    content-visibility: auto;
    contain-intrinsic-size: 100vh;
    /* Prevent layout shifts during loading */
    background-color: var(--hero-color-background);
}

.hero-logo-container img {
    content-visibility: auto;
    contain-intrinsic-size: 200px 100px;
    /* Improve loading experience */
    background: var(--hero-color-accent);
    border-radius: var(--hero-border-radius-small);
}

/* GPU Acceleration for animated elements */
.hero-animated-element {
    will-change: transform;
    transform: translateZ(0);
    backface-visibility: hidden;
    perspective: 1000px;
}

/* Enhanced Focus Management and Accessibility */
.hero-focus-ring:focus {
    outline: 3px solid var(--hero-color-primary);
    outline-offset: 2px;
    border-radius: var(--hero-border-radius-small);
    /* Ensure focus is visible in high contrast mode */
    box-shadow: 0 0 0 2px var(--hero-color-background),
                0 0 0 5px var(--hero-color-primary);
}

/* Skip link styling */
.sr-only {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

.sr-only:focus {
    position: static !important;
    width: auto !important;
    height: auto !important;
    padding: 0.5rem 1rem !important;
    margin: 0 !important;
    overflow: visible !important;
    clip: auto !important;
    white-space: normal !important;
    background: var(--hero-color-primary) !important;
    color: var(--hero-color-secondary) !important;
    text-decoration: none !important;
    border-radius: var(--hero-border-radius-small) !important;
    z-index: var(--hero-z-index-modal) !important;
}

/* ARIA live region for dynamic content */
.hero-announcements {
    position: absolute;
    left: -10000px;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

/* Enhanced contrast ratios */
@media (prefers-contrast: high) {
    .hero-focus-ring:focus {
        outline-width: 4px;
        outline-color: var(--hero-color-primary);
        background: var(--hero-color-secondary);
    }

    .hero-cta-button {
        border-width: 3px;
        font-weight: var(--hero-font-weight-bold);
    }
}

/* Forced colors mode support (Windows high contrast) */
@media (forced-colors: active) {
    .hero-section-responsive {
        forced-color-adjust: none;
        background: Canvas;
        color: CanvasText;
        border: 1px solid ButtonBorder;
    }

    .hero-cta-button {
        background: ButtonFace;
        color: ButtonText;
        border: 1px solid ButtonBorder;
    }

    .hero-focus-ring:focus {
        outline: 2px solid Highlight;
        background: Highlight;
        color: HighlightText;
    }
}

/* Container Queries for consistent responsive behavior */
@container (max-width: 767px) {
    .hero-section-responsive[data-layout="split"] {
        grid-template-columns: 1fr;
        grid-template-rows: auto;
    }

    .hero-mobile-container {
        min-height: clamp(400px, 70vh, 800px);
        max-height: 90vh;
    }
}

@container (max-width: 767px) {
    .hero-section-responsive {
        height: 100vh;
        min-height: 100vh;
        max-height: 100vh;
    }

    .hero-mobile-container {
        min-height: clamp(300px, 60vh, 500px);
        max-height: 80vh;
    }

    /* モバイル画面でのグラデーション調整 */
    .hero-section-responsive::after {
        height: 28vh; /* モバイルでは少し調整 */
    }
}

@media (max-width: 375px) {
    .hero-mobile-container {
        width: 95%;
        min-height: clamp(350px, 65vh, 700px);
        padding: 0.75rem;
    }

    /* 小画面でのグラデーション調整 */
    .hero-section-responsive::after {
        height: 25vh; /* 小画面では少し小さく */
    }

    .hero-mobile-logo {
        width: 80%;
        min-width: 200px;
    }
}

@media (max-width: 320px) {
    .hero-section-responsive {
        height: 100vh;
        min-height: 100vh;
        max-height: 100vh;
        padding: 0;
    }

    .hero-mobile-container {
        width: 98%;
        min-height: clamp(280px, 55vh, 450px);
        padding: 0.5rem;
    }

    .hero-mobile-logo {
        width: 85%;
        min-width: 180px;
    }
}