@import url("https://fonts.googleapis.com/css2?family=Source+Serif+4:opsz,wght@8..60,400;8..60,600;8..60,900&family=Inter:wght@400;500;600;700&family=Noto+Serif+JP:wght@400;600&display=swap");

@import url("blocks/figure.css");
@import url("blocks/details.css");
@import url("blocks/tips.css");
@import url("blocks/quote.css");
@import url("blocks/gallery.css");
@import url("blocks/divider.css");
@import url("blocks/mosaic.css");
@import url("blocks/grids.css");
@import url("lightbox.css");

:root {
  --paper-rule: #d8d0be;
  --paper-ink: #1c1b18;
  --page-max-width: 1040px;
  --page-gutter: 1rem;
}

@theme {
  --color-sumi: #1c1b18;
  --color-washi: #f2ede1;
  --color-seal: #c1272d;
  --color-moss: #5c6b47;
  --color-bamboo: #b08d57;
  --color-rule: #d8d0be;

  --font-serif: "Source Serif 4", serif;
  --font-sans: "Inter", sans-serif;
  --font-jp: "Noto Serif JP", serif;
}

* {
  -webkit-tap-highlight-color: transparent;
}

body {
  background-color: #f2ede1;
  background-image:
    radial-gradient(circle at 20% 10%, rgba(28, 27, 24, 0.02), transparent 40%), radial-gradient(circle at 80% 60%, rgba(28, 27, 24, 0.02), transparent 45%);
}

/* All primary rules share this frame, so their left and right edges stay
   aligned when template content changes. */
.page-frame {
  width: min(100%, var(--page-max-width));
  margin-inline: auto;
  padding-inline: var(--page-gutter);
}

.site-footer {
  border-top: 1px solid var(--paper-rule);
}

/* subtle paper grain, done in pure CSS so no image asset is needed */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.035;
  background-image:
    repeating-linear-gradient(0deg, #1c1b18 0px, transparent 1px, transparent 2px, #1c1b18 3px),
    repeating-linear-gradient(90deg, #1c1b18 0px, transparent 1px, transparent 2px, #1c1b18 3px);
  background-size: 3px 3px;
  z-index: 50;
}

/* kanji glyphs render in the CJK-aware serif for a slightly more authentic stroke */
h1,
h2,
h3,
p,
span,
blockquote {
  font-feature-settings: "palt";
}

/* newspaper-style drop cap on lead paragraphs */
.drop-cap > p:first-of-type::first-letter,
.article-body > p:first-of-type::first-letter {
  float: left;
  font-family: "Source Serif 4", serif;
  font-weight: 900;
  font-size: 4.2rem;
  line-height: 0.78;
  padding-right: 0.35rem;
  padding-top: 0.15rem;
  color: #1c1b18;
}

.drop-cap p {
  /* text-align: justify; */
}

.drop-cap p,
.article-body p {
  margin-bottom: 1rem;
  break-inside: avoid;
  /* text-wrap: balance; */
  text-wrap: pretty;
  -webkit-hyphens: auto;
  -ms-hyphens: auto;
  hyphens: auto;
  overflow-wrap: break-word;
  text-align: justify;
}

[data-cat-btn],
#cat-nav a {
  position: relative;
  padding-bottom: 4px;
  color: rgba(28, 27, 24, 0.5);
  transition: color 0.15s ease;
  text-decoration: none;
}

[data-cat-btn]:hover,
#cat-nav a:hover {
  color: #1c1b18;
}

[data-cat-btn].is-active,
#cat-nav a.is-active {
  color: #1c1b18;
}

[data-cat-btn].is-active::after,
#cat-nav a.is-active::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 2px;
  background: #c1272d;
}

[data-category].is-hidden {
  display: none;
}

.border-rule {
  border-color: var(--paper-rule) !important;
}

.masthead-rule-strong {
  border-color: var(--paper-ink) !important;
}

.paper-link {
  color: inherit;
  text-decoration: none;
}

/* Search matches borrow the journal's bamboo paper and seal-red accent. */
.toki-search-highlight {
  background: rgba(176, 141, 87, 0.24);
  border-bottom: 2px solid var(--color-seal, #c1272d);
  color: inherit;
  padding: 0 0.06em;
}

.paper-search {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.5rem;
}

/* The compact header keeps its full search form for desktop only.  This is
   explicit because this stylesheet is loaded after Tailwind's `.hidden`
   utility and would otherwise override it on small screens. */
.paper-search.hidden {
  display: none;
}

@media (min-width: 640px) {
  .paper-search.sm\:grid {
    display: grid;
  }
}

.paper-search input,
.paper-search button {
  border: 1px solid var(--paper-rule);
  background: #f8f3e8;
  color: #1c1b18;
  min-height: 2.2rem;
  font-family: "Inter", sans-serif;
  font-size: 0.8rem;
  letter-spacing: 0.03em;
  outline: none;
}

.paper-search input:focus-visible,
.paper-search button:focus-visible {
  border-color: var(--paper-ink);
}

.paper-search input {
  padding: 0 0.65rem;
}

.paper-search button {
  padding: 0 0.75rem;
  text-transform: uppercase;
  cursor: pointer;
}

.paper-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 2rem;
}

.paper-grid article h3 a,
#latest-grid article h3 a,
#lead-story h2 a,
.paper-trending a,
.read-link {
  color: inherit;
  text-decoration: none;
}

.paper-grid article h3 a:hover,
#latest-grid article h3 a:hover,
#lead-story h2 a:hover,
.paper-trending a:hover,
.read-link:hover {
  color: #c1272d;
}

.paper-grid article {
  border-top: 1px solid var(--paper-rule);
  padding-top: 0.7rem;
}

/* Listing cards use the same uninterrupted treatment as the All page. */
#section-grid article,
#related-grid article,
#search-grid article {
  border-top: 0;
  padding-top: 0;
}

.paper-grid article h3 {
  font-size: 1.25rem;
  line-height: 1.25;
  margin-bottom: 0.45rem;
}

.paper-card-category {
  color: rgba(92, 107, 71, 0.72);
}

.card-description {
  text-wrap: pretty;
  -webkit-hyphens: auto;
  -ms-hyphens: auto;
  hyphens: auto;
  overflow-wrap: break-word;
  text-align: justify;
}

.card-place {
  color: rgba(28, 27, 24, 0.42);
}

.card-place:not(:empty)::before {
  content: "·";
  margin: 0 0.35rem;
}

.paper-card-category .paper-link {
  color: inherit;
}

.paper-card-category .paper-link:hover {
  color: rgba(92, 107, 71, 0.9);
}

.paper-grid article .paper-meta,
#lead-story .paper-meta,
.paper-trending,
.paper-places {
  font-family: "Inter", sans-serif;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: rgba(28, 27, 24, 0.58);
}

.paper-byline {
  font-family: "Inter", sans-serif;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: rgba(28, 27, 24, 0.38);
}

.paper-trending {
  display: grid;
  gap: 0.65rem;
}

.paper-trending article {
  padding-top: 0.65rem;
}

.paper-trending article:not(:first-child) {
  border-top: 1px solid var(--paper-rule);
}

.editor-pick-stamp {
  position: absolute;
  top: -0.25rem;
  right: -0.25rem;
  width: 3rem;
  height: 3rem;
  border-radius: 9999px;
  border: 2px solid #c1272d;
  color: #c1272d;
  display: flex;
  align-items: center;
  justify-content: center;
  transform: rotate(-8deg);
  text-align: center;
  line-height: 1.05;
  font-family: "Inter", sans-serif;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.03em;
}

#article-view {
  max-width: 46rem;
  margin-inline: auto;
}

#article-view .article-deck {
  font-size: clamp(1.02rem, 4.2vw, 1.15rem);
  color: rgba(28, 27, 24, 0.78);
  margin-bottom: 0.65rem;

  text-wrap: pretty;
  -webkit-hyphens: auto;
  -ms-hyphens: auto;
  hyphens: auto;
  overflow-wrap: break-word;
  text-align: justify;
}

.card-thumb {
  display: block;
  margin-bottom: 0.7rem;
}

.card-thumb img {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  /* border: 1px solid var(--paper-rule); */
}

/* Keep the stamp clear of long headlines. */
#lead-story h2 {
  padding-right: 3.5rem;
}

/* Jump line under the lead story — sits below the columned excerpt as its
   own line, newspaper-style ("continued on..."), instead of floating
   inside the column flow where it can land anywhere. */
.lead-continue {
  margin-top: 0.85rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--paper-rule);
  text-align: right;
  font-style: italic;
  font-size: 0.95rem;
}

/* Shared "eyebrow" label used by every piece of article furniture
   (details box, tips box, gallery) — kept together since it's one small
   typographic treatment, not a per-component layout concern. */
.details-box-title,
.tips-box-title,
.gallery-title {
  font-family: "Inter", sans-serif;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: #c1272d;
  margin-bottom: 0.7rem !important;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 1.75rem;
  border-top: 1px solid var(--paper-rule);
  padding-top: 1rem;
}

.tag-row a {
  font-family: "Inter", sans-serif;
  font-size: 0.66rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(28, 27, 24, 0.6);
  border: 1px solid var(--paper-rule);
  padding: 0.25rem 0.55rem;
  text-decoration: none;
}

.tag-row a:hover {
  color: #c1272d;
  border-color: rgba(193, 39, 45, 0.5);
}

/* ------------------------------------------------------------------
   Prose content — shared by .md-content (a page that's just
   author-written markdown with none of the theme's own generated
   HTML/classes around it, e.g. theme/docs/showcase.md) and .article-body
   (an article's own body text, under the theme-generated header). Same
   elements, same treatment either way. Tailwind's reset strips all
   default heading/paragraph/list/code styling, so without this, body
   markdown reads as flat, unstyled text.
------------------------------------------------------------------ */

.md-content > *:first-child {
  margin-top: 0;
}

.md-content h1 {
  font-size: clamp(1.9rem, 7vw, 2.6rem);
  font-weight: 900;
  line-height: 1.15;
  margin: 0 0 1.25rem;
}

/* An h1 inside an article's own body is one level below the page's real
   headline (#article-view > h1, styled separately) — noticeably smaller
   so the two don't compete. */
.article-body h1 {
  font-size: clamp(1.5rem, 4.5vw, 1.9rem);
  font-weight: 900;
  line-height: 1.2;
  margin: 2.5rem 0 1rem;
}

.md-content h2,
.article-body h2 {
  font-size: 1.5rem;
  font-weight: 800;
  line-height: 1.25;
  margin: 2.5rem 0 1rem;
}

.md-content h3,
.article-body h3 {
  font-size: 1.15rem;
  font-weight: 700;
  margin: 1.75rem 0 0.6rem;
}

.md-content h4,
.article-body h4 {
  font-size: 1.02rem;
  font-weight: 700;
  font-style: italic;
  line-height: 1.3;
  margin: 1.5rem 0 0.5rem;
}

.md-content h5,
.article-body h5 {
  font-family: "Inter", sans-serif;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(28, 27, 24, 0.65);
  margin: 1.25rem 0 0.5rem;
}

.md-content h6,
.article-body h6 {
  font-family: "Inter", sans-serif;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: rgba(28, 27, 24, 0.5);
  margin: 1.1rem 0 0.4rem;
}

.md-content p {
  line-height: 1.65;
  margin-bottom: 1rem;
}

.md-content ul,
.md-content ol,
.article-body ul,
.article-body ol {
  margin: 0 0 0rem 0.5rem;
  line-height: 1.6;
}

.md-content ul,
.article-body ul {
  list-style: disc outside;
}

.md-content ol,
.article-body ol {
  list-style: decimal outside;
}

.md-content li,
.article-body li {
  margin-bottom: 0.35rem;
}

.md-content a,
.article-body a {
  color: #c1272d;
  text-decoration: underline;
  text-decoration-color: rgba(193, 39, 45, 0.35);
}

.md-content a:hover,
.article-body a:hover {
  text-decoration-color: currentColor;
}

.md-content blockquote,
.article-body blockquote {
  margin: 1.5rem 0;
  padding-left: 1rem;
  /* border-left: 1px solid var(--paper-rule); */
  font-style: italic;
  color: rgba(28, 27, 24, 0.75);
}

.md-content table,
.article-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
  font-size: 0.92rem;
}

.md-content th,
.md-content td,
.article-body th,
.article-body td {
  border-bottom: 1px solid var(--paper-rule);
  padding: 0.55rem 0.75rem;
  text-align: left;
  vertical-align: top;
}

.md-content th,
.article-body th {
  font-family: "Inter", sans-serif;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: rgba(28, 27, 24, 0.6);
  border-bottom: 1px solid var(--paper-ink);
}

.md-content code,
.article-body code {
  font-family: "Inter", sans-serif;
  font-size: 0.85em;
  background: rgba(28, 27, 24, 0.06);
  border: 1px solid var(--paper-rule);
  border-radius: 3px;
  padding: 0.1rem 0.35rem;
}

.md-content pre,
.article-body pre {
  margin: 1.5rem 0;
  padding: 1rem 1.1rem;
  overflow-x: auto;
  background: #1c1b18;
  color: #f2ede1;
  border-radius: 4px;
  font-size: 0.82rem;
  line-height: 1.55;
}

.md-content pre code,
.article-body pre code {
  background: none;
  border: none;
  padding: 0;
  color: inherit;
}

.md-content hr,
.article-body hr {
  border: none;
  border-top: 1px solid var(--paper-rule);
  margin: 2.5rem 0;
}

/* ------------------------------------------------------------------
   Home page extras: places list and the photo essay strip
------------------------------------------------------------------ */

.paper-places {
  display: grid;
  gap: 0.65rem;
}

.paper-places li {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  padding-top: 0.65rem;
}

.paper-places li:not(:first-child) {
  border-top: 1px solid var(--paper-rule);
}

.paper-places li a:hover {
  color: #c1272d;
}

.paper-places li span {
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: rgba(28, 27, 24, 0.4);
  white-space: nowrap;
}

.trending-place {
  display: block;
  margin-top: 0.2rem;
  font-size: 0.62rem;
  letter-spacing: 0.1em;
  color: rgba(28, 27, 24, 0.4);
}

/* Empty states and notes sit across the full listing grid. */
.paper-grid > p {
  grid-column: 1 / -1;
}

@media (max-width: 860px) {
  .paper-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* On tablets the lead story shares the row with the sidebar, so two text
   columns would leave a measure of about twenty characters. Use one. */
@media (min-width: 768px) and (max-width: 1023px) {
  #lead-story .drop-cap {
    columns: 1;
  }
}

@media (min-width: 640px) {
  :root {
    --page-gutter: 1.5rem;
  }

  .editor-pick-stamp {
    width: 3.5rem;
    height: 3.5rem;
  }

  #lead-story h2 {
    padding-right: 4.25rem;
  }
}

/* ------------------------------------------------------------------
   Phones. One column throughout, hairlines between stacked cards,
   and images that run to the edge of the screen.
------------------------------------------------------------------ */

@media (max-width: 640px) {
  .paper-grid {
    grid-template-columns: 1fr;
    gap: 1.6rem;
  }

  /* Stacked cards need a rule between them; a gap alone reads as drift. */
  #latest-grid > article + article,
  #section-grid article + article,
  #related-grid article + article,
  #search-grid article + article {
    border-top: 1px solid var(--paper-rule);
    padding-top: 1.6rem;
  }

  #latest-grid {
    row-gap: 1.6rem;
  }

  .paper-places li span {
    white-space: normal;
    text-align: right;
  }

  #cat-nav a {
    padding-bottom: 6px;
  }
}

::selection {
  background: #c1272d;
  color: #f2ede1;
}
