/* ==========================================================================
   Ray Peat RU / EN — Flagship Monolithic Stylesheet (Clean Minimal Edition)
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Philosopher:ital,wght@0,400;0,700;1,400;1,700&display=swap');

:root {
  --font-family: 'Philosopher', 'Times New Roman', serif;
  --font-fallback: Verdana, Geneva, -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'Liberation Mono', Menlo, Consolas, monospace;

  /* Default Flagship Monolithic Obsidian Tokens */
  --bg-page: #131415;
  --bg-card: #131415;
  --bg-nav-bar: #32302f; /* Gruvbox Dark0 Soft distinct gray */
  --text-main: #f0f0ee;
  --text-muted: #b8b8b0;
  --text-dim: #7a7a72;
  
  --accent-title: #f2594b; /* Coral Vermilion */
  --accent-subhead: #ffffff;
  --accent-link: #ffffff;
  --accent-link-hover: #f2594b;
  
  --link-border: rgba(255, 255, 255, 0.35);
  --link-border-hover: #f2594b;
  
  --border-frame: #353535;
  --border-light: #242629;
  --border-accent: #2c2d30;
  --quote-bg: #18191b;
}

/* Base Page */
html {
  background-color: var(--bg-page);
  color: var(--text-main);
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  box-sizing: border-box;
  transition: background-color 0.12s ease, color 0.12s ease;
}

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

body {
  margin: 0;
  padding: 0;
  background-color: var(--bg-page);
  color: var(--text-main);
  font-family: var(--font-family);
  font-size: 1rem;
  line-height: 1.5;
  min-height: 100vh;
}

/* Top Site Header */
.rp-site-header {
  width: 100%;
  margin-top: 2.2rem;
  margin-bottom: 1.5rem;
  font-family: var(--font-fallback);
  text-align: left;
}

.rp-header-content {
  max-width: calc(70ch + 4.8rem);
  margin: 0 auto 1.1rem auto;
  padding: 0 1rem;
}

.rp-site-title {
  font-family: Verdana, Geneva, -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 1.9rem;
  font-weight: 400;
  color: #f0f0ee;
  margin: 0 0 0.35rem 0;
  line-height: 1.15;
  letter-spacing: -0.02em;
}

.rp-site-title a {
  color: #f0f0ee;
  text-decoration: none;
  border-bottom: none;
}

.rp-site-title a:hover {
  color: var(--accent-title);
}

.rp-site-desc {
  font-family: var(--font-fallback);
  font-size: 0.85rem;
  color: var(--text-muted);
  margin: 0;
  line-height: 1.4;
  font-weight: 400;
}

/* Full-Width Gray Ribbon */
.rp-fullwidth-tabs-bar {
  width: 100%;
  background: var(--bg-nav-bar);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  border-bottom: 1px solid rgba(0, 0, 0, 0.4);
  display: block;
  transition: background-color 0.12s ease;
}

.rp-tabs-container {
  max-width: 48rem;
  margin: 0 auto;
  padding: 0 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
}

.rp-tabs-list {
  display: flex;
  list-style: none;
  margin: 0;
  padding: 0;
  flex-wrap: wrap;
}

.rp-tab-item {
  margin: 0;
  padding: 0;
  border: none;
}

.rp-tab-item a {
  display: block;
  padding: 0.38rem 1.4rem 0.38rem 0;
  margin-right: 0.8rem;
  font-family: Verdana, Geneva, sans-serif;
  font-size: 0.92rem;
  line-height: 1.35;
  font-weight: 400;
  color: #ffffff;
  text-decoration: none;
  border: none;
  background: transparent;
  transition: color 0.12s ease, opacity 0.12s ease;
}

.rp-tab-item a:hover {
  color: var(--accent-title);
  opacity: 0.9;
}

.rp-tab-item.active a {
  color: #ffffff;
  font-weight: 700;
}

/* Global Language Switcher */
.rp-lang-switcher {
  font-family: Verdana, Geneva, sans-serif;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-left: auto;
  flex-shrink: 0;
  white-space: nowrap;
  user-select: none;
}

.rp-lang-switcher .lang-cur {
  color: #ffffff;
  font-weight: 700;
}

.rp-lang-switcher .lang-sep {
  color: rgba(255, 255, 255, 0.3);
  margin: 0 0.35rem;
}

.rp-lang-switcher a.lang-link {
  color: var(--text-muted);
  text-decoration: none;
  border-bottom: none;
  font-weight: 500;
  transition: color 0.12s ease;
}

.rp-lang-switcher a.lang-link:hover {
  color: var(--accent-title);
  text-decoration: none;
}

/* Date Tab Badge */
.date-tab-wrapper {
  max-width: 48rem;
  margin: 0 auto;
  text-align: left;
  position: relative;
  top: 1px;
  z-index: 2;
  padding: 0 1rem;
}

.date-tab-badge {
  display: inline-block;
  background: #1e2022;
  color: var(--text-muted);
  border: 1px solid var(--border-frame);
  border-bottom: 1px solid var(--bg-card);
  border-top-left-radius: 6px;
  border-top-right-radius: 6px;
  padding: 0.22rem 0.75rem;
  font-family: Verdana, Geneva, sans-serif;
  font-size: 0.74rem;
  font-weight: 500;
}

/* Reading Card */
.reading-card {
  font-family: var(--font-family);
  font-size: 1rem;
  line-height: 1.5;
  color: var(--text-main);
  background-color: var(--bg-card);
  max-width: calc(70ch + 4.8rem);
  margin: 0 auto 3.5rem auto;
  padding: 1.8rem 2.4rem;
  border: 1px solid var(--border-frame);
  border-radius: 8px;
  box-sizing: border-box;
  transition: background-color 0.12s ease, border-color 0.12s ease, color 0.12s ease;
  position: relative;
}

/* Minimalist Monograph Title / Dateline */
.newsletter-masthead {
  border-bottom: 1px solid var(--border-frame);
  padding-bottom: 0.45rem;
  margin-bottom: 1.25rem;
}

.newsletter-masthead h1.brand,
.newsletter-masthead .brand {
  font-family: var(--font-fallback);
  font-size: 0.88rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--accent-title);
  margin: 0;
  line-height: 1.35;
  text-align: left;
}

.newsletter-masthead h1.brand .subtitle,
.newsletter-masthead .brand .subtitle {
  display: inline;
  font-family: var(--font-fallback);
  font-size: 1em;
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin-left: 0.25em;
}

/* Headings */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-family);
  line-height: 1.25;
  text-wrap: pretty;
  text-align: left;
}

h1 {
  font-family: var(--font-fallback);
  color: var(--accent-title);
  font-size: 1.65rem;
  font-weight: 700;
  letter-spacing: -0.015em;
  margin-top: 0.4em;
  margin-bottom: 0.7em;
  line-height: 1.25;
}

h1 .subtitle {
  display: block;
  font-size: 0.88em;
  font-weight: 400;
  color: var(--text-muted);
  margin-top: 0.35em;
  line-height: 1.35;
  letter-spacing: -0.01em;
}

/* Tight headline lockup: element immediately following h1 collapses top margin */
h1 + h2,
h1 + h3,
h1 + h4,
h1 + h5,
h1 + h6,
h1 + p {
  margin-top: 0.25em;
}

h2, h3, h4, h5, h6 {
  color: var(--accent-subhead);
  font-weight: 700;
  clear: both;
}

h2 {
  font-size: 1.45rem;
  margin-top: 1.8em;
  margin-bottom: 0.5em;
  border-bottom: 1px solid var(--border-light);
  padding-bottom: 0.25em;
}

h3 {
  font-size: 1.25rem;
  margin-top: 1.6rem;
  margin-bottom: 0.2rem;
}

h3 + p,
h3 + ul,
h3 + ol,
h3 + figure,
h3 + blockquote {
  margin-top: 0.35rem;
}

h4 {
  font-size: 1.15rem;
  margin-top: 1.2em;
  margin-bottom: 0.3em;
}

h5, h6 {
  font-size: 1.05rem;
  margin-top: 1em;
  margin-bottom: 0.25em;
}

p {
  font-size: 1.22rem;
  margin: 1.15em 0;
  text-align: left;
  line-height: 1.5;
  font-weight: 450;
}

strong, b {
  font-weight: 700;
  color: #ffffff;
}

/* Links */
a {
  color: var(--accent-link);
  font-weight: 450;
  text-decoration: none;
  border-bottom: 1px solid var(--link-border);
  padding-bottom: 1px;
  transition: color 0.12s ease, border-bottom-color 0.12s ease;
}

@media (hover: hover) and (pointer: fine) {
  a:hover {
    color: var(--accent-link-hover);
    border-bottom-color: var(--link-border-hover);
    cursor: pointer;
  }
}

/* Lists */
ul {
  list-style-type: square;
}

ul, ol {
  padding-left: 1.5em;
  margin: 1.15em 0;
  text-align: left;
}

li {
  font-size: 1.22rem;
  line-height: 1.5;
  margin: 0.45em 0;
  font-weight: 450;
}

li::marker {
  color: var(--accent-title);
}

/* Blockquotes */
blockquote {
  margin: 1.4em 0;
  padding: 0.6em 1.2em;
  background-color: var(--quote-bg);
  border-left: 3px solid var(--accent-title);
}

blockquote p {
  margin: 0.3em 0;
  font-style: italic;
  color: var(--text-muted);
}

/* Figures & Media */
figure {
  margin: 1.2em auto;
  display: block;
}

figure.portrait {
  max-width: 14em;
}

figure.portrait.right {
  float: right;
  margin: 0.3em 0 1em 1.5em;
  text-align: center;
}

figure.portrait.left {
  float: left;
  margin: 0.3em 1.5em 1em 0;
  text-align: center;
}

figure.diagram.center {
  display: block;
  margin: 1.8em auto;
  text-align: center;
  max-width: 100%;
}

figure img {
  max-width: 100%;
  height: auto;
  display: inline-block;
  vertical-align: middle;
}

figcaption {
  font-family: var(--font-family);
  font-size: 0.85rem;
  color: var(--text-muted);
  text-align: center;
  margin-top: 0.55em;
  line-height: 1.35;
}

.clearfix::after {
  content: "";
  display: table;
  clear: both;
}

/* Code */
code, pre {
  font-family: var(--font-mono);
  font-size: 0.88em;
}

pre {
  background-color: var(--quote-bg);
  border: 1px solid var(--border-light);
  padding: 0.8em 1em;
  overflow-x: auto;
}

hr {
  border: 0;
  height: 1px;
  background-color: var(--border-light);
  margin: 2em 0;
}

/* Card-Scoped Feature Classes (Tuner Controls) */
body.feat-dropcap .reading-card .content > p:first-of-type::first-letter,
body.feat-dropcap .reading-card > p:first-of-type::first-letter {
  font-family: var(--font-family);
  float: left;
  font-size: 3.3rem;
  line-height: 0.82;
  padding-top: 4px;
  padding-right: 10px;
  padding-bottom: 2px;
  color: var(--accent-title);
  font-weight: 700;
}

body.feat-borderless .reading-card {
  border: none !important;
  border-radius: 0 !important;
  padding-top: 1.5rem;
}

body.feat-justify .reading-card p {
  text-align: justify;
  text-justify: inter-word;
  hyphens: auto;
}

body.feat-compact-refs .reading-card ul:last-of-type,
body.feat-compact-refs .reading-card ol:last-of-type {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.4;
}

body.feat-bold-links .reading-card a {
  font-weight: 700;
}

/* Footer */
.rp-site-footer {
  max-width: 48rem;
  margin: 2rem auto 4rem auto;
  padding: 1.5rem 1rem;
  text-align: center;
  font-family: var(--font-fallback);
  font-size: 0.78rem;
  color: var(--text-dim);
  border-top: 1px solid var(--border-light);
}

@media (max-width: 768px) {
  .rp-header-content, .rp-tabs-container, .date-tab-wrapper {
    padding: 0 1rem;
  }
  
  .rp-tab-item a {
    padding: 0.35rem 0.8rem 0.35rem 0;
    font-size: 0.85rem;
  }

  .reading-card {
    margin: 0 0.5rem 3rem 0.5rem;
    padding: 1.5rem 1.2rem;
  }
  
  h1 {
    font-size: 1.5rem;
  }

  figure.portrait.right,
  figure.portrait.left {
    float: none;
    margin: 1.4em auto;
    max-width: 85%;
  }
}
