:root {
  --bg: #f4efe7;
  --paper: #fffaf0;
  --ink: #222222;
  --muted: #6b6258;
  --accent: #8b5e34;
  --accent-dark: #4a2f1d;
  --line: #d8c7ad;
  --hole: #2b2b2b;
  --shadow: 0 18px 40px rgba(65, 43, 24, 0.16);
}

* {
  box-sizing: border-box;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: "Source Serif 4", Georgia, "Times New Roman", serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(139, 94, 52, 0.14), transparent 28rem),
    linear-gradient(135deg, #f4efe7 0%, #e8dcc9 100%);
  line-height: 1.72;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(rgba(80, 58, 33, 0.055) 1px, transparent 1px),
    linear-gradient(90deg, rgba(80, 58, 33, 0.055) 1px, transparent 1px);
  background-size: 32px 32px;
  opacity: 0.65;
}

a {
  color: var(--accent-dark);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

a:focus-visible,
button:focus-visible {
  outline: 3px solid rgba(160, 95, 28, 0.55);
  outline-offset: 3px;
}

.article-link {
  color: #a05f1c;
  font-weight: 700;
}

.article-link:hover {
  color: var(--accent-dark);
}


/* ===== BANER NAD MENU ===== */

.site-banner {
  position: relative;
  z-index: 2;
  width: 100%;
  background: #2d2118;
  border-bottom: 1px solid rgba(216, 199, 173, 0.45);
}

.site-banner img {
  display: block;
  width: 100%;
  height: auto;
  object-fit: contain;
}

/* Dekoracyjna czcionka zostaje tylko w elementach nawigacyjnych i nagłówkach. */
.brand,
.topnav,
.nav-toggle,
.eyebrow,
h1,
h2,
h3,
h4,
.card h4,
.timeline strong,
.code-sample {
  font-family: "Special Elite", "Courier New", monospace;
}

p,
li,
.original-text pre {
  font-family: "Source Serif 4", Georgia, "Times New Roman", serif;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}


/* ===== GÓRNE MENU ===== */

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 22px;
  align-items: center;
  padding: 14px min(5vw, 64px);
  background:
    linear-gradient(180deg, rgba(45, 33, 24, 0.98), rgba(45, 33, 24, 0.92));
  border-bottom: 6px solid var(--accent);
  box-shadow: 0 12px 30px rgba(65, 43, 24, 0.18);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-width: 230px;
  color: #fff6e8;
  text-decoration: none;
}

.brand:hover {
  text-decoration: none;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 1px solid rgba(255, 246, 232, 0.35);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.08);
  color: #ead7bd;
  font-size: 1.35rem;
}

.brand strong,
.brand em {
  display: block;
}

.brand strong {
  color: #fff6e8;
  font-size: 1rem;
  line-height: 1.1;
}

.brand em {
  margin-top: 3px;
  color: #ead7bd;
  font-size: 0.74rem;
  font-style: normal;
}

.topnav {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.topnav a,
.nav-parent {
  position: relative;
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 8px 11px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: #fff6e8;
  font-family: inherit;
  font-size: 0.82rem;
  line-height: 1.2;
  cursor: pointer;
  transition: background 0.2s, transform 0.2s;
}

.topnav a {
  text-align: left;
}

.topnav a:hover,
.topnav a.active,
.nav-parent:hover,
.nav-parent.active {
  background: rgba(255, 255, 255, 0.12);
  text-decoration: none;
  transform: translateY(-1px);
}

.topnav a.active::after,
.nav-parent.active::after {
  content: "";
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: 5px;
  height: 2px;
  border-radius: 999px;
  background: #ead7bd;
}

.nav-group {
  position: relative;
}

.nav-parent::before {
  content: "▾";
  margin-right: 7px;
  color: #ead7bd;
  font-size: 0.72rem;
}

.submenu {
  position: absolute;
  top: 100%;
  right: 0;
  display: none;
  min-width: 220px;
  padding: 8px;
  border: 1px solid rgba(255, 246, 232, 0.22);
  border-radius: 14px;
  background: rgba(45, 33, 24, 0.98);
  box-shadow: 0 16px 30px rgba(25, 17, 11, 0.24);
}

.submenu a {
  display: flex;
  width: 100%;
  border-radius: 10px;
}

.nav-group:hover .submenu,
.nav-group.submenu-open .submenu {
  display: block;
}

.nav-toggle {
  display: none;
  justify-self: end;
  padding: 10px 14px;
  border: 1px solid rgba(255, 246, 232, 0.35);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: #fff6e8;
  font-family: inherit;
  cursor: pointer;
}

/* ===== UKŁAD TREŚCI ===== */

.top-layout {
  position: relative;
  z-index: 1;
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
  padding: 44px 0 64px;
}

.hero {
  position: relative;
  padding: 50px;
  border-radius: 30px;
  background: var(--paper);
  box-shadow: var(--shadow);
  overflow: hidden;
  border: 1px solid var(--line);
}

.hero::before {
  content: "";
  position: absolute;
  inset: 22px;
  pointer-events: none;
  background-image:
    radial-gradient(circle, rgba(43, 43, 43, 0.78) 0 6px, transparent 6.5px);
  background-size: 46px 38px;
  opacity: 0.12;
  mask-image: linear-gradient(90deg, transparent, black 30%, black 70%, transparent);
}

.hero-content {
  position: relative;
  z-index: 1;
  max-width: 820px;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--accent);
  font-weight: bold;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-size: 0.78rem;
}

h2 {
  margin-top: 0;
  font-size: clamp(2rem, 4vw, 4rem);
  line-height: 1.04;
  color: var(--accent-dark);
}

h3 {
  margin-top: 0;
  font-size: clamp(1.5rem, 2.3vw, 2.25rem);
  color: var(--accent-dark);
  line-height: 1.15;
}

.plain-heading {
  font-family: "Source Serif 4", Georgia, "Times New Roman", serif;
  font-size: 1rem;
  line-height: 1.72;
}

.section-spaced {
  margin-top: 3.4em;
}

section {
  margin: 42px 0;
  padding: 34px;
  background: rgba(255, 250, 240, 0.86);
  border: 1px solid var(--line);
  border-radius: 26px;
  box-shadow: 0 10px 26px rgba(65, 43, 24, 0.08);
}

.lead {
  font-size: 1.16rem;
  color: #3a3028;
}

.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-top: 22px;
}

.card {
  position: relative;
  min-height: 180px;
  padding: 20px;
  border: 1px solid rgba(216, 199, 173, 0.92);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 253, 247, 0.94), rgba(255, 243, 218, 0.78));
  overflow: hidden;
}

.card::after {
  content: "";
  position: absolute;
  right: 16px;
  bottom: 16px;
  width: 84px;
  aspect-ratio: 1.8;
  pointer-events: none;
  background-image:
    radial-gradient(circle, rgba(43, 43, 43, 0.55) 0 3px, transparent 3.6px);
  background-size: 18px 15px;
  opacity: 0.11;
}

.card h4 {
  position: relative;
  z-index: 1;
  margin: 0 0 10px;
  color: var(--accent-dark);
  font-size: clamp(1.08rem, 1.6vw, 1.28rem);
  line-height: 1.18;
}

.timeline {
  list-style: none;
  padding: 0;
  margin: 20px 0 0;
}

.timeline li {
  display: grid;
  grid-template-columns: 105px 1fr;
  gap: 18px;
  padding: 16px 0;
  border-bottom: 1px dashed var(--line);
}

.timeline strong {
  color: var(--accent);
}

.punch-card {
  margin: 24px 0;
  padding: 22px;
  border-radius: 22px;
  background: #f8e9ca;
  border: 1px solid #c9a875;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.45);
}

.punch-grid {
  display: grid;
  grid-template-columns: repeat(16, 1fr);
  gap: 8px;
}

.hole {
  aspect-ratio: 1;
  border-radius: 50%;
  border: 1px solid #b7925e;
  background: rgba(255, 255, 255, 0.45);
}

.hole.punched {
  background: var(--hole);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.08);
}

.note {
  position: relative;
  margin-top: 18px;
  padding: 16px 18px;
  border: 1px solid rgba(216, 199, 173, 0.92);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 253, 247, 0.94), rgba(255, 243, 218, 0.78));
  color: #4d4035;
  overflow: hidden;
}

.code-sample {
  padding: 18px;
  overflow-x: auto;
  border-radius: 16px;
  background: #2d2118;
  color: #fff6e8;
  font-family: "Special Elite", "Courier New", monospace;
  font-size: 0.93rem;
  line-height: 1.55;
}

.bibliografia li {
  margin-bottom: 12px;
}

.article-page {
  max-width: 980px;
  margin-left: auto;
  margin-right: auto;
}

.article-content {
  margin-top: 32px;
}

.article-image {
  width: min(520px, 100%);
  margin: 24px auto 34px;
}

.article-image-wide {
  width: 100%;
}

.article-image-medium {
  width: min(700px, 100%);
}

.article-image img,
.image-zoom-trigger {
  display: block;
}

.article-image img {
  width: 100%;
  height: auto;
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 12px 24px rgba(65, 43, 24, 0.14);
}

.image-zoom-trigger {
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: zoom-in;
}

.article-image figcaption {
  margin-top: 9px;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.45;
  text-align: center;
}

.matching-caption figcaption {
  margin-top: 7px;
  font-size: 0.76rem;
  line-height: 1.35;
}

.matching-caption figcaption strong,
.matching-caption figcaption span {
  display: block;
}

.matching-caption figcaption strong {
  color: var(--accent-dark);
  font-family: "Special Elite", "Courier New", monospace;
  font-size: 0.82rem;
}

.image-lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 24px;
  overflow: auto;
  background: rgba(24, 17, 12, 0.82);
}

.image-lightbox.open {
  display: flex;
}

body.lightbox-open {
  overflow: hidden;
}

.image-lightbox img {
  width: auto;
  height: auto;
  max-width: none;
  max-height: none;
  margin: auto 0;
  border: 1px solid rgba(255, 246, 232, 0.35);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
}

.inline-portrait {
  float: right;
  width: min(230px, 42%);
  margin: 0 0 18px 24px;
}

.inline-portrait-left {
  float: left;
  margin: 0 24px 18px 0;
}

.analytical-engine-cards {
  width: min(300px, 46%);
}

.paragraph-line-lower {
  margin-top: 1.72em;
}

.paragraph-extra-line-lower {
  margin-top: 3.44em;
}

.clear-float {
  clear: both;
}

.inline-portrait img {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fffdf7;
}

.inline-portrait figcaption {
  margin-top: 7px;
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.35;
}

.inline-portrait figcaption strong,
.inline-portrait figcaption span {
  display: block;
}

.inline-portrait figcaption strong {
  color: var(--accent-dark);
  font-family: "Special Elite", "Courier New", monospace;
  font-size: 0.82rem;
}

.article-section {
  margin: 0;
  padding: 34px 0;
  scroll-margin-top: 110px;
  border: 0;
  border-top: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.article-section:first-child {
  border-top: 0;
  padding-top: 0;
}

.article-section:last-child {
  padding-bottom: 0;
}

.article-section h3 {
  margin-bottom: 18px;
}

.article-section p,
.article-section li {
  font-size: 1.13rem;
}

.bibliography-page .article-section p,
.bibliography-page .article-section li {
  font-size: 1rem;
}

.hollerith-page .article-content > p,
.hollerith-page .article-content > ul > li {
  font-size: 1.13rem;
}

.start-page {
  position: relative;
  max-width: 980px;
  padding: 0;
  overflow: hidden;
}

.start-hero {
  position: relative;
  min-height: clamp(430px, 58vh, 620px);
  display: flex;
  align-items: flex-end;
  padding: clamp(34px, 5vw, 58px);
  overflow: hidden;
  color: #fffaf0;
  background:
    linear-gradient(90deg, rgba(22, 15, 10, 0.9) 0%, rgba(38, 25, 16, 0.72) 42%, rgba(38, 25, 16, 0.2) 78%),
    linear-gradient(0deg, rgba(22, 15, 10, 0.92) 0%, rgba(22, 15, 10, 0.18) 52%, rgba(22, 15, 10, 0.2) 100%),
    url("assets/960px-Punched_card_program_deck.agr.jpeg") center 42% / cover;
}

.start-hero::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image:
    radial-gradient(circle, rgba(255, 246, 232, 0.32) 0 3px, transparent 3.7px);
  background-position: right 32px top 34px;
  background-size: 34px 27px;
  mask-image: linear-gradient(90deg, transparent 0%, black 56%, black 100%);
  opacity: 0.28;
}

.start-hero::after {
  content: "";
  position: absolute;
  right: clamp(20px, 4vw, 48px);
  bottom: clamp(18px, 3vw, 36px);
  width: min(310px, 34%);
  aspect-ratio: 1.85;
  border: 1px solid rgba(255, 246, 232, 0.28);
  border-radius: 6px;
  background-image:
    linear-gradient(rgba(255, 246, 232, 0.12) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 246, 232, 0.12) 1px, transparent 1px),
    radial-gradient(circle, rgba(255, 246, 232, 0.42) 0 3px, transparent 3.8px);
  background-size: 100% 20%, 8.33% 100%, 26px 22px;
  opacity: 0.42;
  transform: rotate(-2deg);
}

.start-hero-copy {
  position: relative;
  z-index: 1;
  width: min(760px, 100%);
}

.start-hero-text {
  display: grid;
  gap: 18px;
  padding-left: clamp(18px, 3vw, 28px);
  border-left: 4px solid rgba(241, 194, 125, 0.88);
}

.start-hero-text p {
  margin: 0;
  color: rgba(255, 250, 240, 0.92);
  font-size: clamp(1.15rem, 1.55vw, 1.38rem);
  line-height: 1.72;
  text-shadow: 0 3px 14px rgba(0, 0, 0, 0.5);
}

.start-hero-text p:first-child {
  color: #ffe9c8;
  font-family: "Liberation Sans", Arial, Helvetica, sans-serif;
  font-size: clamp(1.62rem, 2.55vw, 2.48rem);
  font-weight: 700;
  line-height: 1.38;
}

.start-notes {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(220px, 0.8fr);
  gap: 18px;
  margin: 0;
  padding: 30px clamp(24px, 4vw, 38px) clamp(28px, 4vw, 42px);
  background:
    linear-gradient(180deg, rgba(255, 250, 240, 0.92), rgba(255, 250, 240, 0.78));
  border-top: 1px solid rgba(216, 199, 173, 0.85);
}

.start-notes p {
  position: relative;
  margin: 0;
  padding: 20px;
  border: 1px solid rgba(216, 199, 173, 0.92);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 253, 247, 0.94), rgba(255, 243, 218, 0.78));
  color: #3a3028;
  font-size: 1.05rem;
  line-height: 1.65;
  overflow: hidden;
}

.start-notes p::after,
.pull-quote::after,
.note::after,
.formula::after {
  content: "";
  position: absolute;
  right: 16px;
  bottom: 16px;
  width: 84px;
  aspect-ratio: 1.8;
  pointer-events: none;
  background-image:
    radial-gradient(circle, rgba(43, 43, 43, 0.55) 0 3px, transparent 3.6px);
  background-size: 18px 15px;
  opacity: 0.11;
}

.start-notes p > *,
.pull-quote > *,
.note > *,
.formula > * {
  position: relative;
  z-index: 1;
}

.start-notes p:first-child {
  grid-row: span 2;
  align-self: stretch;
  display: flex;
  align-items: center;
  background:
    linear-gradient(135deg, rgba(255, 243, 218, 0.96), rgba(255, 253, 247, 0.92));
  font-size: 1.12rem;
}

.fact-list {
  margin: 0 0 20px;
  padding-left: 1.3rem;
}

.fact-list li,
.compact-list li {
  margin-bottom: 10px;
}

.fact-list strong {
  display: block;
  color: var(--accent-dark);
  font-family: "Special Elite", "Courier New", monospace;
  font-size: 0.96rem;
}

.article-section p {
  margin: 0 0 18px;
}

.article-section p:last-child,
.article-section ul:last-child,
.article-section ol:last-child {
  margin-bottom: 0;
}

.compact-list {
  margin: 0 0 20px;
  padding-left: 1.3rem;
}

.pull-quote {
  position: relative;
  margin: 24px 0;
  padding: 20px;
  border: 1px solid rgba(216, 199, 173, 0.92);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(255, 243, 218, 0.96), rgba(255, 253, 247, 0.92));
  color: #4d4035;
  font-size: 1.08rem;
  line-height: 1.7;
  overflow: hidden;
}

.formula {
  position: relative;
  padding: 14px 18px;
  border: 1px solid rgba(216, 199, 173, 0.92);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 253, 247, 0.94), rgba(255, 243, 218, 0.78));
  color: var(--accent-dark);
  font-family: "Source Serif 4", Georgia, "Times New Roman", serif;
  overflow: hidden;
}

.original-text pre {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: break-word;
  font-family: "Source Serif 4", Georgia, "Times New Roman", serif;
  font-size: 1.08rem;
  line-height: 1.82;
  color: #2f2923;
}

footer {
  margin: 50px 0 10px;
  color: var(--muted);
  text-align: center;
  font-size: 0.92rem;
}

.page-navigation {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  width: min(980px, 100%);
  margin: 34px auto 0;
}

.page-navigation-link {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 78px;
  padding: 16px 18px;
  border: 1px solid rgba(216, 199, 173, 0.92);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 253, 247, 0.94), rgba(255, 243, 218, 0.78));
  color: var(--accent-dark);
  text-decoration: none;
  box-shadow: 0 10px 20px rgba(65, 43, 24, 0.08);
  transition:
    transform 0.2s ease,
    border-color 0.2s ease,
    box-shadow 0.2s ease;
}

.page-navigation-link:hover,
.page-navigation-link:focus-visible {
  transform: translateY(-2px);
  border-color: rgba(122, 63, 32, 0.46);
  box-shadow: 0 14px 26px rgba(65, 43, 24, 0.12);
}

.page-navigation-link span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.page-navigation-link strong {
  margin-top: 4px;
  font-size: 1.08rem;
  line-height: 1.2;
}

.page-navigation-next {
  align-items: flex-end;
  text-align: right;
}

.page-navigation-placeholder {
  min-height: 78px;
}

@media (max-width: 1040px) {
  .topbar {
    grid-template-columns: 1fr auto;
  }

  .nav-toggle {
    display: inline-flex;
  }

  .topnav {
    display: none;
    grid-column: 1 / -1;
    justify-content: flex-start;
    padding-top: 10px;
  }

  body.menu-open .topnav {
    display: flex;
  }

  .topnav a,
  .nav-parent {
    justify-content: flex-start;
  }

  .topnav a {
    border-radius: 12px;
  }

  .nav-group {
    width: 100%;
  }

  .nav-parent {
    width: 100%;
    border-radius: 12px;
  }

  .submenu {
    position: static;
    width: 100%;
    margin: 4px 0 8px;
    box-shadow: none;
    background: rgba(255, 255, 255, 0.07);
  }
}

@media (max-width: 760px) {
  .top-layout {
    width: min(100% - 24px, 1180px);
    padding-top: 24px;
  }

  .topbar {
    padding: 12px 14px;
  }

  .brand {
    min-width: 0;
  }

  .brand strong {
    font-size: 0.92rem;
  }

  .brand em {
    display: none;
  }

  .hero {
    padding: 32px;
  }

  .grid {
    grid-template-columns: 1fr;
  }

  .timeline li {
    grid-template-columns: 1fr;
  }

  section {
    padding: 24px;
  }

  .page-navigation {
    grid-template-columns: 1fr;
  }

  .page-navigation-placeholder {
    display: none;
  }

  .page-navigation-next {
    align-items: flex-start;
    text-align: left;
  }

  .start-page {
    padding: 0;
  }

  .start-hero {
    min-height: 560px;
    padding: 30px 22px;
    background:
      linear-gradient(180deg, rgba(22, 15, 10, 0.42) 0%, rgba(22, 15, 10, 0.74) 42%, rgba(22, 15, 10, 0.96) 100%),
      url("assets/960px-Punched_card_program_deck.agr.jpeg") center top / cover;
  }

  .start-hero::before {
    background-size: 28px 23px;
    mask-image: linear-gradient(180deg, black 0%, transparent 62%);
    opacity: 0.2;
  }

  .start-hero::after {
    display: none;
  }

  .start-hero-text {
    gap: 12px;
    padding-left: 16px;
  }

  .start-notes {
    grid-template-columns: 1fr;
    padding: 24px 18px 28px;
  }

  .start-notes p:first-child {
    grid-row: auto;
  }

  .card {
    min-height: 0;
  }

  .punch-grid {
    grid-template-columns: repeat(8, 1fr);
  }

  .inline-portrait {
    float: none;
    width: min(260px, 100%);
    margin: 0 auto 20px;
  }

  .inline-portrait figcaption {
    text-align: center;
  }
}
