/* Letters from Meg — Meg - Scripted Essentials */
@import url('https://fonts.googleapis.com/css2?family=Fraunces:ital,opsz,wght@0,9..144,400;0,9..144,500;0,9..144,600;0,9..144,700;1,9..144,400&family=Work+Sans:wght@400;500;600&family=Noto+Sans+JP:wght@400;500;700&family=Noto+Serif+JP:wght@400;500;600&display=swap');

:root {
  --bg: #F5EEDC;
  --paper: #FFFCF6;
  --ink: #64503C;
  --ink-soft: #8C7864;
  --gold: #B49664;
  --gold-soft: #E5D2AE;
  --pink: #C88C8C;
  --rule: #E0D2B6;
  --link: #8A5A20;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: 'Work Sans', -apple-system, BlinkMacSystemFont, "Noto Sans JP", sans-serif;
  font-size: 17px;
  line-height: 1.8;
  -webkit-font-smoothing: antialiased;
}

/* Japanese body uses Noto Sans JP as primary */
html:lang(ja) body {
  font-family: 'Noto Sans JP', 'Work Sans', sans-serif;
}

.visually-hidden {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ===== Header ===== */
.site-header {
  background: var(--paper);
  border-bottom: 1px solid var(--rule);
  padding: 1.2rem 1.5rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
}
.brand {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  line-height: 0;
}
.brand-logo {
  height: 38px;
  width: auto;
  display: block;
}
.top-nav { display: flex; gap: 0.4rem; font-size: 0.9rem; }
.top-nav a {
  color: var(--ink-soft);
  text-decoration: none;
  padding: 0.25rem 0.7rem;
  border-radius: 4px;
  border: 1px solid transparent;
  transition: all 0.15s;
}
.top-nav a:hover { background: var(--bg); color: var(--ink); }
.top-nav a.lang-link { border-color: var(--gold-soft); }

/* ===== Main / article ===== */
main {
  max-width: 760px;
  margin: 0 auto;
  padding: 2.5rem 1.5rem 4rem;
}

article.letter {
  background: var(--paper);
  border-radius: 6px;
  padding: 2.5rem clamp(1.4rem, 5vw, 3.4rem) 3rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04), 0 4px 24px rgba(0,0,0,0.05);
}

/* Hero & in-body images */
article.letter img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 5px;
  margin: 0.5rem 0 1.8rem;
}
/* first image (hero) flush to top, a touch of breathing room below */
article.letter > p:first-of-type img,
article.letter > p img:only-child { margin-top: 0; }

.issue-meta {
  text-align: center;
  font-size: 0.85rem;
  letter-spacing: 0.06em;
  color: var(--ink-soft);
  margin: 0 0 2.2rem;
  text-transform: none;
}

h2 {
  font-family: 'Fraunces', Georgia, serif;
  font-weight: 600;
  font-size: 1.55rem;
  margin: 2.8rem 0 1rem;
  padding-bottom: 0.45rem;
  border-bottom: 2px solid var(--gold-soft);
  color: var(--ink);
  letter-spacing: -0.01em;
}
html:lang(ja) h2 {
  font-family: 'Noto Serif JP', 'Fraunces', serif;
  font-weight: 600;
}

h3 {
  font-family: 'Fraunces', Georgia, serif;
  font-weight: 500;
  font-size: 1.18rem;
  margin: 1.9rem 0 0.6rem;
  color: var(--gold);
}
html:lang(ja) h3 {
  font-family: 'Noto Serif JP', 'Fraunces', serif;
  font-weight: 500;
}

p { margin: 0.9rem 0; }

a { color: var(--link); text-decoration: underline; text-decoration-color: var(--gold-soft); text-underline-offset: 3px; word-break: break-all; }
a:hover { text-decoration-color: var(--gold); }

ul, ol { margin: 0.9rem 0; padding-left: 1.5rem; }
li { margin: 0.5rem 0; }
ol li::marker, ul li::marker { color: var(--gold); }

strong { color: var(--ink); font-weight: 600; }
em { color: var(--ink-soft); }

/* Customer-voice quotes */
blockquote {
  margin: 1.4rem 0;
  padding: 0.2rem 0 0.2rem 1.4rem;
  border-left: 3px solid var(--pink);
  color: var(--ink);
  font-style: italic;
}
blockquote p { margin: 0.4rem 0; }
blockquote p:last-child {
  font-style: normal;
  font-size: 0.85rem;
  color: var(--ink-soft);
  letter-spacing: 0.04em;
}

hr {
  border: none;
  border-top: 1px solid var(--rule);
  margin: 2.6rem 0 1.6rem;
}

.footer-note {
  font-size: 0.85rem;
  color: var(--ink-soft);
  line-height: 1.7;
  text-align: center;
}
.footer-note strong { color: var(--ink); }

/* ===== Back issues (substack-style list) ===== */
.back-issues {
  max-width: 760px;
  margin: 2.5rem auto 0;
  padding: 0 0.2rem;
}
.back-issues-heading {
  font-family: 'Fraunces', Georgia, serif;
  font-weight: 600;
  font-size: 1.1rem;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  border: none;
  padding: 0;
  margin: 0 0 1rem;
}
html:lang(ja) .back-issues-heading {
  font-family: 'Noto Serif JP', serif;
  text-transform: none;
}
.issue-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 1rem; }
.issue-card a {
  display: flex;
  gap: 1.2rem;
  align-items: center;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 0.9rem;
  text-decoration: none;
  color: var(--ink);
  transition: all 0.15s;
}
.issue-card a:hover {
  border-color: var(--gold);
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(0,0,0,0.06);
}
.issue-thumb {
  width: 200px;
  max-width: 38%;
  aspect-ratio: 1200 / 628;
  object-fit: cover;
  border-radius: 4px;
  margin: 0;
  flex-shrink: 0;
}
.issue-card-body { display: flex; flex-direction: column; gap: 0.2rem; }
.issue-card-date { font-size: 0.78rem; color: var(--gold); letter-spacing: 0.05em; }
.issue-card-title {
  font-family: 'Fraunces', Georgia, serif;
  font-weight: 600;
  font-size: 1.05rem;
}
html:lang(ja) .issue-card-title { font-family: 'Noto Serif JP', serif; }
.issue-card-teaser { font-size: 0.9rem; color: var(--ink-soft); line-height: 1.5; }

/* ===== Footer ===== */
.site-footer {
  text-align: center;
  padding: 2rem 1.5rem;
  color: var(--ink-soft);
  font-size: 0.82rem;
  border-top: 1px solid var(--rule);
  background: var(--paper);
}
.site-footer p { margin: 0; }

@media (max-width: 600px) {
  body { font-size: 16px; }
  main { padding: 1.5rem 0.8rem 3rem; }
  article.letter { padding: 1.6rem 1.2rem 2rem; }
  h2 { font-size: 1.3rem; }
  .brand-name { display: none; }
  .issue-card a { flex-direction: column; align-items: stretch; }
  .issue-thumb { width: 100%; max-width: 100%; }
}

/* =================================================================
   jp-ui-contracts recipes — applied only to Japanese pages
   (ja-text / mixed-script / headings)
   ================================================================= */
html:lang(ja) {
  line-break: strict;
  word-break: normal;
  overflow-wrap: anywhere;
  font-kerning: auto;
  text-autospace: normal;
}
html:lang(ja) body { text-rendering: optimizeLegibility; }
html:lang(ja) p,
html:lang(ja) li,
html:lang(ja) dd {
  line-break: strict;
  word-break: normal;
  overflow-wrap: anywhere;
}
html:lang(ja) :where(article, .prose, .content) p { max-width: 42em; }
html:lang(ja) em,
html:lang(ja) strong,
html:lang(ja) a,
html:lang(ja) .latin,
html:lang(ja) .product-name {
  word-break: normal;
  overflow-wrap: anywhere;
}
html:lang(ja) h1,
html:lang(ja) h2,
html:lang(ja) h3 { word-break: auto-phrase; }
html:lang(ja) h1, html:lang(ja) h2, html:lang(ja) h3, html:lang(ja) h4 {
  line-break: strict;
  word-break: normal;
  overflow-wrap: anywhere;
  font-kerning: auto;
}
html:lang(ja) h1 { line-height: 1.35; }
html:lang(ja) h2 { line-height: 1.4; }
html:lang(ja) h3 { line-height: 1.45; }
