/*
 * =============================================================
 * 기리고 (Girigo) Web - Stylesheet
 *
 * © 伤感咩吖 (Alex). All rights reserved.
 * 版权所有 © 伤感咩吖 (Alex)。
 *
 * 未经作者明确书面许可，禁止以任何形式盗用、转载、复用或商用本代码。
 * This code may not be copied, reposted, reused, or commercialized in any
 * form without the explicit written permission of the author.
 *
 * 声明：本项目不拥有图标（icons）与音频（audio）的版权，仅用于个人用途。
 * Disclaimer: The author does not claim ownership of any icons or audio
 * assets used in this project. They are included for personal use only.
 * =============================================================
 */

/* ===== CSS Variables ===== */
:root {
  --bg: #000000;
  --text: #ffffff;
  --record-ring: #f53333;
  --record-ring-bg: rgba(245,51,51,0.15);
  --control-bar: rgba(0,0,0,0.50);
  --page-width: 480px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-user-select: none;
  user-select: none;
  overflow: hidden;
  width: 100vw;
  height: 100dvh;
  overscroll-behavior: none;
  touch-action: manipulation;
}
img, video, svg { display: block; max-width: 100%; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }

/* ===== Splash Overlay ===== */
#splash {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100dvh;
  background: #000;
  display: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  z-index: 9999;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
#splash.show { display: flex; }
#splash .splash-text {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 1px;
  animation: splashPulse 1.5s ease-in-out infinite;
}
@keyframes splashPulse {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 1; }
}

/* ===== Page System ===== */
.page {
  position: absolute;
  top: 0; left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: var(--page-width);
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  display: none;
  background: var(--bg);
}
.page.active { display: flex; flex-direction: column; }

/* ===== Camera Background ===== */
.camera-bg {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  transform: scaleX(-1);
  -webkit-transform: scaleX(-1);
  z-index: 0;
  background: #000;
  will-change: transform;
}

/* ===== Shade overlay (ShadedCamera) ===== */
.shade {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.80);
  z-index: 1;
  pointer-events: none;
}

/* ===== Front Page Content ===== */
#page-front .page-content {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0;
  width: 100%;
  height: 100%;
  padding: 20px;
}

#page-front .camera-bg {
  filter: blur(20px);
  -webkit-filter: blur(20px);
}

.logo-wrap {
  width: 205px;
  height: auto;
  margin-bottom: 12px;
}

.hand-wrap {
  width: 523px;
  height: 436px;
  max-width: 90vw;
  display: flex;
  align-items: center;
  justify-content: center;
  padding-bottom: 40px;
}
.hand-wrap img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  image-rendering: pixelated;
}

/* Start button alpha pulse: animateFloat(1.0→0.0, 800ms, easeInOutCubic, Reverse) */
.btn-start {
  width: 205px;
  max-width: 90vw;
  margin-top: 4px;
  animation: btnAlpha 0.8s ease-in-out infinite alternate-reverse;
}
.btn-start svg { width: 100%; height: auto; }

@keyframes btnAlpha {
  0% { opacity: 1; }
  100% { opacity: 0; }
}

#page-front.fulfilled .camera-bg {
  filter: blur(20px);
  -webkit-filter: blur(20px);
}
#page-front.fulfilled .hand-wrap img {
  filter: brightness(0) saturate(100%) invert(29%) sepia(95%) saturate(3130%) hue-rotate(348deg) brightness(103%) contrast(94%);
  -webkit-filter: brightness(0) saturate(100%) invert(29%) sepia(95%) saturate(3130%) hue-rotate(348deg) brightness(103%) contrast(94%);
}
#page-front.fulfilled .logo-wrap svg,
#page-front.fulfilled .btn-start svg {
  filter: brightness(0) saturate(100%) invert(29%) sepia(95%) saturate(3130%) hue-rotate(348deg) brightness(103%) contrast(94%);
  -webkit-filter: brightness(0) saturate(100%) invert(29%) sepia(95%) saturate(3130%) hue-rotate(348deg) brightness(103%) contrast(94%);
}
#page-front.fulfilled .btn-start {
  opacity: 1;
  cursor: default;
}

/* ===== Camera Page ===== */
#page-camera {
  background: var(--bg);
}
.camera-ui {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  bottom: env(safe-area-inset-bottom);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 20px 16px;
  padding-bottom: max(20px, env(safe-area-inset-bottom));
  z-index: 2;
  pointer-events: none;
}
.camera-ui > * { pointer-events: auto; }

/* ===== Record Button (icon_hand + ring) ===== */
.btn-record-wrap {
  display: flex;
  justify-content: center;
  padding-bottom: 50px;
}
.btn-record {
  position: relative;
  width: 103.2px; height: 103.2px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.btn-record-svg {
  position: absolute;
  top: 0; left: 0;
  width: 103.2px; height: 103.2px;
  transform: rotate(-90deg);
}
.record-ring-track {
  fill: none;
  stroke: var(--text);
  stroke-width: 3.5;
  transition: stroke-opacity 0.2s;
}
.record-ring-fill {
  fill: none;
  stroke: var(--record-ring);
  stroke-width: 3.5;
  stroke-dasharray: 213.6;
  stroke-dashoffset: 213.6;
  transition: stroke-dashoffset 0.3s ease;
}
.record-icon-hand {
  position: relative;
  z-index: 1;
  width: 50.4px;
  height: auto;
  display: block;
}
.record-icon-hand path {
  fill: var(--text);
}

/* Recording state — pulse matches btn-start breathing */
.btn-record.recording .record-ring-track {
  stroke-opacity: 0.5;
}
.btn-record.recording .record-icon-hand path {
  fill: var(--record-ring) !important;
}
.btn-record.recording .record-icon-hand {
  animation: handPulse 0.8s ease-in-out infinite alternate-reverse;
}

@keyframes handPulse {
  0% { opacity: 1; }
  100% { opacity: 0; }
}

/* ===== Camera Error ===== */
.camera-error {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0,0,0,0.85);
  padding: 24px;
  border-radius: 16px;
  text-align: center;
  max-width: 80%;
  z-index: 3;
  display: none;
}
.camera-error.show { display: block; }
.btn-back {
  margin-top: 16px;
  color: var(--text);
  font-weight: 600;
  font-size: 16px;
  border-bottom: 1px solid var(--text);
}

/* ===== Preview Page ===== */
#page-preview {
  background: var(--bg);
}
#video-player { width: 100%; height: 100%; object-fit: cover; }
.preview-bar {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  display: flex;
  justify-content: center;
  gap: 14px;
  padding: 18px 16px;
  padding-bottom: max(18px, env(safe-area-inset-bottom));
  background: var(--control-bar);
  width: 100%;
}
.btn-secondary, .btn-primary {
  flex: 1;
  max-width: 240px;
  background: var(--text);
  color: #444444;
  font-size: 16px;
  font-weight: 600;
  padding: 12px 16px;
  border-radius: 8px;
  transition: transform 0.2s;
}
.btn-secondary {
  background: rgba(255,255,255,0.24);
  color: var(--text);
}
.btn-secondary:active, .btn-primary:active { transform: scale(0.96); }

/* ===== Countdown Page ===== */
#page-countdown {
  background: var(--bg);
}

.countdown-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  -webkit-user-select: none;
  user-select: none;
  overflow: visible;
}

.countdown-dial {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 360px;
  height: auto;
}

.countdown-dial-svg {
  width: 360px;
  height: 360px;
  overflow: visible;
  flex-shrink: 0;
}

.countdown-fill {
  fill: var(--record-ring);
}

.countdown-dot {
  fill: var(--text);
  transition: fill 0.3s ease;
}

.countdown-dot.active {
  fill: var(--record-ring);
}

.countdown-pointer {
  stroke: var(--record-ring);
  stroke-width: 2;
  opacity: 1;
  transition: opacity 0.5s ease;
}

.countdown-timer {
  font-size: 40px;
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  letter-spacing: 2px;
  text-align: center;
  text-shadow: 0 0 10px rgba(0,0,0,0.5);
  pointer-events: none;
  white-space: nowrap;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 2;
}

/* ===== Sending Page ===== */
#page-sending {
  background: var(--bg);
}
.sending-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 59px;
  padding: 90px 16px;
  width: 100%;
  height: 100%;
}
.sending-anim {
  width: 609.6px;
  height: 508px;
  max-width: 90vw;
  max-height: 50vh;
  display: flex;
  align-items: center;
  justify-content: center;
}
.sending-anim img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  image-rendering: pixelated;
}
.sending-footer {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 12px;
}
.sending-text-svg {
  width: 233px;
  max-width: 70vw;
  height: auto;
}
.loading-dots {
  display: flex;
  gap: 4px;
  align-items: flex-start;
}
.dot {
  display: block;
  width: 5px; height: 5px;
  background: var(--text);
  border-radius: 50%;
  opacity: 0;
  transition: opacity 0.2s ease-in-out;
}

/* ===== Wishes Come True Page ===== */
#page-wishes-come-true {
  background: var(--bg);
}
.wishes-come-true-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  padding: 32px;
}
.wishes-come-true-svg {
  width: 335px;
  max-width: min(76vw, 335px);
  height: auto;
  animation: wishesComeTrueIn 700ms ease-out both;
}

@keyframes wishesComeTrueIn {
  0% { opacity: 0; transform: translateY(10px); }
  100% { opacity: 1; transform: translateY(0); }
}

/* ===== Responsive ===== */
@media (max-width: 480px) {
  .logo-wrap { width: 150px; }
  .hand-wrap { width: 380px; height: 318px; }
  .btn-start { width: 180px; }
  .sending-anim { width: 440px; height: 366px; }
  .sending-text-svg { width: 170px; }
  .countdown-dial { width: 280px; height: auto; }
  .countdown-dial-svg { width: 280px; height: 280px; }
  .countdown-timer { font-size: 36px; }
  .camera-ui { padding: 16px 12px; padding-bottom: max(16px, env(safe-area-inset-bottom)); }
  .btn-record-wrap { padding-bottom: 40px; }
  .btn-record { width: 86.4px; height: 86.4px; }
  .btn-record-svg { width: 86.4px; height: 86.4px; }
  .record-icon-hand { width: 42px; }
}
@media (max-width: 360px) {
  .logo-wrap { width: 120px; }
  .hand-wrap { width: 300px; height: 251px; }
  .btn-start { width: 150px; }
  .sending-anim { width: 350px; height: 291px; }
  .sending-text-svg { width: 140px; }
  .countdown-dial { width: 230px; height: auto; }
  .countdown-dial-svg { width: 230px; height: 230px; }
  .countdown-timer { font-size: 30px; }
  .camera-ui { padding: 12px 10px; padding-bottom: max(12px, env(safe-area-inset-bottom)); }
  .btn-record-wrap { padding-bottom: 32px; }
  .btn-record { width: 74.4px; height: 74.4px; }
  .btn-record-svg { width: 74.4px; height: 74.4px; }
  .record-icon-hand { width: 36px; }
}

/*
 * =============================================================
 * 本代码由 伤感咩吖 (Alex) 独立开发制作。
 * Crafted by 伤感咩吖 (Alex).
 *
 * © 伤感咩吖 (Alex). All rights reserved.
 * 禁止盗用 / 转载 / 复用 / 商用。
 * No copying, reposting, reusing, or commercial use permitted.
 * =============================================================
 */
