:root {
  --paper: #fbfbf7;
  --soil: #19291f;
  --rule: #ccd4c9;
  --clay: #f3eee7;
  color-scheme: light;
}
::selection {
  background: #d8e8ae;
  color: #152616;
}
h1,
h2,
h3 {
  text-wrap: balance;
}
button,
a {
  -webkit-tap-highlight-color: rgba(92, 119, 75, 0.16);
}
.sr {
  position: absolute;
  clip-path: inset(50%);
  width: 1px;
  height: 1px;
  overflow: hidden;
  white-space: nowrap;
}
.chapter {
  scroll-margin-top: 12px;
}
.interior {
  width: min(100% - 2 * var(--pad), 1232px);
  margin-inline: auto;
}
.chapter h2 {
  font-size: clamp(36px, 4vw, 62px);
  line-height: 1.23;
  letter-spacing: -0.055em;
  font-weight: 600;
}
.chapter p:not([class]) {
  line-height: 1.85;
}
.inline-link:hover {
  text-decoration: underline;
  text-underline-offset: 4px;
}
.bench-button {
  font: inherit;
  color: inherit;
  background: transparent;
  cursor: pointer;
  min-height: 44px;
  border: 1px solid #899c8b;
  border-radius: 23px;
  padding: 9px 17px;
  font-size: 13px;
}
.inline-link {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  font-size: 14px;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 5px;
}
.start :focus-visible {
  outline-color: #dbefad;
}
.start {
  background: var(--soil);
  color: #f3f8ec;
  padding: clamp(62px, 7vw, 106px) 0;
}
.start h2 {
  font-size: clamp(34px, 3.8vw, 60px);
}
footer {
  background: var(--soil);
  color: #e6efe1;
}
.foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  border-top: 1px solid #526154;
  padding: 22px 0;
}
.foot nav {
  flex-wrap: wrap;
  gap: 18px;
  font-size: 12px;
}
.foot nav a:hover {
  text-decoration: underline;
}
@media (max-width: 760px) {
  /* Reuse the first hero's overlapping word and image for this specific word. */
  #hero[data-mode="word"] .word-face {
    left: 1.3%;
    top: 50%;
    bottom: auto;
    transform: translateY(-17%);
  }
  #hero[data-mode="word"] #word-label {
    position: absolute;
    bottom: 100%;
    margin: 0 0 13px;
  }
  #hero[data-mode="word"] .apple {
    left: 47%;
    right: auto;
    top: 9%;
    bottom: auto;
    height: 64%;
    max-height: min(83vw, 390px);
  }
  #hero[data-mode="word"] .definition {
    min-height: 44px;
  }
  .foot {
    align-items: flex-start;
    flex-direction: column;
    gap: 9px;
  }
  .foot nav {
    gap: 7px 15px;
  }
  .foot nav a {
    padding: 7px 0;
  }
}
@media (max-width: 760px) and (max-height: 740px) {
  #hero[data-mode="word"] .apple {
    height: 61%;
  }
}
@media (max-width: 355px) {
  #hero[data-mode="word"] #word-label .lang {
    display: none;
  }
  #hero[data-mode="word"] #word-label {
    gap: 5px;
  }
  .start h2 {
    font-size: 30px;
  }
}

header {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  column-gap: 16px;
}
header nav {
  justify-self: end;
}
.language-picker {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  border: 1px solid #a9b5a9;
  border-radius: 24px;
}
.language-picker button {
  padding: 6px 16px;
  min-height: 44px;
  border: 0;
  border-radius: 22px;
  color: var(--ink);
  background: transparent;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}
.language-picker button[aria-pressed="true"],
.language-picker button:hover {
  background: #d7e1d3;
}
.language-picker button[aria-pressed="true"] {
  box-shadow: inset 0 0 0 1px #a4b49f;
}
#hero[data-language="tw"] .word-face h2 {
  font-family: "PingFang TC", "Noto Sans TC", system-ui, sans-serif;
  font-size: clamp(136px, 18.5vw, 276px);
  line-height: 1;
  font-weight: 650;
  letter-spacing: -0.06em;
  margin-left: -0.045em;
}
/* The second picker sits in the hero's tagline; it only shows on phones. */
.intro .language-picker {
  display: none;
}
.intro-lead {
  display: contents;
}
@media (max-width: 640px) {
  /* Phones: brand and the one action share a single row; the language
     choice moves into the tagline, where it names what the product is for. */
  header {
    grid-template-columns: 1fr auto;
    column-gap: 8px;
  }
  header .language-picker {
    display: none;
  }
  .intro p {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    margin-top: 12px;
    font-size: 13px;
  }
  /* "の" stays with the picker, so a wrapped line starts at "単語帳". */
  .intro-lead {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    white-space: nowrap;
  }
  .intro .language-picker {
    display: inline-flex;
    padding: 2px;
  }
  .intro .language-picker button {
    min-height: 40px;
    padding: 4px 12px;
  }
  #intro-language {
    display: none;
  }
}
@media (max-width: 760px) {
  #hero[data-language="tw"] .word-face h2 {
    font-size: clamp(86px, 28vw, 194px);
  }
}

/* Attach the pager to the selected word, clear of the object's scroll path. */
.word-picker {
  position: absolute;
  top: 100%;
  margin-top: 12px;
  left: 0;
  display: flex;
  gap: 10px;
  align-items: center;
}
.word-picker button {
  width: 44px;
  height: 44px;
  border: 1px solid #a5b3a5;
  border-radius: 50%;
  background: transparent;
  color: var(--ink);
  font-size: 19px;
}
.word-picker button:hover { background: #dce6d8; }
#word-index { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.stage { touch-action: pan-y pinch-zoom; }
#hero[data-mode="word"][data-word="sprout"] #large-slot { font-size: clamp(145px, 16.6vw, 272px); }
#hero[data-mode="word"][data-language="tw"][data-word="sprout"] #large-slot { font-size: clamp(136px, 18.5vw, 276px); }
#hero:not([data-word="peel"])[data-mode="word"] .apple { transform: none; }
/* Expressions: two lines, broken before the last word by page.js. */
#lemma { white-space: pre-line; }
#hero[data-mode="word"][data-kind="phrase"][data-language="en"] #large-slot {
  font-size: clamp(120px, 13.4vw, 214px);
  line-height: 0.88;
  letter-spacing: -0.05em;
}
#hero[data-mode="word"][data-word="to-go"][data-language="en"] #large-slot {
  font-size: clamp(150px, 18vw, 288px);
}
.exercise-prompt { white-space: pre-line; }
.traveling-word {
  pointer-events: none;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 3;
  object-fit: contain;
  transform-origin: 50% 50%;
}
@media (max-width: 760px) {
  .word-picker { gap: 6px; margin-top: 4px; }
  #hero[data-mode="word"][data-word="sprout"] #large-slot { font-size: clamp(81px, 23.8vw, 159px); }
  #hero[data-mode="word"][data-language="tw"][data-word="sprout"] #large-slot { font-size: clamp(86px, 28vw, 194px); }
  #hero[data-mode="word"][data-kind="phrase"][data-language="en"] #large-slot { font-size: clamp(64px, 19.5vw, 140px); }
  #hero[data-mode="word"][data-word="to-go"][data-language="en"] #large-slot { font-size: clamp(76px, 25vw, 180px); }
  #hero:not([data-word="peel"])[data-mode="word"] .apple { left: auto; right: 0; top: 3%; max-width: 49%; }
}
@media (max-width: 355px) {
  .word-picker { gap: 2px; }
  header .open { white-space: nowrap; padding-inline: 10px; gap: 5px; }
}
#word-label { white-space: nowrap; }

/* ---------- Hero intro: the sample word is typed in, then its card fills in ---------- */
.add-mark {
  position: relative;
  flex: none;
  width: 17px;
  height: 17px;
  border: 1.5px solid var(--ink);
  border-radius: 50%;
  background: var(--ink);
  transition: background 0.25s;
}
.add-mark::before,
.add-mark::after {
  content: "";
  position: absolute;
  transition: opacity 0.2s;
}
/* + while the word is being entered */
.add-mark::before {
  inset: 3px;
  background:
    linear-gradient(var(--ink), var(--ink)) center / 100% 1.5px no-repeat,
    linear-gradient(var(--ink), var(--ink)) center / 1.5px 100% no-repeat;
  opacity: 0;
}
/* ✓ once it is in the vocabulary book */
.add-mark::after {
  left: 4.6px;
  top: 1.6px;
  width: 4px;
  height: 8px;
  border: solid var(--field);
  border-width: 0 1.6px 1.6px 0;
  transform: rotate(45deg);
}
.type-caret {
  display: none;
}
html[data-intro="pending"] .add-mark,
html[data-intro="typing"] .add-mark {
  background: transparent;
}
html[data-intro="pending"] .add-mark::before,
html[data-intro="typing"] .add-mark::before {
  opacity: 1;
}
html[data-intro="pending"] .add-mark::after,
html[data-intro="typing"] .add-mark::after {
  opacity: 0;
}
html[data-intro="reveal"] .add-mark {
  animation: add-pop 0.38s cubic-bezier(0.3, 1.6, 0.5, 1);
}
@keyframes add-pop {
  from { transform: scale(0.6); }
}
html[data-intro="pending"] .type-caret,
html[data-intro="typing"] .type-caret {
  display: inline-block;
  width: 0.05em;
  height: 0.74em;
  margin-left: 0.035em;
  background: var(--ink);
}
html[data-intro="pending"] .type-caret {
  animation: caret 1s steps(1) infinite;
}
html[data-intro="pending"] #lemma {
  display: none;
}
html[data-intro="pending"] .apple,
html[data-intro="typing"] .apple {
  opacity: 0;
  scale: 0.9;
  rotate: -7deg;
  filter: blur(14px);
}
html[data-intro="pending"] .definition,
html[data-intro="typing"] .definition,
html[data-intro="pending"] .word-picker,
html[data-intro="typing"] .word-picker {
  opacity: 0;
  translate: 0 10px;
}
html[data-intro="reveal"] .apple {
  transition:
    opacity 0.45s ease-out,
    scale 0.9s cubic-bezier(0.2, 0.8, 0.2, 1),
    rotate 0.9s cubic-bezier(0.2, 0.8, 0.2, 1),
    filter 0.6s ease-out;
}
html[data-intro="reveal"] .definition {
  transition:
    opacity 0.4s 0.2s,
    translate 0.5s 0.2s cubic-bezier(0.2, 0.8, 0.2, 1);
}
html[data-intro="reveal"] .word-picker {
  transition:
    opacity 0.4s 0.4s,
    translate 0.5s 0.4s cubic-bezier(0.2, 0.8, 0.2, 1);
}

/* ---------- Start: three ways in, one ruled list ----------
   Heading on the left, the ways in on the right, ordered by how far the
   visitor wants to go. Rows instead of boxes; the first row's arrow is the
   only filled one. */
.start-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr);
  gap: clamp(32px, 6vw, 96px);
  align-items: center;
}
.paths {
  list-style: none;
  margin: 0;
  padding: 0;
  border-top: 1px solid #3d5444;
}
.paths li {
  border-bottom: 1px solid #3d5444;
}
/* Label over action on the left; the daily points and the arrow on the right. */
.path {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 176px 46px;
  grid-template-areas:
    "who fact go"
    "act fact go";
  align-items: center;
  row-gap: 3px;
  column-gap: 28px;
  padding: 22px 6px;
  color: #f3f8ec;
}
.path-who { grid-area: who; }
.path-act { grid-area: act; }
.path-fact { grid-area: fact; }
.path-go { grid-area: go; }
.path::before {
  content: "";
  position: absolute;
  inset: 0 -14px;
  z-index: -1;
  border-radius: 14px;
  background: #23382a;
  opacity: 0;
  transition: opacity 0.2s;
}
.path:hover::before {
  opacity: 1;
}
.start .interior {
  isolation: isolate;
}
.path-who {
  font-size: 13px;
  color: #b9c8b6;
}
.path-act {
  font-size: clamp(19px, 1.65vw, 25px);
  font-weight: 650;
  line-height: 1.3;
  letter-spacing: -0.035em;
}
.path-fact {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  font-weight: 600;
  color: #dfe8dc;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.path-meter {
  display: flex;
  gap: 3px;
}
.path-meter i {
  width: 11px;
  height: 6px;
  border-radius: 2px;
  background: rgba(243, 248, 236, 0.18);
}
.path-meter i.on {
  background: #b9dc8f;
}
.path-costs {
  flex-wrap: wrap;
  gap: 6px;
}
.path-costs span {
  padding: 3px 9px;
  border: 1px solid #4a654f;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 500;
  color: #d5dfd4;
}
.path-go {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border: 1px solid #5d7562;
  border-radius: 50%;
  transition: background 0.2s, border-color 0.2s, transform 0.2s;
}
.path-go svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.path:hover .path-go {
  border-color: #b9c8b6;
  transform: translate(2px, -2px);
}
.path-try .path-go {
  border-color: #b9dc8f;
  background: #b9dc8f;
  color: #17291c;
}
.path-try:hover .path-go {
  border-color: #cfeaa9;
  background: #cfeaa9;
}
@media (max-width: 1050px) {
  .start-layout {
    grid-template-columns: 1fr;
    align-items: start;
  }
}
@media (max-width: 640px) {
  .path {
    grid-template-columns: minmax(0, 1fr) 46px;
    grid-template-areas:
      "who go"
      "act go"
      "fact go";
    row-gap: 4px;
    column-gap: 14px;
    padding: 18px 2px;
  }
  .path::before {
    inset: 0 -10px;
  }
  .path-fact { margin-top: 8px; }
}
@media (prefers-reduced-motion: reduce) {
  .path:hover .path-go {
    transform: none;
  }
}

/* Tall phones: nothing sits under the pager any more, so centre the word and
   its picture in the stage instead of leaving the gap at the bottom. */
@media (max-width: 760px) and (min-height: 741px) {
  #hero[data-mode="word"] .word-face {
    top: 54%;
  }
  #hero[data-mode="word"] .apple {
    top: 13%;
  }
  #hero:not([data-word="peel"])[data-mode="word"] .apple {
    top: 7%;
  }
}
