/*
Theme Name: Tsundoku Trading Co.
Theme URI: https://tsundokutrading.example
Author: Tsundoku Trading Co.
Description: Custom theme for Tsundoku Trading Co. — complete manga series and Japanese imports. Washi paper, aizome indigo, sakura petals, and a motion toggle. News runs on native WordPress posts; shop listings render from a listings.json produced by the companion Etsy sync script.
Version: 1.0.0
Requires at least: 6.0
Requires PHP: 7.4
License: GNU General Public License v2 or later
Text Domain: tsundoku
*/

/* ============================================================
   TSUNDOKU TRADING CO. — v2 (sakura)
   Tokens: washi paper / sumi ink / aizome indigo / sakura pink / hanko red
   ============================================================ */
:root {
  --washi:      #F5F0E6;   /* warm paper background */
  --washi-deep: #EDE6D6;   /* darker paper, cards & bands */
  --sumi:       #26241F;   /* soft ink black, text */
  --sumi-soft:  #5C574C;   /* secondary text */
  --indigo:     #274357;   /* aizome — primary accent */
  --indigo-deep:#1B3040;   /* hover / dark surfaces */
  --kraft:      #C8B594;   /* warm tan, labels & branch */
  --branch:     #6B5844;   /* sakura branch wood */
  --sakura:     #E7AFBC;   /* blossom pink */
  --sakura-soft:#F2CDD5;   /* pale petal */
  --hanko:      #B33A3A;   /* vermillion — seal stamp ONLY */
  --line:       #D9D0BC;   /* hairline dividers */

  --font-display: "Shippori Mincho", "Hiragino Mincho ProN", serif;
  --font-body: "Zen Kaku Gothic New", "Hiragino Kaku Gothic ProN", sans-serif;

  --max: 1100px;
  --ease: cubic-bezier(.22,.61,.36,1);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { scroll-behavior: smooth; }
html.reduced-motion { scroll-behavior: auto; }

body {
  font-family: var(--font-body);
  background: var(--washi);
  color: var(--sumi);
  line-height: 1.7;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

::selection { background: var(--indigo); color: var(--washi); }

/* ---------- Reveal-on-scroll (disabled when motion is off) ---------- */
.reveal {
  opacity: 0;
  transform: translateY(22px);
  transition: opacity .7s var(--ease), transform .7s var(--ease);
}
.reveal.is-visible { opacity: 1; transform: none; }

html.reduced-motion .reveal,
html.reduced-motion .reveal.is-visible {
  opacity: 1; transform: none; transition: none;
}
html.reduced-motion *, html.reduced-motion *::before, html.reduced-motion *::after {
  animation: none !important;
  transition-duration: .01ms !important;
}
html.reduced-motion .petal-field { display: none; }

@media (prefers-reduced-motion: reduce) {
  .reveal { opacity: 1; transform: none; transition: none; }
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition-duration: .01ms !important; }
  .petal-field { display: none; }
}

/* ---------- Focus visibility ---------- */
a:focus-visible, button:focus-visible {
  outline: 2px solid var(--indigo);
  outline-offset: 3px;
  border-radius: 2px;
}

/* ============================================================
   NAV
   ============================================================ */
.nav {
  position: sticky; top: 0; z-index: 50;
  background: rgba(245, 240, 230, .92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.nav-inner {
  max-width: var(--max); margin: 0 auto;
  padding: 14px 24px;
  display: flex; align-items: center; gap: 24px;
}
.brand {
  font-family: var(--font-display);
  font-weight: 700; font-size: 1.05rem;
  letter-spacing: .04em;
  color: var(--sumi); text-decoration: none;
  display: flex; align-items: center; gap: 10px;
}
.brand .seal {
  width: 26px; height: 26px; flex: none;
  background: var(--hanko); color: var(--washi);
  font-size: 15px; line-height: 26px; text-align: center;
  border-radius: 4px;
  transform: rotate(-4deg);
  font-family: var(--font-display);
}
.nav-links {
  margin-left: auto;
  display: flex; align-items: center; gap: 22px;
}
.nav-links a {
  color: var(--sumi-soft); text-decoration: none;
  font-size: .88rem; font-weight: 500; letter-spacing: .06em;
  transition: color .2s var(--ease);
}
.nav-links a:hover { color: var(--indigo); }

.motion-toggle {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--sumi-soft);
  font-family: var(--font-body);
  font-size: .78rem; font-weight: 500; letter-spacing: .05em;
  padding: 6px 12px; border-radius: 999px;
  cursor: pointer;
  transition: border-color .2s var(--ease), color .2s var(--ease);
}
.motion-toggle:hover { border-color: var(--indigo); color: var(--indigo); }
.motion-toggle[aria-pressed="true"] { background: var(--washi-deep); }

@media (max-width: 720px) {
  .nav-links a { display: none; }
  .nav-links a.nav-cta { display: inline; }
}

/* ============================================================
   HERO — sakura branch & falling petals
   ============================================================ */
.hero {
  position: relative;
  overflow: hidden;   /* petals stay inside the hero */
}
.hero-inner {
  max-width: var(--max); margin: 0 auto;
  padding: 88px 24px 110px;
  position: relative;
  z-index: 2;
}
.hero-copy { max-width: 560px; }
.hero-copy h1 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(2.2rem, 5vw, 3.4rem);
  line-height: 1.25;
  letter-spacing: .01em;
}
.hero-copy h1 em {
  font-style: normal;
  color: var(--indigo);
}
.hero-def {
  margin-top: 22px;
  padding-left: 18px;
  border-left: 2px solid var(--sakura);
  color: var(--sumi-soft);
  max-width: 46ch;
}
.hero-def .jp {
  font-family: var(--font-display);
  color: var(--sumi);
  font-weight: 600;
}
.hero-actions { margin-top: 34px; display: flex; gap: 14px; flex-wrap: wrap; }

.btn {
  display: inline-block;
  text-decoration: none;
  font-weight: 700; font-size: .92rem; letter-spacing: .04em;
  padding: 13px 26px;
  border-radius: 3px;
  transition: background .2s var(--ease), color .2s var(--ease), transform .15s var(--ease);
}
.btn-primary { background: var(--indigo); color: var(--washi); }
.btn-primary:hover { background: var(--indigo-deep); transform: translateY(-1px); }
.btn-ghost {
  color: var(--indigo);
  border: 1px solid var(--indigo);
}
.btn-ghost:hover { background: var(--indigo); color: var(--washi); }

/* Vertical Japanese eyebrow */
.hero-vertical {
  position: absolute; top: 88px; right: 24px;
  writing-mode: vertical-rl;
  font-family: var(--font-display);
  font-size: .8rem; letter-spacing: .35em;
  color: var(--kraft);
  user-select: none;
  z-index: 2;
}
@media (max-width: 980px) { .hero-vertical { display: none; } }

/* The branch reaches in from the top-right corner */
.branch-art {
  position: absolute; top: 0; right: 0;
  width: min(58vw, 640px);
  height: auto;
  z-index: 1;
  pointer-events: none;
}
@media (max-width: 860px) {
  .branch-art { width: 78vw; opacity: .55; }
  .hero-inner { padding-top: 120px; }
}

/* Petal field fills the hero; petals are added by JS */
.petal-field {
  position: absolute; inset: 0;
  z-index: 1;
  pointer-events: none;
  overflow: hidden;
}
.petal {
  position: absolute;
  top: -24px;
  border-radius: 150% 10% 150% 10%;
  background: linear-gradient(135deg, var(--sakura-soft), var(--sakura));
  opacity: 0;
  animation-name: petal-fall;
  animation-timing-function: linear;
  animation-iteration-count: infinite;
  will-change: transform, opacity;
}
@keyframes petal-fall {
  0%   { transform: translate3d(0, 0, 0) rotate(0deg); opacity: 0; }
  6%   { opacity: .9; }
  25%  { transform: translate3d(-26px, 25vh, 0) rotate(95deg); }
  50%  { transform: translate3d(14px, 50vh, 0) rotate(190deg); opacity: .9; }
  75%  { transform: translate3d(-20px, 75vh, 0) rotate(285deg); }
  98%  { opacity: .85; }
  100% { transform: translate3d(8px, 102vh, 0) rotate(380deg); opacity: 0; }
}

/* A few petals rest at the bottom of the hero even when motion is off */
.petal-rest {
  position: absolute;
  bottom: 18px;
  width: 11px; height: 9px;
  border-radius: 150% 10% 150% 10%;
  background: var(--sakura);
  opacity: .8;
  z-index: 1;
}
.petal-rest.r2 { background: var(--sakura-soft); transform: rotate(140deg) scale(.85); }
.petal-rest.r3 { transform: rotate(70deg) scale(.7); opacity: .6; }

/* ============================================================
   SECTION SCAFFOLD
   ============================================================ */
.section { max-width: var(--max); margin: 0 auto; padding: 84px 24px; position: relative; }
.section + .section { border-top: 1px solid var(--line); }
#shop { border-top: 1px solid var(--line); }

.section-head { display: flex; align-items: baseline; gap: 18px; margin-bottom: 40px; }
.section-head h2 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(1.5rem, 3vw, 2rem);
}
.section-head .jp-label {
  font-family: var(--font-display);
  color: var(--kraft);
  font-size: .95rem; letter-spacing: .2em;
}
.section-sub { color: var(--sumi-soft); max-width: 56ch; margin-top: -28px; margin-bottom: 40px; }

/* ============================================================
   SHOP — product cards
   ============================================================ */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 22px;
}
.card {
  background: var(--washi-deep);
  border: 1px solid var(--line);
  border-radius: 4px;
  overflow: hidden;
  display: flex; flex-direction: column;
  transition: transform .25s var(--ease), box-shadow .25s var(--ease);
}
.card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 28px rgba(38,36,31,.10);
}
html.reduced-motion .card:hover { transform: none; box-shadow: 0 6px 16px rgba(38,36,31,.08); }

/* card art: quiet washi field, one large mincho word, one petal */
.card-art {
  aspect-ratio: 4 / 3;
  position: relative;
  display: flex; align-items: center; justify-content: center;
  border-bottom: 1px solid var(--line);
  overflow: hidden;
}
.card-art .art-word {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(2.6rem, 6vw, 3.4rem);
  letter-spacing: .1em;
  opacity: .9;
}
.card-art .art-petal {
  position: absolute;
  width: 16px; height: 13px;
  border-radius: 150% 10% 150% 10%;
  background: var(--sakura);
  top: 16%; right: 14%;
  transform: rotate(35deg);
}
.card-art .art-petal.small {
  width: 10px; height: 8px;
  top: auto; bottom: 14%; left: 12%; right: auto;
  background: var(--sakura-soft);
  transform: rotate(160deg);
}
.card-body { padding: 18px 20px 20px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.card-tag {
  font-size: .7rem; font-weight: 700; letter-spacing: .14em;
  text-transform: uppercase; color: var(--indigo);
}
.card-title { font-family: var(--font-display); font-weight: 600; font-size: 1.08rem; line-height: 1.4; }
.card-desc { font-size: .88rem; color: var(--sumi-soft); flex: 1; }
.card-foot {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 6px;
}
.card-price { font-weight: 700; font-size: .95rem; }
.card-link {
  font-size: .82rem; font-weight: 700; letter-spacing: .04em;
  color: var(--indigo); text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color .2s var(--ease);
}
.card-link:hover { border-color: var(--indigo); }

.shop-cta { text-align: center; margin-top: 46px; }
.shop-cta p { color: var(--sumi-soft); font-size: .9rem; margin-bottom: 16px; }

/* ============================================================
   NEWS / BLOG
   ============================================================ */
.news-list { display: flex; flex-direction: column; }
.news-item {
  display: grid;
  grid-template-columns: 130px 1fr auto;
  gap: 24px; align-items: baseline;
  padding: 24px 4px;
  border-bottom: 1px solid var(--line);
}
.news-item:first-child { border-top: 1px solid var(--line); }
.news-date {
  font-size: .8rem; letter-spacing: .06em;
  color: var(--sumi-soft);
}
.news-body h3 { font-family: var(--font-display); font-weight: 600; font-size: 1.06rem; }
.news-body p { color: var(--sumi-soft); font-size: .9rem; margin-top: 4px; max-width: 62ch; }
.news-badge {
  font-size: .68rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase;
  padding: 4px 10px; border-radius: 999px;
  white-space: nowrap;
}
.badge-new { background: var(--indigo); color: var(--washi); }
.badge-soon { background: transparent; color: var(--indigo); border: 1px solid var(--indigo); }
.badge-note { background: var(--washi-deep); color: var(--sumi-soft); border: 1px solid var(--line); }

@media (max-width: 640px) {
  .news-item { grid-template-columns: 1fr; gap: 6px; }
  .news-badge { justify-self: start; }
}

/* ============================================================
   ABOUT
   ============================================================ */
.about-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 48px; align-items: start;
}
.about-copy p + p { margin-top: 16px; }
.about-copy .jp-inline { font-family: var(--font-display); }
.about-aside {
  background: var(--washi-deep);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 26px;
}
.about-aside h3 {
  font-family: var(--font-display); font-weight: 600;
  font-size: 1rem; margin-bottom: 14px;
}
.about-aside ul { list-style: none; }
.about-aside li {
  padding: 10px 0;
  font-size: .88rem; color: var(--sumi-soft);
  border-bottom: 1px solid var(--line);
  display: flex; gap: 10px;
}
.about-aside li:last-child { border-bottom: none; }
.about-aside li::before { content: "—"; color: var(--sakura); flex: none; }

@media (max-width: 860px) { .about-grid { grid-template-columns: 1fr; } }

/* ============================================================
   FOOTER
   ============================================================ */
.footer {
  border-top: 1px solid var(--line);
  background: var(--washi-deep);
}
.footer-inner {
  max-width: var(--max); margin: 0 auto;
  padding: 48px 24px;
  display: flex; flex-wrap: wrap; gap: 32px;
  align-items: center; justify-content: space-between;
}
.footer-brand { display: flex; align-items: center; gap: 14px; }
.footer-brand .seal {
  width: 44px; height: 44px;
  background: var(--hanko); color: var(--washi);
  font-family: var(--font-display); font-size: 24px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 6px; transform: rotate(-4deg);
}
.footer-brand strong { font-family: var(--font-display); display: block; }
.footer-brand small { color: var(--sumi-soft); }
.footer-links { display: flex; gap: 20px; }
.footer-links a {
  color: var(--sumi); text-decoration: none;
  font-size: .88rem; font-weight: 500;
  border-bottom: 1px solid var(--kraft);
  transition: color .2s var(--ease), border-color .2s var(--ease);
}
.footer-links a:hover { color: var(--indigo); border-color: var(--indigo); }
.footer-fine {
  width: 100%; text-align: center;
  font-size: .75rem; color: var(--sumi-soft);
  letter-spacing: .04em;
  padding-top: 8px;
}

/* ============================================================
   LISTINGS — real Etsy data (index shop grid + listings page)
   ============================================================ */
.card-img {
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border-bottom: 1px solid var(--line);
  background: var(--washi-deep);
}
.card-img img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
  transition: transform .4s var(--ease);
}
.card:hover .card-img img { transform: scale(1.03); }
html.reduced-motion .card:hover .card-img img { transform: none; }

.freshness {
  text-align: center;
  font-size: .75rem; letter-spacing: .06em;
  color: var(--sumi-soft);
  margin-top: 26px;
}

/* Toolbar on the listings page */
.toolbar {
  display: flex; flex-wrap: wrap; gap: 14px;
  align-items: center;
  margin-bottom: 34px;
}
.toolbar input[type="search"] {
  flex: 1; min-width: 220px;
  font-family: var(--font-body); font-size: .92rem;
  color: var(--sumi);
  background: var(--washi-deep);
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 11px 14px;
  transition: border-color .2s var(--ease);
}
.toolbar input[type="search"]:focus {
  outline: none;
  border-color: var(--indigo);
}
.toolbar input[type="search"]::placeholder { color: var(--sumi-soft); }
.toolbar select {
  font-family: var(--font-body); font-size: .88rem;
  color: var(--sumi);
  background: var(--washi-deep);
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 11px 12px;
  cursor: pointer;
}
.toolbar .count {
  font-size: .82rem; color: var(--sumi-soft);
  letter-spacing: .04em;
  margin-left: auto;
}

/* Empty / status states */
.listings-status {
  text-align: center;
  padding: 60px 20px;
  color: var(--sumi-soft);
}
.listings-status .jp-big {
  display: block;
  font-family: var(--font-display);
  font-size: 2.2rem;
  color: var(--kraft);
  margin-bottom: 12px;
}

/* Compact page header for interior pages */
.page-head {
  max-width: var(--max); margin: 0 auto;
  padding: 64px 24px 0;
}
.page-head h1 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(1.9rem, 4vw, 2.6rem);
}
.page-head p { color: var(--sumi-soft); margin-top: 10px; max-width: 56ch; }

/* ============================================================
   WORDPRESS — post content & archive additions
   ============================================================ */
.entry-meta {
  font-size: .82rem; letter-spacing: .06em;
  color: var(--sumi-soft);
  margin-top: 10px;
}
.entry-content { max-width: 68ch; margin-top: 34px; }
.entry-content p { margin-bottom: 18px; }
.entry-content h2, .entry-content h3 {
  font-family: var(--font-display);
  font-weight: 600;
  margin: 34px 0 14px;
}
.entry-content a { color: var(--indigo); }
.entry-content ul, .entry-content ol { margin: 0 0 18px 22px; }
.entry-content li { margin-bottom: 6px; }
.entry-content img {
  max-width: 100%; height: auto;
  border: 1px solid var(--line);
  border-radius: 4px;
}
.entry-content blockquote {
  border-left: 2px solid var(--sakura);
  padding-left: 18px;
  color: var(--sumi-soft);
  margin: 22px 0;
}
.entry-thumb img {
  width: 100%; height: auto;
  max-width: 150px;
  border: 1px solid var(--line);
  border-radius: 4px;
  margin-top: 30px;
}
.back-link {
  display: inline-block;
  margin-top: 44px;
  font-size: .88rem; font-weight: 700;
  color: var(--indigo);
  text-decoration: none;
  border-bottom: 1px solid var(--kraft);
}
.back-link:hover { border-color: var(--indigo); }

/* News list items are links in WP */
a.news-item {
  text-decoration: none;
  color: inherit;
  transition: background .2s var(--ease);
}
a.news-item:hover { background: var(--washi-deep); }
a.news-item:hover .news-body h3 { color: var(--indigo); }

/* Archive pagination */
.pagination-nav {
  display: flex; justify-content: space-between;
  margin-top: 40px;
  font-size: .88rem; font-weight: 700;
}
.pagination-nav a {
  color: var(--indigo); text-decoration: none;
  border-bottom: 1px solid var(--kraft);
}
.pagination-nav a:hover { border-color: var(--indigo); }

/* Screen-reader utility (WP convention) */
.screen-reader-text {
  border: 0; clip-path: inset(50%);
  height: 1px; width: 1px;
  margin: -1px; overflow: hidden;
  padding: 0; position: absolute;
}

/* ============================================================
   ETSY SHOP PLUGIN — restyle its output to match the theme.
   Written against the plugin's actual markup:
   .etsy-shop-listing-container
     > .etsy-shop-listing
       > .etsy-shop-listing-card  (inline width — needs !important)
         > a.etsy-shop-listing-thumb  (wraps image, detail, and price)
           > img  (inline height — needs !important)
           > .etsy-shop-listing-detail > -title, -maker
           > .etsy-shop-listing-price > .etsy-shop-currency-code
   ============================================================ */
.etsy-plugin-shop .etsy-shop-listing-container {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 22px;
}
.etsy-plugin-shop .etsy-shop-listing {
  display: block;
  float: none;
  margin: 0;
  padding: 0;
}

/* Card: kill the inline pixel width, become a theme card */
.etsy-plugin-shop .etsy-shop-listing-card {
  width: 100% !important;
  height: 100%;
  margin: 0;
  background: var(--washi-deep);
  border: 1px solid var(--line);
  border-radius: 4px;
  overflow: hidden;
  transition: transform .25s var(--ease), box-shadow .25s var(--ease);
}
.etsy-plugin-shop .etsy-shop-listing-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 28px rgba(38,36,31,.10);
}
html.reduced-motion .etsy-plugin-shop .etsy-shop-listing-card:hover {
  transform: none;
  box-shadow: 0 6px 16px rgba(38,36,31,.08);
}

/* The single wrapping link becomes the card's column layout */
.etsy-plugin-shop a.etsy-shop-listing-thumb {
  display: flex;
  flex-direction: column;
  height: 100%;
  text-decoration: none !important;
  color: inherit;
}

/* Image: kill the inline pixel height, go full-bleed */
.etsy-plugin-shop .etsy-shop-listing-card img {
  display: block;
  width: 100% !important;
  height: auto !important;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border: none;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  margin: 0;
  padding: 0;
  transition: transform .4s var(--ease);
}
.etsy-plugin-shop .etsy-shop-listing-card:hover img { transform: scale(1.03); }
html.reduced-motion .etsy-plugin-shop .etsy-shop-listing-card:hover img { transform: none; }

/* Title block */
.etsy-plugin-shop .etsy-shop-listing-detail {
  padding: 16px 18px 0;
  flex: 1; /* pushes the price to the card's bottom edge */
}
.etsy-plugin-shop .etsy-shop-listing-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1rem;
  line-height: 1.45;
  color: var(--sumi);
  margin: 0;
  text-align: left;
  transition: color .2s var(--ease);
}
.etsy-plugin-shop .etsy-shop-listing-card:hover .etsy-shop-listing-title {
  color: var(--indigo);
}
.etsy-plugin-shop .etsy-shop-listing-maker { display: none; } /* empty &nbsp; row */

/* Price */
.etsy-plugin-shop .etsy-shop-listing-price {
  font-family: var(--font-body);
  font-weight: 700;
  font-size: .95rem;
  color: var(--sumi);
  margin: 10px 0 0;
  padding: 0 18px 18px;
  text-align: left;
}
.etsy-plugin-shop .etsy-shop-currency-code {
  font-weight: 400;
  font-size: .78rem;
  color: var(--sumi-soft);
  letter-spacing: .06em;
}

/* Plugin error messages (bad section id, API errors) — style quietly */
.etsy-plugin-shop .etsy-shop-error,
.etsy-plugin-shop > p:only-child {
  text-align: center;
  color: var(--sumi-soft);
  padding: 40px 20px;
}