/*
 * Teihon — teihon.com
 *
 * The palette is lifted from the application itself rather than invented for
 * the page. Someone who downloads after reading this should recognise what they
 * opened; a site in different colours from its product quietly says the
 * screenshots were staged.
 */

:root[data-theme='light'] {
  color-scheme: light;

  --bg: #faf9f6;
  --bg-raised: #ffffff;
  --chrome: #f6f5f2;
  --border: rgba(0, 0, 0, 0.09);
  --text: #1c1c1a;
  --text-dim: #6d6c66;
  --text-faint: #8b8a85;
  --accent: #2f66d8;
  --accent-soft: rgba(61, 125, 255, 0.1);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 24px 56px -20px rgba(20, 20, 18, 0.28);
}

:root[data-theme='dark'] {
  color-scheme: dark;

  --bg: #131314;
  --bg-raised: #1c1c1d;
  --chrome: #1e1e1f;
  --border: rgba(255, 255, 255, 0.11);
  --text: #ececeb;
  --text-dim: #a3a29d;
  --text-faint: #7d7d79;
  --accent: #7ba6ff;
  --accent-soft: rgba(111, 157, 255, 0.14);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 28px 64px -20px rgba(0, 0, 0, 0.7);
}

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

html {
  scroll-behavior: smooth;
}

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', system-ui,
    sans-serif;
  font-size: 17px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* The one place a Japanese face is wanted, and the only place it is loaded from:
   whatever the reader's system already has. A web font for two characters would
   cost more than it earns. */
.kanji,
.kanji-xl {
  font-family: 'Hiragino Mincho ProN', 'Yu Mincho', 'YuMincho', 'MS Mincho', serif;
  font-weight: 500;
}

/*
 * Sit 底本 with Teihon rather than above it.
 *
 * Baseline alignment is right for text running in a line and wrong for these
 * two side by side, and the ink says why: at these sizes the kanji reach 18px
 * above the baseline and 1px below, where Teihon reaches 12px above and nothing
 * below. CJK glyphs fill their em box; Latin lowercase spends half of its on
 * descenders this word does not use. Baselines locked together therefore leave
 * the kanji's optical centre 2.5px above the word's, which is what reads as
 * floating.
 *
 * Centring the boxes instead recovers 1.1px of the 2.5, for the same reason the
 * problem exists — the boxes are different heights. So the baselines stay
 * aligned and the kanji drops by the measured difference. Relative positioning,
 * so layout and therefore the baseline alignment being corrected are untouched;
 * only the paint moves.
 *
 * Scoped to the wordmark rather than every .kanji. The shift is not a property
 * of the character but the gap between two ink heights, and it follows the
 * ratio of the two sizes: 21 against 15 gives 2.5px, while the footer's 16
 * against 14.5 gives 0.68px — not worth correcting, and this value would
 * over-correct it threefold.
 */
.wordmark .kanji {
  position: relative;
  top: 0.119em;
}

a {
  color: var(--accent);
  text-decoration-color: color-mix(in srgb, var(--accent) 35%, transparent);
  text-underline-offset: 3px;
}

a:hover {
  text-decoration-color: currentColor;
}

img,
video {
  max-width: 100%;
  height: auto;
  display: block;
}

/* The frames were sized by a still; a clip has to fill the same box exactly or
   the shadowed border shows a hairline of background down one edge. */
.shot video {
  width: 100%;
}

code {
  font-family: ui-monospace, 'SF Mono', 'JetBrains Mono', Menlo, monospace;
  font-size: 0.88em;
  background: var(--accent-soft);
  padding: 0.1em 0.35em;
  border-radius: 4px;
}

/* --- Bar -------------------------------------------------------------- */

.bar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px clamp(20px, 5vw, 56px);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s ease;
}

.bar.scrolled {
  border-bottom-color: var(--border);
}

.wordmark {
  display: flex;
  align-items: baseline;
  gap: 9px;
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
}

.wordmark .kanji {
  font-size: 21px;
  letter-spacing: 0.06em;
}

.wordmark .name {
  font-size: 15px;
  letter-spacing: 0.01em;
}

.bar nav {
  display: flex;
  align-items: center;
  gap: clamp(14px, 3vw, 28px);
}

.bar nav a {
  color: var(--text-dim);
  text-decoration: none;
  font-size: 14.5px;
}

.bar nav a:hover {
  color: var(--text);
}

#theme {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
}

#theme:hover {
  color: var(--text);
  background: var(--chrome);
}

/* --- Hero ------------------------------------------------------------- */

main {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 clamp(20px, 5vw, 56px);
}

.hero {
  /* Tight enough that the top of the application is above the fold. The
     screenshot is the argument; the words are only there to frame it. */
  padding: clamp(28px, 5vw, 60px) 0 0;
  text-align: center;
}

.lockup {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  margin: 0 0 clamp(20px, 3.4vw, 32px);
}

/* The kanji is the loudest thing on the page on purpose: it is the name, and
   the translation beneath it is the product's whole argument in one line. */
.kanji-xl {
  /* Two boxes rather than two letters, so each can be set in its own time.
     That makes gap the right way to space them: letter-spacing would leave a
     trailing space after the second character and pull the pair off centre,
     which is the very thing the old text-indent was there to undo. */
  display: inline-flex;
  gap: 0.08em;
  font-size: clamp(46px, 8vw, 82px);
  line-height: 1;
  color: var(--text);
}

.gloss {
  font-size: clamp(14px, 2.4vw, 16px);
  color: var(--text-dim);
  letter-spacing: 0.14em;
  text-transform: lowercase;
  margin-top: 11px;
}

.gloss-en {
  font-size: clamp(13.5px, 2.2vw, 15px);
  color: var(--text-faint);
  max-width: 34ch;
}

h1 {
  margin: 0 auto;
  max-width: 20ch;
  font-size: clamp(30px, 4.6vw, 48px);
  line-height: 1.08;
  letter-spacing: -0.022em;
  font-weight: 600;
}

.lede {
  margin: 18px auto 0;
  max-width: 58ch;
  font-size: clamp(16.5px, 2.6vw, 19px);
  color: var(--text-dim);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  margin-top: 28px;
}

.download {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  padding: 11px 26px;
  border-radius: 11px;
  text-decoration: none;
  font-weight: 550;
  border: 1px solid transparent;
  transition:
    transform 0.15s ease,
    background 0.15s ease;
}

.download:hover {
  transform: translateY(-1px);
}

.download.primary {
  background: var(--text);
  color: var(--bg);
}

.download.ghost {
  border-color: var(--border);
  color: var(--text);
  justify-content: center;
}

.download.ghost:hover {
  background: var(--chrome);
}

.download .label {
  font-size: 16px;
}

.download .meta {
  font-size: 12.5px;
  opacity: 0.68;
  font-weight: 400;
}

.fine {
  margin-top: 16px;
  font-size: 13.5px;
  color: var(--text-faint);
}

/* --- Screenshots ------------------------------------------------------ */

.shot {
  margin: 0;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--chrome);
  box-shadow: var(--shadow);
}

.shot.wide {
  margin-top: clamp(30px, 4.5vw, 52px);
}

/* --- Features --------------------------------------------------------- */

.features {
  padding: clamp(72px, 12vw, 132px) 0 0;
}

/* Stacked, with the screenshot full width.
 *
 * These were two columns, which looked tidier and defeated the point: a
 * 1440px capture shrunk into a half-width column renders the app's text at
 * about five pixels, so the feature being demonstrated was illegible in the
 * picture demonstrating it. Full width is worth more than the symmetry. */
.feature {
  margin-bottom: clamp(64px, 10vw, 112px);
}

.feature .copy {
  max-width: 62ch;
  margin-bottom: clamp(24px, 4vw, 40px);
}

.eyebrow {
  margin: 0 0 10px;
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
}

.feature h2,
.download-section h2 {
  margin: 0 0 14px;
  font-size: clamp(26px, 4vw, 36px);
  line-height: 1.15;
  letter-spacing: -0.018em;
  font-weight: 600;
}

.feature p {
  margin: 0 0 14px;
  color: var(--text-dim);
}

.aside {
  font-size: 15px;
  color: var(--text-faint);
  border-left: 2px solid var(--border);
  padding-left: 14px;
}

.grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(268px, 1fr));
  gap: clamp(20px, 3vw, 34px);
  border-top: 1px solid var(--border);
  padding-top: clamp(44px, 7vw, 72px);
}

.grid h3 {
  margin: 0 0 8px;
  font-size: 17.5px;
  font-weight: 600;
  letter-spacing: -0.008em;
}

.grid p {
  margin: 0;
  font-size: 15.5px;
  color: var(--text-dim);
}

/* --- Download --------------------------------------------------------- */

.download-section {
  text-align: center;
  padding: clamp(80px, 12vw, 140px) 0 clamp(60px, 9vw, 96px);
}

.downloads {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  margin: 34px 0 0;
}

.downloads a {
  min-width: 210px;
}

/* --- Footer ----------------------------------------------------------- */

footer {
  border-top: 1px solid var(--border);
  padding: 36px clamp(20px, 5vw, 56px) 56px;
  text-align: center;
  color: var(--text-dim);
}

footer p {
  margin: 0 0 6px;
  font-size: 14.5px;
}

footer .kanji {
  font-size: 16px;
  letter-spacing: 0.06em;
}

/* --- Motion ----------------------------------------------------------- */

/*
 * The first screen settles into place, and nothing else moves.
 *
 * Written entirely inside `no-preference`, so the resting state of every
 * element is the visible one. The alternative — hiding things and revealing
 * them — means a reader who has asked for less motion, or whose stylesheet
 * arrives oddly, gets a blank page. This way the animation can only ever be
 * additive. It is also why this replaced a set of scroll-triggered reveals:
 * those held the whole page at opacity 0 until a script said otherwise.
 */
@media (prefers-reduced-motion: no-preference) {
  @keyframes rise {
    from {
      opacity: 0;
      transform: translateY(10px);
    }
  }

  /* The screenshot comes up from slightly further, and slightly smaller, so it
     arrives last and reads as the thing being presented. */
  @keyframes present {
    from {
      opacity: 0;
      transform: translateY(20px) scale(0.985);
    }
  }

  .hero > *,
  .kanji-xl > span {
    animation: rise 0.62s cubic-bezier(0.22, 0.68, 0.16, 1) both;
  }

  /* Set one character at a time, the way the name would be written. */
  .kanji-xl > span:nth-child(1) {
    animation-delay: 0.04s;
  }

  .kanji-xl > span:nth-child(2) {
    animation-delay: 0.14s;
  }

  /* The lockup animates its characters, not itself, or the two would compound
     into a double fade. */
  .lockup {
    animation: none;
  }

  .gloss {
    animation-delay: 0.3s;
  }

  .gloss-en {
    animation-delay: 0.38s;
  }

  .hero h1 {
    animation-delay: 0.3s;
  }

  .hero .lede {
    animation-delay: 0.4s;
  }

  .hero .actions {
    animation-delay: 0.5s;
  }

  .hero .fine {
    animation-delay: 0.58s;
  }

  .hero .shot.wide {
    animation: present 0.9s cubic-bezier(0.22, 0.68, 0.16, 1) 0.62s both;
  }

  /* The gloss lines sit inside .lockup rather than being hero children, so
     they need the animation named again. */
  .gloss,
  .gloss-en {
    animation-name: rise;
    animation-duration: 0.62s;
    animation-timing-function: cubic-bezier(0.22, 0.68, 0.16, 1);
    animation-fill-mode: both;
  }
}

/* --- Narrow ----------------------------------------------------------- */

@media (max-width: 820px) {
  .grid {
    gap: 26px;
  }
}

@media (max-width: 520px) {
  body {
    font-size: 16px;
  }

  .bar nav a {
    font-size: 14px;
  }

  .actions {
    flex-direction: column;
    align-items: stretch;
  }
}
