/* Phones and tablets (portrait): the fixes on top of the kit, shared by every page.
   Loaded after each page's own <style>, so these win at the same weight. */

/* 1. a section is as tall as its words and pictures, never a screen with an empty part under it, and the
      space between two sections is one even step on every page: --sec-b under one, --sec-t over the next
      (desktop ~152px, tablet ~136px, phone ~104px). The hero and the pinned 3D scroll scenes keep their height.
      The phone's call bar only needs room under the very last block (the footer keeps it).
      A menu jump to a section leaves its heading 24px under the fixed header. */
:root { --sec-t: 88px; --sec-b: 64px; }
@media (max-width: 1023px) { :root { --sec-t: 80px; --sec-b: 56px; } }
@media (max-width: 639px)  { :root { --sec-t: 64px; --sec-b: 40px; } }
main > section.section:not(.hero, .s3d) { height: auto; min-height: 0; padding-top: var(--sec-t); padding-bottom: var(--sec-b);
  scroll-margin-top: calc(var(--nav, 72px) + 24px - var(--sec-t)); }
footer.footer.closing { height: auto; min-height: 0; padding-top: var(--sec-t); }

/* 2. name | value rows (specs, contact): the value gets room for a whole price, phone or address line */
@media (max-width: 479px) {
  .rows > li > .rows__value { max-width: 24ch; }
  .rows__value a[href^="tel:"] { white-space: nowrap; }
}

/* 3. price tables on a phone: one block a version, the name and the price on one line, what differs under it */
@media (max-width: 639px) {
  .trims--price, .trims--price tbody { display: block; width: 100%; }
  .trims--price colgroup, .trims--price thead { display: none; }
  .trims--price tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: var(--s-4); row-gap: 2px;
    padding-block: 12px; border-bottom: 1px solid var(--line); }
  .trims--price tr > * { display: block; width: auto; padding: 0; border: 0; font-size: var(--t-body); }
  .trims--price tr > :first-child { grid-column: 1; grid-row: 1; font-weight: 500; }
  .trims--price tr > td:last-child { grid-column: 2; grid-row: 1; text-align: right; white-space: nowrap; font-weight: 500; }
  .trims--price tr > td:nth-last-child(2) { grid-column: 1 / -1; grid-row: 2; color: var(--muted); font-size: var(--t-small); }
  .trims--price tr > td:empty { display: none; }
  /* the full list: the model as a heading over its versions */
  .trims--all tbody tr:has(th[scope="rowgroup"]) > * { border-top: 0; }
  .trims--all tr:has(> th[scope="rowgroup"]) { border-top: 1px solid var(--line-strong); padding-top: var(--s-5); margin-top: var(--s-3); }
  .trims--all tr:first-child { border-top: 0; margin-top: 0; padding-top: 0; }
  .trims--all tr > th[scope="rowgroup"] { grid-column: 1 / -1; grid-row: 1; font: var(--display-weight) var(--t-lead)/1.25 var(--font-display); margin-bottom: var(--s-2); }
  .trims--all tr:has(> th[scope="rowgroup"]) > td:nth-child(2) { grid-column: 1; grid-row: 2; font-weight: 500; }
  .trims--all tr:has(> th[scope="rowgroup"]) > td:last-child { grid-row: 2; }
  .trims--all tr:has(> th[scope="rowgroup"]) > td:nth-last-child(2) { grid-row: 3; }

  /* trim comparison (VF 5, VF 6): the row's name across, the two versions side by side under it */
  .trims:not(.trims--price), .trims:not(.trims--price) thead, .trims:not(.trims--price) tbody { display: block; width: 100%; }
  .trims:not(.trims--price) colgroup { display: none; }
  .trims:not(.trims--price) tr { display: grid; grid-template-columns: 1fr 1fr; column-gap: var(--s-4); row-gap: 4px;
    padding-block: 12px; border-bottom: 1px solid var(--line); }
  .trims:not(.trims--price) tr > * { display: block; width: auto; padding: 0; border: 0; font-size: var(--t-small); }
  .trims:not(.trims--price) tbody th { grid-column: 1 / -1; color: var(--muted); font-weight: 400; }
  .trims:not(.trims--price) thead tr { padding-top: 0; }
  .trims:not(.trims--price) thead th:first-child { display: none; }
  .trims:not(.trims--price) thead th { font-size: var(--t-body); color: var(--ink); font-weight: 600; }
  .trims:not(.trims--price) tbody tr:first-child td { font-weight: 600; font-size: var(--t-body); }

  /* home page line-up table: car and price on a line, range and power under them */
  #bang-gia .tbl, #bang-gia .tbl tbody { display: block; width: 100%; }
  #bang-gia .tbl colgroup, #bang-gia .tbl thead { display: none; }
  #bang-gia .tbl tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: var(--s-4); align-items: center;
    padding-block: 10px; border-bottom: 1px solid var(--line); }
  #bang-gia .tbl tr > * { display: block; height: auto; padding: 0; border: 0; font-size: var(--t-body); white-space: nowrap; }
  #bang-gia .tbl th { grid-column: 1; grid-row: 1 / span 2; display: flex; align-items: center; font-weight: 500; }
  #bang-gia .tbl__car { width: 64px; height: 34px; margin-right: var(--s-3); flex: none; }
  #bang-gia .tbl td:nth-child(2) { grid-column: 2; grid-row: 1; text-align: right; font-weight: 500; }
  #bang-gia .tbl td:nth-child(3) { grid-column: 2; grid-row: 2; text-align: right; color: var(--muted); font-size: var(--t-small); }
  #bang-gia .tbl td:nth-child(n+4) { display: none; }
}

/* 4. tablet portrait: the home price table keeps each car's picture beside its name */
@media (min-width: 640px) and (max-width: 1023px) {
  #bang-gia .tbl tbody th { white-space: nowrap; }
}

/* 4b. the colour picker's picture on a wide screen: a 3:2 panel instead of a square, so a long, low car does
       not float in a tall grey box with empty space over and under it */
@media (min-width: 1280px) { .cfg__stage { aspect-ratio: 3 / 2; } }
@media (min-width: 1024px) { #cau-hinh .cfg__stage { aspect-ratio: 3 / 2; } }

/* 5. dark mode on the visitor's phone or computer: the site stays light (no forced darkening of the
      photographs and the navy logo), and the header turns dark with the white "Như Ý" logo, so the
      logo is the brightest thing at the top either way */
:root { color-scheme: only light; }
@media (prefers-color-scheme: dark) {
  .nav { --bg: var(--p-inv-bg); --ink: var(--p-inv-ink); --muted: var(--p-inv-muted); --card: var(--p-inv-surface);
         --line: color-mix(in oklab, var(--p-inv-ink) 14%, transparent); --line-strong: color-mix(in oklab, var(--p-inv-ink) 26%, transparent); }
  /* the desktop drop-down stays a light panel; on a phone or tablet the menu is one dark sheet */
  @media (min-width: 1024px) { .nav .nav__menu { --bg: var(--p-bg); --ink: var(--p-ink); --muted: var(--p-muted); --line: color-mix(in oklab, var(--p-ink) 11%, transparent); } }
}

/* 6. paid paint colours under the colour swatches on a model page */
.cfg__paint { margin-top: var(--s-5); }
.cfg__paint .rows__name { white-space: normal; }
