/* DynamicForm "modern" theme: a flat, white, mobile-first look for the public pages.

   Every public form, thank-you and payment page loads it after form.css (PublicTheme.razor), with
   the Pretendard font. A form changes its colour from Form settings -> CSS, e.g.
       :root { --df-accent: #0f766e; }
   and keeps the classic look by writing  df-theme: classic  anywhere in that CSS (a comment will do).

   What it styles:
   - the header, title, intro and footer on one column: 1000px wide for a form with section
     headings, 760px for a single-column form; 16px side gutters on a phone;
   - sections (HTML blocks marked "Section heading"): the heading with "1 / 6" beside its fields
     from 768px up, above them on a phone;
   - two-language labels ("성함 / Full Name") as a bold first language and a grey second one;
   - 48px fields and buttons (thumb-sized, no zoom on iPhone), repeatable rows as cards with a
     "자녀 1 Child 1" title, choices as buttons;
   - multi-step forms (Back / Next), embedded forms (?embed=1, no header), thank-you and payment pages;
   - optional pieces a form's own script may build: .df-stepper (− 1 +) and .df-total (a total card). */

:root {
    --df-accent: #1d4ed8;
    --df-accent-soft: color-mix(in srgb, var(--df-accent) 7%, #fff);
    --df-ink: #0f172a;
    --df-muted: #475569;
    --df-line: #e2e8f0;
    --df-field-line: #7f8ba0;
    --df-sunken: #f8fafc;
    --df-hover: #f1f5f9;
    --df-danger: #b91c1c;
    --df-danger-soft: #fee2e2;
    --df-page: 62.5rem;
    --df-gutter: 1.5rem;
    --df-rail: 13rem;
    --df-rail-gap: 2.5rem;
    --df-font: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo",
               "Malgun Gothic", "Segoe UI", Roboto, "Helvetica Neue", sans-serif;

    /* the base stylesheet's tokens, pointed at the theme's */
    --ink: var(--df-ink);
    --ink-strong: var(--df-ink);
    --muted: var(--df-muted);
    --line: var(--df-line);
    --line-input: var(--df-field-line);
    --primary: var(--df-accent);
    --primary-light: var(--df-accent);
    --primary-soft: var(--df-accent-soft);
    --radius: 0.5rem;
}

@media (max-width: 40rem) {
    :root { --df-gutter: 1rem; }
}

@media (min-width: 64rem) {
    :root { --df-rail: 15rem; --df-rail-gap: 3.5rem; }
}

/* a form without section headings is one column; a narrower page keeps it easy to follow */
body:not(:has(.form-section)) { --df-page: 47.5rem; }

body {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-height: 100dvh;
    font-family: var(--df-font);
    color: var(--df-ink);
    background: #fff;
    -webkit-font-smoothing: antialiased;
    word-break: keep-all;           /* Korean breaks between words, not inside them */
    overflow-wrap: break-word;
}

button, input, select, textarea { font: inherit; }

/* ---------- two-language text: "성함 Full Name", the second language in grey ---------- */

.lbl-sep { display: none; }
.lbl-alt { font-weight: 400; color: var(--df-muted); }
.lbl-alt::before { content: " "; }     /* the space the hidden " / " leaves, where text runs inline */

/* ---------- header, page, footer ---------- */

.site-header {
    position: static;
    background: #fff;
    backdrop-filter: none;
    border-bottom: 1px solid var(--df-line);
}

.site-header__inner,
.site-footer__inner {
    max-width: var(--df-page);
    min-height: 0;
    padding: 0.875rem var(--df-gutter);
}

.brand { gap: 0.75rem; min-width: 0; color: var(--df-ink); }
.brand__mark { flex: none; width: 2.5rem; height: 2.5rem; border-radius: 0.5rem; background: var(--df-accent); }
.brand img { max-height: 2.5rem; }
.brand__name { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 0.625rem; min-width: 0; line-height: 1.35; }
.brand__name .lbl-main { font-size: 1rem; font-weight: 700; }
.brand__name .lbl-alt { font-size: 0.875rem; font-weight: 400; }

.header-link { color: var(--df-muted); }
.header-link:hover { color: var(--df-ink); background: var(--df-hover); }

.page-main { flex: 1 0 auto; padding: 0 var(--df-gutter) 5.5rem; }

/* embedded in another site (?embed=1): no header above, so less air around the form */
.page-main:first-child { padding-top: 0.5rem; padding-bottom: 1.5rem; }
.page-main:first-child .form-title { padding-top: 1rem; }

.form-card {
    max-width: calc(var(--df-page) - 2 * var(--df-gutter));
    padding: 0;
    background: transparent;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    container-type: inline-size;    /* fields pair up by the room they have, not the screen */
}
.form-card > form:first-child { padding-top: 1rem; }      /* title hidden */

.site-footer { background: #fff; color: var(--df-muted); font-size: 0.875rem; line-height: 1.5; }
.site-footer__inner { flex-wrap: wrap; justify-content: space-between; gap: 0.375rem 1.5rem; padding-block: 1.25rem; }
.site-footer a { color: var(--df-accent); }
.site-footer a:hover { color: var(--df-ink); }

/* ---------- title and intro ---------- */

.form-title {
    margin: 0;
    padding-top: clamp(2.25rem, 7vw, 3.5rem);
    text-align: left;
    font-size: clamp(1.75rem, 5vw, 2.375rem);
    line-height: 1.2;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--df-ink);
}
.form-title .lbl-alt {
    display: block;
    margin-top: 0.375rem;
    font-size: clamp(1.0625rem, 2.6vw, 1.25rem);
    line-height: 1.4;
    font-weight: 500;
    letter-spacing: 0;
}
.form-title .lbl-alt::before { content: none; }

/* what is not in a section: the intro of a sectioned form, or the whole of a single-column one */
.form-step > .grid,
.form-step > .group-block,
.form-card > .html-block { margin-top: 1.5rem; }
.form-card:has(.form-section) .form-step > .grid { max-width: 40rem; }

/* a multi-step form's step heading */
.step-title { margin: 2rem 0 0; font-size: 1.3125rem; line-height: 1.3; font-weight: 700; letter-spacing: -0.01em; color: var(--df-ink); }
.step-description { margin: 0.375rem 0 0; font-size: 0.9375rem; line-height: 1.6; }

.html-block .df-lead { margin: 0; font-size: 1rem; line-height: 1.65; }
.html-block .df-alt { margin: 0.25rem 0 0; font-size: 0.9375rem; line-height: 1.6; color: var(--df-muted); }
.html-block .df-note { margin: 1.25rem 0 0; font-size: 0.875rem; line-height: 1.6; color: var(--df-muted); }
.html-block .df-optional { font-size: 0.8125rem; font-weight: 400; color: var(--df-muted); white-space: nowrap; }

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

.form-section {
    margin: 0;
    padding: 2.5rem 0;
    border-top: 1px solid var(--df-line);
}
.form-step > .form-section:first-of-type { margin-top: 2.75rem; }

.form-section__head[data-sections]::before {
    content: attr(data-section) " / " attr(data-sections);
    display: block;
    margin-bottom: 0.375rem;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--df-accent);
    font-variant-numeric: tabular-nums;
}
.form-section__head h2,
.form-section__head h3 {
    margin: 0;
    font-size: 1.3125rem;
    line-height: 1.3;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--df-ink);
}
.form-section__head .df-sub { margin: 0.125rem 0 0; font-size: 0.9375rem; line-height: 1.5; color: var(--df-muted); }
.form-section__head .df-text { margin: 1rem 0 0; max-width: 32.5rem; font-size: 0.9375rem; line-height: 1.65; }
.form-section__head .df-alt { margin: 0.375rem 0 0; max-width: 32.5rem; font-size: 0.875rem; line-height: 1.6; }

.form-section__body {
    container-type: inline-size;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    margin-top: 1.5rem;
}

@media (min-width: 48rem) {
    .form-section {
        display: grid;
        grid-template-columns: minmax(0, var(--df-rail)) minmax(0, 1fr);
        column-gap: var(--df-rail-gap);
    }
    .form-section__body { margin-top: 0; }
}

/* fields sit side by side only where their column is wide enough, phone or not */
.form-card .grid { gap: 1.5rem 1.25rem; }
.form-card .col { grid-column: span 12 / span 12; }

@container (min-width: 27rem) {
    .form-card .col-3 { grid-column: span 3 / span 3; }
    .form-card .col-4 { grid-column: span 4 / span 4; }
    .form-card .col-6 { grid-column: span 6 / span 6; }
    .form-card .col-8 { grid-column: span 8 / span 8; }
}

/* ---------- fields ---------- */

.col { display: flex; flex-direction: column; gap: 0.5rem; min-width: 0; }

.field-label {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.125rem 0.5rem;
    margin: 0;
    font-size: 0.9375rem;
    font-weight: 600;
    line-height: 1.4;
    color: var(--df-ink);
}
.field-letter { display: none; }
.required { margin-left: -0.25rem; color: var(--df-danger); }

.field-help { margin: 0; font-size: 0.875rem; line-height: 1.5; color: var(--df-muted); }

.input {
    min-height: 3rem;
    padding: 0.625rem 0.875rem;
    font-size: 1rem;              /* 16px: iPhone does not zoom into the field */
    line-height: 1.5;
    color: var(--df-ink);
    background-color: #fff;
    border: 1px solid var(--df-field-line);
    border-radius: 0.5rem;
}
.input::placeholder { color: transparent; }   /* the label says what to type; "Enter your answer..." adds nothing */
.input:hover { border-color: #64748b; }
.input:focus {
    outline: 2px solid var(--df-accent);
    outline-offset: 1px;
    border-color: var(--df-field-line);
    box-shadow: none;
}
.input:user-invalid { border-color: var(--df-danger); box-shadow: 0 0 0 1px var(--df-danger); }
.input[readonly] { background: var(--df-sunken); }

input.input:not([type="file"]):not([type="color"]),
select.input:not([multiple]) { height: 3rem; padding-block: 0; }

input[type="number"].input { font-variant-numeric: tabular-nums; }

select.input:not([multiple]) {
    appearance: none;
    -webkit-appearance: none;
    padding-right: 2.5rem;
    text-overflow: ellipsis;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%23475569' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 6l4 4 4-4'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.875rem center;
    background-size: 1rem;
}

textarea.input { display: block; min-height: 7rem; padding-block: 0.75rem; resize: vertical; }

/* choices: up to three side by side, each as wide as its words; four or more, a list */
.choices { display: flex; flex-direction: row; flex-wrap: wrap; gap: 0.5rem; }
.choices:has(> .choice:nth-child(4)) { flex-direction: column; }
.choice {
    flex: 1 1 auto;
    min-width: min(100%, 6.5rem);
    min-height: 3rem;
    padding: 0.5rem 0.75rem;
    gap: 0.5rem;
    background: #fff;
    border: 1px solid var(--df-field-line);
    border-radius: 0.5rem;
}
.choice:hover { border-color: #64748b; background: #fff; }
.choice:has(input:checked) { border-color: var(--df-accent); background: var(--df-accent-soft); box-shadow: inset 0 0 0 1px var(--df-accent); }
.choice:has(input:focus-visible) { outline: 2px solid var(--df-accent); outline-offset: 1px; }
.choice input { width: 1.125rem; height: 1.125rem; margin: 0; accent-color: var(--df-accent); }
.choice span { font-size: 1rem; font-weight: 400; }

/* ---------- repeatable groups: one card per person ---------- */

.group-block { margin: 0; padding: 0; border: 0; }
.form-step > .group-block { margin-top: 1.5rem; }

/* inside a section the section heading names the group; the h3 stays for screen readers */
.form-section__body .group-block > h3 {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
}

.group-rows { display: flex; flex-direction: column; gap: 1rem; counter-reset: df-row; }
.group-rows > .group-row + .group-row { margin-top: 0; }

.grid.group-row {
    counter-increment: df-row;
    position: relative;
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 0.75rem 1rem;
    padding: 1rem 1.25rem 1.5rem;
    background: var(--df-sunken);
    border: 0;
    border-radius: 1rem;
}

.group-row__title {
    display: flex;
    flex: 1 1 100%;
    flex-wrap: wrap;
    align-items: center;
    gap: 0 0.5rem;
    min-height: 2.75rem;
    margin: 0;
    padding-right: 6.5rem;          /* room for Remove */
    font-size: 1rem;
    font-weight: 700;
    line-height: 1.3;
}
.group-row__title .lbl-main::after,
.group-row__title .lbl-alt::after { content: " " counter(df-row); }
.group-row__title .lbl-alt::before { content: none; }

.group-row > .col { flex: 2 1 11rem; }
.group-row > .col-3 { flex: 1 1 5.5rem; }
.group-row > .col-6 { flex: 1 1 14rem; }
.group-row > .col-8 { flex: 3 1 16rem; }
.group-row > .col-12 { flex: 1 1 100%; }

.group-row__actions { position: absolute; top: 1rem; right: 0.5rem; width: auto; padding: 0; }
.group-row__remove {
    min-height: 2.75rem;
    padding: 0 0.75rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--df-danger);
    background: transparent;
    border: 0;
    border-radius: 0.5rem;
}
.group-row__remove:hover { color: var(--df-danger); background: var(--df-danger-soft); border: 0; }
.group-row__remove:focus-visible { outline: 2px solid var(--df-danger); outline-offset: 1px; }

.group-add {
    align-self: flex-start;
    min-height: 3rem;
    margin-top: 1rem;
    padding: 0 1.125rem;
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--df-ink);
    background: #fff;
    border: 1px solid var(--df-field-line);
    border-radius: 0.5rem;
}
.group-add:hover { color: var(--df-ink); background: var(--df-hover); border-color: var(--df-field-line); }
.group-add:focus-visible { outline: 2px solid var(--df-accent); outline-offset: 1px; }

/* ---------- − 1 + stepper (built by a form's script around a number dropdown) ---------- */

.df-stepper {
    display: inline-flex;
    align-self: flex-start;
    background: #fff;
    border: 1px solid var(--df-field-line);
    border-radius: 0.5rem;
    overflow: hidden;
}
.df-stepper__btn {
    width: 3.25rem;
    height: 3rem;
    padding: 0;
    font-size: 1.375rem;
    line-height: 1;
    color: var(--df-ink);
    background: transparent;
    border: 0;
    cursor: pointer;
    touch-action: manipulation;     /* quick taps are taps, not a double-tap zoom */
}
.df-stepper__btn:hover:not(:disabled) { background: var(--df-hover); }
.df-stepper__btn:disabled { color: #a3acb9; cursor: not-allowed; }
.df-stepper__btn:focus-visible { outline: 2px solid var(--df-accent); outline-offset: -2px; }
.df-stepper__value {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    min-width: 5.25rem;
    height: 3rem;
    font-size: 1.0625rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    border-inline: 1px solid var(--df-line);
}
.df-stepper__unit { font-weight: 400; color: var(--df-muted); }

/* ---------- total card (built by a form's script around its total field) ---------- */

.col.df-total {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: "label amount" "line amount" "note note";
    gap: 0 1.5rem;
    padding: 1.5rem;
    background: var(--df-sunken);
    border-radius: 1rem;
}
.df-total > .field-label { grid-area: label; }
.df-total__line { grid-area: line; margin: 0.375rem 0 0; font-size: 0.875rem; line-height: 1.5; color: var(--df-muted); font-variant-numeric: tabular-nums; }
.df-total__amount { grid-area: amount; align-self: end; margin: 0; font-size: 2.25rem; line-height: 1; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.df-total__note { grid-area: note; margin: 1.125rem 0 0; padding-top: 1rem; border-top: 1px solid var(--df-line); overflow-wrap: anywhere; }
.df-total__note p { margin: 0; font-size: 0.875rem; line-height: 1.6; color: var(--df-ink); }
.df-total__note p + p { margin-top: 0.25rem; color: var(--df-muted); }
.df-total__note strong { font-weight: 600; }

@container (max-width: 22rem) {
    .col.df-total { grid-template-columns: minmax(0, 1fr); grid-template-areas: "label" "line" "amount" "note"; }
    .df-total__amount { margin-top: 0.875rem; }
}

/* ---------- multi-step: Back, "Step 1 of 3", Next ---------- */

.wizard-nav { flex-wrap: wrap; gap: 0.75rem 1rem; margin-top: 2rem; padding-top: 1.5rem; border-top: 1px solid var(--df-line); }
.wizard-nav .btn {
    justify-content: center;
    min-height: 3rem;
    padding: 0 1.25rem;
    font-size: 1rem;
    font-weight: 600;
    color: var(--df-ink);
    border-color: var(--df-field-line);
    border-radius: 0.5rem;
}
.wizard-nav .btn:hover { color: var(--df-ink); background: var(--df-hover); border-color: var(--df-field-line); }
.wizard-nav .wizard-next { min-width: 9rem; color: #fff; background: var(--df-accent); border-color: var(--df-accent); }
.wizard-nav .wizard-next:hover { color: #fff; background: var(--df-accent); border-color: var(--df-accent); filter: brightness(0.9); }
.wizard-nav .btn:focus-visible { outline: 2px solid var(--df-accent); outline-offset: 2px; }
.wizard-status { font-size: 0.875rem; color: var(--df-muted); font-variant-numeric: tabular-nums; }
.wizard-nav + .form-actions { margin-top: 1rem; padding-top: 0; border-top: 0; }

@media (max-width: 36rem) {
    .wizard-nav .wizard-next { flex: 1 1 auto; }
}

/* ---------- submit ---------- */

.form-actions {
    flex-wrap: wrap;
    justify-content: flex-start;
    align-items: center;
    gap: 0.875rem 1.5rem;
    margin-top: 0;
    padding-top: 2rem;
    border-top: 1px solid var(--df-line);
}
@media (min-width: 48rem) {
    .form-card:has(.form-section) .form-actions { padding-left: calc(var(--df-rail) + var(--df-rail-gap)); }
}

.btn-submit {
    justify-content: center;
    min-width: 15rem;
    min-height: 3.25rem;
    padding: 0 1.75rem;
    font-size: 1rem;
    font-weight: 600;
    background: var(--df-accent);
    border-radius: 0.5rem;
    box-shadow: none;
}
.btn-submit:hover:not(:disabled) { filter: brightness(0.9); }
.btn-submit:focus-visible { outline: 2px solid var(--df-accent); outline-offset: 2px; }

@media (max-width: 36rem) {
    .btn-submit { width: 100%; }
}

.df-submit-total { margin: 0; font-size: 0.9375rem; line-height: 1.4; color: var(--df-muted); font-variant-numeric: tabular-nums; }
.df-submit-total strong { font-weight: 700; color: var(--df-ink); }

.df-reset { display: flex; flex: 1 1 100%; flex-wrap: wrap; align-items: center; gap: 0 1rem; font-size: 0.875rem; line-height: 1.5; }
.df-link {
    min-height: 2.75rem;
    padding: 0;
    font-size: 0.875rem;
    color: var(--df-muted);
    background: none;
    border: 0;
    text-decoration: underline;
    text-underline-offset: 3px;
    cursor: pointer;
}
.df-link:hover { color: var(--df-ink); }
.df-link--danger { font-weight: 600; color: var(--df-danger); }
.df-link--danger:hover { color: var(--df-danger); }

/* ---------- messages, read-back and closed pages ---------- */

.form-errors,
.submitted-banner { margin: 1.5rem 0 0; border-radius: 0.75rem; }
.form-errors { color: var(--df-danger); }

.closed-panel { max-width: 37.5rem; padding: clamp(3rem, 9vw, 4.5rem) 0 clamp(3.5rem, 10vw, 6rem); text-align: left; }
.closed-panel h2 { margin: 0; font-size: clamp(1.625rem, 5vw, 2.125rem); line-height: 1.25; letter-spacing: -0.02em; }
.closed-panel p { max-width: none; margin: 0.75rem 0 0; font-size: 1rem; line-height: 1.65; color: var(--df-muted); }

.answer__label { text-transform: none; letter-spacing: 0; font-size: 0.875rem; }
