/* ---------------------------------------------------------------------
   Branding & graphics project cards, and the gallery overlay they open.

   Shared by projects.html ("Completed branding projects", "Graphics,
   mockups & illustrations") and index.html ("Branding projects"), so the
   two pages cannot drift apart. It used to live in a <style> block inside
   projects.html; the home page needed the same cards, so it moved here.

   Loads after css/hudl-effects.css, which holds the motion for these same
   cards and relies on being able to override what follows.
   --------------------------------------------------------------------- */

/* ==================== BRANDING & GRAPHICS CARDS ====================== */
.branding-projects-section h2 {
  color: #037a8e;
  margin-bottom: 40px;
}

/* Each grid declares the shape of its covers. Every cover in a grid is
   rendered at exactly this ratio, which is what makes the boxes match. */
#branding-grid,
#home-branding-grid {
  --hudl-cover-ratio: 4 / 5;
}
#graphics-grid {
  --hudl-cover-ratio: 1 / 1;
}

/* The column stretches, the card fills it: every card in a row ends up
   the same height whatever the length of its description. */
.branding-box,
.graphics-box {
  display: flex;
}

/* Every card in a grid is exactly the same size. The cover sits in a
   fixed-ratio frame and each piece of text gets its own reserved row, so a
   project with no client, a one-line blurb or no "View live" link still
   matches the cards beside it instead of coming up short.

   The two optional rows collapse to nothing when NO card in that grid uses
   them (:not(:has(...)) below), so a grid where nobody filled in a client
   does not carry an empty strip. A browser without :has keeps both rows
   reserved, which is the safe way round: a little extra air, never text
   landing on top of text. */
.branding-card {
  position: relative;
  display: grid;
  grid-template-rows:
    auto                                /* cover */
    var(--hudl-name-row, 66px)          /* title, up to two lines */
    var(--hudl-client-row, 25px)        /* client */
    var(--hudl-short-row, 67px)         /* blurb, up to three lines */
    var(--hudl-link-row, 27px);         /* "View live" */
  align-content: start;
  width: 100%;
  background-color: #fff;
  border: 1px solid #e6eaec;
  border-radius: 10px;
  overflow: hidden;
  cursor: pointer;
  padding: 0 0 18px;
  text-align: left;
  transition:
    transform 0.25s ease,
    box-shadow 0.25s ease,
    border-color 0.25s ease;
}

.branding-card:focus-visible {
  outline: 3px solid #ffa132;
  outline-offset: 3px;
}

/* Fixed-ratio frame for the cover: object-fit crops to fill it, so a
   portrait cover and a square one still take up the same space. */
.branding-media {
  position: relative;
  grid-row: 1;
  aspect-ratio: var(--hudl-cover-ratio, 4 / 5);
  background: #f1f4f5;
  overflow: hidden;
}

/* Each text row is pinned to its own track, so a missing element leaves its
   slot empty rather than letting the next one slide up into it. */
.branding-name {
  grid-row: 2;
}
.branding-client {
  grid-row: 3;
}
.branding-short {
  grid-row: 4;
}
.branding-link {
  grid-row: 5;
}

#branding-grid:not(:has(.branding-client)),
#home-branding-grid:not(:has(.branding-client)),
#graphics-grid:not(:has(.branding-client)) {
  --hudl-client-row: 0px;
}
#branding-grid:not(:has(.branding-link)),
#home-branding-grid:not(:has(.branding-link)),
#graphics-grid:not(:has(.branding-link)) {
  --hudl-link-row: 0px;
}

.branding-media img.cover,
.branding-card > img.cover {
  display: block;
  width: 100%;
  height: 100%;
  margin: 0;
  border-radius: 0;
  object-fit: cover;
  object-position: center;
}

/* Fallback for a card rendered without the media frame. */
.branding-card > img.cover {
  grid-row: 1;
  height: auto;
  aspect-ratio: var(--hudl-cover-ratio, 4 / 5);
}

/* Browsers without aspect-ratio support fall back to a padding frame. */
@supports not (aspect-ratio: 1 / 1) {
  .branding-media {
    height: 0;
    padding-bottom: 125%;
  }
  #graphics-grid .branding-media {
    padding-bottom: 100%;
  }
  .branding-media img.cover {
    position: absolute;
    top: 0;
    left: 0;
  }
}

/* 16 padding + two 21.8px lines + 6 margin = the 66px row above. The line
   heights below are spelled out because those row sizes depend on them. */
.branding-name {
  font-size: 1.05rem;
  line-height: 1.3;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #000637;
  margin: 0 0 6px;
  padding: 16px 16px 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Who the work was for, under the title. */
.branding-client {
  font-size: 0.78rem;
  line-height: 1.5;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #037a8e;
  margin: 0 0 6px;
  padding: 0 16px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.branding-short {
  font-size: 0.9rem;
  line-height: 1.55;
  color: #5c6670;
  margin: 0;
  padding: 0 16px;
  /* Clamped to three lines so one wordy project cannot stretch a row.
     The full text stays in the DOM - the gallery overlay reads it. */
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ======================= GALLERY OVERLAY ============================= */
.branding-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 6, 55, 0.82);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 2000;
  padding: 16px;
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
  animation: hudl-overlay-in 0.25s ease;
}

@keyframes hudl-overlay-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* The page behind the overlay is locked while it is open. */
body.hudl-modal-open {
  overflow: hidden;
}

.branding-overlay .overlay-content {
  background: #fff;
  width: 100%;
  max-width: 1000px;
  max-height: 88vh;
  /* dvh: on a phone, vh includes the area under the browser's toolbars, so a
     tall gallery pushed its header - close button and all - off the top. */
  max-height: 88dvh;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 0 0 22px;
  border-radius: 12px;
  position: relative;
  box-shadow: 0 24px 60px rgba(0, 6, 55, 0.45);
}

/* Sticky, so the title and the close button stay reachable while a long
   gallery scrolls. The close button used to scroll out of reach. */
.branding-overlay .overlay-header {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #fff;
  border-bottom: 1px solid #e6eaec;
  padding: 20px 64px 16px 22px;
}

.branding-overlay #overlay-name {
  color: #037a8e;
  font-size: 1.3rem;
  font-weight: 700;
  margin: 0 0 6px;
}

.branding-overlay #overlay-client {
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #037a8e;
  margin: 0 0 6px;
}

.branding-overlay #overlay-description {
  margin: 0;
  font-size: 0.92rem;
  line-height: 1.6;
  color: #5c6670;
}

/* Its look is shared with the site's other dialogs (DIALOG CLOSE BUTTONS in
   css/hudl-effects.css); only where it sits is set here. */
.branding-overlay #branding-close {
  position: absolute;
  top: 14px;
  right: 16px;
}

/* The project's "Full case study" from the CMS, between the sticky header
   and the gallery: the story first, then the pictures. Hidden by .d-none
   whenever the project has no case study. */
.branding-overlay .overlay-case {
  padding: 18px 22px 0;
}

.branding-overlay .overlay-case-title {
  color: #000637;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin: 0 0 10px;
}

.branding-overlay .overlay-case-body {
  font-size: 0.95rem;
  line-height: 1.75;
  color: #4a5560;
}

/* The body is editor-authored, so whatever the editor allows has to land
   somewhere sensible. */
.branding-overlay .overlay-case-body > *:first-child {
  margin-top: 0;
}

.branding-overlay .overlay-case-body > *:last-child {
  margin-bottom: 0;
}

.branding-overlay .overlay-case-body p,
.branding-overlay .overlay-case-body ul,
.branding-overlay .overlay-case-body ol {
  margin: 0 0 12px;
}

.branding-overlay .overlay-case-body h2,
.branding-overlay .overlay-case-body h3,
.branding-overlay .overlay-case-body h4,
.branding-overlay .overlay-case-body h5,
.branding-overlay .overlay-case-body h6 {
  color: #000637;
  font-size: 1.05rem;
  font-weight: 700;
  margin: 18px 0 8px;
}

.branding-overlay .overlay-case-body a {
  color: #037a8e;
  text-decoration: underline;
  word-break: break-word;
}

.branding-overlay .overlay-case-body blockquote {
  margin: 14px 0;
  padding: 2px 0 2px 14px;
  border-left: 3px solid #ffa132;
  color: #5c6670;
  font-style: italic;
}

.branding-overlay .overlay-case-body img {
  width: 100%;
  height: auto;
  margin: 10px 0;
  border-radius: 8px;
  background: #f1f4f5;
  border: 1px solid #eef1f2;
}

.branding-overlay .overlay-case-body table {
  width: 100%;
  margin: 0 0 12px;
  border-collapse: collapse;
}

.branding-overlay .overlay-case-body th,
.branding-overlay .overlay-case-body td {
  padding: 6px 8px;
  border: 1px solid #e6eaec;
  text-align: left;
  vertical-align: top;
}

.branding-overlay .overlay-images {
  padding: 20px 22px 0;
  margin-left: 0;
  margin-right: 0;
}

.branding-overlay .overlay-images img {
  width: 100%;
  height: auto;
  margin: 0;
  border-radius: 8px;
  background: #f1f4f5;
  border: 1px solid #eef1f2;
}

@media (max-width: 575.98px) {
  .branding-overlay {
    padding: 8px;
  }
  .branding-overlay .overlay-content {
    max-height: 92vh;
    max-height: 92dvh;
  }
  .branding-overlay #branding-close {
    top: 10px;
    right: 10px;
  }
  .branding-overlay .overlay-header {
    padding: 16px 58px 14px 16px;
  }
  .branding-overlay .overlay-case {
    padding: 14px 16px 0;
  }
  .branding-overlay .overlay-images {
    padding: 14px 10px 0;
  }
}
