/* The signed-out Salvage landing page.
 *
 * Loaded only for Views/Home/Index.cshtml when nobody is signed in: the view sets
 * ViewBag.ThdLanding and Views/Shared/_ThdLayout.cshtml writes the link. The build globs wwwroot/css/*.css into the asset manifest, so this file registers
 * itself as the manifest key "thd-landing.css" - nothing else has to be edited to add it.
 *
 * It holds NO image paths on purpose. The photographs belong to the Salvage app
 * (/css/images/landing/...), not to the shared design system, so the markup references them with
 * <img srcset> and this file only lays them out. That also gets real responsive images and a
 * real alt attribute, which a CSS background cannot do.
 *
 * The hero bleeds to the edges of .thd-sheet rather than breaking out of it: the chosen
 * direction is a framed sheet, and a hero that escapes the frame fights it. .thd-sheet pads
 * space-4, and space-6 from 768px, so the bleed is exactly that padding, negated.
 */

.thd-landing__hero {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  display: flex;
  align-items: flex-end;
  min-height: 320px;
  margin: calc(var(--thd-space-4) * -1) calc(var(--thd-space-4) * -1) var(--thd-space-6);
  border-start-start-radius: var(--thd-radius-sheet);
  border-start-end-radius: var(--thd-radius-sheet);
}

@media (min-width: 768px) {
  .thd-landing__hero {
    min-height: 420px;
    margin: calc(var(--thd-space-6) * -1) calc(var(--thd-space-6) * -1) var(--thd-space-8);
  }
}

/* The photograph. object-fit keeps it filling the band at any aspect ratio without distorting. */
.thd-landing__hero-media {
  position: absolute;
  inset: 0;
  z-index: -2;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 55%;
}

/* The scrim is what makes the copy legible, so it is not decoration and is never dropped. On a wide
 * screen it is DIRECTIONAL on purpose: a flat scrim heavy enough for text across the whole band
 * erases the photograph into grey. So it is heavy where the copy sits and clears off it.
 *
 * The binding constraint is the green eyebrow, not the white text: at 12px it is small text, so its
 * floor is 4.5:1, while the 28-40px title only needs 3.0.
 *
 * The rule that keeps the copy legible: no text sits on less than 0.80 of the scrim colour. Over a
 * pure white pixel, the brightest any photograph can be, 0.80 gives the eyebrow 4.70:1, the stat
 * label 7.08:1, the lead 8.49:1 and the title 10.40:1; 0.82 gives the eyebrow 5.06:1. (0.78 gives
 * 4.36:1 and fails.) On a wide screen the heavy part runs to 58% of the band or to the width of the
 * copy block (44rem), whichever is further: with 58% alone the title was at 1.97:1 and the lead at
 * 2.11:1 on a 768px screen, where the copy reaches past 58%.
 *
 * Measured on the current photographs (THDDEV-2052) in Chromium at 13 widths from 320 to 2560px, the
 * worst pixel behind each text: eyebrow 4.81:1, title 11.03:1, lead 9.56:1, stat label 8.99:1.
 * Those four figures belong to these photographs; the floors above do not. After replacing the
 * photograph, or changing the scrim or the copy block's width, measure again.
 *
 * Phone takes a vertical scrim instead: the copy spans the full width there, so there is no clear
 * side to fall off towards. */
.thd-landing__hero::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  /* Phone is nearly flat, not a falloff. The copy fills the whole band at this width, so the
   * eyebrow sits at the TOP - where a falloff gradient is at its weakest, which is precisely
   * where the first version put green-on-near-white and made it unreadable. It never drops below
   * 0.80 (see above). The photograph is dim here as a result; on a phone the four tile images
   * carry the imagery instead. */
  background: linear-gradient(
    to top,
    rgba(16, 16, 16, 0.88) 0%,
    rgba(16, 16, 16, 0.84) 60%,
    rgba(16, 16, 16, 0.80) 100%
  );
}

@media (min-width: 768px) {
  .thd-landing__hero::before {
    background: linear-gradient(
      to right,
      rgba(16, 16, 16, 0.84) 0%,
      rgba(16, 16, 16, 0.82) max(58%, 44rem),
      rgba(16, 16, 16, 0.34) max(80%, 54rem),
      rgba(16, 16, 16, 0.06) 100%
    );
  }
}

.thd-landing__hero-body {
  padding: var(--thd-space-6) var(--thd-space-4);
  max-width: 44rem;
  color: #ffffff;
}

@media (min-width: 768px) {
  .thd-landing__hero-body {
    padding: var(--thd-space-8) var(--thd-space-6);
  }
}

.thd-landing__eyebrow {
  margin: 0 0 var(--thd-space-2);
  font-size: 12px;
  line-height: 16px;
  font-weight: var(--thd-font-weight-semibold);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  /* NOT var(--thd-site-accent). That token switches with the theme - #1C774A light, #4CC38A dark -
   * but this band is ALWAYS dark, whatever the theme, because it is a photograph under a scrim.
   * Against 0.82 of the scrim over a pure white pixel: #4CC38A is 5.06:1 and passes; the light-theme
   * #1C774A is 2.02:1 and fails. So the value is fixed here deliberately. */
  color: #4cc38a;
}

.thd-landing__title {
  margin: 0 0 var(--thd-space-3);
  font-size: 28px;
  line-height: 34px;
  font-weight: var(--thd-font-weight-semibold);
  color: #ffffff;
}

@media (min-width: 768px) {
  .thd-landing__title {
    font-size: 40px;
    line-height: 46px;
  }
}

.thd-landing__lead {
  margin: 0 0 var(--thd-space-5);
  font-size: 16px;
  line-height: 24px;
  color: rgba(255, 255, 255, 0.88);
}

.thd-landing__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--thd-space-3);
  align-items: center;
}

/* The hero buttons sit on a photograph, so they carry their own treatment rather than inheriting
 * a surface button's. Both take the touch target height token. */
.thd-landing__cta,
.thd-landing__cta-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--thd-space-2);
  min-height: var(--thd-size-target-touch);
  padding: 0 var(--thd-space-5);
  border-radius: var(--thd-radius-control);
  font-weight: var(--thd-font-weight-semibold);
  text-decoration: none;
  cursor: pointer;
}

/* Same reason as the eyebrow, in reverse: white on the light-theme brand green #1C774A measures
 * 5.55:1 and passes, white on the dark-theme #4CC38A measures 2.22:1 and fails. The button sits
 * on the always-dark hero, so it takes the fixed value rather than the theme-switched token. */
.thd-landing__cta {
  background: #1c774a;
  border: var(--thd-size-border-width) solid transparent;
  color: #ffffff;
}

.thd-landing__cta:hover,
.thd-landing__cta:focus-visible {
  filter: brightness(1.08);
  color: #ffffff;
}

.thd-landing__cta-secondary {
  background: rgba(255, 255, 255, 0.10);
  border: var(--thd-size-border-width) solid rgba(255, 255, 255, 0.55);
  color: #ffffff;
}

.thd-landing__cta-secondary:hover,
.thd-landing__cta-secondary:focus-visible {
  background: rgba(255, 255, 255, 0.20);
  color: #ffffff;
}

/* The shared focus ring is a blue made for light surfaces and is faint on this band. White is not:
 * it is the same colour as the title, so it has the title's floor (above). Forced colours still
 * substitutes its own. */
.thd-landing__cta:focus-visible,
.thd-landing__cta-secondary:focus-visible {
  outline-color: #ffffff;
}

/* The recall count. A figure with its label, not a sentence: it is the one hard number on the
 * page and it should read as one. Tabular figures so it does not jitter as it grows. */
.thd-landing__stat {
  margin: var(--thd-space-5) 0 0;
  display: flex;
  align-items: baseline;
  gap: var(--thd-space-2);
  font-variant-numeric: tabular-nums;
}

.thd-landing__stat-figure {
  font-size: 26px;
  line-height: 30px;
  font-weight: var(--thd-font-weight-semibold);
  color: #ffffff;
}

.thd-landing__stat-label {
  font-size: 13px;
  line-height: 18px;
  color: rgba(255, 255, 255, 0.78);
}

/* ---- the four tiles ---------------------------------------------------------------------- */

.thd-landing__tiles {
  display: grid;
  gap: var(--thd-space-4);
  grid-template-columns: 1fr;
}

@media (min-width: 560px) {
  .thd-landing__tiles {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 1100px) {
  .thd-landing__tiles {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

.thd-landing__tile {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: var(--thd-size-border-width) solid var(--thd-color-border);
  border-radius: var(--thd-radius-card);
  background: var(--thd-color-surface);
  color: var(--thd-color-text);
  text-decoration: none;
}

.thd-landing__tile:hover,
.thd-landing__tile:focus-visible {
  border-color: var(--thd-color-control);
  box-shadow: var(--thd-elevation-card);
  color: var(--thd-color-text);
}

/* height:auto and flex:none are both load-bearing. The tile is a COLUMN flex container, so the
 * image's main axis is vertical: without them the flex base size comes from the img's height
 * attribute (538) and aspect-ratio never gets to apply, giving a 290x538 letterbox instead of 4:3.
 * The width/height attributes stay on the element so the browser still reserves the right box
 * before the file arrives and the grid does not jump. */
.thd-landing__tile-media {
  display: block;
  flex: none;
  width: 100%;
  height: auto;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  background: var(--thd-color-active);
}

/* The photograph lifts very slightly on hover, inside its own frame. The frame does not move,
 * so nothing reflows and the grid stays still. */
.thd-landing__tile-media {
  transition: transform 220ms ease;
}

.thd-landing__tile:hover .thd-landing__tile-media {
  transform: scale(1.03);
}

.thd-landing__tile-body {
  padding: var(--thd-space-4);
}

.thd-landing__tile-title {
  margin: 0 0 var(--thd-space-1);
  font-size: 16px;
  line-height: 22px;
  font-weight: var(--thd-font-weight-semibold);
  color: var(--thd-color-text);
}

.thd-landing__tile-text {
  margin: 0;
  font-size: 14px;
  line-height: 20px;
  color: var(--thd-color-text-muted);
}

/* ---- accessibility fallbacks ------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  .thd-landing__tile-media {
    transition: none;
  }
  .thd-landing__tile:hover .thd-landing__tile-media {
    transform: none;
  }
}

/* Forced colours drops the hero photograph (the tile photographs stay) and leans on system colours, so
 * the hero copy must not stay white on an unpainted ground. */
@media (forced-colors: active) {
  .thd-landing__hero {
    border: 1px solid CanvasText;
  }
  .thd-landing__hero::before {
    background: Canvas;
  }
  .thd-landing__hero-media {
    display: none;
  }
  .thd-landing__hero-body,
  .thd-landing__title,
  .thd-landing__stat-figure {
    color: CanvasText;
  }
  .thd-landing__lead,
  .thd-landing__stat-label,
  .thd-landing__eyebrow {
    color: CanvasText;
  }
  .thd-landing__cta,
  .thd-landing__cta-secondary {
    border: 1px solid CanvasText;
    background: Canvas;
    color: LinkText;
  }
  .thd-landing__tile {
    border-color: CanvasText;
  }
}

@media print {
  .thd-landing__hero {
    min-height: 0;
  }
  .thd-landing__hero-media,
  .thd-landing__tile-media {
    display: none;
  }
  .thd-landing__hero::before {
    background: none;
  }
  .thd-landing__hero-body,
  .thd-landing__eyebrow,
  .thd-landing__title,
  .thd-landing__lead,
  .thd-landing__stat-figure,
  .thd-landing__stat-label {
    color: #000000;
  }
  /* Paper gets no dark band and, by default, no backgrounds: white labels would not show. */
  .thd-landing__cta,
  .thd-landing__cta-secondary {
    background: none;
    border: 1px solid #000000;
    color: #000000;
  }
}
