/* ==========================================================================
   TAYEN Internal Portal — Light Minimalist High-Tech Design System
   Ice-White Canvas · Precision CAD Hairlines · Electric Tech-Blue Accents
   ========================================================================== */

:root {
  /* Surface & Canvas */
  --bg-canvas: #f4f7fb;
  --bg-surface: rgba(255, 255, 255, 0.88);
  --bg-surface-solid: #ffffff;
  --bg-surface-hover: #ffffff;
  --bg-subtle: #edf2f8;

  /* Lines & Borders */
  --border-subtle: #dce5f2;
  --border-strong: #c5d4e8;
  --grid-line: rgba(15, 23, 42, 0.042);

  /* Brand & Tech-Blue Accents */
  --accent-primary: #0066ff;
  --accent-primary-dark: #0052cc;
  --accent-cyan: #0ea5e9;
  --accent-soft: rgba(0, 102, 255, 0.08);
  --accent-ring: rgba(0, 102, 255, 0.24);
  --status-online: #10b981;
  --status-beta: #f59e0b;

  /* Typography Colors */
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;

  /* Typography Families */
  --font-sans: 'Plus Jakarta Sans', 'Noto Sans TC', 'Microsoft JhengHei', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  /* Elevation */
  --shadow-card: 0 2px 6px rgba(15, 23, 42, 0.03), 0 10px 28px -12px rgba(15, 23, 42, 0.08);
  --shadow-card-hover: 0 8px 20px rgba(0, 102, 255, 0.08), 0 22px 44px -16px rgba(15, 23, 42, 0.14);

  /* Geometry & Motion */
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 18px;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --container-max: 1140px;
}

/* Reset & Base */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-sans);
  color: var(--text-primary);
  background-color: var(--bg-canvas);
  line-height: 1.6;
  overflow-x: hidden;
  position: relative;
}

/* ==========================================================================
   Architectural Engineering Grid & Soft Ambient Light
   ========================================================================== */

.bg-grid {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image:
    linear-gradient(to right, var(--grid-line) 1px, transparent 1px),
    linear-gradient(to bottom, var(--grid-line) 1px, transparent 1px);
  background-size: 36px 36px;
  mask-image: radial-gradient(ellipse 85% 75% at 50% 22%, #000 45%, transparent 100%);
  -webkit-mask-image: radial-gradient(ellipse 85% 75% at 50% 22%, #000 45%, transparent 100%);
}

.bg-glow {
  position: fixed;
  z-index: 0;
  pointer-events: none;
  border-radius: 999px;
  filter: blur(72px);
}

.bg-glow--top {
  top: -180px;
  left: 50%;
  transform: translateX(-50%);
  width: 820px;
  height: 360px;
  background: radial-gradient(circle, rgba(14, 165, 233, 0.14) 0%, rgba(0, 102, 255, 0.05) 55%, transparent 75%);
}

.bg-glow--side {
  bottom: -140px;
  right: -120px;
  width: 520px;
  height: 420px;
  background: radial-gradient(circle, rgba(0, 102, 255, 0.08) 0%, transparent 70%);
}

/* Shell & Container */
.page-shell {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.container {
  width: 100%;
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 0 24px;
}

/* ==========================================================================
   Top System Navigation Bar
   ========================================================================== */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(244, 247, 251, 0.8);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid rgba(220, 229, 242, 0.85);
}

.topbar__inner {
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: inherit;
}

.brand__mark {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, #0066ff 0%, #0ea5e9 100%);
  color: #ffffff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(0, 102, 255, 0.24);
  flex-shrink: 0;
}

.brand__mark svg {
  width: 21px;
  height: 21px;
}

.brand__text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.brand__name {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--text-primary);
}

.brand__code {
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-top: 2px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid var(--border-subtle);
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 500;
  color: var(--text-secondary);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.03);
}

.status-pill__dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--status-online);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.18);
  animation: pulse-dot 2.4s ease-in-out infinite;
}

.status-pill__divider {
  width: 1px;
  height: 11px;
  background: var(--border-subtle);
}

.status-pill__count {
  color: var(--accent-primary);
  font-weight: 600;
}

@keyframes pulse-dot {
  0%, 100% {
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.18);
  }
  50% {
    box-shadow: 0 0 0 6px rgba(16, 185, 129, 0.05);
  }
}

/* ==========================================================================
   Compact Hero Banner with Generated Light-Tech Visual
   ========================================================================== */

.hero {
  padding: 18px 0 14px;
}

.hero__frame {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.96) 0%, rgba(244, 248, 253, 0.92) 100%);
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-card);
  padding: 26px 36px;
}

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

.hero__bg-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: right center;
  opacity: 0.92;
  display: block;
}

.hero__visual-mask {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0.96) 0%,
    rgba(255, 255, 255, 0.88) 42%,
    rgba(244, 247, 251, 0.32) 76%,
    rgba(244, 247, 251, 0.12) 100%
  );
}

.hero__content {
  position: relative;
  z-index: 2;
  max-width: 600px;
}

.hero__eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 11px;
  border-radius: 999px;
  background: var(--accent-soft);
  border: 1px solid rgba(0, 102, 255, 0.16);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--accent-primary);
  margin-bottom: 14px;
}

.hero__eyebrow-dot {
  width: 6px;
  height: 6px;
  border-radius: 1px;
  background: var(--accent-primary);
  transform: rotate(45deg);
}

.hero__title {
  margin: 0 0 10px;
  font-size: clamp(26px, 3.2vw, 34px);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
  color: var(--text-primary);
}

.hero__subtitle {
  margin: 0;
  font-size: 15px;
  color: var(--text-secondary);
  line-height: 1.7;
}

/* Precision CAD Corner Ticks */
.cad-tick {
  position: absolute;
  width: 11px;
  height: 11px;
  pointer-events: none;
  z-index: 3;
  transition: border-color 0.25s var(--ease-out), transform 0.25s var(--ease-out);
}

.cad-tick--tl {
  top: 9px;
  left: 9px;
  border-top: 1.5px solid rgba(0, 102, 255, 0.38);
  border-left: 1.5px solid rgba(0, 102, 255, 0.38);
}

.cad-tick--tr {
  top: 9px;
  right: 9px;
  border-top: 1.5px solid rgba(0, 102, 255, 0.38);
  border-right: 1.5px solid rgba(0, 102, 255, 0.38);
}

.cad-tick--bl {
  bottom: 9px;
  left: 9px;
  border-bottom: 1.5px solid rgba(0, 102, 255, 0.38);
  border-left: 1.5px solid rgba(0, 102, 255, 0.38);
}

.cad-tick--br {
  bottom: 9px;
  right: 9px;
  border-bottom: 1.5px solid rgba(0, 102, 255, 0.38);
  border-right: 1.5px solid rgba(0, 102, 255, 0.38);
}

/* ==========================================================================
   Main Tools Directory & Responsive Grid
   ========================================================================== */

.portal-main {
  flex: 1;
  padding: 6px 0 32px;
}

.section-bar {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(220, 229, 242, 0.85);
}

.section-bar__left {
  display: flex;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
}

.section-bar__code {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--accent-primary);
}

.section-bar__title {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: 0.01em;
}

.section-bar__meta {
  font-size: 12.5px;
  color: var(--text-muted);
}

/* Adaptive Tool Grid */
.tools-grid {
  display: grid;
  gap: 24px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.tools-grid--count-1 {
  grid-template-columns: minmax(0, 560px);
  justify-content: center;
}

.tools-grid--count-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.tools-grid--count-many {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

/* ==========================================================================
   Tool Card — Glass Precision Engineering Tile
   ========================================================================== */

.tool-card {
  --mouse-x: 50%;
  --mouse-y: 50%;
  position: relative;
  display: flex;
  flex-direction: column;
  text-decoration: none;
  color: inherit;
  background: var(--bg-surface);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-card);
  transition:
    transform 0.32s var(--ease-out),
    border-color 0.28s var(--ease-out),
    box-shadow 0.32s var(--ease-out),
    background-color 0.28s var(--ease-out);
  animation: card-enter 0.55s var(--ease-out) backwards;
  animation-delay: calc(var(--card-index, 0) * 90ms);
}

/* Subtle interactive cursor highlight */
.tool-card::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  opacity: 0;
  background: radial-gradient(
    420px circle at var(--mouse-x) var(--mouse-y),
    rgba(0, 102, 255, 0.07),
    transparent 60%
  );
  transition: opacity 0.3s ease;
}

.tool-card:hover {
  transform: translateY(-4px);
  border-color: rgba(0, 102, 255, 0.45);
  background: var(--bg-surface-hover);
  box-shadow: var(--shadow-card-hover);
}

.tool-card:hover::before {
  opacity: 1;
}

.tool-card:focus-visible {
  outline: 2px solid var(--accent-primary);
  outline-offset: 3px;
  border-color: var(--accent-primary);
}

.tool-card .cad-tick {
  border-color: rgba(148, 163, 184, 0.45);
}

.tool-card:hover .cad-tick {
  border-color: var(--accent-primary);
}

.tool-card:hover .cad-tick--tl { transform: translate(-2px, -2px); }
.tool-card:hover .cad-tick--tr { transform: translate(2px, -2px); }
.tool-card:hover .cad-tick--bl { transform: translate(-2px, 2px); }
.tool-card:hover .cad-tick--br { transform: translate(2px, 2px); }

/* Media Frame (16:9 Generated Visual Showcase) */
.tool-card__media {
  position: relative;
  aspect-ratio: 16 / 9;
  background: linear-gradient(145deg, #eef4fc 0%, #f8fafd 100%);
  border-bottom: 1px solid var(--border-subtle);
  overflow: hidden;
}

.tool-card__media.is-fallback {
  background-image:
    linear-gradient(to right, rgba(0, 102, 255, 0.08) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(0, 102, 255, 0.08) 1px, transparent 1px),
    linear-gradient(135deg, #eaf2ff 0%, #f6f9fd 100%);
  background-size: 24px 24px, 24px 24px, 100% 100%;
}

.tool-card__img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.6s var(--ease-out);
}

.tool-card:hover .tool-card__img {
  transform: scale(1.035);
}

.tool-card__media-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(
    180deg,
    rgba(244, 247, 251, 0.16) 0%,
    transparent 35%,
    transparent 72%,
    rgba(255, 255, 255, 0.28) 100%
  );
}

/* Floating Code & Category Badges on Media */
.tool-card__badges {
  position: absolute;
  top: 14px;
  left: 14px;
  right: 14px;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  pointer-events: none;
}

.badge-code,
.badge-category {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  font-size: 11px;
  font-weight: 600;
}

.badge-code {
  font-family: var(--font-mono);
  letter-spacing: 0.06em;
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.86);
  border: 1px solid rgba(203, 213, 225, 0.85);
}

.badge-code__dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--status-online);
}

.badge-code__dot--beta {
  background: var(--status-beta);
}

.badge-category {
  color: var(--accent-primary);
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid rgba(0, 102, 255, 0.22);
}

/* Card Content Body */
.tool-card__body {
  position: relative;
  z-index: 2;
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 18px 22px 15px;
}

.tool-card__header {
  margin-bottom: 8px;
}

.tool-card__title {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  line-height: 1.3;
  color: var(--text-primary);
  letter-spacing: -0.01em;
  transition: color 0.2s ease;
}

.tool-card:hover .tool-card__title {
  color: var(--accent-primary);
}

.tool-card__subtitle {
  margin: 3px 0 0;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}

.tool-card__desc {
  margin: 0 0 13px;
  font-size: 14px;
  line-height: 1.65;
  color: var(--text-secondary);
}

.tool-card__tags {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: auto;
  list-style: none;
  padding: 0;
  margin-bottom: 0;
}

.tool-card__tag {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--bg-subtle);
  border: 1px solid rgba(203, 213, 225, 0.7);
  padding: 3px 10px;
  border-radius: 6px;
  transition: border-color 0.2s ease, color 0.2s ease, background-color 0.2s ease;
}

.tool-card:hover .tool-card__tag {
  background: rgba(0, 102, 255, 0.06);
  border-color: rgba(0, 102, 255, 0.2);
  color: var(--accent-primary-dark);
}

/* Card Footer Action Bar */
.tool-card__footer {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 24px;
  border-top: 1px solid rgba(220, 229, 242, 0.85);
  background: rgba(248, 250, 253, 0.72);
}

.tool-card__host {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tool-card__host svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  color: var(--accent-cyan);
}

.tool-card__cta {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 9px;
  background: var(--accent-soft);
  color: var(--accent-primary);
  font-size: 13px;
  font-weight: 600;
  flex-shrink: 0;
  transition: background-color 0.24s var(--ease-out), color 0.24s var(--ease-out), transform 0.24s var(--ease-out);
}

.tool-card__cta svg {
  width: 15px;
  height: 15px;
  transition: transform 0.24s var(--ease-out);
}

.tool-card:hover .tool-card__cta {
  background: var(--accent-primary);
  color: #ffffff;
}

.tool-card:hover .tool-card__cta svg {
  transform: translate(2px, -2px);
}

/* ==========================================================================
   Footer & Noscript Notice
   ========================================================================== */

.portal-footer {
  border-top: 1px solid rgba(220, 229, 242, 0.85);
  background: rgba(255, 255, 255, 0.55);
  padding: 18px 0;
}

.portal-footer__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.portal-footer__copy,
.portal-footer__meta {
  margin: 0;
  font-size: 12.5px;
  color: var(--text-muted);
}

.portal-footer__en {
  margin-left: 6px;
  opacity: 0.85;
}

.portal-footer__meta {
  font-family: var(--font-mono);
  font-size: 11.5px;
  letter-spacing: 0.04em;
}

.noscript-notice {
  padding: 20px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background: #ffffff;
  color: var(--text-secondary);
  text-align: center;
}

/* ==========================================================================
   Animations & Responsive Breakpoints
   ========================================================================== */

@keyframes card-enter {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 1080px) {
  .tools-grid--count-many {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 820px) {
  .hero__frame {
    padding: 28px 24px;
  }

  .hero__visual-mask {
    background: linear-gradient(
      90deg,
      rgba(255, 255, 255, 0.96) 0%,
      rgba(255, 255, 255, 0.86) 62%,
      rgba(244, 247, 251, 0.55) 100%
    );
  }

  .tools-grid,
  .tools-grid--count-2,
  .tools-grid--count-many {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 560px) {
  .container {
    padding: 0 16px;
  }

  .topbar__inner {
    height: 58px;
  }

  .status-pill__label,
  .status-pill__divider {
    display: none;
  }

  .hero {
    padding: 16px 0 14px;
  }

  .hero__frame {
    padding: 22px 18px;
  }

  .hero__subtitle {
    font-size: 14px;
  }

  .section-bar {
    flex-direction: column;
    gap: 4px;
  }

  .tool-card__body {
    padding: 16px 16px 13px;
  }

  .tool-card__footer {
    padding: 11px 14px;
    gap: 8px;
  }

  .tool-card__host {
    font-size: 11px;
    gap: 5px;
  }

  .tool-card__cta {
    padding: 6px 10px;
    font-size: 12px;
    gap: 4px;
  }

  .portal-footer__en {
    display: block;
    margin-left: 0;
    margin-top: 2px;
  }
}

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