/* ============================================================
   ⛩ 神社籤詩 — style.css
   ============================================================ */

/* ── Custom Properties ── */
:root {
  --bg-gradient: linear-gradient(170deg, #fef8ee 0%, #fbf0dc 60%, #f5e6c8 100%);
  --card-bg: #fffdf9;
  --card-border: rgba(160, 100, 50, 0.12);
  --card-shadow: 0 2px 8px rgba(120, 60, 20, 0.06), 0 8px 32px rgba(120, 60, 20, 0.08);

  --text: #2a1f14;
  --text-secondary: #7a5f4e;
  --text-muted: #a89078;

  --shrine-red: #b53c2a;
  --shrine-red-glow: rgba(181, 60, 42, 0.28);

  --divider: rgba(150, 90, 50, 0.13);
  --pill-bg: rgba(181, 60, 42, 0.06);
  --pill-active-bg: #b53c2a;
  --pill-active-text: #fffdf9;

  --font-serif: 'Noto Serif TC', 'Georgia', 'PMingLiU', '宋體', serif;
  --font-ui: -apple-system, 'Inter', 'Helvetica Neue', sans-serif;

  /* Seal accent per fortune level */
  --seal-daikichi: #9a7000;
  --seal-kichi: #b05a10;
  --seal-chukichi: #8a6820;
  --seal-shokichi: #2e7a50;
  --seal-suekichi: #60707e;
  --seal-kyo: #48508a;
  --seal-daikyo: #802020;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg-gradient: linear-gradient(170deg, #1a140e 0%, #221a12 60%, #2a2018 100%);
    --card-bg: #26201a;
    --card-border: rgba(200, 150, 80, 0.14);
    --card-shadow: 0 2px 8px rgba(0, 0, 0, 0.32), 0 8px 32px rgba(0, 0, 0, 0.42);

    --text: #f5ebd8;
    --text-secondary: #c0906a;
    --text-muted: #8a6a54;

    --shrine-red: #d4604a;
    --shrine-red-glow: rgba(212, 96, 74, 0.32);

    --divider: rgba(200, 140, 70, 0.16);
    --pill-bg: rgba(212, 168, 81, 0.08);
    --pill-active-bg: #b53c2a;
    --pill-active-text: #fffdf9;

    --seal-daikichi: #d4a820;
    --seal-kichi: #e07830;
    --seal-chukichi: #c09030;
    --seal-shokichi: #50b878;
    --seal-suekichi: #8090a0;
    --seal-kyo: #7080c0;
    --seal-daikyo: #c04040;
  }
}

/* ── Reset ── */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html { scroll-behavior: smooth; }

body {
  background: var(--bg-gradient);
  background-attachment: fixed;
  color: var(--text);
  font-family: var(--font-serif);
  min-height: 100vh;
  padding: 1.5rem 1rem 4rem;
}

/* ── Layout ── */
.app-container {
  max-width: 560px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* ── Header ── */
header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  position: relative;
  padding-top: 0.25rem;
}

.back-btn {
  position: absolute;
  left: 0;
  top: 0.25rem;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  text-decoration: none;
  color: var(--text-secondary);
  font-family: var(--font-ui);
  font-size: 0.82rem;
  font-weight: 500;
  padding: 0.38rem 0.75rem;
  border-radius: 99px;
  border: 1px solid var(--divider);
  background: rgba(0, 0, 0, 0.02);
  transition: all 0.25s ease;
  white-space: nowrap;
}

@media (prefers-color-scheme: dark) {
  .back-btn { background: rgba(255, 255, 255, 0.02); }
}

.back-btn:hover {
  color: var(--text);
  border-color: var(--text-secondary);
  transform: translateX(-2px);
}

.back-arrow {
  display: inline-block;
  transition: transform 0.25s ease;
}

.back-btn:hover .back-arrow { transform: translateX(-3px); }

header h1 {
  font-size: 1.85rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--text);
  text-align: center;
  margin-top: 2rem;
}

/* ── Mode Toggle ── */
.mode-toggle {
  display: flex;
  background: var(--pill-bg);
  border: 1px solid var(--divider);
  border-radius: 99px;
  padding: 0.22rem;
  gap: 0.15rem;
}

.mode-pill {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-family: var(--font-ui);
  font-size: 0.82rem;
  font-weight: 500;
  padding: 0.4rem 0.9rem;
  border-radius: 99px;
  cursor: pointer;
  transition: all 0.25s ease;
}

.mode-pill.active {
  background: var(--pill-active-bg);
  color: var(--pill-active-text);
}

.mode-pill:not(.active):hover { color: var(--text); }

/* ── Shrine Scene ── */
.shrine-scene {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.2rem;
  padding: 2.5rem 1.5rem 2.2rem;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 24px;
  box-shadow: var(--card-shadow);
  text-align: center;
}

.shrine-emblem {
  font-size: 3.6rem;
  line-height: 1;
  animation: float-shrine 6s ease-in-out infinite;
}

@keyframes float-shrine {
  0%, 100% { transform: translateY(0px); }
  50%       { transform: translateY(-7px); }
}

.shrine-poem {
  font-size: 0.95rem;
  color: var(--text-secondary);
  letter-spacing: 0.14em;
  font-weight: 300;
}

/* ── Draw Button ── */
.draw-btn {
  width: 118px;
  height: 118px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(145deg, #c54030, #8a2818);
  color: #fffdf9;
  font-family: var(--font-serif);
  font-size: 1.45rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  box-shadow: 0 6px 20px var(--shrine-red-glow);
  animation: pulse-draw 3.2s ease-in-out infinite;
}

.draw-btn:hover {
  transform: scale(1.07);
  box-shadow: 0 10px 32px var(--shrine-red-glow);
  animation: none;
}

.draw-btn:active { transform: scale(0.96); }

@keyframes pulse-draw {
  0%, 100% { box-shadow: 0 6px 20px var(--shrine-red-glow), 0 0 0 0 var(--shrine-red-glow); }
  55%       { box-shadow: 0 6px 20px var(--shrine-red-glow), 0 0 0 14px rgba(181, 60, 42, 0); }
}

/* ── Fortune Card ── */
.fortune-card {
  display: none;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 24px;
  box-shadow: var(--card-shadow);
  padding: 1.75rem 1.5rem 1.5rem;
  text-align: center;
}

.fortune-card.visible {
  display: block;
  animation: card-reveal 0.65s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes card-reveal {
  from { opacity: 0; transform: translateY(28px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Meta bar */
.fortune-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.fortune-date {
  font-family: var(--font-ui);
  font-size: 0.76rem;
  color: var(--text-muted);
  letter-spacing: 0.04em;
}

.fortune-mode-badge {
  font-family: var(--font-ui);
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--shrine-red);
  background: var(--pill-bg);
  border: 1px solid var(--divider);
  border-radius: 99px;
  padding: 0.18rem 0.6rem;
}

@media (prefers-color-scheme: dark) {
  .fortune-mode-badge { color: var(--seal-daikichi); }
}

/* Fortune Seal */
.fortune-seal-wrapper { margin: 0.25rem 0 0.75rem; }

.fortune-seal {
  width: 112px;
  height: 112px;
  border-radius: 50%;
  border: 3px solid;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto;
  font-family: var(--font-serif);
  font-size: 2.1rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  transition: color 0.45s ease, border-color 0.45s ease, background 0.45s ease;
}

/* Seal colours by level – light mode */
.fortune-seal[data-level="大吉"] { color: var(--seal-daikichi); border-color: var(--seal-daikichi); background: rgba(154, 112, 0, 0.07); }
.fortune-seal[data-level="吉"]   { color: var(--seal-kichi);    border-color: var(--seal-kichi);    background: rgba(176, 90, 16, 0.07); }
.fortune-seal[data-level="中吉"] { color: var(--seal-chukichi); border-color: var(--seal-chukichi); background: rgba(138, 104, 32, 0.07); }
.fortune-seal[data-level="小吉"] { color: var(--seal-shokichi); border-color: var(--seal-shokichi); background: rgba(46, 122, 80, 0.07); }
.fortune-seal[data-level="末吉"] { color: var(--seal-suekichi); border-color: var(--seal-suekichi); background: rgba(96, 112, 126, 0.07); }
.fortune-seal[data-level="凶"]   { color: var(--seal-kyo);      border-color: var(--seal-kyo);      background: rgba(72, 80, 138, 0.07); }
.fortune-seal[data-level="大凶"] { color: var(--seal-daikyo);   border-color: var(--seal-daikyo);   background: rgba(128, 32, 32, 0.07); }

/* Ornament Divider */
.ornament-divider {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  margin: 1.2rem 0;
}

.ornament-line {
  flex: 1;
  height: 1px;
  background: var(--divider);
}

.ornament-dot {
  color: var(--text-muted);
  font-size: 0.6rem;
}

/* ── Fortune Fields ── */
.fortune-fields {
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.field-row {
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.42s ease, transform 0.42s ease;
  padding: 0.7rem 0.9rem;
  border-radius: 12px;
  border: 1px solid var(--divider);
  background: rgba(0, 0, 0, 0.015);
}

.field-row.visible {
  opacity: 1;
  transform: translateY(0);
}

@media (prefers-color-scheme: dark) {
  .field-row { background: rgba(255, 255, 255, 0.025); }
}

.field-label {
  font-family: var(--font-ui);
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--text-secondary);
  margin-bottom: 0.35rem;
}

.field-content {
  font-size: 0.94rem;
  line-height: 1.75;
  color: var(--text);
  font-weight: 400;
}

/* ── Lucky Row ── */
.lucky-row {
  display: flex;
  gap: 0.85rem;
  justify-content: center;
  flex-wrap: wrap;
}

.lucky-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.28rem;
  background: var(--pill-bg);
  border: 1px solid var(--divider);
  border-radius: 14px;
  padding: 0.75rem 1.4rem;
  min-width: 130px;
}

.lucky-label {
  font-family: var(--font-ui);
  font-size: 0.72rem;
  color: var(--text-secondary);
  font-weight: 500;
  letter-spacing: 0.04em;
}

.lucky-value {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--shrine-red);
}

@media (prefers-color-scheme: dark) {
  .lucky-value { color: var(--seal-daikichi); }
}

/* ── Redraw Button ── */
.redraw-btn {
  display: block;
  width: 100%;
  margin-top: 1.25rem;
  padding: 0.85rem;
  background: transparent;
  border: 1.5px solid var(--divider);
  border-radius: 12px;
  color: var(--text-secondary);
  font-family: var(--font-serif);
  font-size: 0.97rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  cursor: pointer;
  transition: all 0.25s ease;
}

.redraw-btn:hover {
  background: rgba(0, 0, 0, 0.03);
  border-color: var(--text-secondary);
  color: var(--text);
}

@media (prefers-color-scheme: dark) {
  .redraw-btn:hover { background: rgba(255, 255, 255, 0.04); }
}

.redraw-btn:active { transform: scale(0.98); }

/* ── Toast ── */
.toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--text);
  color: var(--card-bg);
  font-family: var(--font-ui);
  font-size: 0.88rem;
  padding: 0.6rem 1.2rem;
  border-radius: 99px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18);
  opacity: 0;
  transition: all 0.35s cubic-bezier(0.22, 1, 0.36, 1);
  pointer-events: none;
  white-space: nowrap;
  z-index: 200;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ── Responsive ── */
@media (max-width: 420px) {
  header h1    { font-size: 1.55rem; }
  .draw-btn    { width: 100px; height: 100px; font-size: 1.25rem; }
  .fortune-seal{ width: 96px; height: 96px; font-size: 1.8rem; }
  .lucky-item  { min-width: 110px; }
}
