/*
 * CSS 기초 예제 스타일시트
 * 선택자, 박스 모델, 텍스트 스타일링, 위치 지정 등
 */

/* ============================================
   기본 스타일
   ============================================ */

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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    padding: 20px;
    max-width: 900px;
    margin: 0 auto;
    background-color: #f5f5f5;
}

h1 {
    text-align: center;
    color: #333;
    margin-bottom: 30px;
}

h2 {
    color: #2c3e50;
    border-bottom: 2px solid #3498db;
    padding-bottom: 10px;
    margin: 20px 0;
}

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

/* ============================================
   1. 선택자
   ============================================ */

/* 요소 선택자 */
p {
    margin: 10px 0;
}

/* 클래스 선택자 */
.highlight {
    background-color: #ffeb3b;
    padding: 5px 10px;
}

.warning {
    color: #e74c3c;
    font-weight: bold;
}

/* ID 선택자 */
#unique {
    background-color: #3498db;
    color: white;
    padding: 10px;
    border-radius: 4px;
}

/* 자손 선택자 (모든 자손) */
.parent span {
    color: #e74c3c;
    font-weight: bold;
}

/* 자식 선택자 (직접 자식만) */
.container-child > p {
    background-color: #e8f6f3;
    padding: 10px;
    border-left: 4px solid #1abc9c;
}

/* 인접 형제 선택자 */
h3 + p {
    color: #9b59b6;
    font-style: italic;
}

/* 속성 선택자 */
input[type="text"] {
    border: 2px solid #3498db;
    padding: 8px;
    margin: 5px;
}

input[type="email"] {
    border: 2px solid #e74c3c;
    padding: 8px;
    margin: 5px;
}

a[target="_blank"] {
    color: #e74c3c;
}

a[target="_blank"]::after {
    content: " ↗";
}

/* ============================================
   2. 가상 클래스
   ============================================ */

/* 호버 효과 */
.btn {
    display: inline-block;
    padding: 10px 20px;
    background-color: #3498db;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn:hover {
    background-color: #2980b9;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

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

/* 링크 상태 */
.link {
    display: inline-block;
    margin: 10px;
}

.link:link {
    color: #3498db;
}

.link:visited {
    color: #9b59b6;
}

.link:hover {
    color: #e74c3c;
}

.link:active {
    color: #f39c12;
}

/* first-child, last-child */
.pseudo-list {
    list-style: none;
    padding: 10px;
    background-color: #ecf0f1;
}

.pseudo-list li {
    padding: 10px;
    margin: 5px 0;
    background-color: white;
}

.pseudo-list li:first-child {
    background-color: #d5f5e3;
    border-left: 4px solid #27ae60;
}

.pseudo-list li:last-child {
    background-color: #fadbd8;
    border-left: 4px solid #e74c3c;
}

/* nth-child */
.nth-list {
    list-style: none;
    padding: 10px;
}

.nth-list li {
    padding: 10px;
    margin: 5px 0;
}

.nth-list li:nth-child(odd) {
    background-color: #aed6f1;
}

.nth-list li:nth-child(even) {
    background-color: #f9e79f;
}

/* focus */
.form-input {
    padding: 10px;
    border: 2px solid #bdc3c7;
    border-radius: 4px;
    width: 300px;
    transition: border-color 0.3s, box-shadow 0.3s;
}

.form-input:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 8px rgba(52, 152, 219, 0.4);
}

/* ============================================
   3. 가상 요소
   ============================================ */

/* ::before, ::after */
.quote {
    position: relative;
    padding: 20px 40px;
    background-color: #f8f9fa;
    font-style: italic;
    border-left: 4px solid #3498db;
}

.quote::before {
    content: """;
    position: absolute;
    left: 10px;
    top: 0;
    font-size: 3em;
    color: #3498db;
    line-height: 1;
}

.quote::after {
    content: """;
    position: absolute;
    right: 10px;
    bottom: -10px;
    font-size: 3em;
    color: #3498db;
    line-height: 1;
}

/* ::first-letter */
.first-letter-example::first-letter {
    font-size: 3em;
    font-weight: bold;
    color: #e74c3c;
    float: left;
    margin-right: 10px;
    line-height: 0.8;
}

/* ::first-line */
.first-line-example::first-line {
    font-weight: bold;
    color: #2c3e50;
}

/* ============================================
   4. 박스 모델
   ============================================ */

.box-demo {
    display: flex;
    gap: 20px;
    margin: 20px 0;
}

.box {
    width: 200px;
    padding: 20px;
    border: 5px solid #3498db;
    margin: 10px;
    background-color: #ecf0f1;
}

.content-box {
    box-sizing: content-box;
    /* 실제 너비 = 200 + 40 + 10 = 250px */
}

.border-box {
    box-sizing: border-box;
    /* 실제 너비 = 200px (패딩, 보더 포함) */
}

/* 박스 모델 시각화 */
.box-model-visual {
    margin: 20px auto;
    width: fit-content;
}

.margin-area {
    background-color: #ffeaa7;
    padding: 30px;
    text-align: center;
    font-size: 12px;
}

.border-area {
    background-color: #fdcb6e;
    padding: 20px;
}

.padding-area {
    background-color: #81ecec;
    padding: 30px;
}

.content-area {
    background-color: #74b9ff;
    padding: 30px;
    color: white;
    font-weight: bold;
}

/* ============================================
   5. 색상
   ============================================ */

.color-demo {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.color-box {
    padding: 20px;
    color: white;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
    border-radius: 4px;
    min-width: 150px;
    text-align: center;
}

/* ============================================
   6. 텍스트 스타일링
   ============================================ */

.text-font {
    font-family: Georgia, 'Times New Roman', serif;
}

.text-size {
    font-size: 1.5em;
}

.text-weight {
    font-weight: bold;
}

.text-style {
    font-style: italic;
}

.text-decoration {
    text-decoration: underline wavy #e74c3c;
}

.text-transform-upper {
    text-transform: uppercase;
}

.text-transform-capital {
    text-transform: capitalize;
}

.text-spacing {
    letter-spacing: 2px;
    word-spacing: 10px;
}

.text-shadow {
    font-size: 2em;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3),
                 0 0 20px rgba(52, 152, 219, 0.5);
}

.text-align-center {
    text-align: center;
    background-color: #ecf0f1;
    padding: 10px;
}

.text-line-height {
    line-height: 2;
    background-color: #f8f9fa;
    padding: 10px;
}

/* ============================================
   7. display 속성
   ============================================ */

.display-demo {
    background-color: #ecf0f1;
    padding: 10px;
    margin: 10px 0;
}

.display-block {
    display: block;
    background-color: #3498db;
    color: white;
    padding: 10px;
    margin: 5px 0;
}

.display-inline {
    display: inline;
    background-color: #27ae60;
    color: white;
    padding: 10px;
    /* width, height 적용 안됨 */
}

.display-inline-block {
    display: inline-block;
    background-color: #e74c3c;
    color: white;
    padding: 10px;
    margin: 5px;
    width: 120px;
    height: 60px;
    vertical-align: middle;
}

.display-none {
    display: none;
}

/* ============================================
   8. position 속성
   ============================================ */

.position-demo {
    background-color: #ecf0f1;
    padding: 20px;
    margin: 20px 0;
    min-height: 100px;
}

.pos-relative {
    position: relative;
    top: 20px;
    left: 20px;
    background-color: #3498db;
    color: white;
    padding: 10px;
    width: fit-content;
}

.position-parent {
    position: relative;
    height: 150px;
}

.pos-absolute {
    position: absolute;
    top: 10px;
    right: 10px;
    background-color: #e74c3c;
    color: white;
    padding: 10px;
}

.pos-fixed-demo {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background-color: #9b59b6;
    color: white;
    padding: 15px;
    border-radius: 4px;
    z-index: 1000;
}

.sticky-container {
    height: 200px;
    overflow: auto;
}

.pos-sticky {
    position: sticky;
    top: 0;
    background-color: #f39c12;
    color: white;
    padding: 10px;
}

/* ============================================
   9. overflow 속성
   ============================================ */

.overflow-demo {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
}

.overflow-demo > div {
    width: 150px;
    height: 100px;
    background-color: #ecf0f1;
    padding: 10px;
    border: 2px solid #bdc3c7;
}

.overflow-visible {
    overflow: visible;
}

.overflow-hidden {
    overflow: hidden;
}

.overflow-scroll {
    overflow: scroll;
}

.overflow-auto {
    overflow: auto;
}

/* ============================================
   푸터
   ============================================ */

footer {
    text-align: center;
    padding: 20px;
    color: #7f8c8d;
    border-top: 1px solid #ecf0f1;
    margin-top: 30px;
}
