/* ==========================================================================
   人格特質量表 — 頁級樣式
   視覺規格來源：docs/tickets/perception-test-ui-260924/design/index.html
   頂欄以頁面 scope（body.pt-page）override 呈現，規格對齊 mbti-test.css；
   共用的 js/header.js、css/header.css 零修改。
   ========================================================================== */

:root {
    --bg: #F7F6F1;
    --paper: #FFFEFA;
    --ink: #213F36;
    --green: #234D40;
    --light: #E7EEE5;
    --line: #E1E4D9;
    --muted: #647362;
    --muted-deep: #55634F; /* 小字在砂色/淺底上的加深版（WCAG AA 抽查用） */
    --orange: #BC6848;
    --sand: #F4E7D7;
    --font: 'Noto Sans TC', 'PingFang TC', 'Microsoft JhengHei', sans-serif;
    --serif: 'Noto Serif TC', 'PingFang TC', 'Microsoft JhengHei', serif;
}

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

[hidden] { display: none !important; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font: 14px/1.7 var(--font);
    -webkit-text-size-adjust: 100%;
}

.page h1,
.page h2,
.page h3,
.page p,
.page dl,
.page dd,
.page ol,
.page ul { margin: 0; }

.page h1,
.page h2,
.page h3 { font-weight: 600; }

.page svg,
#flow-dialog svg,
.time-up-overlay svg {
    width: 19px;
    height: 19px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.7;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.page button,
#flow-dialog button,
.page a,
.page input,
.page summary { outline-offset: 4px; }

.page button:focus-visible,
.page a:focus-visible,
.page input:focus-visible,
.page summary:focus-visible,
#flow-dialog button:focus-visible { outline: 3px solid var(--orange); }

.page button { color: inherit; cursor: pointer; transition: background .15s; }
.page button:disabled { cursor: not-allowed; opacity: .48; }
.page button svg { vertical-align: middle; }
.page a { color: inherit; }

/* ---------- 共用 header 頂欄（頁面 scope；不改 header.css/header.js） ---------- */
/* 規格對齊 body.mbti-page（暖白紙底＋深綠 logo＋陶橘點），取代 header.css 預設黑底 */
body.pt-page .site-header {
    background: var(--paper);
    border-bottom: 1px solid var(--line);
    height: 84px;
    padding: 0 24px;
    gap: 18px;
}
body.pt-page .site-logo {
    color: var(--green);
    font-size: 26px;
    font-weight: 800;
    letter-spacing: -1.3px;
    min-width: 0;
    max-width: calc(100% - 150px); /* 長品牌名截斷，不擠壓返回入口 */
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
body.pt-page .site-logo::after {
    content: '';
    display: inline-block;
    width: 8px;
    height: 8px;
    margin-left: 3px;
    border-radius: 50%;
    background: var(--orange);
    vertical-align: 0.22em;
}
body.pt-page .site-back {
    color: var(--green);
    font-size: 12px;
    font-weight: 600;
    flex-shrink: 0;
    white-space: nowrap;
    padding: 14px 0;
}
body.pt-page .site-back svg { width: 16px; height: 16px; }
body.pt-page .site-back:hover { color: var(--orange); }

@media (min-width: 1281px) {
    /* 內容 1220px 置中時，頂欄左右留白與 .page 內容邊緣對齊 */
    body.pt-page .site-header { padding: 0 max(30px, calc((100vw - 1220px) / 2)); }
}

/* ---------- layout ---------- */
.page {
    max-width: 1220px;
    margin: auto;
    padding: 33px 0 24px;
}

.page-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    gap: 12px;
}

.eyebrow {
    font-size: 10px;
    letter-spacing: .16em;
    font-weight: 600;
    color: #67755E;
}

.grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 286px;
    gap: 27px;
    align-items: start;
}

.card {
    border: 1px solid var(--line);
    background: var(--paper);
    border-radius: 15px;
    padding: 25px;
}

.subtle { font-size: 12px; color: var(--muted); }

/* ---------- buttons ---------- */
.btn {
    min-height: 44px;
    padding: 10px 17px;
    border-radius: 8px;
    border: 1px solid #D9E1D0;
    background: var(--paper);
    color: #526645;
    font-size: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-decoration: none;
    font-family: inherit;
}

.btn:hover { background: #EDF2E6; }
.btn.primary { background: var(--green); border-color: var(--green); color: #FFFDF7; }
.btn.primary:hover { background: #183C30; }
.wide { width: 100%; }

/* ---------- hero ---------- */
.hero {
    background: #E8EDE1;
    border: 1px solid #DFE5D6;
    border-radius: 20px;
    padding: 32px;
    position: relative;
    overflow: hidden;
    min-height: 226px;
    display: flex;
    align-items: center;
}

.hero-copy { position: relative; z-index: 1; max-width: 75%; }
.hero h1 { font-size: 31px; font-weight: 600; letter-spacing: .02em; line-height: 1.55; margin: 7px 0 10px; }
.hero h1 span { color: #6C8466; }
.hero p { font-size: 12px; line-height: 1.9; color: #5A6E52; }

.botanical {
    position: absolute;
    right: 15px;
    bottom: -12px;
    width: 220px;
    height: 226px;
    opacity: .85;
}

.botanical svg { width: 100%; height: 100%; stroke: none; }

/* ---------- facts ---------- */
.facts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 17px; }

.fact {
    border: 1px solid var(--line);
    background: var(--paper);
    border-radius: 12px;
    padding: 17px 19px;
    display: flex;
    gap: 12px;
    align-items: center;
}

.fact strong { display: block; font-size: 20px; font-weight: 500; line-height: 1.3; }
.fact small { font-size: 11px; color: var(--muted); }

.iconbox {
    width: 35px;
    height: 35px;
    display: grid;
    place-items: center;
    background: #EDF1E9;
    border-radius: 9px;
    color: #738764;
    font-size: 11px;
    flex-shrink: 0;
}

.fact:nth-child(2) .iconbox { background: #F5EAE0; color: #B17D61; }
.fact:nth-child(3) .iconbox { background: #EEE9EF; color: #957C97; }

/* ---------- headings / steps / callout ---------- */
.section-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 25px 0 13px;
    gap: 12px;
}

.section-head h2 { font-size: 17px; font-weight: 600; }
.section-head small { font-size: 11px; color: var(--muted); }

.steps { display: grid; gap: 17px; }
.step { display: grid; grid-template-columns: 28px 1fr; gap: 10px; }
.step > b { font-size: 11px; font-weight: 500; color: #859277; padding-top: 2px; }
.step h3 { font-size: 13px; font-weight: 500; }
.step p { font-size: 12px; color: var(--muted); margin-top: 3px; line-height: 1.9; }

.callout {
    padding: 16px 18px;
    display: flex;
    gap: 12px;
    align-items: flex-start;
    border: 1px solid #E2D7BF;
    border-radius: 11px;
    background: #F8F0E1;
    margin-top: 20px;
    color: #826038;
    font-size: 12px;
    line-height: 1.9;
}

.callout svg { flex-shrink: 0; margin-top: 3px; }
.callout strong { font-weight: 600; }

/* ---------- aside ---------- */
.aside-title { font-size: 15px; font-weight: 600; margin-top: 8px; }

.journey { list-style: none; margin: 22px 0 0; padding: 0; }
.journey li { display: flex; align-items: center; gap: 12px; font-size: 12px; padding: 11px 0; color: var(--muted); }
.journey span {
    width: 26px;
    height: 26px;
    display: grid;
    place-items: center;
    border: 1px solid #DDE3D4;
    border-radius: 50%;
    font-size: 10px;
    flex-shrink: 0;
}

.journey .active { color: var(--green); font-weight: 600; }
.journey .active span { background: var(--green); color: var(--paper); border-color: var(--green); }

.aside-note { margin-top: 20px; padding: 23px; border-radius: 14px; background: #EFEADD; position: relative; }
.aside-note .eyebrow { color: #8E704A; }
.aside-note h3 { font-family: var(--serif); font-size: 23px; font-weight: 500; line-height: 1.65; margin: 14px 0 10px; }
.aside-note p { font-size: 12px; color: #7C6E55; line-height: 1.9; }

.mini-note { font-size: 11px; line-height: 1.9; color: var(--muted); padding: 17px 8px; }

/* ---------- start form ---------- */
.start-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin: 19px 0 22px; }
.field { display: flex; flex-direction: column; gap: 7px; font-size: 12px; color: var(--muted); }

.page input {
    border: 1px solid #DCE2D3;
    border-radius: 8px;
    padding: 10px 12px;
    color: var(--ink);
    background: var(--paper);
    min-width: 0;
    height: 44px;
    font: inherit;
}

.page input::placeholder { color: #798370; }

.start-footer {
    display: flex;
    justify-content: space-between;
    gap: 18px;
    align-items: center;
    border-top: 1px solid var(--line);
    padding-top: 19px;
}

.start-footer small { color: var(--muted); font-size: 11px; }

.error {
    padding: 14px 17px;
    border: 1px solid #E4C8BA;
    background: #F7EAE4;
    color: #8C4835;
    border-radius: 10px;
    margin-top: 15px;
    font-size: 12px;
}

.error strong { font-weight: 600; }
.error p { margin-top: 4px; }

.notice {
    padding: 13px 17px;
    border: 1px solid var(--line);
    background: #EEF3E9;
    border-radius: 10px;
    margin-bottom: 17px;
    color: #526B46;
    font-size: 12px;
}

/* ---------- test page ---------- */
.test-heading {
    display: flex;
    justify-content: space-between;
    gap: 24px;
    align-items: center;
    margin-bottom: 23px;
}

.test-heading h1 { font-size: 27px; line-height: 1.5; font-weight: 600; margin: 5px 0; }

.timer {
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 13px;
    padding: 12px 23px;
    min-width: 167px;
    text-align: center;
}

.timer small { display: block; font-size: 10px; color: var(--muted); }
.timer strong {
    font-size: 28px;
    font-weight: 500;
    font-variant-numeric: tabular-nums;
    letter-spacing: .04em;
    line-height: 1.3;
    display: block;
}

.timer.warning { background: #F8F0E1; border-color: #DFC59C; color: #8A602C; }
.timer.warning small { color: #8A602C; }
.timer.danger { background: #F7EAE4; border-color: #D9AEA0; color: #923C29; }
.timer.danger small { color: #923C29; }

.exam-grid { grid-template-columns: minmax(0, 1fr) 313px; }

/* ---------- question card ---------- */
.question-card { padding: 0; overflow: hidden; border-radius: 18px; }

.section-band {
    padding: 17px 27px;
    background: #E8EDE1;
    border-bottom: 1px solid #DFE5D6;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    gap: 10px;
}

.section-band.preference { background: var(--sand); border-color: #E5D7C2; }
.section-band span:last-child { font-size: 10px; letter-spacing: .07em; }

.question-inner { padding: 30px; }
.question-num { font-size: 12px; color: #6D7C60; letter-spacing: .08em; }
.question-inner h2 { font-size: 23px; font-weight: 500; line-height: 1.65; margin: 11px 0 6px; }

#question-title:focus-visible { outline: 3px solid var(--orange); outline-offset: 4px; }

.options { display: grid; gap: 15px; margin: 26px 0 20px; }

.option {
    width: 100%;
    background: var(--paper);
    border: 1px solid #DCE2D3;
    border-radius: 12px;
    padding: 23px 21px;
    display: flex;
    align-items: center;
    gap: 17px;
    text-align: left;
    min-height: 100px;
    font-size: 16px;
    line-height: 1.8;
    font-family: inherit;
}

.option:hover { background: #F2F5ED; border-color: #9AAE8E; }
.option[aria-checked=true] { background: #EAF0E4; border: 2px solid #527748; padding: 22px 20px; }

.option-letter {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    border-radius: 8px;
    border: 1px solid #DAE1D0;
    display: grid;
    place-items: center;
    color: #7E8F6E;
    font-size: 12px;
}

.option[aria-checked=true] .option-letter { background: var(--green); border-color: var(--green); color: white; }

.option-text { min-width: 0; overflow-wrap: anywhere; }

.radio-mark {
    width: 20px;
    height: 20px;
    border: 1px solid #BCC9B1;
    border-radius: 50%;
    margin-left: auto;
    flex-shrink: 0;
    display: grid;
    place-items: center;
}

.option[aria-checked=true] .radio-mark { background: var(--green); border-color: var(--green); }
.option[aria-checked=true] .radio-mark::after { content: '✓'; color: white; font-size: 12px; }

.question-help { font-size: 11px; color: var(--muted); display: flex; align-items: center; gap: 7px; }

.question-foot {
    border-top: 1px solid var(--line);
    padding: 18px 27px;
    display: flex;
    justify-content: space-between;
    gap: 10px;
    align-items: center;
    background: #FCFCF6;
}

.question-foot small { font-size: 11px; color: var(--muted); }

/* ---------- identity ---------- */
.identity {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-top: 19px;
    padding: 0 5px;
    font-size: 11px;
    color: var(--muted);
    flex-wrap: wrap;
}

.avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: #DCE6D9;
    color: #567451;
    flex-shrink: 0;
}

.identity-email { overflow-wrap: anywhere; }

/* ---------- navigator ---------- */
.navigator { padding: 22px; }

.progress-title { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.progress-title h2 { font-size: 14px; font-weight: 600; }
.progress-title strong { font-size: 12px; font-weight: 500; }

.meter { height: 5px; background: #E7EBDF; border-radius: 10px; overflow: hidden; }
.meter > div { height: 100%; background: #6A895C; width: 0; transition: width .2s; }

.legend { display: flex; gap: 12px; font-size: 10px; color: var(--muted); margin: 14px 0 20px; }
.legend span { display: flex; align-items: center; gap: 5px; }
.legend i { width: 7px; height: 7px; background: #DAE5D0; border: 1px solid #B7C7AB; border-radius: 2px; display: inline-block; }
.legend span:nth-child(2) i { background: var(--paper); }
.legend span:nth-child(3) i { background: var(--green); }

.nav-heading {
    font-size: 11px;
    font-weight: 500;
    color: #657855;
    display: flex;
    justify-content: space-between;
    margin: 17px 0 10px;
}

.dots { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 5px; }

.dot {
    height: 37px;
    min-width: 0;
    font-size: 10px;
    border: 1px solid #E0E5D7;
    border-radius: 6px;
    background: var(--paper);
    color: #64745A;
    padding: 0;
    position: relative;
    font-family: inherit;
}

.dot.answered { background: #E6EDDC; border-color: #CEDCBE; color: #45653A; }
.dot.answered::after {
    content: '';
    position: absolute;
    bottom: 3px;
    left: calc(50% - 2px);
    width: 4px;
    height: 2px;
    background: #6B865A;
}

.dot[aria-current=true] { background: var(--green); border-color: var(--green); color: white; }
.dot[aria-current=true]::after { background: white; }
.dot:disabled { opacity: .6; }

.navigator details > summary { list-style: none; cursor: pointer; }
.navigator details > summary::-webkit-details-marker { display: none; }
.navigator details > summary::after { content: '收合題號 −'; font-size: 10px; color: var(--muted); }
.navigator details:not([open]) > summary::after { content: '展開全部題號 ＋'; }

.submit-area { border-top: 1px solid var(--line); padding-top: 17px; margin-top: 20px; }
.submit-area p { font-size: 10px; line-height: 1.8; color: var(--muted); margin: 9px 0 0; }

/* ---------- state cards ---------- */
.state-card { padding: 45px; text-align: center; }
.state-card h2 { font-size: 21px; font-weight: 500; margin: 13px 0; }
.state-card .btn { margin-top: 19px; }

.spinner {
    display: inline-block;
    width: 27px;
    height: 27px;
    border: 2px solid #DDE5D5;
    border-top-color: #527748;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- finish / receipt ---------- */
.finish { max-width: 780px; margin: 20px auto 60px; padding: 45px; text-align: center; }

.success-icon {
    width: 64px;
    height: 64px;
    background: #E7EEE0;
    display: grid;
    place-items: center;
    border-radius: 50%;
    margin: 0 auto 20px;
    color: #5C7D4D;
}

.success-icon svg { width: 29px; height: 29px; }
.finish h1 { font-size: 29px; font-weight: 500; margin: 8px 0 12px; }

/* ---------- completed view（重測閘門完成頁）：說明與返回鈕加大，間距放寬利於閱讀 ---------- */
#completedView .subtle { font-size: 15px; line-height: 1.9; color: #4C5B4E; }
#completedView .receipt {
    margin-top: 12px;
    margin-bottom: 16px;
    font-size: 14px;
}
#completedView .receipt > div { grid-template-columns: 120px 1fr; gap: 12px; }
#completed-note { margin: 2px 0 26px; }
#completedView .btn.primary {
    font-size: 15px;
    min-height: 52px;
    padding: 13px 32px;
}

.receipt {
    margin: 27px 0;
    text-align: left;
    background: #F2F4EB;
    border-radius: 12px;
    padding: 20px 24px;
    display: grid;
    gap: 13px;
    font-size: 12px;
}

.receipt > div { display: grid; grid-template-columns: 105px 1fr; gap: 10px; }
.receipt dt { color: var(--muted-deep); }
.receipt dd { margin: 0; overflow-wrap: anywhere; }

/* ---------- footer ---------- */
.footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid var(--line);
    margin-top: 32px;
    padding-top: 19px;
    color: var(--muted);
    font-size: 10px;
    gap: 15px;
    flex-wrap: wrap;
}

/* ---------- time up overlay ---------- */
.time-up-overlay {
    position: fixed;
    inset: 0;
    background: #17372BDD;
    display: grid;
    place-items: center;
    padding: 20px;
    z-index: 2000;
    color: var(--ink);
}

.time-up-card {
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 19px;
    padding: 32px 34px;
    max-width: 430px;
    text-align: center;
}

.time-up-card h2 { font-size: 24px; font-weight: 500; margin: 9px 0 10px; }
.time-up-card p { font-size: 13px; line-height: 1.9; color: var(--muted); margin-bottom: 18px; }

/* ---------- dialog ---------- */
#flow-dialog {
    border: 1px solid var(--line);
    border-radius: 19px;
    padding: 27px;
    background: var(--paper);
    color: var(--ink);
    width: 470px;
    max-width: calc(100% - 28px);
    max-height: 90dvh;
    box-shadow: 0 22px 100px #1537232b;
}

#flow-dialog::backdrop { background: #17372B55; backdrop-filter: blur(4px); }
#flow-dialog h2 { font-size: 22px; font-weight: 500; margin: 9px 0 13px; }
#flow-dialog p { font-size: 13px; line-height: 1.9; color: var(--muted); white-space: pre-line; }

.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 24px; }

/* ---------- screen reader only ---------- */
.sr {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}

/* ---------- responsive ---------- */
@media (max-width: 1280px) {
    .page { padding: 28px 30px; }
}

@media (max-width: 1000px) {
    .grid { grid-template-columns: minmax(0, 1fr) 250px; gap: 20px; }
    .exam-grid { grid-template-columns: minmax(0, 1fr) 280px; }
    .hero h1 { font-size: 27px; }
    .hero-copy { max-width: 85%; }
    .botanical { opacity: .45; right: -20px; }
    .question-inner { padding: 24px; }
    .option { font-size: 14px; }
}

@media (max-width: 760px) {
    body.pt-page .site-header { height: 68px; padding: 0 20px; gap: 14px; }
    body.pt-page .site-logo { font-size: 24px; letter-spacing: -1px; max-width: calc(100% - 140px); }
    body.pt-page .site-logo::after { width: 7px; height: 7px; }
    .page { padding: 23px 20px; }
    .grid { grid-template-columns: 1fr; }
    .intro-aside { display: none; }
    .hero { padding: 25px; min-height: 220px; }
    .hero-copy { max-width: 90%; }
    .hero h1 { font-size: 27px; }
    .hero p { max-width: 240px; }
    .botanical { width: 160px; height: 185px; right: -5px; opacity: .45; }
    .facts { gap: 8px; }
    .fact { padding: 13px 10px; gap: 7px; }
    .fact .iconbox { display: none; }
    .fact small { font-size: 10px; }
    .card { padding: 21px; }
    .start-fields { grid-template-columns: 1fr; gap: 15px; }
    .start-footer { align-items: flex-start; flex-direction: column; gap: 14px; }
    .start-footer .btn { width: 100%; }
    .section-head { align-items: flex-start; }
    .section-head small { font-size: 10px; }
    .test-heading { align-items: flex-start; gap: 12px; }
    .test-heading h1 { font-size: 21px; }
    .test-heading .subtle { font-size: 11px; }
    .timer { min-width: 108px; padding: 10px 13px; }
    .timer strong { font-size: 25px; }
    .timer small { font-size: 9px; }
    .question-card { padding: 0; }
    .question-inner { padding: 23px 20px; }
    .question-inner h2 { font-size: 21px; }
    .section-band { padding: 14px 20px; }
    .section-band span:last-child { font-size: 9px; }
    .option { padding: 20px 14px; gap: 12px; font-size: 15px; min-height: 113px; }
    .option[aria-checked=true] { padding: 19px 13px; }
    .option-letter { width: 26px; height: 28px; }
    .question-foot { padding: 15px 20px; }
    .question-foot .btn { padding: 8px 11px; }
    .identity { margin-top: 15px; gap: 8px; }
    .identity-email { flex-basis: 100%; padding-left: 38px; margin-top: -11px; }
    .dots { grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 6px; }
    .dot { height: 44px; }
    .navigator { padding: 21px; }
    .finish { padding: 28px 21px; margin: 15px auto; }
    .finish h1 { font-size: 25px; }
    .receipt { padding: 18px; }
    .receipt > div { grid-template-columns: 75px 1fr; font-size: 11px; }
    .footer { align-items: flex-start; flex-direction: column; gap: 4px; }
    .state-card { padding: 32px 20px; }
    .page-top .eyebrow { font-size: 9px; letter-spacing: .08em; }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation: none !important;
        transition: none !important;
        scroll-behavior: auto !important;
    }
}
