/* 視覺對齊 jdc-company-profile 公司簡介簡報 */
:root {
  --teal: #00696D;
  --teal-dark: #005457;
  --magenta: #BB094E;
  --ink: #2C2C2C;
  --muted: #6F6F6B;
  --faint: #B5B5B0;
  --line: #E2E2DF;
  --bg: #FDFDFC;
  --placeholder: #F1F1EE;
  --gutter: clamp(16px, 3.5vw, 56px);
  --sheet-ms: 320ms;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; -webkit-tap-highlight-color: rgb(0 105 109 / .15); }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 'PingFang TC', 'Noto Sans TC', 'Microsoft JhengHei', sans-serif; }
button, input { font: inherit; color: inherit; }
h1, h2, p { margin: 0; }
:focus-visible { outline: 3px solid var(--magenta); outline-offset: 2px; }
#posters:focus { outline: none; }
/* 只設在清單上：設在 html 的 scroll-padding-top 會讓工具列內的元素取得焦點時整頁往回跳 */
#posters, #posters :is(a, button) { scroll-margin-top: calc(var(--tools-height, 0px) + 16px); }

.skip-link { position: absolute; top: -64px; left: var(--gutter); z-index: 20; padding: 8px 14px; background: var(--teal); color: #fff; font-size: 13px; letter-spacing: .14em; text-decoration: none; }
.skip-link:focus { top: 8px; }

.page { padding: 24px var(--gutter) 28px; }

.strip { display: flex; justify-content: space-between; align-items: center; gap: 12px; color: var(--muted); font-size: 13px; letter-spacing: .1em; white-space: nowrap; }
.logo { display: block; height: 42px; width: auto; }

.hero { margin-top: 12px; padding-bottom: 22px; border-bottom: 1px solid var(--line); }
.rule { width: 48px; height: 2px; background: var(--magenta); margin-bottom: 16px; }
h1 { font-size: 36px; font-weight: 600; letter-spacing: .04em; line-height: 1.3; }
.hero p { color: var(--muted); letter-spacing: .08em; margin-top: 6px; }
.hero p span { white-space: nowrap; }

.tools { position: sticky; top: 0; z-index: 10; display: flex; justify-content: space-between; align-items: center; gap: 12px 20px; flex-wrap: wrap; padding: 12px 0; margin-bottom: 24px; background: var(--bg); border-bottom: 1px solid var(--line); }
.chips { display: flex; gap: 2px; flex-wrap: wrap; flex: 1; min-width: 280px; }
.chips button { border: 0; background: none; padding: 4px 10px; font-size: 14px; color: var(--muted); cursor: pointer; white-space: nowrap; transition: color 120ms, background-color 150ms; }
.chips button[aria-pressed=true] { background: var(--teal); color: #fff; }
.chip-count { margin-left: 5px; font-size: 12px; font-variant-numeric: tabular-nums; }
.search { width: 100%; max-width: 300px; padding: 9px 12px; border: 1px solid var(--faint); border-radius: 0; background: #fff; appearance: none; }
.search:focus { border-color: var(--teal); }
.search:disabled { background: var(--placeholder); cursor: not-allowed; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 36px 24px; margin: 0; padding: 0; list-style: none; }
.grid:empty { display: none; }
.poster { position: relative; display: flex; flex-direction: column; }
.poster-info { padding-top: 10px; display: flex; flex-direction: column; flex: 1; }
.poster-info small { color: var(--muted); font-size: 12px; letter-spacing: .04em; }
.poster-info h2 { font-size: inherit; font-weight: 600; line-height: 1.35; margin: 2px 0 6px; }
.poster-info .file-meta { margin-top: auto; }
.thumb { display: block; width: 100%; aspect-ratio: 1 / 1.414; padding: 0; border: 1px solid var(--line); background: var(--placeholder); overflow: hidden; cursor: zoom-in; transition: border-color 120ms; }
.thumb img { display: block; width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity 300ms ease-out, transform 200ms ease-out; }
.thumb img.is-loaded { opacity: 1; }
.no-thumb { display: flex; width: 100%; aspect-ratio: 1 / 1.414; align-items: center; justify-content: center; padding: 8px; border: 1px solid var(--line); background: var(--placeholder); color: var(--muted); font-size: 13px; text-align: center; }
.thumb .no-thumb { border: 0; height: 100%; }

.actions { display: flex; justify-content: space-between; align-items: center; margin-top: 2px; }
.btn { display: inline-block; padding: 8px 14px; border: 1px solid transparent; font-size: 13px; font-weight: 500; letter-spacing: .14em; text-align: center; text-decoration: none; cursor: pointer; }
.download { background: var(--teal); color: #fff; }
.btn, .text-btn { transition: color 120ms, background-color 120ms, border-color 120ms, transform 100ms; }
.btn:active, .text-btn:active { transform: translateY(1px); }
.source { flex: 1; padding-inline: 8px; letter-spacing: .04em; }
.outline { background: #fff; border-color: var(--faint); }
.text-btn { background: none; border: 0; padding: 8px 4px; color: var(--muted); font-size: 13px; letter-spacing: .14em; cursor: pointer; }

.message { padding: 32px 16px; color: var(--muted); text-align: center; overflow-wrap: anywhere; }
.message .birds { display: flex; justify-content: center; align-items: flex-end; gap: 4px; width: fit-content; margin: 0 auto 12px; padding: 0 14px; overflow: hidden; border-bottom: 1px solid var(--line); }
.message .birds img { display: block; height: 40px; width: auto; }
.message button { margin-top: 12px; }

.toast { position: fixed; bottom: 24px; left: 50%; z-index: 20; max-width: calc(100vw - 32px); padding: 8px 16px; background: var(--ink); color: #fff; font-size: 13px; letter-spacing: .08em; width: max-content; text-align: center; transform: translate(-50%, 8px); opacity: 0; pointer-events: none; transition: opacity 120ms, transform 120ms; }
.toast.is-on { transform: translateX(-50%); opacity: 1; transition: opacity 220ms ease-out, transform 220ms var(--ease-out); }
dialog .toast { top: 52px; bottom: auto; }

/* 吉祥物探頭：鳥躲在邊緣後面，外層裁切當作邊緣，只有互動時露出上半身 */
.peek { position: absolute; top: -24px; right: 14%; height: 24px; overflow: hidden; pointer-events: none; }
.peek-left { right: auto; left: 14%; }
.peek img { display: block; height: 32px; width: auto; transform: translateY(100%); transition: transform 140ms ease-in; }
.poster.is-peeking .peek img, .poster:has(:focus-visible) .peek img { transform: none; transition: transform 260ms var(--ease-out); }
/* 觸控按過後 :hover 會黏住，滑過的樣式只給真的能滑過的裝置 */
@media (hover: hover) {
  .poster:hover .peek img { transform: none; transition: transform 260ms var(--ease-out); }
  .chips button:hover { color: var(--teal); }
  .chips button[aria-pressed=true]:hover { color: #fff; }
  .thumb:hover { border-color: var(--teal); }
  .thumb:hover img { transform: scale(1.02); }
  .download:hover { background: var(--teal-dark); }
  .outline:hover { border-color: var(--teal); color: var(--teal); }
  .text-btn:hover { color: var(--teal); }
}
.toast-bird { position: absolute; left: 12px; bottom: 100%; height: 28px; overflow: hidden; }
.toast-bird img { display: block; height: 36px; width: auto; animation: bird-rise 320ms var(--ease-out); }
.is-looking img { animation: bird-rise 360ms var(--ease-out) backwards, bird-look 760ms ease-in-out 360ms; transform-origin: 50% 100%; }
.is-looking img:nth-child(2) { animation-delay: 80ms, 480ms; }
@keyframes bird-rise { from { transform: translateY(100%); } }
@keyframes bird-look { 30% { transform: rotate(-7deg); } 70% { transform: rotate(6deg); } }

/* 海報展開：關閉比開啟快 */
.sheet-closing { --sheet-ms: 200ms; }
::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) { animation-duration: var(--sheet-ms); animation-timing-function: var(--ease-out); }

footer { margin-top: 56px; border-top: 1px solid var(--line); padding-top: 12px; color: var(--muted); font-size: 12px; letter-spacing: .2em; text-align: right; }

dialog { max-width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 32px); max-height: calc(100dvh - 32px); padding: 14px; border: 0; background: var(--bg); color: var(--ink); overflow: auto; }
dialog::backdrop { background: #111c; }
dialog .sheet { position: relative; display: flex; align-items: center; justify-content: center; height: min(66vh, 760px); height: min(66dvh, 760px); aspect-ratio: 1 / 1.414; max-width: 100%; margin: auto; border: 1px solid var(--line); background: var(--placeholder); overflow: hidden; }
.sheet-note { padding: 8px; color: var(--muted); font-size: 13px; text-align: center; }
.sheet img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.sheet-full { opacity: 0; transition: opacity 300ms ease-out; }
.sheet-full.is-loaded { opacity: 1; }
dialog h2 { font-size: 17px; font-weight: 600; margin-top: 10px; }
dialog p { color: var(--muted); font-size: 13px; margin-bottom: 10px; }
dialog .dialog-actions { display: flex; gap: 8px; }
dialog .dialog-actions > * { flex: 1; padding: 10px; }

@media (pointer: coarse) {
  .chips button, .btn, .text-btn { min-height: 44px; }
  .text-btn { min-width: 44px; }
  .btn { display: inline-flex; align-items: center; justify-content: center; }
  /* 小於 16px 時 iOS 聚焦輸入框會自動放大整頁 */
  .search { font-size: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  /* 不移動，改用淡入，探頭與提示仍看得到 */
  .peek img { transform: none; opacity: 0; transition: opacity 150ms; }
  .poster.is-peeking .peek img, .poster:has(:focus-visible) .peek img { opacity: 1; transition: opacity 150ms; }
  @media (hover: hover) {
    .poster:hover .peek img { opacity: 1; transition: opacity 150ms; }
  }
  .toast, .toast.is-on { transform: translateX(-50%); }
  .toast-bird img, .is-looking img { animation: none; }
  .thumb:hover img { transform: none; }
  .btn:active, .text-btn:active { transform: none; }
}

/* 手機與觸控平板共用；橫放的條件限定寬度，直放時鍵盤把可視高度壓矮也不會誤判 */
@media (max-width: 720px), (max-height: 500px) and (min-width: 560px), (min-width: 721px) and (max-width: 1194px) and (pointer: coarse) {
  .page { padding-top: 16px; }
  /* 頁首收成一區：名稱、張數、標誌同一列，海報才能早點出現 */
  header { display: grid; grid-template-columns: auto 1fr auto; align-items: baseline; column-gap: 10px; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
  .strip, .hero { display: contents; }
  .rule { grid-area: 1 / 1 / 2 / 3; margin-bottom: 10px; }
  h1 { grid-area: 2 / 1; font-size: 28px; }
  #count { grid-area: 2 / 2; font-size: 12px; letter-spacing: .04em; }
  .logo { grid-area: 1 / 3 / 3 / 4; align-self: end; height: 36px; }
  .hero p { grid-area: 3 / 1 / 4 / -1; font-size: 13px; }
  .tools { padding-block: 8px; gap: 8px; margin-bottom: 22px; }
  .search { order: -1; height: 44px; max-width: none; }
  /* 橫向捲動會裁掉超出範圍的內容，上下留白要放得下焦點框 */
  .chips { min-width: 0; flex-wrap: nowrap; overflow-x: auto; overscroll-behavior-x: contain; scroll-padding-inline: var(--gutter); }
  .peek { top: -22px; height: 22px; }
  .peek img { height: 30px; }
  footer { margin-top: 36px; letter-spacing: .12em; }
}

/* 手機直放 */
@media (max-width: 559px), (max-width: 720px) and (min-height: 501px) {
  /* 往下捲時搜尋框滑出畫面，只留類型按鈕：上移距離等於工具列上方留白加搜尋框高度 */
  .tools { top: -52px; }
  .chips { flex: 1 0 calc(100% + 2 * var(--gutter)); margin: -5px calc(-1 * var(--gutter)); padding: 5px var(--gutter); }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 26px 12px; }
  /* 海報撐滿寬度不留灰邊，195px 是標題兩行、按鈕與視窗留白，矮螢幕時改由高度限制 */
  dialog { width: calc(100vw - 32px); }
  dialog .sheet { height: auto; width: 100%; width: min(100%, calc((100dvh - 195px) / 1.414)); }
}

/* 手機橫放與觸控平板：頁首與工具列各收成一列。滑鼠操作的窄視窗不適用，類型按鈕維持換行才不必橫向捲動 */
@media (max-height: 500px) and (min-width: 560px), (min-width: 721px) and (max-width: 1194px) and (pointer: coarse) {
  header { grid-template-columns: auto 1fr auto auto; }
  h1 { font-size: 24px; }
  .hero p { grid-area: 2 / 2; }
  #count { grid-area: 2 / 3; }
  .logo { grid-area: 1 / 4 / 3 / 5; }
  .tools { flex-wrap: nowrap; }
  .search { flex: 0 0 260px; }
  .chips { flex: 1 1 0; margin: -5px calc(-1 * var(--gutter)) -5px 0; padding: 5px var(--gutter) 5px 5px; }
}

/* 手機橫放：高度最缺，海報縮小多排幾欄，預覽改左右排 */
@media (max-height: 500px) and (min-width: 560px) {
  .grid { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 26px 16px; }
  dialog { width: min(560px, calc(100vw - 32px)); }
  dialog[open] { display: grid; grid-template-columns: auto minmax(0, 1fr); grid-template-rows: auto auto 1fr; column-gap: 16px; }
  dialog .sheet { grid-row: 1 / -1; height: calc(100vh - 60px); height: calc(100dvh - 60px); max-width: none; margin: 0; }
  dialog h2 { margin-top: 0; }
  dialog .dialog-actions { align-self: end; }
}
