/* ==========================================================================
   KOUHLANI LAW FIRM — Theme
   Institutional navy-and-white system in the manner of cravath.com.
   Brand navy sampled from Cravath's own theme-color token: #002554
   ========================================================================== */

/* --- 1. Tokens ----------------------------------------------------------- */

:root {
  --navy:        #002554;
  --navy-deep:   #001B3D;
  --white:       #FFFFFF;
  --paper:       #F4F6F9;
  --rule:        #C8D2DF;
  --rule-dark:   rgba(255, 255, 255, 0.22);
  --ink:         #0E1F33;
  --ink-muted:   #56687F;
  --white-muted: rgba(255, 255, 255, 0.72);

  --font-display: "Newsreader", "Times New Roman", Times, serif;
  --font-text:    "Archivo", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;

  --size-hero:  clamp(2.5rem, 6vw, 5rem);
  --size-h2:    clamp(1.9rem, 3.4vw, 2.9rem);
  --size-h3:    clamp(1.3rem, 2vw, 1.65rem);
  --size-lead:  clamp(1.05rem, 1.5vw, 1.3rem);
  --size-body:  1rem;
  --size-small: 0.82rem;
  --size-micro: 0.7rem;

  --gutter:    clamp(1.5rem, 5vw, 5rem);
  --section-y: clamp(4.5rem, 9vw, 8.5rem);
  --measure:   68ch;

  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
}

/* --- 2. Reset ------------------------------------------------------------ */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--white);
  color: var(--ink);
  font-family: var(--font-text);
  font-size: var(--size-body);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; display: block; }

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 400;
  line-height: 1.12;
  letter-spacing: -0.015em;
  margin: 0;
  text-wrap: balance;
}

p { margin: 0 0 1.15em; max-width: var(--measure); }
p:last-child { margin-bottom: 0; }
a { color: inherit; }

:focus-visible { outline: 2px solid currentColor; outline-offset: 3px; }

.skip {
  position: absolute; left: -9999px; top: 0; z-index: 100;
  background: var(--navy); color: var(--white);
  padding: 0.9rem 1.5rem; font-size: var(--size-small); text-decoration: none;
}
.skip:focus { left: 0; }

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

/* --- 3. Layout ----------------------------------------------------------- */

.shell { width: 100%; max-width: 1320px; margin-inline: auto; padding-inline: var(--gutter); }

.section { padding-block: var(--section-y); }
.section--paper { background: var(--paper); }
.section--navy  { background: var(--navy); color: var(--white); }
.section--navy p { color: var(--white-muted); }
.section--tight { padding-block: clamp(3rem, 6vw, 5rem); }

.section__head {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1.25rem;
  padding-bottom: 2.75rem;
  margin-bottom: 3.25rem;
  border-bottom: 1px solid var(--rule);
}
.section--navy .section__head { border-bottom-color: var(--rule-dark); }

@media (min-width: 900px) {
  .section__head {
    grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
    align-items: end;
    gap: 3rem;
  }
}

.section__title { font-size: var(--size-h2); }
.section__note { font-size: var(--size-lead); color: var(--ink-muted); line-height: 1.5; }
.section--navy .section__note { color: var(--white-muted); }

.grid { display: grid; gap: 2.5rem 3rem; }
@media (min-width: 760px)  { .grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 1000px) { .grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 760px)  { .grid--split { grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: 3.5rem; } }

/* --- 4. Typographic utilities -------------------------------------------- */

.index {
  font-family: var(--font-text);
  font-size: var(--size-small);
  font-variant-numeric: tabular-nums;
  color: var(--ink-muted);
}
.section--navy .index { color: var(--white-muted); }

.lead  { font-size: var(--size-lead); line-height: 1.55; }
.small { font-size: var(--size-small); }
.muted { color: var(--ink-muted); }
.section--navy .muted { color: var(--white-muted); }

/* --- 5. Links and actions ------------------------------------------------ */

.link {
  font-family: var(--font-text);
  font-size: var(--size-small);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-decoration: none;
  padding-bottom: 0.35rem;
  border-bottom: 1px solid currentColor;
  display: inline-block;
  transition: opacity 0.25s var(--ease);
}
.link:hover { opacity: 0.6; }

.btn {
  display: inline-block;
  font-family: var(--font-text);
  font-size: var(--size-small);
  letter-spacing: 0.09em;
  text-transform: uppercase;
  text-decoration: none;
  padding: 1rem 2.25rem;
  border: 1px solid var(--navy);
  background: var(--navy);
  color: var(--white);
  cursor: pointer;
  transition: background 0.25s var(--ease), color 0.25s var(--ease);
}
.btn:hover { background: transparent; color: var(--navy); }

.btn--ghost { background: transparent; color: var(--white); border-color: var(--rule-dark); }
.btn--ghost:hover { background: var(--white); color: var(--navy); border-color: var(--white); }

/* --- 6. Masthead --------------------------------------------------------- */

.masthead {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--navy);
  border-bottom: 1px solid var(--rule-dark);
}

.masthead__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2rem;
  min-height: 84px;
}

/* The supplied logo is navy on transparent; invert it to white for navy fields. */
.logo { display: block; line-height: 0; }
.logo img { height: 32px; width: auto; filter: brightness(0) invert(1); }

.nav { display: none; gap: 2rem; align-items: center; }
@media (min-width: 1040px) { .nav { display: flex; } }

.nav a {
  color: var(--white);
  text-decoration: none;
  font-size: var(--size-small);
  letter-spacing: 0.04em;
  padding-block: 0.4rem;
  border-bottom: 1px solid transparent;
  transition: border-color 0.25s var(--ease);
}
.nav a:hover { border-bottom-color: var(--white); }
.nav a[aria-current="page"] { border-bottom-color: var(--white); }

.masthead__end { display: flex; align-items: center; gap: 1.5rem; }

.lang { display: flex; gap: 0.5rem; align-items: center; font-size: var(--size-micro); letter-spacing: 0.14em; }
.lang a {
  padding: 0.3rem 0.1rem;
  color: var(--white-muted);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: color 0.2s var(--ease);
}
.lang a:hover { color: var(--white); }
.lang a[aria-current="true"] { color: var(--white); border-bottom-color: var(--white); }

.burger {
  display: inline-flex; flex-direction: column; justify-content: center; gap: 5px;
  width: 34px; height: 34px; background: none; border: 0; cursor: pointer; padding: 0;
}
@media (min-width: 1040px) { .burger { display: none; } }
.burger span { display: block; height: 1px; width: 100%; background: var(--white); }

.drawer { display: none; border-top: 1px solid var(--rule-dark); background: var(--navy); }
.drawer[data-open="true"] { display: block; }
@media (min-width: 1040px) { .drawer { display: none !important; } }
.drawer nav { display: grid; padding-block: 1rem 2rem; }
.drawer a {
  color: var(--white);
  text-decoration: none;
  font-family: var(--font-display);
  font-size: 1.35rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--rule-dark);
}

/* --- 7. Hero ------------------------------------------------------------- */

.hero {
  background: var(--navy);
  color: var(--white);
  padding-block: clamp(4.5rem, 11vw, 9.5rem) clamp(3.5rem, 7vw, 6rem);
}
.hero--page { padding-block: clamp(3.5rem, 8vw, 6.5rem) clamp(3rem, 6vw, 5rem); }

.hero__title { font-size: var(--size-hero); letter-spacing: -0.025em; max-width: 17ch; }
.hero--page .hero__title { max-width: 20ch; }

.hero__rule { width: 88px; height: 1px; background: var(--rule-dark); margin: 2.5rem 0; border: 0; }

.hero__lead { font-size: var(--size-lead); color: var(--white-muted); max-width: 56ch; line-height: 1.55; }

.hero__meta {
  display: flex; flex-wrap: wrap; gap: 2.5rem;
  margin-top: 3.5rem; padding-top: 2rem; border-top: 1px solid var(--rule-dark);
}
.hero__meta div { min-width: 150px; }
.hero__meta dt {
  font-size: var(--size-micro); letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--white-muted); margin-bottom: 0.5rem;
}
.hero__meta dd { margin: 0; font-family: var(--font-display); font-size: 1.2rem; }

/* --- 8. Editorial entries ------------------------------------------------ */

.entry { border-top: 1px solid var(--rule); padding-top: 1.5rem; }
.section--navy .entry { border-top-color: var(--rule-dark); }

.entry__index { display: block; margin-bottom: 1.75rem; }
.entry__title { font-size: var(--size-h3); margin-bottom: 0.85rem; }
.entry__body  { color: var(--ink-muted); }
.section--navy .entry__body { color: var(--white-muted); }

.entry__list { margin: 1rem 0 0; padding: 0; list-style: none; }
.entry__list li {
  font-size: var(--size-small); color: var(--ink-muted);
  padding: 0.55rem 0; border-bottom: 1px solid var(--rule);
}
.section--navy .entry__list li { color: var(--white-muted); border-bottom-color: var(--rule-dark); }
.entry__list li:last-child { border-bottom: 0; }
.entry__list--framed { border-top: 1px solid var(--rule); }

/* --- 9. Credentials ------------------------------------------------------ */

.creds { margin: 0; padding: 0; list-style: none; }
.creds li { padding: 0.95rem 0; border-bottom: 1px solid var(--rule); display: grid; gap: 0.15rem; }
.creds li:first-child { border-top: 1px solid var(--rule); }
.creds b { font-weight: 500; }
.creds span { font-size: var(--size-small); color: var(--ink-muted); }

/* --- 10. Insights index -------------------------------------------------- */

.post {
  display: block; text-decoration: none;
  border-top: 1px solid var(--rule); padding-top: 1.5rem;
  transition: opacity 0.25s var(--ease);
}
.post:hover { opacity: 0.62; }
.post__meta {
  display: flex; justify-content: space-between; gap: 1rem;
  font-size: var(--size-micro); letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--ink-muted); margin-bottom: 1.75rem;
}
.post__title { font-size: var(--size-h3); margin-bottom: 0.75rem; }
.post__excerpt { font-size: var(--size-small); color: var(--ink-muted); }
.post__thumb { margin-bottom: 1.5rem; aspect-ratio: 16 / 10; overflow: hidden; background: var(--paper); }
.post__thumb img { width: 100%; height: 100%; object-fit: cover; }

.post--row {
  display: grid; gap: 1.5rem 3rem; padding-block: 2.25rem 2.5rem;
  border-top: 1px solid var(--rule); padding-top: 2.25rem;
}
@media (min-width: 860px) { .post--row { grid-template-columns: minmax(0, 3fr) minmax(0, 8fr); align-items: start; } }
.post--row .post__meta { display: grid; gap: 0.5rem; justify-content: start; margin-bottom: 0; }

/* --- 11. Article --------------------------------------------------------- */

.article { padding-block: clamp(3rem, 7vw, 5.5rem) var(--section-y); }
.article__wrap { max-width: 720px; margin-inline: auto; }

.article__meta {
  display: flex; flex-wrap: wrap; gap: 1.5rem;
  font-size: var(--size-micro); letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--ink-muted); margin-bottom: 1.75rem;
}
.article__title { font-size: clamp(2rem, 4vw, 3.1rem); margin-bottom: 1.5rem; }
.article__standfirst {
  font-size: var(--size-lead); color: var(--ink-muted); line-height: 1.55;
  padding-bottom: 2.5rem; border-bottom: 1px solid var(--rule); margin-bottom: 3rem;
}

/* Styles applied to the raw HTML dropped into content/blog/ */
.article__body { font-size: 1.06rem; line-height: 1.75; }
.article__body > * { max-width: 100%; }
.article__body h2 { font-size: clamp(1.5rem, 2.6vw, 2rem); margin: 3rem 0 1rem; }
.article__body h3 { font-size: var(--size-h3); margin: 2.25rem 0 0.75rem; }
.article__body p  { margin: 0 0 1.4em; max-width: none; }
.article__body ul, .article__body ol { margin: 0 0 1.4em; padding-left: 1.25rem; }
.article__body li { margin-bottom: 0.5rem; }
.article__body a { color: var(--navy); text-decoration: none; border-bottom: 1px solid var(--rule); }
.article__body a:hover { border-bottom-color: var(--navy); }
.article__body blockquote {
  margin: 2.5rem 0; padding-left: 1.75rem;
  border-left: 1px solid var(--navy);
  font-family: var(--font-display); font-size: 1.35rem; line-height: 1.4;
}
.article__body blockquote p { margin: 0; }
.article__body figure { margin: 2.75rem 0; }
.article__body figcaption {
  font-size: var(--size-small); color: var(--ink-muted);
  padding-top: 0.75rem; border-top: 1px solid var(--rule); margin-top: 0.75rem;
}
.article__body img { width: 100%; height: auto; }
.article__body hr { border: 0; border-top: 1px solid var(--rule); margin: 3rem 0; }
.article__body table { width: 100%; border-collapse: collapse; margin: 2rem 0; font-size: var(--size-small); }
.article__body th, .article__body td { text-align: left; padding: 0.75rem 1rem 0.75rem 0; border-bottom: 1px solid var(--rule); }
.article__body th { font-weight: 500; }

/* YouTube embeds: wrap an iframe in <div class="embed"> or drop the iframe in bare */
.article__body .embed, .article__body iframe {
  position: relative; width: 100%; aspect-ratio: 16 / 9; margin: 2.75rem 0; border: 0;
}
.article__body .embed iframe {
  position: absolute; inset: 0; width: 100%; height: 100%; margin: 0;
}

.article__foot {
  margin-top: 4rem; padding-top: 2rem; border-top: 1px solid var(--rule);
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 1.5rem;
}

/* --- 12. Forms ----------------------------------------------------------- */

.field { display: grid; gap: 0.5rem; margin-bottom: 1.5rem; }
.field label {
  font-size: var(--size-micro); letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--white-muted);
}
.field input, .field textarea, .field select {
  font: inherit; font-size: var(--size-body);
  color: var(--white); background: transparent;
  border: 0; border-bottom: 1px solid var(--rule-dark);
  padding: 0.65rem 0; border-radius: 0;
  transition: border-color 0.25s var(--ease);
}
.field input:focus, .field textarea:focus, .field select:focus {
  outline: none; border-bottom-color: var(--white);
}
.field textarea { resize: vertical; min-height: 96px; }
.field select option { color: var(--ink); }
.field--hp { position: absolute; left: -9999px; }

.notice {
  padding: 1.25rem 1.5rem; margin-bottom: 2.5rem;
  border: 1px solid var(--rule-dark); font-size: var(--size-small);
}
.notice--ok { border-color: var(--white); }
.notice p { color: var(--white) !important; }

.contact__block { margin-bottom: 2.25rem; }
.contact__block dt {
  font-size: var(--size-micro); letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--white-muted); margin-bottom: 0.5rem;
}
.contact__block dd { margin: 0; font-size: 1.05rem; }
.contact__block a { text-decoration: none; border-bottom: 1px solid var(--rule-dark); }

/* --- 13. Footer ---------------------------------------------------------- */

.footer {
  background: var(--navy-deep); color: var(--white-muted);
  padding-block: 3.5rem 2.5rem; font-size: var(--size-small);
}
.footer__top {
  display: grid; gap: 2.5rem;
  padding-bottom: 2.5rem; border-bottom: 1px solid var(--rule-dark);
}
@media (min-width: 860px) { .footer__top { grid-template-columns: minmax(0, 4fr) minmax(0, 8fr); } }

.footer__logo img { height: 30px; width: auto; filter: brightness(0) invert(1); opacity: 0.92; }

.footer__cols { display: grid; gap: 2rem; }
@media (min-width: 560px) { .footer__cols { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.footer__cols h4 {
  font-family: var(--font-text); font-size: var(--size-micro);
  letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--white-muted); margin-bottom: 1rem; font-weight: 400;
}
.footer__cols ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.6rem; }
.footer__cols a { color: var(--white); text-decoration: none; opacity: 0.82; }
.footer__cols a:hover { opacity: 1; }

.footer__base {
  padding-top: 2rem;
  font-size: var(--size-micro);
  letter-spacing: 0.06em;
}

/* --- 14. Portrait -------------------------------------------------------- */

/* Square source image (/static/profile-picture.png). Cropped to a portrait
   ratio on the profile page; kept square in the homepage summary. */
.portrait { margin: 0; }
.portrait img {
  width: 100%; height: auto; display: block;
  background: var(--paper);
}
.portrait--tall img { aspect-ratio: 4 / 5; object-fit: cover; object-position: center 22%; }
.portrait--square img { aspect-ratio: 1 / 1; object-fit: cover; }
.portrait figcaption {
  margin-top: 1rem; padding-top: 0.85rem; border-top: 1px solid var(--rule);
  font-size: var(--size-small); color: var(--ink-muted);
}
.section--navy .portrait figcaption { border-top-color: var(--rule-dark); color: var(--white-muted); }

@media (min-width: 760px) {
  .grid--portrait { grid-template-columns: minmax(0, 4fr) minmax(0, 8fr); gap: 3.5rem; align-items: start; }
}

/* --- 15. Section subheads ------------------------------------------------ */

.subhead {
  font-size: var(--size-h3);
  margin: 3.5rem 0 1.5rem;
}
.subhead:first-child { margin-top: 0; }

/* --- 16. Arabic and right-to-left ---------------------------------------- */

/* Newsreader and Archivo have no Arabic coverage, so the Arabic locale swaps
   in Noto. Loaded conditionally in base.html. */
[lang="ar"] {
  --font-display: "Noto Kufi Arabic", "Noto Naskh Arabic", serif;
  --font-text: "Noto Naskh Arabic", "Segoe UI", sans-serif;
  --measure: 64ch;
}

[lang="ar"] h1, [lang="ar"] h2, [lang="ar"] h3, [lang="ar"] h4 {
  letter-spacing: 0;          /* negative tracking damages Arabic joins */
  line-height: 1.35;
}
[lang="ar"] body { line-height: 1.9; }

/* Latin-derived micro-labels keep their tracking; Arabic must not have any. */
[dir="rtl"] .kicker,
[dir="rtl"] .link,
[dir="rtl"] .btn,
[dir="rtl"] .hero__meta dt,
[dir="rtl"] .contact__block dt,
[dir="rtl"] .field label,
[dir="rtl"] .post__meta,
[dir="rtl"] .article__meta,
[dir="rtl"] .footer__cols h4,
[dir="rtl"] .footer__base,
[dir="rtl"] .lang {
  letter-spacing: 0;
  text-transform: none;
}

/* Rules and indents that were physically left/right become logical. */
[dir="rtl"] .article__body blockquote {
  border-left: 0;
  border-right: 1px solid var(--navy);
  padding-left: 0;
  padding-right: 1.75rem;
}
[dir="rtl"] .article__body ul,
[dir="rtl"] .article__body ol { padding-left: 0; padding-right: 1.25rem; }
[dir="rtl"] .article__body th,
[dir="rtl"] .article__body td { text-align: right; padding: 0.75rem 0 0.75rem 1rem; }
[dir="rtl"] .skip { left: auto; right: -9999px; }
[dir="rtl"] .skip:focus { right: 0; }

/* Phone numbers, email addresses and the wordmark stay left-to-right. */
[dir="rtl"] [dir="ltr"] { direction: ltr; text-align: right; unicode-bidi: isolate; }

/* --- 17. Honorific ------------------------------------------------------- */

/* French abbreviates Maître as Mᵉ, with a raised e. Browsers shrink <sup> and
   lift it too far for display type, so it is set explicitly. */
sup {
  font-size: 0.58em;
  line-height: 0;
  vertical-align: 0.42em;
  margin-inline-end: 0.04em;
}
