/* 中文打字測評 — 視覺與易用性 */
:root {
  --ty-panel: rgba(255, 255, 255, 0.92);
  --ty-soft: #f3f8fc;
  --ty-ink: var(--ink, #14232f);
  --ty-muted: var(--muted, #5a6b78);
  --ty-line: var(--line, #d5e0ea);
  --ty-sea: var(--sea, #1a6ea8);
  --ty-deep: var(--sea-deep, #0a3048);
  --ty-ok: var(--ok, #2f9e6b);
  --ty-warn: var(--warn, #d97706);
  --ty-danger: var(--danger, #c23b4d);
}

body.ty-body {
  min-height: 100vh;
}

.ty-wrap {
  max-width: 980px;
  margin: 0 auto;
}

.ty-wrap-wide {
  max-width: 1180px;
  margin: 0 auto;
}

/* 英雄區 */
.ty-hero {
  text-align: center;
  margin: 0.5rem 0 1.75rem;
  padding: 0.5rem 0 0.25rem;
}

.ty-hero h1 {
  font-family: var(--font-display);
  color: var(--ty-deep);
  font-size: clamp(1.6rem, 3vw, 2.1rem);
  margin-bottom: 0.4rem;
  letter-spacing: 0.02em;
}

.ty-hero p {
  color: var(--ty-muted);
  max-width: 36rem;
  margin: 0 auto;
  line-height: 1.7;
}

.ty-hero-left {
  text-align: left;
}

.ty-hero-left p {
  margin-left: 0;
}

/* 雙入口卡片 */
.ty-choice-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

@media (max-width: 720px) {
  .ty-choice-grid {
    grid-template-columns: 1fr;
  }
}

.ty-choice {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  text-decoration: none;
  color: inherit;
  background: var(--ty-panel);
  border: 1.5px solid var(--ty-line);
  border-radius: 18px;
  padding: 1.35rem 1.4rem;
  box-shadow: 0 10px 28px rgba(10, 48, 72, 0.06);
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
  min-height: 9.5rem;
}

.ty-choice:hover {
  transform: translateY(-3px);
  box-shadow: 0 16px 36px rgba(10, 48, 72, 0.12);
  border-color: rgba(43, 143, 212, 0.45);
  color: inherit;
}

.ty-choice-primary {
  background: linear-gradient(145deg, #f7fbfe 0%, #e8f4fc 100%);
  border-color: rgba(26, 110, 168, 0.28);
}

.ty-choice-kicker {
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--ty-sea);
  text-transform: uppercase;
}

.ty-choice h2 {
  font-family: var(--font-display);
  font-size: 1.45rem;
  color: var(--ty-deep);
  margin: 0;
}

.ty-choice p {
  color: var(--ty-muted);
  margin: 0;
  flex: 1;
  line-height: 1.55;
  font-size: 0.95rem;
}

.ty-choice-cta {
  font-weight: 700;
  color: var(--ty-sea);
  font-size: 0.95rem;
}

/* 步驟條 */
.ty-steps {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
  margin: 0 0 1.25rem;
  flex-wrap: wrap;
}

.ty-step {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.85rem;
  border-radius: 999px;
  background: #eef3f7;
  color: var(--ty-muted);
  font-size: 0.85rem;
  font-weight: 600;
}

.ty-step.is-active {
  background: rgba(26, 110, 168, 0.14);
  color: var(--ty-deep);
}

.ty-step.is-done {
  background: rgba(47, 158, 107, 0.14);
  color: #1f7a52;
}

.ty-step-num {
  width: 1.35rem;
  height: 1.35rem;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.06);
  font-size: 0.75rem;
}

.ty-step.is-active .ty-step-num {
  background: var(--ty-sea);
  color: #fff;
}

/* 統計 */
.ty-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(108px, 1fr));
  gap: 0.65rem;
  margin-bottom: 1rem;
}

.ty-stats-sticky {
  position: sticky;
  top: 4.25rem;
  z-index: 20;
  background: rgba(238, 243, 247, 0.92);
  backdrop-filter: blur(8px);
  padding: 0.65rem 0;
  margin: -0.5rem 0 1rem;
}

.ty-stat {
  background: #fff;
  border: 1px solid var(--ty-line);
  border-radius: 14px;
  padding: 0.7rem 0.75rem;
  text-align: center;
  box-shadow: 0 4px 12px rgba(10, 48, 72, 0.04);
}

.ty-stat span {
  display: block;
  font-size: 0.75rem;
  color: var(--ty-muted);
  margin-bottom: 0.15rem;
}

.ty-stat strong {
  font-size: 1.2rem;
  color: var(--ty-deep);
  font-variant-numeric: tabular-nums;
}

/* 打字區：文章與輸入同高、同行高／字距／寬度，避免對不齊 */
.ty-type-panel {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  margin-bottom: 0.25rem;
  --ty-type-font-size: 22px;
  --ty-type-line-height: 44px;
  --ty-type-letter-spacing: 0.04em;
  --ty-type-pad-y: 16px;
  --ty-type-pad-x: 18px;
  --ty-type-height: 232px; /* 約 5 行：pad*2 + line*5 */
  --ty-type-font: "Noto Sans TC", "Microsoft JhengHei", "PingFang TC", "Heiti TC", sans-serif;
}

.ty-passage,
.ty-input {
  height: var(--ty-type-height);
  min-height: var(--ty-type-height);
  max-height: var(--ty-type-height);
  font-family: var(--ty-type-font);
  font-size: var(--ty-type-font-size);
  line-height: var(--ty-type-line-height);
  letter-spacing: var(--ty-type-letter-spacing);
  padding: var(--ty-type-pad-y) var(--ty-type-pad-x);
  background: #fff;
  border: 1.5px solid var(--ty-line);
  border-radius: 16px;
  box-sizing: border-box;
  /* 兩區皆常駐捲軸，內容寬度一致，換行才會對齊 */
  overflow-y: scroll;
  overflow-x: hidden;
  word-break: break-all;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
  tab-size: 4;
  -moz-tab-size: 4;
}

.ty-passage {
  margin: 0;
  scroll-behavior: auto;
}

/* 高亮不可改變字寬／行高，否則與 textarea 對不齊 */
.ty-char {
  display: inline;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  vertical-align: baseline;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}

.ty-correct {
  background: rgba(47, 158, 107, 0.18);
  color: #1f7a52;
}

.ty-wrong {
  background: rgba(194, 59, 77, 0.16);
  color: #a12e3d;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.ty-current {
  background: rgba(43, 143, 212, 0.28);
  /* 不用 box-shadow，避免撐高行盒 */
  outline: 2px solid var(--ty-sea);
  outline-offset: -1px;
  animation: tyPulse 1.1s ease-in-out infinite;
}

@keyframes tyPulse {
  0%, 100% { outline-color: var(--ty-sea); }
  50% { outline-color: transparent; }
}

.ty-pending {
  color: var(--ty-ink);
  background: transparent;
}

.ty-input {
  width: 100%;
  resize: none;
  margin: 0;
  color: var(--ty-ink);
  appearance: none;
  -webkit-appearance: none;
  field-sizing: fixed;
}

.ty-input:focus {
  outline: none;
  border-color: var(--sea-bright, #2b8fd4);
  box-shadow: 0 0 0 4px rgba(43, 143, 212, 0.15);
}

.ty-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.ty-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin-top: 1rem;
}

/* 徽章／列表 */
.ty-badge {
  display: inline-block;
  padding: 0.2rem 0.7rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  background: #e8f2fa;
  color: var(--ty-deep);
  vertical-align: middle;
}

.ty-badge-ok { background: #e6f6ee; color: #1f7a52; }
.ty-badge-warn { background: #fff4e5; color: #b45309; }
.ty-badge-danger { background: #fde8ec; color: #a12e3d; }
.ty-badge-muted { background: #eef1f4; color: var(--ty-muted); }

.ty-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.ty-list li,
.ty-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 1rem 0.15rem;
  border-bottom: 1px solid var(--ty-line);
  flex-wrap: wrap;
}

.ty-list li:last-child,
.ty-item:last-child {
  border-bottom: none;
}

.ty-item-card {
  background: var(--ty-soft);
  border: 1px solid var(--ty-line);
  border-radius: 14px;
  padding: 1rem 1.1rem;
  margin-bottom: 0.75rem;
  border-bottom: 1px solid var(--ty-line);
}

.ty-item-card:last-child {
  margin-bottom: 0;
}

.ty-identity {
  font-size: 0.9rem;
  color: var(--ty-muted);
}

.ty-bar {
  height: 10px;
  background: #e8eef4;
  border-radius: 999px;
  overflow: hidden;
  min-width: 80px;
}

.ty-bar > span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--sea-bright, #2b8fd4), var(--ty-sea));
  border-radius: 999px;
}

/* 通行碼 */
.ty-passcode {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 1.75rem;
  letter-spacing: 0.35em;
  font-weight: 700;
  color: var(--ty-deep);
  text-align: center;
}

.ty-passcode-display {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-family: ui-monospace, monospace;
  font-size: 1.25rem;
  letter-spacing: 0.2em;
  font-weight: 700;
  color: var(--ty-deep);
  background: #f4f8fb;
  border: 1px dashed rgba(26, 110, 168, 0.35);
  border-radius: 12px;
  padding: 0.35rem 0.75rem;
}

.ty-copy-btn {
  letter-spacing: 0;
  font-family: var(--font);
  font-size: 0.8rem;
  padding: 0.25rem 0.55rem;
  border-radius: 999px;
  border: 1px solid var(--ty-line);
  background: #fff;
  cursor: pointer;
  color: var(--ty-sea);
  font-weight: 600;
}

.ty-copy-btn:hover {
  background: #eef6fc;
}

/* 導覽 */
.ty-nav-sub {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-bottom: 1.35rem;
  padding: 0.35rem;
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid var(--ty-line);
  border-radius: 999px;
  width: fit-content;
  max-width: 100%;
}

.ty-nav-sub a {
  text-decoration: none;
  font-weight: 600;
  color: var(--ty-sea);
  padding: 0.4rem 0.9rem;
  border-radius: 999px;
  font-size: 0.92rem;
}

.ty-nav-sub a:hover,
.ty-nav-sub a.active {
  background: rgba(26, 110, 168, 0.14);
  color: var(--ty-deep);
}

/* 空狀態 */
.ty-empty {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--ty-muted);
}

.ty-empty strong {
  display: block;
  color: var(--ty-deep);
  font-size: 1.05rem;
  margin-bottom: 0.35rem;
}

/* 教師統計磁貼 */
.ty-stat-tiles {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.85rem;
  margin-bottom: 1.5rem;
}

@media (max-width: 900px) {
  .ty-stat-tiles {
    grid-template-columns: repeat(2, 1fr);
  }
}

.ty-stat-tile {
  display: block;
  text-decoration: none;
  color: inherit;
  background: #fff;
  border: 1px solid var(--ty-line);
  border-radius: 16px;
  padding: 1.1rem 1.15rem;
  box-shadow: 0 8px 22px rgba(10, 48, 72, 0.05);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.ty-stat-tile:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 28px rgba(10, 48, 72, 0.1);
  color: inherit;
}

.ty-stat-tile strong {
  display: block;
  font-family: var(--font-display);
  font-size: 1.85rem;
  color: var(--ty-deep);
  line-height: 1.1;
}

.ty-stat-tile span {
  color: var(--ty-muted);
  font-size: 0.9rem;
}

/* 快速步驟 */
.ty-flow {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.85rem;
  margin: 1rem 0 1.25rem;
}

@media (max-width: 800px) {
  .ty-flow {
    grid-template-columns: 1fr;
  }
}

.ty-flow-step {
  background: var(--ty-soft);
  border: 1px solid var(--ty-line);
  border-radius: 14px;
  padding: 1rem 1.1rem;
}

.ty-flow-step b {
  display: block;
  color: var(--ty-deep);
  margin-bottom: 0.25rem;
}

.ty-flow-step span {
  color: var(--ty-muted);
  font-size: 0.9rem;
  line-height: 1.5;
}

.ty-session-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  background: #f4f8fb;
  border: 1px solid var(--ty-line);
  border-radius: 999px;
  padding: 0.45rem 0.9rem;
  font-size: 0.9rem;
  color: var(--ty-muted);
}

.ty-card-quiet .card-header {
  border-bottom: 1px solid var(--ty-line);
  padding-bottom: 0.75rem;
  margin-bottom: 0.85rem;
}

.ty-hint {
  font-size: 0.88rem;
  color: var(--ty-muted);
  line-height: 1.55;
  margin: 0 0 1rem;
}

.ty-form-stack .form-group:last-of-type {
  margin-bottom: 1.35rem;
}

@media (max-width: 640px) {
  .ty-type-panel {
    --ty-type-font-size: 18px;
    --ty-type-line-height: 36px;
    --ty-type-pad-y: 12px;
    --ty-type-pad-x: 14px;
    --ty-type-height: 192px;
  }
  .ty-passcode {
    font-size: 1.45rem;
    letter-spacing: 0.28em;
  }
  .navbar-menu .navbar-link {
    font-size: 0.85rem;
  }
}
