/* In native (Capacitor), keep the top safe-area/header offset, but DON'T add extra left/right padding here.
   Left/right safe-area padding is handled by .table-container (so we don't double-pad in landscape). */
.cap-native .main-content {
  padding-top: calc(63.5px + var(--safe-top));
}

/* Apply font size adjustments only to main content */
.main-content {
  font-size: var(--base-font-size);
  max-width: 100%; /* Ensure main content does not exceed viewport width */
  padding-bottom: 90px; /* Slightly more than footer height to ensure visibility */
  line-height: 1.5em;
}

/* Text sections */
.text-section {
  font-size: 1em; /* Standard body text size */
}

/* Flexbox container for side-by-side layout */
.container {
  display: flex;
  max-width: 100vw; /* Prevent content from expanding beyond the viewport */
  justify-content: space-around;
  align-items: flex-start;
  margin-top: 20px;
}

/* Left and Right text sections */
.text-section {
  width: 45%; /* Set the intended width */
  max-width: 100%; /* Ensure it doesn’t exceed container width */
  display: flex;
  flex-direction: column;
}

/* Right section specific styling */
.right-section {
  align-items: flex-start;
  white-space: normal; /* Allows text to wrap naturally to the next line */
}

/* Ensure both dropdowns have the same fixed width */
select {
  font-size: 16px;
  margin-bottom: 10px;
  width: 150px;
  max-width: 200px;
}

label {
  font-size: 16px;
  margin-bottom: 5px;
  color: black;
}

/* Proportionally limit title size */
h2 {
  font-size: clamp(1.2em, calc(var(--base-font-size) * 1.4), 1.6em);
  margin-bottom: -0.5em;
  letter-spacing: 2px;
  line-height: 1.5em;
}

/* Styling for selected words */
.selected-word {
  outline: 2px solid #007BFF;
  display: inline;
}

/* Highlighting for equivalent words */
.highlight {
  background-color: var(--highlight-color);
  box-sizing: border-box;
}

.unnumbered-highlight {
  background-color: var(--unnumbered-highlight-color);
  box-sizing: border-box;
}

/* Limit notes size growth */
.notes {
  font-style: italic;
  font-size: clamp(0.8em, calc(var(--base-font-size) * 0.85), 0.8em);
  color: #6d6d6d;
  margin-top: 10px;
}

/* Styling for the footer in mini-dictionary mode */
.footer {
  display: none; /* Hidden by default */
  position: fixed;
  bottom: 0;
  width: 100%;
  height: 60px; /* viewport height */
  background-color: var(--footer-bg-color);
  padding: 10px;
  box-shadow: 0 -2px 5px rgba(0, 0, 0, 0.1);
  overflow: hidden; /* Ensures no extra scrolling */
}

.footer.footer-expanded {
  height: auto; /* allow height to expand naturally */
  overflow: visible;
}

.footer.active {
  display: block; /* Displayed when in miniDictionary mode */
  left: 0px;
}

.footer.hidden {
  display: none !important;
}

/* Hide the right section in mini-dictionary mode */
.container.single-column #rightSection {
  display: none;
}

/* Only apply full width to left section in mini-dictionary mode */
.container.single-column #leftSection {
  width: 100%;
}

/* Style for footer language selector */
.footer select {
  margin-bottom: 10px;
  width: 150px;
}

/* Style for displaying equivalent words in footer content */
.footer-content {
  color: var(--footer-text-color);
  line-height: 1.5;
  font-size: 1.5em;
}

/* Main container for the grid layout */
.table-container {
  display: block;
  padding: 63.5px calc(10px + var(--safe-right)) 70px calc(10px + var(--safe-left));
}

/* In native mode, avoid overly-large gutters in landscape while still protecting against the notch */
.cap-native .table-container {
  padding-right: max(10px, var(--safe-right));
  padding-left: max(10px, var(--safe-left));
}

.table-container.single-column {
  grid-template-columns: 1fr !important;
  padding-bottom: 70px;
}

.table-container.single-column .right-title,
.table-container.single-column .right-text,
.table-container.single-column .right-notes,
.table-container.single-column .gap {
  display: none !important; /* Hide right side and gap */
}

.table-container.single-column .left-title,
.table-container.single-column .left-text,
.table-container.single-column .left-notes {
  grid-column: 1 / -1 !important; /* Span full width */
}

/* Individual rows for title, text, and notes */
.row {
  display: grid;
  grid-template-columns: 1fr 20px 1fr;
  width: 100%;
  margin-bottom: 1em;
}

/* Apply margin to all cells */
.cell {
  margin-top: 1em;
  padding: 0;
  width: 100%;
  word-wrap: break-word;
  overflow-wrap: break-word;
  word-break: break-word;
  min-width: 0;
}

/* Remove margin from the first and last cells in each text section */
.left-text .cell:first-child,
.right-text .cell:first-child,
.left-text .cell:second-child,
.right-text .cell:second-child,
.left-text .cell:last-child,
.right-text .cell:last-child {
  margin-top: 0;
}

.author-header {
  font-size: 1.2em;
  margin-top: 32px;
  margin-bottom: 24px;
  color: #656565;
  border-bottom: 1px solid #ddd;
  border-top: 1px solid #ddd;
}

.centered-content {
  display: block; /* Ensure it is a block-level container */
  text-align: center; /* Centers text */
  margin: 0 auto; /* Centers the container */
  max-width: 100%; /* Prevent horizontal overflow */
}

.nonvisible {
  visibility: hidden;
}

.drop-zone {
  display: inline-block;
  min-width: 5em;
  border: 1px dashed gray;
  text-align: center;
  vertical-align: bottom;
  line-height: 1.3em;
}

.draggable-word {
  background-color: #eee;
  border: 1px dashed gray;
  margin: 0.3em;
  padding: 0.3em 0.6em;
  cursor: grab;
  display: inline-block;
  line-height: 1.4; /* to match reader flow */
}

.hidden-word {
  color: transparent;             /* Hide the word */
}

#footerDictionary {
  touch-action: none;
  padding-bottom: 30px;
}

.left-title,
.right-title {
  white-space: normal;
  word-wrap: break-word;
  overflow-wrap: break-word;
}
