/* ==========================================================================
   Main Custom CSS — HAOK Mladost
   Loaded after tokens.css. Site-wide custom styles that are NOT direct
   overrides of Divi's .et_pb_* classes go here (use divi-overrides.css for
   those). Reference design tokens via var(--haokm-*).

   Class naming: prefix custom classes with `haokm-`, applied in the builder
   via Advanced > Attributes (not the legacy "CSS ID & Classes" field).
   ========================================================================== */

/* Brand typography defaults */
body {
  font-family: var(--haokm-font-body);
}

h1, h2, h3, h4 {
  font-family: var(--haokm-font-heading);
}

/* Accessible focus ring for keyboard users (WCAG 2.1 AA).
   Red on the beige page background clears 4.5:1 contrast. */
:where(a, button, input, select, textarea, [tabindex]):focus-visible {
  outline: 2px solid var(--haokm-red);
  outline-offset: 2px;
}

/* Utility: constrain readable text blocks */
.haokm-readable {
  max-width: var(--haokm-max-width-text);
  margin-inline: auto;
}

/* Respect user motion preferences globally */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ==========================================================================
   News card — reusable card for related posts (and any post grid), ported
   from the prototype's .news-card. Output by the [haokm_related] shortcode.
   ========================================================================== */
.haokm-news-card {
  background: var(--haokm-white);
  border-radius: var(--haokm-radius);
  /*overflow: hidden;*/
  box-shadow: var(--haokm-shadow);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  display: flex;
  flex-direction: column;
}
.haokm-news-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--haokm-shadow-hover);
}
.haokm-news-card .thumb {
  border-top-left-radius: var(--haokm-radius);
  border-top-right-radius: var(--haokm-radius);
  display: block;
  aspect-ratio: 16 / 10;
  /* fallback when a post has no featured image; inline background-image wins */
  background: linear-gradient(135deg, var(--haokm-red-dark), var(--haokm-red));
  background-size: cover;
  background-position: center;
  position: relative;
}
.haokm-news-card .thumb .tag {
  position: absolute;
  top: 12px;
  left: 12px;
  background: var(--haokm-red);
  color: var(--haokm-white);
  font-size: 0.68rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 5px 10px;
  border-radius: 6px;
}
.haokm-news-card .body {
  padding: 16px 18px 20px;
  display: flex;
  flex-direction: column;
  flex: 1;
}
.haokm-news-card .date {
  font-size: 0.76rem;
  color: var(--haokm-red);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin-bottom: 7px;
}
.haokm-news-card h3 {
  font-size: 1.05rem;
  margin: 0 0 8px;
}
.haokm-news-card h3 a {
  color: var(--haokm-black);
  text-decoration: none;
}
.haokm-news-card h3 a:hover {
  color: var(--haokm-red);
}
.haokm-news-card .read {
  margin-top: auto;
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
  color: var(--haokm-black);
  letter-spacing: 0.4px;
  text-decoration: none;
}
.haokm-news-card .read::after {
  content: " →";
  color: var(--haokm-red);
}

/* ==========================================================================
   Related posts grid — [haokm_related] output. The "Povezane vijesti" heading
   is a separate Heading module with the .haokm-section-head class.
   ========================================================================== */
.haokm-related-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
}

/* ==========================================================================
   Previous / next post navigation — [haokm_post_nav] output.
   ========================================================================== */
.haokm-post-nav {
  display: flex;
  justify-content: space-between;
  gap: 14px;
}
.haokm-post-nav a {
  background: var(--haokm-white);
  border-radius: var(--haokm-radius-sm);
  box-shadow: var(--haokm-shadow);
  padding: 14px 18px;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--haokm-black);
  text-decoration: none;
  max-width: 48%;
  transition: color 0.2s ease;
}
.haokm-post-nav a:hover {
  color: var(--haokm-red);
}
.haokm-post-nav a small {
  display: block;
  font-weight: 600;
  color: var(--haokm-gray-text);
  text-transform: uppercase;
  font-size: 0.7rem;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}
.haokm-post-nav a.next {
  text-align: right;
  margin-left: auto;
}

/* Tablet / phone (prototype @ 768px) */
@media (max-width: 980px) {
  .haokm-related-grid {
    grid-template-columns: 1fr;
  }
  .haokm-post-nav {
    flex-direction: column;
  }
  .haokm-post-nav a,
  .haokm-post-nav a.next {
    max-width: 100%;
    text-align: left;
    margin: 0;
  }
}

/* ==========================================================================
   Team roster — output of [haokm_team_roster] (inc/snippets.php).
   Athletes card grid + coaches/staff lists, ported from the prototype's
   .players-grid / .staff-card (ai-research/prijedlog/sportasi.html), with
   --haokm-* tokens and the haokm- class prefix.
   ========================================================================== */
.haokm-roster {
  display: block;
}

/* Section heading above the coaches / staff lists. */
.haokm-roster-head {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 40px 0 22px;
}
.haokm-roster-head h2 {
  font-family: var(--haokm-font-heading);
  font-size: clamp(1.3rem, 2.4vw, 1.8rem);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin: 0;
  padding-bottom: 0;
  position: relative;
  padding-left: 16px;
}
.haokm-roster-head h2::before {
  content: "";
  position: absolute;
  left: 0;
  top: 4px;
  bottom: 4px;
  width: 6px;
  border-radius: 6px;
  background: var(--haokm-red);
}
.haokm-roster-head .line {
  flex: 1;
  height: 2px;
  background: var(--haokm-gray-border);
}

/* Athletes grid — 5 per row on desktop (a 20-player squad lands as 4 clean
   rows of 5, and the photo drops to roughly half its old width, which was the
   point). At that size the card is only ~200px wide inside a Divi row, so the
   info block below is deliberately compact: the position is printed once, as
   the red kicker, and the birth date carries no label. */
.haokm-players-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 16px;
}
/* Flex column + `margin-top: auto` on .meta pins the divider and the birth date
   to the bottom of every card. Grid rows stretch all cards to the tallest one,
   so even a name that needs an extra line cannot knock a card's divider out of
   line with its neighbours. */
.haokm-player-card {
  display: flex;
  flex-direction: column;
  background: var(--haokm-white);
  border-radius: var(--haokm-radius);
  box-shadow: var(--haokm-shadow);
  overflow: hidden;
  transition: transform 0.2s, box-shadow 0.2s;
}
.haokm-player-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--haokm-shadow-hover);
}
.haokm-player-photo {
  flex: none; /* keep the 3/4 ratio — a flex item would otherwise shrink */
  aspect-ratio: 3 / 4;
  background: var(--haokm-beige);
  position: relative;
  display: grid;
  place-items: center;
  overflow: hidden;
}
.haokm-player-photo .haokm-person-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.haokm-player-photo .haokm-person-ph {
  width: 64px;
  height: 64px;
  color: var(--haokm-red);
  opacity: 0.35;
}
.haokm-player-photo .num {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 1;
  background: var(--haokm-red);
  color: #fff;
  font-family: var(--haokm-font-heading);
  font-weight: 900;
  font-size: 0.95rem;
  width: 34px;
  height: 34px;
  border-radius: 9px;
  display: grid;
  place-items: center;
}
.haokm-player-info {
  display: flex;
  flex: 1;
  flex-direction: column;
  padding: 12px 12px 14px;
}
/* One line, always — several positions get an ellipsis rather than pushing the
   name down on that one card. The full list is on the player's profile. */
.haokm-player-info .pos {
  display: block;
  font-size: 0.68rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  line-height: 1.3;
  color: var(--haokm-red);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* Two lines are reserved whether the name needs them or not, so single-line
   names don't leave the block above the divider shorter than their neighbours. */
.haokm-player-info h3 {
  font-size: clamp(0.88rem, 0.78rem + 0.35vw, 1.02rem);
  line-height: 1.25;
  min-height: calc(2 * 1.25em);
  margin: 3px 0 9px;
  overflow-wrap: break-word;
}
.haokm-player-info h3 a {
  color: var(--haokm-black);
}
.haokm-player-info h3 a:hover {
  color: var(--haokm-red);
}
.haokm-player-info .meta {
  margin-top: auto;
  border-top: 1px solid var(--haokm-gray-border);
  padding-top: 8px;
}
.haokm-player-info .meta .label {
  display: block;
  font-size: 0.75rem;
  line-height: 1.3;
  letter-spacing: 0.3px;
  color: var(--haokm-gray-text);
}
.haokm-player-info .meta .date {
  display: block;
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1.3;
  color: var(--haokm-black);
  white-space: nowrap;
}

/* Coaches / staff lists */
.haokm-staff-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 18px;
}
.haokm-staff-card {
  display: flex;
  gap: 16px;
  align-items: center;
  background: var(--haokm-white);
  border-radius: var(--haokm-radius);
  box-shadow: var(--haokm-shadow);
  padding: 16px;
}
.haokm-staff-card .ph {
  width: 84px;
  height: 84px;
  flex: none;
  border-radius: 12px;
  background: var(--haokm-beige);
  display: grid;
  place-items: center;
  overflow: hidden;
}
.haokm-staff-card .ph .haokm-person-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.haokm-staff-card .ph .haokm-person-ph {
  width: 40px;
  height: 40px;
  color: var(--haokm-red);
  opacity: 0.35;
}
.haokm-staff-body {
  min-width: 0;
}
.haokm-staff-card .role {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--haokm-red);
}
.haokm-staff-card h3 {
  margin: 0 0 4px;
  font-size: 1.02rem;
}
.haokm-staff-card h3 a {
  color: var(--haokm-black);
}
.haokm-staff-card h3 a:hover {
  color: var(--haokm-red);
}
.haokm-staff-card .det {
  font-size: 0.84rem;
  color: var(--haokm-gray-text);
  margin-top: 6px;
}
.haokm-staff-card .det a {
  color: var(--haokm-red);
}

/* Roster responsive (active breakpoints: tablet 980, phone 767).
   The players grid steps 5 → 4 → 3 → 2 → 1 so the card never drops below
   roughly 160px, where the name would start breaking badly. */
@media (max-width: 1280px) {
  .haokm-players-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}
@media (max-width: 980px) {
  .haokm-players-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}
@media (max-width: 767px) {
  .haokm-players-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .haokm-staff-grid {
    grid-template-columns: 1fr;
  }
}
@media (max-width: 480px) {
  .haokm-players-grid {
    grid-template-columns: 1fr;
  }
}

/* ==========================================================================
   Single person profile — output of [haokm_profile] (inc/snippets.php).
   Photo (+ jersey badge) on the left, detail table on the right. Meant to sit
   inside the white content box. Ported from the prototype's .profile-photo /
   .detail-table (ai-research/prijedlog/profil.html).
   ========================================================================== */
.haokm-profile {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 34px;
  align-items: start;
}
.haokm-profile-photo {
  aspect-ratio: 3 / 4;
  background: var(--haokm-beige);
  border-radius: var(--haokm-radius);
  box-shadow: var(--haokm-shadow);
  position: relative;
  display: grid;
  place-items: center;
  overflow: hidden;
}
.haokm-profile-photo .haokm-person-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.haokm-profile-photo .haokm-person-ph {
  width: 90px;
  height: 90px;
  color: var(--haokm-red);
  opacity: 0.35;
}
.haokm-profile-photo .num {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 1;
  background: var(--haokm-red);
  color: #fff;
  font-family: var(--haokm-font-heading);
  font-weight: 900;
  font-size: 1.5rem;
  width: 58px;
  height: 58px;
  border-radius: 14px;
  display: grid;
  place-items: center;
}
.haokm-profile-badges {
  margin-bottom: 6px;
}
.haokm-profile-pos {
  display: inline-block;
  background: var(--haokm-yellow);
  color: var(--haokm-black);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-size: 0.76rem;
  padding: 6px 14px;
  border-radius: 30px;
  margin: 0 6px 8px 0;
}
.haokm-detail-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 10px;
}
.haokm-detail-table th,
.haokm-detail-table td {
  text-align: left;
  padding: 12px 4px;
  border-bottom: 1px solid var(--haokm-gray-border);
  font-size: 0.92rem;
}
.haokm-detail-table th {
  color: var(--haokm-gray-text);
  font-weight: 600;
  width: 40%;
}
.haokm-detail-table td {
  font-weight: 700;
}
.haokm-detail-table td a {
  color: var(--haokm-red);
}
.haokm-detail-table tr:last-child th,
.haokm-detail-table tr:last-child td {
  border-bottom: 0;
}

@media (max-width: 767px) {
  .haokm-profile {
    grid-template-columns: 1fr;
    gap: 22px;
  }
  .haokm-profile-photo {
    max-width: 240px;
    margin-left: auto;
    margin-right: auto;
  }
}

/* ---- Add custom site styles below ---- */

/* ==========================================================================
   Gallery cards — one shared component for every image-card grid shortcode
   ([haokm_gallery_seasons], [haokm_photo_albums]; see inc/snippets.php).
   All of them emit the same markup; the content modifiers
   .haok-gallery-grid--seasons / --albums and .haok-gallery-card--season /
   --album exist only so a single content type can be restyled later without
   forking this block.

   The card title is ALSO declared in divi-overrides.css: Divi's module
   heading typography loads after the child theme CSS and wins on equal
   specificity, so the h2 has to be re-asserted there. Its size is read from
   --haokm-gallery-title-size below, which stays the single source of truth.
   ========================================================================== */
.haok-gallery-grid {
  --haokm-gallery-title-size: clamp(1rem, 0.93rem + 0.32vw, 1.15rem);

  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: var(--haokm-space-5);
}

@media (max-width: 480px) {
  .haok-gallery-grid {
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  }
}

.haok-gallery-card {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: var(--haokm-radius);
  background: var(--haokm-white);
  box-shadow: var(--haokm-shadow);
  text-decoration: none;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.haok-gallery-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--haokm-shadow-hover);
}

.haok-gallery-card-image {
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: var(--haokm-beige);
}

.haok-gallery-card-image img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.haok-gallery-card-content {
  padding: var(--haokm-space-4) var(--haokm-space-5);
}

.haok-gallery-card-content h2 {
  margin: 0;
  font-family: var(--haokm-font-heading);
  font-size: var(--haokm-gallery-title-size);
  font-weight: 800;
  line-height: 1.3;
  color: var(--haokm-black);
  transition: color 0.2s ease;
}

.haok-gallery-card:hover .haok-gallery-card-content h2 {
  color: var(--haokm-red);
}

@media (max-width: 767px) {
  .haok-gallery-grid {
    gap: var(--haokm-space-4);
  }
}
