/* public/css/base.css - 設計系統 Tokens、基礎樣式、背景網格、45° 切角框架、按鈕表單與共用 Modal */
/* 純黑背景 + 參考圖螢光青藍線框 HUD + 原版 NTU COOL 三欄排版 */

:root {
  --bg-black: #000000;
  --box-bg: rgba(0, 245, 255, 0.025);
  --box-bg-strong: rgba(0, 12, 18, 0.94);

  --cyan: #00f5ff;
  --cyan-bright: #dffcff;
  --cyan-line: rgba(0, 245, 255, 0.44);
  --cyan-hair: rgba(0, 245, 255, 0.17);
  --cyan-glow: 0 0 14px rgba(0, 245, 255, 0.25);

  --amber: #ffb020;
  --amber-line: rgba(255, 176, 32, 0.48);
  --red: #ff3b5c;
  --red-line: rgba(255, 59, 92, 0.5);
  --green: #00ff9d;
  --green-line: rgba(0, 255, 157, 0.45);

  --text-main: #e8fcff;
  --text-sub: #82d7ea;
  --text-dim: #4a93a8;

  --font-display: "Orbitron", "Noto Sans TC", sans-serif;
  --font-mono: "JetBrains Mono", monospace;
  --font-sans: "Noto Sans TC", system-ui, -apple-system, sans-serif;
}

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

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg-black);
  color: var(--text-main);
  font-family: var(--font-sans);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

[hidden] {
  display: none !important;
}

.mono {
  font-family: var(--font-mono);
}

.accent {
  color: var(--cyan);
  text-shadow: 0 0 10px rgba(0, 245, 255, 0.65);
}

/* =========================================================
   純黑背景與微弱技術網格、掃描線（完全不擋點擊）
   ========================================================= */
.hud-bg-grid {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(0, 245, 255, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 245, 255, 0.03) 1px, transparent 1px);
  background-size: 48px 48px;
}

.hud-scanlines {
  position: fixed;
  inset: 0;
  z-index: 90;
  pointer-events: none;
  background: repeating-linear-gradient(
    to bottom,
    rgba(0, 245, 255, 0.015) 0px,
    rgba(0, 245, 255, 0.015) 1px,
    transparent 1px,
    transparent 4px
  );
  opacity: 0.45;
}

/* =========================================================
   參考圖風格：純黑通透 45° 多邊形切角線框與發光斜邊
   注意：採用 background-image 繪製斜邊，使其鎖定在容器可視邊框盒，
   即使套用在 overflow-y: auto 捲動容器上也不會隨內容飄移。
   所有繼承 .hud-box 的子類別須使用 background-color，避免覆寫漸層斜邊。
   ========================================================= */
.hud-box {
  position: relative;
  --box-edge: var(--cyan);
  background-color: var(--box-bg);
  background-image:
    linear-gradient(135deg, transparent 7.6px, var(--box-edge) 7.6px, var(--box-edge) 9.6px, transparent 9.6px),
    linear-gradient(-45deg, transparent 7.6px, var(--box-edge) 7.6px, var(--box-edge) 9.6px, transparent 9.6px);
  background-position: top left, bottom right;
  background-size: 18px 18px;
  background-repeat: no-repeat;
  background-attachment: scroll;
  clip-path: polygon(
    12px 0,
    100% 0,
    100% calc(100% - 12px),
    calc(100% - 12px) 100%,
    0 100%,
    0 12px
  );
  box-shadow:
    inset 0 0 0 1px var(--cyan-line),
    inset 0 0 22px rgba(0, 245, 255, 0.04);
}

.hud-header-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-bottom: 8px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--cyan-line);
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  color: var(--cyan);
  position: relative;
}

.hud-header-line::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: -1px;
  width: 34px;
  height: 2px;
  background: var(--cyan);
  box-shadow: 0 0 8px var(--cyan);
}

.line-node {
  width: 7px;
  height: 7px;
  background: var(--cyan);
  box-shadow: 0 0 8px var(--cyan);
  flex-shrink: 0;
}

.count-pill {
  padding: 1px 8px;
  border: 1px solid var(--cyan-line);
  background: rgba(0, 245, 255, 0.1);
  color: var(--cyan-bright);
  font-size: 0.72rem;
  font-weight: 700;
}

/* =========================================================
   按鈕與表單控制項
   ========================================================= */
.hud-btn {
  --btn-edge: var(--cyan-line);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 15px;
  border: 0;
  clip-path: polygon(
    7px 0,
    100% 0,
    100% calc(100% - 7px),
    calc(100% - 7px) 100%,
    0 100%,
    0 7px
  );
  background-color: transparent;
  background-image:
    linear-gradient(135deg, transparent 4.2px, var(--btn-edge) 4.2px, var(--btn-edge) 5.8px, transparent 5.8px),
    linear-gradient(-45deg, transparent 4.2px, var(--btn-edge) 4.2px, var(--btn-edge) 5.8px, transparent 5.8px);
  background-position: top left, bottom right;
  background-size: 12px 12px;
  background-repeat: no-repeat;
  font-family: var(--font-sans);
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-main);
  cursor: pointer;
  text-decoration: none;
  transition: background-color 0.15s ease, box-shadow 0.15s ease, color 0.15s ease;
}

.hud-btn-sm {
  padding: 5px 11px;
  font-size: 0.76rem;
}

.hud-btn-primary {
  --btn-edge: var(--cyan);
  background-color: rgba(0, 245, 255, 0.18);
  box-shadow: inset 0 0 0 1px var(--cyan), var(--cyan-glow);
  color: #ffffff;
}
.hud-btn-primary:hover {
  --btn-edge: var(--cyan-bright);
  background-color: rgba(0, 245, 255, 0.3);
  box-shadow: inset 0 0 0 1px var(--cyan-bright), 0 0 20px rgba(0, 245, 255, 0.45);
}

.hud-btn-outline {
  --btn-edge: var(--cyan-line);
  background-color: rgba(0, 245, 255, 0.06);
  box-shadow: inset 0 0 0 1px var(--cyan-line);
  color: var(--cyan-bright);
}
.hud-btn-outline:hover {
  --btn-edge: var(--cyan);
  background-color: rgba(0, 245, 255, 0.18);
  box-shadow: inset 0 0 0 1px var(--cyan);
}

.hud-btn-ghost {
  --btn-edge: var(--cyan-hair);
  background-color: rgba(0, 245, 255, 0.02);
  box-shadow: inset 0 0 0 1px var(--cyan-hair);
  color: var(--text-sub);
}
.hud-btn-ghost:hover,
.hud-btn-ghost[aria-pressed="true"] {
  --btn-edge: var(--cyan);
  background-color: rgba(0, 245, 255, 0.14);
  box-shadow: inset 0 0 0 1px var(--cyan);
  color: var(--cyan-bright);
}

.kbd {
  padding: 1px 6px;
  border: 1px solid var(--cyan-line);
  background: rgba(0, 245, 255, 0.08);
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--cyan);
}

.hud-input, .hud-select {
  background: #000000;
  border: 1px solid var(--cyan-line);
  color: var(--text-main);
  padding: 6px 10px;
  font-family: var(--font-sans);
  font-size: 0.82rem;
  outline: none;
}

.hud-input:focus, .hud-select:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 12px rgba(0, 245, 255, 0.25);
}

.hud-input::placeholder {
  color: var(--text-dim);
}

/* =========================================================
   Modals (公告閱讀 / 檔案預覽 / 代理視窗 / Cmd+K / 撰寫訊息)
   包含半透明背景、展開收合幾何、霓虹閃爍、全息掃描與線型動態描框
   ========================================================= */
.hud-modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 20px;
}

.hud-modal.is-closing {
  pointer-events: none;
}

#modal-content-reader {
  z-index: 85;
}

.hud-modal-backdrop {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at center, rgba(0, 14, 22, 0.34) 0%, rgba(0, 5, 10, 0.56) 100%);
  backdrop-filter: blur(2.5px);
  opacity: 0;
  transition: opacity 0.24s ease;
}

.hud-modal.is-opening .hud-modal-backdrop,
.hud-modal.is-open .hud-modal-backdrop {
  opacity: 1;
}

.hud-modal.is-closing .hud-modal-backdrop {
  opacity: 0;
  transition-duration: 0.22s;
}

.hud-modal-dialog {
  position: relative;
  z-index: 1;
  background-color: rgba(0, 10, 16, 0.90);
  backdrop-filter: blur(10px);
  display: flex;
  flex-direction: column;
  max-height: 90vh;
  width: 100%;
  overflow: hidden;
  transform-origin: center center;
}

/* 全息掃描光束 */
.hud-modal-dialog::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 19;
  pointer-events: none;
  opacity: 0;
  background: linear-gradient(
    to bottom,
    transparent 0%,
    rgba(0, 245, 255, 0.06) 36%,
    rgba(0, 245, 255, 0.32) 47%,
    rgba(223, 252, 255, 0.78) 50%,
    rgba(0, 245, 255, 0.32) 53%,
    rgba(0, 245, 255, 0.06) 64%,
    transparent 100%
  );
  transform: translateY(-100%);
}

/* 45° 切角雙向線型動態描框 SVG */
.hud-modal-trace {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 20;
  pointer-events: none;
  overflow: visible;
}

.hud-modal-trace path {
  fill: none;
  stroke-dasharray: 100;
  stroke-dashoffset: 100;
  stroke-linecap: square;
  opacity: 0;
}

.hud-modal-trace .trace-glow {
  stroke: var(--cyan);
  stroke-width: 4;
}

.hud-modal-trace .trace-core {
  stroke: var(--cyan-bright);
  stroke-width: 1.7;
}

/* 開啟動畫：展開 + 霓虹閃爍 + 掃描光束 + 線型描框 */
.hud-modal.is-opening .hud-modal-dialog {
  animation: hudModalDeploy 0.46s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.hud-modal.is-opening .hud-modal-dialog::before {
  animation: hudModalScanOpen 0.42s ease-out forwards;
}

.hud-modal.is-opening .hud-modal-trace path {
  animation: hudTraceDraw 0.48s cubic-bezier(0.2, 0.85, 0.25, 1) forwards;
}

.hud-modal.is-opening .hud-modal-dialog > :not(.hud-modal-trace) {
  animation: hudModalContentIn 0.32s ease-out 0.1s both;
}

/* 常駐開啟狀態：確保無殘留濾鏡與描框不擋視線 */
.hud-modal.is-open .hud-modal-trace {
  opacity: 0;
}

/* 關閉動畫：霓虹斷電閃爍 + 回抽描框 + 縱橫收束光線 */
.hud-modal.is-closing .hud-modal-dialog {
  animation: hudModalCollapse 0.29s cubic-bezier(0.55, 0, 0.75, 0.2) forwards;
}

.hud-modal.is-closing .hud-modal-dialog::before {
  animation: hudModalScanClose 0.25s ease-in forwards;
}

.hud-modal.is-closing .hud-modal-trace path {
  animation: hudTraceRetract 0.26s ease-in forwards;
}

.hud-modal.is-closing .hud-modal-dialog > :not(.hud-modal-trace) {
  animation: hudModalContentOut 0.13s ease-in forwards;
}

/* Cmd+K 快捷搜尋面板維持更俐落的開關節奏 */
.hud-modal.is-opening .hud-modal-dialog.modal-cmd {
  animation-duration: 0.32s;
}
.hud-modal.is-opening .hud-modal-dialog.modal-cmd::before {
  animation-duration: 0.3s;
}
.hud-modal.is-opening .hud-modal-dialog.modal-cmd .hud-modal-trace path {
  animation-duration: 0.34s;
}
.hud-modal.is-opening .hud-modal-dialog.modal-cmd > :not(.hud-modal-trace) {
  animation-duration: 0.22s;
  animation-delay: 0.06s;
}

.hud-modal.is-closing .hud-modal-dialog.modal-cmd {
  animation-duration: 0.21s;
}
.hud-modal.is-closing .hud-modal-dialog.modal-cmd::before {
  animation-duration: 0.19s;
}
.hud-modal.is-closing .hud-modal-dialog.modal-cmd .hud-modal-trace path {
  animation-duration: 0.2s;
}
.hud-modal.is-closing .hud-modal-dialog.modal-cmd > :not(.hud-modal-trace) {
  animation-duration: 0.1s;
}

@keyframes hudModalDeploy {
  0% {
    opacity: 0;
    transform: scaleX(0.76) scaleY(0.05);
    filter: brightness(2.2) drop-shadow(0 0 26px rgba(0, 245, 255, 0.95));
  }
  18% {
    opacity: 1;
    transform: scaleX(1.016) scaleY(0.12);
    filter: brightness(1.9) drop-shadow(0 0 22px rgba(0, 245, 255, 0.85));
  }
  42% {
    opacity: 1;
    transform: scaleX(1) scaleY(1.012);
    filter: brightness(1.35) drop-shadow(0 0 18px rgba(0, 245, 255, 0.65));
  }
  52% {
    opacity: 0.72;
    transform: scaleX(1) scaleY(1);
    filter: brightness(1.8) drop-shadow(0 0 24px rgba(0, 245, 255, 0.92));
  }
  60% {
    opacity: 1;
    filter: brightness(1.15) drop-shadow(0 0 14px rgba(0, 245, 255, 0.5));
  }
  68% {
    opacity: 0.86;
    filter: brightness(1.5) drop-shadow(0 0 18px rgba(0, 245, 255, 0.72));
  }
  100% {
    opacity: 1;
    transform: none;
    filter: none;
  }
}

@keyframes hudModalCollapse {
  0% {
    opacity: 1;
    transform: scaleX(1) scaleY(1);
    filter: brightness(1.1) drop-shadow(0 0 14px rgba(0, 245, 255, 0.55));
  }
  20% {
    opacity: 0.68;
    transform: scaleX(1.01) scaleY(0.98);
    filter: brightness(1.9) drop-shadow(0 0 22px rgba(0, 245, 255, 0.9));
  }
  58% {
    opacity: 0.96;
    transform: scaleX(1.03) scaleY(0.035);
    filter: brightness(2.5) drop-shadow(0 0 26px rgba(0, 245, 255, 1));
  }
  100% {
    opacity: 0;
    transform: scaleX(0.22) scaleY(0.008);
    filter: brightness(2.6) drop-shadow(0 0 12px rgba(0, 245, 255, 0.8));
  }
}

@keyframes hudModalScanOpen {
  0% {
    opacity: 0;
    transform: translateY(-90%);
  }
  20% {
    opacity: 0.88;
  }
  75% {
    opacity: 0.55;
  }
  100% {
    opacity: 0;
    transform: translateY(95%);
  }
}

@keyframes hudModalScanClose {
  0% {
    opacity: 0;
    transform: translateY(70%);
  }
  35% {
    opacity: 0.85;
  }
  100% {
    opacity: 0;
    transform: translateY(0%);
  }
}

@keyframes hudTraceDraw {
  0% {
    opacity: 1;
    stroke-dashoffset: 100;
  }
  55% {
    opacity: 1;
    stroke-dashoffset: 14;
  }
  70% {
    opacity: 0.45;
    stroke-dashoffset: 4;
  }
  82% {
    opacity: 1;
    stroke-dashoffset: 0;
  }
  100% {
    opacity: 0;
    stroke-dashoffset: 0;
  }
}

@keyframes hudTraceRetract {
  0% {
    opacity: 0.9;
    stroke-dashoffset: 0;
  }
  25% {
    opacity: 0.5;
    stroke-dashoffset: 12;
  }
  45% {
    opacity: 1;
    stroke-dashoffset: 35;
  }
  100% {
    opacity: 0;
    stroke-dashoffset: 100;
  }
}

@keyframes hudModalContentIn {
  0% {
    opacity: 0;
    transform: translateY(6px);
  }
  55% {
    opacity: 0.78;
  }
  72% {
    opacity: 0.96;
  }
  100% {
    opacity: 1;
    transform: none;
  }
}

@keyframes hudModalContentOut {
  0% {
    opacity: 1;
  }
  100% {
    opacity: 0;
  }
}

.modal-md { max-width: 720px; }
.modal-xl { max-width: 1220px; height: 86vh; }
.modal-cmd { max-width: 640px; align-self: start; margin-top: 8vh; }

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--cyan-hair);
}

.modal-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.modal-title {
  margin: 4px 0 4px;
  font-size: 1.06rem;
}

.modal-meta {
  font-size: 0.74rem;
  color: var(--text-sub);
}

.modal-body {
  padding: 18px 20px;
  overflow-y: auto;
  font-size: 0.92rem;
  color: var(--text-main);
}

.rich-html {
  line-height: 1.72;
  color: var(--text-main);
  word-break: break-word;
  min-width: 0;
}
.rich-html > :first-child { margin-top: 0; }
.rich-html > :last-child { margin-bottom: 0; }
.rich-html h1,
.rich-html h2,
.rich-html h3,
.rich-html h4 {
  color: var(--cyan-bright);
  font-weight: 700;
  line-height: 1.38;
  margin: 1.05em 0 0.45em;
}
.rich-html h1,
.rich-html h2 {
  padding-bottom: 5px;
  border-bottom: 1px solid var(--cyan-hair);
}
.rich-html p { margin: 0.45em 0; }
.rich-html ul,
.rich-html ol {
  margin: 0.5em 0;
  padding-left: 1.45em;
}
.rich-html li { margin: 0.25em 0; }
.rich-html li::marker { color: var(--cyan); }
.rich-html strong,
.rich-html b {
  color: var(--cyan-bright);
  font-weight: 700;
}
.rich-html blockquote {
  margin: 0.75em 0;
  padding: 8px 14px;
  border-left: 2px solid var(--cyan);
  background: rgba(0, 245, 255, 0.04);
  color: var(--text-sub);
}
.rich-html hr {
  border: 0;
  border-top: 1px solid var(--cyan-hair);
  margin: 14px 0;
}
.rich-html code,
.rich-html pre {
  font-family: var(--font-mono);
  font-size: 0.84em;
  background: rgba(0, 245, 255, 0.06);
  border: 1px solid var(--cyan-hair);
}
.rich-html code { padding: 1px 5px; }
.rich-html pre {
  padding: 10px 12px;
  overflow-x: auto;
  margin: 10px 0;
}
.rich-html pre code {
  background: transparent;
  border: 0;
  padding: 0;
}
.rich-html a {
  color: var(--cyan);
  text-decoration: underline;
  text-underline-offset: 3px;
}
.rich-html a:hover { color: var(--cyan-bright); }
.rich-html img {
  max-width: 100%;
  height: auto;
  border: 1px solid var(--cyan-hair);
}
.rich-table-wrap {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 10px 0;
  border: 1px solid var(--cyan-hair);
  background: rgba(0, 14, 22, 0.45);
}
.rich-html table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.86rem;
  min-width: 320px;
}
.rich-html th,
.rich-html td {
  padding: 8px 10px;
  border: 1px solid var(--cyan-hair);
  text-align: left;
  vertical-align: top;
}
.rich-html th {
  background: rgba(0, 245, 255, 0.09);
  color: var(--cyan-bright);
  font-weight: 700;
}
.rich-html tr:nth-child(even) td {
  background: rgba(0, 245, 255, 0.02);
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 12px 20px;
  border-top: 1px solid var(--cyan-hair);
}

.proxy-iframe-wrap {
  flex: 1;
  background: #ffffff;
}

.cmd-input-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--cyan-line);
}

.cmd-prefix {
  color: var(--cyan);
  font-weight: 700;
}

.cmd-input {
  flex: 1;
  background: transparent;
  border: 0;
  outline: none;
  color: var(--text-main);
  font-size: 0.95rem;
  font-family: var(--font-sans);
}

.cmd-results {
  max-height: 380px;
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.cmd-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid transparent;
  cursor: pointer;
}

.cmd-item:hover,
.cmd-item.active {
  background: rgba(0, 245, 255, 0.14);
  border-color: var(--cyan-line);
}

.cmd-item-title {
  font-size: 0.88rem;
  font-weight: 500;
}

.cmd-item-sub {
  font-size: 0.74rem;
  color: var(--text-sub);
}

