/* Part q-market: the Iowa Land Values and Cash Rent by County page, as q-market.php lays it out. The gl-q classes
   exist only on that page. The look follows Our History (l-history.css) and the listing index's table: navy ink on
   white, hairline rules between rows, figures in tabular digits, no boxes. Every page loads every part's stylesheet
   until growthland-restyle.php's part map knows this page, so each rule carries #main .gl-q and wins over the other
   parts' list and table rules there. */

#main .gl-q { --gl-q-sticky: 70px; margin: 4px 0 40px; color: var(--gl-ink); }
#main .gl-q :is(p, li) { text-wrap: pretty; }
#main .gl-q a:not(.gl-q-county) { color: var(--gl-navy); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: .2em; }
#main .gl-q a:hover { text-decoration-thickness: 2px; }
#main .gl-q a:focus-visible, #main .gl-q button:focus-visible, #main .gl-q input:focus-visible, #main .gl-q .gl-q-scroll:focus-visible { outline: 3px solid #5b7bd5; outline-offset: 2px; }

/* On the review copy only: new wording waits for Growthland's approval. */
#main .gl-q .gl-draft-note { max-width: 46em; margin: 0 0 24px; padding: 10px 14px; border: 1px dashed var(--gl-field); border-radius: var(--gl-radius); background: var(--gl-wash); font-size: 14px; line-height: 1.5; color: var(--gl-muted); }

#main .gl-q .gl-q-lead { max-width: 40em; margin: 0 0 14px; font-size: 18px; line-height: 1.65; }
#main .gl-q .gl-q-src { max-width: 52em; margin: 0 0 40px; font-size: 15px; line-height: 1.7; color: var(--gl-muted); }
#main .gl-q .gl-q-src-k { font-weight: 600; color: var(--gl-ink); }
#main .gl-q .gl-q-out { white-space: normal; }
#main .gl-q .gl-q-out .gl-i { width: 15px; height: 15px; margin: -2px 0 0 4px; }

/* ---------- The table section ---------- */

#main .gl-q .gl-q-data h2 { margin: 0 0 16px; font-size: 1.625rem; line-height: 1.25; }

/* The search, the listings switch, and the count share a row where they fit. */
#main .gl-q .gl-q-tools { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px 16px; margin: 0 0 16px; }
#main .gl-q .gl-q-tools[hidden] { display: none; }
/* Until q-market.js wires the tools they keep their space unseen; a page whose script doesn't run drops them. */
html.gl-js #main .gl-q .gl-q-tools.gl-q-wait { visibility: hidden; }
html:not(.gl-js) #main .gl-q .gl-q-tools.gl-q-wait { display: none; }
#main .gl-q .gl-q-find { flex: 1 1 20rem; max-width: 28rem; }
#main .gl-q .gl-q-find-l { display: block; margin: 0 0 6px; font-size: 15px; font-weight: 600; color: var(--gl-ink); }
#main .gl-q .gl-q-box { position: relative; }
#main .gl-q .gl-q-find-i { position: absolute; top: 50%; left: 14px; color: var(--gl-muted); transform: translateY(-50%); pointer-events: none; }
#main .gl-q input[type="search"] { box-sizing: border-box; width: 100%; height: 48px; margin: 0; padding: 0 48px 0 44px; border: 1px solid var(--gl-field); border-radius: var(--gl-radius); background: #fff; box-shadow: none; font: 400 17px/1.3 var(--gl-sans); color: var(--gl-ink); -webkit-appearance: none; appearance: none; }
#main .gl-q input[type="search"]::-webkit-search-cancel-button { display: none; }
#main .gl-q input[type="search"]::placeholder { color: var(--gl-muted); opacity: 1; }
#main .gl-q input[type="search"]:focus { border-color: var(--gl-navy); }
#main .gl-q .gl-q-clear { position: absolute; top: 2px; right: 2px; display: flex; align-items: center; justify-content: center; width: 44px; height: 44px; min-height: 0; margin: 0; padding: 0; border: 0; border-radius: var(--gl-radius); background: transparent; color: var(--gl-muted); }
#main .gl-q .gl-q-clear[hidden] { display: none; }
#main .gl-q .gl-q-clear:hover { color: var(--gl-navy); }

/* The switch reads like the index's type chips: an outline that fills navy while on. */
#main .gl-q .gl-q-only { display: inline-flex; align-items: center; gap: 8px; min-height: 48px; margin: 0; padding: 0 16px; border: 1px solid var(--gl-field); border-radius: var(--gl-radius); background: #fff; font: 600 15px/1.25 var(--gl-sans); letter-spacing: 0; text-transform: none; color: var(--gl-navy); transition: background-color var(--gl-fast), color var(--gl-fast), border-color var(--gl-fast); }
#main .gl-q .gl-q-only .gl-i { width: 18px; height: 18px; }
#main .gl-q .gl-q-only[aria-pressed="true"] { border-color: var(--gl-navy); background: var(--gl-navy); color: #fff; }
@media (hover: hover) {
  #main .gl-q .gl-q-only[aria-pressed="false"]:hover { border-color: var(--gl-navy); }
}
#main .gl-q .gl-q-count { margin: 0 0 0 auto; padding-bottom: 12px; font-size: 15px; color: var(--gl-muted); font-variant-numeric: tabular-nums; }

/* The table: hairline rules between rows, figures right-aligned in tabular digits. */
#main .gl-q .gl-q-scroll { margin: 0; }
#main .gl-q .gl-q-table { width: 100%; margin: 0; border-collapse: separate; border-spacing: 0; font-size: 17px; line-height: 1.4; font-variant-numeric: tabular-nums lining-nums; }
#main .gl-q .gl-q-table :is(th, td) { padding: 10px 14px; border: 0; border-bottom: 1px solid var(--gl-rule); background: #fff; text-align: right; vertical-align: middle; font-size: 17px; letter-spacing: 0; text-transform: none; color: var(--gl-ink); }
#main .gl-q .gl-q-table :is(th, td):first-child { padding-left: 0; text-align: left; }
#main .gl-q .gl-q-table :is(th, td):last-child { padding-right: 0; }
#main .gl-q .gl-q-table tbody th { font-weight: 600; }
#main .gl-q .gl-q-table tbody tr[hidden] { display: none; }

/* The headings: each is a sort button with its label, a muted line naming the survey, and a direction arrow. */
#main .gl-q .gl-q-table thead th { padding: 0; border-bottom: 2px solid var(--gl-navy); vertical-align: bottom; }
#main .gl-q .gl-q-sort { display: flex; justify-content: flex-end; align-items: flex-end; gap: 6px; width: 100%; min-height: 48px; margin: 0; padding: 10px 14px 10px 6px; border: 0; border-radius: 0; background: transparent; font: inherit; letter-spacing: 0; text-align: right; text-transform: none; color: var(--gl-ink); }
#main .gl-q .gl-q-table thead th:first-child .gl-q-sort { justify-content: flex-start; padding-left: 0; text-align: left; }
#main .gl-q .gl-q-table thead th:last-child .gl-q-sort { padding-right: 0; }
#main .gl-q .gl-q-th { display: flex; flex-direction: column; gap: 2px; text-wrap: balance; }
#main .gl-q .gl-q-th-l { font-size: 15px; font-weight: 600; line-height: 1.3; }
#main .gl-q .gl-q-th-s { font-size: 14px; font-weight: 400; line-height: 1.3; color: var(--gl-muted); }
/* The survey and date for each column, one line above the table in place of a second line in every heading. Each
   part keeps to itself when the line wraps. */
#main .gl-q .gl-q-cols { display: flex; flex-wrap: wrap; gap: 0 16px; margin: 0 0 8px; font-size: 15px; line-height: 1.5; color: var(--gl-muted); }
#main .gl-q .gl-q-dir { flex: none; width: 16px; height: 16px; margin-bottom: 2px; color: var(--gl-muted); }
#main .gl-q th[aria-sort] .gl-q-dir { color: var(--gl-navy); }
#main .gl-q th[aria-sort] .gl-q-th-l { color: var(--gl-navy); }
@media (hover: hover) {
  #main .gl-q .gl-q-sort:hover .gl-q-th-l { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: .2em; }
  #main .gl-q .gl-q-table tbody tr:hover > * { background: var(--gl-wash); }
}

/* The county cell: the name, a link when the county has listings, then its count and any pair note under it. */
#main .gl-q .gl-q-cname { display: flex; flex-wrap: wrap; align-items: baseline; column-gap: 10px; }
#main .gl-q a.gl-q-county { display: inline-flex; align-items: center; min-width: 44px; min-height: 44px; margin: -10px 0; color: var(--gl-navy); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: .2em; }
#main .gl-q .gl-q-sale { font-size: 14px; font-weight: 400; color: var(--gl-muted); white-space: nowrap; }
#main .gl-q .gl-q-pair { flex: 0 0 100%; margin-top: 2px; font-size: 14px; font-weight: 400; line-height: 1.35; color: var(--gl-muted); }

/* The state average closes the table under a navy rule. */
#main .gl-q .gl-q-table tfoot :is(th, td) { border-top: 2px solid var(--gl-navy); border-bottom: 0; font-weight: 600; color: var(--gl-navy); }

#main .gl-q .gl-q-empty { padding: 24px 0; border-bottom: 1px solid var(--gl-rule); }
#main .gl-q .gl-q-empty[hidden] { display: none; }
#main .gl-q .gl-q-empty p { margin: 0 0 12px; font-size: 17px; }
#main .gl-q .gl-q-reset { min-height: 44px; margin: 0; padding: 0 16px; border: 1px solid var(--gl-navy); border-radius: var(--gl-radius); background: #fff; font: 600 15px/1 var(--gl-sans); letter-spacing: 0; text-transform: none; color: var(--gl-navy); }
#main .gl-q .gl-q-note { max-width: 52em; margin: 16px 0 0; font-size: 15px; line-height: 1.6; color: var(--gl-muted); }

/* Wide screens: the four figures share the width evenly beside a wider county column, and the headings stay in view
   under the stuck header (70 px tall from 850 px up) while the 99 rows scroll. */
@media (min-width: 850px) {
  #main .gl-q .gl-q-table { table-layout: fixed; }
  #main .gl-q .gl-q-table thead th:first-child { width: 24%; }
  #main .gl-q .gl-q-table thead th { position: sticky; top: var(--gl-q-sticky); z-index: 2; }
  /* "N for sale" starts at one place down the table, 7 em in, past the longest name (Pottawattamie), instead of
     right after each name (11/4 /ui review). A pair note still takes its own line under both. */
  #main .gl-q .gl-q-cname { display: grid; grid-template-columns: 7em minmax(0, 1fr); column-gap: 10px; }
  #main .gl-q .gl-q-pair { grid-column: 1 / -1; }
}

/* Tapping the search box scrolled it up under the stuck header. It stops below the header with its label in view. */
#main .gl-q input[type="search"] { scroll-margin-top: calc(var(--gl-q-sticky) + 44px); }

/* Phones and tablets: the table scrolls sideways under a sticky county column. */
@media (max-width: 849px) {
  /* The table runs its full height with the page, and only scrolls sideways under the pinned county column. The short
     box that scrolled both ways inside the page (75% of the screen) trapped a phone's swipe (11/4 sweep). While more
     columns wait off the right edge, that edge fades out (q-market.js sets gl-q-more), so the table reads as wider
     than the screen. */
  #main .gl-q .gl-q-scroll { overflow-x: auto; overflow-y: hidden; overscroll-behavior-x: contain; margin-right: -15px; padding-right: 15px; }
  #main .gl-q .gl-q-scroll.gl-q-more { -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 48px), transparent); mask-image: linear-gradient(to right, #000 calc(100% - 48px), transparent); }
  #main .gl-q .gl-q-table { width: max-content; min-width: 100%; }
  /* The stuck county column had only the pale rule at its right, so a swiped heading looked cut off behind it. A
     navy-tinted edge shows where the column sits over the figures. */
  #main .gl-q .gl-q-table :is(th, td):first-child { position: sticky; left: 0; z-index: 1; min-width: 7.5rem; max-width: 9rem; padding-right: 12px; border-right: 1px solid rgba(24, 42, 97, .35); }
  #main .gl-q .gl-q-table thead th:first-child { z-index: 3; }
  #main .gl-q .gl-q-table thead th:not(:first-child) { width: 8.5rem; min-width: 8.5rem; max-width: 8.5rem; }
  #main .gl-q .gl-q-table thead th:not(:first-child) .gl-q-th { white-space: normal; }
  #main .gl-q .gl-q-table td { white-space: nowrap; }
  #main .gl-q .gl-q-sale { flex: 0 0 100%; }
  #main .gl-q .gl-q-count { flex-basis: 100%; margin: 0; padding: 0; }
  #main .gl-q .gl-q-find { max-width: none; }
}
@media (max-width: 549px) {
  #main .gl-q .gl-q-only { width: 100%; justify-content: center; }
  #main .gl-q .gl-q-lead { font-size: 17px; }
}

/* ---------- The text sections, in the Our History rail ---------- */

#main .gl-q .gl-q-sec { margin-top: 72px; }
#main .gl-q .gl-q-head h2 { margin: 0 0 16px; font-size: 1.625rem; line-height: 1.25; }
@media (min-width: 1000px) {
  #main .gl-q .gl-q-sec { display: grid; grid-template-columns: minmax(0, 4fr) minmax(0, 8fr); column-gap: 48px; align-items: start; }
  #main .gl-q .gl-q-head h2 { max-width: 13em; margin: 0; }
}
@media (max-width: 849px) {
  #main .gl-q .gl-q-sec { margin-top: 44px; }
  #main .gl-q .gl-q-head h2, #main .gl-q .gl-q-data h2 { font-size: 1.5rem; }
}

/* How to use: ruled rows, each with a navy line icon beside a short heading and its text. */
#main .gl-q .gl-q-rows, #main .gl-q .gl-q-links { max-width: 40em; margin: 0; padding: 0; border-bottom: 1px solid var(--gl-rule); list-style: none; }
#main .gl-q .gl-q-rows > li { display: grid; grid-template-columns: 24px minmax(0, 1fr); column-gap: 16px; margin: 0; padding: 18px 0; border-top: 1px solid var(--gl-rule); }
#main .gl-q .gl-q-rows > li > .gl-i { width: 22px; height: 22px; margin-top: 2px; color: var(--gl-navy); }
#main .gl-q .gl-q-rows h3 { margin: 0 0 6px; font-size: 18px; font-weight: 600; line-height: 1.35; color: var(--gl-ink); }
#main .gl-q .gl-q-rows p { margin: 0; font-size: 17px; line-height: 1.65; }

/* More market reports: ruled rows, the link on its own line and who publishes it under it. */
#main .gl-q .gl-q-links > li { display: flex; flex-direction: column; gap: 2px; margin: 0; padding: 12px 0 14px; border-top: 1px solid var(--gl-rule); }
#main .gl-q .gl-q-links .gl-q-out { display: inline-flex; align-items: center; align-self: flex-start; min-height: 44px; font-size: 17px; font-weight: 600; }
#main .gl-q .gl-q-links span:not(.screen-reader-text) { font-size: 15px; line-height: 1.55; color: var(--gl-muted); }

#main .gl-q .gl-q-call { max-width: 40em; margin: 56px 0 0; font-size: 17px; line-height: 1.65; }
#main .gl-q a.gl-q-tel { white-space: nowrap; }

@media (prefers-reduced-motion: reduce) {
  #main .gl-q .gl-q-only { transition: none; }
}

@media print {
  #main .gl-q .gl-q-tools, #main .gl-q .gl-draft-note { display: none; }
  #main .gl-q .gl-q-table thead th { position: static; }
  #main .gl-q .gl-q-scroll { max-height: none; overflow: visible; }
  #main .gl-q .gl-q-dir { display: none; }
}
