/* ==========================================================================
   Juan Ramon Hernandez

   Structure from Apple and Tesla — centered composition, oversized type,
   generous vertical space, pill buttons, no visible chrome.
   Palette from Etsy — warm cream ground, warm charcoal ink, rust accent.

   The combination is deliberate: cold monochrome minimalism is the default
   for technology profiles, and looking like everyone else is the one thing
   an authority site cannot afford. Warmth is the differentiator; the
   restraint keeps it senior.
   ========================================================================== */

:root {
  /* Sampled from etsy.com */
  --paper: #faf8f5;
  --paper-alt: #ffffff;
  --paper-sunk: #efecea;
  --ink: #312b36;
  --ink-soft: #665e5c;
  --ink-muted: #928681;
  --rule: #e0dad6;
  --accent: #cf4018;
  --accent-deep: #a3300f;
  --accent-soft: #fbece5;

  --sans: ui-sans-serif, -apple-system, BlinkMacSystemFont, "SF Pro Text",
    "Segoe UI", Inter, Roboto, Helvetica, Arial, sans-serif;
  --serif: ui-serif, Georgia, Cambria, "Times New Roman", Times, serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
    "Liberation Mono", monospace;

  --gutter: clamp(1.25rem, 5vw, 4rem);
  --measure: 38rem;
  --rhythm: clamp(4.5rem, 10vw, 9rem);
  --radius: 20px;
  --pill: 999px;
  --shadow: 0 1px 2px rgba(49, 43, 54, 0.04),
    0 8px 24px rgba(49, 43, 54, 0.06);
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #17151a;
    --paper-alt: #1f1c23;
    --paper-sunk: #100e13;
    --ink: #f4f1ed;
    --ink-soft: #c3bcbb;
    --ink-muted: #8f8785;
    --rule: #332e38;
    --accent: #ff7a4d;
    --accent-deep: #ff9670;
    --accent-soft: #2a1d19;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.35);
  }
}

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: clamp(1rem, 0.95rem + 0.25vw, 1.125rem);
  line-height: 1.62;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

::selection {
  background: var(--accent);
  color: #fff;
}

a {
  color: inherit;
}

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

.skip {
  position: absolute;
  left: -9999px;
  background: var(--ink);
  color: var(--paper);
  padding: 0.75rem 1.25rem;
  z-index: 200;
}
.skip:focus {
  left: 0;
  top: 0;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

/* ------------------------------------------------- masthead (Apple-style) */

.masthead {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  flex-wrap: wrap;
  padding: 0.9rem var(--gutter);
  background: color-mix(in srgb, var(--paper) 82%, transparent);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--rule);
}

.masthead__name {
  font-weight: 640;
  letter-spacing: -0.02em;
  text-decoration: none;
  font-size: 1rem;
}

.masthead__nav {
  display: flex;
  gap: clamp(0.9rem, 2.2vw, 2rem);
  align-items: center;
  font-size: 0.875rem;
}

.masthead__nav a {
  text-decoration: none;
  color: var(--ink-soft);
  transition: color 0.18s ease;
}

.masthead__nav a:hover,
.masthead__nav a[aria-current="page"] {
  color: var(--ink);
}

.masthead__cta {
  color: #fff !important;
  background: var(--ink);
  border-radius: var(--pill);
  padding: 0.4rem 0.95rem;
  font-weight: 560;
  transition: background 0.18s ease, transform 0.18s ease;
}

.masthead__cta:hover {
  background: var(--accent);
  transform: translateY(-1px);
}

/* ------------------------------------------------------------------ layout */

.wrap {
  padding-inline: var(--gutter);
  max-width: 76rem;
  margin-inline: auto;
}

.section {
  padding-block: var(--rhythm);
}

/* Alternating surfaces instead of hairline dividers — the Apple pattern.
   Rules chop a page into rows; surfaces let sections breathe as slabs. */
.section--alt {
  background: var(--paper-alt);
}

.section--sunk {
  background: var(--paper-sunk);
}

.label {
  font-family: var(--mono);
  font-size: 0.6875rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 0.9rem;
  font-weight: 600;
}

/* Section intro centers above its content — Tesla/Apple, not editorial rail. */
.split {
  display: block;
}

.split__rail {
  text-align: center;
  max-width: 44rem;
  margin: 0 auto clamp(2.25rem, 5vw, 3.5rem);
}

.split__rail h2,
.split__rail p {
  margin-inline: auto;
}

/* --------------------------------------------------------------------- hero */

.hero {
  text-align: center;
  padding-block: clamp(4.5rem, 13vw, 10rem) clamp(3.5rem, 9vw, 7rem);
  max-width: 60rem;
  margin-inline: auto;
}

.hero h1 {
  font-size: clamp(2.75rem, 8vw, 6.25rem);
  line-height: 1.02;
  letter-spacing: -0.045em;
  font-weight: 660;
  margin: 0 auto clamp(1.5rem, 3.5vw, 2.25rem);
  max-width: 15ch;
  text-wrap: balance;
}

.hero h1 em {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 400;
  letter-spacing: -0.02em;
  color: var(--accent);
}

.hero__lede {
  font-size: clamp(1.125rem, 2vw, 1.5rem);
  line-height: 1.5;
  color: var(--ink-soft);
  max-width: 34rem;
  margin: 0 auto clamp(2rem, 4vw, 2.75rem);
  text-wrap: pretty;
}

.hero__meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem 1.25rem;
  font-family: var(--mono);
  font-size: 0.6875rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-muted);
  margin-top: clamp(2rem, 4vw, 3rem);
}

/* ------------------------------------------------ buttons (Tesla/Apple pill) */

.actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.75rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-width: 12rem;
  padding: 0.8rem 1.75rem;
  border-radius: var(--pill);
  font: inherit;
  font-size: 0.9375rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 0.18s ease, color 0.18s ease, transform 0.18s ease,
    border-color 0.18s ease;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn--primary {
  background: var(--ink);
  color: var(--paper);
}

.btn--primary:hover {
  background: var(--accent);
}

.btn--ghost {
  background: transparent;
  color: var(--ink);
  border-color: var(--ink);
}

.btn--ghost:hover {
  background: var(--ink);
  color: var(--paper);
}

/* --------------------------------------------------------------- typography */

h2 {
  font-size: clamp(1.875rem, 4vw, 3rem);
  line-height: 1.08;
  letter-spacing: -0.035em;
  font-weight: 640;
  margin: 0 0 1rem;
  text-wrap: balance;
}

h3 {
  font-size: clamp(1.0625rem, 1.6vw, 1.25rem);
  line-height: 1.32;
  letter-spacing: -0.015em;
  font-weight: 620;
  margin: 0 0 0.5rem;
}

p {
  margin: 0 0 1.15rem;
  text-wrap: pretty;
}

/* Centered blocks with left-aligned text. Centering the block keeps the
   Apple/Tesla composition; leaving the text ragged-right keeps it readable. */
.prose {
  max-width: var(--measure);
  margin-inline: auto;
  color: var(--ink-soft);
}

.prose--wide {
  max-width: 46rem;
}

.lead {
  font-size: clamp(1.125rem, 1.9vw, 1.4375rem);
  line-height: 1.5;
  color: var(--ink);
  max-width: 40rem;
  margin-inline: auto;
}

.center {
  text-align: center;
}

.link {
  color: var(--accent);
  text-decoration: none;
  font-weight: 560;
  transition: color 0.18s ease;
}
.link:hover {
  color: var(--accent-deep);
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* -------------------------------------------------------------------- cards */

.cards {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 19rem), 1fr));
}

.card {
  background: var(--paper-alt);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: clamp(1.5rem, 3vw, 2rem);
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow);
}

.card p {
  color: var(--ink-soft);
  font-size: 0.9375rem;
  margin: 0;
}

.card__num {
  font-family: var(--mono);
  font-size: 0.6875rem;
  letter-spacing: 0.16em;
  color: var(--accent) !important;
  font-weight: 600;
  margin-bottom: 0.1rem !important;
}

.tags {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0.75rem 0 0;
  padding: 0;
  justify-content: center;
}

.tags li {
  font-size: 0.75rem;
  color: var(--ink-soft);
  background: var(--paper-sunk);
  border-radius: var(--pill);
  padding: 0.3rem 0.8rem;
}

/* ------------------------------------------------------------------- facts */

.facts {
  list-style: none;
  margin: 0 auto;
  padding: 0;
  max-width: 50rem;
  counter-reset: fact;
}

.facts li {
  border-top: 1px solid var(--rule);
  padding: 1.15rem 0;
  display: grid;
  grid-template-columns: 2.75rem minmax(0, 1fr);
  gap: 0.5rem;
  align-items: start;
  color: var(--ink-soft);
}

.facts li::before {
  counter-increment: fact;
  content: counter(fact, decimal-leading-zero);
  font-family: var(--mono);
  font-size: 0.6875rem;
  color: var(--accent);
  padding-top: 0.4rem;
  font-weight: 600;
}

/* ---------------------------------------------------------------- chapters */

.chapters {
  display: grid;
  gap: 1rem;
  max-width: 54rem;
  margin-inline: auto;
}

.chapter {
  background: var(--paper-alt);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: clamp(1.5rem, 3vw, 2.25rem);
  display: grid;
  gap: 0.35rem clamp(1.5rem, 4vw, 3rem);
  grid-template-columns: minmax(0, 1fr);
}

@media (min-width: 48rem) {
  .chapter {
    grid-template-columns: 11rem minmax(0, 1fr);
  }
}

.chapter__period {
  font-family: var(--mono);
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  color: var(--ink-muted);
  padding-top: 0.3rem;
}

.chapter__org {
  color: var(--accent);
  font-size: 0.9375rem;
  font-weight: 560;
  margin: 0 0 0.75rem;
}

.chapter__outcome {
  border-left: 2px solid var(--accent);
  padding-left: 1rem;
  color: var(--ink-muted);
  font-size: 0.9375rem;
  margin-bottom: 0;
}

/* ----------------------------------------------------------------- columns */

.cols {
  display: grid;
  gap: clamp(1.5rem, 3.5vw, 2.5rem);
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 17rem), 1fr));
  max-width: 60rem;
  margin-inline: auto;
}

.stack {
  list-style: none;
  margin: 0;
  padding: 0;
}

.stack li {
  border-top: 1px solid var(--rule);
  padding: 0.85rem 0;
  color: var(--ink-soft);
  font-size: 0.9375rem;
}

.stack li span {
  display: block;
  font-size: 0.8125rem;
  color: var(--ink-muted);
  margin-top: 0.15rem;
}

/* --------------------------------------------------------------------- faq */

.qa {
  background: var(--paper-alt);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: clamp(1.35rem, 3vw, 2rem);
  margin-bottom: 1rem;
  max-width: 50rem;
  margin-inline: auto;
}

.qa h3 {
  font-size: clamp(1.0625rem, 1.9vw, 1.3125rem);
  margin-bottom: 0.6rem;
}

.qa p {
  color: var(--ink-soft);
  margin: 0;
}

/* ----------------------------------------------------------------- writing */

.entry {
  background: var(--paper-alt);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: clamp(1.5rem, 3vw, 2.25rem);
  margin-bottom: 1rem;
  max-width: 50rem;
  margin-inline: auto;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.entry:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow);
}

.entry .label {
  color: var(--ink-muted);
}

.entry__title {
  font-size: clamp(1.3125rem, 2.6vw, 1.75rem);
  line-height: 1.15;
  letter-spacing: -0.025em;
  margin: 0.35rem 0 0.6rem;
}

.entry__title a {
  text-decoration: none;
}

.entry__title a:hover {
  color: var(--accent);
}

.entry p {
  color: var(--ink-soft);
  margin: 0;
}

/* -------------------------------------------------------------------- post */

.post__head,
.post > .wrap,
.post__foot {
  max-width: 46rem;
}

.post__head {
  padding-block: clamp(3rem, 8vw, 5.5rem) clamp(1.75rem, 4vw, 2.75rem);
  text-align: center;
}

.post__head .label {
  color: var(--ink-muted);
}

.post__head h1 {
  font-size: clamp(2rem, 5vw, 3.5rem);
  line-height: 1.06;
  letter-spacing: -0.035em;
  font-weight: 660;
  margin: 0.75rem auto 1.25rem;
  max-width: 18ch;
  text-wrap: balance;
}

.post__head .hero__lede {
  margin-bottom: 0;
}

.post__body {
  font-size: clamp(1.0625rem, 1rem + 0.25vw, 1.1875rem);
  line-height: 1.72;
  color: var(--ink-soft);
  padding-bottom: clamp(2.5rem, 5vw, 3.5rem);
  border-bottom: 1px solid var(--rule);
}

.post__body p {
  margin: 0 0 1.4rem;
}

.post__body h2 {
  font-size: clamp(1.375rem, 2.4vw, 1.75rem);
  color: var(--ink);
  margin: 2.75rem 0 1rem;
}

.post__body strong {
  color: var(--ink);
  font-weight: 620;
}

.post__body ul,
.post__body ol {
  margin: 0 0 1.4rem;
  padding-left: 1.25rem;
}

.post__body li {
  margin-bottom: 0.6rem;
  padding-left: 0.25rem;
}

.post__body hr {
  border: 0;
  border-top: 1px solid var(--rule);
  margin: 2.5rem 0;
}

.post__body em {
  color: var(--ink-muted);
}

.post__body a {
  color: var(--accent);
}

.post__foot {
  padding-block: clamp(2rem, 4vw, 2.75rem) clamp(3rem, 6vw, 4rem);
  text-align: center;
}

/* ---------------------------------------------------------- ask-ai block */

.askai {
  background: var(--paper-sunk);
  padding-block: clamp(3.5rem, 8vw, 5.5rem);
  text-align: center;
}

.askai__inner {
  max-width: 48rem;
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.askai h2 {
  font-size: clamp(1.5rem, 3vw, 2.25rem);
  margin-bottom: 0.85rem;
}

.askai__intro {
  color: var(--ink-soft);
  max-width: 34rem;
  margin: 0 auto 1.75rem;
}

.askai__prompt {
  font-family: var(--mono);
  font-size: 0.8125rem;
  line-height: 1.65;
  color: var(--ink-soft);
  background: var(--paper-alt);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 1.1rem 1.35rem;
  margin: 0 auto 1.75rem;
  text-align: left;
  overflow-wrap: break-word;
}

.askai__row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.625rem;
  align-items: center;
  justify-content: center;
}

.askai__btn {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.6rem 1.1rem;
  border: 1px solid var(--rule);
  border-radius: var(--pill);
  background: var(--paper-alt);
  color: var(--ink);
  font: inherit;
  font-size: 0.875rem;
  font-weight: 560;
  text-decoration: none;
  cursor: pointer;
  transition: border-color 0.18s ease, transform 0.18s ease,
    background 0.18s ease, color 0.18s ease;
}

.askai__btn:hover {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
  transform: translateY(-1px);
}

.askai__btn svg {
  width: 17px;
  height: 17px;
  flex: none;
}

.askai__note {
  font-size: 0.8125rem;
  color: var(--ink-muted);
  margin: 1.35rem auto 0;
  max-width: 34rem;
}

.askai__status {
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--accent);
  width: 100%;
  margin-top: 0.35rem;
}

/* ------------------------------------------------------------------ footer */

.footer {
  background: var(--ink);
  color: var(--paper);
  padding: clamp(3rem, 7vw, 4.5rem) var(--gutter) 2rem;
}

.footer__grid {
  display: grid;
  gap: clamp(1.75rem, 4vw, 3rem);
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 15rem), 1fr));
  padding-bottom: 2.5rem;
  max-width: 76rem;
  margin-inline: auto;
}

.footer .label {
  color: var(--accent-deep);
}

.footer__block p {
  margin: 0 0 0.6rem;
  font-size: 0.9375rem;
  color: color-mix(in srgb, var(--paper) 72%, transparent);
}

.footer__lead {
  max-width: 30ch;
}

.footer__muted {
  color: color-mix(in srgb, var(--paper) 55%, transparent) !important;
  max-width: 28ch;
}

.footer__link {
  display: block;
  color: var(--paper);
  text-decoration: none;
  font-size: 0.9375rem;
  padding: 0.15rem 0;
  width: fit-content;
  border-bottom: 1px solid transparent;
}
.footer__link:hover {
  border-bottom-color: var(--accent);
  color: var(--accent-deep);
}

.footer__legal {
  border-top: 1px solid color-mix(in srgb, var(--paper) 18%, transparent);
  padding-top: 1.5rem;
  font-family: var(--mono);
  font-size: 0.6875rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: color-mix(in srgb, var(--paper) 45%, transparent);
  margin: 0;
  max-width: 76rem;
  margin-inline: auto;
}

/* ------------------------------------------------------------------ motion */

[data-reveal] {
  transition:
    opacity 0.75s cubic-bezier(0.22, 1, 0.36, 1),
    transform 0.75s cubic-bezier(0.22, 1, 0.36, 1);
}

[data-reveal].is-pending {
  opacity: 0;
  transform: translateY(18px);
}

@media (prefers-reduced-motion: reduce) {
  [data-reveal],
  [data-reveal].is-pending {
    opacity: 1;
    transform: none;
    transition: none;
  }
}

@media print {
  .masthead__nav,
  .askai,
  .skip {
    display: none;
  }
}
