/*
Theme Name: MyLegge
Theme URI: https://mylegge.it
Author: Francesco Capparelli
Description: Tema editoriale originale per MyLegge.it: autorevole, accessibile, veloce e privo di dipendenze esterne.
Version: 1.0.2
Requires at least: 6.5
Tested up to: 7.0
Requires PHP: 8.1
Text Domain: mylegge
*/

:root {
  --paper: #f5f0e7;
  --paper-deep: #ebe2d4;
  --ink: #191816;
  --muted: #6e675e;
  --accent: #b83d2e;
  --accent-dark: #8e2d22;
  --forest: #234845;
  --line: rgba(25, 24, 22, 0.2);
  --shadow: 0 18px 60px rgba(33, 27, 19, 0.12);
  --serif: Iowan Old Style, Baskerville, "Times New Roman", serif;
  --sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --content: 760px;
  --wide: 1240px;
}

/* MyLegge identity: a distinct legal-tech publication, not a variation of the
   personal magazine. These rules intentionally reshape the shared foundation. */
:root {
  --paper: #f7f9fb;
  --paper-deep: #e8eef2;
  --ink: #0b1e2a;
  --muted: #526570;
  --accent: #19a7b8;
  --accent-dark: #087b8a;
  --forest: #0b1e2a;
  --line: rgba(11, 30, 42, 0.17);
  --shadow: 0 22px 70px rgba(5, 23, 34, 0.15);
  --serif: Charter, Iowan Old Style, Georgia, serif;
  --sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.site-header { background: var(--ink); color: #fff; border-bottom: 0; }
.header-inner { min-height: 92px; }
.wordmark {
  gap: 0;
  font-family: var(--sans);
  font-size: clamp(1.65rem, 3vw, 2.35rem);
  font-weight: 850;
  letter-spacing: -0.06em;
}
.wordmark span:first-child { color: #fff; }
.wordmark span:last-child { color: var(--accent); }
.site-description { color: rgba(255,255,255,0.6); }
.main-navigation a { color: #fff; }
.main-navigation a:hover { color: var(--accent); }
.menu-toggle { border-color: #fff; color: #fff; }

.hero {
  min-height: min(720px, 78vh);
  display: flex;
  align-items: center;
  background: var(--ink);
  color: #fff;
  border-bottom: 8px solid var(--accent);
}
.hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, rgba(25,167,184,0.1) 1px, transparent 1px),
    linear-gradient(rgba(25,167,184,0.1) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: linear-gradient(to left, #000, transparent 65%);
}
.hero::after {
  content: "§";
  right: 4vw;
  bottom: -0.28em;
  color: rgba(25,167,184,0.16);
  font-family: var(--serif);
  font-size: clamp(270px, 36vw, 560px);
}
.hero-grid { grid-template-columns: minmax(0, 1.25fr) minmax(260px, 0.75fr); }
.hero h1 {
  max-width: 860px;
  font-family: var(--sans);
  font-size: clamp(3.6rem, 8vw, 7.8rem);
  font-weight: 850;
  letter-spacing: -0.075em;
  line-height: 0.87;
}
.hero .eyebrow { color: var(--accent); }
.hero-copy { border-left-color: var(--accent); font-family: var(--sans); font-size: 1.18rem; }
.hero .button-link { background: var(--accent); border-color: var(--accent); color: var(--ink); }
.hero .button-link:hover { background: #fff; border-color: #fff; color: var(--ink); }

.latest-section { background: #fff; }
.section-heading { border-bottom: 4px solid var(--ink); }
.section-heading h2, .archive-header h1 { font-family: var(--sans); font-weight: 820; letter-spacing: -0.055em; }
.story-title, .story-card:first-child .story-title { font-family: var(--serif); }
.story-image { background: var(--paper-deep); border-radius: 2px; }
.story-card:first-child .story-image { border-bottom: 6px solid var(--accent); }

.topics-section { padding: clamp(70px, 9vw, 120px) 0; background: var(--paper); }
.topic-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; background: var(--line); border: 1px solid var(--line); }
.topic-card { min-height: 220px; padding: 30px; background: var(--paper); text-decoration: none; }
.topic-card:hover { background: var(--ink); color: #fff; }
.topic-number { display: block; margin-bottom: 48px; color: var(--accent); font-size: 0.72rem; font-weight: 800; letter-spacing: 0.1em; }
.topic-title { margin: 0 0 10px; font-family: var(--sans); font-size: 1.35rem; font-weight: 800; letter-spacing: -0.035em; }
.topic-description { margin: 0; color: var(--muted); font-size: 0.82rem; line-height: 1.45; }
.topic-card:hover .topic-description { color: rgba(255,255,255,0.68); }

.manifesto { background: var(--accent); color: var(--ink); }
.manifesto h2 { font-family: var(--sans); font-weight: 850; }
.manifesto .section-kicker { color: var(--ink); }
.manifesto-copy { font-family: var(--serif); font-weight: 600; }

.entry-title { font-family: var(--sans); font-weight: 850; letter-spacing: -0.065em; }
.entry-featured img { border-bottom: 8px solid var(--accent); }
.entry-content blockquote { border-left-color: var(--accent); color: var(--ink); }
.site-footer { background: #06131b; }
.footer-title { font-family: var(--sans); font-weight: 850; }

@media (max-width: 900px) {
  .topic-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 600px) {
  .topic-grid { grid-template-columns: 1fr; }
  .hero { min-height: auto; }
}

*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 18px;
  line-height: 1.65;
  text-rendering: optimizeLegibility;
}

img { display: block; max-width: 100%; height: auto; }
a { color: inherit; text-decoration-thickness: 1px; text-underline-offset: 0.2em; }
a:hover { color: var(--accent); }
button, input, textarea, select { font: inherit; }

.screen-reader-text {
  position: absolute !important;
  width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.screen-reader-text:focus {
  top: 12px; left: 12px; z-index: 100000;
  width: auto; height: auto; padding: 12px 18px; margin: 0;
  overflow: visible; clip: auto; white-space: normal;
  background: #fff; color: #000;
}

.site-shell { width: min(calc(100% - 40px), var(--wide)); margin-inline: auto; }
.content-width { width: min(calc(100% - 40px), var(--content)); margin-inline: auto; }

.site-header {
  position: relative;
  border-bottom: 1px solid var(--line);
  background: rgba(245, 240, 231, 0.96);
}
.header-inner {
  min-height: 104px;
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto;
  align-items: center;
  gap: 32px;
}
.site-branding { line-height: 1; }
.wordmark {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0 0.08em;
  max-width: 610px;
  font-family: var(--serif);
  font-size: clamp(1.45rem, 3vw, 2.4rem);
  font-weight: 700;
  letter-spacing: -0.045em;
  text-decoration: none;
}
.wordmark span:last-child { color: var(--accent); }
.site-description {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.menu-toggle {
  display: none;
  border: 1px solid var(--ink);
  background: transparent;
  padding: 9px 12px;
  cursor: pointer;
}
.main-navigation ul, .footer-navigation ul {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 20px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.main-navigation a {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-decoration: none;
  text-transform: uppercase;
}

.hero {
  position: relative;
  overflow: hidden;
  padding: clamp(76px, 10vw, 150px) 0 clamp(70px, 9vw, 126px);
  border-bottom: 1px solid var(--line);
}
.hero::after {
  content: "?";
  position: absolute;
  right: -0.07em;
  bottom: -0.42em;
  color: rgba(184, 61, 46, 0.08);
  font-family: var(--serif);
  font-size: clamp(300px, 42vw, 650px);
  font-weight: 700;
  line-height: 1;
  pointer-events: none;
}
.hero-grid {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(240px, 0.6fr);
  gap: clamp(48px, 8vw, 110px);
  align-items: end;
}
.eyebrow, .section-kicker, .post-kicker {
  margin: 0 0 18px;
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.hero h1 {
  max-width: 900px;
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(3.4rem, 8.8vw, 8rem);
  font-weight: 500;
  letter-spacing: -0.065em;
  line-height: 0.88;
}
.hero-copy {
  padding-left: 24px;
  border-left: 3px solid var(--accent);
  font-family: var(--serif);
  font-size: clamp(1.25rem, 2vw, 1.7rem);
  line-height: 1.35;
}
.hero-copy p { margin-top: 0; }

.button-link {
  display: inline-block;
  padding: 12px 18px;
  border: 1px solid var(--ink);
  background: var(--ink);
  color: var(--paper);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-decoration: none;
  text-transform: uppercase;
  transition: transform 160ms ease, background 160ms ease;
}
.button-link:hover { background: var(--accent); color: #fff; transform: translateY(-2px); }

.latest-section, .archive-shell { padding: clamp(70px, 9vw, 120px) 0; }
.section-heading {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 24px;
  margin-bottom: 36px;
  padding-bottom: 16px;
  border-bottom: 2px solid var(--ink);
}
.section-heading h2, .archive-header h1 {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(2.4rem, 5vw, 4.4rem);
  font-weight: 500;
  letter-spacing: -0.045em;
  line-height: 1;
}
.section-heading a { font-size: 0.78rem; font-weight: 800; text-transform: uppercase; }

.story-grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 34px 28px;
}
.story-card { grid-column: span 4; }
.story-card:first-child { grid-column: span 8; grid-row: span 2; }
.story-card article { height: 100%; }
.story-card a { text-decoration: none; }
.story-image {
  aspect-ratio: 16 / 10;
  margin-bottom: 18px;
  overflow: hidden;
  background: var(--paper-deep);
}
.story-image img { width: 100%; height: 100%; object-fit: cover; transition: transform 420ms ease; }
.story-card a:hover .story-image img { transform: scale(1.025); }
.story-card:first-child .story-image { aspect-ratio: 16 / 9; }
.story-title {
  margin: 0 0 10px;
  font-family: var(--serif);
  font-size: clamp(1.45rem, 2.5vw, 2.35rem);
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1.08;
}
.story-card:first-child .story-title { font-size: clamp(2.2rem, 4.5vw, 4.3rem); }
.story-excerpt { margin: 0; color: var(--muted); font-size: 0.92rem; line-height: 1.55; }
.story-meta, .entry-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.manifesto {
  padding: clamp(70px, 9vw, 120px) 0;
  background: var(--forest);
  color: #f8f2e8;
}
.manifesto-grid {
  display: grid;
  grid-template-columns: 0.7fr 1.3fr;
  gap: clamp(44px, 8vw, 120px);
}
.manifesto h2 {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(2.4rem, 5vw, 5rem);
  font-weight: 500;
  letter-spacing: -0.05em;
  line-height: 0.95;
}
.manifesto-copy { max-width: 720px; font-family: var(--serif); font-size: 1.35rem; line-height: 1.5; }
.manifesto-copy p:first-child { margin-top: 0; }

.archive-header { margin-bottom: 50px; }
.archive-description { max-width: 680px; color: var(--muted); }
.archive-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 44px 28px; }

.entry-header { padding: clamp(70px, 8vw, 120px) 0 50px; }
.entry-title {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(3rem, 7vw, 6.6rem);
  font-weight: 500;
  letter-spacing: -0.055em;
  line-height: 0.96;
}
.entry-deck { max-width: 850px; margin: 28px 0 0; color: var(--muted); font-family: var(--serif); font-size: 1.45rem; line-height: 1.4; }
.entry-featured { width: min(calc(100% - 40px), var(--wide)); margin: 0 auto 60px; }
.entry-featured img { width: 100%; max-height: 720px; object-fit: cover; box-shadow: var(--shadow); }
.entry-content { padding-bottom: 80px; font-family: var(--serif); font-size: clamp(1.15rem, 1.5vw, 1.28rem); }
.entry-content > * { max-width: var(--content); margin-left: auto; margin-right: auto; }
.entry-content > .alignwide { max-width: var(--wide); }
.entry-content > .alignfull { max-width: none; }
.entry-content p { margin-top: 0; margin-bottom: 1.45em; }
.entry-content h2, .entry-content h3 {
  margin-top: 1.7em;
  margin-bottom: 0.65em;
  font-family: var(--sans);
  letter-spacing: -0.025em;
  line-height: 1.15;
}
.entry-content blockquote {
  padding: 8px 0 8px 28px;
  border-left: 4px solid var(--accent);
  color: var(--forest);
  font-size: 1.35em;
  font-style: italic;
}
.entry-content a { color: var(--accent-dark); }
.entry-content figcaption { color: var(--muted); font-family: var(--sans); font-size: 0.72rem; text-align: center; }

.post-footer {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  padding: 26px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  font-size: 0.82rem;
}

.about-page { padding: clamp(70px, 9vw, 130px) 0; }
.about-grid {
  display: grid;
  grid-template-columns: minmax(280px, 0.82fr) minmax(0, 1.18fr);
  gap: clamp(48px, 8vw, 112px);
  align-items: start;
}
.about-portrait { position: sticky; top: 28px; }
.about-portrait img { width: 100%; aspect-ratio: 4 / 5; object-fit: cover; box-shadow: var(--shadow); }
.about-copy .entry-title { margin-bottom: 40px; }
.about-copy .entry-content { padding-bottom: 0; font-size: 1.18rem; }
.about-copy .entry-content > * { max-width: none; margin-left: 0; margin-right: 0; }
.about-signature {
  margin-top: 44px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.author-box {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 26px;
  align-items: center;
  margin: 60px auto 90px;
  padding: 34px;
  background: var(--paper-deep);
}
.author-box img { border-radius: 50%; aspect-ratio: 1; object-fit: cover; }
.author-box h2 { margin: 0 0 8px; font-family: var(--serif); font-size: 1.8rem; }
.author-box p { margin: 0; color: var(--muted); font-size: 0.9rem; }

.pagination { margin-top: 60px; }
.pagination .nav-links { display: flex; flex-wrap: wrap; gap: 8px; }
.pagination a, .pagination span { padding: 8px 12px; border: 1px solid var(--line); text-decoration: none; }
.pagination .current { background: var(--ink); color: var(--paper); }

.site-footer { padding: 56px 0 28px; background: var(--ink); color: var(--paper); }
.footer-top {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 60px;
  padding-bottom: 48px;
  border-bottom: 1px solid rgba(255,255,255,0.2);
}
.footer-title { margin: 0; font-family: var(--serif); font-size: clamp(2.1rem, 4vw, 4rem); letter-spacing: -0.04em; }
.footer-note { max-width: 600px; color: rgba(255,255,255,0.68); }
.footer-navigation { align-self: end; }
.footer-navigation ul { justify-content: flex-end; }
.footer-navigation a { font-size: 0.78rem; text-decoration: none; }
.footer-bottom { display: flex; justify-content: space-between; gap: 20px; padding-top: 24px; color: rgba(255,255,255,0.6); font-size: 0.72rem; }

.not-found { padding: 120px 0; text-align: center; }
.not-found h1 { margin: 0; font-family: var(--serif); font-size: clamp(4rem, 12vw, 10rem); }

@media (max-width: 900px) {
  .header-inner { min-height: 82px; }
  .menu-toggle { display: block; }
  .main-navigation {
    display: none;
    grid-column: 1 / -1;
    padding-bottom: 22px;
  }
  .main-navigation.is-open { display: block; }
  .main-navigation ul { align-items: flex-start; flex-direction: column; gap: 14px; }
  .hero-grid, .manifesto-grid, .footer-top { grid-template-columns: 1fr; }
  .hero-copy { max-width: 580px; }
  .story-card, .story-card:first-child { grid-column: span 6; grid-row: auto; }
  .story-card:first-child { grid-column: 1 / -1; }
  .archive-grid { grid-template-columns: repeat(2, 1fr); }
  .footer-navigation ul { justify-content: flex-start; }
  .about-grid { grid-template-columns: 1fr; }
  .about-portrait { position: static; max-width: 560px; }
}

@media (max-width: 600px) {
  body { font-size: 16px; }
  .site-shell, .content-width, .entry-featured { width: min(calc(100% - 28px), var(--wide)); }
  .site-description { display: none; }
  .hero { padding-top: 66px; }
  .hero h1 { font-size: clamp(3rem, 18vw, 5rem); }
  .story-grid, .archive-grid { display: block; }
  .story-card { margin-bottom: 42px; }
  .section-heading { align-items: flex-start; flex-direction: column; }
  .entry-title { font-size: clamp(2.9rem, 15vw, 4.8rem); }
  .author-box { grid-template-columns: 76px 1fr; padding: 22px; }
  .footer-bottom { flex-direction: column; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}

/* Final MyLegge component layer. Kept after the common responsive foundation
   so the legal-tech identity wins the cascade at every viewport. */
.site-header { background: var(--ink); color: #fff; border-bottom: 0; }
.header-inner { min-height: 92px; }
.wordmark { gap: 0; font-family: var(--sans); font-size: clamp(1.65rem, 3vw, 2.35rem); font-weight: 850; letter-spacing: -0.06em; }
.wordmark span:first-child { color: #fff; }
.wordmark span:last-child { color: var(--accent); }
.site-description { color: rgba(255,255,255,0.6); }
.main-navigation a { color: #fff; }
.main-navigation a:hover { color: var(--accent); }
.menu-toggle { border-color: #fff; color: #fff; }

.hero {
  min-height: min(720px, 78vh);
  display: flex;
  align-items: center;
  background: var(--ink);
  color: #fff;
  border-bottom: 8px solid var(--accent);
}
.hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, rgba(25,167,184,0.1) 1px, transparent 1px), linear-gradient(rgba(25,167,184,0.1) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: linear-gradient(to left, #000, transparent 65%);
}
.hero::after { content: "§"; right: 4vw; bottom: -0.28em; color: rgba(25,167,184,0.16); font-family: var(--serif); font-size: clamp(270px, 36vw, 560px); }
.hero-grid { grid-template-columns: minmax(0, 1.25fr) minmax(260px, 0.75fr); }
.hero h1 { max-width: 860px; font-family: var(--sans); font-size: clamp(3.6rem, 8vw, 7.8rem); font-weight: 850; letter-spacing: -0.075em; line-height: 0.87; }
.hero .eyebrow { color: var(--accent); }
.hero-copy { border-left-color: var(--accent); font-family: var(--sans); font-size: 1.18rem; }
.hero .button-link { background: var(--accent); border-color: var(--accent); color: var(--ink); }
.hero .button-link:hover { background: #fff; border-color: #fff; color: var(--ink); }

.latest-section { background: #fff; }
.section-heading { border-bottom: 4px solid var(--ink); }
.section-heading h2, .archive-header h1 { font-family: var(--sans); font-weight: 820; letter-spacing: -0.055em; }
.story-title, .story-card:first-child .story-title { font-family: var(--serif); }
.story-image { background: var(--paper-deep); border-radius: 2px; }
.story-card:first-child .story-image { border-bottom: 6px solid var(--accent); }

.topics-section { padding: clamp(70px, 9vw, 120px) 0; background: var(--paper); }
.topic-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; background: var(--line); border: 1px solid var(--line); }
.topic-card { min-height: 220px; padding: 30px; background: var(--paper); text-decoration: none; }
.topic-card:hover { background: var(--ink); color: #fff; }
.topic-number { display: block; margin-bottom: 48px; color: var(--accent); font-size: 0.72rem; font-weight: 800; letter-spacing: 0.1em; }
.topic-title { margin: 0 0 10px; font-family: var(--sans); font-size: 1.35rem; font-weight: 800; letter-spacing: -0.035em; }
.topic-description { margin: 0; color: var(--muted); font-size: 0.82rem; line-height: 1.45; }
.topic-card:hover .topic-description { color: rgba(255,255,255,0.68); }

.manifesto { background: var(--accent); color: var(--ink); }
.manifesto h2 { font-family: var(--sans); font-weight: 850; }
.manifesto .section-kicker { color: var(--ink); }
.manifesto-copy { font-family: var(--serif); font-weight: 600; }
.entry-title { font-family: var(--sans); font-weight: 850; letter-spacing: -0.065em; }
.entry-featured img { border-bottom: 8px solid var(--accent); }
.entry-content blockquote { border-left-color: var(--accent); color: var(--ink); }
.site-footer { background: #06131b; }
.footer-title { font-family: var(--sans); font-weight: 850; }

@media (max-width: 900px) {
  .topic-grid { grid-template-columns: repeat(2, 1fr); }
  .hero-grid { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
  .topic-grid { grid-template-columns: 1fr; }
  .hero { min-height: auto; }
}
