/* 종이접기 교실 — 공작용 커팅 매트 위의 색종이 */
:root {
  --mat: #e3eadf;          /* 커팅 매트 */
  --mat-line: rgba(30, 60, 40, 0.07);
  --mat-line-strong: rgba(30, 60, 40, 0.13);
  --page: #eef2eb;
  --ink: #1e2b3a;          /* 글자·버튼 남색 */
  --ink-soft: #4d5b69;
  --muted: #5c6875;
  --sheet: #fbfaf6;        /* 종이 흰 면 */
  --rule: #d3dbd0;
  --accent: #d9483b;       /* 작품별 색종이 색으로 바뀜 */
  --focus: #2f6fd6;
  --display: 'Gowun Dodum', 'Pretendard', system-ui, sans-serif;
  --body: 'Pretendard', system-ui, -apple-system, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: var(--body); color: var(--ink); background: var(--page); -webkit-font-smoothing: antialiased; }
[hidden] { display: none !important; }
button, select, input { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--ink); color: #fff; padding: 8px 12px; border-radius: 8px; z-index: 10; }
.skip:focus { left: 8px; }

/* 매트 격자 */
.matgrid {
  background-color: var(--mat);
  background-image:
    linear-gradient(var(--mat-line-strong) 1px, transparent 1px),
    linear-gradient(90deg, var(--mat-line-strong) 1px, transparent 1px),
    linear-gradient(var(--mat-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--mat-line) 1px, transparent 1px);
  background-size: 120px 120px, 120px 120px, 24px 24px, 24px 24px;
  background-position: -1px -1px;
}

/* ---------- 작품 목록 ---------- */
#gallery { min-height: 100vh; }
.g-head { max-width: 1120px; margin: 0 auto; padding: 64px 24px 28px; }
.g-head { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 420px); gap: 32px; align-items: center; }
.hero { position: relative; display: block; aspect-ratio: 1; border-radius: 4px; overflow: hidden; color: var(--ink); text-decoration: none; }
.hero canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.hero-cap { position: absolute; left: 14px; bottom: 12px; font-family: var(--display); font-size: 20px; background: rgba(251, 250, 246, .85); padding: 4px 10px; border-radius: 4px; }
.g-lang { margin-bottom: 14px; }
.legend b, .p-legend b { font-weight: 400; }
.brand { font-family: var(--display); font-weight: 400; font-size: clamp(40px, 6vw, 68px); line-height: 1.05; margin: 0 0 18px; letter-spacing: -0.01em; }
.start-btn { display: inline-block; margin-top: 22px; padding: 13px 22px; border-radius: 999px; background: var(--ink); color: var(--sheet); text-decoration: none; font-weight: 600; font-size: 16px; }
.start-btn:hover { background: #2b3d52; }
.lede { font-size: 19px; line-height: 1.6; color: var(--ink-soft); max-width: 34em; margin: 0; }
.g-main { max-width: 1120px; margin: 0 auto; padding: 8px 24px 40px; }
.g-title { font-family: var(--display); font-weight: 400; font-size: 24px; margin: 24px 0 18px; }
.bands { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 22px; }
.bands button { font: inherit; font-size: 14.5px; display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 999px; border: 1px solid var(--rule); background: var(--sheet); color: var(--ink-soft); cursor: pointer; }
.bands button small { font-size: 12px; color: var(--muted); }
.bands button:hover { border-color: var(--ink-soft); }
.bands button[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--sheet); }
.bands button[aria-pressed="true"] small { color: inherit; opacity: .75; }
.rubric { margin: -10px 0 22px; font-size: 14px; color: var(--ink-soft); }
.rubric summary { cursor: pointer; width: fit-content; color: var(--muted); }
.rubric summary:hover { color: var(--ink); }
.rubric ol { margin: 10px 0 0; padding-left: 1.6em; columns: 2 260px; column-gap: 32px; line-height: 1.7; }
.rubric li::marker { font-family: var(--display); color: var(--ink); }
.cards { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 22px; }
.card a { display: block; text-decoration: none; color: inherit; border-radius: 4px; }
.card .pic { position: relative; aspect-ratio: 1; border-radius: 3px; overflow: hidden; box-shadow: 0 1px 0 rgba(30, 43, 58, 0.08); }
.card .pic img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; padding: 10%; transition: transform .35s ease; }
.card .lv { position: absolute; left: 12px; top: 10px; font-family: var(--display); font-size: 18px; line-height: 1; color: var(--ink); opacity: .85; }
.card a:hover .pic img, .card a:focus-visible .pic img { transform: translateY(-4px) rotate(-2deg); }
.card .meta { padding: 12px 2px 0; }
.card h3 { font-family: var(--display); font-weight: 400; font-size: 22px; margin: 0 0 6px; }
.card p { margin: 0; font-size: 14.5px; color: var(--ink-soft); line-height: 1.5; }
.card .facts { margin-top: 8px; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; font-size: 13px; color: var(--muted); }
.g-foot { max-width: 1120px; margin: 0 auto; padding: 12px 24px 56px; color: var(--muted); font-size: 14px; }

/* 접기 기호 */
.tips { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 18px; }
.tips li { background: var(--sheet); border: 1px solid var(--rule); border-radius: 6px; padding: 16px 18px 18px; }
.tips h3 { font-family: var(--display); font-weight: 400; font-size: 20px; margin: 0 0 6px; }
.tips p { margin: 0; font-size: 14.5px; color: var(--ink-soft); line-height: 1.6; }
.symbols { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 18px; }
.symbols a { display: block; text-decoration: none; color: inherit; background: var(--sheet); border: 1px solid var(--rule); border-radius: 6px; padding: 16px 18px 18px; height: 100%; }
.symbols a:hover { border-color: #b9c4b5; }
.symbols svg { width: 120px; height: 80px; display: block; margin-bottom: 8px; }
.symbols h3 { font-family: var(--display); font-weight: 400; font-size: 20px; margin: 0 0 4px; }
.symbols p { margin: 0; font-size: 14px; color: var(--ink-soft); line-height: 1.55; }
.sym-paper { fill: #f3efe6; stroke: var(--ink); stroke-width: 1.2; }
.sym-valley { stroke: #d9483b; stroke-width: 2.5; stroke-dasharray: 6 4; }
.sym-valley.thin { stroke-width: 1.6; fill: none; }
.sym-mountain { stroke: #9a5b13; stroke-width: 2.5; stroke-dasharray: 10 3 2 3; }
.sym-arrow { fill: none; stroke: var(--ink); stroke-width: 2; stroke-linecap: round; }
.sym-arrow.back { stroke-dasharray: 4 3; }

/* 난이도 막대: 10칸 중 채운 칸 */
.meter { display: inline-flex; gap: 2px; vertical-align: middle; }
.meter i { width: 7px; height: 7px; background: var(--rule); transform: rotate(45deg); border-radius: 1px; }
.meter i.on { background: var(--ink); }

/* ---------- 접기 화면 ---------- */
#viewer { height: 100vh; display: grid; grid-template-rows: auto 1fr; }
.v-head { display: flex; align-items: center; gap: 18px; padding: 12px 22px; border-bottom: 1px solid var(--rule); background: var(--page); }
.back { color: var(--ink); text-decoration: none; font-weight: 600; padding: 8px 12px 8px 30px; border-radius: 10px; position: relative; }
.back::before { content: ''; position: absolute; left: 12px; top: 50%; width: 8px; height: 8px; border-left: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: translateY(-50%) rotate(45deg); }
.back:hover { background: #e2e8df; }
.v-title { display: flex; align-items: center; gap: 12px; }
.v-title h1 { font-family: var(--display); font-weight: 400; font-size: 26px; margin: 0; }
.paper-info { margin-left: auto; color: var(--muted); font-size: 14px; }

.v-body { display: grid; grid-template-columns: minmax(0, 1fr) 360px; min-height: 0; }
.v-left { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; min-height: 0; }
.instruction { display: flex; gap: 14px; align-items: flex-start; padding: 18px 24px 14px; min-height: 76px; }
.badge { flex: none; font-family: var(--display); font-size: 22px; line-height: 1; padding: 8px 12px 7px; border-radius: 3px; background: var(--accent); color: #fff; transition: background .3s; }
#stepText { margin: 2px 0 0; font-size: 21px; line-height: 1.5; font-weight: 600; max-width: 40em; }
.stage { position: relative; min-height: 0; border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); }
.stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; }
.stage canvas:active { cursor: grabbing; }
.legend { position: absolute; left: 16px; bottom: 12px; display: flex; gap: 16px; font-size: 13px; color: var(--ink-soft); background: rgba(251, 250, 246, .85); padding: 6px 10px; border-radius: 6px; }
.legend span[hidden] { display: none; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.lg { display: inline-block; width: 28px; height: 3px; background: repeating-linear-gradient(90deg, var(--accent) 0 6px, transparent 6px 10px); }
.lg.cut { background: repeating-linear-gradient(90deg, #d23c3c 0 4px, transparent 4px 8px); }
.lg.mountain { background: repeating-linear-gradient(90deg, #9a5b13 0 10px, transparent 10px 13px, #9a5b13 13px 15px, transparent 15px 18px); }

.controls { padding: 14px 24px 18px; background: var(--page); }
#progress { width: 100%; accent-color: var(--ink); margin: 0 0 12px; }
.btns { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.btns button { padding: 11px 18px; border-radius: 10px; border: 1.5px solid var(--rule); background: var(--sheet); font-weight: 600; cursor: pointer; }
.btns button:hover:not(:disabled) { border-color: #b9c4b5; }
.btns button:disabled { opacity: .4; cursor: default; }
.btns .primary { background: var(--ink); border-color: var(--ink); color: #fff; min-width: 132px; }
.btns .primary:hover:not(:disabled) { background: #2b3c50; border-color: #2b3c50; }
.speed { margin-left: auto; font-size: 14px; color: var(--ink-soft); display: inline-flex; gap: 8px; align-items: center; }
.speed select { padding: 8px 10px; border-radius: 8px; border: 1.5px solid var(--rule); background: var(--sheet); }

.v-steps { border-left: 1px solid var(--rule); min-height: 0; display: flex; flex-direction: column; background: var(--page); }
.v-steps h2 { font-family: var(--display); font-weight: 400; font-size: 18px; margin: 18px 20px 8px; }
#stepList { list-style: none; margin: 0; padding: 0 12px 20px; overflow-y: auto; }
#stepList li { display: grid; grid-template-columns: 30px 64px 1fr; gap: 10px; align-items: center; padding: 8px; border-radius: 10px; cursor: pointer; color: var(--ink-soft); font-size: 14.5px; line-height: 1.45; }
#stepList li:hover { background: #e2e8df; }
#stepList .num { font-family: var(--display); font-size: 20px; text-align: center; color: var(--muted); }
#stepList img { width: 64px; height: 64px; border-radius: 3px; background: var(--mat); }
#stepList li.now { background: var(--sheet); color: var(--ink); box-shadow: inset 3px 0 0 var(--accent); }
#stepList li.now .num { color: var(--accent); }
#stepList li.done .num { color: var(--ink); }

/* 크게 보기(전체 화면): 교실 화면에 띄워 함께 접을 때 */
button.print-link { cursor: pointer; font: inherit; font-weight: 600; }
#viewer:fullscreen { background: var(--page); }
#viewer:fullscreen #stepText { font-size: 30px; }
#viewer:fullscreen .badge { font-size: 30px; }
#viewer:fullscreen .v-steps { display: none; }
#viewer:fullscreen .v-body { grid-template-columns: 1fr; }
#viewer:fullscreen .peek img { width: 96px; height: 96px; }

/* 이 단계를 마치면 되는 모양 */
.peek { margin: 0 0 0 auto; flex: none; text-align: center; }
.peek img { width: 64px; height: 64px; display: block; border-radius: 4px; background: var(--mat); border: 1px solid var(--rule); }
.peek figcaption { font-size: 11.5px; color: var(--muted); margin-top: 3px; }

/* 완성 뒤 다음 작품, 접어 본 작품 표시 */
.next-model { padding: 11px 18px; border-radius: 10px; background: var(--accent); color: #fff; font-weight: 600; text-decoration: none; }
.next-model:hover { filter: brightness(1.08); }
/* 이어서 접기 표시는 완성 표시보다 옅게 */
.resume-badge { color: var(--ink-soft); border-style: dashed; }
.done-badge { white-space: nowrap; font-size: 12.5px; font-weight: 600; color: var(--ink); background: #fff; border: 1.5px solid var(--rule); padding: 2px 8px; border-radius: 999px; }
.card .pic .check { position: absolute; right: 10px; top: 10px; width: 26px; height: 26px; border-radius: 50%; background: var(--ink); }
.card .pic .check::after { content: ''; position: absolute; left: 9px; top: 5px; width: 6px; height: 11px; border: solid #fff; border-width: 0 2.5px 2.5px 0; transform: rotate(45deg); }

/* ---------- 인쇄용 도면 ---------- */
.print-link { color: var(--ink); font-weight: 600; text-decoration: none; padding: 8px 12px; border: 1.5px solid var(--rule); border-radius: 10px; background: var(--sheet); }
.print-link:hover { border-color: #b9c4b5; }
#print { min-height: 100vh; background: #d9dfd6; }
.p-head { display: flex; justify-content: space-between; align-items: center; max-width: 900px; margin: 0 auto; padding: 14px 16px; }
.p-btn { padding: 10px 18px; border-radius: 10px; border: 0; background: var(--ink); color: #fff; font-weight: 600; cursor: pointer; }
.p-sheet { max-width: 900px; margin: 0 auto 40px; background: #fff; padding: 36px 40px; box-shadow: 0 2px 12px rgba(0,0,0,.08); }
.p-title h1 { font-family: var(--display); font-weight: 400; font-size: 34px; margin: 0 0 4px; }
.p-title p { margin: 0 0 22px; color: var(--ink-soft); }
.p-steps { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px 16px; }
.p-steps li { break-inside: avoid; display: flex; flex-direction: column; gap: 6px; }
.p-steps .pic { position: relative; border: 1px solid #e3e7e1; border-radius: 4px; }
.p-steps img { width: 100%; aspect-ratio: 1; display: block; }
.p-steps .n { position: absolute; left: 8px; top: 6px; font-family: var(--display); font-size: 22px; color: var(--ink); }
.p-steps p { margin: 0; font-size: 13.5px; line-height: 1.5; }
.p-steps li.final .pic { border-color: var(--accent); }
.p-legend { display: flex; gap: 18px; margin: 24px 0 0; font-size: 12.5px; color: var(--ink-soft); }
.p-legend span { display: inline-flex; gap: 6px; align-items: center; }
.p-legend span:last-child { margin-left: auto; }
@media print {
  @page { size: A4; margin: 12mm; }
  body { background: #fff; }
  #print { background: #fff; }
  .p-head { display: none; }
  .p-sheet { box-shadow: none; padding: 0; max-width: none; margin: 0; }
  .p-steps { gap: 10px; }
  .p-steps p { font-size: 11pt; }
}

@media (max-width: 900px) {
  .g-head { grid-template-columns: 1fr; }
  .hero { max-width: 420px; }
  @media (max-width: 560px) { .hero { aspect-ratio: 16 / 9; max-width: none; } }
  .p-steps { grid-template-columns: repeat(2, 1fr); }
  .p-sheet { padding: 20px 16px; }
  #viewer { height: auto; min-height: 100vh; }
  .v-head { flex-wrap: wrap; gap: 8px 14px; padding: 10px 14px; }
  .paper-info { margin-left: 0; width: 100%; }
  .v-body { grid-template-columns: 1fr; }
  /* 안내문·접기 화면·조작 버튼이 한 화면에 함께 보이도록: 조작부는 화면 아래에 붙인다 */
  .v-left { grid-template-rows: auto clamp(240px, 100svh - 430px, 58vh) auto; }
  .instruction { padding: 14px 16px 10px; }
  #stepText { font-size: 18px; }
  .controls { padding: 10px 16px 12px; position: sticky; bottom: 0; z-index: 5; box-shadow: 0 -1px 0 var(--rule), 0 -8px 16px rgba(30, 43, 58, 0.06); }
  .speed { margin-left: 0; }
  .v-steps { border-left: 0; border-top: 1px solid var(--rule); }
  .g-head { padding-top: 40px; }
}
/* 휴대폰: 작품 카드를 두 줄로 배치해 한눈에 더 많이 보이게 */
@media (max-width: 560px) {
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px 12px; }
  .card .lv { font-size: 14px; left: 8px; top: 6px; }
  .card h3 { font-size: 17px; margin-bottom: 4px; }
  .card p { font-size: 13px; line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
  .card .facts { flex-wrap: wrap; gap: 4px 8px; font-size: 12px; }
  .bands { gap: 6px; }
  .bands button { padding: 7px 11px; font-size: 13.5px; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

/* 전자칠판·큰 모니터: 교실 뒤에서도 읽히도록 접기 화면 글자를 키운다 */
@media (min-width: 1600px) {
  #stepText { font-size: 28px; max-width: 46em; }
  .badge { font-size: 28px; }
  .v-title h1 { font-size: 32px; }
  .controls button, .speed, .speed select { font-size: 18px; }
  #stepList li { font-size: 16.5px; grid-template-columns: 34px 76px 1fr; }
  #stepList .num { font-size: 24px; }
  .legend { font-size: 15px; }
}

/* 작은 단계 그림: 흰 종이가 바탕에 묻히지 않도록 얇은 윤곽 그림자 */
#stepList img, .peek img { background: none; border: 0; filter: drop-shadow(0 0 0.6px rgba(30, 43, 58, 0.55)) drop-shadow(0 1px 1.5px rgba(30, 43, 58, 0.18)); }
