/* True Home Solar. Mobile first. Colours, sizes and radii are read off the UX/UI frames (docs/design/) and are
   approximate until the UX/UI team sends its design tokens (docs/features/ux-ui.md, request 2). */
/* Font: True's BetterTogether, the same files as Prebook (copied, not linked). Prebook declares four families
   (better_togetherbold ...); here it is one family with four weights so font-weight works. Only 300, 400, 500
   and 700 exist, so the 600 and 800 used below show Bold. */
@font-face {
  font-family: "Better Together";
  src: url("../fonts/bettertogether-light-webfont.woff2") format("woff2"),
    url("../fonts/bettertogether-light-webfont.woff") format("woff");
  font-weight: 300;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Better Together";
  src: url("../fonts/bettertogether-regular-webfont.woff2") format("woff2"),
    url("../fonts/bettertogether-regular-webfont.woff") format("woff");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Better Together";
  src: url("../fonts/bettertogether-medium-webfont.woff2") format("woff2"),
    url("../fonts/bettertogether-medium-webfont.woff") format("woff");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Better Together";
  src: url("../fonts/bettertogether-bold-webfont.woff2") format("woff2"),
    url("../fonts/bettertogether-bold-webfont.woff") format("woff");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --red: #e00000;
  --red-dark: #b30000;
  --red-tint: #fff0f0;
  --ink: #212121;
  --muted: #6b7680;
  --line: #c9cdd2;
  --grey: #e3e5e8;
  --page: #fafafa;
  --ok: #0a3;
  --radius: 12px;
}

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

[hidden] {
  display: none !important;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  margin: 0;
  font-family: "Better Together", "Noto Sans Thai", "Sarabun", system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--page);
  line-height: 1.5;
}

img {
  max-width: 100%;
}

.container {
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
  padding: 0 16px;
}

/* Header and footer are drawn by the shared True script into these two elements. The header's height is
   reserved so the page does not jump when it appears; the footer sits at the bottom of a short page. */
#header_obj {
  min-height: 72px;
}

@media (min-width: 1024px) {
  #header_obj {
    min-height: 102px;
  }
}

#footer_obj {
  margin-top: auto;
}

.form-page {
  margin-bottom: 40px;
}

/* Hero: the banner image(s) from config/hero.php. One <picture> per slide, the mobile image under 768px (ecommerce's
   MicrositeBanner); the box ratio is fixed so the page does not jump while an image loads. Two or more slides slide by
   themselves (hero.js) and get dots. */
.hero {
  position: relative;
  overflow: hidden;
  background: #f1f3f5;
}

.hero-track {
  display: flex;
  transition: transform .5s ease;
}

.hero-slide {
  flex: 0 0 100%;
  display: block;
  aspect-ratio: 1 / 1;
}

.hero-slide img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

@media (min-width: 768px) {
  .hero-slide {
    aspect-ratio: 1920 / 618;
  }
}

@media (prefers-reduced-motion: reduce) {
  .hero-track {
    transition: none;
  }
}

.hero-dots {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 8px;
  display: flex;
  justify-content: center;
}

/* an 8px dot inside a 24px-high tap target */
.hero-dot {
  width: 24px;
  height: 24px;
  padding: 0;
  background: none;
  border: 0;
  cursor: pointer;
}

.hero-dot::before {
  content: "";
  display: block;
  width: 8px;
  height: 8px;
  margin: 0 auto;
  border-radius: 50%;
  background: rgba(255, 255, 255, .6);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .25);
}

/* the current slide is a solid white pill, visible on any banner colour */
.hero-dot[aria-current="true"]::before {
  width: 20px;
  border-radius: 4px;
  background: #fff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .45);
}

.hero-dot:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: -2px;
  border-radius: 50%;
}

/* Form page */
.form-page {
  padding-top: 8px;
  padding-bottom: 8px;
}

.back-row {
  margin: 8px 0 0;
}

.back {
  color: var(--ink);
  text-decoration: none;
  font-weight: 600;
  font-size: 18px;
}

.form-title {
  margin: 24px 0 4px;
  text-align: center;
  font-size: 26px;
}

.form-subtitle {
  margin: 0 auto 20px;
  max-width: 640px;
  text-align: center;
  color: var(--muted);
}

.form-subtitle a {
  color: var(--muted); /* the same grey as the rest of the subtitle; the underline marks the links */
  text-decoration: underline;
}

/* The new lines in the text (\n) are shown from 768px; on a phone the text flows as one paragraph, in full. */
@media (min-width: 768px) {
  .form-subtitle {
    white-space: pre-line;
  }
}

.stepper {
  display: flex;
  justify-content: center;
  align-items: center;
  list-style: none;
  margin: 0 0 20px;
  padding: 0;
}

.stepper li {
  display: flex;
  align-items: center;
}

.stepper li+li::before {
  content: "";
  width: 48px;
  border-top: 2px dotted #aaa;
  margin: 0 8px;
}

.stepper li span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #aab0b6;
  color: #fff;
  font-size: 13px;
  font-weight: 700;
}

.stepper li.is-done span,
.stepper li.is-current span {
  background: var(--red);
}

.stepper li.is-done+li::before,
.stepper li.is-current::before {
  border-top-color: var(--red);
}

.card {
  background: #fff;
  border-radius: var(--radius);
  padding: 20px 16px 24px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .08);
}

.step-title {
  margin: 0 0 16px;
  text-align: center;
  font-size: 20px;
}

.group-title {
  margin: 20px 0 10px;
  font-size: 17px;
}

/* Fields, radios and checkboxes follow Prebook's reserve page (assets/iphone-17/css/pre-booking.css: .form-template,
   .radio-wrapper .cr-wrapper). Differences: no clear (x) button, 16px text on small screens too (below 16px iOS
   zooms the page on focus), and the card highlight on roof types. */
/* Fields: the label sits on the top border of the input; the error line sits just below it */
.field {
  position: relative;
  margin: 18px 0 32px;
}

.field label {
  position: absolute;
  top: -5px;
  left: 12px;
  z-index: 5;
  padding: 0 4px;
  background: #fff;
  font-size: 12px;
  line-height: 16px;
}

.field .req {
  color: var(--red);
}

/* A label with an (i) icon after it (field.php, 'hint'): the label and the icon sit together on the top border; the icon opens the how-to dialog (.sheet-howto) */
.field .label-row {
  position: absolute;
  top: -5px;
  left: 12px;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 4px;
  background: #fff;
}

.field .label-row label {
  position: static;
  padding: 0;
}

/* The (i) is a label, not a button (and has no "for", so it never focuses the box); tabindex makes it reachable with the keyboard */
.field .label-row .hint-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  top: 0; /* not the -5px / 12px that `.field label` gives every label */
  left: 0;
  width: 16px;
  height: 16px;
  cursor: pointer;
}

.field .hint-icon:focus-visible {
  outline: 2px solid #0a78c8;
  outline-offset: 2px;
  border-radius: 50%;
}

.field input,
.field select {
  width: 100%;
  height: 56px;
  padding: 0 46px 0 16px;
  font: inherit;
  font-size: 16px;
  color: var(--ink);
  background: #fff;
  border: 1px solid #c0c0c0;
  border-radius: 16px;
  outline: 0;
  transition: border-color .15s ease-in-out, box-shadow .15s ease-in-out;
}

/* The clear (X) of a focused box that has text (clear.js); Prebook's size. [hidden] is spelled out because display:flex would beat it */
.field .clear-field {
  position: absolute;
  top: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 56px;
  padding: 0;
  background: none;
  border: 0;
  cursor: pointer;
}

.field .clear-field[hidden] {
  display: none;
}

/* A select is drawn like the text box, with the chevron as a file (the browser's own arrow is hidden) */
.field select {
  appearance: none;
  -webkit-appearance: none;
  background: #fff url("../images/icons/chevron-down.svg") no-repeat right 12px center / 24px 24px;
  text-overflow: ellipsis;
  cursor: pointer;
}

.field select:disabled {
  background-color: #fafafa;
  border-color: #e3e5e8;
  color: rgba(48, 60, 70, .55);
  cursor: default;
}

/* The line under the area boxes that asks for a hand-made choice when a pin could not be matched */
.field-note {
  margin: -20px 4px 24px;
  color: var(--red);
  font-size: 13px;
}

.field input::placeholder {
  color: rgba(48, 60, 70, .38);
}

/* Prebook gets this focus look from Bootstrap's .form-control:focus: a soft blue glow, border unchanged */
.field input:focus,
.field select:focus {
  box-shadow: inset 0 1px 1px rgba(0, 0, 0, .075), 0 0 8px rgba(102, 175, 233, .6);
}

.field.has-error input,
.field.has-error select {
  border-color: var(--red);
}

/* Prebook keeps the blue glow here, which is hard to see against the red border; the glow turns red instead */
.field.has-error input:focus,
.field.has-error select:focus {
  box-shadow: inset 0 1px 1px rgba(0, 0, 0, .075), 0 0 8px rgba(224, 0, 0, .6);
}

.field.has-error label {
  color: var(--red);
}

.field-error {
  margin: 4px 4px 0;
  color: var(--red);
  font-size: 13px;
}

.field>.field-error {
  position: absolute;
  left: 16px;
  bottom: -18px;
  width: calc(100% - 16px);
  margin: 0;
  font-size: 12px;
  line-height: 16px;
  letter-spacing: .004em;
}

/* Radio and checkbox: the real input is hidden, .cr-input is drawn in its place (Prebook's .cr-wrapper) */
.cr-wrapper input,
.choice input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  z-index: -1;
}

.cr-input {
  position: relative;
  flex: none;
  width: 20px;
  height: 20px;
  background: #fff;
  border: 2px solid #303c46;
  border-radius: 4px;
  transition: background 250ms;
}

input[type="radio"]~.cr-input {
  border-radius: 20px;
}

.cr-input::after {
  content: "";
  position: absolute;
  display: none;
  left: 3px;
  top: 3px;
  width: 10px;
  height: 10px;
  background: #fff;
}

input[type="checkbox"]~.cr-input::after {
  clip-path: polygon(14% 44%, 0 65%, 50% 100%, 100% 16%, 80% 0%, 43% 62%);
}

input[type="radio"]~.cr-input::after {
  border-radius: 20px;
}

input:checked~.cr-input {
  background: var(--red);
  border-color: var(--red);
}

input:checked~.cr-input::after {
  display: block;
}

input:disabled~.cr-input,
input:disabled~.cr-text {
  opacity: .5;
  cursor: not-allowed;
}

.cr-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  gap: 14px;
  cursor: pointer;
}

.cr-text {
  font-size: 14px;
  line-height: 20px;
  letter-spacing: .0025em;
}

/* Step 1: the Privacy Notice (no tick) comes after the Consent tick, indented to sit under its label */
.privacy-notice {
  margin: 14px 0 0;
  padding-left: 34px; /* the 20px box and the 14px gap of .cr-wrapper */
  color: var(--ink);
  font-weight: 400;
  font-size: 12px;
  line-height: 16px;
  letter-spacing: .004em;
}

.privacy-notice a {
  color: #0a6ebd;
}

.cr-consent {
  margin-top: 24px;
  align-items: flex-start;
}

.cr-consent .cr-input {
  margin-top: 0;
}

.cr-consent .cr-text {
  font-weight: 500;
  font-size: 12px;
  line-height: 20px;
  letter-spacing: .0025em;
}

/* Roof types: image cards with a round indicator; the chosen card is outlined */
.choice-list {
  display: grid;
  gap: 10px;
}

.choice {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border: 1px solid #e6e8ea;
  border-radius: var(--radius);
  background: #fff;
  cursor: pointer;
}

.choice img {
  flex: none;
  width: 88px;
  height: auto;
  border-radius: 8px;
}

.choice-name {
  display: flex;
  flex-direction: column;
  font-weight: 600;
}

.choice-name strong {
  font-weight: 600;
}

.choice-text {
  font-weight: 400;
  font-size: 14px;
  color: var(--muted);
}

.choice:has(input:checked) {
  border-color: var(--red);
  background: var(--red-tint);
}

.radio-list {
  display: grid;
  gap: 14px;
  margin-top: 6px;
}

/* Services: Prebook's select-pay card (1px #f0f0f3 border, 6px radius, indicator on the left), the image in front of the text */
.cr-wrapper.select-pay {
  gap: 12px;
  min-height: 56px;
  padding: 16px 20px;
  border: 1px solid #f0f0f3;
  border-radius: 6px;
  background: #fff;
}

.cr-wrapper.select-pay img {
  flex: none;
  width: 64px;
  height: 64px;
}

.cr-wrapper.select-pay .choice-name {
  font-weight: 400;
}

.cr-wrapper.select-pay .choice-name strong {
  font-weight: 500;
  font-size: 16px;
}

.pay-list {
  gap: 20px;
}

.link {
  padding: 0;
  background: none;
  border: 0;
  color: #0a6ebd;
  font: inherit;
  font-size: 14px;
  text-align: left;
  cursor: pointer;
}

/* Read-only fields (latitude, longitude): they only change when a pin is confirmed, so they look inactive */
.field input[readonly] {
  background: #fafafa;
  border-color: #e3e5e8;
  color: rgba(48, 60, 70, .55);
  cursor: default;
}

.field input[readonly]:focus {
  box-shadow: none;
}

/* Step 1 map: a preview in the form. Tapping it opens the map view (.map-view) */
.map-inline {
  position: relative;
  overflow: hidden;
  margin: 0 0 8px;
  border-radius: var(--radius);
  background: #eef0f2;
  aspect-ratio: 16 / 9;
}

/* z-index 0 makes the canvas its own stacking context: Google's layers and controls (they use large z-indexes) stay inside it,
   under the buttons laid over the preview */
.map-inline-canvas {
  position: absolute;
  inset: 0;
  z-index: 0;
}

.map-open {
  position: absolute;
  inset: 0;
  z-index: 3;
  width: 100%;
  padding: 0;
  background: transparent;
  border: 0;
  cursor: pointer;
}

.map-open:disabled {
  cursor: default;
}

.map-open:focus-visible {
  outline: 3px solid var(--red);
  outline-offset: -3px;
}

/* "ใช้ตำแหน่งปัจจุบัน" on the preview: sits above the tap-to-open layer, so a tap on it does not open the map view */
.map-locate-inline {
  position: absolute;
  right: 8px;
  bottom: 8px;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  background: #fff;
  border: 0;
  border-radius: 50%;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .3);
  cursor: pointer;
}

.map-locate-inline img {
  width: 24px;
  height: 24px;
}

.map-locate-inline:disabled {
  opacity: .6;
  cursor: default;
}

.map-locate-inline:focus-visible {
  outline: 2px solid #007ad0;
  outline-offset: 2px;
}

/* Loading and error cover the preview; ready hides the cover */
.map-state {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 16px;
  background: #eef0f2;
  color: #333c46;
  text-align: center;
}

.map-state p {
  margin: 0;
}

.map-inline[data-state="ready"] .map-state {
  display: none;
}

.btn-small {
  width: auto;
  padding: 0 20px;
}

/* The map view fills the screen under the shared header (map.js sets its top from the header's height, as the
   design keeps the header on screen). The panel is a bottom sheet on a phone and a side card on a desktop. Its
   z-index sits under the dialogs (.overlay, 50) and above the page. */
.map-view {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  background: #fff;
}

body.map-view-open {
  overflow: hidden;
}

.map-view-bar {
  flex: none;
  padding: 10px 16px;
  border-bottom: 1px solid #ececec;
}

.map-back {
  padding: 4px 0;
  background: none;
  border: 0;
  font: inherit;
  font-size: 18px;
  font-weight: 600;
  cursor: pointer;
}

.map-view-body {
  position: relative;
  flex: 1;
  min-height: 0;
}

.map-view-canvas {
  position: absolute;
  inset: 0;
}

/* Place search (not in the UX/UI frames, added at the owner's request): a box at the top of the map. Google's
   suggestion list (.pac-container) is appended to the body, so it needs a z-index above the map view. */
.map-search {
  position: absolute;
  top: 12px;
  left: 12px;
  right: 12px;
  z-index: 3;
}

.map-search input {
  width: 100%;
  height: 40px;
  padding: 0 16px;
  font: inherit;
  font-size: 16px;
  color: var(--ink);
  background: #fff;
  border: 0;
  border-radius: 100px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .2);
  outline: 0;
}

/* The search box's clear (X), the form's .clear-field sized for the 40px box (map.js wires it) */
.map-search input {
  padding-right: 44px;
}

.map-search .clear-field {
  position: absolute;
  top: 0;
  right: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  background: none;
  border: 0;
  cursor: pointer;
}

.map-search .clear-field[hidden] {
  display: none;
}

.map-search input::placeholder {
  color: rgba(48, 60, 70, .55);
}

.map-search input:focus {
  box-shadow: 0 2px 8px rgba(0, 0, 0, .2), 0 0 0 2px #007ad0;
}

.pac-container {
  z-index: 10000;
  font-family: inherit;
}

.map-panel .sheet-handle {
  flex: none;
  margin: 0 auto;
}

.map-panel {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-height: 75%;
  padding: 20px 16px 24px;
  border-radius: 20px 20px 0 0;
  background: #fafafa;
  box-shadow: 0 -2px 12px rgba(0, 0, 0, .15);
}

/* Below 1024px the panel is a bottom sheet: a handle invites the pull-down (sheet.js), it slides up when the view opens */
@media (max-width: 1023px) {
  .map-panel {
    padding-top: 12px;
    overscroll-behavior: contain;
  }

  .map-view:not([hidden]) .map-panel {
    animation: sheet-up .22s ease-out;
  }

  .map-panel .sheet-handle {
    touch-action: none;
  }

  /* Pulled down: out of sight (and out of the tab order) until the pin changes and map.js takes the class off */
  .map-panel {
    transition: transform .22s ease-out;
  }

  .map-panel.is-collapsed {
    transform: translateY(100%);
    visibility: hidden;
    transition: transform .22s ease-in, visibility 0s .22s;
  }
}

@media (prefers-reduced-motion: reduce) {
  .overlay-sheet:not([hidden]),
  .overlay-sheet:not([hidden]) .sheet,
  .map-view:not([hidden]) .map-panel {
    animation: none;
  }

  .overlay-sheet.is-leaving,
  .map-panel,
  .map-panel.is-collapsed {
    transition: none;
  }
}

/* "ใช้ตำแหน่งปัจจุบัน": a 40px row in the design's tertiary blue; the whole row is the button */
.map-locate {
  display: flex;
  flex: none;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 40px;
  padding: 0;
  background: none;
  border: 0;
  border-radius: 16px;
  color: #007ad0;
  font: inherit;
  font-size: 16px;
  font-weight: 700;
  line-height: 24px;
  letter-spacing: .005em;
  text-align: left;
  cursor: pointer;
}

.map-locate img {
  flex: none;
  width: 24px;
  height: 24px;
}

.map-locate:hover,
.map-locate:active {
  background: rgba(0, 122, 208, .08);
}

.map-locate:focus-visible {
  outline: 2px solid #007ad0;
  outline-offset: 2px;
}

/* the address, the coordinates and any note: takes the space between the locate row and the confirm button */
.map-panel-info {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
}

.map-address {
  margin: 0;
  color: #303c46;
  font-size: 20px;
  font-weight: 700;
  line-height: 32px;
  overflow-wrap: anywhere;
}

.map-coords {
  margin: 4px 0 0;
  color: #303c46;
  font-size: 16px;
  line-height: 24px;
  letter-spacing: .005em;
}

.map-panel .notice {
  margin: 8px 0 0;
}

.map-confirm {
  flex: none;
}

/* The pin with the address above it, in the preview and in the map view (map.js builds it as the marker's content) */
.map-pin {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.map-pin-bubble {
  position: relative;
  width: max-content;
  max-width: min(520px, 80vw);
  margin-bottom: 10px;
  padding: 8px 14px;
  border-radius: 8px;
  background: #333f48;
  color: #fff;
  font-family: "Better Together", "Noto Sans Thai", "Sarabun", system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.4;
  text-align: center;
  pointer-events: none;
}

.map-pin-bubble::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  margin-left: -6px;
  border: 6px solid transparent;
  border-top-color: #333f48;
}

/* Summary */
.summary-group {
  margin: 0 0 14px;
  padding: 14px 16px;
  border: 1px solid #ececec;
  border-radius: var(--radius);
}

.summary-group h4 {
  margin: 0 0 8px;
  font-size: 16px;
}

.summary dl {
  margin: 0;
  display: grid;
  grid-template-columns: minmax(110px, 40%) 1fr;
  gap: 6px 12px;
  font-size: 14px;
}

.summary dt {
  color: var(--muted);
}

.summary dd {
  margin: 0;
  text-align: right;
  overflow-wrap: anywhere;
}

/* Buttons */
.actions {
  margin-top: 24px;
  display: flex;
  justify-content: center;
}

/* The design's button: 40px high, 14px medium label, pill-shaped */
.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 40px;
  padding: 0 24px;
  border-radius: 100px;
  border: 1px solid var(--red);
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  line-height: 20px;
  letter-spacing: .001em;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
}

.btn-primary {
  background: var(--red);
  color: #fff;
}

.btn-primary:hover {
  background: var(--red-dark);
}

.btn-primary:disabled {
  background: var(--grey);
  border-color: var(--grey);
  color: #9aa1a8;
  cursor: not-allowed;
}

.btn-outline {
  background: #fff;
  color: var(--red);
}

.notice {
  margin: 14px 0 0;
  padding: 10px 14px;
  border-radius: 8px;
  background: var(--red-tint);
  color: var(--red-dark);
  font-size: 14px;
}

/* Dialogs */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(0, 0, 0, .5);
}

.overlay-sheet {
  align-items: flex-end;
  padding: 0;
}

.sheet {
  width: 100%;
  max-width: 640px;
  padding: 12px 20px 24px;
  border-radius: 20px 20px 0 0;
  background: #fafafa;
}

.sheet-handle {
  display: block;
  width: 44px;
  height: 4px;
  margin: 0 auto 16px;
  border-radius: 2px;
  background: #cfd3d7;
}

.sheet h2 {
  margin: 0 0 8px;
  font-size: 20px;
}

.sheet {
  max-height: 85vh;
  overflow-y: auto;
}

.sheet:focus {
  outline: 0;
}

/* On a phone the sheet has no close button: a tap on the dark strip above it, Esc, or a finger pulling it down
   (sheet.js) closes it. The popup from 768px keeps "ปิด". The sheet slides up when it opens and out when it closes. */
@keyframes sheet-up {
  from {
    transform: translateY(100%);
  }

  to {
    transform: none;
  }
}

@keyframes backdrop-in {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

@media (max-width: 767px) {
  .sheet .btn {
    display: none;
  }

  .overlay-sheet:not([hidden]) {
    animation: backdrop-in .22s ease-out;
  }

  .overlay-sheet:not([hidden]) .sheet {
    animation: sheet-up .22s ease-out;
  }

  .overlay-sheet.is-leaving {
    background: transparent;
    transition: background .22s;
  }

  /* the sheet scrolls on its own: a pull at its end must not scroll the page behind, and the grips take the drag */
  .sheet {
    overscroll-behavior: contain;
  }

  .sheet-handle,
  .sheet h2 {
    touch-action: none;
  }
}

.sheet p {
  margin: 0 0 16px;
  color: #333c46;
}

/* The Terms body is Legal's text from the database (limited HTML, filtered by the server) */
.sheet-body {
  margin: 0 0 16px;
  color: #333c46;
  overflow-wrap: anywhere;
}

.sheet-body p,
.sheet-body ul,
.sheet-body ol {
  margin: 0 0 12px;
}

.sheet-body ul,
.sheet-body ol {
  padding-left: 22px;
}

.sheet-body h3,
.sheet-body h4 {
  margin: 16px 0 6px;
  font-size: 16px;
}

.sheet-body a {
  color: #0a6ebd;
}

/* The how-to dialog of the (i) icon after the Program Registration Number (program-registration-help.php): the title and
   the "ปิด" button stay put while the text and the two example pictures scroll between them */
.sheet-howto {
  display: flex;
  flex-direction: column;
  max-height: 80vh;
  overflow: hidden;
}

.sheet-howto h2 {
  text-align: center;
}

.howto-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  text-align: center;
}

.sheet-howto .howto-intro {
  margin: 0 0 16px;
  font-size: 16px;
  line-height: 24px;
}

.howto-example .howto-explain {
  font-weight: 400; /* the name and "คลิก" above it stay bold */
}

.howto-example figcaption a {
  color: #0a78c8;
  text-decoration: underline;
}

.howto-example {
  margin: 0 0 16px;
  padding: 16px 12px;
  border-radius: 16px;
  background: #f7f8fa;
}

.howto-example figcaption {
  margin: 0 0 12px;
  font-weight: 700;
  color: var(--red);
}

.howto-example img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 4px;
}

.sheet-howto .btn {
  flex: none;
}

@media (max-width: 767px) {
  .sheet-howto {
    height: 600px; /* a fixed height; max-height (80vh) above keeps it on screen on a short phone */
  }

  .sheet-howto .btn {
    display: flex; /* the Terms sheet hides its button on a phone; this one keeps "ปิด" */
  }
}

/* Thank-you and error pages */
.thank-you,
.page {
  max-width: 640px;
  margin: 0 auto;
  padding: 56px 16px;
  text-align: center;
}

.thank-you h1 {
  margin: 16px 0 8px;
  font-size: 26px;
}

.thank-you p {
  margin: 0 0 24px;
  color: #333c46;
}

.thank-you .btn {
  max-width: 320px;
  margin: 0 auto;
}

/* Desktop: two columns of fields */
@media (min-width: 768px) {
  .card {
    padding: 28px 40px 32px;
  }

  .step {
    display: grid;
    grid-template-columns: 1fr 1fr;
    column-gap: 20px;
  }

  .step>* {
    grid-column: 1 / -1;
  }

  .step>.field {
    grid-column: auto;
  }

  .actions .btn {
    max-width: 280px;
  }

  /* The Terms open as a centered popup instead of a bottom sheet (the design's "pop up" frame: 360px, radius 24px,
     title 20px bold, text 16px/24px in a 192px area that scrolls, a filled red close button) */
  .overlay-sheet {
    align-items: center;
    padding: 16px;
  }

  .sheet {
    max-width: 360px;
    max-height: none;
    padding: 24px 0 0;
    border-radius: 24px;
    background: #fff;
    overflow: visible;
  }

  .sheet-handle {
    display: none;
  }

  .sheet h2 {
    margin: 0 0 8px;
    padding: 0 16px 0 22px;
    font-size: 20px;
    line-height: 32px;
    font-weight: 700;
    color: #1a1c1e;
  }

  .sheet-body {
    margin: 0;
    padding: 0 16px 0 22px;
    max-height: 192px;
    overflow-y: auto;
    font-size: 16px;
    line-height: 24px;
    color: #303c46;
  }

  /* a <button> does not stretch with width: auto, so the width is spelled out: the popup less 24px each side */
  .sheet .btn {
    width: calc(100% - 48px);
    margin: 24px;
    background: var(--red);
    color: #fff;
  }

  .sheet .btn:hover {
    background: var(--red-dark);
  }

  /* the how-to popup is wider than the Terms popup (560px instead of 360px) and its text and pictures are longer: it is as tall as the window less 300px, and its body scrolls inside, instead of stopping at 192px */
  .sheet-howto {
    max-width: 560px;
    max-height: calc(100vh - 300px);
    overflow: hidden;
  }

  .sheet-howto .howto-body {
    max-height: none;
    padding: 0 22px;
  }

  .sheet-howto h2 {
    padding: 0 22px;
  }

  .map-inline {
    aspect-ratio: 21 / 9;
  }

  .choice-list {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Map view on a desktop (the shared header's desktop width): the design has no back row, the map starts right under
   the header and the card floats on it, vertically centred, 24px from the right. A back control is still needed to
   leave without confirming, so it floats over the map's top left corner, with the place search beside it (the pill
   has a fixed width so the search box can start after it). */
@media (min-width: 1024px) {
  .map-view-bar {
    position: absolute;
    top: 16px;
    left: 16px;
    z-index: 3;
    width: 140px;
    padding: 4px 0;
    border: 0;
    border-radius: 100px;
    background: #fff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, .2);
    text-align: center;
  }

  /* 16px + the 140px pill + 12px; never under the 429px card (24px from the right) */
  .map-search {
    top: 16px;
    left: 168px;
    right: auto;
    width: min(360px, calc(100% - 168px - 477px));
  }

  .map-panel {
    top: 0;
    right: 24px;
    bottom: 0;
    left: auto;
    width: 429px;
    height: min(572px, calc(100% - 48px));
    margin: auto 0;
    max-height: none;
    padding: 24px 16px 32px;
    border-radius: 24px;
    background: #fff;
    box-shadow: 0 2px 16px 2px rgba(0, 0, 0, .08);
  }

  .map-panel .sheet-handle {
    display: none;
  }
}

/* Phone: a focused text box is slid to the top of the screen (keyboard.js), just under the fixed shared header
   (--ths-header-h is measured by keyboard.js) with a little air; the page gets spare room while typing so even the
   last box of a step can get there */
@media (max-width: 767px) {
  .field {
    scroll-margin-top: calc(var(--ths-header-h, 0px) + 24px);
  }

  .stepper {
    scroll-margin-top: var(--ths-header-h, 0px);
  }

  body.keyboard-open {
    padding-bottom: 60vh;
  }
}

/* Two buttons side by side on a step (the outline "ติดต่อเจ้าหน้าที่" and the primary one). On a phone they stack, the primary first, as the
   UX/UI frames draw them. The outline button comes first in the page, so the stack is reversed. */
.actions-split {
  gap: 12px;
  flex-direction: column-reverse;
  align-items: center;
}

.actions-split .btn {
  max-width: 100%;
}

@media (min-width: 768px) {
  .actions-split {
    flex-direction: row;
    justify-content: center;
    gap: 16px;
  }

  .actions-split .btn {
    flex: 1 1 0;
    max-width: 280px;
  }
}

/* The Callback Request popups: a centered card on every width (frames "lead-to-tele-popup": 560px on a desktop, 312px on a phone) */
.modal {
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 40px 24px 24px;
  border-radius: 24px;
  background: #fff;
  text-align: center;
}

.modal:focus {
  outline: 0;
}

.modal-icon {
  display: block;
  width: 80px;
  height: 80px;
  margin: 0 auto 24px;
}

.modal h2 {
  margin: 0 0 16px;
  font-size: 24px;
  line-height: 32px;
  font-weight: 500;
}

.modal-text {
  margin: 0 0 24px;
  color: #333c46;
  font-size: 14px;
  line-height: 22px;
  white-space: pre-line;
}

/* the code line of the error popup is small and light, as in TOL web's popup */
.modal-code {
  margin: -12px 0 24px;
  color: rgba(48, 60, 70, .6);
  font-size: 11px;
  line-height: 16px;
}

.modal-code:empty {
  display: none;
}

.modal-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

@media (min-width: 768px) {
  .modal {
    padding: 48px 32px 32px;
  }

  .modal-actions {
    flex-direction: row;
  }

  .modal-actions .btn {
    flex: 1 1 0;
  }
}

@media (max-width: 767px) {
  .modal {
    max-width: 312px;
    padding: 32px 16px 16px;
  }
}
