/* Base styles */
body {
  margin: 0;
  padding: 40px 0;
  font-family: 'JetBrains Mono', monospace;
  background: #f5f5f5;
  color: #111;
  display: block;
  box-sizing: border-box;
  font-size: 16px;
  line-height: 1.4;
  word-break: break-word;
  width: 100%;
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
}

body > * {
  margin: 0 auto;
}

/* Font families */
.serif {
  font-family: 'Spectral', serif;
  letter-spacing: 0.10em;
}

.display {
  font-family: 'Instrument Serif', serif;
  letter-spacing: normal;
}

.mono {
  font-family: 'JetBrains Mono', monospace;
  letter-spacing: 0.10em;
}

/* Headings — size & rhythm only (no font-family) */
h1, h2, h3, h4, h5, h6 {
  margin: 0;
  line-height: 1.2;
  font-weight: 400;
  letter-spacing: 0.02em;
}

/* scaling system */
h1 { font-size: clamp(2.5rem, 6vw, 4rem); }
h2 { font-size: clamp(2rem, 5vw, 3.2rem); }
h3 { font-size: clamp(1.6rem, 4vw, 2.4rem); }
h4 { font-size: clamp(1.3rem, 3vw, 1.8rem); }
h5 { font-size: clamp(0.75rem, 1.5vw, 0.9rem); }
h6 { font-size: clamp(0.65rem, 1.2vw, 0.8rem); letter-spacing: 0.05em; }

/* optional vertical spacing when stacked */
h1 + *, h2 + *, h3 + *, h4 + *, h5 + *, h6 + * {
  margin-top: 0.6em;
}

/* Topline rows */
.topline {
  display: flex;
  justify-content: space-between;
  width: 98vw;
  padding: 0 1%;
  box-sizing: border-box;
  flex-shrink: 0;
  gap: clamp(8px, 2vw, 24px);
}

/* children blocks inside topline */
.topline > * {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  word-wrap: break-word;
  overflow-wrap: anywhere;
  min-width: 0;
}

/* spacing utility classes */
.spacing-none      { margin-top: 0 !important; margin-bottom: 0 !important; }
.spacing-small     { margin-bottom: 20px; }
.spacing-medium    { margin-bottom: 50px; }
.spacing-large     { margin-bottom: 80px; }
.spacing-xlarge    { margin-bottom: 110px; }
.spacing-xxlarge   { margin-bottom: 140px; }

.spacing-top-small   { margin-top: 20px; }
.spacing-top-medium  { margin-top: 50px; }
.spacing-top-large   { margin-top: 80px; }
.spacing-top-xlarge  { margin-top: 110px; }
.spacing-top-xxlarge { margin-top: 140px; }

body.homepage .topline + .topline {
  margin-top: 0;
}

/* images */
.island-image {
  width: 100%;
  max-width: 600px;
  height: auto;
  display: block;
  object-fit: cover;
  border-radius: 4px;
}

.island-image.small {
  max-width: 250px;
}

.topline img {
  flex-shrink: 0;
}

/* Horizontal gap classes for topline rows */
.topline.gap-small { gap: 10px; }
.topline.gap-medium { gap: 20px; }
.topline.gap-large { gap: 40px; }

.topline.gap-small > *,
.topline.gap-medium > *,
.topline.gap-large > * {
  flex-shrink: 0;
}

/* links */
.topline a {
  text-decoration: none;
  color: #111;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.topline a:hover {
  text-decoration: underline;
  opacity: 0.8;
}

/* non-link blocks */
.topline div,
.topline span {
  display: flex;
  flex-direction: column;
  word-wrap: break-word;
  overflow-wrap: anywhere;
}

/* alignment classes */
.left   { justify-content: flex-start !important; align-items: flex-start !important; text-align: left; }
.center { justify-content: center !important; align-items: center !important; text-align: center; }
.right  { justify-content: flex-end !important; align-items: flex-end !important; text-align: right; }

/* Text formatting */
.bold { font-weight: 700; }
.italic { font-style: italic; }
.underline { text-decoration: underline; }
.cross { text-decoration: line-through; }

/* Paragraph handling inside blocks */
.topline div p,
.topline span p {
  margin: 0;
  padding: 0;
  line-height: 1.4;
}

/* space between paragraphs */
.topline div p + p,
.topline span p + p {
  margin-top: 35px;
}

/* -------------------------------------------------- */
/* Horizontal layout for image + text rows */
.horizontal-row {
  display: flex !important;         /* enforce flex row */
  flex-direction: row !important;   /* side by side */
  flex-wrap: nowrap !important;     /* prevent stacking */
  justify-content: center;
  align-items: flex-start;
  gap: 24px;
  width: 100%;
}

/* Override children to prevent flex:1 issues from .topline > * */
.horizontal-row > * {
  flex: 0 0 auto;          /* don't grow/shrink */
  display: block;          /* stop inner centering */
  max-width: 45vw;         /* adjust as needed */
}

/* Force text inside horizontal row to wrap correctly */
.horizontal-row .right p {
  min-width: 0;
  word-wrap: break-word;
  overflow-wrap: anywhere;
}

/* Responsive: stack vertically on small screens */
@media (max-width: 880px) {
  .horizontal-row {
    flex-direction: column;
    align-items: center;
  }
  .horizontal-row > * {
    width: 90%;
    max-width: 90%;
  }
}

/* Reset inconsistent defaults */
* {
  box-sizing: border-box;
  max-width: 100%;
}

/* Keep nav centered + proportional */
nav.topline a {
  white-space: nowrap;
}

/* Sticky header */
.sticky-header {
  position: -webkit-sticky; /* Safari */
  position: sticky;
  top: 0;
  z-index: 100;
  background: transparent;
  padding: 20px 0;
  width: 100%;
  flex-wrap: nowrap !important;
}

/* Ensure flex items stay proportionate on tablets/mobiles */
@media (max-width: 880px) {
  .topline {
    flex-wrap: wrap;
    justify-content: center;
    text-align: center;
  }
  .topline a {
    flex: 0 0 auto;
  }
  
  /* Don't let sticky header wrap on mobile */
  .sticky-header {
    flex-wrap: nowrap !important;
  }
}

/* Mobile fix ONLY for sections (island pages) */
@media (max-width: 880px) {
  section[style*="flex-wrap:nowrap"] {
    flex-wrap: wrap !important;
    flex-direction: column !important;
    align-items: center !important;
  }
  
  section[style*="flex-wrap:nowrap"] > div {
    flex: 1 1 100% !important;
    max-width: 100vw !important;
    width: 100vw !important;
    padding: 0 !important;
  }
  
  /* For sections using .topline class */
  section.topline {
    flex-direction: column !important;
    align-items: center !important;
    padding: 0 !important;
  }
  
  section.topline > div {
    max-width: 100vw !important;
    width: 100vw !important;
    padding: 0 !important;
  }
  
  section video,
  section img {
    max-width: 100% !important;
    width: 100% !important;
    border-radius: 0 !important;
  }
}