/*
Theme Name: Birdsong Kyoto
Theme URI: https://birdsongkyoto.example
Author: KOKU Creative
Description: Warm, music-led, bilingual (EN/JA) homepage theme for Birdsong Kyoto — a parent-and-child early music & English class in Kyoto.
Version: 1.0.0
Requires at least: 6.4
Tested up to: 7.0
Requires PHP: 8.0
Text Domain: birdsong-kyoto
*/

/* ============================================================
   Birdsong Kyoto — design tokens & base styles
   Warm, nurturing, joyful-but-calm. Storybook / Japanese-craft.
   ============================================================ */

/* Metrics-matched fallbacks: keep line-wrapping identical before the webfont
   swaps in, so headings reserve the right height (no font-swap overlap/shift).
   Erring slightly wide so the fallback never under-reserves vs. the webfont. */
@font-face {
  font-family: "Fraunces Fallback";
  src: local("Georgia"), local("Times New Roman");
  size-adjust: 116%;
  ascent-override: 92%;
  descent-override: 26%;
}
@font-face {
  font-family: "Nunito Fallback";
  src: local("Arial");
  size-adjust: 103%;
}

:root {
  /* Palette */
  --washi:       #F4ECD8;  /* background */
  --washi-deep:  #EBE0C7;  /* subtle card / alt surface */
  --washi-soft:  #FAF5E9;  /* lifted card surface */
  --sage:        #9AAE8B;
  --sage-deep:   #5F7A5C;
  /* AA-accessible text variants (darker) for small text on light surfaces.
     Use for body/label text only; the base hues above remain for fills,
     borders, dots and large display where contrast already passes. */
  --sage-deep-text: #4C6249;
  --persimmon-text: #A8501F;
  --sage-tint:   #DDE5D3;  /* soft sage wash */
  --indigo:      #33597A;  /* primary / headings */
  --indigo-deep: #274A66;
  --indigo-tint: #DCE5EC;
  --persimmon:   #C9784E;  /* warm accent, sparing */
  --persimmon-soft: #F0D9CB;
  --ink:         #332E26;  /* body text */
  --ink-soft:    #6A6253;  /* muted text */

  /* Accent intensity (tweakable) */
  --accent: var(--persimmon);

  /* Type */
  --font-display: "Fraunces", "Fraunces Fallback", Georgia, serif;
  --font-body: "Nunito Sans", "Nunito Fallback", system-ui, -apple-system, sans-serif;
  --font-ja: "Zen Maru Gothic", "Nunito Sans", sans-serif;

  /* Heading scale (tweakable) */
  --h-scale: 1;

  /* Shape (tweakable) */
  --radius-sm: 14px;
  --radius:    22px;
  --radius-lg: 32px;
  --radius-pill: 999px;

  /* Spacing rhythm */
  --section-y: clamp(2.75rem, 5vw, 4.5rem);
  --gutter: clamp(1.25rem, 5vw, 4rem);
  --maxw: 1180px;

  /* Motion */
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
  --reveal-dur: 720ms;

  /* Soft shadows — warm-tinted, never harsh */
  --shadow-sm: 0 2px 8px rgba(51, 46, 38, 0.06);
  --shadow:    0 14px 40px -18px rgba(51, 46, 38, 0.28);
  --shadow-lift: 0 24px 60px -24px rgba(51, 46, 38, 0.34);
}

* { box-sizing: border-box; }

/* The [hidden] attribute must win over component display rules (e.g. the form's
   display:flex), so toggling `hidden` in JS actually hides the element. */
[hidden] { display: none !important; }

html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 18px;
  line-height: 1.7;
  color: var(--ink);
  /* Washi paper feel: a barely-there warm fiber texture over the base washi.
     Pure CSS (no image), so it's free. Subtle by design — felt, not seen. */
  background-color: var(--washi);
  background-image:
    repeating-linear-gradient(122deg, rgba(95,122,92,0.020) 0 1px, transparent 1px 7px),
    repeating-linear-gradient(58deg,  rgba(201,120,78,0.016) 0 1px, transparent 1px 9px),
    radial-gradient(circle at 18% 22%, rgba(255,255,255,0.5) 0, transparent 42%);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

:lang(ja), .is-ja {
  font-family: var(--font-ja);
  line-height: 1.85;
}

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-optical-sizing: auto;
  color: var(--indigo);
  font-weight: 540;
  line-height: 1.12;
  letter-spacing: -0.01em;
  margin: 0;
  text-wrap: pretty;
}

.is-ja h1, .is-ja h2, .is-ja h3, .is-ja h4 { font-family: var(--font-ja); font-weight: 700; letter-spacing: 0; }

/* Japanese line-breaking: break at natural phrase boundaries (kinsoku-aware)
   instead of mid-word, so headings/text never strand a small kana (っゃゅょ)
   or punctuation. Scoped to Japanese; modern browsers honour auto-phrase,
   older ones fall back to default wrapping (no harm). */
:lang(ja), .is-ja, .is-ja h1, .is-ja h2, .is-ja h3, .is-ja h4 {
  line-break: strict;
  word-break: auto-phrase;
  overflow-wrap: anywhere;
}

/* Phrase units (split on 、) break only between phrases, never mid-word. */
.bk-phrase { display: inline-block; }

a { color: var(--indigo); }

/* ---- Layout helpers ---- */
.wrap { width: 100%; max-width: var(--maxw); margin-inline: auto; padding-inline: var(--gutter); }
.section { padding-block: var(--section-y); }

.eyebrow {
  font-family: var(--font-body);
  font-weight: 800;
  font-size: 0.82rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--sage-deep-text);
  display: inline-flex;
  align-items: center;
  gap: 0.6em;
  margin: 0 0 1.1rem;
}
.eyebrow::before {
  content: "";
  width: 1.6rem; height: 2px; border-radius: 2px;
  background: var(--sage);
}

h1.display {
  font-size: calc(clamp(2.6rem, 6.4vw, 4.7rem) * var(--h-scale));
  font-weight: 500;
}
h2.title {
  font-size: calc(clamp(1.9rem, 3.4vw, 2.65rem) * var(--h-scale));
}
.lede {
  font-size: clamp(1.15rem, 1.9vw, 1.4rem);
  line-height: 1.6;
  color: var(--ink);
  max-width: 38ch;
}

/* ---- Buttons ---- */
.btn {
  font-family: var(--font-body);
  font-weight: 800;
  font-size: 1.02rem;
  border-radius: var(--radius-pill);
  padding: 0.92em 1.7em;
  border: 2px solid transparent;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.55em;
  text-decoration: none;
  line-height: 1;
  white-space: nowrap;
  transition: transform 220ms var(--ease), box-shadow 220ms var(--ease), background-color 220ms var(--ease), color 220ms var(--ease);
}
.btn-primary {
  background: var(--indigo);
  color: var(--washi);
  box-shadow: var(--shadow-sm);
}
.btn-primary:hover { background: var(--indigo-deep); transform: translateY(-2px); box-shadow: var(--shadow); }
.btn-secondary {
  background: transparent;
  color: var(--indigo);
  border-color: var(--indigo);
}
.btn-secondary:hover { background: var(--indigo); color: var(--washi); transform: translateY(-2px); }
.btn-lg { font-size: 1.12rem; padding: 1.05em 2em; }
.btn:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, button:focus-visible {
  outline: 3px solid var(--persimmon);
  outline-offset: 3px;
}

/* ---- Cards ---- */
.card {
  background: var(--washi-soft);
  border-radius: var(--radius-lg);
  padding: clamp(1.6rem, 3vw, 2.4rem);
  box-shadow: var(--shadow-sm);
  border: 1px solid rgba(51,46,38,0.05);
}

/* ---- Form fields ---- */
.field { display: flex; flex-direction: column; gap: 0.5rem; }
.field label { font-weight: 800; font-size: 0.95rem; color: var(--ink); }
.field .hint { font-size: 0.85rem; color: var(--ink-soft); font-weight: 600; }
.input, select.input {
  font-family: var(--font-body);
  font-size: 1.05rem;
  color: var(--ink);
  background: var(--washi-soft);
  border: 2px solid rgba(95,122,92,0.35);
  border-radius: var(--radius-sm);
  padding: 0.85em 1.1em;
  width: 100%;
  transition: border-color 200ms var(--ease), box-shadow 200ms var(--ease);
  appearance: none;
}
.input::placeholder { color: #A99F8C; }
.input:focus, select.input:focus {
  outline: none;
  border-color: var(--indigo);
  box-shadow: 0 0 0 4px var(--indigo-tint);
}
select.input {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2333597A' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 1.1em center;
  padding-right: 2.8em;
  cursor: pointer;
}

/* ---- Reveal-on-scroll ----
   Base state is VISIBLE (so screenshots, PDF export, and no-JS all show
   content). The pre-animation hidden state is only applied while
   <html> carries .pre-reveal, set synchronously by an inline head script. */
.pre-reveal .reveal {
  opacity: 0;
  transform: translateY(26px);
}
.reveal {
  transition: opacity var(--reveal-dur) var(--ease), transform var(--reveal-dur) var(--ease);
}
.reveal.in { opacity: 1; transform: none; }
.reveal[data-delay="1"] { transition-delay: 90ms; }
.reveal[data-delay="2"] { transition-delay: 180ms; }
.reveal[data-delay="3"] { transition-delay: 270ms; }
.reveal[data-delay="4"] { transition-delay: 360ms; }

/* ultimate failsafe: if JS reveal never runs OR the animation clock is
   throttled (transitions freeze), show everything instantly — transition:none
   makes the opacity change clock-independent */
.reveal-fallback .reveal { opacity: 1 !important; transform: none !important; transition: none !important; }

body.no-motion .reveal { opacity: 1; transform: none; transition: none; }
body.no-motion .btn:hover, body.no-motion .lift:hover { transform: none; }
@media (prefers-reduced-motion: reduce) {
  .reveal { opacity: 1 !important; transform: none !important; transition: none; }
}

/* gentle hover lift utility */
.lift { transition: transform 260ms var(--ease), box-shadow 260ms var(--ease); }
.lift:hover { transform: translateY(-4px); box-shadow: var(--shadow); }

/* ---- Image placeholder (no photos yet) ---- */
.ph {
  position: relative;
  background:
    repeating-linear-gradient(135deg, rgba(95,122,92,0.10) 0 12px, rgba(95,122,92,0.04) 12px 24px),
    var(--sage-tint);
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  color: var(--sage-deep);
}
.ph::after {
  content: attr(data-ph);
  font-family: "Nunito Sans", monospace;
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--sage-deep);
  background: rgba(244,236,216,0.82);
  padding: 0.5em 1em;
  border-radius: var(--radius-pill);
  text-align: center;
  max-width: 80%;
}

/* visually-hidden util for a11y */
.vh {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* skip link */
.skip {
  position: absolute; left: 1rem; top: -100px;
  background: var(--indigo); color: var(--washi);
  padding: 0.7em 1.2em; border-radius: var(--radius-pill);
  z-index: 200; font-weight: 800; text-decoration: none;
  transition: top 180ms var(--ease);
}
.skip:focus { top: 1rem; }
