/*
Theme Name:  D-Mag Editorial
Theme URI:   https://d-mag.net
Author:      D-Mag
Description: Broadsheet editorial theme inspired by international affairs journals. Disciplined typography, hairline rules, red kicker accents.
Version:     1.0.0
Text Domain: dmag
*/

/* =========================================================
   TOKENS
   ========================================================= */
:root {
  --paper:       #ffffff;
  --paper-warm:  #f6f4ef;
  --ink:         #15191d;
  --ink-soft:    #4b4f54;
  --hairline:    #d8d4c9;
  --rule:        #15191d;
  --red:         #a32638;
  --navy:        #16243f;

  --serif: Georgia, "Times New Roman", serif;
  --sans:  -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;

  --maxw: 1180px;
}

/* =========================================================
   RESET
   ========================================================= */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 17px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
img  { max-width: 100%; height: auto; display: block; }
a    { color: inherit; text-decoration: none; }
ul   { margin: 0; padding: 0; list-style: none; }
h1, h2, h3, h4 { font-family: var(--serif); font-weight: 700; line-height: 1.15; margin: 0; }
p    { margin: 0 0 1.1em; }

.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 24px; }
hr.hairline    { border: 0; border-top: 1px solid var(--hairline); margin: 0; }
hr.rule-strong { border: 0; border-top: 2px solid var(--rule);     margin: 0; }

.eyebrow {
  font-family: var(--sans);
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--red);
  display: block;
  margin-bottom: 6px;
}
.eyebrow a { color: var(--red); }

.meta {
  font-family: var(--sans);
  font-size: 12.5px;
  color: var(--ink-soft);
}

/* =========================================================
   TOP BAR
   ========================================================= */
.top-bar {
  background: var(--navy);
  color: #cfd6e2;
  font-family: var(--sans);
  font-size: 12px;
}
.top-bar .wrap {
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 34px;
}
.top-bar a { color: #cfd6e2; }
.top-bar a:hover { color: #fff; }
.top-bar .topics a {
  margin-left: 18px;
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: .08em;
}

/* =========================================================
   MASTHEAD
   ========================================================= */
.masthead { padding: 28px 0 16px; text-align: center; }
.masthead .site-title { font-size: 46px; font-weight: 700; letter-spacing: -.01em; }
.masthead .site-title a { color: var(--ink); }
.masthead .tagline {
  font-family: var(--sans);
  font-size: 12px;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin-top: 6px;
}

/* =========================================================
   NAV — bold navy bar (Foreign Affairs style)
   ========================================================= */
.main-nav { background: #1c3354; }
.main-nav .wrap { display: flex; justify-content: space-between; align-items: center; }
.main-nav ul  { display: flex; flex-wrap: wrap; }
.main-nav a {
  display: block;
  padding: 14px 16px;
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: #c8d4e6;
}
.main-nav a:hover { color: #ffffff; }
.main-nav .current-menu-item > a,
.main-nav .current-cat > a {
  color: #ffffff;
  border-bottom: 2px solid #e8a020;
  padding-bottom: 12px;
}

/* =========================================================
   FRONT PAGE — HERO
   ========================================================= */
.hero { padding: 36px 0 0; }
.hero-grid {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 0;
  border-bottom: 1px solid var(--hairline);
  padding-bottom: 32px;
}

/* Lead story */
.hero-lead { padding-right: 40px; border-right: 1px solid var(--hairline); }
.hero-lead .thumb {
  aspect-ratio: 16/10;
  overflow: hidden;
  margin-bottom: 18px;
  background: var(--paper-warm);
}
.hero-lead .thumb img { width: 100%; height: 100%; object-fit: cover; }
.hero-lead h1 { font-size: 38px; margin: 10px 0 14px; line-height: 1.12; }
.hero-lead h1 a:hover { color: var(--red); }
.hero-lead .dek { font-style: italic; font-size: 18px; color: var(--ink-soft); margin-bottom: 10px; }

/* Side stack */
.hero-side { padding-left: 28px; display: flex; flex-direction: column; }
.side-item { padding: 18px 0; border-bottom: 1px solid var(--hairline); }
.side-item:last-child { border-bottom: 0; }
.side-item h3 { font-size: 18px; margin: 6px 0 6px; line-height: 1.2; }
.side-item h3 a:hover { color: var(--red); }

/* Second row — three columns under the hero */
.hero-lower {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0;
  margin-top: 32px;
}
.hero-lower .lower-item {
  padding: 0 24px 32px;
  border-right: 1px solid var(--hairline);
}
.hero-lower .lower-item:first-child { padding-left: 0; }
.hero-lower .lower-item:last-child  { padding-right: 0; border-right: 0; }
.hero-lower .thumb {
  aspect-ratio: 3/2;
  overflow: hidden;
  margin-bottom: 14px;
  background: var(--paper-warm);
}
.hero-lower .thumb img { width: 100%; height: 100%; object-fit: cover; transition: transform .35s ease; }
.hero-lower .lower-item a:hover .thumb img { transform: scale(1.03); }
.hero-lower h3 { font-size: 20px; margin: 8px 0 8px; line-height: 1.18; }
.hero-lower h3 a:hover { color: var(--red); }

/* =========================================================
   SECTION HEADING
   ========================================================= */
.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin: 36px 0 16px;
  border-top: 2px solid var(--rule);
  padding-top: 10px;
}
.section-head h2 {
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
}

/* =========================================================
   ARTICLE GRID
   ========================================================= */
.grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 32px 28px;
}
.card .thumb {
  aspect-ratio: 4/3;
  overflow: hidden;
  margin-bottom: 12px;
  background: var(--paper-warm);
}
.card .thumb img { width: 100%; height: 100%; object-fit: cover; transition: transform .4s ease; }
.card a:hover .thumb img { transform: scale(1.035); }
.card h3 { font-size: 20px; margin: 6px 0 8px; }
.card h3 a:hover { color: var(--red); }
.card .excerpt { font-size: 15px; color: var(--ink-soft); }
.card .meta { margin-top: 8px; }

/* =========================================================
   ARCHIVE LIST
   ========================================================= */
.archive-list { display: flex; flex-direction: column; }
.archive-row {
  display: grid;
  grid-template-columns: 1fr 220px;
  gap: 28px;
  padding: 24px 0;
  border-top: 1px solid var(--hairline);
  align-items: center;
}
.archive-row:first-child { border-top: 0; }
.archive-row h2 { font-size: 25px; margin: 6px 0 10px; }
.archive-row h2 a:hover { color: var(--red); }
.archive-row .thumb { aspect-ratio: 4/3; overflow: hidden; background: var(--paper-warm); }
.archive-row .thumb img { width: 100%; height: 100%; object-fit: cover; }

/* =========================================================
   SIDEBAR RAIL
   ========================================================= */
.layout-with-rail { display: grid; grid-template-columns: 1fr 300px; gap: 50px; }
.rail { border-top: 2px solid var(--rule); padding-top: 16px; }
.rail h2 {
  font-family: var(--sans);
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  margin-bottom: 14px;
}
.most-read li { padding: 12px 0; border-top: 1px solid var(--hairline); }
.most-read li:first-child { border-top: 0; }
.most-read .num {
  font-family: var(--serif);
  font-size: 24px;
  color: var(--hairline);
  font-weight: 700;
  display: block;
}
.most-read a { font-size: 15px; }
.most-read a:hover { color: var(--red); }

/* =========================================================
   SINGLE ARTICLE
   ========================================================= */
.article-header { max-width: 760px; margin: 40px auto 0; text-align: center; padding: 0 24px; }
.article-header h1 { font-size: 40px; margin: 10px 0 14px; }
.article-header .dek { font-style: italic; font-size: 20px; color: var(--ink-soft); margin-bottom: 18px; }
.byline-row {
  display: flex;
  justify-content: center;
  gap: 14px;
  font-family: var(--sans);
  font-size: 13px;
  color: var(--ink-soft);
  padding-bottom: 20px;
  border-bottom: 1px solid var(--hairline);
}
.byline-row .author { color: var(--ink); font-weight: 700; }

.article-feature-image { max-width: var(--maxw); margin: 28px auto; padding: 0 24px; }
.article-feature-image img { width: 100%; aspect-ratio: 16/9; object-fit: cover; }
.article-feature-image figcaption {
  font-family: var(--sans);
  font-size: 12px;
  color: var(--ink-soft);
  margin-top: 8px;
  border-left: 2px solid var(--red);
  padding-left: 10px;
}

.article-body { max-width: 700px; margin: 0 auto; padding: 0 24px 60px; font-size: 19px; line-height: 1.72; }
.article-body p:first-of-type::first-letter {
  float: left;
  font-size: 76px;
  line-height: .78;
  font-weight: 700;
  padding: 6px 8px 0 0;
  color: var(--ink);
}
.article-body h2 { font-size: 26px; margin: 36px 0 12px; }
.article-body h3 { font-size: 21px; margin: 28px 0 10px; }
.article-body blockquote {
  margin: 30px 0;
  padding-left: 20px;
  border-left: 3px solid var(--red);
  font-style: italic;
  font-size: 22px;
}
.article-body a { color: var(--red); text-decoration: underline; text-underline-offset: 3px; }

.tags-row { max-width: 700px; margin: 0 auto; padding: 0 24px 50px; }
.tags-row a {
  display: inline-block;
  font-family: var(--sans);
  font-size: 11px;
  letter-spacing: .07em;
  text-transform: uppercase;
  border: 1px solid var(--hairline);
  padding: 5px 12px;
  margin: 0 8px 8px 0;
}
.tags-row a:hover { border-color: var(--red); color: var(--red); }

.related { max-width: var(--maxw); margin: 0 auto; padding: 28px 24px 70px; border-top: 2px solid var(--rule); }

/* =========================================================
   FOOTER
   ========================================================= */
.site-footer { background: var(--navy); color: #aab3c5; margin-top: 70px; }
.site-footer .wrap { padding: 50px 24px 28px; }
.footer-grid { display: grid; grid-template-columns: 1.4fr repeat(3, 1fr); gap: 32px; }
.footer-brand { font-family: var(--serif); color: #fff; font-size: 26px; margin-bottom: 10px; }
.footer-blurb { font-family: var(--sans); font-size: 13px; line-height: 1.65; max-width: 30ch; }
.footer-grid h2 {
  font-family: var(--sans);
  color: #fff;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  margin-bottom: 14px;
}
.footer-grid li { font-family: var(--sans); font-size: 13.5px; margin-bottom: 8px; }
.footer-grid a:hover { color: #fff; }
.footer-bottom {
  display: flex;
  justify-content: space-between;
  font-family: var(--sans);
  font-size: 11.5px;
  color: #7f8aa0;
  padding-top: 22px;
  margin-top: 28px;
  border-top: 1px solid #2a3a5a;
}

/* =========================================================
   RESPONSIVE
   ========================================================= */
@media (max-width: 900px) {
  .hero-grid            { grid-template-columns: 1fr; }
  .hero-lead            { padding-right: 0; border-right: 0; }
  .hero-side            { padding-left: 0; border-top: 1px solid var(--hairline); margin-top: 24px; }
  .hero-lower           { grid-template-columns: 1fr; }
  .hero-lower .lower-item { padding: 16px 0; border-right: 0; border-top: 1px solid var(--hairline); }
  .grid                 { grid-template-columns: repeat(2, 1fr); }
  .layout-with-rail     { grid-template-columns: 1fr; }
  .footer-grid          { grid-template-columns: 1fr 1fr; }
  .archive-row          { grid-template-columns: 1fr; }
  .archive-row .thumb   { order: -1; }
}
@media (max-width: 600px) {
  .grid                 { grid-template-columns: 1fr; }
  .masthead .site-title { font-size: 32px; }
  .article-header h1    { font-size: 28px; }
  .hero-lead h1         { font-size: 26px; }
  .footer-grid          { grid-template-columns: 1fr; }
  .top-bar .topics      { display: none; }
  .hero-lower           { grid-template-columns: 1fr; }
}
