/* write-practice.css — premium Japanese letter drawing studio */

.wp-page {
  max-width: 1040px;
  margin: 0 auto;
  padding-bottom: 88px;
}

.wp-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text3, #9a8f80);
  text-decoration: none;
  margin-bottom: 20px;
  transition: color 0.2s;
}
.wp-back:hover { color: var(--sakura, #ff6584); }

.wp-page-title {
  font-family: 'Nunito', sans-serif;
  font-size: clamp(1.5rem, 3.5vw, 2rem);
  font-weight: 800;
  color: #fff;
  letter-spacing: -0.02em;
  margin: 0 0 24px;
  line-height: 1.2;
}
.wp-page-title span[lang="ja"] {
  font-family: 'Noto Sans JP', sans-serif;
  font-weight: 900;
  background: linear-gradient(135deg, var(--sakura, #ff6584), var(--mint, #00f5d4));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* ── Flip card (lesson-style preview) ───────────────────────────── */
.wp-flip-section {
  display: flex;
  justify-content: center;
  margin-bottom: 28px;
}
.wp-flip-card {
  width: min(280px, 88vw);
  height: 200px;
  perspective: 1000px;
  cursor: pointer;
}
.wp-flip-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transition: transform 0.55s cubic-bezier(0.34, 1.2, 0.64, 1);
  transform-style: preserve-3d;
}
.wp-flip-card.is-flipped .wp-flip-inner {
  transform: rotateY(180deg);
}
.wp-flip-front,
.wp-flip-back {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  backface-visibility: hidden;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.4);
}
.wp-flip-front {
  background: linear-gradient(145deg, rgba(255, 101, 132, 0.15), rgba(13, 15, 18, 0.95));
}
.wp-flip-back {
  background: linear-gradient(145deg, rgba(0, 245, 212, 0.12), rgba(13, 15, 18, 0.95));
  transform: rotateY(180deg);
}
.wp-flip-label,
.wp-flip-hint {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text3, #9aa3c0);
}
.wp-flip-char {
  font-family: 'Noto Sans JP', sans-serif;
  font-size: 5rem;
  font-weight: 900;
  color: #fff;
  line-height: 1;
}
.wp-flip-romaji {
  font-family: 'Nunito', sans-serif;
  font-size: 1.6rem;
  font-weight: 700;
  color: #fff;
}
.wp-flip-gloss {
  font-size: 0.85rem;
  color: var(--text3, #9aa3c0);
}

/* ── Hero ───────────────────────────────────────────────────────── */
.wp-hero {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 28px 32px;
  padding: 28px 32px;
  margin-bottom: 28px;
  border-radius: 24px;
  background:
    radial-gradient(ellipse 80% 60% at 10% 20%, rgba(255, 101, 132, 0.14), transparent 55%),
    radial-gradient(ellipse 60% 50% at 90% 80%, rgba(0, 245, 212, 0.08), transparent 50%),
    linear-gradient(155deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.01));
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
}

.wp-hero-visual {
  position: relative;
  width: 148px;
  height: 148px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.wp-hero-ring {
  position: absolute;
  inset: 0;
}
.wp-hero-ring svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}
.wp-ring-track {
  fill: none;
  stroke: rgba(255, 255, 255, 0.08);
  stroke-width: 6;
}
.wp-ring-fill {
  fill: none;
  stroke: url(#wp-ring-grad);
  stroke-width: 6;
  stroke-linecap: round;
  stroke-dasharray: 326.7;
  stroke-dashoffset: 326.7;
  transition: stroke-dashoffset 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}
.wp-ring-label {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Nunito', sans-serif;
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--mint, #00f5d4);
  letter-spacing: 0.04em;
}

.wp-hero-char {
  position: relative;
  z-index: 1;
  font-family: 'Noto Sans JP', sans-serif;
  font-size: 4.6rem;
  font-weight: 900;
  line-height: 1;
  color: #fff;
  text-shadow:
    0 0 40px rgba(255, 101, 132, 0.45),
    0 0 80px rgba(0, 245, 212, 0.15);
  animation: wpCharFloat 4s ease-in-out infinite;
}

@keyframes wpCharFloat {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-4px); }
}

.wp-hero-info { min-width: 0; }
.wp-hero-romaji-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
  margin: 6px 0 8px;
}
.wp-hero-romaji {
  font-family: 'Nunito', sans-serif;
  font-size: 1.75rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--red, #e63946), var(--sakura, #ff6584));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.wp-hero-say {
  font-size: 0.88rem;
  color: var(--text3, #9a8f80);
  font-style: italic;
}
.wp-hero-gloss { font-size: 1rem; color: #ccc; margin-bottom: 4px; }
.wp-hint {
  font-size: 0.86rem;
  color: var(--text3, #888);
  line-height: 1.65;
  margin: 8px 0 16px;
  max-width: 52ch;
}

/* Buttons */
.wp-btn {
  font-family: 'Nunito', sans-serif;
  font-weight: 700;
  font-size: 0.8rem;
  padding: 9px 18px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.04);
  color: #ddd;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s, background 0.2s, transform 0.15s;
}
.wp-btn:hover {
  border-color: rgba(255, 101, 132, 0.45);
  color: #fff;
  background: rgba(255, 101, 132, 0.08);
}
.wp-btn--primary {
  background: linear-gradient(135deg, var(--red, #e63946), #ff4d6d);
  border-color: transparent;
  color: #fff;
  font-size: 0.92rem;
  padding: 13px 32px;
  box-shadow: 0 8px 28px rgba(230, 57, 70, 0.35);
}
.wp-btn--primary:hover {
  filter: brightness(1.08);
  color: #fff;
  transform: translateY(-1px);
}
.wp-btn--primary:disabled {
  background: var(--bg2, #141628);
  border-color: rgba(255, 255, 255, 0.08);
  color: #666;
  cursor: not-allowed;
  filter: none;
  box-shadow: none;
  transform: none;
}

.wp-diff {
  font-size: 0.76rem;
  font-weight: 700;
  padding: 6px 14px;
  border-radius: 100px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #cfcfcf;
}
.wp-diff--easy   { color: #34d399; border-color: rgba(52, 211, 153, 0.4); background: rgba(52, 211, 153, 0.1); }
.wp-diff--medium { color: #fbbf24; border-color: rgba(251, 191, 36, 0.4); background: rgba(251, 191, 36, 0.1); }
.wp-diff--hard   { color: #fb923c; border-color: rgba(251, 146, 60, 0.4); background: rgba(251, 146, 60, 0.1); }
.wp-diff--expert { color: #f87171; border-color: rgba(248, 113, 113, 0.45); background: rgba(248, 113, 113, 0.12); }

/* Step dots */
.wp-dots {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-bottom: 28px;
}
.wp-dot {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  font-weight: 800;
  color: #777;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.1);
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}
.wp-dot--done {
  color: #042f1f;
  background: var(--mint, #00f5d4);
  border-color: var(--mint, #00f5d4);
  box-shadow: 0 0 16px rgba(0, 245, 212, 0.4);
}
.wp-dot--current {
  color: #fff;
  border-color: var(--sakura, #ff6584);
  box-shadow: 0 0 0 3px rgba(255, 101, 132, 0.3), 0 0 20px rgba(255, 101, 132, 0.2);
  transform: scale(1.08);
}

/* ── Layout: sidebar + stage ────────────────────────────────────── */
.wp-layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 28px;
  align-items: start;
}

.wp-sidebar {
  position: sticky;
  top: 88px;
  padding: 20px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(12px);
}

.wp-stroke-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.wp-stroke-title {
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--sakura, #ff6584);
}
.wp-stroke-count {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--mint, #00f5d4);
}

.wp-strokes {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 20px;
  min-height: 48px;
}

.wp-stroke-chip {
  position: relative;
  width: 52px;
  height: 52px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(16, 18, 38, 0.8);
  cursor: default;
  overflow: hidden;
  transition: border-color 0.2s, box-shadow 0.2s, transform 0.2s;
}
.wp-stroke-chip canvas {
  display: block;
  width: 100%;
  height: 100%;
}
.wp-stroke-chip .wp-chip-num {
  position: absolute;
  top: 3px;
  left: 5px;
  font-size: 0.58rem;
  font-weight: 800;
  color: rgba(255, 255, 255, 0.5);
  z-index: 2;
  line-height: 1;
}
.wp-stroke-chip--active {
  border-color: var(--mint, #00f5d4);
  box-shadow: 0 0 0 2px rgba(0, 245, 212, 0.25), 0 0 20px rgba(0, 245, 212, 0.15);
  transform: scale(1.06);
}
.wp-stroke-chip--active .wp-chip-num { color: var(--mint, #00f5d4); }
.wp-stroke-chip--done {
  border-color: rgba(0, 245, 212, 0.35);
  opacity: 0.75;
}
.wp-stroke-chip--done .wp-chip-num { color: var(--mint, #00f5d4); }

.wp-learn-tips { display: flex; flex-direction: column; gap: 10px; }
.wp-tip-card {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.05);
}
.wp-tip-icon {
  flex-shrink: 0;
  font-size: 0.85rem;
  line-height: 1.4;
}
.wp-tip-card p {
  margin: 0;
  font-size: 0.76rem;
  line-height: 1.5;
  color: var(--text3, #9a8f80);
}
.wp-tip-card strong { color: #d7dcf2; font-weight: 600; }

/* ── Drawing stage ──────────────────────────────────────────────── */
.wp-main { min-width: 0; }

.wp-stage-frame {
  position: relative;
  max-width: 480px;
  margin: 0 auto;
  padding: 20px;
  border-radius: 28px;
  background:
    linear-gradient(160deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.01)),
    radial-gradient(circle at 50% 0%, rgba(255, 101, 132, 0.08), transparent 60%);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow:
    0 24px 64px rgba(0, 0, 0, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.wp-corner {
  position: absolute;
  font-family: 'Noto Sans JP', serif;
  font-size: 1.1rem;
  font-weight: 700;
  color: rgba(255, 101, 132, 0.25);
  pointer-events: none;
  user-select: none;
}
.wp-corner--tl { top: 14px; left: 18px; }
.wp-corner--br { bottom: 14px; right: 18px; }

.wp-stage-wrap { max-width: 440px; margin: 0 auto; }

.wp-actions {
  display: flex;
  justify-content: center;
  margin-top: 22px;
}

/* Practice cell — washi-dark paper square */
.wp-cell {
  position: relative;
  background:
    repeating-linear-gradient(
      0deg,
      transparent,
      transparent 2px,
      rgba(255, 255, 255, 0.015) 2px,
      rgba(255, 255, 255, 0.015) 4px
    ),
    linear-gradient(145deg, #12142a 0%, #0e1020 50%, #141830 100%);
  border: 2px solid rgba(255, 255, 255, 0.12);
  border-radius: 20px;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  box-shadow:
    inset 0 0 60px rgba(0, 0, 0, 0.5),
    inset 0 2px 0 rgba(255, 255, 255, 0.04);
  transition: border-color 0.4s, box-shadow 0.4s;
}

.wp-cell::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 30% 25%, rgba(255, 220, 200, 0.03), transparent 50%);
  pointer-events: none;
  z-index: 0;
}

.wp-cell-tag {
  position: absolute;
  top: 10px;
  left: 12px;
  z-index: 6;
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--sakura, #ff6584);
  background: rgba(13, 15, 18, 0.82);
  padding: 4px 10px;
  border-radius: 8px;
  border: 1px solid rgba(255, 101, 132, 0.2);
  pointer-events: none;
  backdrop-filter: blur(6px);
}

.wp-stroke-badge {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 4;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Nunito', sans-serif;
  font-size: 1.6rem;
  font-weight: 900;
  color: rgba(0, 245, 212, 0.12);
  border: 2px dashed rgba(0, 245, 212, 0.15);
  pointer-events: none;
  animation: wpBadgePulse 2s ease-in-out infinite;
}

@keyframes wpBadgePulse {
  0%, 100% { opacity: 0.6; transform: translate(-50%, -50%) scale(1); }
  50%      { opacity: 1; transform: translate(-50%, -50%) scale(1.04); }
}

.wp-guide {
  position: absolute;
  inset: 6%;
  width: 88%;
  height: 88%;
  opacity: 0.22;
  pointer-events: none;
  z-index: 1;
  filter: invert(1) brightness(1.6);
  transition: opacity 0.4s;
}

.wp-hint-canvas {
  position: absolute;
  inset: 0;
  z-index: 2;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.wp-canvas {
  position: relative;
  z-index: 3;
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: crosshair;
}

.wp-clear {
  position: absolute;
  bottom: 10px;
  right: 10px;
  z-index: 6;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(20, 22, 43, 0.9);
  color: var(--muted, #9a8f80);
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  backdrop-filter: blur(8px);
}
.wp-clear:hover {
  background: var(--red, #e63946);
  color: #fff;
  border-color: var(--red, #e63946);
  transform: rotate(-90deg);
}

.wp-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.wp-progress {
  font-size: 0.82rem;
  font-weight: 800;
  color: var(--red, #e63946);
  background: rgba(230, 57, 70, 0.12);
  border: 1px solid rgba(230, 57, 70, 0.3);
  padding: 6px 14px;
  border-radius: 100px;
}

.wp-cell-tag.wp-status-bad {
  color: #ff6b7a;
  background: rgba(230, 57, 70, 0.18);
  border-color: rgba(230, 57, 70, 0.35);
  animation: wpStatusShake 0.4s ease;
}

@keyframes wpStatusShake {
  0%, 100% { transform: translateX(0); }
  25%      { transform: translateX(-4px); }
  75%      { transform: translateX(4px); }
}

.wp-cell.wp-done {
  border-color: var(--mint, #00f5d4);
  box-shadow:
    0 0 0 2px rgba(0, 245, 212, 0.35),
    0 0 40px rgba(0, 245, 212, 0.12),
    inset 0 0 60px rgba(0, 0, 0, 0.5);
}
.wp-cell.wp-done .wp-cell-tag {
  color: #0b8a5e;
  background: rgba(0, 245, 212, 0.16);
  border-color: rgba(0, 245, 212, 0.35);
}
.wp-cell.wp-done .wp-stroke-badge { display: none !important; }

/* Feedback flashes */
@keyframes wpFlashOk {
  0%   { box-shadow: inset 0 0 0 0 rgba(0, 245, 212, 0), 0 0 0 0 rgba(0, 245, 212, 0); }
  30%  { box-shadow: inset 0 0 40px rgba(0, 245, 212, 0.15), 0 0 0 4px rgba(0, 245, 212, 0.5); }
  100% { box-shadow: inset 0 0 0 0 rgba(0, 245, 212, 0), 0 0 0 0 rgba(0, 245, 212, 0); }
}
@keyframes wpFlashBad {
  0%   { box-shadow: inset 0 0 0 0 rgba(230, 57, 70, 0), 0 0 0 0 rgba(230, 57, 70, 0); }
  30%  { box-shadow: inset 0 0 40px rgba(230, 57, 70, 0.12), 0 0 0 4px rgba(230, 57, 70, 0.55); }
  100% { box-shadow: inset 0 0 0 0 rgba(230, 57, 70, 0), 0 0 0 0 rgba(230, 57, 70, 0); }
}
.wp-flash-ok { animation: wpFlashOk 0.55s ease; }
.wp-flash-bad { animation: wpFlashBad 0.55s ease; }

/* Sakura celebration */
.wp-petal {
  position: absolute;
  top: -18px;
  z-index: 8;
  display: block;
  overflow: visible;
  opacity: 0;
  pointer-events: none;
  will-change: transform, opacity;
  animation-name: wpPetalFall;
  animation-timing-function: ease-in;
  animation-iteration-count: 1;
}
.wp-petal path {
  stroke: rgba(225, 110, 158, 0.45);
  stroke-width: 3;
}

@keyframes wpPetalFall {
  0%   { transform: translate(0, 0) rotate(0deg); opacity: 0; }
  10%  { opacity: var(--op, 0.9); }
  25%  { transform: translate(var(--sway, 12px), calc(var(--fall, 440px) * 0.25)) rotate(calc(var(--rot, 360deg) * 0.25)); }
  50%  { transform: translate(calc(var(--sway, 12px) * -1), calc(var(--fall, 440px) * 0.5)) rotate(calc(var(--rot, 360deg) * 0.5)); }
  75%  { transform: translate(var(--sway, 12px), calc(var(--fall, 440px) * 0.75)) rotate(calc(var(--rot, 360deg) * 0.75)); }
  90%  { opacity: var(--op, 0.9); }
  100% { transform: translate(calc(var(--sway, 12px) * -0.5), var(--fall, 440px)) rotate(var(--rot, 360deg)); opacity: 0; }
}

@keyframes wpCelebrateGlow {
  0%   { box-shadow: 0 0 0 0 rgba(249, 168, 197, 0); }
  35%  { box-shadow: 0 0 32px 8px rgba(249, 168, 197, 0.45); }
  100% { box-shadow: 0 0 0 2px rgba(0, 245, 212, 0.35); }
}
.wp-cell.wp-celebrate { animation: wpCelebrateGlow 1.3s ease-out; }

.wp-mastered-stamp {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 9;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px 7px 9px;
  background: var(--mint, #00f5d4);
  color: #04140d;
  border-radius: 100px;
  font-family: 'Nunito', sans-serif;
  font-weight: 800;
  font-size: 0.74rem;
  letter-spacing: 0.04em;
  box-shadow: 0 4px 18px rgba(0, 245, 212, 0.5);
  transform: scale(0);
  animation: wpStampPop 0.5s cubic-bezier(0.2, 1.4, 0.4, 1) forwards;
}
.wp-mastered-stamp .wp-stamp-check {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
}
.wp-mastered-stamp .wp-stamp-check::after {
  content: '';
  width: 6px;
  height: 10px;
  border: solid #0b8a5e;
  border-width: 0 2.5px 2.5px 0;
  transform: rotate(45deg);
  margin-top: -2px;
}
@keyframes wpStampPop {
  to { transform: scale(1); }
}

/* Responsive */
@media (max-width: 860px) {
  .wp-layout { grid-template-columns: 1fr; }
  .wp-sidebar {
    position: static;
    order: 2;
  }
  .wp-main { order: 1; }
  .wp-strokes { justify-content: center; }
}

@media (max-width: 600px) {
  .wp-hero {
    grid-template-columns: 1fr;
    text-align: center;
    padding: 24px 20px;
  }
  .wp-hero-visual { margin: 0 auto; }
  .wp-hero-romaji-row { justify-content: center; }
  .wp-toolbar { justify-content: center; }
  .wp-hero-char { font-size: 3.8rem; }
  .wp-stage-frame { padding: 14px; border-radius: 22px; }
}

@media (prefers-reduced-motion: reduce) {
  .wp-hero-char,
  .wp-stroke-badge { animation: none; }
  .wp-petal { display: none; }
  .wp-cell.wp-celebrate { animation: none; }
  .wp-mastered-stamp { animation: none; transform: scale(1); }
  .wp-ring-fill { transition: none; }
}