/* ============================================================
   協會理監事電子投票系統 — 樣式表
   Design tokens: 官方文書 × 印章驗證 意象
   ============================================================ */

:root {
  /* Color */
  --navy: #1b2a4a;
  --navy-deep: #101a30;
  --navy-soft: #2a3c63;
  --seal: #a63a2e;
  --seal-soft: #c65b4a;
  --paper: #f7f5f0;
  --paper-dim: #efeae0;
  --paper-card: #fffdf9;
  --ink: #26241f;
  --ink-soft: #5a564c;
  --line: #d8d3c6;
  --line-strong: #b9b2a0;
  --success: #4c7a5e;

  /* Type */
  --font-display: "Noto Serif TC", "PingFang TC", "Microsoft JhengHei", serif;
  --font-body: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif;
  --font-mono: "Roboto Mono", "Noto Sans Mono CJK TC", monospace;

  /* Layout */
  --max-w: 1180px;
  --gutter: clamp(20px, 5vw, 64px);
  --radius: 3px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { font-family: var(--font-display); margin: 0; color: var(--navy); font-weight: 700; }
p { margin: 0; }
a { color: inherit; }
ul { margin: 0; padding: 0; list-style: none; }
button { font-family: inherit; }

.container {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 var(--gutter);
}

:focus-visible {
  outline: 2px solid var(--seal);
  outline-offset: 3px;
}

.eyebrow {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  letter-spacing: 0.14em;
  color: var(--seal);
  text-transform: uppercase;
  display: inline-flex;
  align-items: center;
  gap: 0.6em;
}
.eyebrow::before {
  content: "";
  width: 22px;
  height: 1px;
  background: var(--seal);
  display: inline-block;
}

/* ---------- Header ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(247, 245, 240, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px var(--gutter);
  max-width: var(--max-w);
  margin: 0 auto;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--navy);
  text-decoration: none;
}
.brand-mark {
  width: 34px; height: 34px;
  flex: none;
  display: block;
}
.main-nav { display: none; gap: 32px; font-size: 0.95rem; }
.main-nav a { text-decoration: none; color: var(--ink-soft); transition: color 0.15s; }
.main-nav a:hover { color: var(--seal); }
.header-cta { display: none; }

.nav-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px; height: 40px;
  border: 1px solid var(--line-strong);
  background: transparent;
  border-radius: var(--radius);
  cursor: pointer;
}
.nav-toggle svg { width: 20px; height: 20px; stroke: var(--navy); }

.mobile-nav {
  display: none;
  flex-direction: column;
  padding: 8px var(--gutter) 20px;
  border-top: 1px solid var(--line);
  gap: 4px;
}
.mobile-nav.open { display: flex; }
.mobile-nav a {
  padding: 10px 0;
  text-decoration: none;
  color: var(--ink);
  border-bottom: 1px dashed var(--line);
  font-size: 0.98rem;
}
.mobile-nav .btn { margin-top: 12px; }

@media (min-width: 900px) {
  .main-nav { display: flex; }
  .header-cta { display: inline-flex; }
  .nav-toggle { display: none; }
  .mobile-nav { display: none !important; }
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 13px 26px;
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  border: 1px solid transparent;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
  letter-spacing: 0.02em;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--seal); color: var(--paper-card); }
.btn-primary:hover { background: var(--seal-soft); }
.btn-outline { background: transparent; color: var(--navy); border-color: var(--navy); }
.btn-outline:hover { background: var(--navy); color: var(--paper); }
.btn-ghost { background: transparent; color: var(--paper); border-color: rgba(247,245,240,0.4); }
.btn-ghost:hover { border-color: var(--paper); }
.btn-block { width: 100%; }

/* ---------- Hero ---------- */
.hero {
  padding: 64px 0 72px;
  border-bottom: 1px solid var(--line);
  overflow: hidden;
}
.hero .container {
  display: grid;
  gap: 48px;
  align-items: center;
}
.hero h1 {
  font-size: clamp(2rem, 5vw, 3.1rem);
  line-height: 1.3;
  margin: 18px 0 20px;
}
.hero h1 em {
  font-style: normal;
  color: var(--seal);
}
.hero-sub {
  font-size: 1.05rem;
  color: var(--ink-soft);
  max-width: 46ch;
  margin-bottom: 30px;
}
.hero-actions { display: flex; flex-wrap: wrap; gap: 14px; margin-bottom: 28px; }
.hero-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 22px;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--ink-soft);
}
.hero-meta span { display: flex; align-items: center; gap: 6px; }
.hero-meta .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--success); }

/* Signature visual: tally-mark ballot counter */
.tally-card {
  background: var(--paper-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 28px 26px 24px;
  box-shadow: 0 24px 48px -28px rgba(27, 42, 74, 0.35);
  position: relative;
}
.tally-card::before {
  content: "";
  position: absolute;
  inset: 8px;
  border: 1px dashed var(--line-strong);
  pointer-events: none;
  border-radius: 2px;
}
.tally-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--ink-soft);
  letter-spacing: 0.08em;
  margin-bottom: 18px;
}
.tally-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px 6px;
  margin-bottom: 18px;
}
.tally-char svg { width: 100%; height: auto; overflow: visible; }
.tally-char path {
  fill: none;
  stroke: var(--seal);
  stroke-width: 7;
  stroke-linecap: square;
  stroke-dasharray: 60;
  stroke-dashoffset: 60;
  animation: draw-stroke 0.5s ease forwards;
}
@keyframes draw-stroke { to { stroke-dashoffset: 0; } }

.tally-count {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  border-top: 1px solid var(--line);
  padding-top: 16px;
}
.tally-count .num {
  font-family: var(--font-mono);
  font-size: 2rem;
  color: var(--navy);
  font-weight: 700;
}
.tally-count .label { font-size: 0.85rem; color: var(--ink-soft); }
.tally-stamp {
  position: absolute;
  top: -14px; right: -10px;
  width: 82px; height: 82px;
  border: 2px solid var(--seal);
  border-radius: 50%;
  color: var(--seal);
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 0.62rem;
  letter-spacing: 0.08em;
  transform: rotate(12deg);
  background: rgba(247, 245, 240, 0.9);
  line-height: 1.3;
}

@media (min-width: 860px) {
  .hero .container { grid-template-columns: 1.1fr 0.9fr; }
}

/* ---------- Section shell ---------- */
.section { padding: 76px 0; border-bottom: 1px solid var(--line); }
.section-head { max-width: 640px; margin-bottom: 44px; }
.section-head h2 { font-size: clamp(1.6rem, 3.2vw, 2.2rem); margin-top: 14px; line-height: 1.4; }
.section-head p { color: var(--ink-soft); margin-top: 14px; }
.section-dark { background: var(--navy); color: var(--paper); border-color: var(--navy-deep); }
.section-dark h2, .section-dark h3 { color: var(--paper); }
.section-dark .section-head p { color: rgba(247,245,240,0.72); }
.section-dark .eyebrow { color: var(--seal-soft); }
.section-dark .eyebrow::before { background: var(--seal-soft); }

/* ---------- Election type cards (ballots) ---------- */
.ballot-grid {
  display: grid;
  gap: 20px;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}
.ballot-card {
  background: var(--paper-card);
  border: 1px solid var(--line);
  border-top: 4px solid var(--seal);
  border-radius: var(--radius);
  padding: 26px 22px;
  position: relative;
}
.ballot-card .tag {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--seal);
  letter-spacing: 0.08em;
}
.ballot-card h3 { font-size: 1.2rem; margin: 10px 0 10px; }
.ballot-card p { color: var(--ink-soft); font-size: 0.92rem; }
.ballot-card .check {
  position: absolute; top: 22px; right: 20px;
  width: 22px; height: 22px;
  border: 1.5px solid var(--line-strong);
  border-radius: 3px;
}

/* ---------- Security grid ---------- */
.security-grid {
  display: grid;
  gap: 1px;
  background: rgba(247,245,240,0.14);
  border: 1px solid rgba(247,245,240,0.14);
  grid-template-columns: 1fr;
}
@media (min-width: 700px) { .security-grid { grid-template-columns: 1fr 1fr; } }
@media (min-width: 1040px) { .security-grid { grid-template-columns: 1fr 1fr 1fr; } }
.security-item {
  background: var(--navy);
  padding: 28px 26px;
}
.security-item .idx {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--seal-soft);
  letter-spacing: 0.1em;
}
.security-item h3 { font-size: 1.05rem; margin: 12px 0 10px; }
.security-item p { color: rgba(247,245,240,0.72); font-size: 0.9rem; }

.stamp-badge {
  margin-top: 40px;
  display: inline-flex;
  align-items: center;
  gap: 16px;
  border: 1px solid rgba(247,245,240,0.3);
  padding: 14px 22px;
  border-radius: var(--radius);
}
.stamp-badge .ring {
  width: 46px; height: 46px;
  border: 2px solid var(--seal-soft);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display);
  color: var(--seal-soft);
  font-size: 1.2rem;
  transform: rotate(-8deg);
  flex: none;
}
.stamp-badge .txt { font-family: var(--font-mono); font-size: 0.82rem; color: rgba(247,245,240,0.85); }

/* ---------- Process steps ---------- */
.steps {
  display: grid;
  gap: 28px;
  grid-template-columns: 1fr;
  counter-reset: step;
}
@media (min-width: 860px) { .steps { grid-template-columns: repeat(3, 1fr); } }
.step {
  position: relative;
  padding: 30px 24px 24px;
  border: 1px solid var(--line);
  background: var(--paper-card);
  border-radius: var(--radius);
}
.step .step-no {
  font-family: var(--font-mono);
  font-size: 2.1rem;
  color: var(--line-strong);
  line-height: 1;
  margin-bottom: 14px;
  display: block;
}
.step h3 { font-size: 1.08rem; margin-bottom: 10px; }
.step p { color: var(--ink-soft); font-size: 0.92rem; }
.step-connector {
  display: none;
}
@media (min-width: 860px) {
  .steps { position: relative; }
  .step:not(:last-child)::after {
    content: "";
    position: absolute;
    top: 44px; right: -18px;
    width: 36px; height: 1px;
    background: var(--line-strong);
  }
}

/* ---------- Application form ---------- */
.apply-shell {
  background: var(--paper-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: clamp(24px, 4vw, 48px);
}
.form-grid {
  display: grid;
  gap: 20px;
  grid-template-columns: 1fr;
}
@media (min-width: 720px) { .form-grid { grid-template-columns: 1fr 1fr; } }
.field { display: flex; flex-direction: column; gap: 8px; }
.field.full { grid-column: 1 / -1; }
.field label {
  font-size: 0.86rem;
  font-weight: 700;
  color: var(--navy);
}
.field label .req { color: var(--seal); margin-left: 3px; }
.field input, .field select, .field textarea {
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 11px 13px;
  font-size: 0.95rem;
  font-family: var(--font-body);
  background: #fff;
  color: var(--ink);
}
.field textarea { resize: vertical; min-height: 90px; }
.field input:focus, .field select:focus, .field textarea:focus {
  outline: 2px solid var(--seal);
  outline-offset: 1px;
  border-color: var(--seal);
}
.field small { color: var(--ink-soft); font-size: 0.78rem; }
.checkbox-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 20px;
}
.checkbox-row label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.92rem;
  font-weight: 400;
  color: var(--ink);
}
.checkbox-row input { width: 16px; height: 16px; accent-color: var(--seal); }

.form-footer {
  margin-top: 30px;
  padding-top: 22px;
  border-top: 1px dashed var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
}
.form-footer p { font-size: 0.8rem; color: var(--ink-soft); max-width: 42ch; }

.form-status {
  margin-top: 18px;
  padding: 14px 16px;
  border-radius: var(--radius);
  font-size: 0.9rem;
  display: none;
}
.form-status.show { display: block; }
.form-status.ok { background: rgba(76, 122, 94, 0.12); color: var(--success); border: 1px solid rgba(76,122,94,0.3); }
.form-status.err { background: rgba(166, 58, 46, 0.1); color: var(--seal); border: 1px solid rgba(166,58,46,0.3); }

/* ---------- Footer ---------- */
.site-footer {
  background: var(--navy-deep);
  color: rgba(247,245,240,0.75);
  padding: 56px 0 28px;
  font-size: 0.9rem;
}
.footer-grid {
  display: grid;
  gap: 32px;
  grid-template-columns: 1fr;
  padding-bottom: 32px;
  border-bottom: 1px solid rgba(247,245,240,0.14);
}
@media (min-width: 720px) { .footer-grid { grid-template-columns: 1.4fr 1fr 1fr; } }
.footer-brand h3 { color: var(--paper); font-size: 1.05rem; margin-bottom: 10px; }
.footer-brand p { color: rgba(247,245,240,0.6); max-width: 40ch; }
.footer-col h4 {
  color: var(--paper);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  margin-bottom: 14px;
  text-transform: uppercase;
}
.footer-col a, .footer-col li { display: block; margin-bottom: 9px; color: rgba(247,245,240,0.7); text-decoration: none; }
.footer-col a:hover { color: var(--paper); }
.footer-bottom {
  padding-top: 22px;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 12px;
  font-size: 0.8rem;
  color: rgba(247,245,240,0.5);
  font-family: var(--font-mono);
}

/* ---------- Install / offline toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translate(-50%, 120%);
  background: var(--navy);
  color: var(--paper);
  padding: 13px 20px;
  border-radius: var(--radius);
  font-size: 0.86rem;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: 0 20px 40px -18px rgba(0,0,0,0.5);
  z-index: 60;
  transition: transform 0.3s ease;
  max-width: calc(100vw - 40px);
}
.toast.show { transform: translate(-50%, 0); }
.toast button {
  background: var(--seal);
  color: var(--paper);
  border: none;
  padding: 7px 12px;
  border-radius: var(--radius);
  font-size: 0.8rem;
  cursor: pointer;
  flex: none;
}
.toast .dismiss {
  background: transparent;
  color: rgba(247,245,240,0.6);
  padding: 4px;
}

.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;
}
