/*
 * 반응형 웹 디자인 예제 스타일시트
 * Mobile First 접근법
 */

/* ============================================
   CSS 변수 (Custom Properties)
   ============================================ */
:root {
    --primary-color: #3498db;
    --secondary-color: #2ecc71;
    --dark-color: #2c3e50;
    --light-color: #ecf0f1;
    --text-color: #333;

    /* 반응형 여백 */
    --spacing-sm: 10px;
    --spacing-md: 20px;
    --spacing-lg: 40px;
}

/* ============================================
   기본 스타일 (모바일 우선)
   ============================================ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: var(--text-color);
    background-color: #f5f5f5;
}

.container {
    width: 100%;
    padding: var(--spacing-sm);
}

/* ============================================
   네비게이션
   ============================================ */
.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    background-color: var(--dark-color);
    padding: 15px var(--spacing-sm);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.logo {
    color: white;
    font-size: 1.25rem;
    font-weight: bold;
}

.menu-toggle {
    display: block;
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
}

.nav-links {
    display: none;
    width: 100%;
    list-style: none;
    flex-direction: column;
    margin-top: 15px;
}

.nav-links.active {
    display: flex;
}

.nav-links li a {
    display: block;
    color: white;
    text-decoration: none;
    padding: 10px 0;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.nav-links li a:hover {
    color: var(--primary-color);
}

/* ============================================
   메인 콘텐츠
   ============================================ */
h1 {
    font-size: 1.75rem;
    margin: var(--spacing-md) 0;
    text-align: center;
}

.lead {
    text-align: center;
    color: #666;
    margin-bottom: var(--spacing-md);
}

.section {
    background: white;
    padding: var(--spacing-md);
    margin-bottom: var(--spacing-md);
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

h2 {
    font-size: 1.25rem;
    color: var(--dark-color);
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--primary-color);
}

/* ============================================
   뷰포트 인디케이터
   ============================================ */
.viewport-indicator span {
    display: none;
    padding: 15px;
    background: var(--primary-color);
    color: white;
    border-radius: 8px;
    font-size: 1.25rem;
    text-align: center;
}

.viewport-indicator .mobile { display: block; }

/* ============================================
   반응형 그리드
   ============================================ */
.responsive-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
}

.grid-item {
    background: var(--primary-color);
    color: white;
    padding: 30px;
    text-align: center;
    border-radius: 8px;
    font-size: 1.5rem;
    font-weight: bold;
}

/* ============================================
   반응형 카드
   ============================================ */
.card-grid {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
}

.card {
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.card-image {
    height: 150px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.5rem;
}

.card-content {
    padding: var(--spacing-md);
}

.card-content h3 {
    margin-bottom: 10px;
}

.card-content p {
    color: #666;
    margin-bottom: 15px;
}

.btn {
    display: inline-block;
    padding: 10px 20px;
    background: var(--primary-color);
    color: white;
    text-decoration: none;
    border-radius: 4px;
    border: none;
    cursor: pointer;
    font-size: 1rem;
}

.btn:hover {
    background: #2980b9;
}

.btn-primary {
    width: 100%;
}

/* ============================================
   반응형 타이포그래피
   ============================================ */
.responsive-heading {
    /* clamp(최소값, 선호값, 최대값) */
    font-size: clamp(1.5rem, 5vw, 3rem);
    color: var(--dark-color);
    margin-bottom: 15px;
}

.responsive-text {
    font-size: clamp(0.875rem, 2vw, 1.125rem);
    line-height: 1.8;
}

code {
    background: var(--light-color);
    padding: 2px 6px;
    border-radius: 3px;
    font-family: monospace;
}

/* ============================================
   반응형 이미지
   ============================================ */
.image-container {
    text-align: center;
}

.responsive-image {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
}

.caption {
    margin-top: 10px;
    font-size: 0.875rem;
    color: #666;
}

/* ============================================
   반응형 테이블
   ============================================ */
.table-container {
    overflow-x: auto;
}

.responsive-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 600px;
}

.responsive-table th,
.responsive-table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid #ddd;
}

.responsive-table th {
    background: var(--dark-color);
    color: white;
}

.responsive-table tbody tr:hover {
    background: #f5f5f5;
}

/* 모바일 테이블 스타일 */
@media (max-width: 600px) {
    .responsive-table {
        min-width: auto;
    }

    .responsive-table thead {
        display: none;
    }

    .responsive-table tbody tr {
        display: block;
        margin-bottom: 15px;
        border: 1px solid #ddd;
        border-radius: 8px;
        padding: 10px;
    }

    .responsive-table td {
        display: flex;
        justify-content: space-between;
        border-bottom: 1px solid #eee;
        padding: 8px 0;
    }

    .responsive-table td:last-child {
        border-bottom: none;
    }

    .responsive-table td::before {
        content: attr(data-label);
        font-weight: bold;
        color: var(--dark-color);
    }
}

/* ============================================
   반응형 폼
   ============================================ */
.responsive-form {
    max-width: 100%;
}

.form-row {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
}

.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
    color: var(--dark-color);
}

.form-group input,
.form-group textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1rem;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 5px rgba(52, 152, 219, 0.3);
}

/* ============================================
   코드 블록
   ============================================ */
pre {
    background: #2c3e50;
    color: #ecf0f1;
    padding: 15px;
    border-radius: 8px;
    overflow-x: auto;
    font-size: 0.875rem;
    line-height: 1.5;
}

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

/* ============================================
   푸터
   ============================================ */
.footer {
    background: var(--dark-color);
    color: white;
    padding: var(--spacing-md);
    margin-top: var(--spacing-lg);
}

.footer-content {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
}

.footer-section h3 {
    margin-bottom: 10px;
    color: var(--primary-color);
}

.footer-section ul {
    list-style: none;
}

.footer-section ul li a {
    color: #bdc3c7;
    text-decoration: none;
}

.footer-section ul li a:hover {
    color: white;
}

.social-links {
    display: flex;
    gap: 15px;
    font-size: 1.5rem;
}

.social-links a {
    text-decoration: none;
}

.footer-bottom {
    margin-top: var(--spacing-md);
    padding-top: var(--spacing-md);
    border-top: 1px solid rgba(255,255,255,0.1);
    text-align: center;
    color: #7f8c8d;
}

/* ============================================
   태블릿 (576px 이상)
   ============================================ */
@media (min-width: 576px) {
    :root {
        --spacing-sm: 15px;
        --spacing-md: 25px;
    }

    .viewport-indicator .mobile { display: none; }
    .viewport-indicator .tablet { display: block; }

    .responsive-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .form-row {
        flex-direction: row;
    }

    .form-row .form-group {
        flex: 1;
    }
}

/* ============================================
   작은 데스크탑 (768px 이상)
   ============================================ */
@media (min-width: 768px) {
    .container {
        max-width: 720px;
        margin: 0 auto;
    }

    .menu-toggle {
        display: none;
    }

    .nav-links {
        display: flex;
        width: auto;
        flex-direction: row;
        margin-top: 0;
        gap: 20px;
    }

    .nav-links li a {
        padding: 10px;
        border-bottom: none;
    }

    .viewport-indicator .tablet { display: none; }
    .viewport-indicator .small-desktop { display: block; }

    .responsive-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .card-grid {
        flex-direction: row;
        flex-wrap: wrap;
    }

    .card {
        flex: 1 1 calc(50% - var(--spacing-md));
        max-width: calc(50% - var(--spacing-md) / 2);
    }

    .btn-primary {
        width: auto;
    }

    .footer-content {
        flex-direction: row;
        justify-content: space-between;
    }

    .footer-section {
        flex: 1;
    }
}

/* ============================================
   데스크탑 (992px 이상)
   ============================================ */
@media (min-width: 992px) {
    :root {
        --spacing-md: 30px;
        --spacing-lg: 50px;
    }

    .container {
        max-width: 960px;
    }

    h1 {
        font-size: 2.5rem;
    }

    .viewport-indicator .small-desktop { display: none; }
    .viewport-indicator .desktop { display: block; }

    .card {
        flex: 1 1 calc(33.333% - var(--spacing-md));
        max-width: calc(33.333% - var(--spacing-md) / 1.5);
    }
}

/* ============================================
   큰 화면 (1200px 이상)
   ============================================ */
@media (min-width: 1200px) {
    .container {
        max-width: 1140px;
    }

    .viewport-indicator .desktop { display: none; }
    .viewport-indicator .large { display: block; }
}

/* ============================================
   인쇄 스타일
   ============================================ */
@media print {
    .navbar,
    .menu-toggle,
    .footer {
        display: none;
    }

    body {
        background: white;
        color: black;
    }

    .section {
        box-shadow: none;
        border: 1px solid #ddd;
    }

    a {
        color: black;
        text-decoration: underline;
    }
}
