/* =================================
   1. 폰트 임포트 (파일 최상단)
   ================================= */
@import url('https://fonts.googleapis.com/css2?family=Gowun+Dodum&display=swap');
@import url('https://webfontworld.github.io/gmarket/GmarketSans.css');
@import url('https://webfontworld.github.io/bookk/BookkMyungjo.css');

/* '학교안심 보드마카'는 woff2 직접 임포트 */
@font-face {
    font-family: 'HakgyoansimBodumaka';
    src: url('https://cdn.jsdelivr.net/gh/projectnoonnu/noonfonts_2307-2@1.0/HakgyoansimBodumakaR.woff2') format('woff2');
    font-weight: normal;
    font-style: normal;
}

/* =================================
   2. 기본 및 공통 스타일
   ================================= */
* {
    box-sizing: border-box;
}

body {
    /* 👈 1. 기본 폰트를 Gmarket Sans로 변경 */
    font-family: 'GmarketSans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    margin: 0;
    padding: 0;
    background-color: #f7f9fc;
    color: #333;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

header {
    width: 100%;
    padding: 15px 25px;
    background-color: #ffffff;
    border-bottom: 1px solid #e0e0e0;
}

header h1 {
    margin: 0;
    font-size: 1.5rem;
    color: #007bff;
}

main {
    flex-grow: 1;
    width: 100%;
    max-width: 800px;
    margin: 20px auto;
    padding: 0 20px;
}

/* 공통 버튼 스타일 */
button {
    padding: 10px 18px;
    font-size: 1rem;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    background-color: #007bff;
    color: white;
    transition: background-color 0.2s, box-shadow 0.2s;
    /* 👈 버튼에도 기본 폰트(Gmarket Sans)가 적용됩니다 */
    font-family: 'GmarketSans', sans-serif; 
}

button:hover {
    background-color: #0056b3;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

button:disabled {
    background-color: #c0c0c0;
    cursor: not-allowed;
}

/* =================================
   3. 홈 (index.html)
   ================================= */
.home-container {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-grow: 1;
}

#start-quiz-btn {
    padding: 25px 50px;
    font-size: 2rem;
    font-weight: bold;
}

body[data-page="home"] footer {
    position: fixed;
    bottom: 20px;
    left: 20px;
    background: none;
    border: none;
}

#history-btn {
    background-color: #6c757d;
}

#history-btn:hover {
    background-color: #5a6268;
}

/* =================================
   4. 설정 (settings.html)
   ================================= */
.setting-box {
    background-color: #ffffff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 25px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.setting-box h3 {
    margin-top: 0;
    border-bottom: 2px solid #f0f0f0;
    padding-bottom: 10px;
}

#level-select, #grade-select, #type-select {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 15px;
}

.toggle-btn {
    background-color: #f0f0f0;
    color: #555;
    border: 1px solid #ccc;
}

.toggle-btn.active {
    background-color: #007bff;
    color: white;
    border-color: #007bff;
    font-weight: bold;
}

#subject-select {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: 10px;
    margin-bottom: 15px;
}

#subject-select label {
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 6px;
    text-align: center;
    cursor: pointer;
}

#subject-select input[type="radio"] {
    display: none;
}

#subject-select input[type="radio"]:checked + span {
    color: #007bff;
    font-weight: bold;
}

#subject-select label.selected {
    background-color: #e6f2ff;
    border-color: #007bff;
}

input[type="text"], input[type="number"] {
    width: 100%;
    padding: 12px;
    font-size: 1rem;
    border: 1px solid #ccc;
    border-radius: 6px;
    margin-bottom: 15px;
    /* 👈 입력란에도 Gmarket Sans 적용 (고운돋움은 서술형에만) */
    font-family: 'GmarketSans', sans-serif;
}

#generate-quiz-btn {
    width: 100%;
    padding: 15px;
    font-size: 1.2rem;
    font-weight: bold;
    background-color: #28a745;
}

#generate-quiz-btn:hover {
    background-color: #218838;
}


/* =================================
   5. 퀴즈 (quiz.html) - 폰트 변경 핵심
   ================================= */
.quiz-page-container {
    padding-bottom: 100px;
}

#quiz-container {
    background-color: #ffffff;
    border-radius: 8px;
    padding: 20px;
}

#quiz-container h2 {
    text-align: center;
    color: #666;
}

.quiz-question {
    margin-bottom: 25px;
    border-bottom: 1px solid #f0f0f0;
    padding-bottom: 20px;
}

.quiz-question h4 {
    /* 👈 2. 문제 설명 폰트: 학교안심 보드마카 */
    font-family: 'HakgyoansimBodumaka', 'GmarketSans', sans-serif;
    font-size: 1.4rem; /* 폰트가 잘 보이도록 크기 조정 */
    margin-bottom: 15px;
}

/* 선택형 보기 */
.quiz-options label {
    /* 👈 3. 선택형 답안 폰트: 부크크 명조 */
    font-family: 'BookkMyungjo', 'GmarketSans', serif;
    font-size: 1.1rem; /* 명조체가 잘 보이도록 크기 조정 */
    
    display: block;
    padding: 10px;
    margin-bottom: 8px;
    border: 1px solid #eee;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.quiz-options label:hover {
    background-color: #f9f9f9;
}

.quiz-options input[type="radio"] {
    margin-right: 10px;
}

/* 서술형 답안 */
.quiz-question textarea {
    /* 👈 4. 서술형 입력 폰트: 고운돋움 */
    font-family: 'Gowun Dodum', 'GmarketSans', sans-serif;
    
    width: 100%;
    min-height: 100px;
    padding: 10px;
    font-size: 1.05rem; /* 폰트가 잘 보이도록 크기 조정 */
    line-height: 1.6; /* 줄 간격 추가 */
    border: 1px solid #ccc;
    border-radius: 6px;
}

#submit-quiz-btn {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: 90%;
    max-width: 760px;
    padding: 18px;
    font-size: 1.3rem;
    font-weight: bold;
}

/* =================================
   6. 과거 기록 (history.html)
   ================================= */
.history-container {
    padding-bottom: 80px;
}

#history-list {
    list-style-type: none;
    padding: 0;
    margin: 0;
}

#history-list li {
    background-color: #ffffff;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    padding: 15px 20px;
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 1.1rem;
}

#history-list li span:first-child {
    color: #555;
    font-size: 0.95rem;
}

#history-list li span:last-child {
    font-weight: bold;
    color: #007bff;
}

body[data-page="history"] footer {
    padding: 20px;
    text-align: center;
    background: none;
}

#go-home-btn {
    background-color: #6c757d;
}

#go-home-btn:hover {
    background-color: #5a6268;
}