/* ============================================================
   Today in Cars — /advertise
   Depends on tokens.css (design-system variables + primitives)
   and home.css (shared page chrome: body reset, .container,
   .masthead, footer.foot). This file styles the advertiser page:
   hero, inquiry form, stat row, the two placements with their email
   mock-ups, the FAQ and the closing button.

   Everything on the page shares one left edge. Three layouts:
     above 720px   hero in two columns; numbers right of the form; placements in two columns
     600 to 720px  hero in two columns; numbers under the form; placements stacked
     below 600px   everything stacked
   ============================================================ */

/* The closing button jumps back up to the form: glide there instead of cutting, unless the
   visitor has asked their system for reduced motion. Only this page loads this file. */
@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}

.adv { border-top: 1px solid var(--ink); }
.adv-wrap { max-width: var(--col-wide); margin: 0 auto; }
.adv section { padding: var(--sp-8) 0; border-bottom: 1px solid var(--rule-soft); }
.adv section:last-child { border-bottom: 0; }
.adv section[id] { scroll-margin-top: 64px; }   /* the masthead is sticky and 64px tall */

.adv h1 {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: clamp(34px, 6vw, 56px);
  line-height: var(--lh-tight);
  letter-spacing: var(--ls-tight);
  color: var(--ink);
  margin: var(--sp-3) 0 0;
  max-width: 18ch;
  text-wrap: balance;
}
.adv h2 {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: var(--fs-30);
  line-height: var(--lh-snug);
  color: var(--ink);
  margin: 0 0 var(--sp-5);
}
.adv p { font-family: var(--font-body); font-size: var(--fs-18); line-height: 1.55; color: var(--fg-1); margin: 0 0 var(--sp-4); }
.adv .adv-note { font-size: var(--fs-14); line-height: 1.5; color: var(--fg-3); margin: var(--sp-5) 0 0; }

/* ---------- Hero: the headline beside a phone showing an issue ----------
   The phone stands on the section's bottom rule: its box is shorter than the image, so the
   lower part is clipped, and a mask fades the cut. The box keeps its shape at every width. */
.adv section.adv-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) clamp(220px, 32vw, 340px);
  gap: var(--sp-5);
  align-items: center;
  padding-bottom: 0;
}
.adv-hero-text { padding-bottom: var(--sp-8); }
.adv-hero-phone {
  align-self: end;
  aspect-ratio: 17 / 20;
  overflow: hidden;
  -webkit-mask-image: linear-gradient(#000 80%, transparent);
  mask-image: linear-gradient(#000 80%, transparent);
}
.adv-hero-phone img { display: block; width: 100%; height: auto; }

/* ---------- Buttons ---------- */
.adv-btn {
  display: inline-block;
  padding: 15px 28px;
  font-family: var(--font-display);
  font-weight: 900;
  font-size: var(--fs-16);
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #fff;
  background: var(--signal);
  border: 0;
  border-radius: var(--r-1);
  cursor: pointer;
  transition: background var(--t-fast) var(--ease-out);
}
.adv-btn:hover { background: var(--signal-hover); }
.adv-btn:focus-visible { outline: 3px solid var(--ink); outline-offset: 3px; }
.adv-btn[disabled] { opacity: 0.6; cursor: default; }

/* ---------- The form with the numbers beside it ----------
   One section with the hero's own two columns: the form on the left (under the headline),
   the four numbers stacked on the right, starting at the phone's left edge. The numbers'
   column is only as wide as its widest number, so the rule over each one stays short. */
.adv section.adv-ask { display: grid; grid-template-columns: minmax(0, 1fr) clamp(220px, 32vw, 340px); column-gap: var(--sp-5); align-items: start; }
.adv-stats { display: grid; grid-template-columns: max-content; justify-content: start; gap: var(--sp-5); margin: 0; padding: 0; list-style: none; }
.adv-stats li { border-top: 3px solid var(--ink); padding-top: var(--sp-3); }
.adv-stat-n {
  display: block;
  font-family: var(--font-display);
  font-weight: 900;
  font-size: clamp(30px, 4.4vw, 48px);
  line-height: 1;
  letter-spacing: var(--ls-tight);
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.adv-stat-l { display: block; margin-top: var(--sp-2); font-family: var(--font-body); font-size: var(--fs-16); line-height: 1.35; color: var(--fg-2); }

/* ---------- Placements ----------
   Two columns whose rows line up (name, price, spec, mock-up): each placement borrows the
   parent's rows with subgrid, so a spec that wraps on one side does not push its mock-up
   lower than the other's, and both mock-ups end level. */
.adv-placements { display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: auto auto auto 1fr; column-gap: var(--sp-6); }
.adv-placement { display: grid; grid-row: span 4; grid-template-rows: subgrid; min-width: 0; }
.adv-placement h3 { font-family: var(--font-display); font-weight: 900; font-size: var(--fs-24); line-height: var(--lh-snug); color: var(--ink); margin: 0 0 var(--sp-1); }
.adv .adv-price { font-family: var(--font-display); font-weight: 700; font-size: var(--fs-21); line-height: 1.3; color: var(--signal); margin: 0 0 var(--sp-3); }
.adv-price small { font-family: var(--font-body); font-weight: 400; font-size: var(--fs-16); color: var(--fg-2); }   /* "From" and "per issue" */
.adv .adv-spec { font-size: var(--fs-16); line-height: 1.5; color: var(--fg-2); margin: 0 0 var(--sp-5); }

/* The mock-ups borrow the email's look (white card, Arial, the email's ink and ash),
   so they are styled with literals from newsletter/platform/template.py, not site tokens. */
.adv-mock { margin: 0; display: flex; }
.adv-mail { flex: 1; min-width: 0; background: #FFFFFF; border: 1px solid var(--ash-200); border-radius: 6px; padding: 18px 20px 20px; font-family: Arial, Helvetica, sans-serif; color: #2A2A2D; overflow: hidden; }
.adv-mail p { font-family: Arial, Helvetica, sans-serif; font-size: 15px; line-height: 23px; color: #2A2A2D; margin: 0; }
.adv-mail .m-banner { display: block; width: 100%; height: auto; }   /* the email's own banner, 4:1 */
.adv-mail .m-label { text-align: center; font-size: 12px; line-height: 18px; letter-spacing: 0.08em; text-transform: uppercase; color: #807866; margin: 14px 0 0; }
.adv-mail .m-logo { display: block; width: 180px; max-width: 70%; height: auto; margin: 10px auto 0; }
.adv-mail .m-ad { margin-top: 12px; }
.adv-mail .m-ad b, .adv-mail .m-link { color: #0F0F10; text-decoration: underline; text-decoration-color: #C8102E; text-underline-offset: 2px; }
.adv-mail .m-link { white-space: nowrap; }   /* keeps the arrow with its words */
/* Section heading as the email draws it: emoji, name, short red rule, all centred. */
.adv-mail .m-emoji { text-align: center; font-size: 28px; line-height: 40px; margin: 0; }
.adv-mail .m-head { text-align: center; font-weight: 700; font-size: 20px; line-height: 30px; color: #0F0F10; margin: 0; }
.adv-mail .m-rule { width: 40px; height: 3px; background: #C8102E; margin: 6px auto 12px; }
.adv-mail .m-item { padding: 10px 0; border-top: 1px solid #E6E0D2; }
.adv-mail .m-item:first-of-type { border-top: 0; }
.adv-mail .m-item .m-title { display: block; font-weight: 700; font-size: 15px; line-height: 21px; color: #0F0F10; text-decoration: underline; text-decoration-color: #C8102E; text-underline-offset: 2px; margin-bottom: 3px; }
.adv-mail .m-dim { opacity: 0.38; }
.adv-mail .m-yours { background: #F6F2E9; margin: 0 -20px; padding: 12px 20px; }
.adv-mail .m-yours + .m-item { border-top: 0; }
/* What follows the ad in a real issue, dimmed: the first section's heading and grey bars for text. */
.adv-mail .m-sec { margin-top: 20px; border-top: 1px solid #E6E0D2; padding-top: 12px; }
.adv-mail .m-sec .m-rule { margin-bottom: 16px; }
.adv-mail .m-skel { height: 10px; border-radius: 2px; background: #B7AF9E; margin: 0 0 12px; }
.adv-mail .m-skel.title { height: 12px; width: 78%; background: #807866; margin-bottom: 14px; }
.adv-mail .m-skel.short { width: 62%; margin-bottom: 0; }

/* ---------- Inquiry form ---------- */
.adv-form { max-width: var(--col-narrow); }
.adv-field { display: flex; flex-direction: column; min-width: 0; margin-bottom: var(--sp-4); }
.adv-field label { font-family: var(--font-display); font-weight: 700; font-size: var(--fs-14); color: var(--ink); margin-bottom: 6px; }
.adv-field label span { font-weight: 400; color: var(--fg-3); }
.adv-field input, .adv-field textarea {
  width: 100%;
  padding: 13px 14px;
  font-family: var(--font-body);
  font-size: var(--fs-16);
  color: var(--ink);
  background: var(--paper-pure);
  border: 2px solid var(--ink);
  border-radius: var(--r-1);
  outline: none;
  transition: border-color var(--t-fast) var(--ease-out);
}
.adv-field textarea { min-height: 120px; resize: vertical; line-height: 1.5; }
.adv-field input:focus, .adv-field textarea:focus { border-color: var(--signal); }
.adv-form .cf-turnstile { margin-top: var(--sp-4); }
.adv-form .adv-btn { margin-top: var(--sp-3); min-width: 160px; }
.adv .adv-form .form-msg { font-size: var(--fs-16); margin: var(--sp-3) 0 0; }
.adv .adv-form .form-msg:empty { display: none; }
.adv-form .form-msg.error { color: var(--signal); }
.adv-sent { max-width: var(--col-narrow); border-left: 4px solid #0f6b2f; padding: var(--sp-2) 0 var(--sp-2) var(--sp-4); }
.adv .adv-sent p { margin: 0; }
.adv-sent[hidden] { display: none; }

/* ---------- FAQ and the closing button ---------- */
.adv-faq { max-width: var(--col-body); }
.adv-faq h3 { font-family: var(--font-display); font-weight: 700; font-size: var(--fs-21); line-height: var(--lh-snug); color: var(--ink); margin: var(--sp-6) 0 var(--sp-2); }
.adv-faq h3:first-child { margin-top: 0; }
.adv .adv-faq p { color: var(--fg-2); margin: 0; }
.adv section.adv-closer { text-align: center; }   /* the one centred thing on the page: a lone button */

/* No-JS confirmation: /api/advertise 303s form posts back here with #sent / #send-error,
   revealed via :target (same pattern as /subscribe). */
.adv-banner { display: none; margin: 0; padding: .85rem 0; font-weight: 700; text-align: center; font-family: var(--font-body); }
.adv-banner--ok { background: #0f6b2f; color: #fff; }
.adv-banner--err { background: var(--signal, #C8102E); color: #fff; }
.adv-banner:target, .adv-banner[data-show] { display: block; }

@media (max-width: 720px) {
  /* The numbers fall below the form, in a row of four (two by two on a phone, below). */
  .adv section.adv-ask { grid-template-columns: 1fr; row-gap: var(--sp-7); }
  .adv-ask .adv-stats { grid-template-columns: repeat(4, 1fr); justify-content: normal; }
  /* Placements stack. A mock-up keeps an email's width and does not stretch across the page. */
  .adv-placements { grid-template-columns: 1fr; grid-template-rows: none; }
  .adv-placement { display: block; }
  .adv-placement + .adv-placement { margin-top: var(--sp-7); }
  .adv-mock { max-width: 480px; }
}
@media (max-width: 640px) {
  .adv .container { padding: 0 var(--sp-4); }   /* the phone masthead's own inset (home.css) */
  .adv section { padding: var(--sp-7) 0; }
  .adv section.adv-hero { padding-bottom: 0; }
  .adv-hero-text { padding-bottom: var(--sp-7); }
  .adv-ask .adv-stats { grid-template-columns: 1fr 1fr; justify-content: normal; row-gap: var(--sp-6); }
  .adv h2 { font-size: var(--fs-24); }
}
@media (max-width: 599px) {
  /* The hero stacks: the headline, then the phone. On a phone-sized screen the picture fills
     the column, so it lines up with the headline on both sides; on anything wider it is
     capped and centred (left-aligned, it left a sliver of empty space on its right). */
  .adv section.adv-hero { grid-template-columns: 1fr; gap: 0; }
  .adv-hero-text { padding-bottom: var(--sp-6); }
  .adv-hero-phone { width: min(100%, 420px); margin: 0 auto; }
  .adv-form .adv-btn { width: 100%; }   /* the form's fields are full width here, so its button is too */
}
