/* Target only elements *inside* the body */
body [lang] {
  display: none;
}

/* Then show only the matching ones */
html.lang-active-en body [lang="en"],
html.lang-active-pl body [lang="pl"] {
  display: block; /* or inline/block as appropriate */
}

.post-content {
    margin-bottom: 20px;
}

/* Progress bar container */
.progress-bar {
    display: flex;
    height: 24px;
    border-radius: 4px;
    overflow: visible;
    margin: 0.5rem 1rem;
    position: relative;
}

/* Each segment */
.progress-bar .segment {
    cursor: pointer;
    position: relative;
    /* flex basis comes from inline style */
}

.progress-bar .segment:first-child {
    border-top-left-radius: 0.6rem;
    border-bottom-left-radius: 0.6rem;
}

.progress-bar .segment:last-child {
    border-top-right-radius: 0.6rem;
    border-bottom-right-radius: 0.6rem;
}

/* Hover tooltip */
.progress-bar .segment:hover::after {
    content: attr(data-activity) "\A" attr(data-hours) " hrs";
    white-space: pre;
    display: inline-block;
    line-height: 1.2;
    position: absolute;
    top: -3em;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.75);
    color: #fff;
    padding: 4px 8px;
    border-radius: 3px;
    pointer-events: none;
    z-index: 10;
    text-align: center;
    font-family: Roboto, Helvetica, "Noto Sans", Arial;
}


.sleep        { background-color: #323842; }
.dating       { background-color: #c61734; }
.friends      { background-color: #015745; }
.robots       { background-color: #fe65af; }
.school       { background-color: #01a8b3; }
.work         { background-color: #199748; }
.productive   { background-color: #fef236; }
.hobby        { background-color: #ff6c00; }
.leisure      { background-color: #5b3bb0; }
.waste        { background-color: #ff2816; }
.transition   { background-color: #bffe54; }

.bad      { background-color: #5b3bb0; }
.poor     { background-color: #c61734; }
.ok       { background-color: #ff6c00; }
.neutral  { background-color: #fabc05; }
.good     { background-color: #01a8b3; }
.great    { background-color: #199748; }

/* container for the two buttons */
.lang-switch {
  display: inline-flex;
  gap: 0.5em;
  margin-bottom: 1em;
}

.lang-switch {
  display: inline-flex;
  gap: 0.25em;
  margin-bottom: 1em;
}

.lang-switch button {
  background: #282c34;
  color: #ccc;
  border: 1px solid transparent;
  border-radius: 9999px;
  padding: 0.25em 0.75em;
  margin: 0 0.15em;
  font-family: Oswald, Arial, sans-serif;
  font-size: 0.85rem;
  cursor: pointer;
  transition: 
    background 0.2s, 
    border-color 0.2s, 
    color 0.2s;
}

.lang-switch button:hover {
  background: #4a4f5b;
}

.lang-switch button.active {
  background: transparent;
  color: #00ccff;
  border-color: #00ccff;         /* just an outline highlight */
}

.lang-switch button:focus {
  outline: none;
  box-shadow: 0 0 0 2px rgba(0, 204, 255, 0.5);
}

.image-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 4px; /* Further reduced gap for minimal spacing */
    max-width: 800px;
    margin: 0 auto;
    max-height: 100vh;
    overflow: hidden; /* Ensure strict height constraint */
    align-items: flex-start;
    justify-content: center; /* Center images for better alignment */
}

.image-grid .item {
  /* each portrait item wants at least 200px, but will grow to fill the row */
  flex: 1 1 200px;
  cursor: pointer;
  transition: transform 0.2s ease, filter 0.2s ease;
  display: flex;
  align-items: stretch; /* Ensure items stretch to match row height */
  min-width: 0; /* Prevent flex items from overflowing */
}

.image-grid .item:hover {
  transform: scale(1.02);
  filter: brightness(1.1);
}

.image-grid .item.landscape {
  /* landscape images can be more flexible width */
  flex: 1 1 250px;
  /* Removed max-width constraint to allow proportional layouts */
}

/* Handle direct img children for backward compatibility */
.image-grid > img {
  flex: 1 1 200px;
  cursor: pointer;
  transition: transform 0.2s ease, filter 0.2s ease;
  height: auto;
  display: block;
  border-radius: 4px;
  object-fit: contain;
  margin: 0 auto;
  min-width: 0;
}

.image-grid > img:hover {
  transform: scale(1.02);
  filter: brightness(1.1);
}

.image-grid > img.landscape {
  flex: 1 1 250px;
  /* Removed max-width constraint to allow proportional layouts */
}

.image-grid img {
  height: auto;
  display: block;
  border-radius: 4px;
  width: 100%;
  object-fit: contain;
  margin: 0 auto;
}

/* Dynamic sizing based on number of images - applies to both .item img and direct > img */
.image-grid[data-count="1"] img,
.image-grid[data-count="2"] img {
  max-height: 65vh; /* Increased for better visibility */
}

.image-grid[data-count="3"] img,
.image-grid[data-count="4"] img {
  max-height: 50vh; /* Increased for better visibility */
}

.image-grid[data-count="5"] img,
.image-grid[data-count="6"] img {
  max-height: 35vh;
}

.image-grid img {
  max-height: 25vh; /* Reduced from 30vh for stricter constraint */
}

/* Optimize large grids (7+ images) to minimize gaps */
.image-grid[data-count="7"] .item,
.image-grid[data-count="8"] .item,
.image-grid[data-count="9"] .item {
  flex: 1 1 calc(33.333% - 3px); /* Force 3-column layout for large grids */
  max-width: calc(33.333% - 3px);
  min-width: calc(33.333% - 3px); /* Prevent shrinking below this size */
}

/* Optimize large grids (7+ images) to minimize gaps */
.image-grid[data-count="7"] .item.landscape,
.image-grid[data-count="8"] .item.landscape {
  flex: 0 0 calc((100% - 5px) / 2) !important; /* Landscape images can span 2 columns worth */
  max-width: calc((100% - 5px) / 2) !important;
  min-width: calc((100% - 5px) / 2) !important;
}

/* Special handling for 9-image grids to ensure consistent 3x3 layout */
.image-grid[data-count="9"] {
  gap: 1px !important; /* Minimal gap for 9-image grids */
  justify-content: stretch; /* Fill all available space */
}

.image-grid[data-count="9"] .item {
  flex: 0 0 calc((100% - 8px) / 3) !important; /* Exact calculation: (100% - 8 gaps) / 3 items */
  max-width: calc((100% - 8px) / 3) !important;
  min-width: calc((100% - 8px) / 3) !important;
  width: calc((100% - 8px) / 3) !important;
}

/* Also apply to other large grids */
.image-grid[data-count="7"] .item,
.image-grid[data-count="8"] .item {
  flex: 0 0 calc((100% - 10px) / 3) !important; /* Account for gaps between 3 columns */
  max-width: calc((100% - 10px) / 3) !important;
  min-width: calc((100% - 10px) / 3) !important;
}

/* Additional constraint for rows with mixed aspect ratios */
.image-grid.mixed-row {
  gap: 4px; /* Consistent gap */
  flex-wrap: wrap; /* Allow wrapping for 4+ images */
}

.image-grid.mixed-row img {
  /* Dimensions will be set dynamically by JavaScript for precise fitting */
  object-fit: cover; /* Use cover for mixed-row to fill containers completely */
  object-position: center;
}

/* Fullscreen modal styles */
.fullscreen-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.fullscreen-modal.active {
  opacity: 1;
  visibility: visible;
}

.fullscreen-modal img {
  max-width: 90vw;
  max-height: 90vh;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

.fullscreen-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: white;
  font-size: 32px;
  font-weight: bold;
  cursor: pointer;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 1001;
  opacity: 0.6;
  user-select: none;
}

.fullscreen-nav:hover {
  opacity: 1;
  transform: translateY(-50%) scale(1.2);
}

.fullscreen-nav:disabled {
  opacity: 0.2;
  cursor: not-allowed;
}

.fullscreen-nav:disabled:hover {
  transform: translateY(-50%);
}

.fullscreen-nav.prev {
  left: 30px;
}

.fullscreen-nav.next {
  right: 30px;
}

.fullscreen-close {
  position: absolute;
  top: 30px;
  right: 30px;
  background: none;
  border: none;
  color: white;
  font-size: 32px;
  font-weight: bold;
  cursor: pointer;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 1001;
  opacity: 0.6;
  user-select: none;
}

.fullscreen-close:hover {
  opacity: 1;
  transform: scale(1.2);
}

/* A11y helper for hidden labels */
.sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* Wrap blurb + compact form inline, not full width */
.subscribe {
  display: flex;
  align-items: flex-start;
  gap: 10px 14px;
  flex-wrap: wrap;
  margin: 0.75em 0 1.25em;
  flex-direction: column;
}

/* Blurb text sits inline; follows your theme fonts */
.subscribe-blurb {
  margin: 0;
  font-size: 0.95rem;
  color: #ccc;
}

/* Compact pill form matching lang-switch look */
.subscribe-form {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  /* prevent stretching to full width */
  width: auto;
}

/* Make the input compact and not flex 1 */
.subscribe-form input[type="email"] {
  flex: 0 1 260px;              /* compact width, not full row */
  min-width: 200px;
  padding: 8px 12px;
  border: 1px solid #444;
  border-radius: 9999px;
  background: #1f2229;
  color: #fff;
  font-size: 0.95rem;
  transition: border-color 0.2s, background 0.2s;
}

.subscribe-form input[type="email"]::placeholder { color: #aaa; }

.subscribe-form input[type="email"]:focus {
  outline: none;
  border-color: #00ccff;
  background: #282c34;
}

/* Button in pill style to match lang-switch */
.subscribe-form button {
  padding: 8px 14px;
  border: 1px solid #00ccff;
  border-radius: 9999px;
  background: transparent;
  color: #00ccff;
  font-size: 0.95rem;
  cursor: pointer;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
}

.subscribe-form button:hover {
  background: #0099ff;
  border-color: #0099ff;
  color: #000;
}

/* Inline feedback, compact */
#subscribe-message {
  margin-left: 6px;
  font-size: 0.9rem;
  font-style: italic;
  min-height: 1em;     /* keeps layout stable before message appears */
}