/* web/static/style.css — Direction B: 現代簡約 (Apple-like) — Polish v2 */
* { box-sizing: border-box; }

:root {
    /* === Spacing scale (8pt grid) === */
    --s-1: 4px;
    --s-2: 8px;
    --s-3: 12px;
    --s-4: 16px;
    --s-5: 20px;
    --s-6: 24px;
    --s-8: 32px;
    --s-10: 40px;
    --s-12: 48px;
    --s-16: 64px;

    /* === Radii === */
    --r-sm: 8px;
    --r-md: 12px;
    --r-lg: 16px;

    /* === Color === */
    --bg: #fafafa;
    --ink: #1c1c1e;
    --ink-soft: #4a4a4d;
    --ink-muted: #8e8e93;
    --accent: #d4af37;
    --accent-soft: #b8962f;
    --accent-bg: rgba(212, 175, 55, 0.08);
    --accent-glow: rgba(212, 175, 55, 0.18);
    --hairline: rgba(0, 0, 0, 0.06);
    --hairline-strong: rgba(0, 0, 0, 0.12);
    --surface: #ffffff;
    --surface-soft: #f5f5f7;
    --danger: #c0392b;

    /* === Motion === */
    --ease-out: cubic-bezier(0.25, 0.46, 0.45, 0.94);
    --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
    --t-fast: 0.15s;
    --t-base: 0.25s;
    --t-slow: 0.4s;
}

::selection { background: var(--accent-glow); color: var(--ink); }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "PingFang TC",
                 "Microsoft JhengHei", "Helvetica Neue", sans-serif;
    background: var(--bg);
    color: var(--ink);
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    font-feature-settings: "kern", "liga", "calt";
    overflow-x: hidden;
    min-height: 100vh;
    /* Cross-page fade: start invisible; .page-ready triggers fade-in */
    opacity: 1;
    transition: opacity 0.28s ease;
}
body.page-leaving { opacity: 0; }
body:not(.page-ready) {
    /* Run only when JS is enabled to avoid blank-page flash on no-JS */
    animation: page-in 0.4s var(--ease-out) backwards;
}
@keyframes page-in {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ===== HERO / INTRO SECTION ===== */
.hero {
    position: relative;
    width: 100%;
    min-height: 78vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--s-12) var(--s-5) var(--s-10);
    overflow: hidden;
    border-bottom: 1px solid var(--hairline);
}
/* === Global background canvas (constellation animation) ===
   Pinned to viewport; lives behind ALL page content via z-index 0.
   Body bg color (#fafafa) shows through transparent canvas regions
   (we never fillRect — only the dots+lines are drawn).
   No explicit width/height in CSS — JS sets style.width/height
   from window.innerWidth/Height after measuring (avoids 100vh ≠
   innerHeight on mobile when address bar is visible). */
.bg-canvas {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
}

/* Per-page opacity — all three pages keep strong presence; form
   cards already cover the centre so dots only show in margins. */
.page-landing   .bg-canvas { opacity: 1; }
.page-wizard    .bg-canvas { opacity: 0.85; }
.page-submitted .bg-canvas { opacity: 0.85; }

/* Content sits above the canvas */
.hero, .wizard { position: relative; z-index: 1; }
.hero-content {
    position: relative;
    z-index: 2;
    text-align: center;
    max-width: 480px;
    width: 100%;
    animation: fade-in 0.7s var(--ease-out);
}
.hero-title {
    margin: 0;
    font-size: 36px;
    font-weight: 600;
    letter-spacing: -0.8px;
    color: var(--ink);
    line-height: 1.1;
}
.hero-subtitle {
    color: var(--ink-muted);
    font-size: 11.5px;
    font-weight: 500;
    letter-spacing: 2.5px;
    text-transform: uppercase;
    margin: var(--s-3) 0 0;
}
.hero-divider {
    width: 32px;
    height: 1px;
    background: var(--accent);
    margin: var(--s-6) auto var(--s-6);
    opacity: 0.65;
}
.hero-mark {
    color: var(--accent);
    font-size: 22px;
    margin-bottom: var(--s-4);
    line-height: 1;
    text-shadow: 0 0 18px var(--accent-glow);
}
.hero-line {
    font-size: 17px;
    font-weight: 500;
    color: var(--ink);
    letter-spacing: 0.5px;
    margin: 0 0 var(--s-5);
    line-height: 1.55;
}
.hero-paragraph {
    font-size: 14px;
    line-height: 1.85;
    color: var(--ink-soft);
    margin: 0 auto;
    max-width: 360px;
    letter-spacing: 0.3px;
}
.hero-cta {
    display: inline-flex;
    align-items: center;
    gap: var(--s-3);
    margin-top: var(--s-10);
    padding: 14px 32px;
    border: 1px solid var(--accent);
    border-radius: 999px;
    background: transparent;
    color: var(--ink);
    text-decoration: none;
    font-size: 13.5px;
    font-weight: 500;
    letter-spacing: 2.5px;
    text-transform: uppercase;
    cursor: pointer;
    transition: background-color var(--t-base) var(--ease-out),
                color var(--t-base) var(--ease-out),
                transform var(--t-base) var(--ease-out),
                box-shadow var(--t-base) var(--ease-out);
}
.hero-cta-arrow {
    display: inline-block;
    transition: transform var(--t-base) var(--ease-spring);
    font-weight: 400;
}
.hero-cta:hover {
    background: var(--accent);
    color: #fff;
    transform: translateY(-2px);
    box-shadow: 0 12px 28px rgba(212, 175, 55, 0.25);
}
.hero-cta:hover .hero-cta-arrow {
    transform: translateX(5px);
}
.hero-cta:active {
    transform: translateY(0);
    box-shadow: 0 4px 12px rgba(212, 175, 55, 0.2);
}

/* Full-viewport hero (landing page variant) */
.hero-fullscreen {
    min-height: 100vh;
    padding: var(--s-12) var(--s-5);
}

@media (max-width: 480px) {
    .hero { padding: var(--s-10) var(--s-4); }
    .hero-fullscreen { padding: var(--s-10) var(--s-4); }
    .hero-title { font-size: 30px; }
    .hero-line { font-size: 15px; }
    .hero-paragraph { font-size: 13px; }
    .hero-cta {
        padding: 13px 28px;
        font-size: 12.5px;
        letter-spacing: 2px;
    }
}

.wizard {
    max-width: 480px;
    margin: 0 auto;
    padding: var(--s-6) var(--s-4) var(--s-12);
}

/* === Wizard header === */
.wizard-header {
    text-align: center;
    margin-bottom: var(--s-6);
    animation: fade-in 0.45s var(--ease-out);
}
.wizard-back {
    display: inline-flex;
    align-items: center;
    gap: var(--s-2);
    margin-bottom: var(--s-6);
    color: var(--ink-muted);
    font-size: 12px;
    font-weight: 500;
    letter-spacing: 1px;
    text-decoration: none;
    padding: 6px 12px;
    border-radius: 999px;
    transition: color var(--t-base) var(--ease-out),
                background-color var(--t-base) var(--ease-out);
}
.wizard-back:hover {
    color: var(--ink);
    background: var(--surface-soft);
}
.wizard-back-arrow {
    display: inline-block;
    transition: transform var(--t-base) var(--ease-spring);
}
.wizard-back:hover .wizard-back-arrow {
    transform: translateX(-3px);
}
h1 {
    margin: 0;
    font-size: 30px;
    font-weight: 600;
    letter-spacing: -0.6px;
    color: var(--ink);
    line-height: 1.15;
}
.subtitle {
    color: var(--ink-muted);
    font-size: 12px;
    font-weight: 500;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    margin: var(--s-3) 0 var(--s-6);
}

/* === Progress === */
.progress {
    position: relative;
    height: 2px;
    background: var(--hairline-strong);
    border-radius: 1px;
    max-width: 260px;
    margin: 0 auto;
    overflow: hidden;
}
.progress-fill {
    position: absolute;
    top: 0; left: 0; bottom: 0;
    width: 0;
    background: var(--accent);
    transition: width var(--t-slow) var(--ease-out);
}
.progress-label {
    margin: var(--s-3) 0 0;
    font-size: 10.5px;
    font-weight: 500;
    color: var(--ink-muted);
    letter-spacing: 1.5px;
    text-align: center;
    text-transform: uppercase;
    font-variant-numeric: tabular-nums;
}

/* === Step card === */
.step {
    background: var(--surface);
    padding: var(--s-8) var(--s-6) var(--s-6);
    border-radius: var(--r-lg);
    border: 1px solid var(--hairline);
}
.step.hidden { display: none; }

/* Step enters: fade + slight Y rise. Triggers on every showStep(). */
.step:not(.hidden) {
    animation: step-in 0.32s var(--ease-out);
}
@keyframes step-in {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

h2 {
    margin: 0 0 var(--s-6);
    font-size: 19px;
    font-weight: 600;
    color: var(--ink);
    letter-spacing: -0.3px;
    line-height: 1.3;
}

/* === Form fields === */
label {
    display: block;
    margin-bottom: var(--s-5);
    font-size: 13px;
    font-weight: 500;
    color: var(--ink-soft);
    letter-spacing: 0.15px;
}
input, select, textarea {
    display: block;
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--hairline-strong);
    border-radius: var(--r-md);
    font-size: 16px;
    background: var(--surface);
    color: var(--ink);
    margin-top: var(--s-2);
    min-height: 44px;
    font-family: inherit;
    font-weight: 450;
    transition: border-color var(--t-fast) var(--ease-out),
                box-shadow var(--t-fast) var(--ease-out);
}
/* Tabular numerals on numeric inputs so YYYY MM DD / HH:MM align cleanly */
input[type="number"] { font-variant-numeric: tabular-nums; }

input:hover:not(:focus), select:hover:not(:focus), textarea:hover:not(:focus) {
    border-color: var(--ink-muted);
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-bg);
}
/* Distinguish keyboard focus for accessibility without affecting mouse users */
input:focus-visible, select:focus-visible, textarea:focus-visible {
    box-shadow: 0 0 0 3px var(--accent-glow);
}
textarea {
    min-height: 120px;
    resize: vertical;
    line-height: 1.6;
    font-weight: 450;
}

.row { display: flex; gap: var(--s-2); align-items: center; }
.row input { flex: 1; }
.row span {
    color: var(--ink-muted);
    font-size: 18px;
    padding: 0 var(--s-1);
    font-variant-numeric: tabular-nums;
}

/* === Buttons === */
.actions {
    display: flex;
    gap: var(--s-3);
    margin-top: var(--s-8);
}
.actions.right-only {
    justify-content: flex-end;
}

button {
    position: relative;
    flex: 1;
    min-height: 48px;
    padding: 0 var(--s-5);
    font-size: 15px;
    font-weight: 500;
    border: none;
    border-radius: var(--r-md);
    cursor: pointer;
    font-family: inherit;
    letter-spacing: 0.2px;
    transition: background-color var(--t-fast) var(--ease-out),
                transform 0.08s var(--ease-out),
                border-color var(--t-fast) var(--ease-out),
                color var(--t-fast) var(--ease-out);
}
button.next, button.submit {
    background: var(--ink);
    color: #fff;
}
button.next:hover, button.submit:hover {
    background: #2c2c2e;
}
button.next:active, button.submit:active {
    transform: scale(0.97);
    background: #0e0e10;
}
button.prev {
    background: var(--surface-soft);
    color: var(--ink-soft);
    border: 1px solid var(--hairline);
    font-weight: 500;
}
button.prev:hover {
    background: #ebebed;
    border-color: var(--hairline-strong);
}
button.prev:active {
    transform: scale(0.97);
    background: #e5e5e7;
}
button.submit {
    font-weight: 600;
    letter-spacing: 0.3px;
}
button.submit::before {
    content: "✦";
    color: var(--accent);
    margin-right: var(--s-2);
    display: inline-block;
    transition: transform var(--t-base) var(--ease-spring);
}
button.submit:hover::before {
    transform: rotate(72deg) scale(1.15);
}
button:disabled:not(.is-submitting) {
    opacity: 0.35;
    cursor: not-allowed;
}

/* === Submit loading state === */
button.is-submitting {
    color: transparent;
    pointer-events: none;
    cursor: progress;
}
button.is-submitting::before { opacity: 0; }
button.is-submitting::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 18px;
    height: 18px;
    margin: -9px 0 0 -9px;
    border: 2px solid rgba(255, 255, 255, 0.25);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.65s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.actions.right-only > button {
    flex: 0 0 auto;
    min-width: 140px;
}

/* === Error / Hint === */
.error {
    color: var(--danger);
    font-size: 13px;
    min-height: 1.4em;
    margin: var(--s-2) 0 0;
    font-weight: 500;
    transition: color var(--t-base) var(--ease-out);
}
.error:empty { min-height: 1.4em; }

.hint {
    color: var(--ink-soft);
    font-size: 13px;
    background: var(--surface-soft);
    padding: var(--s-3) var(--s-4);
    border-radius: var(--r-sm);
    border-left: 2px solid var(--accent);
    margin: 0 0 var(--s-4);
    line-height: 1.55;
}
.hint strong { color: var(--ink); font-weight: 600; }

/* === Preset radio list === */
#preset_list {
    display: flex;
    flex-direction: column;
    gap: var(--s-2);
    margin-bottom: var(--s-4);
}
#preset_list label {
    display: flex;
    align-items: center;
    padding: 14px 16px;
    border: 1px solid var(--hairline-strong);
    border-radius: var(--r-md);
    margin-bottom: 0;
    font-weight: 500;
    cursor: pointer;
    font-size: 14px;
    color: var(--ink);
    transition: border-color var(--t-fast) var(--ease-out),
                background-color var(--t-fast) var(--ease-out),
                padding var(--t-fast) var(--ease-out);
}
#preset_list label:hover {
    border-color: var(--ink-muted);
}
#preset_list label:has(input:checked) {
    border-color: var(--accent);
    border-width: 1.5px;
    padding: 13.5px 15.5px;
    background: var(--accent-bg);
    animation: select-pulse 0.32s var(--ease-spring);
}
@keyframes select-pulse {
    0%   { transform: scale(1); }
    45%  { transform: scale(1.015); }
    100% { transform: scale(1); }
}
#preset_list input {
    width: auto;
    min-height: 0;
    margin: 0 var(--s-3) 0 0;
    accent-color: var(--accent);
}

/* === Summary === */
.summary {
    background: var(--surface-soft);
    padding: var(--s-5);
    border-radius: var(--r-md);
    border: 1px solid var(--hairline);
    font-size: 14px;
    line-height: 1.75;
    margin: var(--s-5) 0 0;
    white-space: pre-line;
    color: var(--ink-soft);
    font-variant-numeric: tabular-nums;
}
.summary::before {
    content: "確認資料";
    display: block;
    font-size: 10.5px;
    color: var(--accent-soft);
    letter-spacing: 2px;
    text-transform: uppercase;
    margin-bottom: var(--s-3);
    font-weight: 600;
}

.hidden { display: none; }

/* === Submitted (thank-you) page === */
.submitted-card {
    text-align: center;
    padding: var(--s-10) var(--s-6);
}
.submitted-mark {
    font-size: 28px;
    color: var(--accent);
    text-shadow: 0 0 22px var(--accent-glow);
    margin-bottom: var(--s-5);
    line-height: 1;
}
.submitted-title {
    font-size: 22px;
    font-weight: 600;
    margin: 0 0 var(--s-6);
    letter-spacing: -0.3px;
    color: var(--ink);
}
.submitted-card p {
    color: var(--ink-soft);
    font-size: 14px;
    line-height: 1.75;
    margin: 0 0 var(--s-4);
}
.submitted-card p:last-child { margin-bottom: 0; }
.submitted-sid code {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 13px;
    background: var(--surface-soft);
    padding: 2px 8px;
    border-radius: 6px;
    color: var(--ink);
    letter-spacing: 0.3px;
}
.submitted-fallback {
    font-size: 12.5px !important;
    color: var(--ink-muted) !important;
    margin-top: var(--s-6) !important;
    padding-top: var(--s-4);
    border-top: 1px solid var(--hairline);
}

/* === Respect users who prefer no motion === */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
