/* Hiroto sample. Winter morning: navy sky, dawn field, silver lines.
   Mobile first. System fonts only. Body text is held to WCAG AA. */

:root {
  --bg: #eef3f8;
  --bg-deep: #0e243c;
  --sky-top: #071422;
  --sky-mid: #0c2340;
  --sky-low: #1e5580;
  --paper: #f7fafc;
  --ink: #102033;
  --ink-soft: #31465c;
  --on-deep: #f4f7fb;
  --on-deep-soft: #d6e2f0;
  --accent: #184872;
  --line: #8ea3b8;
  --header-h: 57px;
  --horizon: 182px;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Yu Mincho", "YuMincho",
    "Hiragino Mincho ProN", "Noto Serif JP", "Noto Serif CJK JP", serif;
  --sans: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Hiragino Kaku Gothic ProN",
    "Yu Gothic", "Noto Sans JP", "Noto Sans CJK JP", "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

html {
  scroll-padding-top: calc(var(--header-h) + env(safe-area-inset-top));
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 1rem;
  line-height: 1.75;
  line-break: strict;
  word-break: auto-phrase;
  -webkit-font-smoothing: antialiased;
}

::selection {
  background: var(--sky-low);
  color: var(--on-deep);
}

.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  z-index: 100;
  padding: 10px 16px;
  background: var(--sky-top);
  color: var(--on-deep);
  border-radius: 0 0 4px 0;
}

.skip-link:focus {
  left: 0;
}

:focus-visible {
  outline: 2px solid var(--on-deep);
  outline-offset: 3px;
  box-shadow: 0 0 0 5px var(--sky-top);
}

.wrap {
  width: min(100% - 40px, 40rem);
  margin-inline: auto;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

html[data-lang="en"] .eyebrow {
  letter-spacing: 0.12em;
}

h2 {
  margin: 0 0 18px;
  font-size: clamp(1.55rem, 4vw, 2.05rem);
  font-weight: 600;
  line-height: 1.35;
  text-wrap: balance;
}

a {
  color: inherit;
}

.brand,
.next {
  text-decoration: none;
}

/* Header */

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  padding-top: env(safe-area-inset-top);
  background: rgba(7, 20, 34, 0.94);
  color: var(--on-deep);
  border-bottom: 1px solid rgba(214, 226, 240, 0.4);
  backdrop-filter: blur(10px);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: var(--header-h);
}

.brand {
  font-family: var(--serif);
  font-size: 1.2rem;
  letter-spacing: 0.12em;
  color: var(--on-deep);
}

.lang-toggle {
  min-width: 7.5rem;
  min-height: 44px;
  padding: 8px 14px;
  border: 1px solid #c5d4e4;
  border-radius: 4px;
  background: transparent;
  color: var(--on-deep);
  font: inherit;
  font-size: 0.9rem;
  cursor: pointer;
  touch-action: manipulation;
}

.lang-toggle:hover {
  border-color: var(--on-deep);
}

/* Sky */

.sky {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: calc(100svh - var(--header-h) - env(safe-area-inset-top));
  overflow: hidden;
  background: linear-gradient(
    180deg,
    var(--sky-top) 0%,
    var(--sky-mid) 46%,
    var(--sky-low) calc(100% - var(--horizon)),
    var(--sky-low) 100%
  );
  color: var(--on-deep);
}

.flock {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

.bird {
  position: absolute;
  display: block;
  height: auto;
}

.bird path,
.closing-mark path {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.bird-1 {
  top: 18px;
  left: 10%;
  width: 32px;
  color: #f4f7fb;
}

.bird-2 {
  top: 54px;
  left: 64%;
  width: 18px;
  color: #d6e2f0;
}

.bird-3 {
  top: 34px;
  left: 36%;
  width: 26px;
  color: #e7eef6;
}

.sky-copy {
  position: relative;
  z-index: 1;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 96px 0 28px;
}

.sky .eyebrow {
  color: var(--on-deep-soft);
}

.hero-name {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(4.6rem, 24vw, 8rem);
  font-weight: 500;
  line-height: 1.05;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.reading {
  margin: 14px 0 0;
  color: var(--on-deep-soft);
  font-size: 1.15rem;
  letter-spacing: 0.42em;
}

.romaji {
  margin: 4px 0 0;
  color: var(--on-deep-soft);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.28em;
  text-transform: uppercase;
}

.rule {
  width: 40px;
  height: 1px;
  margin: 20px 0;
  border: 0;
  background: var(--on-deep-soft);
}

.born {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 0;
  margin: 0;
  padding: 0;
  list-style: none;
  color: var(--on-deep);
}

.born li {
  display: flex;
  align-items: center;
}

.born li + li::before {
  content: "";
  width: 3px;
  height: 3px;
  margin: 0 10px;
  border-radius: 50%;
  background: var(--on-deep-soft);
}

.next {
  display: inline-flex;
  align-items: center;
  align-self: flex-start;
  gap: 8px;
  min-height: 44px;
  margin-top: 28px;
  padding: 8px 16px;
  border: 1px solid #c5d4e4;
  border-radius: 4px;
  background: var(--sky-mid);
  color: var(--on-deep);
  font-weight: 700;
  font-size: 0.92rem;
  touch-action: manipulation;
}

.next::after {
  content: "";
  width: 7px;
  height: 7px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: translateY(-2px) rotate(45deg);
}

.next:hover {
  border-color: var(--on-deep);
}

.horizon {
  position: relative;
  z-index: 1;
  overflow: hidden;
}

.ridge {
  display: block;
  width: 100%;
  height: 110px;
  background: var(--sky-low);
}

.ridge path {
  fill: none;
  stroke: #e7eef6;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}

.dawn {
  height: 72px;
  background: linear-gradient(180deg, var(--sky-low) 0%, var(--bg) 78%);
}

/* Kanji */

.meaning {
  padding: 56px 0 72px;
}

.meaning-head h2 {
  margin: 0;
}

.kanji-row {
  display: grid;
  grid-template-columns: 4.75rem 1fr;
  gap: 8px 18px;
  align-items: center;
  padding: 22px 0;
  border-top: 1px solid var(--line);
}

.kanji-row:last-child {
  border-bottom: 1px solid var(--line);
}

.kanji-char {
  margin: 0;
  font-family: var(--serif);
  font-size: 3.3rem;
  line-height: 1;
}

.kanji-kana-label {
  margin: 0;
  color: var(--accent);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.kanji-read {
  margin: 0;
  font-size: 1.15rem;
  letter-spacing: 0.18em;
}

.kanji-row h3 {
  margin: 8px 0 0;
  font-size: 1.05rem;
  font-weight: 600;
  text-wrap: balance;
}

.kanji-body {
  margin: 4px 0 0;
  color: var(--ink-soft);
  font-size: 0.95rem;
}

/* Chapters */

.chapter {
  padding: 72px 0;
}

.why {
  background: var(--bg-deep);
  color: var(--on-deep);
}

.why .eyebrow {
  color: var(--on-deep-soft);
}

.parents {
  margin: 0;
  padding: 0 0 0 16px;
  border-left: 1px solid var(--on-deep-soft);
}

.parents p {
  margin: 0 0 14px;
  font-size: 1.05rem;
}

.parents p:last-child {
  margin-bottom: 0;
}

.sign {
  margin: 18px 0 0;
  font-family: var(--serif);
  text-align: right;
  color: var(--on-deep-soft);
}

/* Birth day */

.facts {
  margin: 0;
}

.fact {
  display: grid;
  grid-template-columns: 6.5rem 1fr;
  gap: 8px 16px;
  align-items: baseline;
  margin: 0;
  padding: 14px 0;
  border-top: 1px solid var(--line);
}

.fact:last-child {
  border-bottom: 1px solid var(--line);
}

.fact dt {
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.fact dd {
  margin: 0;
  font-size: 1.08rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.nowrap {
  white-space: nowrap;
}

.timeline {
  counter-reset: step;
  list-style: none;
  margin: 36px 0 0;
  padding: 0;
}

.timeline li {
  display: grid;
  grid-template-columns: 2.6rem 1fr;
  column-gap: 12px;
  padding: 16px 0;
  border-top: 1px solid var(--line);
}

.timeline li:last-child {
  border-bottom: 1px solid var(--line);
}

.timeline li::before {
  content: counter(step, decimal-leading-zero);
  counter-increment: step;
  grid-column: 1;
  grid-row: 1 / span 2;
  padding-top: 0.15em;
  color: var(--accent);
  font-size: 0.82rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
}

.timeline h3 {
  grid-column: 2;
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
}

.timeline p {
  grid-column: 2;
  margin: 2px 0 0;
  color: var(--ink-soft);
}

/* Letter */

.letter-chapter .wrap {
  display: grid;
  gap: 8px;
}

.envelope {
  position: relative;
  color: var(--ink);
}

.flap {
  display: none;
}

.letter {
  padding: 8px 2px 0;
  scroll-margin-top: calc(var(--header-h) + env(safe-area-inset-top) + 12px);
}

.letter-to {
  margin: 0 0 16px;
  font-family: var(--serif);
  font-size: 1.45rem;
}

.letter p {
  margin: 0 0 14px;
}

.letter-sign {
  margin: 22px 0 0;
  font-family: var(--serif);
  text-align: right;
}

.letter-date {
  margin: 2px 0 0;
  color: var(--ink-soft);
  font-size: 0.92rem;
  text-align: right;
}

.seal {
  display: none;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: pointer;
  touch-action: manipulation;
}

.wax {
  width: 92px;
  height: 92px;
  filter: drop-shadow(0 8px 12px rgba(4, 12, 24, 0.35));
}

.seal-open-label {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.seal-kicker {
  font-family: var(--serif);
  font-size: 1.28rem;
}

.seal-hint {
  color: var(--on-deep-soft);
  font-size: 0.88rem;
}

.seal-close-label {
  display: none;
}

/* Sealed until the seal is tapped. no-js readers see the letter instead. */

.js .envelope:not(.is-open) {
  border-radius: 6px;
  box-shadow: 0 18px 40px rgba(7, 20, 34, 0.12);
  min-height: 400px;
  overflow: hidden;
  color: var(--on-deep);
  background: linear-gradient(180deg, #143552 0%, #0c1c31 100%);
  border-color: rgba(214, 226, 240, 0.45);
}

.js .envelope:not(.is-open) .flap {
  display: block;
  position: absolute;
  z-index: 1;
  left: 0;
  right: 0;
  top: 0;
  height: 54%;
  background: linear-gradient(180deg, #245888 0%, #1a456c 100%);
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  transform-origin: 50% 0;
  pointer-events: none;
}

.js .envelope:not(.is-open) #letter {
  display: none;
}

.js .seal {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  width: 100%;
  text-align: center;
}

.js .envelope:not(.is-open) .seal {
  position: absolute;
  z-index: 2;
  inset: 0;
  padding: 24px 20px;
}

.js .envelope:not(.is-open) .seal:focus-visible {
  outline-offset: -6px;
}

.js .envelope.is-opening .flap {
  transform: translateY(-70%);
  opacity: 0;
}

.js .envelope.is-opening .wax,
.js .envelope.is-opening .seal-open-label {
  opacity: 0;
}

.js .envelope.is-open {
  background: var(--paper);
  color: var(--ink);
  border-color: var(--line);
}

.js .envelope.is-open .seal {
  min-height: 48px;
  padding: 4px 16px 20px;
  color: var(--accent);
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.js .envelope.is-open .wax,
.js .envelope.is-open .seal-open-label {
  display: none;
}

.js .envelope.is-open .seal-close-label {
  display: inline;
}

/* Closing */

.closing {
  padding: 72px 0 calc(80px + env(safe-area-inset-bottom));
}

.closing-mark {
  width: 36px;
  height: auto;
  margin: 0 0 16px;
  color: var(--accent);
}

.closing-from {
  margin: 0;
  font-family: var(--serif);
  font-size: 1.5rem;
  letter-spacing: 0.04em;
}

.closing-note {
  margin: 16px 0 0;
  font-size: 0.92rem;
}

.closing-note a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.closing-note a:hover {
  color: var(--ink);
}

@media (min-width: 720px) {
  .kanji-row {
    grid-template-columns: 6rem 1fr;
    padding: 28px 0;
  }

  .kanji-char {
    font-size: 4rem;
  }

  .letter {
    padding: 44px 48px 12px;
  }
}

@media (max-height: 700px) {
  :root {
    --horizon: 128px;
  }

  .sky {
    min-height: 0;
  }

  .sky-copy {
    padding: 84px 0 16px;
  }

  .hero-name {
    font-size: clamp(3.2rem, 16vw, 5rem);
  }

  .ridge {
    height: 84px;
  }

  .dawn {
    height: 44px;
  }
}

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

  .bird-1,
  .bird-2,
  .bird-3 {
    left: 0;
    animation: fly linear infinite;
  }

  .bird-1 {
    animation-duration: 48s;
    animation-delay: -12s;
  }

  .bird-2 {
    animation-duration: 74s;
    animation-delay: -40s;
  }

  .bird-3 {
    animation-duration: 58s;
    animation-delay: -24s;
  }

  .motion .reveal {
    opacity: 0;
    transform: translateY(14px);
    transition: opacity 0.7s ease, transform 0.7s ease;
  }

  .motion .reveal.is-in {
    opacity: 1;
    transform: none;
  }

  .motion .timeline .reveal:nth-child(2) {
    transition-delay: 0.08s;
  }

  .motion .timeline .reveal:nth-child(3) {
    transition-delay: 0.16s;
  }

  .motion .timeline .reveal:nth-child(4) {
    transition-delay: 0.24s;
  }

  .flap,
  .wax,
  .seal-open-label {
    transition: transform 0.5s ease, opacity 0.45s ease;
  }

  .letter.is-rising {
    animation: rise 0.6s ease;
  }

  .seal:active .wax {
    transform: scale(0.97);
  }
}

@media (prefers-reduced-motion: reduce) {
  .motion .reveal,
  .letter.is-rising {
    opacity: 1;
    transform: none;
    animation: none;
    transition: none;
  }
}

@keyframes fly {
  from {
    transform: translate3d(-12vw, 0, 0);
  }

  to {
    transform: translate3d(108vw, 0, 0);
  }
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(12px);
  }

  to {
    opacity: 1;
    transform: none;
  }
}
