/* Yorimichi Shrine (寄り道神社): the shared look of every Side Quests page (the shrine grounds, the manga reader,
   reviews and travel posts). No sidebar: shrine.js sets data-time from local time (or the scene chosen with the time chip),
   and each time has its own painting and palette. */
@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;700&family=Klee+One:wght@400;600&family=Noto+Sans+JP:wght@500;700&family=Shippori+Mincho+B1:wght@600;800&family=Space+Mono:wght@400;700&display=swap');
:root {
  --mono:'Space Mono',monospace;--jp:'Noto Sans JP',sans-serif;--serif:'Shippori Mincho B1','Yu Mincho',serif;--hand:'Klee One',var(--jp);
  --scene:url('assets/morning-shrine.webp');--page:#dde7f4;
  --ink:#1d2b26;--ink-soft:#4c5c55;--accent:#b5402a;--seal:#bf3b28;--line:#1d2b2626;
  --chip:#f4f7f8a8;--chip-hover:#f4f7f8e6;--hero-veil:#eef4fab3;--board-veil:#eef2f159;
  --paper:#fbf6ea;--paper-deep:#f1e7d2;--paper-ink:#2a2118;--paper-soft:#6b5a48;
  --wood-light:#ead3ab;--wood:#d6b384;--wood-deep:#b98e5c;--wood-edge:#93673b;--grain:#7a4f2a12;--ema-ink:#2a1b10;
  --grain-fine:repeating-linear-gradient(177deg,transparent 0 9px,var(--grain) 9px 10px,transparent 10px 17px),repeating-linear-gradient(173deg,transparent 0 13px,var(--grain) 13px 14px,transparent 14px 29px),
    radial-gradient(ellipse 120% 30% at 20% 38%,#8a5a2a14,transparent 70%),radial-gradient(ellipse 120% 26% at 80% 74%,#8a5a2a12,transparent 70%);
  --post:#7a5537;--post-dark:#4f3423;--roof:#3b3835;--roof-light:#5b5650;--cord:#c7372a;
  --stone:#cdc8bb;--stone-light:#e3ded2;--stone-dark:#a29c8f;--stone-ink:#36332e;--moss:#5f7d4166;
}
html[data-time=evening] {
  --scene:url('assets/evening-shrine.webp');--page:#f2c4a8;
  --ink:#3a211c;--ink-soft:#6e4a40;--accent:#a63a26;--seal:#b9372a;--line:#3a211c26;
  --chip:#fdebdda8;--chip-hover:#fdebdde6;--hero-veil:#fde6d6b3;--board-veil:#f6dccb59;
  --paper:#fcf1e4;--paper-deep:#f3dfc8;
  --wood-light:#edcb98;--wood:#d9a96f;--wood-deep:#b9824f;--wood-edge:#8b5830;
  --post:#6f4a30;--post-dark:#47291a;--roof:#3a3030;--roof-light:#5c4c48;
  --stone:#d2bfb0;--stone-light:#e6d3c3;--stone-dark:#a8917f;--stone-ink:#3b2c25;--moss:#6a6b3a66;
}
html[data-time=night] {
  --scene:url('assets/night-shrine.webp');--page:#2c3b57;
  --ink:#eef1f6;--ink-soft:#b6c0d2;--accent:#f0b45e;--seal:#a52c1c;--line:#eef1f626;
  --chip:#121b31a8;--chip-hover:#121b31e6;--hero-veil:#13203a99;--board-veil:#0f182c80;
  --paper:#efe5d0;--paper-deep:#e2d4b8;
  --wood-light:#cbaf86;--wood:#ae8d64;--wood-deep:#8b6b48;--wood-edge:#5c432b;--grain:#3a24101a;--ema-ink:#1d140b;
  --post:#4c392b;--post-dark:#2c2118;--roof:#1e2130;--roof-light:#363b4f;--cord:#b0382c;
  --stone:#8d92a0;--stone-light:#a9adba;--stone-dark:#676b79;--stone-ink:#1b1e2c;--moss:#3c5a4a66;
  --board-light:radial-gradient(ellipse 52% 46% at 50% 44%,#f0b45e2b,transparent 72%);
}

* { box-sizing:border-box; }
[hidden] { display:none!important; }
html { scroll-behavior:smooth;background:var(--page); }
body { display:flex;flex-direction:column;margin:0;min-height:100vh;color:var(--ink);background:var(--page);isolation:isolate;font:16px/1.7 'DM Sans',sans-serif; }
a { color:inherit;text-decoration:none; }
button,select { font:inherit;color:inherit; }
a,button { -webkit-tap-highlight-color:transparent; }
a:focus-visible,button:focus-visible,select:focus-visible { outline:2px solid var(--accent);outline-offset:4px; }
[lang=ja] { font-family:var(--jp); }
img { max-width:100%; }
.sr-only { position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap;border:0; }
/* Like the home street, the painting is sized to the large viewport, so it stays still instead of rescaling
   while phone browsers hide and show their toolbars during scrolling. */
.shrine-scene { position:fixed;inset:0 0 auto;z-index:-2;height:100vh;height:100lvh;background:var(--scene) 66% 42%/cover no-repeat var(--page); }

/* The way back: a small frosted chip, the only navigation on these pages. */
.shrine-back { display:inline-flex;align-items:center;gap:8px;padding:9px 16px;border-radius:999px;background:var(--chip);-webkit-backdrop-filter:blur(8px);backdrop-filter:blur(8px);font:700 10px/1.4 var(--mono);letter-spacing:.16em;color:var(--ink);transition:background .25s,transform .25s; }
.shrine-back:hover { background:var(--chip-hover);transform:translateX(-2px); }
button.shrine-back { border:0;cursor:pointer; }
.shrine-back [lang=ja] { font:700 12px/1 var(--jp);letter-spacing:.12em;color:var(--accent); }

/* The time of day: a small chip in the top-right corner shows the scene and the local time, and opens the choices, as on
   the home street: preview Morning, Evening or Night, or follow the local clock. It scrolls away with the page. */
.theme-controls { position:absolute;top:16px;right:24px;z-index:30;display:flex;flex-direction:column;align-items:flex-end;color:var(--ink); }
.theme-controls[hidden] { display:none; }
.theme-toggle {
  display:inline-flex;align-items:center;gap:7px;padding:8px 12px 8px 10px;border:1px solid var(--line);border-radius:999px;background:var(--chip);
  font:700 11px/1.2 var(--mono);letter-spacing:.06em;font-variant-numeric:tabular-nums;cursor:pointer;-webkit-backdrop-filter:blur(8px);backdrop-filter:blur(8px);transition:background .25s;
}
.theme-toggle:hover,.theme-toggle[aria-expanded=true] { background:var(--chip-hover); }
.theme-now svg { display:block;width:16px;height:16px;fill:none;stroke:var(--accent);stroke-width:1.6;stroke-linecap:round;stroke-linejoin:round; }
.theme-toggle::after { content:'';width:5px;height:5px;margin:0 2px 0 1px;border-right:1.5px solid currentColor;border-bottom:1.5px solid currentColor;rotate:45deg;translate:0 -2px;opacity:.55;transition:rotate .25s,translate .25s; }
.theme-toggle[aria-expanded=true]::after { rotate:225deg;translate:0 1px; }
.theme-menu {
  width:270px;margin-top:6px;padding:7px 8px 5px;border:1px solid var(--line);border-radius:10px;background:var(--chip-hover);
  box-shadow:0 5px 24px #101d2814;-webkit-backdrop-filter:blur(14px);backdrop-filter:blur(14px);animation:theme-menu-in .2s ease both;
}
@keyframes theme-menu-in { from { opacity:0;transform:translateY(-4px); } }
.theme-options { display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:3px; }
.theme-options button {
  display:flex;align-items:center;justify-content:center;gap:5px;min-height:34px;padding:5px 6px;border:1px solid transparent;border-radius:6px;
  background:transparent;color:var(--ink-soft);font-size:11px;font-weight:600;cursor:pointer;transition:background .2s,color .2s,border-color .2s;
}
.theme-options button:hover { background:var(--chip);color:var(--ink); }
.theme-options button[aria-pressed="true"] { background:var(--chip);color:var(--accent);border-color:var(--line); }
.theme-options svg { width:17px;height:17px;flex-shrink:0;fill:none;stroke:currentColor;stroke-width:1.5;stroke-linecap:round;stroke-linejoin:round; }
.theme-meta { display:flex;justify-content:space-between;align-items:center;gap:8px;padding:3px 5px 0;font:9px/1.5 var(--mono); }
.theme-auto { padding:2px 0;border:0;background:none;color:var(--accent);font:inherit;cursor:pointer;text-underline-offset:3px; }
.theme-auto:hover,.theme-controls[data-mode="preview"] .theme-auto { text-decoration:underline; }
.theme-auto::before { content:'';display:inline-block;width:5px;height:5px;margin-right:5px;border-radius:50%;background:var(--seal); }
.theme-auto[aria-pressed="true"]::before { background:#6a9f68; }
.theme-controls[aria-busy="true"] .theme-options { opacity:.65; }
/* A scene change: the old painting fades out over the new one. */
.shrine-scene.is-leaving { animation:scene-leave 1.6s ease forwards; }
@keyframes scene-leave { to { opacity:0; } }

/* Opening an entry is a page-to-page transition. The page crossfades over the still painting while the chosen piece
   really opens: a manga cover lifts off the shelf and lands where it sits on the series page, an omikuji slip unfolds
   into the review sheet, and a stamp-book page turns over into the trip. Going Back plays it in reverse.
   side-quests.js names the chosen piece; the new page names its match. Other browsers fade by hand (side-quests.js). */
@view-transition { navigation:auto; }
::view-transition-old(root),::view-transition-new(root) { animation-duration:.45s; }
.series-cover { view-transition-name:quest-cover; }
[data-post=reviews] .post { view-transition-name:quest-sheet; }
[data-post=travel] .post { view-transition-name:quest-flip; }
::view-transition-group(quest-cover) { animation-duration:.75s;animation-timing-function:cubic-bezier(.2,.8,.2,1); }
::view-transition-old(quest-cover),::view-transition-new(quest-cover) { animation-duration:.75s; }
::view-transition-group(quest-sheet) { animation-duration:.8s;animation-timing-function:cubic-bezier(.2,.8,.2,1); }
::view-transition-old(quest-sheet) { animation:quest-fade-out .3s ease both; }
::view-transition-new(quest-sheet) { animation:quest-fade-in .5s ease .12s both; }
::view-transition-group(quest-flip) { animation-duration:.9s;animation-timing-function:cubic-bezier(.45,0,.2,1); }
::view-transition-image-pair(quest-flip) { perspective:1600px; }
::view-transition-old(quest-flip),::view-transition-new(quest-flip) { mix-blend-mode:normal;backface-visibility:hidden; }
::view-transition-old(quest-flip) { animation:quest-flip-out .45s cubic-bezier(.5,0,1,1) both; }
::view-transition-new(quest-flip) { animation:quest-flip-in .45s cubic-bezier(0,0,.4,1) .45s both; }
/* Arriving through an opening, the pieces that morph stay still; the rest of the card rises gently. */
.quest-arriving .series-card,.quest-arriving .post { animation:none; }
.quest-arriving .series-info { animation:quest-rise-in .6s cubic-bezier(.2,.8,.2,1) .15s both; }
.volume-cover.is-opening,.omikuji.is-opening,.goshuin-page.is-opening { animation:quest-zoom-out .45s cubic-bezier(.2,.8,.2,1) both; }
.quest-leaving main { animation:quest-fade-out .4s ease both; }
@keyframes quest-zoom-out { to { opacity:0;transform:scale(1.5); } }
@keyframes quest-fade-out { to { opacity:0; } }
@keyframes quest-fade-in { from { opacity:0; } }
@keyframes quest-rise-in { from { opacity:0;transform:translateY(18px) scale(.985); } }
@keyframes quest-flip-out { to { transform:rotateY(90deg); } }
@keyframes quest-flip-in { from { transform:rotateY(-90deg); } }

/* A red ink seal, as stamped on manga covers, goshuin pages and opened ema. */
.seal { display:inline-grid;place-items:center;padding:3px 4px 2px;border:1.5px solid currentColor;border-radius:3px;font:800 11px/1 var(--serif);letter-spacing:.04em;color:var(--seal);rotate:-6deg; }

@media(max-aspect-ratio:5/4) { .shrine-scene { background-position:70% 50%; } }
@media(max-width:760px) {
  .shrine-back { padding:8px 13px;font-size:9px; }
  .theme-controls { top:10px;right:12px; }
  .theme-toggle { gap:6px;padding:7px 10px 7px 9px;font-size:10px; }
  .theme-now svg { width:15px;height:15px; }
  .theme-menu { width:min(250px,calc(100vw - 24px));padding:4px 5px 3px;border-radius:8px;box-shadow:none; }
  .theme-options button { min-height:29px;padding:3px 4px;font-size:10px; }
  .theme-options svg { width:15px;height:15px; }
  .theme-meta { padding-top:1px;font-size:8px; }
}
/* The narrowest phones keep the Japanese half of the way-back chip, so it clears the time chip; the English stays for
   screen readers. */
@media(max-width:330px) {
  .shrine-back .back-en { position:absolute;width:1px;height:1px;margin:-1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap; }
}
@media(prefers-reduced-motion:reduce) {
  @view-transition { navigation:none; }
  html { scroll-behavior:auto; }
  .theme-options button { transition:none; }
  .shrine-scene.is-leaving { display:none; }
}
