/* 利善美智能維護頁：紙感底色、品牌紅，以及「描線 → 由下往上建構標誌 → 掃描」的開場動畫。 */

@font-face {
  font-family: "Noto Serif TC Sub";
  src: url("/assets/fonts/noto-serif-tc.woff2") format("woff2");
  font-weight: 200 900;
  font-display: swap;
}

/* Supplementary subset (Noto Serif CJK TC, OFL) for portal-card copy absent from the base subset. */
@font-face {
  font-family: "Noto Serif TC Ext";
  src: url("/assets/fonts/noto-serif-tc-ext-400.woff2") format("woff2");
  font-weight: 200 500;
  font-display: swap;
}

@font-face {
  font-family: "Noto Serif TC Ext";
  src: url("/assets/fonts/noto-serif-tc-ext-700.woff2") format("woff2");
  font-weight: 600 900;
  font-display: swap;
}

@font-face {
  font-family: "Plex Mono";
  src: url("/assets/fonts/plex-mono-400.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: "Plex Mono";
  src: url("/assets/fonts/plex-mono-500.woff2") format("woff2");
  font-weight: 500;
  font-display: swap;
}

:root {
  --paper: #f3eee7;
  --paper-light: #faf7f2;
  --paper-deep: #e7dfd3;
  --ink: #1c1816;
  --ink-soft: #5d554f;
  --line: rgb(28 24 22 / 14%);
  --red: #bf1e2e;
  --red-wash: rgb(191 30 46 / 9%);
  --serif: "Noto Serif TC Sub", "Noto Serif TC Ext", "Noto Serif TC", "Source Han Serif TC", "PMingLiU", serif;
  --mono: "Plex Mono", ui-monospace, "SFMono-Regular", Consolas, "Noto Serif TC Sub", monospace;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-build: cubic-bezier(0.65, 0, 0.25, 1);
  --gutter: clamp(20px, 4.5vw, 64px);
  --frame: min(100% - var(--gutter) * 2, 1240px);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  background: radial-gradient(120% 90% at 20% 45%, var(--paper-light) 0%, var(--paper) 50%, var(--paper-deep) 100%);
  color: var(--ink);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  position: relative;
  isolation: isolate;
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-height: 100vh;
  min-height: 100svh;
  margin: 0;
  overflow-x: hidden;
  font-family: var(--serif);
  font-size: 1.0625rem;
  line-height: 1.9;
  -webkit-font-smoothing: antialiased;
}

/* 繪圖紙格線，集中在標誌一側並往外淡出 */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -2;
  pointer-events: none;
  background-image:
    linear-gradient(var(--line) 1px, transparent 1px),
    linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: 56px 56px;
  -webkit-mask-image: radial-gradient(65% 75% at 27% 50%, #000 15%, transparent 75%);
  mask-image: radial-gradient(65% 75% at 27% 50%, #000 15%, transparent 75%);
  opacity: 0.55;
  animation: fade-in 1.8s ease both;
}

/* 紙張顆粒 */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  opacity: 0.06;
}

::selection {
  background: var(--red);
  color: #fff;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- 頁首／頁尾 ---------- */

.site-header,
.site-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 6px 24px;
  width: var(--frame);
  margin-inline: auto;
}

.site-header p,
.site-footer p {
  margin: 0;
}

.site-header {
  padding-block: clamp(20px, 3.5vh, 36px);
  animation: fade-in 1s ease 0.2s both;
}

.site-footer {
  padding-block: 18px 24px;
  border-top: 1px solid var(--line);
  color: var(--ink-soft);
  font-size: 0.8125rem;
  letter-spacing: 0.04em;
  animation: fade-in 1s ease 1.5s both;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.14em;
}

.brand img {
  width: 30px;
  height: 30px;
}

.host {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink-soft);
  font-family: var(--mono);
  font-size: 0.8125rem;
}

.host::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--red);
}

/* ---------- 主視覺 ---------- */

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr);
  align-content: center;
  align-items: center;
  gap: clamp(48px, 8vw, 128px);
  width: var(--frame);
  margin-inline: auto;
  padding-block: clamp(40px, 7vh, 80px);
}

.stage {
  position: relative;
  justify-self: center;
  width: min(100%, 470px, 62vh);
  aspect-ratio: 1;
  margin: 0;
}

.viewfinder {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
}

.corner {
  position: absolute;
  width: 13%;
  aspect-ratio: 1;
  border: 0 solid var(--ink);
  animation: corner-in 1s var(--ease-out) 0.1s both;
}

.corner--tl {
  top: 0;
  left: 0;
  border-width: 2px 0 0 2px;
  --from: -16px, -16px;
}

.corner--tr {
  top: 0;
  right: 0;
  border-width: 2px 2px 0 0;
  --from: 16px, -16px;
}

.corner--bl {
  bottom: 0;
  left: 0;
  border-width: 0 0 2px 2px;
  --from: -16px, 16px;
}

.corner--br {
  right: 0;
  bottom: 0;
  border-width: 0 2px 2px 0;
  --from: 16px, 16px;
}

.tag {
  position: absolute;
  bottom: calc(100% + 12px);
  left: 0;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 3px 11px 3px 10px;
  background: var(--red);
  color: #fff;
  font-family: var(--mono);
  font-size: 0.75rem;
  font-weight: 500;
  line-height: 1.6;
  letter-spacing: 0.1em;
  animation: rise-in 0.7s var(--ease-out) 1s both;
}

.tag__dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

/* 辨識掃描線：開場結束後，從取景框頂端緩慢掃到底端 */
.scan {
  position: absolute;
  inset: 0 5% auto;
  height: 18%;
  border-bottom: 1px solid rgb(191 30 46 / 70%);
  background: linear-gradient(to bottom, transparent, rgb(191 30 46 / 8%));
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 20%, #000 80%, transparent);
  mask-image: linear-gradient(90deg, transparent, #000 20%, #000 80%, transparent);
  opacity: 0;
  animation: scan 5.6s var(--ease-build) 2.9s infinite;
}

.emblem {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 13% 16%;
}

.mark-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 1648 / 1380;
}

.blueprint {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  fill: none;
  animation: settle 1.2s ease 2.5s forwards;
}

.blueprint__guides {
  stroke: var(--ink);
  stroke-width: 4;
  stroke-dasharray: 14 22;
  opacity: 0;
  animation: guides-in 1s ease 0.5s forwards;
}

.blueprint__edges path {
  stroke: var(--ink);
  stroke-width: 5;
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  animation: draw 1.4s var(--ease-out) 0.3s forwards;
}

.blueprint__edges path:nth-child(2) {
  animation-delay: 0.42s;
}

.blueprint__edges path:nth-child(3) {
  animation-delay: 0.56s;
}

.blueprint__marks path {
  stroke: var(--red);
  stroke-width: 7;
  transform-box: fill-box;
  transform-origin: center;
  animation: pop 0.6s var(--ease-out) 0.9s both;
}

.blueprint__marks path:nth-child(2) {
  animation-delay: 1.05s;
}

.blueprint__marks path:nth-child(3) {
  animation-delay: 1.2s;
}

/* logo 以遮罩呈現，內層紅色由下往上「蓋起來」 */
.mark {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background: var(--red-wash);
  -webkit-mask: url("/assets/mark.png") center / 100% 100% no-repeat;
  mask: url("/assets/mark.png") center / 100% 100% no-repeat;
  animation: fade-in 0.8s ease 0.2s both;
}

.mark__fill {
  position: absolute;
  inset: 0;
  background: var(--red);
  transform-origin: 50% 100%;
  animation: build 1.8s var(--ease-build) 0.7s both;
}

.mark__sheen {
  position: absolute;
  inset: -10% -60%;
  background: linear-gradient(100deg, transparent 42%, rgb(255 255 255 / 36%) 50%, transparent 58%);
  transform: translateX(-60%);
  animation: sheen 7s ease-in-out 3.4s infinite;
}

/* 施工水平線：與紅色填色同步上升，完成後淡出 */
.level {
  position: absolute;
  inset: 0 -9%;
  border-bottom: 1px dashed var(--red);
  pointer-events: none;
  opacity: 0;
  animation: level 1.8s var(--ease-build) 0.7s both;
}

.wordmark {
  display: block;
  width: 100%;
  height: auto;
  margin-top: 9%;
  animation: wipe-in 1s var(--ease-out) 2.1s both;
}

/* ---------- 文案 ---------- */

.copy {
  max-width: 560px;
}

.copy > * {
  margin: 0;
  text-wrap: pretty;
  animation: rise-in 0.9s var(--ease-out) both;
}

.eyebrow {
  display: flex;
  align-items: center;
  gap: 14px;
  color: var(--red);
  font-family: var(--mono);
  font-size: 0.8125rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  animation-delay: 0.45s;
}

.eyebrow::before {
  content: "";
  width: 40px;
  height: 1px;
  background: currentColor;
}

.title {
  margin-top: 16px;
  font-size: clamp(2.75rem, 1.5rem + 4.6vw, 6rem);
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: 0.04em;
  white-space: nowrap;
  animation-delay: 0.55s;
}

.js .title {
  overflow: hidden;
  animation: none;
}

.char {
  display: inline-block;
  animation: char-in 1.1s var(--ease-out) both;
  animation-delay: calc(0.55s + var(--i) * 75ms);
}

.desc {
  max-width: 30em;
  margin-top: 28px;
  font-size: clamp(1.0625rem, 1rem + 0.3vw, 1.1875rem);
  animation-delay: 1s;
}

.desc-en {
  margin-top: 6px;
  color: var(--ink-soft);
  font-size: 0.9375rem;
  line-height: 1.7;
  animation-delay: 1.1s;
}

.note {
  margin-top: 22px;
  padding: 10px 16px;
  border-left: 2px solid var(--red);
  background: rgb(255 255 255 / 50%);
  font-size: 0.9375rem;
  animation-delay: 1.15s;
}

.note[hidden] {
  display: none;
}

.progress {
  position: relative;
  max-width: 380px;
  height: 2px;
  margin-top: 44px;
  overflow: hidden;
  background: var(--line);
  animation-delay: 1.25s;
}

.progress__bar {
  position: absolute;
  inset: 0 auto 0 0;
  width: 30%;
  background: var(--red);
  animation: progress 2.6s var(--ease-build) 1.7s infinite both;
}

.progress-label {
  margin-top: 12px;
  color: var(--ink-soft);
  font-family: var(--mono);
  font-size: 0.75rem;
  letter-spacing: 0.12em;
  animation-delay: 1.3s;
}

/* ---------- 動畫 ---------- */

@keyframes fade-in {
  from {
    opacity: 0;
  }
}

@keyframes rise-in {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
}

@keyframes char-in {
  from {
    transform: translateY(105%);
  }
}

@keyframes corner-in {
  from {
    opacity: 0;
    transform: translate(var(--from));
  }
}

@keyframes draw {
  to {
    stroke-dashoffset: 0;
  }
}

@keyframes guides-in {
  to {
    opacity: 0.45;
  }
}

@keyframes pop {
  from {
    opacity: 0;
    transform: scale(0.4) rotate(-45deg);
  }
}

@keyframes settle {
  to {
    opacity: 0.5;
  }
}

@keyframes build {
  from {
    transform: scaleY(0);
  }
}

@keyframes level {
  0% {
    opacity: 0;
    transform: translateY(0);
  }

  8%,
  86% {
    opacity: 1;
  }

  100% {
    opacity: 0;
    transform: translateY(-100%);
  }
}

@keyframes wipe-in {
  from {
    clip-path: inset(0 100% 0 0);
  }

  to {
    clip-path: inset(0);
  }
}

@keyframes sheen {
  0% {
    transform: translateX(-60%);
  }

  28%,
  100% {
    transform: translateX(60%);
  }
}

@keyframes scan {
  0% {
    opacity: 0;
    transform: translateY(0);
  }

  12%,
  80% {
    opacity: 1;
  }

  100% {
    opacity: 0;
    transform: translateY(455%);
  }
}

@keyframes progress {
  from {
    transform: translateX(-100%);
  }

  to {
    transform: translateX(340%);
  }
}

/* ---------- 響應式 ---------- */

@media (max-width: 760px) {
  .hero {
    grid-template-columns: minmax(0, 1fr);
    gap: 48px;
    padding-block: 40px 56px;
  }

  .stage {
    justify-self: start;
    width: min(100%, 340px);
  }

  .copy {
    max-width: none;
  }
}

@media (max-width: 480px) {
  .site-footer {
    flex-direction: column;
    align-items: flex-start;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 1ms !important;
    animation-delay: 0s !important;
    animation-iteration-count: 1 !important;
  }

  .scan,
  .mark__sheen {
    display: none;
  }

  .progress__bar {
    animation: none !important;
  }
}

/* ---------- 首頁：三張系統入口大卡片 ---------- */

.page {
  display: flex;
  flex-direction: column;
  gap: clamp(32px, 5vh, 56px);
  width: var(--frame);
  margin-inline: auto;
  padding-block: clamp(16px, 3vh, 40px) clamp(40px, 7vh, 80px);
}

.hero--compact {
  grid-template-columns: auto minmax(0, 1fr);
  gap: clamp(28px, 5vw, 72px);
  width: 100%;
  padding-block: 0;
}

.hero--compact .stage {
  width: clamp(150px, 18vw, 240px);
}

.hero--compact .tag {
  bottom: calc(100% + 8px);
}

.hero--compact .title {
  font-size: clamp(2.25rem, 1.4rem + 3vw, 4rem);
}

.hero--compact .desc {
  margin-top: 18px;
}

.portals__title {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 0 0 20px;
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  animation: rise-in 0.9s var(--ease-out) 1.1s both;
}

.portals__eyebrow {
  color: var(--red);
  font-family: var(--mono);
  font-size: 0.8125rem;
  font-weight: 500;
  letter-spacing: 0.04em;
}

.portal-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(16px, 2vw, 28px);
  margin: 0;
  padding: 0;
  list-style: none;
}

.portal-grid > li {
  display: flex;
  animation: rise-in 0.9s var(--ease-out) both;
  animation-delay: 1.2s;
}

.portal-grid > li:nth-child(2) {
  animation-delay: 1.32s;
}

.portal-grid > li:nth-child(3) {
  animation-delay: 1.44s;
}

.portal-tile {
  position: relative;
  display: flex;
  flex: 1;
  flex-direction: column;
  min-height: clamp(260px, 34vh, 340px);
  padding: clamp(22px, 2.4vw, 32px);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: rgb(255 255 255 / 55%);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  color: var(--ink);
  text-decoration: none;
  transition: transform 0.3s var(--ease-out), box-shadow 0.3s var(--ease-out), border-color 0.3s, background 0.3s;
}

/* 左上紅色取景角，呼應主視覺取景框 */
.portal-tile::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 0;
  height: 3px;
  background: var(--red);
  transition: width 0.4s var(--ease-out);
}

.portal-tile--live::before {
  width: 56px;
}

.portal-tile:hover,
.portal-tile:focus-visible {
  border-color: rgb(191 30 46 / 40%);
  background: rgb(255 255 255 / 88%);
  box-shadow: 0 10px 32px rgb(28 24 22 / 9%);
  transform: translateY(-4px);
}

.portal-tile:hover::before,
.portal-tile:focus-visible::before {
  width: 100%;
}

.portal-tile:focus-visible {
  outline: 3px solid var(--red);
  outline-offset: 4px;
}

.portal-tile__top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.portal-tile__icon {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  border-radius: 6px;
  background: var(--red-wash);
  color: var(--red);
}

.portal-tile__icon svg {
  width: 30px;
  height: 30px;
}

.portal-tile__title {
  margin-top: 28px;
  font-size: clamp(1.375rem, 1.1rem + 0.8vw, 1.75rem);
  font-weight: 800;
  line-height: 1.3;
  letter-spacing: 0.06em;
}

.portal-tile__en {
  margin-top: 4px;
  color: var(--ink-soft);
  font-family: var(--mono);
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.portal-tile__desc {
  margin-top: 16px;
  margin-bottom: 22px;
  color: var(--ink-soft);
  font-size: 0.9375rem;
  line-height: 1.75;
  text-wrap: pretty;
}

.portal-tile__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: auto;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.portal-tile__host {
  overflow: hidden;
  color: var(--ink-soft);
  font-family: var(--mono);
  font-size: 0.8125rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.portal-tile__arrow {
  color: var(--red);
  font-family: var(--mono);
  font-size: 1.25rem;
  transition: transform 0.3s var(--ease-out);
}

.portal-tile:hover .portal-tile__arrow,
.portal-tile:focus-visible .portal-tile__arrow {
  transform: translateX(6px);
}

.portal-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px;
  border-radius: 3px;
  background: rgb(28 24 22 / 7%);
  color: var(--ink-soft);
  font-family: var(--serif);
  font-size: 0.8125rem;
  font-weight: 700;
  line-height: 1.6;
  letter-spacing: 0.06em;
  white-space: nowrap;
}

.portal-badge--live {
  background: rgb(191 30 46 / 12%);
  color: var(--red);
}

.portal-badge--live::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

@media (max-width: 960px) {
  .portal-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .portal-tile {
    min-height: 0;
  }
}

@media (max-width: 760px) {
  .hero--compact {
    grid-template-columns: minmax(0, 1fr);
    gap: 36px;
    padding-block: 24px 0;
  }

  .hero--compact .stage {
    width: min(100%, 180px);
  }

  .hero--compact .title {
    white-space: normal;
  }
}

@media (prefers-reduced-motion: reduce) {
  .portal-tile,
  .portal-tile::before,
  .portal-tile__arrow {
    transition: none;
  }

  .portal-tile:hover,
  .portal-tile:focus-visible {
    transform: none;
  }
}
