/* SL3 勞工權益試算工具 · 繁體中文字體落地與精緻明亮配色 (SL3-ZH-TYPOGRAPHY-20261019) */

/* 1. 網路字型子集宣告 (Webfont Subsets) */
@font-face {
  font-family: "Inter Web";
  src: url("./webfonts/Inter-Subset.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0020-007E, U+00A0-00FF, U+2000-206F;
}

@font-face {
  font-family: "Noto Sans TC Web";
  src: url("./webfonts/NotoSansTC-Subset.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

/* 2. 根層級變數與基礎排版設定 */
:root {
  /* 優先採用 Noto Sans TC Web 與 Inter，無縫銜接本機繁中系統黑體 */
  font-family: "Inter Web", "Noto Sans TC Web", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang TC", "Microsoft JhengHei UI", "Microsoft JhengHei", "Noto Sans TC", sans-serif;
  color: #0f172a;
  background: #f7f5fc;
  font-size: 18px;
  line-height: 1.68;
  letter-spacing: 0.01em;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;

  /* 主題色彩調色盤 (Bright Modern Editorial Palette) */
  --bg-page: #f7f5fc;
  --bg-card: #ffffff;
  --text-main: #0f172a;
  --text-muted: #475569;
  --text-light: #64748b;
  --border-card: #cbd5e1;
  --border-focus: #2563eb;
  --primary-blue: #1d4ed8;
  --primary-blue-hover: #1e40af;
  --accent-teal: #0f766e;
  --badge-bg: #eff6ff;
  --badge-text: #1d4ed8;
  --badge-border: #bfdbfe;
  --aside-bg: #f3effc;
  --aside-border: #ddd3ef;
  --aside-stripe: #8b74b5;
  --aside-text: #49365f;
  --formula-bg: #eff6ff;
  --formula-border: #2563eb;
  --formula-text: #1e3a8a;
  --result-bg: #f0fdf4;
  --result-border: #86efac;
  --result-stripe: #16a34a;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg-page); color: var(--text-main); }

main {
  max-width: 920px;
  margin: 0 auto;
  padding: 40px 20px;
}

/* 3. 頁首與標題系統 */
header {
  padding: 16px 0 28px;
  border-bottom: 3px solid var(--accent-teal);
}

.eyebrow {
  letter-spacing: 0.14em;
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--primary-blue);
  margin: 0 0 8px 0;
  text-transform: uppercase;
}

h1 {
  font-size: clamp(1.85rem, 4.5vw, 2.6rem);
  line-height: 1.28;
  color: #0f172a;
  margin: 8px 0 10px 0;
  font-weight: 800;
  letter-spacing: -0.015em;
  overflow-wrap: break-word;
}

header p {
  color: var(--text-muted);
  font-size: 1.05rem;
  margin: 6px 0 14px 0;
}

h2 {
  font-size: 1.3rem;
  line-height: 1.4;
  color: #0f172a;
  margin-top: 0;
  margin-bottom: 16px;
  font-weight: 700;
  overflow-wrap: break-word;
  border-bottom: 1px solid #e2e8f0;
  padding-bottom: 8px;
}

.badge {
  display: inline-block;
  background: var(--badge-bg);
  color: var(--badge-text);
  border: 1px solid var(--badge-border);
  border-radius: 6px;
  padding: 5px 14px;
  font-size: 0.88rem;
  font-weight: 600;
  line-height: 1.5;
  overflow-wrap: break-word;
}

/* 4. 卡片區塊與導引 */
section, aside {
  margin: 28px 0;
  padding: 26px 28px;
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: 12px;
  box-shadow: 0 1px 3px 0 rgba(15, 23, 42, 0.06), 0 1px 2px -1px rgba(15, 23, 42, 0.06);
  overflow-wrap: break-word;
}

aside {
  background: var(--aside-bg);
  border: 1px solid var(--aside-border);
  border-left: 5px solid var(--aside-stripe);
  color: var(--aside-text);
}

aside h2 {
  color: #713f12;
  border-bottom-color: #fef08a;
}

/* 5. 表單結構與輸入控制項 (Step 1, Step 2, Step 3) */
.form-group {
  border: 1.5px solid var(--border-card);
  border-radius: 10px;
  margin: 22px 0;
  padding: 20px 22px;
  background: #ffffff;
  min-width: 0;
}

.form-group legend {
  font-weight: 700;
  padding: 4px 14px;
  color: #1e293b;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  font-size: 1.02rem;
  line-height: 1.5;
}

label {
  display: block;
  margin: 14px 0 8px 0;
  font-weight: 600;
  color: var(--text-main);
  font-size: 0.95rem;
  line-height: 1.5;
  overflow-wrap: break-word;
}

input, select {
  display: block;
  width: 100%;
  min-width: 0;
  min-height: 48px;
  font: inherit;
  font-size: 1rem;
  padding: 10px 14px;
  border: 1.5px solid #cbd5e1;
  border-radius: 8px;
  background: #ffffff;
  color: #0f172a;
  margin-top: 6px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input:focus-visible, select:focus-visible {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.2);
}

small {
  font-weight: 400;
  color: var(--text-light);
  font-size: 0.88rem;
  line-height: 1.5;
}

.form-actions {
  margin: 26px 0 16px 0;
}

.button-row {
  margin-top: 18px;
}

/* 6. 按鈕系統 */
button {
  font: inherit;
  font-weight: 700;
  background: var(--primary-blue);
  color: #ffffff;
  border: 0;
  border-radius: 8px;
  padding: 13px 26px;
  cursor: pointer;
  min-height: 48px;
  box-shadow: 0 2px 4px 0 rgba(37, 99, 235, 0.2);
  transition: background-color 0.15s ease, transform 0.05s ease;
}

button:hover:not(:disabled) {
  background: var(--primary-blue-hover);
}

button:active:not(:disabled) {
  transform: translateY(1px);
}

button:focus-visible {
  outline: 3px solid #60a5fa;
  outline-offset: 2px;
}

button:disabled {
  background: #e2e8f0;
  color: #94a3b8;
  cursor: not-allowed;
  box-shadow: none;
}

#export-result {
  margin-top: 12px;
  background: #ffffff;
  color: var(--primary-blue);
  border: 2px solid var(--primary-blue);
  box-shadow: none;
}

#export-result:hover:not(:disabled) {
  background: #eff6ff;
}

/* 7. 公式呈現盒與計算結果 */
.formula {
  border-left: 4px solid var(--formula-border);
  color: var(--formula-text);
  background: var(--formula-bg);
  padding: 14px 18px;
  border-radius: 0 8px 8px 0;
  margin: 14px 0 0 0;
  overflow-wrap: break-word;
  line-height: 1.68;
}

output {
  display: block;
  white-space: pre-wrap;
  padding: 22px 24px;
  margin-top: 20px;
  background: var(--result-bg);
  border: 1.5px solid var(--result-border);
  border-left: 5px solid var(--result-stripe);
  border-radius: 8px;
  overflow-wrap: anywhere;
  word-break: break-word;
  color: #0f172a;
  font-size: 1.02rem;
  line-height: 1.7;
}

.result-group {
  background: #f8fafc;
  border: 1px solid #cbd5e1;
}

.help-text {
  font-size: 0.88rem;
  color: var(--text-light);
  margin-top: 12px;
  line-height: 1.6;
  overflow-wrap: break-word;
}

.grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

/* 8. 數字等寬對齊規範 (Tabular Numerals) */
.formula, table, output, code, input[inputmode="numeric"], input[type="number"], .badge, #coverage-count {
  font-variant-numeric: tabular-nums lining-nums;
}

/* 9. 表格排版與橫向捲動容器 */
.table-scroll {
  overflow: auto;
  border: 1.5px solid #cbd5e1;
  border-radius: 8px;
  -webkit-overflow-scrolling: touch;
  background: #ffffff;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.94rem;
  line-height: 1.6;
}

th, td {
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid #e2e8f0;
  padding: 13px 16px;
  min-width: 120px;
}

th {
  background: #1e293b;
  color: #ffffff;
  font-weight: 700;
  letter-spacing: 0.02em;
}

tbody tr:nth-child(even) {
  background: #f8fafc;
}

tbody tr:hover {
  background: #eff6ff;
}

summary {
  cursor: pointer;
  padding: 12px 0;
  font-weight: 700;
  color: var(--primary-blue);
  overflow-wrap: break-word;
}

caption {
  text-align: left;
  padding: 10px 12px;
  color: var(--text-light);
  font-size: 0.88rem;
  line-height: 1.5;
}

.table-scroll:focus-visible {
  outline: 3px solid var(--border-focus);
  outline-offset: 3px;
}

.coverage-scenario {
  display: block;
  margin: 8px 0;
  padding: 6px 10px;
  font-size: 0.85rem;
  text-align: left;
  border-radius: 6px;
}

#coverage-body td {
  min-width: 190px;
  overflow-wrap: anywhere;
}

#coverage-body p {
  margin: 8px 0;
}

/* 10. 頁尾與文字連結 */
footer {
  font-size: 0.88rem;
  color: var(--text-light);
  padding: 28px 0 20px;
  line-height: 1.7;
}

a {
  color: var(--primary-blue);
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

a:hover {
  color: var(--primary-blue-hover);
}

code {
  overflow-wrap: anywhere;
  word-break: break-all;
  font-family: ui-monospace, "SF Mono", "Cascadia Code", "Roboto Mono", Menlo, Consolas, "Noto Sans TC", monospace;
  font-size: 0.9em;
  background: #f1f5f9;
  padding: 2px 6px;
  border-radius: 4px;
}

[hidden] { display: none !important; }

#fields.first-batch { display: block; }
#fields.first-batch fieldset { margin-left: 0; margin-right: 0; }
input, select { min-width: 0; }

/* 11. 響應式與中高齡縮放重流 (Responsive & 200% Zoom) */
@media (max-width: 640px) {
  main { padding: 20px 14px; }
  section, aside { padding: 20px 16px; border-radius: 10px; }
  .grid { grid-template-columns: 1fr; }
  .form-group { padding: 16px 14px; }
  h1 { font-size: 1.75rem; line-height: 1.3; }
  input, select, button { width: 100%; min-height: 48px; }
}

.home-screen-entry { margin: 12px 0 0; font-size: 0.9rem; }
.home-screen-entry a, .home-screen-sources a {
  display: inline-block;
  min-height: 44px;
  padding: 8px 0;
}
#home-screen-guide {
  scroll-margin-top: 20px;
  font-size: 1rem;
  color: #334155;
  overflow-wrap: anywhere;
}
#home-screen-guide details { border-top: 1px solid #e2e8f0; }
#home-screen-guide summary { min-height: 48px; }
#home-screen-guide details p { margin: 8px 0 16px; }
.home-screen-sources { font-size: 0.9rem; }
.home-screen-entry a:focus-visible,
#home-screen-guide a:focus-visible,
#home-screen-guide summary:focus-visible {
  outline: 3px solid #0284c7;
  outline-offset: 3px;
}

/* Narrow-screen forms: allow native iOS date controls and nested grids to shrink. */
fieldset, .grid > *, label { min-inline-size: 0; max-inline-size: 100%; }
.grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
input, select, textarea { box-sizing: border-box; max-inline-size: 100%; }
input[type="date"] {
  -webkit-appearance: none;
  appearance: none;
  inline-size: 100%;
  min-inline-size: 0;
  text-align: left;
}
input[type="date"]::-webkit-date-and-time-value { min-inline-size: 0; text-align: left; }
input[type="date"]::-webkit-datetime-edit { min-inline-size: 0; padding: 0; }
.calculator-directory { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.calculator-directory button { width: 100%; min-width: 0; text-align: left; white-space: normal; overflow-wrap: anywhere; padding: 10px 12px; }
.calculator-directory button[aria-current="true"] { outline: 2px solid currentColor; outline-offset: 2px; }
.coverage-cell-label { display: none; }
@media (max-width: 640px) {
  .grid, .calculator-directory { grid-template-columns: minmax(0, 1fr); }
  fieldset { margin-inline: 0; padding-inline: 12px; }
  legend { max-inline-size: 100%; white-space: normal; }
  #section-coverage .table-scroll { overflow: visible; border: 0; }
  #section-coverage table, #section-coverage tbody, #section-coverage tr, #coverage-body td { display: block; width: 100%; min-width: 0; max-width: 100%; }
  #section-coverage caption { display: block; }
  #section-coverage thead { display: none; }
  #coverage-body tr { margin-block: 16px; border: 1px solid currentColor; border-radius: 8px; overflow: hidden; }
  #coverage-body td { padding: 12px; }
  .coverage-cell-label { display: block; font-weight: 700; margin-bottom: 8px; }
  .coverage-scenario { max-width: 100%; white-space: normal; }
}

#contact-feedback { overflow-wrap: anywhere; }
.contact-email { display: inline-block; min-height: 44px; padding-block: 8px; }
.contact-email:focus-visible { outline: 3px solid #0284c7; outline-offset: 3px; }

/* Visible editorial guide; independent of calculator language rendering. */
#labor-dispute-guide { margin-top: 2rem; line-height: 1.8; overflow-wrap: anywhere; }
#labor-dispute-guide > section { margin-block: 1.5rem; }
#labor-dispute-guide h3 { margin-bottom: .5rem; }
#labor-dispute-guide details { margin-block: .75rem; }

.baker-return { display:flex; flex-wrap:wrap; gap:.5rem; margin-bottom:1.2rem; font-size:.95rem; }
.baker-return a { color:inherit; text-underline-offset:.2em; }
