@use '../abstracts' as *;

// ============================================================
// Single posts and pages
// ============================================================

// ---- Post hero ----
.post-hero { max-width: 760px; margin: 0 auto; text-align: center; }

.hero-tag {
  display: inline-block;
  background: var(--glass);
  @include glass-blur(8px);
  border: 1px solid var(--hairline);
  color: var(--accent-deep);
  font-size: 13px; font-weight: 500; letter-spacing: 0.08em;
  padding: 7px 20px; border-radius: $pill-radius; margin-bottom: 22px;
  text-decoration: none;
  transition: color 0.25s ease, transform 0.25s ease;

  &:hover { transform: translateY(-2px); }
}

// A child page's parents, in the pill
.hero-tag--trail {
  a { color: inherit; text-decoration: none; }
  a:hover { text-decoration: underline; text-underline-offset: 3px; }
  span { margin: 0 4px; color: var(--ink-faint); }
  &:hover { transform: none; }
}

.hero-title {
  font-family: $font-serif;
  font-size: clamp(30px, 5vw, 46px);
  font-weight: 400; line-height: 1.42; margin-bottom: 22px;
  overflow-wrap: break-word; // long titles (PLAYBOOK §2)
}

.hero-meta {
  display: flex; align-items: center; justify-content: center;
  gap: 12px; color: var(--ink-faint); font-size: 14.5px;

  .avatar {
    @include circle(38px);
    object-fit: cover;
    border: 2px solid var(--ring);
    box-shadow: 0 6px 16px -8px rgba(86, 112, 140, 0.4);
  }

  .author-link {
    color: var(--ink-soft); font-weight: 500; text-decoration: none;

    &:hover { color: var(--accent-deep); }
  }

  // The date is a permalink — same look, colour on hover only (PLAYBOOK §9)
  .posted-on a {
    color: inherit;
    text-decoration: none;

    &:hover { color: var(--accent-deep); }
  }

  .dot { @include circle(4px); background: var(--ink-faint); flex-shrink: 0; }

  // Two lines on phones: avatar + name, then date · reading time
  @include below(mobile) {
    flex-wrap: wrap;
    gap: 6px 10px;
    font-size: 14px;

    > * { white-space: nowrap; }

    // The dot after the name is hidden and becomes the line break
    .author-link + .dot {
      flex-basis: 100%;
      height: 0;
      background: none;
    }
  }
}

// ---- Featured image (alonely_featured_image(), decision D16) ----
.featured-img {
  max-width: 900px; margin: 40px auto 0;
  border-radius: var(--radius-lg); overflow: hidden;
  box-shadow: var(--shadow-soft);
  border: 1px solid var(--hairline);

  img {
    display: block;
    filter: var(--img-filter);
  }

  // A large landscape photo: the design's 21:10 band
  &.is-cropped img {
    width: 100%; height: auto;
    aspect-ratio: 21 / 10; object-fit: cover;
  }

  // Anything smaller or taller: its own size, centred, never enlarged
  &.is-natural {
    width: fit-content;
    max-width: min(900px, 100%);

    img {
      width: auto;
      max-width: 100%;
      height: auto;
      max-height: 640px;
    }
  }
}

// ---- Tags ----
.post-tags {
  max-width: 700px; margin: 44px auto 0;
  display: flex; flex-wrap: wrap; gap: 10px;

  a {
    background: var(--glass);
    border: 1px solid var(--hairline);
    color: var(--ink-soft); font-size: 13.5px;
    padding: 6px 16px; border-radius: $pill-radius; text-decoration: none;
    transition: color 0.25s ease, transform 0.25s ease;

    &:hover { color: var(--accent-deep); transform: translateY(-2px); }
  }
}

// ---- Author box ----
.author-box {
  max-width: 760px; margin: 56px auto 0;
  display: flex; align-items: center; gap: 28px;
  background: var(--card);
  @include glass-blur(14px);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-lg);
  padding: 32px 36px;
  box-shadow: var(--shadow-soft);

  @include below(mobile) {
    flex-direction: column; text-align: center; padding: 28px 22px;
  }

  .avatar {
    @include circle(88px);
    object-fit: cover;
    flex-shrink: 0; border: 4px solid var(--ring);
    box-shadow: var(--shadow-avatar);
  }

  .box-text { min-width: 0; }
  .box-label { font-size: 13px; letter-spacing: 0.14em; color: var(--accent-deep); font-weight: 500; margin-bottom: 4px; } // text: --accent-deep (D9; --accent is 3.2:1)

  .box-name {
    font-family: $font-serif; font-size: 22px; color: var(--ink); margin-bottom: 6px;

    a { color: inherit; text-decoration: none; }
    a:hover { color: var(--accent-deep); }
  }

  .box-bio { font-size: 15px; font-weight: 300; color: var(--ink-soft); }
}

// ---- Previous / next post ----
.post-nav {
  max-width: 760px; margin: 40px auto 0;
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 18px;

  @include below(mobile) {
    grid-template-columns: minmax(0, 1fr);
  }

  a {
    min-width: 0;
    background: var(--card-solid);
    border: 1px solid var(--hairline);
    border-radius: var(--radius-md);
    padding: 22px 26px; text-decoration: none;
    box-shadow: var(--shadow-soft);
    transition: transform 0.3s ease, box-shadow 0.3s ease;

    &:hover { transform: translateY(-4px); box-shadow: var(--shadow-hover); }
  }

  .nav-label { font-size: 13px; color: var(--ink-faint); display: block; margin-bottom: 6px; }

  .nav-title {
    font-family: $font-serif; font-size: 17px; color: var(--ink); line-height: 1.5;
    @include line-clamp(2);
    overflow-wrap: anywhere;
  }

  .nav-next {
    grid-column: 2; // stays in the right column even with no previous post
    text-align: right;

    @include below(mobile) {
      grid-column: auto;
      text-align: left;
    }
  }
}

// ---- Page (page.php) ----
.page-hero .hero-title { margin-bottom: 0; }
.page-hero .page-excerpt {
  margin-top: 16px;
  color: var(--ink-soft);
  font-size: 17px;
  font-weight: 300;
}

// ---- 404 ----
.error-404 {
  .archive-description { margin-bottom: 8px; }
}
