/* =========================================================
   Sumi-e Visual System - Shared CSS
   =========================================================
   Ink Wash / Sumi-e art style foundation for web games.
   Loaded by each game via:
     <link rel="stylesheet" href="/games/shared/sumi-e.css">
   Provides colors, typography, textures, components,
   animations, and utility classes.
   ========================================================= */

/* --- Google Font --- */
@import url('https://fonts.googleapis.com/css2?family=Noto+Serif+JP:wght@400;700&display=swap');

/* --- Custom Properties --- */
:root {
  --paper: #f5f0e8;
  --ink: #1a1a2e;
  --ink-wash: #4a4a5a;
  --vermillion: #c0392b;
  --gold: #d4a574;
  --water: rgba(26, 26, 46, 0.15);
}

/* --- Rice Paper Texture Background --- */
.sumi-body {
  margin: 0;
  padding: 0;
  background-color: var(--paper);
  background-image:
    /* Fine grain noise layer */
    repeating-radial-gradient(
      circle at 17% 32%,
      transparent 0,
      transparent 1px,
      rgba(180, 170, 150, 0.08) 1px,
      rgba(180, 170, 150, 0.08) 2px
    ),
    repeating-radial-gradient(
      circle at 63% 71%,
      transparent 0,
      transparent 1px,
      rgba(160, 150, 130, 0.06) 1px,
      rgba(160, 150, 130, 0.06) 2px
    ),
    /* Coarser fiber texture */
    repeating-radial-gradient(
      circle at 41% 56%,
      transparent 0,
      transparent 3px,
      rgba(200, 190, 170, 0.04) 3px,
      rgba(200, 190, 170, 0.04) 5px
    );
  background-size: 7px 7px, 11px 11px, 23px 23px;
  min-height: 100vh;
  font-family: 'Noto Serif JP', serif;
  color: var(--ink);
}

/* --- Calligraphic Title --- */
.sumi-title {
  font-family: 'Noto Serif JP', serif;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: 0.05em;
  text-shadow:
    1px 1px 0 rgba(26, 26, 46, 0.15),
    -0.5px 0.5px 0 rgba(26, 26, 46, 0.08);
  margin: 0;
  line-height: 1.3;
  font-size: 2.5rem;
}

/* --- Lighter Subtitle --- */
.sumi-subtitle {
  font-family: 'Noto Serif JP', serif;
  font-weight: 400;
  color: var(--ink-wash);
  letter-spacing: 0.02em;
  margin: 0;
  line-height: 1.5;
  font-size: 1.2rem;
}

/* --- Ink Brush-Styled Button --- */
.sumi-button {
  display: inline-block;
  background: var(--ink);
  color: var(--paper);
  font-family: 'Noto Serif JP', serif;
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: 0.04em;
  border: 2px solid var(--ink);
  border-radius: 4px 8px 6px 10px;
  padding: 12px 28px;
  cursor: pointer;
  transition: background 0.25s ease, transform 0.1s ease, border-color 0.25s ease;
  text-decoration: none;
  line-height: 1;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

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

.sumi-button:active {
  transform: scale(0.96);
}

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

/* --- Red Seal Stamp --- */
.sumi-seal {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--vermillion);
  color: var(--paper);
  font-family: 'Noto Serif JP', serif;
  font-weight: 700;
  font-size: 1.3rem;
  border: 2px solid rgba(192, 57, 43, 0.8);
  box-shadow:
    0 0 0 1px rgba(192, 57, 43, 0.3),
    inset 0 1px 2px rgba(0, 0, 0, 0.15),
    0 2px 6px rgba(192, 57, 43, 0.25);
  line-height: 1;
  flex-shrink: 0;
}

/* --- Standard Text on Paper --- */
.sumi-text {
  color: var(--ink);
  font-family: 'Noto Serif JP', serif;
  font-weight: 400;
  line-height: 1.8;
  font-size: 1rem;
}

/* --- Canvas Wrapper --- */
.sumi-canvas-container {
  background: var(--paper);
  border: 1px solid var(--ink-wash);
  box-shadow:
    inset 0 1px 4px rgba(26, 26, 46, 0.1),
    inset 0 0 8px rgba(26, 26, 46, 0.05);
  position: relative;
  overflow: hidden;
}

.sumi-canvas-container canvas {
  display: block;
}

/* --- HUD Overlay --- */
.sumi-hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  padding: 12px 16px;
  color: var(--ink);
  font-family: 'Noto Serif JP', serif;
  font-weight: 700;
  font-size: 1rem;
  pointer-events: none;
  z-index: 10;
}

/* --- Start / Game-Over Overlay --- */
.sumi-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(245, 240, 232, 0.92);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  z-index: 100;
  gap: 16px;
}

/* =========================================================
   Keyframe Animations
   ========================================================= */

/* Ink spreading in */
@keyframes ink-spread {
  from {
    opacity: 0;
    transform: scale(0.8);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* Brush writing left-to-right reveal */
@keyframes brush-write {
  from {
    clip-path: inset(0 100% 0 0);
  }
  to {
    clip-path: inset(0 0 0 0);
  }
}

/* Ink dripping downward */
@keyframes ink-drip {
  from {
    transform: translateY(0);
    opacity: 1;
  }
  to {
    transform: translateY(30px);
    opacity: 0;
  }
}

/* Seal stamp impression */
@keyframes seal-stamp {
  from {
    transform: scale(1.5);
    opacity: 0;
  }
  50% {
    transform: scale(0.9);
    opacity: 1;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

/* Continuous rotation (for phonograph game) */
@keyframes record-spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

/* =========================================================
   Utility Classes
   ========================================================= */

.sumi-animate-spread {
  animation: ink-spread 0.5s ease-out both;
}

.sumi-animate-write {
  animation: brush-write 1s ease-out both;
}

.sumi-animate-stamp {
  animation: seal-stamp 0.4s ease-out both;
}

.hidden {
  display: none !important;
}

/* =========================================================
   Responsive
   ========================================================= */

@media (max-width: 600px) {
  .sumi-title {
    font-size: 1.6rem;
  }

  .sumi-subtitle {
    font-size: 1rem;
  }

  .sumi-seal {
    width: 46px;
    height: 46px;
    font-size: 1rem;
  }

  .sumi-button {
    padding: 10px 20px;
    font-size: 0.9rem;
  }

  .sumi-hud {
    padding: 8px 12px;
    font-size: 0.85rem;
  }

  .sumi-overlay {
    gap: 12px;
  }
}
