/* 千粒碾米所：一路放大的稻田 */
:root {
  --sans: "PingFang TC", "Noto Sans TC", "Source Han Sans TC", "Microsoft JhengHei", system-ui, sans-serif;
  --serif-fallback: "Noto Serif TC", "Source Han Serif TC", "Songti TC", "PMingLiU", serif;
  --title-font: "Noto Serif TC", var(--serif-fallback);
  --title-weight: 600;
  --pad: clamp(20px, 4.2vw, 72px);
  --radius: 2px;
  --ease: cubic-bezier(.22, .8, .24, 1);
  /* 定案配色「穀殼墨黑」 */
  --ink: #141210;
  --ink-deep: #0b0a09;
  --paper: #f3eee2;
  --gold: #b9b4a8;
  --seal: #8a6a3f;
  --accent: #e07b39;
  --accent-ink: #141210;
  --kraft: #dcc7a1;
  --shade: 20, 18, 16;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: none;
  background: var(--ink-deep);
  color: var(--paper);
  font: 400 16px/1.8 var(--sans);
  -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
.display { font-family: var(--title-font); font-weight: var(--title-weight); letter-spacing: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.skip-link { position: fixed; left: 12px; top: -60px; z-index: 50; padding: 10px 14px; background: var(--paper); color: var(--ink); }
.skip-link:focus { top: 12px; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }
[tabindex="-1"]:focus { outline: none; }

/* ── 畫面 ── */
.scene { position: fixed; inset: 0; overflow: hidden; }
.zoom-canvas, .zoom-fallback { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.zoom-fallback { object-fit: cover; opacity: 0; transition: opacity .5s ease; }
.is-fallback .zoom-fallback { opacity: 1; }
.is-fallback .zoom-canvas { display: none; }
.scrim {
  position: absolute; inset: 0; pointer-events: none;
  background:
    linear-gradient(90deg, rgba(var(--shade), .62) 0%, rgba(var(--shade), .34) 30%, rgba(var(--shade), 0) 52%),
    linear-gradient(180deg, rgba(var(--shade), .38) 0%, rgba(var(--shade), 0) 18%, rgba(var(--shade), 0) 80%, rgba(var(--shade), .3) 100%);
}

/* 取景框：框住下一站會放大到的範圍 */
.viewfinder {
  position: absolute; left: 50%; top: 50%;
  width: var(--vf-w, 260px); height: var(--vf-h, 146px);
  transform: translate(-50%, -50%);
  opacity: var(--vf-o, 1);
  transition: opacity .3s ease;
}
.viewfinder .corner { position: absolute; width: 16px; height: 16px; border: 0 solid var(--paper); filter: drop-shadow(0 0 3px rgba(0,0,0,.45)); transition: transform .35s var(--ease); }
.viewfinder .tl { left: -1px; top: -1px; border-left-width: 2px; border-top-width: 2px; }
.viewfinder .tr { right: -1px; top: -1px; border-right-width: 2px; border-top-width: 2px; }
.viewfinder .bl { left: -1px; bottom: -1px; border-left-width: 2px; border-bottom-width: 2px; }
.viewfinder .br { right: -1px; bottom: -1px; border-right-width: 2px; border-bottom-width: 2px; }
.viewfinder-label {
  position: absolute; left: calc(100% + 12px); top: -2px;
  display: flex; align-items: baseline; gap: 8px; white-space: nowrap;
  font-size: 13px; line-height: 1.4; text-shadow: 0 1px 6px rgba(0,0,0,.55);
}
.viewfinder-label b { font-family: var(--title-font); font-weight: var(--title-weight); font-size: 22px; }
.viewfinder-hit {
  position: fixed; left: 50%; top: 50%; z-index: 4;
  width: max(var(--vf-w, 260px), 48px); height: max(var(--vf-h, 146px), 48px);
  transform: translate(-50%, -50%);
  border: 0; padding: 0; background: none; border-radius: 0;
  cursor: zoom-in;
}
.viewfinder-hit[hidden] { display: none; }
body.vf-hover .viewfinder .tl { transform: translate(-5px, -5px); }
body.vf-hover .viewfinder .tr { transform: translate(5px, -5px); }
body.vf-hover .viewfinder .bl { transform: translate(-5px, 5px); }
body.vf-hover .viewfinder .br { transform: translate(5px, 5px); }

/* ── 頁首 ── */
.site-header {
  position: fixed; inset: 0 0 auto; z-index: 10;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 16px;
  padding: clamp(14px, 2vw, 26px) var(--pad);
  text-shadow: 0 1px 8px rgba(0,0,0,.35);
}
.brand { display: inline-flex; align-items: center; gap: 12px; justify-self: start; color: inherit; text-decoration: none; min-height: 44px; }
.seal {
  display: grid; place-items: center;
  width: 40px; height: 40px; padding: 2px;
  background: var(--seal); color: #fbf6ea; border-radius: var(--radius);
  font: 400 15px/1 var(--title-font);
  writing-mode: vertical-rl; letter-spacing: 0;
  text-shadow: none;
}
.brand-name { font-size: 22px; line-height: 1.2; }
.scale-readout { margin: 0; display: flex; align-items: center; gap: 12px; font-size: 13px; line-height: 1.3; }
.scale-bar { display: block; width: var(--bar, 80px); height: 9px; border: 1.5px solid currentColor; border-top: 0; transition: width .25s linear; }
.scale-bar i { display: block; width: 50%; height: 100%; border-right: 1.5px solid currentColor; }
.scale-text { display: grid; }
.scale-text b { font-weight: 500; font-variant-numeric: tabular-nums; }
.scale-text small { font-size: 12px; opacity: .78; font-variant-numeric: tabular-nums; }
.header-actions { justify-self: end; display: flex; align-items: center; gap: 10px; }

.button {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 22px;
  border: 1px solid transparent; border-radius: var(--radius);
  font-size: 15px; font-weight: 500; line-height: 1.2; text-decoration: none; white-space: nowrap;
  transition: background-color .2s ease, color .2s ease, border-color .2s ease, transform .2s ease;
}
.button:active { transform: translateY(1px); }
.button-solid { background: var(--accent); color: var(--accent-ink); text-shadow: none; }
.button-solid:hover { filter: brightness(1.08); }
.button-line { border-color: rgba(245, 240, 228, .7); background: rgba(var(--shade), .28); color: var(--paper); backdrop-filter: blur(6px); }
.button-line:hover { background: var(--paper); color: var(--ink); text-shadow: none; }
.menu-open { display: none; border-color: rgba(245, 240, 228, .7); background: rgba(var(--shade), .28); color: var(--paper); min-width: 64px; }
.site-header .button { min-height: 44px; padding: 0 18px; }

/* ── 站點選單：五個由大到小的方框 ── */
.zoom-nav { position: fixed; right: var(--pad); top: 50%; z-index: 5; transform: translateY(-50%); }
.zoom-nav ol { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.zoom-nav button {
  display: grid; grid-template-columns: 44px auto; grid-template-rows: auto auto; align-items: center; column-gap: 10px;
  min-height: 56px; width: 100%; padding: 4px 6px; border: 0; background: none; text-align: left;
  text-shadow: 0 1px 6px rgba(0,0,0,.45);
}
.nav-square { grid-row: 1 / 3; justify-self: center; width: var(--s); height: var(--s); border: 1.5px solid currentColor; opacity: .7; transition: background-color .3s ease, opacity .3s ease; box-shadow: 0 0 6px rgba(0,0,0,.25); }
.zoom-nav li:nth-child(1) .nav-square { --s: 40px; }
.zoom-nav li:nth-child(2) .nav-square { --s: 31px; }
.zoom-nav li:nth-child(3) .nav-square { --s: 23px; }
.zoom-nav li:nth-child(4) .nav-square { --s: 15px; }
.zoom-nav li:nth-child(5) .nav-square { --s: 8px; }
.nav-name { font-size: 24px; line-height: 1.1; opacity: .75; }
.zoom-nav small { font-size: 11px; line-height: 1.3; opacity: 0; transform: translateX(-4px); transition: opacity .2s ease, transform .2s ease; font-variant-numeric: tabular-nums; }
.zoom-nav button:hover small, .zoom-nav button:focus-visible small, .zoom-nav button[aria-current] small { opacity: .85; transform: none; }
.zoom-nav button[aria-current] .nav-square { background: var(--paper); opacity: 1; }
.zoom-nav button[aria-current] .nav-name, .zoom-nav button:hover .nav-name { opacity: 1; }
.zoom-nav button:disabled { opacity: .35; cursor: default; }

/* ── 各站內容 ── */
.stations { position: fixed; z-index: 3; left: var(--pad); top: 50%; transform: translateY(-46%); width: min(540px, 36vw); pointer-events: none; }
.station { pointer-events: auto; }
.station[hidden] { display: none; }
.station-mark { display: flex; align-items: flex-end; gap: 16px; margin: 0 0 18px; }
.station-char { font-size: clamp(88px, 9.4vw, 168px); line-height: 1; text-shadow: 0 4px 30px rgba(var(--shade), .4); }
.station-meta { padding-bottom: .9em; font-size: 13px; letter-spacing: .04em; opacity: .86; white-space: nowrap; }
.station-title { margin: 0; font-size: clamp(34px, 3.4vw, 60px); line-height: 1.3; text-wrap: balance; text-shadow: 0 2px 22px rgba(var(--shade), .45); }
.station-lede { margin: 20px 0 0; max-width: 30em; font-size: clamp(15px, 1.15vw, 17px); line-height: 1.85; text-wrap: pretty; text-shadow: 0 1px 10px rgba(var(--shade), .6); }
.station-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 28px; }

.figures { display: grid; grid-template-columns: repeat(3, auto); justify-content: start; gap: 8px 36px; margin: 26px 0 0; }
.figures div { display: grid; gap: 2px; }
.figures dt { font-size: 13px; opacity: .8; }
.figures dd { margin: 0; font-size: 15px; }
.figures dd .display { font-size: clamp(36px, 3.2vw, 52px); line-height: 1.1; margin-right: 2px; }

.varieties, .products { list-style: none; margin: 24px 0 0; padding: 0; display: grid; gap: 12px; }
.varieties li, .products li {
  display: grid; gap: 2px; padding: 14px 18px;
  border-left: 3px solid var(--gold);
  background: rgba(var(--shade), .36); backdrop-filter: blur(8px);
}
.varieties b, .products b { font-size: 18px; font-weight: 600; line-height: 1.4; }
.varieties span, .products span { font-size: 15px; line-height: 1.7; }
.products li { grid-template-columns: 1fr auto; column-gap: 16px; }
.products b, .products span { grid-column: 1; }
.products em { grid-column: 2; grid-row: 1 / 3; align-self: center; font-style: normal; font-size: 15px; font-weight: 600; white-space: nowrap; font-variant-numeric: tabular-nums; }

.steps { list-style: none; margin: 26px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.steps button {
  display: inline-flex; align-items: center; gap: 10px; min-height: 48px; padding: 0 16px 0 8px;
  border: 1px solid rgba(245, 240, 228, .55); border-radius: var(--radius);
  background: rgba(var(--shade), .3); backdrop-filter: blur(6px);
  font-size: 15px;
}
.steps button:hover { background: var(--paper); color: var(--ink); text-shadow: none; }
.step-no { display: grid; place-items: center; width: 30px; height: 30px; background: var(--paper); color: var(--ink); font-size: 13px; font-weight: 600; }

/* 進場：大字由上往下寫出來，標題由模糊對焦到清楚 */
.station.is-entering .station-char { animation: brush-down 1s var(--ease) both; }
.station.is-entering .station-meta { animation: fade-in .6s ease .35s both; }
.station.is-entering .station-title { animation: focus-in .9s var(--ease) .15s both; }
.station.is-entering .station-lede,
.station.is-entering .figures,
.station.is-entering .varieties,
.station.is-entering .steps,
.station.is-entering .products,
.station.is-entering .station-actions { animation: focus-in .8s var(--ease) both; }
.station.is-entering .station-lede { animation-delay: .32s; }
.station.is-entering .figures, .station.is-entering .varieties, .station.is-entering .steps, .station.is-entering .products { animation-delay: .44s; }
.station.is-entering .station-actions { animation-delay: .56s; }
.station.is-leaving { animation: focus-out .35s ease both; }
@keyframes brush-down { from { clip-path: inset(0 0 100% 0); filter: blur(3px); } to { clip-path: inset(0 0 -10% 0); filter: blur(0); } }
@keyframes focus-in { from { opacity: 0; filter: blur(10px); transform: scale(1.035); } to { opacity: 1; filter: blur(0); transform: none; } }
@keyframes focus-out { to { opacity: 0; filter: blur(8px); transform: scale(.97); } }
@keyframes fade-in { from { opacity: 0; } to { opacity: .86; } }

/* ── 品名標示貼紙（細節面板） ── */
.label-panel { position: fixed; inset: 0; z-index: 30; display: grid; justify-items: end; align-items: center; padding: var(--pad); background: rgba(var(--shade), .38); }
.label-panel[hidden] { display: none; }
.label-sticker {
  position: relative; width: min(440px, 100%); max-height: calc(100dvh - 2 * var(--pad)); overflow: auto;
  padding: 30px 30px 28px;
  background: var(--kraft); color: var(--ink);
  border-radius: var(--radius);
  box-shadow: 0 22px 60px rgba(0,0,0,.35), inset 0 0 0 6px var(--kraft), inset 0 0 0 7.5px var(--ink);
  transform-origin: 100% 0;
}
.label-panel.is-open .label-sticker { animation: stick-on .55s var(--ease) both; }
@keyframes stick-on { from { opacity: 0; transform: translate(40px, -12px) rotate(4deg); } 60% { opacity: 1; } to { opacity: 1; transform: rotate(-.8deg); } }
.label-kicker { margin: 0 0 6px; font-size: 12px; letter-spacing: .06em; opacity: .7; }
.label-sticker h2 { margin: 0 0 14px; font-size: 30px; line-height: 1.3; }
.label-sticker p { margin: 0 0 10px; font-size: 15px; line-height: 1.8; }
.panel-close { position: absolute; right: 12px; top: 12px; min-width: 44px; min-height: 44px; border: 1px solid currentColor; border-radius: var(--radius); background: none; font-size: 13px; }
.label-rows { display: grid; margin: 0; border-top: 1px solid currentColor; }
.label-rows div { display: grid; grid-template-columns: 6.5em 1fr; gap: 12px; padding: 10px 0; border-bottom: 1px solid rgba(20, 18, 16, .2); }
.label-rows dt { font-size: 13px; opacity: .72; }
.label-rows dd { margin: 0; font-size: 15px; }
.label-note { font-size: 13px !important; opacity: .75; margin-top: 12px !important; }
.label-form { display: grid; gap: 12px; }
.label-form label { display: grid; gap: 4px; font-size: 13px; }
.label-form input, .label-form select { min-height: 46px; padding: 0 12px; border: 1px solid rgba(0,0,0,.35); border-radius: var(--radius); background: var(--paper); color: var(--ink); font-size: 16px; }
.label-form .button { margin-top: 6px; }
.form-status { min-height: 1.6em; margin: 0 !important; font-size: 14px !important; font-weight: 500; }

/* ── 全螢幕選單：像米袋口往下翻開 ── */
.menu-sheet { position: fixed; inset: 0; z-index: 40; background: var(--ink); color: var(--paper); overflow: auto; }
.menu-sheet[hidden] { display: none; }
.menu-sheet.is-open { animation: bag-open .5s var(--ease) both; }
.menu-sheet.is-closing { animation: bag-close .35s ease both; }
@keyframes bag-open { from { clip-path: inset(0 0 100% 0); } to { clip-path: inset(0 0 0 0); } }
@keyframes bag-close { from { clip-path: inset(0 0 0 0); } to { clip-path: inset(0 0 100% 0); } }
.menu-inner { min-height: 100%; display: grid; grid-template-rows: auto 1fr auto; gap: 24px; padding: 18px var(--pad) 28px; }
.menu-close { justify-self: end; min-width: 64px; min-height: 44px; border: 1px solid rgba(245,240,228,.6); border-radius: var(--radius); background: none; }
.menu-list { list-style: none; margin: 0; padding: 0; display: grid; align-content: center; gap: 4px; }
.menu-list button { display: grid; grid-template-columns: 64px 1fr; align-items: center; gap: 16px; width: 100%; min-height: 72px; padding: 6px 0; border: 0; border-bottom: 1px solid rgba(245,240,228,.18); background: none; text-align: left; }
.menu-list b { font-size: 48px; line-height: 1; font-weight: var(--title-weight); }
.menu-list span { font-size: 15px; opacity: .86; }
.menu-list button[aria-current] b { color: var(--gold); }
.menu-sheet.is-open .menu-list li { animation: focus-in .5s var(--ease) both; }
.menu-sheet.is-open .menu-list li:nth-child(2) { animation-delay: .06s; }
.menu-sheet.is-open .menu-list li:nth-child(3) { animation-delay: .12s; }
.menu-sheet.is-open .menu-list li:nth-child(4) { animation-delay: .18s; }
.menu-sheet.is-open .menu-list li:nth-child(5) { animation-delay: .24s; }
.menu-foot { display: grid; gap: 14px; }
.menu-foot p { margin: 0; font-size: 14px; opacity: .8; }

.hint { position: fixed; left: 50%; bottom: 22px; z-index: 3; margin: 0; transform: translateX(-50%); font-size: 12px; letter-spacing: .08em; opacity: .85; text-shadow: 0 1px 6px rgba(0,0,0,.5); transition: opacity .4s ease; }
.hint span::after { content: ""; display: block; width: 1px; height: 26px; margin: 8px auto 0; background: currentColor; animation: hint-line 1.8s ease-in-out infinite; transform-origin: top; }
@keyframes hint-line { 0% { transform: scaleY(0); } 50% { transform: scaleY(1); transform-origin: top; } 51% { transform-origin: bottom; } 100% { transform: scaleY(0); transform-origin: bottom; } }
body.has-moved .hint { opacity: 0; }

/* ── 小螢幕：字放下方 ── */
@media (max-width: 900px), (orientation: portrait) {
  .site-header { grid-template-columns: 1fr auto; padding-block: 12px; }
  .scale-readout { display: none; }
  .header-actions .button-solid { display: none; }
  .menu-open { display: inline-flex; }
  .zoom-nav { display: none; }
  .brand-name { font-size: 19px; }
  .seal { width: 36px; height: 36px; font-size: 14px; }
  .scrim { background:
    linear-gradient(180deg, rgba(var(--shade), .45) 0%, rgba(var(--shade), 0) 16%, rgba(var(--shade), 0) 38%, rgba(var(--shade), .55) 62%, rgba(var(--shade), .82) 100%); }
  .stations { left: 0; right: 0; top: auto; bottom: 0; width: auto; transform: none; padding: 0 var(--pad) max(22px, env(safe-area-inset-bottom)); }
  .station-mark { gap: 12px; margin-bottom: 10px; }
  .station-char { font-size: 64px; }
  .station-meta { padding-bottom: .6em; }
  .station-title { font-size: clamp(28px, 7.4vw, 40px); }
  .station-lede { margin-top: 12px; font-size: 15px; line-height: 1.75; }
  .station-actions { margin-top: 18px; }
  .station-actions .button { flex: 1 1 auto; }
  .figures { gap: 6px 22px; margin-top: 16px; }
  .figures dd .display { font-size: 30px; }
  .varieties, .products { margin-top: 14px; gap: 8px; }
  .varieties li, .products li { padding: 10px 14px; }
  .varieties span, .products span { font-size: 14px; }
  .steps { margin-top: 16px; }
  .viewfinder-label { left: 50%; top: calc(100% + 8px); transform: translateX(-50%); }
  .hint { display: none; }
  .label-panel { justify-items: stretch; align-items: end; padding: 0; }
  .label-sticker { width: 100%; max-height: 88dvh; border-radius: var(--radius) var(--radius) 0 0; }
  @keyframes stick-on { from { opacity: 0; transform: translateY(40px); } to { opacity: 1; transform: none; } }
}
@media (max-height: 720px) and (min-width: 901px) {
  .station-char { font-size: 84px; }
  .station-title { font-size: clamp(30px, 3vw, 46px); }
  .station-lede { margin-top: 14px; }
  .station-actions { margin-top: 18px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-delay: 0ms !important; transition-duration: .01ms !important; }
  .hint span::after { animation: none; }
}
