/* 象棋靈籤 - 普普／新野獸派風格，僅用根目錄 style.css */

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: #f0f0f0;
  font-family: "Microsoft JhengHei", "PingFang TC", sans-serif;
  -webkit-font-smoothing: antialiased;
}

::selection {
  background: #facc15;
  color: #000;
}

/* 背景點狀紋 */
.bg-dots {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.05;
  background-image: radial-gradient(#000 2px, transparent 0);
  background-size: 20px 20px;
}

/* ===== 頁首 ===== */
.header {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.5rem;
  background: #000;
  color: #fff;
  border-bottom: 4px solid #000;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.logo-dot {
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  background: #ef4444;
  border: 2px solid #fff;
}

.logo-text {
  font-weight: 900;
  font-size: 1.25rem;
  letter-spacing: -0.02em;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.author-tag {
  font-weight: 700;
  font-size: 0.875rem;
  background: #fff;
  color: #000;
  padding: 0.25rem 0.5rem;
  text-transform: uppercase;
}

@media (max-width: 768px) {
  .author-tag { display: none; }
}

.btn-reset {
  background: none;
  border: none;
  color: inherit;
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0.25rem;
}

.btn-reset:hover {
  color: #ef4444;
}

/* ===== 主內容區 ===== */
.main {
  position: relative;
  z-index: 10;
  max-width: 80rem;
  margin: 0 auto;
  padding: 3rem 1rem;
  min-height: 60vh;
}

/* 錯誤訊息區：預設完全隱藏，只有加上 .is-visible 才顯示 */
.error-box {
  display: none;
  max-width: 42rem;
  margin: 0 auto 2rem;
  padding: 1.5rem;
  background: #fef2f2;
  border: 4px solid #ef4444;
  align-items: center;
  gap: 1rem;
}
.error-box.is-visible {
  display: flex;
}

.error-icon {
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  background: #ef4444;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  flex-shrink: 0;
}

.error-msg {
  flex: 1;
  font-weight: 900;
  color: #b91c1c;
}

.error-retry {
  text-decoration: underline;
  background: none;
  border: none;
  cursor: pointer;
  font-weight: 700;
  color: #b91c1c;
}

/* ===== 各步驟 view：預設隱藏 ===== */
.view {
  max-width: 56rem;
  margin: 0 auto;
}

.view[hidden] {
  display: none !important;
}

/* ----- 歡迎頁 ----- */
.view-welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  text-align: center;
  padding: 1.5rem;
  gap: 2rem;
}

.welcome-card {
  position: relative;
}

.welcome-card::before {
  content: "";
  position: absolute;
  inset: -1rem;
  background: #facc15;
  border: 4px solid #000;
  box-shadow: 8px 8px 0 #000;
  transform: rotate(-3deg);
  z-index: 0;
}

.welcome-title {
  position: relative;
  z-index: 1;
  font-size: clamp(2.5rem, 6vw, 4rem);
  font-weight: 900;
  color: #000;
  line-height: 1.1;
  margin: 0;
}

.welcome-sub {
  display: inline-block;
  background: #000;
  color: #fff;
  padding: 0 1rem;
  font-style: italic;
}

.welcome-desc {
  font-size: 1.25rem;
  font-weight: 700;
  max-width: 28rem;
  padding: 1rem;
  background: #22d3ee;
  border: 2px solid #000;
  transform: rotate(1deg);
  margin: 0;
}

.btn-start {
  padding: 1rem 2rem;
  font-size: 1.5rem;
  font-weight: 900;
  background: #00ff66;
  border: 4px solid #000;
  box-shadow: 6px 6px 0 #000;
  cursor: pointer;
}

.btn-start:hover {
  transform: translate(2px, 2px);
  box-shadow: none;
}

/* ----- 問題頁 ----- */
.view-question {
  padding: 1.5rem;
}

.question-card {
  padding: 1.5rem;
  background: #f472b6;
  border: 4px solid #000;
  box-shadow: 8px 8px 0 #000;
  transform: rotate(-1deg);
}

.question-title {
  font-size: 1.875rem;
  font-weight: 900;
  margin: 0 0 1rem;
}

.question-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.question-form textarea {
  width: 100%;
  min-height: 10rem;
  padding: 1rem;
  font-size: 1.125rem;
  font-weight: 700;
  border: 4px solid #000;
  background: #fff;
  font-family: inherit;
  resize: vertical;
}

.question-form textarea:focus {
  outline: none;
  box-shadow: 0 0 0 4px #facc15;
}

.btn-submit {
  width: 100%;
  padding: 1rem;
  font-size: 1.5rem;
  font-weight: 900;
  background: #000;
  color: #fff;
  border: 4px solid #000;
  cursor: pointer;
}

.btn-submit:hover {
  background: #fff;
  color: #000;
}

/* ----- 陣法選擇 ----- */
.view-method {
  padding: 1.5rem;
}

.method-heading {
  font-size: 1.5rem;
  font-weight: 900;
  text-align: center;
  background: #fde047;
  padding: 0.5rem 1.5rem;
  border: 4px solid #000;
  margin: 0 auto 3rem;
  display: block;
  width: fit-content;
}

.method-grid {
  display: grid;
  gap: 2rem;
}

@media (min-width: 768px) {
  .method-grid { grid-template-columns: 1fr 1fr; }
}

.method-card {
  padding: 2rem;
  background: #fff;
  border: 4px solid #000;
  box-shadow: 12px 12px 0 #ff3366;
  cursor: pointer;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
  font-family: inherit;
}

.method-card:last-child {
  box-shadow: 12px 12px 0 #00ff66;
}

.method-card:hover {
  transform: translate(4px, 4px);
  box-shadow: none;
}

.method-dots {
  display: flex;
  gap: 0.5rem;
}

.method-dots .dot {
  width: 3rem;
  height: 3rem;
  border-radius: 50%;
  border: 2px solid #000;
}

.method-dots .dot.red { background: #ff3366; }
.method-dots .dot.black { background: #000; }

.method-dots.bagua {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.25rem;
}

.method-dots.bagua::before {
  content: "";
  grid-column: span 3;
  height: 0;
}

.method-card .method-dots.bagua {
  width: 8rem;
}

.method-card h3 {
  font-size: 1.875rem;
  font-weight: 900;
  margin: 0;
}

.method-card p {
  font-weight: 700;
  color: #374151;
  margin: 0;
}

.method-badge {
  margin-top: auto;
  padding: 0.5rem 1rem;
  background: #000;
  color: #fff;
  font-weight: 700;
}

/* ----- 抽籤動畫頁 ----- */
.view-drawing {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  gap: 3rem;
  padding: 2rem;
}

.drawing-wrap {
  position: relative;
  width: 12rem;
  height: 12rem;
}

.drawing-spinner {
  position: absolute;
  inset: 0;
  animation: spin-slow 12s linear infinite;
}

.drawing-spinner::before {
  content: "↺";
  position: absolute;
  inset: 0;
  font-size: 8rem;
  opacity: 0.2;
  display: flex;
  align-items: center;
  justify-content: center;
}

.drawing-circle {
  position: absolute;
  inset: 0;
  margin: auto;
  width: 8rem;
  height: 8rem;
  background: #facc15;
  border: 8px solid #000;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: bounce 1s ease-in-out infinite;
}

.drawing-circle span {
  font-size: 3rem;
  font-weight: 900;
}

.drawing-title {
  font-size: 1.5rem;
  font-weight: 900;
  background: #000;
  color: #fff;
  padding: 0.5rem 1.5rem;
  margin: 0;
}

.drawing-desc {
  font-size: 1.25rem;
  font-weight: 900;
  color: #4b5563;
  margin: 0;
}

@keyframes spin-slow {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@keyframes bounce {
  50% { transform: translateY(-8px); }
}

/* ----- 結果頁 ----- */
.view-result {
  padding: 1rem;
}

.result-card {
  background: #fff;
  border: 8px solid #000;
  padding: 2rem;
  box-shadow: 16px 16px 0 #000;
}

.result-pieces {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 2rem;
  margin-bottom: 3rem;
}

.piece-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

.piece-circle {
  width: 5rem;
  height: 5rem;
  border-radius: 50%;
  border: 4px solid #000;
  box-shadow: 4px 4px 0 #000;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.875rem;
  font-weight: 900;
}

.piece-circle.red {
  background: #ff3366;
  color: #fff;
}

.piece-circle.black {
  background: #1a1a1a;
  color: #00ff66;
}

.piece-label {
  font-size: 0.75rem;
  font-weight: 700;
  background: #000;
  color: #fff;
  padding: 0.25rem 0.5rem;
  text-transform: uppercase;
}

.result-report-wrap {
  border-top: 4px solid #000;
  padding-top: 2rem;
}

.report-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.report-icon {
  width: 4rem;
  height: 4rem;
  background: #ff3366;
  border: 4px solid #000;
  border-radius: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  color: #fff;
}

.report-header h3 {
  font-size: 1.5rem;
  font-weight: 900;
  text-transform: uppercase;
  margin: 0;
}

.report-header p {
  font-weight: 700;
  color: #6b7280;
  font-size: 0.75rem;
  letter-spacing: 0.1em;
  margin: 0.25rem 0 0;
}

.report-body {
  background: #fafafa;
  border: 2px solid #000;
  padding: 1.5rem 2.5rem;
  margin-bottom: 3rem;
  min-height: 8rem;
}

/* Markdown 報告內文 */
.report-body h1 {
  font-size: 1.75rem;
  font-weight: 900;
  border-bottom: 8px solid #facc15;
  display: inline-block;
  margin: 2rem 0 1rem;
}

.report-body h2 {
  font-size: 1.25rem;
  font-weight: 900;
  background: #000;
  color: #fff;
  padding: 0.25rem 0.5rem;
  display: inline-block;
  margin: 1.5rem 0 0.5rem;
}

.report-body h3 {
  font-size: 1.125rem;
  font-weight: 900;
  text-decoration: underline;
  text-decoration-color: #ec4899;
  text-decoration-thickness: 4px;
  margin: 1rem 0 0.5rem;
}

.report-body p {
  font-weight: 500;
  font-size: 1.125rem;
  line-height: 1.6;
  margin-bottom: 1rem;
}

.report-body blockquote {
  border-left: 8px solid #22d3ee;
  background: #ecfeff;
  padding: 1rem;
  font-style: italic;
  font-weight: 700;
  margin: 1rem 0;
  box-shadow: 4px 4px 0 #000;
}

.report-body ul {
  margin: 0.5rem 0 1rem 1.5rem;
}

.report-body li {
  font-weight: 700;
  margin-bottom: 0.25rem;
}

.report-body strong {
  background: #fef08a;
  padding: 0 2px;
  border-bottom: 2px solid #000;
}

/* 下載報告：兩個欄位（PNG、Markdown） */
.download-btns {
  display: flex;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}
.btn-download {
  flex: 1;
  min-width: 10rem;
  padding: 0.75rem 1rem;
  font-size: 1rem;
  font-weight: 700;
  background: #fff;
  border: 4px solid #000;
  box-shadow: 4px 4px 0 #000;
  cursor: pointer;
  font-family: inherit;
}
.btn-download:hover {
  background: #f0f0f0;
}
.btn-download:active {
  transform: translate(2px, 2px);
  box-shadow: 2px 2px 0 #000;
}

.btn-again {
  width: 100%;
  padding: 1.5rem;
  font-size: 1.5rem;
  font-weight: 900;
  background: #22d3ee;
  border: 4px solid #000;
  box-shadow: 8px 8px 0 #000;
  cursor: pointer;
}

.btn-again:hover {
  background: #000;
  color: #fff;
}

.btn-again:active {
  transform: translate(4px, 4px);
  box-shadow: none;
}

/* ----- 載入遮罩 ----- */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #fff;
}

.loading-overlay[hidden] {
  display: none !important;
}

.loading-spinner {
  width: 4rem;
  height: 4rem;
  border: 4px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.loading-text {
  font-size: 1.875rem;
  font-weight: 900;
  margin: 1rem 0 0;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ===== 頁尾 ===== */
.footer {
  margin-top: 5rem;
  padding: 2rem;
  border-top: 8px solid #000;
  background: #facc15;
  color: #000;
  text-align: center;
}

.footer-quote {
  font-size: 1.875rem;
  font-weight: 900;
  font-style: italic;
  margin: 0 0 1rem;
}

.footer-tags {
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin-bottom: 1rem;
}

.footer-tags span {
  background: #000;
  color: #fff;
  padding: 0.25rem 0.5rem;
}

.footer-copy {
  font-size: 0.75rem;
  font-weight: 700;
  opacity: 0.6;
  margin: 0;
}
