/* ==============================================
   산림청 안전보건 전자책 스타일시트
   ============================================== */

/* CSS 변수 정의 (CSS Custom Properties) */
:root {
    /* 컬러 팔레트 */
    --primary-color: #4a7c59;
    --secondary-color: #6b8e6b;
    --accent-color: #8bc34a;
    --text-primary: #333;
    --text-secondary: #666;
    --text-light: #b0b0b0;
    --background-primary: #f5f5f5;
    --background-card: #ffffff;
    --background-dark: #1a1a1a;
    --background-card-dark: #2d2d2d;
    
    /* 그라디언트 */
    --gradient-primary: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    --gradient-background: linear-gradient(rgba(0,0,0,0.4), rgba(0,0,0,0.4));
    --gradient-card-top: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
    --gradient-icon: linear-gradient(135deg, #e8f5e8, #d4edd4);
    --gradient-shimmer: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    
    /* 간격 및 크기 */
    --spacing-xs: 10px;
    --spacing-sm: 15px;
    --spacing-md: 20px;
    --spacing-lg: 30px;
    --spacing-xl: 50px;
    
    --border-radius-sm: 15px;
    --border-radius-md: 25px;
    --border-radius-full: 50%;
    
    /* 그림자 */
    --shadow-card: 0 10px 30px rgba(0,0,0,0.1);
    --shadow-card-hover: 0 20px 40px rgba(0,0,0,0.15);
    --shadow-button: 0 5px 15px rgba(74, 124, 89, 0.3);
    --shadow-text: 2px 2px 4px rgba(0,0,0,0.3);
    
    /* 트랜지션 */
    --transition-default: all 0.3s ease;
    --transition-fast: all 0.2s ease;
    --transition-slow: all 0.5s ease;
    
    /* 애니메이션 지속시간 */
    --animation-duration-fast: 0.8s;
    --animation-duration-slow: 1s;
    --animation-rotation: 10s;
}

/* ==============================================
   기본 리셋 및 베이스 스타일
   ============================================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

*:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: 'Noto Sans KR', 'Malgun Gothic', Arial, sans-serif;
    line-height: 1.6;
    color: var(--text-primary);
    background-color: var(--background-primary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ==============================================
   헤더 섹션 스타일
   ============================================== */
.header {
    background: var(--gradient-background), 
                url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1200 600"><rect fill="%234a7c59" width="1200" height="600"/><circle fill="%236b8e6b" cx="200" cy="100" r="50" opacity="0.3"/><circle fill="%235a7a5a" cx="800" cy="200" r="80" opacity="0.2"/><circle fill="%236b8e6b" cx="400" cy="400" r="60" opacity="0.3"/><circle fill="%235a7a5a" cx="1000" cy="300" r="70" opacity="0.2"/></svg>');
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    height: 50vh;
    min-height: 300px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    color: white;
    position: relative;
    overflow: hidden;
}

.header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><path d="M20,80 Q50,60 80,80 L80,100 L20,100 Z" fill="%2300000020"/></svg>');
    background-size: 50px 50px;
    opacity: 0.1;
    animation: backgroundMove 20s ease-in-out infinite;
}

.header h1 {
    font-size: clamp(2rem, 5vw, 4rem);
    font-weight: 700;
    margin-bottom: 1rem;
    text-shadow: var(--shadow-text);
    z-index: 1;
    position: relative;
    letter-spacing: 0.02em;
}

.header h2 {
    font-size: clamp(1.2rem, 3vw, 2rem);
    font-weight: 400;
    margin-bottom: 2rem;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.3);
    z-index: 1;
    position: relative;
    letter-spacing: 0.01em;
}

/* ==============================================
   메인 콘텐츠 영역
   ============================================== */
.main-content {
    max-width: 1200px;
    margin: -100px auto 0;
    padding: 0 var(--spacing-md);
    position: relative;
    z-index: 2;
}

/* ==============================================
   카드 그리드 시스템
   ============================================== */
.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: var(--spacing-lg);
    margin-bottom: var(--spacing-xl);
}

/* ==============================================
   카드 컴포넌트
   ============================================== */
.card {
    background: var(--background-card);
    border-radius: 20px;
    padding: 40px 30px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.08);
    transition: var(--transition-default);
    position: relative;
    overflow: visible;
    min-height: 220px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    border: none;
}

.card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 30px rgba(0,0,0,0.12);
}

.card:focus-within {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* ==============================================
   카드 아이콘
   ============================================== */
.card-icon {
    width: 90px;
    height: 90px;
    border-radius: 50%;
    background: rgba(74, 124, 89, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 25px;
    position: relative;
    border: none;
}

.card-icon::before {
    content: '🐾';
    font-size: 2.5rem;
    position: relative;
    z-index: 1;
    opacity: 0.8;
}

/* 각 카드별 아이콘 */
.card:nth-child(1) .card-icon::before { content: '🌲'; }
.card:nth-child(2) .card-icon::before { content: '🌱'; }
.card:nth-child(3) .card-icon::before { content: '📚'; }
.card:nth-child(4) .card-icon::before { content: '⚖️'; }
.card:nth-child(5) .card-icon::before { content: '📋'; }

/* ==============================================
   카드 텍스트 요소
   ============================================== */
.card-title {
    font-size: 1.2rem;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 20px;
    letter-spacing: 0.02em;
}

.card-subtitle {
    display: none;
}

.card-description {
    display: none;
}

/* ==============================================
   다운로드 버튼
   ============================================== */
.download-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 12px 30px;
    border-radius: 10px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition-default);
    margin-top: 0;
    position: relative;
    overflow: hidden;
    letter-spacing: 0.01em;
    min-width: 180px;
}

.download-btn:hover {
    background: var(--secondary-color);
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(74, 124, 89, 0.3);
}

.download-btn:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

.download-btn:active {
    transform: translateY(0);
}

/* ==============================================
   애니메이션 정의
   ============================================== */
@keyframes rotate {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(50px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes backgroundMove {
    0%, 100% { transform: translateX(0) translateY(0); }
    25% { transform: translateX(10px) translateY(-5px); }
    50% { transform: translateX(-5px) translateY(10px); }
    75% { transform: translateX(-10px) translateY(-10px); }
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

/* ==============================================
   유틸리티 클래스
   ============================================== */
.fade-in {
    opacity: 0;
    animation: fadeIn var(--animation-duration-slow) ease-in forwards;
}

.slide-up {
    opacity: 0;
    transform: translateY(50px);
    animation: slideUp var(--animation-duration-fast) ease-out forwards;
}

.touch-active {
    transform: scale(0.98);
    transition: transform 0.1s ease;
}

/* ==============================================
   반응형 디자인 - 태블릿
   ============================================== */
@media (max-width: 768px) {
    :root {
        --spacing-lg: 25px;
        --spacing-xl: 40px;
    }
    
    .header {
        height: 40vh;
        min-height: 250px;
        background-attachment: scroll;
    }
    
    .main-content {
        margin: -50px auto 0;
        padding: 0 var(--spacing-sm);
    }
    
    .cards-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: var(--spacing-md);
    }
    
    .card {
        padding: 30px 20px;
        min-height: 200px;
    }
    
    .card-icon {
        width: 80px;
        height: 80px;
        margin-bottom: 20px;
    }
    
    .card-icon::before {
        font-size: 2.2rem;
    }
    
    .card-title {
        font-size: 1.1rem;
        margin-bottom: 18px;
    }
}

/* ==============================================
   반응형 디자인 - 모바일
   ============================================== */
@media (max-width: 480px) {
    :root {
        --spacing-md: 15px;
        --spacing-lg: 20px;
        --spacing-xl: 30px;
    }
    
    .header {
        height: 35vh;
        min-height: 200px;
    }
    
    .cards-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .card {
        padding: 25px 20px;
        min-height: 180px;
    }
    
    .card-icon {
        width: 70px;
        height: 70px;
        margin-bottom: 18px;
    }
    
    .card-icon::before {
        font-size: 2rem;
    }
    
    .card-title {
        font-size: 1.1rem;
        margin-bottom: 16px;
    }
    
    .download-btn {
        padding: 10px 24px;
        font-size: 0.85rem;
        min-width: 110px;
    }
}

/* ==============================================
   접근성 및 사용성 개선
   ============================================== */
@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;
    }
}

@media (prefers-contrast: high) {
    :root {
        --text-primary: #000000;
        --text-secondary: #333333;
        --background-card: #ffffff;
    }
    
    .card {
        border: 2px solid var(--primary-color);
    }
}

/* ==============================================
   다크 모드 지원
   ============================================== */
@media (prefers-color-scheme: dark) {
    :root {
        --text-primary: #e0e0e0;
        --text-secondary: var(--text-light);
        --background-primary: var(--background-dark);
        --background-card: var(--background-card-dark);
    }
    
    body {
        background-color: var(--background-dark);
        color: var(--text-primary);
    }
    
    .card {
        background: var(--background-card-dark);
        color: var(--text-primary);
        border-color: rgba(139, 195, 74, 0.2);
    }
    
    .card-title {
        color: var(--accent-color);
    }
    
    .card-description {
        color: var(--text-light);
    }
    
    .card-icon {
        background: linear-gradient(135deg, #2d4a2d, #3d5a3d);
        border-color: rgba(255, 255, 255, 0.1);
    }
}

/* ==============================================
   인쇄 스타일
   ============================================== */
@media print {
    .header {
        height: auto;
        min-height: auto;
        background: none;
        color: black;
        page-break-after: avoid;
    }
    
    .card {
        break-inside: avoid;
        box-shadow: none;
        border: 1px solid #ccc;
        margin-bottom: 20px;
    }
    
    .download-btn {
        display: none;
    }
    
    .card-icon::after {
        display: none;
    }
}

/* 목차 링크 스타일 */
.toc-link {
    text-decoration: none;
    color: inherit;
    display: block;
    padding: 3px 0;
    transition: color 0.2s;
}

.toc-link:hover {
    color: #4a7c59;
    text-decoration: underline;
}

.toc-link:focus {
    outline: 2px solid #4a7c59;
    outline-offset: 2px;
}