/*
Theme Name:   ButikCorfixen Child
Theme URI:    https://butikcorfixen.dk
Description: Child theme for GeneratePress – Scandinavian magazine style
Author:       ButikCorfixen
Author URI:   https://butikcorfixen.dk
Template:     generatepress
Version:      1.0
*/

/* ======================================================
   Scandinavian Editorial Style – Global tokens + base
   ====================================================== */

:root{
  --bc-text:#1f2937;
  --bc-muted:#6b7280;
  --bc-border:#e5e7eb;
  --bc-bg:#ffffff;
  --bc-soft:#f8fafc;
  --bc-accent:#8b5e34; /* varm nordisk tone */

  --bc-radius: 16px;
  --bc-radius-sm: 12px;
  --bc-shadow: 0 10px 30px rgba(0,0,0,.07);
  --bc-shadow-sm: 0 6px 18px rgba(0,0,0,.06);

  --bc-max: 860px;           /* content width */
  --bc-max-wide: 1120px;     /* hero/figure width */
  --bc-lh: 1.72;
}

body{
  color: var(--bc-text);
  background: var(--bc-bg);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* Links */
a{
  color: var(--bc-text);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
}
a:hover{ color: var(--bc-accent); }

/* Headings */
h1,h2,h3{
  letter-spacing:-0.02em;
  line-height:1.2;
}
h1{ font-size:clamp(2rem,3vw,2.75rem); }
h2{ font-size:clamp(1.5rem,2.2vw,2rem); }
h3{ font-size:1.25rem; }

/* Content width (GeneratePress) */
.site-content .content-area{
  max-width: 1040px;
  margin: 0 auto;
}
.entry-content{
  max-width: 760px;
  margin: 0 auto;
  font-size: 1.05rem; /* magazine feel */
}

/* Gutenberg spacing */
.entry-content > *{
  margin-bottom:1.25rem;
}

/* Rhythm for headings in content */
.entry-content h2{
  margin-top: 3rem;
}
.entry-content h3{
  margin-top: 2rem;
}

/* Article list styling */
article{
  border-bottom:1px solid var(--bc-border);
  padding-bottom:2.5rem;
  margin-bottom:2.5rem;
}
article:last-child{
  border-bottom:none;
  margin-bottom:0;
}

.entry-title a{
  text-decoration:none;
}
.entry-title a:hover{
  color:var(--bc-accent);
}

/* Images */
.entry-content img{
  border-radius:14px;
  box-shadow:0 8px 28px rgba(0,0,0,.08);
}

/* Soft boxes (use class is-style-bc-soft in blocks) */
.is-style-bc-soft{
  background:var(--bc-soft);
  border:1px solid var(--bc-border);
  border-radius:16px;
  padding:1.5rem;
}

/* Buttons (Gutenberg default) */
.wp-block-button__link{
  background:var(--bc-text);
  color:#fff !important;
  border-radius:999px;
  padding:.8rem 1.2rem;
  text-decoration:none;
}
.wp-block-button__link:hover{
  background:var(--bc-accent);
}

/* Header / navigation */
.main-navigation a{
  text-decoration:none;
  color:var(--bc-text);
}
.main-navigation a:hover{
  color:var(--bc-accent);
}

/* Footer */
.bc-footer{
  border-top:1px solid var(--bc-border);
  margin-top:4rem;
  padding:2rem 1rem;
  background:var(--bc-bg);
}
.bc-footer__inner{
  max-width:1040px;
  margin:0 auto;
  text-align:center;
}
.bc-footer__links{
  list-style:none;
  padding:0;
  margin:0 0 1rem 0;
  display:flex;
  flex-wrap:wrap;
  gap:.75rem 1.25rem;
  justify-content:center;
}
.bc-footer__links a{
  text-decoration:none;
  color:var(--bc-muted);
  font-size:.95rem;
}
.bc-footer__links a:hover{
  color:var(--bc-accent);
}
.bc-footer__meta{
  font-size:.85rem;
  color:var(--bc-muted);
}

/* ======================================================
   ButikCorfixen – Article UI (SEO + UX)
   Bruges til: .bc-article, TOC, callouts, FAQ, breadcrumbs
   ====================================================== */

.bc-article{
  color: var(--bc-text);
  background: transparent;
}

.bc-article__header,
.bc-article__content,
.bc-article__footer{
  max-width: var(--bc-max);
  margin: 0 auto;
  padding-left: 16px;
  padding-right: 16px;
}

@media (min-width: 900px){
  .bc-article__header,
  .bc-article__content,
  .bc-article__footer{
    padding-left: 0;
    padding-right: 0;
  }
}

/* Typography */
.bc-article__title{
  line-height: 1.15;
  letter-spacing: -.02em;
  margin: 10px 0 10px;
  font-weight: 800;
  font-size: clamp(1.85rem, 2.8vw, 2.6rem);
}

.bc-article__lede{
  margin: 0 0 14px;
  color: var(--bc-muted);
  font-size: 1.05rem;
  line-height: 1.65;
  max-width: 68ch;
}

.bc-article__content{
  line-height: var(--bc-lh);
  font-size: 1.02rem;
}

.bc-article__content p{
  margin: 0 0 1rem;
  max-width: 78ch;
}

.bc-article__content h2{
  margin: 2.2rem 0 .8rem;
  font-size: 1.55rem;
  line-height: 1.25;
  letter-spacing: -.01em;
}

.bc-article__content h3{
  margin: 1.4rem 0 .5rem;
  font-size: 1.18rem;
  line-height: 1.35;
}

.bc-article__content ul,
.bc-article__content ol{
  margin: 0 0 1.1rem 1.1rem;
  padding: 0;
}

.bc-article__content li{
  margin: .35rem 0;
}

.bc-article__content a{
  color: var(--bc-accent);
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-thickness: 1px;
}

.bc-article__content a:hover{
  text-decoration-thickness: 2px;
}

/* Prevent long URLs from breaking layout */
.bc-article__content a,
.bc-article__content p,
.bc-article__content li{
  overflow-wrap: anywhere;
}

/* Meta */
.bc-article__meta{
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  color: var(--bc-muted);
  font-size: .92rem;
  margin: 8px 0 16px;
}
.bc-article__meta-sep{ opacity: .6; }

/* Breadcrumbs */
.bc-breadcrumbs{
  margin: 6px 0 10px;
  font-size: .9rem;
  color: var(--bc-muted);
}
.bc-breadcrumbs__list{
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  list-style: none;
  padding: 0;
  margin: 0;
}
.bc-breadcrumbs__item a{
  color: var(--bc-muted);
  text-decoration: none;
  border-bottom: 1px solid transparent;
}
.bc-breadcrumbs__item a:hover{
  border-bottom-color: var(--bc-border);
}
.bc-breadcrumbs__sep{ opacity: .5; }

/* Hero image */
.bc-article__hero{
  max-width: var(--bc-max-wide);
  margin: 18px auto 18px;
  padding-left: 16px;
  padding-right: 16px;
}
@media (min-width: 900px){
  .bc-article__hero{
    padding-left: 0;
    padding-right: 0;
  }
}
.bc-article__hero img{
  width: 100%;
  height: auto;
  display: block;
  border-radius: var(--bc-radius);
  box-shadow: var(--bc-shadow);
  background: var(--bc-soft);
}
.bc-article__caption{
  margin-top: 10px;
  color: var(--bc-muted);
  font-size: .92rem;
  line-height: 1.5;
  max-width: 80ch;
}

/* Divider */
.bc-divider{
  border: 0;
  border-top: 1px solid var(--bc-border);
  margin: 1.8rem 0;
}

/* Callouts */
.bc-callout{
  border: 1px solid var(--bc-border);
  background: var(--bc-soft);
  border-radius: var(--bc-radius);
  padding: 16px 16px;
  margin: 16px 0 18px;
  box-shadow: var(--bc-shadow-sm);
}
.bc-callout__title{
  margin: 0 0 10px;
  font-size: 1.05rem;
  letter-spacing: -.01em;
}
.bc-callout--overview{ border-left: 6px solid var(--bc-accent); }
.bc-callout--tip{ border-left: 6px solid rgba(139,94,52,.5); }
.bc-callout--note{ border-left: 6px solid rgba(31,41,55,.18); }
.bc-callout--cta{ background: #fff; border: 1px solid var(--bc-border); }
.bc-callout--summary{ border-left: 6px solid var(--bc-accent); }

/* Checklist + linklist */
.bc-checklist,
.bc-linklist{
  list-style: none;
  padding: 0;
  margin: 0;
}
.bc-checklist li,
.bc-linklist li{
  position: relative;
  padding-left: 26px;
  margin: .55rem 0;
}
.bc-checklist li::before{
  content: "✓";
  position: absolute;
  left: 0;
  top: 0;
  color: var(--bc-accent);
  font-weight: 700;
}
.bc-linklist li::before{
  content: "→";
  position: absolute;
  left: 0;
  top: 0;
  color: var(--bc-muted);
}

/* TOC */
.bc-toc{
  border: 1px solid var(--bc-border);
  background: #fff;
  border-radius: var(--bc-radius);
  padding: 16px 16px;
  margin: 18px 0 22px;
  box-shadow: var(--bc-shadow-sm);
}
.bc-toc__title{
  margin: 0 0 10px;
  font-size: 1.05rem;
}
.bc-toc__list{
  margin: 0;
  padding-left: 1.2rem;
}
.bc-toc__list li{ margin: .35rem 0; }
.bc-toc a{
  color: var(--bc-text);
  text-decoration: none;
  border-bottom: 1px solid transparent;
}
.bc-toc a:hover{
  border-bottom-color: var(--bc-border);
}

/* Smooth anchors */
html{ scroll-behavior: smooth; }
.bc-article [id]{ scroll-margin-top: 90px; }

.bc-toc--sticky{
  position: sticky;
  top: 90px;
}

/* FAQ */
.bc-faq{ margin-top: 1.6rem; }
.bc-faq__item{
  border: 1px solid var(--bc-border);
  border-radius: var(--bc-radius-sm);
  background: #fff;
  margin: 10px 0;
  overflow: hidden;
  box-shadow: 0 4px 14px rgba(0,0,0,.05);
}
.bc-faq__q{
  cursor: pointer;
  padding: 14px 14px;
  font-weight: 700;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.bc-faq__q::-webkit-details-marker{ display: none; }
.bc-faq__q::after{
  content: "+";
  font-weight: 800;
  color: var(--bc-accent);
  flex: 0 0 auto;
}
details[open] > .bc-faq__q::after{ content: "–"; }
.bc-faq__a{
  padding: 0 14px 14px;
  color: var(--bc-text);
}
.bc-faq__a p{ margin: 10px 0 0; }

/* Authorbox / disclaimer */
.bc-authorbox{
  border: 1px solid var(--bc-border);
  background: #fff;
  border-radius: var(--bc-radius);
  padding: 14px 16px;
  margin: 18px 0 10px;
  box-shadow: var(--bc-shadow-sm);
}
.bc-authorbox__small{
  margin: 0;
  color: var(--bc-muted);
  line-height: 1.6;
}
.bc-article__disclaimer{ margin: 10px 0 0; }
.bc-muted{
  color: var(--bc-muted);
  font-size: .92rem;
  line-height: 1.6;
}

/* Figures inside content */
.bc-article__content figure{
  margin: 1.2rem 0 1.2rem;
}
.bc-article__content img{
  max-width: 100%;
  height: auto;
  border-radius: var(--bc-radius-sm);
}

/* Blockquote */
.bc-article__content blockquote{
  margin: 1.2rem 0;
  padding: 14px 16px;
  border-left: 6px solid rgba(139,94,52,.45);
  background: var(--bc-soft);
  border-radius: var(--bc-radius-sm);
  color: var(--bc-text);
}

/* Mobile tune */
@media (max-width: 520px){
  .bc-callout,
  .bc-toc{
    padding: 14px 14px;
  }
  .bc-article__lede{
    font-size: 1.02rem;
  }
}

/* Print */
@media print{
  .bc-toc,
  .bc-callout--cta{
    display: none !important;
  }
  .bc-article__hero img{
    box-shadow: none;
  }
}

/* ======================================================
   ButikCorfixen – Frontpage (hero, cards, latest posts)
   ====================================================== */

.bc-front-hero{
  padding: clamp(3rem, 6vw, 5.5rem) 16px;
  background: var(--bc-soft);
  border-bottom: 1px solid var(--bc-border);
}
.bc-front-hero__inner{
  max-width: var(--bc-max);
  margin: 0 auto;
}
.bc-front-hero__title{
  font-size: clamp(2rem, 3.5vw, 3rem);
  line-height: 1.1;
  margin-bottom: .8rem;
}
.bc-front-hero__lede{
  font-size: 1.1rem;
  color: var(--bc-muted);
  max-width: 65ch;
}
.bc-front-hero__actions{
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 16px 0 10px;
}
.bc-front-hero__trust{
  list-style: none;
  padding: 0;
  margin: 14px 0 0;
  color: var(--bc-muted);
  display: grid;
  gap: 6px;
}
.bc-front-hero__trust li{
  padding-left: 20px;
  position: relative;
}
.bc-front-hero__trust li::before{
  content: "•";
  position: absolute;
  left: 0;
  top: 0;
  color: var(--bc-accent);
  font-weight: 900;
}

/* Grid + cards */
.bc-grid{
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px,1fr));
  gap: 18px;
  margin-top: 1.5rem;
}
.bc-grid--featured{
  grid-template-columns: repeat(auto-fit, minmax(260px,1fr));
}
.bc-card{
  display: block;
  padding: 18px;
  border: 1px solid var(--bc-border);
  border-radius: var(--bc-radius);
  background: #fff;
  text-decoration: none;
  box-shadow: var(--bc-shadow-sm);
}
.bc-card h3{
  margin: 0 0 .35rem;
  color: var(--bc-text);
}
.bc-card p{
  margin: 0;
  color: var(--bc-muted);
  font-size: .95rem;
}
.bc-card__meta{
  display: inline-block;
  margin-top: 10px;
  color: var(--bc-muted);
  font-size: .88rem;
}

/* Buttons */
.bc-btn{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid var(--bc-border);
  text-decoration: none;
  font-weight: 700;
  line-height: 1;
  box-shadow: 0 6px 18px rgba(0,0,0,.06);
  transition: transform .08s ease, box-shadow .12s ease;
}
.bc-btn:hover{
  transform: translateY(-1px);
  box-shadow: 0 10px 24px rgba(0,0,0,.08);
}
.bc-btn--primary{
  background: var(--bc-accent);
  color: #fff;
  border-color: transparent;
}
.bc-btn--ghost{
  background: #fff;
  color: var(--bc-text);
}

/* Latest posts cards (shortcode) */
.bc-grid--latest{
  grid-template-columns: repeat(auto-fit, minmax(260px,1fr));
}
.bc-card--post{
  padding: 0;
  overflow: hidden;
}
.bc-card__link{
  display: block;
  text-decoration: none;
  color: inherit;
}
.bc-card__media{
  background: var(--bc-soft);
}
.bc-card__img{
  width: 100%;
  height: auto;
  display: block;
}
.bc-card__img--placeholder{
  width: 100%;
  aspect-ratio: 16 / 9;
  background: linear-gradient(180deg, rgba(0,0,0,.03), rgba(0,0,0,.01));
}
.bc-card__body{
  padding: 14px 16px 16px;
}
.bc-card__top{
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  color: var(--bc-muted);
  font-size: .9rem;
}
.bc-card__cat a{
  color: var(--bc-muted);
  text-decoration: none;
  border-bottom: 1px solid transparent;
}
.bc-card__cat a:hover{
  border-bottom-color: var(--bc-border);
}
.bc-card__dot{ opacity: .6; }
.bc-card__title{
  margin: 0 0 8px;
  font-size: 1.05rem;
  line-height: 1.35;
}
.bc-card__excerpt{
  margin: 0;
  color: var(--bc-muted);
  font-size: .95rem;
  line-height: 1.6;
}

/* ======================================================
   GeneratePress override fixes
   - Sikrer at CTA-tekst aldrig bliver hvid/usynlig
   ====================================================== */

/* Primary CTA: brun + hvid tekst (force) */
.bc-front-hero .bc-btn--primary,
.bc-frontpage a.bc-btn.bc-btn--primary,
.bc-article a.bc-btn.bc-btn--primary{
  background-color: var(--bc-accent) !important;
  color: #ffffff !important;
  border: 1px solid var(--bc-accent) !important;
  text-decoration: none !important;
}

/* Hover/focus */
.bc-front-hero .bc-btn--primary:hover,
.bc-front-hero .bc-btn--primary:focus,
.bc-frontpage a.bc-btn.bc-btn--primary:hover,
.bc-article a.bc-btn.bc-btn--primary:hover{
  background-color: color-mix(in srgb, var(--bc-accent), #000 8%) !important;
  color: #ffffff !important;
  text-decoration: none !important;
}

/* Ghost button: altid synlig tekst */
.bc-front-hero .bc-btn--ghost,
.bc-frontpage a.bc-btn.bc-btn--ghost,
.bc-article a.bc-btn.bc-btn--ghost{
  background: #ffffff !important;
  color: var(--bc-text) !important;
  border: 1px solid var(--bc-border) !important;
  text-decoration: none !important;
}

/* Fokus for keyboard */
.bc-front-hero .bc-btn--primary:focus-visible{
  outline: 2px solid rgba(139, 94, 52, 0.35);
  outline-offset: 3px;
}

/* ======================================================
   Featured image: skjul kun på single posts (ikke i lister)
   - Beholder featured til "seneste indlæg" mm.
   ====================================================== */

/* Gutenberg featured image block */
.single-post .inside-article .wp-block-post-featured-image{
  display: none !important;
}

/* Classic GP markup (fallback) */
.single-post .inside-article .post-image,
.single-post .inside-article .featured-image,
.single-post .inside-article .post-image-above-header{
  display: none !important;
}
/* =========================================================
   BUTIKCORFIXEN – Poleret archive/kategori grid + cards
   ========================================================= */

/* Container: 2 kolonner */
body.archive .site-main {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 28px;
  align-items: start;
}

@media (max-width: 900px) {
  body.archive .site-main { grid-template-columns: 1fr; gap: 18px; }
}

/* Header (titel + kategori-beskrivelse) øverst på tværs */
body.archive .page-header {
  grid-column: 1 / -1;
  margin-bottom: 8px;
}

/* Fjern klassisk spacing fra article */
body.archive .site-main article {
  margin: 0;
}

/* Kortet */
body.archive .site-main article .inside-article {
  border-radius: 18px;
  overflow: hidden;
  background: #fff;
  box-shadow: 0 10px 28px rgba(0,0,0,0.08);
  transition: transform .18s ease, box-shadow .18s ease;
  height: 100%;
  display: flex;
  flex-direction: column;
}

body.archive .site-main article .inside-article:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 34px rgba(0,0,0,0.12);
}

/* Featured image som "cover" med ens højde */
body.archive .post-image,
body.archive .featured-image {
  margin: 0 !important;
}

body.archive .post-image a,
body.archive .featured-image a {
  display: block;
}

body.archive .post-image img,
body.archive .featured-image img {
  display: block;
  width: 100%;
  height: 210px;          /* justér hvis du vil */
  object-fit: cover;
}

@media (max-width: 900px) {
  body.archive .post-image img,
  body.archive .featured-image img {
    height: 200px;
  }
}

/* Indholdspadding */
body.archive .entry-header,
body.archive .entry-summary,
body.archive .entry-content {
  padding: 14px 18px;
}

/* Meta-linje (kategori + læsetid + dato) */
body.archive .entry-meta {
  font-size: 13px;
  opacity: 0.75;
  margin: 0 0 8px 0;
}

body.archive .entry-meta a {
  text-decoration: none;
}

/* Title */
body.archive .entry-title {
  font-size: 18px;
  line-height: 1.25;
  margin: 0 0 10px 0;
}

body.archive .entry-title a {
  text-decoration: none;
}

/* Uddrag: clamp så kortene bliver ens */
body.archive .entry-summary {
  padding-top: 0;
  flex: 1; /* gør at cards får ens “bund” */
}

body.archive .entry-summary p {
  margin: 0;
  font-size: 14px;
  line-height: 1.55;
  opacity: 0.86;

  display: -webkit-box;
  -webkit-line-clamp: 3;   /* antal linjer i uddrag */
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Skjul "Læs mere" hvis du vil have ren forside-stil */
body.archive .read-more-container,
body.archive a.read-more {
  display: none !important;
}
/**
 * BUTIKCORFIXEN – Læsetid i entry meta (arkiver + single hvis ønsket)
 * Beregner ud fra ordantal (200 ord/min).
 */

function bc_reading_time_minutes($post_id = null, $wpm = 200) {
  $post_id = $post_id ?: get_the_ID();
  $content = get_post_field('post_content', $post_id);

  if (!$content) return '';

  $text = wp_strip_all_tags($content);
  $word_count = str_word_count($text);
  $minutes = (int) max(1, ceil($word_count / max(1, (int)$wpm)));

  return $minutes . ' min';
}

/**
 * Tilføj læsetid til GeneratePress meta (bruger generate_post_date filter).
 * Output bliver fx: "januar 27, 2026 · 3 min"
 */
add_filter('generate_post_date', function($time_string) {
  if (!is_archive() && !is_home()) {
    return $time_string;
  }

  $minutes = bc_reading_time_minutes(get_the_ID(), 200);
  if (!$minutes) return $time_string;

  return $time_string . ' · ' . esc_html($minutes);
});
