@import url('./assets/fonts/fonts.css');

:root {
  --bg: oklch(97% 0.012 82);
  --surface: oklch(99% 0.006 78);
  --fg: oklch(22% 0.02 50);
  --muted: oklch(45% 0.024 62);
  --border: oklch(84% 0.018 72);
  --accent: oklch(55% 0.11 42);

  --surface-soft: oklch(95% 0.016 82);
  --surface-hover: oklch(93% 0.02 78);
  --technical: oklch(42% 0.07 220);
  --technical-soft: oklch(93% 0.026 220);
  --shadow-hover: 0 1rem 2.75rem oklch(28% 0.025 55 / 0.11);

  --font-display: "Noto Serif TC", "Songti TC", PMingLiU, Georgia, "Times New Roman", serif;
  --font-body: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", "Segoe UI", system-ui, sans-serif;
  --font-mono: "Cascadia Code", "SFMono-Regular", Consolas, "Liberation Mono", "Noto Sans TC", monospace;

  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;
  --space-7: 3rem;
  --space-8: 4.5rem;
  --radius-sm: 0.625rem;
  --radius-md: 0.875rem;
  --radius-lg: 1.125rem;
  --content: 76rem;
}

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

html {
  scroll-behavior: smooth;
  scroll-padding-top: 6rem;
}

body {
  margin: 0;
  min-width: 20rem;
  padding-right: env(safe-area-inset-right, 0px);
  padding-left: env(safe-area-inset-left, 0px);
  background:
    linear-gradient(oklch(35% 0.02 55 / 0.03) 1px, transparent 1px),
    linear-gradient(90deg, oklch(35% 0.02 55 / 0.03) 1px, transparent 1px),
    var(--bg);
  background-size: 3rem 3rem;
  color: var(--fg);
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.65;
  text-rendering: optimizeLegibility;
}

a {
  color: inherit;
}

button {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

[hidden] {
  display: none !important;
}

:focus-visible {
  outline: 3px solid var(--technical);
  outline-offset: 4px;
}

.skip-link {
  position: fixed;
  top: var(--space-3);
  left: max(var(--space-3), env(safe-area-inset-left, 0px));
  z-index: 100;
  min-height: 2.75rem;
  padding: var(--space-3) var(--space-4);
  transform: translateY(-180%);
  border-radius: var(--radius-sm);
  background: var(--technical);
  color: var(--surface);
  font-weight: 700;
  text-decoration: none;
}

.skip-link:focus {
  transform: translateY(0);
}

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

main {
  min-width: 0;
}

.shell {
  width: min(calc(100% - 2rem), var(--content));
  margin-inline: auto;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  border-bottom: 1px solid oklch(76% 0.02 72 / 0.78);
  background: oklch(97% 0.012 82 / 0.9);
  backdrop-filter: blur(18px);
}

.header-inner {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  min-height: 4.75rem;
  gap: var(--space-5);
}

.brand {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  min-height: 2.75rem;
  gap: var(--space-3);
  color: var(--fg);
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 2.25rem;
  height: 2.25rem;
  place-items: center;
  border: 1px solid var(--accent);
  border-radius: 50%;
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 700;
}

.brand-copy {
  display: grid;
  line-height: 1.15;
}

.brand-title {
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.06em;
}

.brand-subtitle {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

.nav-link {
  display: inline-flex;
  align-items: center;
  min-height: 2.75rem;
  padding-inline: var(--space-4);
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 650;
  text-decoration: none;
  transition: background-color 160ms ease, color 160ms ease;
}

.nav-link:hover,
.nav-link[aria-current='page'] {
  background: var(--surface-hover);
  color: var(--fg);
}

.language-switcher {
  display: flex;
  padding: 0.2rem;
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  background: var(--surface-soft);
}

.language-option {
  min-width: 3rem;
  min-height: 2.75rem;
  padding: 0 var(--space-3);
  border: 0;
  border-radius: 0.55rem;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 0.76rem;
  font-weight: 700;
  transition: background-color 160ms ease, color 160ms ease;
}

.language-option:hover {
  background: var(--surface-hover);
  color: var(--fg);
}

.language-option[aria-pressed='true'] {
  background: var(--fg);
  color: var(--surface);
}

.projects-intro {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(18rem, 0.48fr);
  align-items: end;
  gap: clamp(3rem, 8vw, 8rem);
  padding-block: clamp(3.75rem, 8vw, 7rem) clamp(3.25rem, 7vw, 6rem);
}

.eyebrow,
.section-kicker,
.summary-label,
.card-platform,
.content-label {
  margin: 0;
  color: var(--technical);
  font-family: var(--font-mono);
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.role-meta {
  margin: var(--space-2) 0 0;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 650;
  letter-spacing: 0.05em;
}

.page-title {
  max-width: 21ch;
  margin: var(--space-5) 0;
  font-family: var(--font-display);
  font-size: clamp(2.5rem, 3.8vw, 3.9rem);
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.12;
  text-wrap: balance;
  overflow-wrap: break-word;
}

html[lang='zh-TW'] .page-title {
  letter-spacing: 0;
  line-height: 1.34;
}

.intro-copy {
  max-width: 42rem;
  margin: 0;
  color: var(--muted);
  font-size: clamp(1.02rem, 1.5vw, 1.18rem);
  line-height: 1.75;
  text-wrap: pretty;
}

.collection-summary {
  border-top: 1px solid var(--border);
  padding-top: var(--space-4);
}

.summary-label {
  color: var(--accent);
}

.summary-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin: var(--space-5) 0;
}

.summary-list div {
  min-width: 0;
  padding-right: var(--space-3);
}

.summary-list div + div {
  padding-left: var(--space-3);
  border-left: 1px solid var(--border);
}

.summary-list dt {
  font-family: var(--font-display);
  font-size: clamp(1.7rem, 3vw, 2.4rem);
  font-weight: 600;
  line-height: 1;
}

.summary-list dd {
  margin: var(--space-2) 0 0;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.summary-note {
  margin: 0;
  color: var(--muted);
  font-family: var(--font-display);
  font-size: 0.95rem;
  line-height: 1.6;
  text-wrap: pretty;
}

.collection-section {
  padding-block: var(--space-8);
  border-top: 1px solid var(--border);
  background: oklch(94% 0.018 80 / 0.58);
}

.collection-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: var(--space-6);
  margin-bottom: var(--space-7);
}

.section-title {
  margin: var(--space-2) 0 0;
  font-family: var(--font-display);
  font-size: clamp(2rem, 3.5vw, 3.25rem);
  font-weight: 600;
  letter-spacing: -0.025em;
  line-height: 1.08;
  text-wrap: balance;
  overflow-wrap: anywhere;
}

.filter-area {
  display: grid;
  justify-items: end;
  gap: var(--space-2);
}

.controls-row {
  display: flex;
  max-width: 100%;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-3);
}

.filter-group {
  display: flex;
  max-width: 100%;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: var(--space-2);
}

.sort-control {
  display: inline-flex;
  align-items: center;
  min-height: 2.75rem;
  gap: var(--space-2);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.76rem;
  font-weight: 700;
}

.sort-select {
  min-height: 2.75rem;
  padding: 0 2.25rem 0 var(--space-3);
  border: 1px solid var(--border);
  border-radius: 999px;
  background-color: var(--surface);
  color: var(--fg);
  cursor: pointer;
  font-family: var(--font-body);
  font-size: 0.86rem;
  font-weight: 700;
}

.sort-select:hover {
  border-color: var(--technical);
  background-color: var(--technical-soft);
  color: var(--fg);
}

.filter-button {
  min-height: 2.75rem;
  padding: 0 var(--space-4);
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--fg);
  cursor: pointer;
  font-size: 0.86rem;
  font-weight: 700;
  transition: background-color 160ms ease, border-color 160ms ease, color 160ms ease;
}

.filter-button:hover {
  border-color: var(--technical);
  background: var(--technical-soft);
  color: var(--fg);
}

.filter-button[aria-pressed='true'] {
  border-color: var(--fg);
  background: var(--fg);
  color: var(--surface);
}

.result-count {
  margin: 0;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.76rem;
  overflow-wrap: anywhere;
}

.demo-notice {
  margin: calc(var(--space-5) * -1) 0 var(--space-5);
  padding: var(--space-4) var(--space-5);
  border: 1px solid oklch(42% 0.07 220 / 0.28);
  border-radius: var(--radius-md);
  background: var(--technical-soft);
  color: var(--fg);
  font-size: 0.92rem;
  scroll-margin-top: 6rem;
  overflow-wrap: anywhere;
}

.project-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-5);
  align-items: stretch;
}

.project-card {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  transition: border-color 180ms ease, box-shadow 180ms ease, transform 180ms ease;
}

.project-card-link,
.project-card-static {
  display: grid;
  grid-template-rows: auto 1fr;
  height: 100%;
  min-width: 0;
  color: inherit;
  text-decoration: none;
}

.project-card--linked:hover,
.project-card--linked:focus-within {
  border-color: oklch(65% 0.04 55);
  box-shadow: var(--shadow-hover);
  transform: translateY(-2px);
}

.project-card-link:focus-visible {
  border-radius: inherit;
  outline: 3px solid var(--technical);
  outline-offset: -4px;
}

.project-cover {
  position: relative;
  min-width: 0;
  border-bottom: 1px solid var(--border);
  background: var(--surface-soft);
}

.project-cover-media {
  position: relative;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: var(--surface-soft);
}

.project-cover-image {
  display: block;
  width: 100%;
  height: 100%;
  background: var(--surface-soft);
  object-fit: cover;
}

.project-cover-fallback {
  background:
    linear-gradient(135deg, transparent 0 48%, oklch(42% 0.07 220 / 0.12) 48% 49%, transparent 49%),
    repeating-linear-gradient(90deg, transparent 0 2rem, oklch(42% 0.07 220 / 0.07) 2rem 2.0625rem),
    var(--technical-soft);
}

.project-cover-fallback-mark {
  position: absolute;
  top: 50%;
  left: 50%;
  width: clamp(4rem, 24%, 7rem);
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
  border: 1px solid oklch(42% 0.07 220 / 0.34);
  border-radius: 50%;
}

.project-cover-fallback-mark::after {
  position: absolute;
  inset: 24%;
  border: 1px solid oklch(42% 0.07 220 / 0.34);
  border-radius: 50%;
  content: '';
}

.project-code {
  position: absolute;
  top: var(--space-3);
  left: var(--space-3);
  z-index: 1;
  padding: 0.3rem 0.55rem;
  border: 1px solid oklch(84% 0.018 72 / 0.88);
  border-radius: 999px;
  background: oklch(99% 0.006 78 / 0.92);
  color: var(--technical);
  box-shadow: 0 0.25rem 0.8rem oklch(28% 0.025 55 / 0.08);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  line-height: 1.2;
}

.project-card-body {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: var(--space-4);
}

.project-name {
  display: -webkit-box;
  margin: var(--space-2) 0 0;
  overflow: hidden;
  font-family: var(--font-display);
  font-size: clamp(1.3rem, 1.8vw, 1.65rem);
  font-weight: 600;
  line-height: 1.2;
  overflow-wrap: anywhere;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
}

.project-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  margin: 0;
  color: var(--technical);
  font-family: var(--font-mono);
  font-size: 0.74rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
  overflow-wrap: anywhere;
}

.period-value-short {
  display: none;
}

.context-copy {
  display: -webkit-box;
  margin: var(--space-3) 0 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.55;
  text-wrap: pretty;
  overflow-wrap: anywhere;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
}

.project-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  margin-top: auto;
  padding-top: var(--space-4);
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin: 0;
  padding: 0;
  list-style: none;
}

.tag {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.75rem;
}

.tag + .tag::before {
  margin-right: var(--space-2);
  color: var(--border);
  content: '/';
}

.detail-cue {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.75rem;
  flex: 0 0 auto;
  gap: var(--space-2);
  padding-inline: var(--space-3);
  border: 1px solid var(--technical);
  border-radius: var(--radius-sm);
  color: var(--technical);
  font-size: 0.86rem;
  font-weight: 700;
  pointer-events: none;
  transition: background-color 160ms ease, border-color 160ms ease, color 160ms ease;
}

.detail-cue-short {
  display: none;
}

.project-card--linked:hover .detail-cue,
.project-card--linked:focus-within .detail-cue {
  border-color: var(--technical);
  background: var(--technical);
  color: var(--surface);
}

.detail-cue--unavailable {
  border-color: var(--border);
  background: var(--surface-soft);
  color: var(--muted);
}

@media (max-width: 71.999rem) {
  .project-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.site-footer {
  border-top: 1px solid var(--border);
}

.footer-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  min-height: 6.5rem;
  gap: var(--space-5);
  color: var(--muted);
  font-size: 0.82rem;
}

.footer-inner p {
  margin: 0;
  overflow-wrap: anywhere;
}

.footer-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-4);
}

.footer-link,
.back-to-top {
  display: inline-flex;
  align-items: center;
  min-height: 2.75rem;
  color: var(--technical);
  font-weight: 700;
  text-underline-offset: 0.25rem;
}

.footer-link:hover,
.back-to-top:hover {
  color: var(--fg);
}

@media (max-width: 64rem) {
  .projects-intro {
    grid-template-columns: minmax(0, 1fr) minmax(16rem, 0.48fr);
    gap: var(--space-7);
  }

  .page-title {
    max-width: 15ch;
    font-size: clamp(2.35rem, 5vw, 3.4rem);
  }

}

@media (max-width: 48rem) {
  html {
    scroll-padding-top: 8.5rem;
  }

  #main-content,
  .demo-notice {
    scroll-margin-top: 8.5rem;
  }

  .shell {
    width: min(calc(100% - 1.5rem), var(--content));
  }

  .header-inner {
    grid-template-columns: minmax(0, 1fr) auto;
    min-height: 4.25rem;
    gap: var(--space-3);
  }

  .brand-copy {
    display: none;
  }

  .site-nav {
    grid-column: 1 / -1;
    grid-row: 2;
    margin-inline: 0;
    padding: 0 0 var(--space-2);
    border-top: 1px solid var(--border);
  }

  .nav-link {
    flex: 1;
    justify-content: center;
  }

  .projects-intro {
    grid-template-columns: 1fr;
    gap: var(--space-7);
    padding-top: var(--space-7);
  }

  .page-title {
    max-width: 12ch;
    font-size: clamp(2.25rem, 8.8vw, 3.25rem);
  }

  .collection-toolbar {
    grid-template-columns: 1fr;
    align-items: start;
  }

  .filter-area {
    justify-items: start;
  }

  .filter-group {
    justify-content: flex-start;
  }

  .controls-row {
    align-items: flex-start;
    justify-content: flex-start;
  }
}

@media (max-width: 47.999rem) {
  .project-list {
    grid-template-columns: 1fr;
    gap: var(--space-3);
  }

  .project-card-link,
  .project-card-static {
    grid-template-columns: 6.75rem minmax(0, 1fr);
    grid-template-rows: auto;
    align-items: stretch;
  }

  .project-cover {
    align-self: stretch;
    min-width: 6.75rem;
    min-height: 6.75rem;
    border-right: 1px solid var(--border);
    border-bottom: 0;
  }

  .project-cover-media {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    min-width: 6.75rem;
    min-height: 6.75rem;
    aspect-ratio: auto;
  }

  .project-cover-fallback-mark {
    width: 3.5rem;
  }

  .project-code {
    top: var(--space-2);
    left: var(--space-2);
    padding: 0.2rem 0.4rem;
    font-size: 0.64rem;
  }

  .project-card-body {
    min-height: 6.75rem;
    padding: var(--space-3);
  }

  .project-meta {
    gap: 0.3rem;
    font-size: 0.68rem;
    line-height: 1.35;
  }

  .period-value--unknown .period-value-long {
    display: none;
  }

  .period-value--unknown .period-value-short {
    display: inline;
  }

  .project-name {
    margin-top: var(--space-1);
    font-size: 1.08rem;
    line-height: 1.25;
  }

  .context-copy {
    margin-top: var(--space-1);
    font-size: 0.8rem;
    line-height: 1.4;
  }

  .project-card-footer {
    justify-content: flex-start;
    margin-top: var(--space-2);
    padding-top: 0;
  }

  .tag-list {
    display: none;
  }

  .detail-cue {
    min-height: 1.75rem;
    justify-content: flex-start;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--technical);
    font-size: 0.76rem;
  }

  .project-card--linked:hover .detail-cue,
  .project-card--linked:focus-within .detail-cue {
    border-color: transparent;
    background: transparent;
    color: var(--fg);
  }

  .detail-cue-long {
    display: none;
  }

  .detail-cue-short {
    display: inline;
  }

  .detail-cue--unavailable {
    color: var(--muted);
  }
}

@media (max-width: 34rem) {
  .collection-section {
    padding-block: var(--space-7);
  }

  .sort-control {
    align-items: flex-start;
    flex-direction: column;
  }

  .footer-inner {
    align-items: flex-start;
    flex-direction: column;
    justify-content: center;
  }

  .footer-actions {
    justify-content: flex-start;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}

@media (forced-colors: active) {
  .language-switcher,
  .filter-button,
  .project-card {
    border: 1px solid CanvasText;
  }
}
