/* =========================================================================
   style.css — base layout, tokens, components
   ========================================================================= */

:root {
    --background: #ffffff;
    --surface: #f7f8fa;
    --surface-raised: #ffffff;
    --text: #16181c;
    --muted: #5c6470;
    --border: #dfe3e8;
    --accent: #0b57d0;
    --accent-soft: #e8f0fe;
    --focus: #0b57d0;
    --brand-accent: #d92d20;

    /* Card surface: a low-contrast top-to-bottom wash, not a decorative gradient. */
    --card-top: #ffffff;
    --card-bottom: #f4f6f9;
    --card-hover-top: #ffffff;
    --card-hover-bottom: #eef2f8;
    --shadow-card: 0 1px 2px rgba(16, 24, 40, 0.04);
    --shadow-hover: 0 6px 18px rgba(11, 87, 208, 0.10);
    --shadow-open: 0 8px 24px rgba(11, 87, 208, 0.12);

    --radius: 14px;
    --radius-small: 10px;
    --space: 16px;
    --content-width: 960px;
    --transition: 200ms ease;
}

[data-theme="dark"] {
    --background: #101317;
    --surface: #171b21;
    --surface-raised: #1c2128;
    --text: #e6e9ee;
    --muted: #9aa4b2;
    --border: #2a313a;
    --accent: #7aa7f0;
    --accent-soft: #1d2a3f;
    --focus: #7aa7f0;
    --brand-accent: #ff6b60;

    --card-top: #1f242c;
    --card-bottom: #171b21;
    --card-hover-top: #242a33;
    --card-hover-bottom: #1b2027;
    --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.30);
    --shadow-hover: 0 6px 20px rgba(0, 0, 0, 0.38), 0 0 0 1px rgba(122, 167, 240, 0.16);
    --shadow-open: 0 8px 26px rgba(0, 0, 0, 0.42), 0 0 0 1px rgba(122, 167, 240, 0.22);
}

* {
    box-sizing: border-box;
}

[hidden] {
    display: none !important;
}

html {
    -webkit-text-size-adjust: 100%;
    /* Keeps anchored content clear of the sticky header. */
    scroll-padding-top: 72px;
}

body {
    margin: 0;
    background: var(--background);
    color: var(--text);
    font-family: "Google Sans", "Noto Sans Thai", "IBM Plex Sans Thai", "Sarabun",
        "Leelawadee UI", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 16px;
    line-height: 1.55;
    overflow-x: hidden;
}

html[lang="th"] body {
    line-height: 1.7;
}

html[lang="th"] .estimate__value,
html[lang="th"] h1,
html[lang="th"] h2,
html[lang="th"] h3 {
    line-height: 1.35;
}

h1, h2, h3 {
    font-weight: 500;
    line-height: 1.25;
    margin: 0 0 8px;
}

p {
    margin: 0 0 12px;
}

a {
    color: var(--accent);
}

.wrap {
    width: 100%;
    max-width: var(--content-width);
    margin: 0 auto;
    padding: 0 var(--space);
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

.skip-link {
    position: absolute;
    left: -9999px;
    top: 0;
    background: var(--surface-raised);
    color: var(--text);
    padding: 12px 16px;
    z-index: 10;
}

.skip-link:focus {
    left: 8px;
    top: 8px;
}

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

/* --- header ------------------------------------------------------------ */

.app-header {
    border-bottom: 1px solid var(--border);
    background: var(--background);
    position: sticky;
    top: 0;
    z-index: 5;
}

.app-header__inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 56px;
}

.brand {
    font-size: 15px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    font-weight: 500;
}

.brand__accent {
    color: var(--brand-accent);
    font-weight: 700;
}

.app-header__actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.lang-button {
    min-width: 52px;
    height: 44px;
    padding: 0 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font: inherit;
    font-size: 13px;
    font-weight: 500;
    letter-spacing: 0.04em;
    background: transparent;
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 22px;
    cursor: pointer;
}

.lang-button:hover {
    background: var(--surface);
}

.icon-button {
    width: 44px;
    height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    background: transparent;
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 50%;
    cursor: pointer;
}

.icon-button:hover {
    background: var(--surface);
}

/* --- hero -------------------------------------------------------------- */

.hero {
    padding: 40px 0 8px;
}

.hero h1 {
    font-size: 32px;
}

.hero__lead {
    color: var(--muted);
    max-width: 52ch;
}

.hero__note {
    font-size: 13px;
    color: var(--muted);
    margin: 0;
}

/* --- sections ---------------------------------------------------------- */

section {
    margin-bottom: 40px;
}

.section-title {
    font-size: 20px;
    margin: 32px 0 16px;
}

.step {
    display: block;
    font-size: 12px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 2px;
}

.stage {
    animation: reveal var(--transition);
}

@keyframes reveal {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: none; }
}

/* --- topic cards ------------------------------------------------------- */

/* Single-column stack at every width: reading flows top-to-bottom and an
   expanding panel never shifts a neighbouring column. Width comes from .wrap,
   so topic cards line up with the estimate, forecast and summary blocks. */
.cards {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.card {
    background: linear-gradient(180deg, var(--card-top) 0%, var(--card-bottom) 100%);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow-card);
    transition: background var(--transition), border-color var(--transition), box-shadow var(--transition);
}

.card:hover {
    background: linear-gradient(180deg, var(--card-hover-top) 0%, var(--card-hover-bottom) 100%);
    border-color: var(--accent);
    box-shadow: var(--shadow-hover);
}

/* Keyboard focus gets the same affordance as hover. */
.card:focus-within {
    border-color: var(--accent);
    box-shadow: var(--shadow-hover);
}

/* Expanded: left accent rail drawn as an inset shadow, so nothing shifts. */
.card.is-open {
    border-color: var(--accent);
    box-shadow: inset 3px 0 0 0 var(--accent), var(--shadow-open);
}

/* Has selections but is collapsed: accent border only, no rail. */
.card.is-selected:not(.is-open) {
    border-color: var(--accent);
}

.card__head {
    width: 100%;
    display: flex;
    align-items: flex-start;
    gap: 14px;
    min-height: 72px;
    padding: 16px;
    background: transparent;
    border: 0;
    color: inherit;
    font: inherit;
    text-align: left;
    cursor: pointer;
}

.card__number {
    font-size: 13px;
    font-weight: 500;
    color: var(--muted);
    min-width: 28px;
    padding-top: 2px;
}

.card__text {
    flex: 1;
}

.card__title {
    font-size: 18px;
    font-weight: 500;
    display: block;
}

.card__summary {
    display: block;
    font-size: 14px;
    color: var(--muted);
}

.card__count {
    display: inline-block;
    margin-top: 4px;
    font-size: 12px;
    color: var(--accent);
}

.card__chevron {
    color: var(--muted);
    transition: transform var(--transition);
    padding-top: 2px;
}

.card__head[aria-expanded="true"] .card__chevron {
    transform: rotate(180deg);
}

.card__panel {
    display: grid;
    grid-template-rows: 0fr;
    transition: grid-template-rows var(--transition);
}

.card__panel.is-open {
    grid-template-rows: 1fr;
}

/* Collapsed panels stay out of the tab order. */
.card__panel > div {
    overflow: hidden;
    visibility: hidden;
}

.card__panel.is-open > div {
    visibility: visible;
}

.card__options {
    border-top: 1px solid var(--border);
    padding: 8px 16px 16px;
    margin: 0;
}

.option {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    padding: 12px 0;
    min-height: 44px;
    cursor: pointer;
    border-bottom: 1px solid var(--border);
}

.option:last-of-type {
    border-bottom: 0;
}

.option input {
    width: 20px;
    height: 20px;
    margin: 2px 0 0;
    accent-color: var(--accent);
    flex-shrink: 0;
}

.option__label {
    font-weight: 500;
    display: block;
}

.option__description {
    font-size: 14px;
    color: var(--muted);
    display: block;
}

/* Line items shown under an option, one label / amount pair per row. */
.option__details {
    display: block;
    margin-top: 8px;
    padding-left: 10px;
    border-left: 2px solid var(--border);
}

.option__detail {
    display: flex;
    gap: 12px;
    justify-content: space-between;
    align-items: baseline;
    font-size: 13px;
    line-height: 1.6;
    color: var(--muted);
}

.option__detail-value {
    flex-shrink: 0;
    font-variant-numeric: tabular-nums;
    color: var(--text);
}

.note {
    margin-top: 12px;
    padding: 12px;
    font-size: 13px;
    color: var(--muted);
    background: var(--surface);
    border-radius: var(--radius-small);
    border: 1px solid var(--border);
}

/* --- estimate ---------------------------------------------------------- */

.estimate {
    display: grid;
    gap: 12px;
    padding: 20px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.estimate__block {
    display: flex;
    flex-direction: column;
}

.estimate__label {
    font-size: 12px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--muted);
}

.estimate__value {
    font-size: 34px;
    font-weight: 500;
    line-height: 1.15;
}

.estimate__value--secondary {
    font-size: 24px;
}

.estimate__value--tertiary {
    font-size: 20px;
}

.estimate__note {
    font-size: 12px;
    color: var(--muted);
    margin-top: 2px;
}

.estimate__block--headline {
    grid-column: 1 / -1;
}

.breakdown {
    margin-top: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-small);
    background: var(--surface-raised);
}

.breakdown > summary {
    padding: 12px 16px;
    min-height: 44px;
    cursor: pointer;
    font-size: 15px;
}

.breakdown-group {
    padding: 0 16px 12px;
}

.breakdown-group h4 {
    font-size: 13px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--muted);
    margin: 12px 0 6px;
    font-weight: 500;
}

.breakdown-line {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    font-size: 14px;
    padding: 4px 0;
    border-bottom: 1px dashed var(--border);
}

.breakdown-line:last-child {
    border-bottom: 0;
}

.breakdown-line__amounts {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    white-space: nowrap;
}

.breakdown-line__monthly {
    color: var(--muted);
}

/* Service facts and a la carte heading inside a topic card */
.option-group {
    font-size: 12px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--muted);
    font-weight: 500;
    margin: 16px 0 4px;
}

.facts__list {
    margin: 0 0 8px;
    font-size: 14px;
}

.facts__list dt {
    font-weight: 500;
    margin-top: 8px;
}

.facts__list dd {
    margin: 0;
    color: var(--muted);
}

/* Credit line picker, shown only while a deposit applies */
.credit {
    margin-top: 16px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-small);
    background: var(--surface);
}

.credit__label {
    display: block;
    font-size: 12px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 6px;
}

.credit__select {
    width: 100%;
    min-height: 44px;
    padding: 8px 12px;
    font: inherit;
    color: var(--text);
    background: var(--surface-raised);
    border: 1px solid var(--border);
    border-radius: var(--radius-small);
}

.credit__deposit {
    margin: 8px 0 4px;
    font-weight: 500;
}

.credit__note {
    margin: 0;
    font-size: 13px;
    color: var(--muted);
}

/* --- forecast ---------------------------------------------------------- */

.forecast {
    display: grid;
    gap: 12px;
    list-style: none;
    padding: 0;
    margin: 0;
    counter-reset: none;
}

.forecast__item {
    background: var(--surface-raised);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
}

.forecast__title {
    font-size: 12px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--muted);
}

.forecast__theme {
    font-size: 18px;
    font-weight: 500;
    display: block;
    margin-bottom: 8px;
}

.forecast__list {
    margin: 0;
    padding-left: 18px;
    font-size: 14px;
    color: var(--text);
}

.forecast__list li {
    margin-bottom: 6px;
}

.forecast__empty {
    font-size: 14px;
    color: var(--muted);
}

/* --- summary ----------------------------------------------------------- */

.summary {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    background: var(--surface-raised);
}

.summary__heading {
    font-size: 12px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--muted);
}

.summary-topic {
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}

.summary-topic:last-of-type {
    border-bottom: 0;
}

.summary-topic__title {
    display: block;
    font-weight: 500;
}

.summary-topic__options {
    display: block;
    color: var(--muted);
    font-size: 14px;
}

.summary__totals {
    display: grid;
    gap: 12px;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 2px solid var(--border);
}

.summary__totals > div {
    display: flex;
    flex-direction: column;
}

/* --- actions ----------------------------------------------------------- */

.actions {
    display: flex;
    gap: 12px;
    margin-top: 20px;
    flex-wrap: wrap;
}

.button {
    min-height: 48px;
    padding: 12px 20px;
    border-radius: var(--radius-small);
    border: 1px solid var(--border);
    background: var(--surface-raised);
    color: var(--text);
    font: inherit;
    font-weight: 500;
    cursor: pointer;
    flex: 1 1 auto;
}

.button:hover {
    background: var(--surface);
}

.button--primary {
    background: var(--accent);
    border-color: var(--accent);
    color: #ffffff;
}

[data-theme="dark"] .button--primary {
    color: #0d1117;
}

.button--primary:hover {
    filter: brightness(0.95);
    background: var(--accent);
}

/* --- contact + disclaimer --------------------------------------------- */

.contact {
    margin-top: 32px;
    text-align: center;
}

.contact h3 {
    font-size: 12px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--muted);
}

.contact__qr {
    width: 180px;
    max-width: 60vw;
    margin: 12px auto 8px;
    padding: 8px;
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: var(--radius-small);
}

.contact__qr svg {
    display: block;
    width: 100%;
    height: auto;
}

.contact__caption {
    font-size: 14px;
    color: var(--muted);
    margin-bottom: 4px;
}

.disclaimer {
    margin-top: 32px;
    font-size: 13px;
    color: var(--muted);
    border-top: 1px solid var(--border);
    padding-top: 16px;
}

.disclaimer h3 {
    font-size: 12px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.disclaimer ul {
    padding-left: 18px;
    margin: 0 0 12px;
}

.disclaimer li {
    margin-bottom: 6px;
}

.empty-hint {
    color: var(--muted);
    font-size: 14px;
    padding: 8px 0 24px;
}

.app-footer {
    border-top: 1px solid var(--border);
    padding-top: 16px;
    padding-bottom: 32px;
    font-size: 13px;
    color: var(--muted);
}

.print-header {
    display: none;
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 1ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 1ms !important;
    }
}
