/* ═══════════════════════════════════════════════════
   HAIKU PAGE — Ukiyo-e × Art Deco
   ═══════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:ital,wght@0,300;0,400;0,600;1,300;1,400&family=Noto+Serif+JP:wght@300;400;600&family=Poiret+One&display=swap');

/* ── Palette ── */
:root {
  --hk-ink: #1a1520;
  --hk-indigo: #2d2b4e;
  --hk-indigo-light: #3e3a65;
  --hk-sakura: #d4918e;
  --hk-sakura-light: #e8b4b0;
  --hk-sakura-pale: #f2d5d3;
  --hk-sakura-wash: #faf0ef;
  --hk-gold: #c4a265;
  --hk-gold-light: #ddc38e;
  --hk-cream: #f7f0e8;
  --hk-cream-dark: #ede3d5;
  --hk-paper: #faf6f0;
  --hk-washi: #f5ede2;
  --hk-charcoal: #3a3540;
  --hk-grey: #8a8490;
  --hk-white: #fffdf9;
}

/* ── Reset for page ── */
#haiku-page {
  font-family: 'Cormorant Garamond', 'Noto Serif JP', Georgia, serif;
  color: var(--hk-ink);
  background: var(--hk-paper);
  line-height: 1.7;
  overflow-x: hidden;
}

#haiku-page *,
#haiku-page *::before,
#haiku-page *::after {
  box-sizing: border-box;
}

/* ── Washi paper texture (CSS-only) ── */
#haiku-page::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background-image:
    radial-gradient(ellipse at 20% 50%, rgba(212,145,142,0.06) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 30%, rgba(196,162,101,0.05) 0%, transparent 50%);
}

/* ══════════════════════════════════════
   HERO
   ══════════════════════════════════════ */
.haiku-hero {
  position: relative;
  min-height: 60vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    linear-gradient(175deg,
      var(--hk-indigo) 0%,
      #352f54 30%,
      #4a3f5e 60%,
      var(--hk-sakura) 100%);
  overflow: hidden;
}

/* Woodblock grain overlay */
.haiku-hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='400' height='400'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='400' height='400' filter='url(%23n)' opacity='0.08'/%3E%3C/svg%3E");
  opacity: 0.5;
  pointer-events: none;
}

/* Ukiyo-e wave pattern along bottom */
.haiku-hero::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 80px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1200 80' preserveAspectRatio='none'%3E%3Cpath d='M0 60 Q150 20 300 60 Q450 100 600 60 Q750 20 900 60 Q1050 100 1200 60 L1200 80 L0 80Z' fill='%23faf6f0' opacity='0.95'/%3E%3Cpath d='M0 65 Q150 30 300 65 Q450 100 600 65 Q750 30 900 65 Q1050 100 1200 65 L1200 80 L0 80Z' fill='%23faf6f0'/%3E%3C/svg%3E") no-repeat bottom center;
  background-size: 100% 80px;
}

.hero-frame {
  position: relative;
  z-index: 2;
  text-align: center;
  padding: 3rem;
}

/* Deco corner lines */
.hero-deco-line {
  position: absolute;
  width: 60px;
  height: 60px;
  border-color: var(--hk-gold);
  border-style: solid;
  border-width: 0;
  opacity: 0.6;
}
.hero-deco-line.top-left { top: 0; left: 0; border-top-width: 2px; border-left-width: 2px; }
.hero-deco-line.top-right { top: 0; right: 0; border-top-width: 2px; border-right-width: 2px; }
.hero-deco-line.bottom-left { bottom: 0; left: 0; border-bottom-width: 2px; border-left-width: 2px; }
.hero-deco-line.bottom-right { bottom: 0; right: 0; border-bottom-width: 2px; border-right-width: 2px; }

.hero-title {
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

.title-jp {
  font-family: 'Noto Serif JP', serif;
  font-size: clamp(3rem, 8vw, 6rem);
  font-weight: 300;
  color: var(--hk-sakura-pale);
  letter-spacing: 0.3em;
  text-shadow: 0 2px 20px rgba(0,0,0,0.3);
  line-height: 1.1;
}

.title-en {
  font-family: 'Poiret One', 'Cormorant Garamond', serif;
  font-size: clamp(1.2rem, 3vw, 2rem);
  font-weight: 400;
  color: var(--hk-gold-light);
  letter-spacing: 0.5em;
  text-transform: uppercase;
}

.hero-sub {
  margin-top: 1.5rem;
  font-family: 'Cormorant Garamond', serif;
  font-size: 1.1rem;
  font-style: italic;
  font-weight: 300;
  color: var(--hk-sakura-light);
  letter-spacing: 0.15em;
  opacity: 0.9;
}

/* Sakura particles container */
.sakura-fall {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  overflow: hidden;
}

/* ══════════════════════════════════════
   SECTION HEADINGS (Deco-ruled)
   ══════════════════════════════════════ */
.section-heading {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  margin-bottom: 2.5rem;
  font-family: 'Poiret One', sans-serif;
  font-size: 1.3rem;
  font-weight: 400;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--hk-indigo);
  text-align: center;
  justify-content: center;
}

.heading-rule {
  flex: 0 1 120px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--hk-gold), transparent);
}

/* ══════════════════════════════════════
   GENERATOR
   ══════════════════════════════════════ */
.haiku-generator {
  position: relative;
  z-index: 1;
  padding: 5rem 1.5rem;
  background: var(--hk-paper);
}

.gen-container {
  max-width: 680px;
  margin: 0 auto;
}

/* Toggle buttons */
.form-toggle {
  display: flex;
  justify-content: center;
  gap: 0;
  margin-bottom: 1rem;
  border: 1px solid var(--hk-gold);
  border-radius: 2px;
  overflow: hidden;
  max-width: 480px;
  margin-left: auto;
  margin-right: auto;
}

.toggle-btn {
  flex: 1;
  padding: 0.65rem 0.5rem;
  background: transparent;
  border: none;
  border-right: 1px solid var(--hk-gold);
  font-family: 'Cormorant Garamond', serif;
  font-size: 0.95rem;
  font-weight: 400;
  color: var(--hk-indigo);
  cursor: pointer;
  transition: background 0.3s, color 0.3s;
  letter-spacing: 0.08em;
}

.toggle-btn:last-child { border-right: none; }

.toggle-btn:hover {
  background: var(--hk-sakura-wash);
}

.toggle-btn.active {
  background: var(--hk-indigo);
  color: var(--hk-gold-light);
}

/* Form description */
.form-desc {
  text-align: center;
  font-style: italic;
  font-weight: 300;
  font-size: 0.95rem;
  color: var(--hk-grey);
  margin-bottom: 2rem;
  min-height: 1.5em;
  transition: opacity 0.3s;
}

/* Inputs */
.gen-inputs {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 1.2rem;
  margin-bottom: 2rem;
}

@media (max-width: 600px) {
  .gen-inputs {
    grid-template-columns: 1fr;
  }
}

.input-group label {
  display: block;
  font-family: 'Poiret One', sans-serif;
  font-size: 0.75rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--hk-indigo-light);
  margin-bottom: 0.4rem;
}

.input-group input,
.input-group select {
  width: 100%;
  padding: 0.6rem 0.8rem;
  background: var(--hk-washi);
  border: 1px solid var(--hk-cream-dark);
  border-radius: 2px;
  font-family: 'Cormorant Garamond', serif;
  font-size: 1rem;
  color: var(--hk-ink);
  transition: border-color 0.3s;
}

.input-group input:focus,
.input-group select:focus {
  outline: none;
  border-color: var(--hk-sakura);
  box-shadow: 0 0 0 2px rgba(212,145,142,0.15);
}

.input-group input::placeholder {
  color: var(--hk-grey);
  font-style: italic;
  font-weight: 300;
  opacity: 0.7;
}

/* Generate button */
.gen-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.8rem;
  margin: 0 auto 2.5rem;
  padding: 0.75rem 2.5rem;
  background: var(--hk-indigo);
  border: 1px solid var(--hk-gold);
  border-radius: 2px;
  color: var(--hk-gold-light);
  font-family: 'Poiret One', sans-serif;
  font-size: 1rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.3s, transform 0.15s;
}

.gen-btn:hover {
  background: var(--hk-indigo-light);
  transform: translateY(-1px);
}

.gen-btn:active {
  transform: translateY(0);
}

.gen-btn.secondary {
  background: transparent;
  color: var(--hk-indigo);
  border-color: var(--hk-sakura);
  margin-top: 1rem;
}

.gen-btn.secondary:hover {
  background: var(--hk-sakura-wash);
}

.btn-icon {
  font-family: 'Noto Serif JP', serif;
  font-size: 1.1rem;
}

/* Poem output */
.poem-output {
  margin-bottom: 1rem;
}

.poem-frame {
  position: relative;
  padding: 2.5rem 2rem;
  background: var(--hk-washi);
  border: 1px solid var(--hk-cream-dark);
  min-height: 140px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

/* Deco corners on poem card */
.poem-corner {
  position: absolute;
  width: 20px;
  height: 20px;
}
.poem-corner::before,
.poem-corner::after {
  content: '';
  position: absolute;
  background: var(--hk-gold);
}
.poem-corner::before { width: 20px; height: 1px; }
.poem-corner::after { width: 1px; height: 20px; }

.poem-corner.tl { top: 8px; left: 8px; }
.poem-corner.tl::before { top: 0; left: 0; }
.poem-corner.tl::after { top: 0; left: 0; }

.poem-corner.tr { top: 8px; right: 8px; }
.poem-corner.tr::before { top: 0; right: 0; }
.poem-corner.tr::after { top: 0; right: 0; }

.poem-corner.bl { bottom: 8px; left: 8px; }
.poem-corner.bl::before { bottom: 0; left: 0; }
.poem-corner.bl::after { bottom: 0; left: 0; }

.poem-corner.br { bottom: 8px; right: 8px; }
.poem-corner.br::before { bottom: 0; right: 0; }
.poem-corner.br::after { bottom: 0; right: 0; }

.poem-body {
  text-align: center;
  font-size: 1.25rem;
  font-weight: 300;
  line-height: 2;
  letter-spacing: 0.04em;
}

.poem-body .poem-line {
  display: block;
  opacity: 0;
  transform: translateY(8px);
  animation: poemLineIn 0.6s ease forwards;
}
.poem-body .poem-line:nth-child(1) { animation-delay: 0.1s; }
.poem-body .poem-line:nth-child(2) { animation-delay: 0.4s; }
.poem-body .poem-line:nth-child(3) { animation-delay: 0.7s; }
.poem-body .poem-line:nth-child(4) { animation-delay: 1.0s; }
.poem-body .poem-line:nth-child(5) { animation-delay: 1.3s; }

/* Haibun prose block */
.poem-body .haibun-prose {
  display: block;
  font-size: 1rem;
  font-style: italic;
  line-height: 1.8;
  margin-bottom: 1.5rem;
  text-align: left;
  max-width: 480px;
  opacity: 0;
  transform: translateY(8px);
  animation: poemLineIn 0.8s ease forwards;
  animation-delay: 0.1s;
}

.poem-body .haibun-verse {
  display: block;
  margin-top: 1rem;
  opacity: 0;
  transform: translateY(8px);
  animation: poemLineIn 0.6s ease forwards;
  animation-delay: 0.9s;
}

@keyframes poemLineIn {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.poem-placeholder {
  color: var(--hk-grey);
  font-style: italic;
  font-weight: 300;
  font-size: 1rem;
  opacity: 0.6;
}

.poem-form-label {
  position: absolute;
  bottom: 10px;
  right: 14px;
  font-family: 'Poiret One', sans-serif;
  font-size: 0.65rem;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  color: var(--hk-sakura);
  opacity: 0.7;
}

/* ══════════════════════════════════════
   HISTORY
   ══════════════════════════════════════ */
.haiku-history {
  position: relative;
  z-index: 1;
  padding: 4rem 1.5rem 6rem;
  background: var(--hk-cream);
  border-top: 1px solid var(--hk-cream-dark);
}

/* Subtle wave separator at top */
.haiku-history::before {
  content: '';
  position: absolute;
  top: -40px;
  left: 0;
  right: 0;
  height: 40px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1200 40' preserveAspectRatio='none'%3E%3Cpath d='M0 40 L0 20 Q300 0 600 20 Q900 40 1200 20 L1200 40Z' fill='%23f7f0e8'/%3E%3C/svg%3E") no-repeat;
  background-size: 100% 40px;
}

.history-container {
  max-width: 720px;
  margin: 0 auto;
}

.history-body p {
  margin-bottom: 1.4rem;
  font-size: 1.05rem;
  font-weight: 300;
  color: var(--hk-charcoal);
}

.history-lede {
  font-size: 1.15rem !important;
  font-weight: 400 !important;
  color: var(--hk-ink) !important;
  border-left: 3px solid var(--hk-gold);
  padding-left: 1.2rem;
  margin-bottom: 2rem !important;
}

.history-subhead {
  font-family: 'Poiret One', sans-serif;
  font-size: 1.05rem;
  font-weight: 400;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--hk-indigo);
  margin: 2.5rem 0 1rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--hk-sakura-light);
}

.history-body em {
  font-style: italic;
  color: var(--hk-indigo-light);
}

.history-body strong {
  font-weight: 600;
  color: var(--hk-ink);
}

.history-coda {
  margin-top: 3rem;
  padding: 2rem;
  text-align: center;
  border-top: 1px solid var(--hk-gold);
  border-bottom: 1px solid var(--hk-gold);
}

.history-coda p {
  font-size: 1.1rem !important;
  font-style: italic;
  font-weight: 400 !important;
  color: var(--hk-indigo) !important;
  margin-bottom: 0 !important;
  line-height: 1.9;
}

/* ══════════════════════════════════════
   RESPONSIVE
   ══════════════════════════════════════ */
@media (max-width: 768px) {
  .haiku-hero { min-height: 50vh; }
  .hero-frame { padding: 2rem 1.5rem; }
  .hero-deco-line { width: 40px; height: 40px; }
  .poem-frame { padding: 2rem 1.5rem; }
  .history-container { padding: 0 0.5rem; }
}

@media (max-width: 480px) {
  .form-toggle { flex-direction: column; }
  .toggle-btn { border-right: none; border-bottom: 1px solid var(--hk-gold); }
  .toggle-btn:last-child { border-bottom: none; }
}
