/* =====================================================
   은하 탐험 - 스타일
   -----------------------------------------------------
   색상은 아래 :root 의 변수만 바꾸면 전체에 적용됩니다.
   빔프로젝터용으로 글씨를 크게(본문 20px, 제목 36px 이상) 잡았습니다.
   ===================================================== */

:root {
  --bg-dark: #05071a;          /* 가장 어두운 배경 (거의 검정) */
  --bg-navy: #0d1540;          /* 남색 배경 */
  --panel: #141c4a;            /* 카드/창 배경 */
  --panel-border: #2c3a80;
  --text: #f4f6ff;             /* 기본 글씨 (밝은 흰색) */
  --text-dim: #b9c2ec;         /* 보조 글씨 */
  --accent: #5cc8ff;           /* 포인트 색 (하늘색) */
  --accent-dark: #0a4a6e;
  --danger: #ff6b6b;
}

/* hidden 속성이 붙은 요소는 항상 숨김 */
[hidden] {
  display: none !important;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
}

body {
  font-family: "Malgun Gothic", "맑은 고딕", "Apple SD Gothic Neo", sans-serif;
  font-size: 20px;
  line-height: 1.5;
  color: var(--text);
  background: radial-gradient(ellipse at top, var(--bg-navy), var(--bg-dark) 70%);
  background-attachment: fixed;
}

/* ---------- 공통 버튼 ---------- */
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 52px;
  padding: 10px 22px;
  font: inherit;
  font-size: 20px;
  font-weight: bold;
  color: var(--text);
  background: var(--panel);
  border: 2px solid var(--panel-border);
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}

.button:hover {
  border-color: var(--accent);
}

.button:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.button-primary {
  color: var(--bg-dark);
  background: var(--accent);
  border-color: var(--accent);
}

.button-primary:hover {
  background: #8ad8ff;
}

.button-danger {
  color: #fff;
  background: transparent;
  border-color: var(--danger);
}

.button-danger:hover {
  background: var(--danger);
  border-color: var(--danger);
}

.button-subtle {
  background: transparent;
}

/* ---------- 화면 전환 효과 (살짝 확대되며 나타남, 0.5초) ---------- */
.screen {
  animation: screen-in 0.5s ease-out;
}

@keyframes screen-in {
  from {
    opacity: 0;
    transform: scale(1.03);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* =====================================================
   1. 시작 화면
   ===================================================== */
#start-screen {
  min-height: 100%;
  padding: 48px 32px 32px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.start-header {
  text-align: center;
  margin-bottom: 40px;
}

.start-header h1 {
  margin: 0;
  font-size: 64px;
  letter-spacing: 4px;
  text-shadow: 0 0 24px rgba(92, 200, 255, 0.6);
}

.subtitle {
  margin: 8px 0 0;
  font-size: 28px;
  color: var(--text-dim);
}

.galaxy-list {
  width: 100%;
  max-width: 1400px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 28px;
}

.galaxy-card {
  display: flex;
  flex-direction: column;
  padding: 0 0 20px;
  font: inherit;
  color: var(--text);
  text-align: left;
  background: var(--panel);
  border: 2px solid var(--panel-border);
  border-radius: 18px;
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
}

.galaxy-card:hover,
.galaxy-card:focus-visible {
  transform: translateY(-6px);
  border-color: var(--accent);
  box-shadow: 0 0 28px rgba(92, 200, 255, 0.35);
  outline: none;
}

.galaxy-thumb {
  position: relative;
  aspect-ratio: 4 / 3;
  background: #000;
}

.galaxy-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* 썸네일 이미지가 없을 때 */
.galaxy-thumb.no-image {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 30px;
  font-weight: bold;
  color: var(--text-dim);
  background: radial-gradient(circle at 50% 50%, #2a3a8c 0%, #101848 45%, #03040f 100%);
}

/* 썸네일 위 핀 개수 표시 */
.pin-count {
  position: absolute;
  top: 10px;
  right: 10px;
  padding: 2px 12px;
  font-size: 18px;
  font-weight: bold;
  color: var(--bg-dark);
  background: var(--accent);
  border-radius: 999px;
}

.galaxy-card-name {
  margin: 16px 20px 6px;
  font-size: 32px;
}

.galaxy-card-summary {
  margin: 0 20px;
  font-size: 20px;
  color: var(--text-dim);
}

.start-footer {
  margin-top: 40px;
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  justify-content: center;
}

/* =====================================================
   2. 은하 화면
   ===================================================== */
#galaxy-screen {
  height: 100%;
  display: flex;
  flex-direction: column;
  background: #000;
}

.top-bar {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 20px;
  background: rgba(13, 21, 64, 0.95);
  border-bottom: 2px solid var(--panel-border);
}

.galaxy-title {
  flex: 1;
  margin: 0;
  font-size: 36px;
  text-align: center;
}

.mode-button {
  min-width: 190px;
}

/* 편집 모드일 때 버튼을 하늘색으로 강조 */
.mode-button.is-edit {
  color: var(--bg-dark);
  background: var(--accent);
  border-color: var(--accent);
}

.edit-hint {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 3;
  margin: 0;
  padding: 6px 20px;
  border-radius: 999px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.5);
  pointer-events: none; /* 안내 문구 위를 클릭해도 그 아래에 핀이 추가되도록 */
  font-size: 20px;
  font-weight: bold;
  text-align: center;
  color: var(--bg-dark);
  background: var(--accent);
}

/* 이미지가 놓이는 영역. 남는 공간은 검은색 */
.stage {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
  overflow: hidden;
}

/* 실제 이미지 크기에 맞춰지는 상자 (크기는 JS 에서 정함) */
.image-box {
  position: relative;
  flex: none;
}

.image-box.is-edit {
  cursor: crosshair;
}

.galaxy-image {
  display: block;
  width: 100%;
  height: 100%;
  user-select: none;
  -webkit-user-drag: none;
  pointer-events: none; /* 이미지를 끌어서 옮기는 동작 방지 */
}

/* 이미지 파일이 없을 때 대신 보이는 우주색 화면 */
.galaxy-fallback {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 56px;
  font-weight: bold;
  color: rgba(244, 246, 255, 0.35);
  background:
    radial-gradient(ellipse at 50% 50%, rgba(92, 200, 255, 0.25) 0%, transparent 35%),
    radial-gradient(ellipse at 50% 50%, #26307a 0%, #0b1033 50%, #020309 100%);
  user-select: none;
}

.pin-layer {
  position: absolute;
  inset: 0;
}

/* ---------- 핀 (빛나는 점 + 깜빡임) ---------- */
.pin {
  position: absolute;
  width: 44px;            /* 터치하기 쉬운 크기 */
  height: 44px;
  padding: 0;
  transform: translate(-50%, -50%);
  background: transparent;
  border: none;
  cursor: pointer;
}

/* 가운데 빛나는 점 */
.pin::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 20px;
  height: 20px;
  margin: -10px 0 0 -10px;
  background: #fff;
  border: 3px solid var(--accent);
  border-radius: 50%;
  box-shadow: 0 0 12px 4px var(--accent), 0 0 28px 8px rgba(92, 200, 255, 0.5);
}

/* 퍼져 나가는 빛 고리 (깜빡임) */
.pin::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 20px;
  height: 20px;
  margin: -10px 0 0 -10px;
  border: 3px solid var(--accent);
  border-radius: 50%;
  animation: pin-pulse 1.8s ease-out infinite;
}

@keyframes pin-pulse {
  from {
    transform: scale(1);
    opacity: 0.9;
  }
  to {
    transform: scale(2.6);
    opacity: 0;
  }
}

.pin:hover::before,
.pin:focus-visible::before {
  background: var(--accent);
}

.pin:focus-visible {
  outline: none;
}

/* 마우스를 올리면 보이는 제목 툴팁 */
.pin-tooltip {
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  margin-bottom: 4px;
  padding: 4px 14px;
  font: inherit;
  font-size: 20px;
  font-weight: bold;
  white-space: nowrap;
  color: var(--text);
  background: rgba(5, 7, 26, 0.92);
  border: 2px solid var(--accent);
  border-radius: 8px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
}

.pin:hover .pin-tooltip,
.pin:focus-visible .pin-tooltip {
  opacity: 1;
}

/* =====================================================
   3. 모달 (핀 추가/수정, 핀 보기, 가져오기)
   ===================================================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(0, 0, 0, 0.7);
  animation: fade-in 0.2s ease-out;
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.modal {
  position: relative;
  width: 100%;
  max-width: 640px;
  max-height: 100%;
  overflow-y: auto;
  padding: 28px 32px;
  background: var(--panel);
  border: 2px solid var(--accent);
  border-radius: 18px;
  box-shadow: 0 0 40px rgba(92, 200, 255, 0.3);
}

.modal-title {
  margin: 0 0 20px;
  font-size: 34px;
  color: var(--accent);
}

.modal-text {
  margin: 0 0 20px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 24px;
}

.modal-actions-column {
  flex-direction: column;
}

/* 입력 칸 */
.field {
  display: block;
  margin-bottom: 18px;
}

.field-label {
  display: block;
  margin-bottom: 6px;
  font-weight: bold;
}

.required {
  color: var(--danger);
}

.field input[type="text"],
.field textarea {
  width: 100%;
  padding: 10px 14px;
  font: inherit;
  font-size: 20px;
  color: var(--text);
  background: var(--bg-dark);
  border: 2px solid var(--panel-border);
  border-radius: 10px;
}

.field textarea {
  resize: vertical;
}

.field input[type="text"]:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.field-error {
  display: block;
  margin-top: 4px;
  font-size: 18px;
  color: var(--danger);
}

.photo-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.photo-status {
  margin: 6px 0 0;
  font-size: 18px;
  color: var(--text-dim);
}

.photo-preview {
  display: block;
  max-width: 100%;
  max-height: 220px;
  margin-top: 10px;
  border-radius: 10px;
  border: 2px solid var(--panel-border);
}

/* 핀 보기 카드 */
.pin-card {
  max-width: 760px;
}

.pin-card-photo {
  display: block;
  max-width: 100%;
  max-height: 50vh;
  margin: 0 auto 20px;
  border-radius: 12px;
}

.pin-card .modal-title {
  padding-right: 40px; /* 닫기 버튼과 겹치지 않게 */
}

.pin-card-description {
  margin: 0;
  font-size: 22px;
  white-space: pre-wrap; /* 줄바꿈 그대로 표시 */
  word-break: keep-all;
}

.close-button {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 48px;
  height: 48px;
  font-size: 26px;
  color: var(--text);
  background: transparent;
  border: none;
  border-radius: 50%;
  cursor: pointer;
}

.close-button:hover {
  background: rgba(255, 255, 255, 0.1);
}

/* =====================================================
   4. 안내 메시지 (토스트)
   ===================================================== */
.toast {
  position: fixed;
  left: 50%;
  bottom: 32px;
  z-index: 20;
  transform: translateX(-50%);
  max-width: 90%;
  padding: 14px 28px;
  font-size: 22px;
  font-weight: bold;
  text-align: center;
  color: var(--bg-dark);
  background: var(--accent);
  border-radius: 12px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.5);
  animation: fade-in 0.2s ease-out;
}

.toast.is-error {
  color: #fff;
  background: #c0392b;
}

/* =====================================================
   5. 서버 연동 후 추가된 요소
   ===================================================== */

/* 상단 바의 "선생님" 표시 */
.teacher-badge {
  padding: 4px 14px;
  font-size: 18px;
  font-weight: bold;
  color: var(--bg-dark);
  background: var(--mine);
  border-radius: 999px;
}

/* 핀 입력 창 아래 안내 문구 */
.form-note {
  margin: 0;
  font-size: 18px;
  color: var(--text-dim);
}

/* 핀 카드의 "내가 만든 핀" 표시 */
.pin-card-mine {
  margin: 16px 0 0;
  font-size: 18px;
  font-weight: bold;
  color: var(--mine);
}

/* 내가 만든 핀은 노란 테두리로 구분 */
:root {
  --mine: #ffd95c;
}

.pin.is-mine::before {
  border-color: var(--mine);
}

.pin.is-mine::after {
  border-color: var(--mine);
}

.button:disabled {
  opacity: 0.6;
  cursor: wait;
}
